Search in sources :

Example 51 with NullProgressMonitor

use of org.eclipse.core.runtime.NullProgressMonitor in project tdi-studio-se by Talend.

the class RemoveProjectLibsFolder method execute.

/*
     * (non-Javadoc)
     * 
     * @see org.talend.migration.IProjectMigrationTask#execute(org.talend.core.model.general.Project)
     */
@Override
public ExecutionResult execute(Project project) {
    String libsFolderName = "libs";
    IFolder libsF = null;
    try {
        IProject fsProject = ResourceUtils.getProject(project.getTechnicalLabel());
        libsF = fsProject.getFolder(libsFolderName);
        if (!libsF.exists()) {
            return ExecutionResult.NOTHING_TO_DO;
        }
        final IPath location = libsF.getLocation();
        libsFolder = new File(location.toPortableString());
        ShareProjectLibsMigration migration = new ShareProjectLibsMigration();
        migration.shareLibs(null, new NullProgressMonitor());
    } catch (PersistenceException e) {
        ExceptionHandler.process(e);
        return ExecutionResult.FAILURE;
    }
    try {
        libsF.delete(true, new NullProgressMonitor());
    } catch (CoreException e) {
        ExceptionHandler.process(e);
        return ExecutionResult.FAILURE;
    }
    return ExecutionResult.SUCCESS_NO_ALERT;
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IPath(org.eclipse.core.runtime.IPath) CoreException(org.eclipse.core.runtime.CoreException) PersistenceException(org.talend.commons.exception.PersistenceException) File(java.io.File) IProject(org.eclipse.core.resources.IProject) IFolder(org.eclipse.core.resources.IFolder)

Example 52 with NullProgressMonitor

use of org.eclipse.core.runtime.NullProgressMonitor in project tesb-studio-se by Talend.

the class PublishMetadataRunnable method getTempFile.

private File getTempFile(InputStream inputStream) throws PersistenceException, IOException, CoreException {
    Project project = ProjectManager.getInstance().getCurrentProject();
    IProject fsProject = null;
    fsProject = ResourceUtils.getProject(project);
    IPath path = new Path("temp");
    String name = File.createTempFile("tESBConsumer", ".wsdl").getName();
    path = path.append(name);
    IFile file = fsProject.getFile(path);
    file.create(inputStream, false, new NullProgressMonitor());
    return new File(file.getLocation().toPortableString());
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.core.runtime.Path) Project(org.talend.core.model.general.Project) IProject(org.eclipse.core.resources.IProject) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IFile(org.eclipse.core.resources.IFile) IPath(org.eclipse.core.runtime.IPath) IFile(org.eclipse.core.resources.IFile) File(java.io.File) IProject(org.eclipse.core.resources.IProject)

Example 53 with NullProgressMonitor

use of org.eclipse.core.runtime.NullProgressMonitor in project tdi-studio-se by Talend.

the class BuildJobManager method buildJobs.

public boolean buildJobs(String destinationPath, List<? extends IRepositoryNode> nodes, List<String> topNames, String version, String context, Map<ExportChoice, Object> exportChoiceMap, JobExportType jobExportType, IProgressMonitor monitor) throws Exception {
    IProgressMonitor pMonitor = new NullProgressMonitor();
    if (monitor != null) {
        pMonitor = monitor;
    }
    final List<ProcessItem> processes = getProcesses(nodes);
    if (processes.size() == 1) {
        ProcessItem item = processes.get(0);
        buildJob(destinationPath, item, version, context, exportChoiceMap, jobExportType, pMonitor);
    } else {
        int scale = 1000;
        int steps = 3;
        pMonitor.beginTask(Messages.getString("JobScriptsExportWizardPage.newExportJobScript", jobExportType), //$NON-NLS-1$
        steps * scale * nodes.size());
        String topName = null;
        if (topNames != null && !topNames.isEmpty()) {
            topName = topNames.get(0);
        } else {
            topName = ProjectManager.getInstance().getCurrentProject().getLabel();
        }
        File desFile = new File(destinationPath);
        //$NON-NLS-1$ //$NON-NLS-2$
        File createTempFile = File.createTempFile("building_job", "");
        createTempFile.delete();
        File tempFolder = new File(desFile.getParent() + File.separator + createTempFile.getName());
        if (tempFolder.exists()) {
            tempFolder.delete();
        }
        File tempProFolder = new File(tempFolder, topName);
        tempProFolder.mkdirs();
        for (int i = 0; i < processes.size(); i++) {
            ProcessItem processItem = processes.get(i);
            //$NON-NLS-1$
            pMonitor.setTaskName(Messages.getString("BuildJobManager.building", processItem.getProperty().getLabel()));
            IBuildJobHandler buildJobHandler = BuildJobFactory.createBuildJobHandler(processItem, context, processItem.getProperty().getVersion(), exportChoiceMap, jobExportType);
            buildJobHandler.generateItemFiles(true, new SubProgressMonitor(pMonitor, scale));
            buildJobHandler.generateJobFiles(new SubProgressMonitor(pMonitor, scale));
            buildJobHandler.build(new SubProgressMonitor(pMonitor, scale));
            IFile jobTargetFile = buildJobHandler.getJobTargetFile();
            if (jobTargetFile != null && jobTargetFile.exists()) {
                // unzip to temp folder
                FilesUtils.unzip(jobTargetFile.getLocation().toPortableString(), tempProFolder.getAbsolutePath());
                String zipPath = jobTargetFile.getLocation().toPortableString();
                if (needClasspathJar(exportChoiceMap)) {
                    JavaJobExportReArchieveCreator creator = new JavaJobExportReArchieveCreator(zipPath, processItem.getProperty().getLabel());
                    creator.setTempFolder(tempFolder.getAbsolutePath());
                    creator.buildNewJar();
                }
            }
            pMonitor.worked(scale);
        }
        FilesUtils.zip(tempFolder.getAbsolutePath(), destinationPath);
        FilesUtils.deleteFile(tempFolder, true);
        pMonitor.done();
    }
    return true;
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) IFile(org.eclipse.core.resources.IFile) ProcessItem(org.talend.core.model.properties.ProcessItem) IBuildJobHandler(org.talend.core.runtime.process.IBuildJobHandler) JavaJobExportReArchieveCreator(org.talend.repository.ui.wizards.exportjob.JavaJobExportReArchieveCreator) ZipToFile(org.talend.repository.ui.utils.ZipToFile) IFile(org.eclipse.core.resources.IFile) File(java.io.File) SubProgressMonitor(org.eclipse.core.runtime.SubProgressMonitor)

Example 54 with NullProgressMonitor

use of org.eclipse.core.runtime.NullProgressMonitor in project tdi-studio-se by Talend.

the class BigDataEeImportTest method importEeDemo.

@Before
public void importEeDemo() throws Exception {
    initDemo(BIG_DATA_EE_DEMO_PLUGIN_ID);
    Assert.assertNotNull(currentDemo);
    initTestPaths();
    initTempPro();
    eeResManager = DemoImportTestUtil.getResourceManager(currentDemo);
    Assert.assertNotNull(eeResManager);
    ImportExportHandlersManager importManager = new ImportExportHandlersManager();
    List<ImportItem> projectRecords = importManager.populateImportingItems(eeResManager, true, new NullProgressMonitor());
    Assert.assertTrue(projectRecords.size() > 0);
    importManager.importItemRecords(new NullProgressMonitor(), eeResManager, projectRecords, true, projectRecords.toArray(new ImportItem[0]), null);
}
Also used : ImportExportHandlersManager(org.talend.repository.items.importexport.handlers.ImportExportHandlersManager) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) ImportItem(org.talend.repository.items.importexport.handlers.model.ImportItem) Before(org.junit.Before)

Example 55 with NullProgressMonitor

use of org.eclipse.core.runtime.NullProgressMonitor in project tdi-studio-se by Talend.

the class BigdataCeImportTest method importCeDemo.

@Before
public void importCeDemo() throws Exception {
    initDemo(BIG_DATA_CE_DEMO_PLUGIN_ID);
    if (currentDemo == null) {
        // maybe license problem, the demo plugin is not loaded.
        return;
    }
    initTestPaths();
    initTempPro();
    Assert.assertNotNull(currentDemo);
    ceResManager = DemoImportTestUtil.getResourceManager(currentDemo);
    Assert.assertNotNull(ceResManager);
    ImportExportHandlersManager importManager = new ImportExportHandlersManager();
    List<ImportItem> projectRecords = importManager.populateImportingItems(ceResManager, true, new NullProgressMonitor());
    Assert.assertTrue(projectRecords.size() > 0);
    importManager.importItemRecords(new NullProgressMonitor(), ceResManager, projectRecords, true, projectRecords.toArray(new ImportItem[0]), null);
}
Also used : ImportExportHandlersManager(org.talend.repository.items.importexport.handlers.ImportExportHandlersManager) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) ImportItem(org.talend.repository.items.importexport.handlers.model.ImportItem) Before(org.junit.Before)

Aggregations

NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)1614 CoreException (org.eclipse.core.runtime.CoreException)416 Test (org.junit.Test)382 IFile (org.eclipse.core.resources.IFile)342 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)267 IProject (org.eclipse.core.resources.IProject)258 File (java.io.File)205 IPath (org.eclipse.core.runtime.IPath)182 IOException (java.io.IOException)153 Path (org.eclipse.core.runtime.Path)132 ArrayList (java.util.ArrayList)122 IStatus (org.eclipse.core.runtime.IStatus)113 IFolder (org.eclipse.core.resources.IFolder)87 ICompilationUnit (org.eclipse.jdt.core.ICompilationUnit)69 SubProgressMonitor (org.eclipse.core.runtime.SubProgressMonitor)63 InvocationTargetException (java.lang.reflect.InvocationTargetException)60 List (java.util.List)59 IProjectDescription (org.eclipse.core.resources.IProjectDescription)57 IType (org.eclipse.jdt.core.IType)57 Status (org.eclipse.core.runtime.Status)55