Example usage for org.eclipse.jface.operation IRunnableWithProgress run

List of usage examples for org.eclipse.jface.operation IRunnableWithProgress run

Introduction

In this page you can find the example usage for org.eclipse.jface.operation IRunnableWithProgress run.

Prototype

public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException;

Source Link

Document

Runs this operation.

Usage

From source file:org.talend.camel.designer.runprocess.maven.BundleJavaProcessor.java

License:Open Source License

@Override
public void generatePom(int option) {
    if (option == TalendProcessOptionConstants.GENERATE_IS_MAINJOB) {
        super.generatePom(option);
        try {// ww  w . j a v  a 2  s.  c o  m
            IRepositoryObject repositoryObject = new RepositoryObject(getProperty());

            // Fix TESB-22660: Avoide to operate repo viewer before it open
            if (PlatformUI.isWorkbenchRunning()) {
                RepositorySeekerManager.getInstance().searchRepoViewNode(getProperty().getId(), false);
            }

            IRunnableWithProgress action = new JavaCamelJobScriptsExportWSAction(repositoryObject,
                    getProperty().getVersion(), "", false);
            action.run(new NullProgressMonitor());
        } catch (Exception e) {
            ExceptionHandler.process(e);
        }
    }
}

From source file:org.talend.dataprofiler.core.download.AbstractDQMissingJarsExtraUpdatesFactory.java

License:Open Source License

private boolean runNotInstallModule(SubMonitor mainSubMonitor,
        IRunnableWithProgress notInstalledModulesRunnable) {
    if (notInstalledModulesRunnable == null) {
        return false;
    }//from  w ww  .ja va 2s. c o m
    try {
        notInstalledModulesRunnable.run(mainSubMonitor.newChild(1));
        return true;
    } catch (InvocationTargetException e) {
        log.error("failed to fetch missing third parties jars information for " + getJarFileNames().get(0), e); //$NON-NLS-1$
        return false;
    } catch (InterruptedException e) {
        log.error("failed to fetch missing third parties jars information" + getJarFileNames().get(0), e); //$NON-NLS-1$
        return false;
    }
}

From source file:org.talend.dataprofiler.core.ui.views.DQRespositoryView.java

License:Open Source License

public DQRespositoryView() {
    super();//from w  w  w  . jav a  2  s .c  o m

    // MOD qiongli 2010-9-7,bug 14698,add 'try...catch'
    try {

        RepositoryWorkUnit<Object> dQRepositoryWorkUnit = new RepositoryWorkUnit<Object>(
                "Create DQ Repository structure") { //$NON-NLS-1$

            @Override
            protected void run() {
                final IWorkspaceRunnable op = new IWorkspaceRunnable() {

                    public void run(IProgressMonitor monitor) throws CoreException {
                        manager = DQStructureManager.getInstance();
                        if (manager.isNeedCreateStructure()) {
                            manager.createDQStructure();
                        }
                    }
                };
                IRunnableWithProgress iRunnableWithProgress = new IRunnableWithProgress() {

                    public void run(final IProgressMonitor monitor)
                            throws InvocationTargetException, InterruptedException {
                        IWorkspace workspace = ResourcesPlugin.getWorkspace();
                        try {
                            ISchedulingRule schedulingRule = workspace.getRoot();
                            // the update the project files need to be done in the workspace runnable to
                            // avoid all notification of changes before the end of the modifications.
                            workspace.run(op, schedulingRule, IWorkspace.AVOID_UPDATE, monitor);
                        } catch (CoreException e) {
                            throw new InvocationTargetException(e);
                        }

                    }
                };

                try {
                    // do not use the UI related
                    iRunnableWithProgress.run(new NullProgressMonitor());
                } catch (Exception e) {
                    ExceptionHandler.process(e);
                }

            }
        };
        // TDQ-11267 by zshen ForceTransaction attribute make sure TDQ folder can be commit on the server
        dQRepositoryWorkUnit.setAvoidUnloadResources(true);
        dQRepositoryWorkUnit.setUnloadResourcesAfterRun(true);
        dQRepositoryWorkUnit.setFilesModifiedOutsideOfRWU(true);
        dQRepositoryWorkUnit.setForceTransaction(true);
        ProxyRepositoryFactory.getInstance().executeRepositoryWorkUnit(dQRepositoryWorkUnit);

        if (manager.isNeedMigration()) {

            // TDQ-12154 commit all once after all migrations done.
            RepositoryWorkUnit<Object> workUnit = new RepositoryWorkUnit<Object>(
                    "Migration for DQ Repository") { //$NON-NLS-1$

                @Override
                protected void run() {
                    final IWorkspaceRunnable op = new IWorkspaceRunnable() {

                        public void run(IProgressMonitor monitor) throws CoreException {
                            ProductVersion wVersion = WorkspaceVersionHelper.getVesion();
                            new MigrationTaskManager(wVersion).doMigrationTask(monitor);
                        }
                    };
                    IRunnableWithProgress iRunnableWithProgress = new IRunnableWithProgress() {

                        public void run(final IProgressMonitor monitor)
                                throws InvocationTargetException, InterruptedException {
                            IWorkspace workspace = ResourcesPlugin.getWorkspace();
                            try {
                                ISchedulingRule schedulingRule = workspace.getRoot();
                                // the update the project files need to be done in the workspace runnable to
                                // avoid all notification of changes before the end of the modifications.
                                workspace.run(op, schedulingRule, IWorkspace.AVOID_UPDATE, monitor);
                            } catch (CoreException e) {
                                throw new InvocationTargetException(e);
                            }

                        }
                    };

                    try {
                        // need to display the progress on UI
                        ProgressUI.popProgressDialog(iRunnableWithProgress);
                    } catch (Exception e) {
                        ExceptionHandler.process(e);
                    }

                }
            };

            workUnit.setAvoidUnloadResources(true);
            ProxyRepositoryFactory.getInstance().executeRepositoryWorkUnit(workUnit);

        }
    } catch (Exception e) {
        log.error(e, e);
    }
}

From source file:org.talend.librariesmanager.utils.ModulesInstaller.java

License:Open Source License

public static void installModules(final Shell shell, final String[] jarNames) {
    final List<ModuleToInstall> toInstall = new ArrayList<ModuleToInstall>();
    final IRunnableWithProgress rwp = RemoteModulesHelper.getInstance().getNotInstalledModulesRunnable(jarNames,
            toInstall);//from  ww  w .  j  a  va  2 s  . co m
    if (rwp != null) {
        Job job = new Job(Messages.getString("RemoteModulesHelper.job.title")) {//$NON-NLS-1$

            @Override
            protected IStatus run(IProgressMonitor progressMonitor) {
                try {
                    rwp.run(progressMonitor);
                } catch (InvocationTargetException e) {
                    log.warn("fetching remote Modules data failed", e); //$NON-NLS-1$
                    return Status.CANCEL_STATUS;
                } catch (InterruptedException e) {
                    log.warn("fetching remote Modules data failed", e); //$NON-NLS-1$
                    return Status.CANCEL_STATUS;
                }
                return Status.OK_STATUS;
            }
        };

        job.setUser(true);
        job.setPriority(Job.INTERACTIVE);
        job.schedule();
        try {
            job.join();
        } catch (InterruptedException e) {
            log.error(e.getMessage(), e);
        }
    }
    if (!toInstall.isEmpty()) {
        Display.getDefault().syncExec(new Runnable() {

            @Override
            public void run() {
                String text = Messages.getString("ModulesInstaller_text"); //$NON-NLS-1$
                String title = Messages.getString("ModulesInstaller_title"); //$NON-NLS-1$
                ExternalModulesInstallDialogWithProgress dialog = new ExternalModulesInstallDialogWithProgress(
                        shell, text, title, SWT.APPLICATION_MODAL);
                dialog.showDialog(true, jarNames);
            }
        });
    }
}

From source file:org.talend.librariesmanager.utils.RemoteModulesHelperTest.java

License:Open Source License

/**
 * Test method for//w w  w.  j  a v a 2 s.c  o  m
 * {@link org.talend.librariesmanager.utils.RemoteModulesHelper#getNotInstalledModulesRunnable(java.util.List, java.util.List, boolean)}
 * .
 * 
 * @throws InterruptedException
 * @throws InvocationTargetException
 */
@Test
public void testGetNotInstalledModulesRunnableListOfModuleNeededListOfModuleToInstallBoolean()
        throws InvocationTargetException, InterruptedException {
    List<ModuleNeeded> neededModules = new ArrayList<ModuleNeeded>();
    ModuleNeeded m1 = new ModuleNeeded("tMysqlInput", "mysql.jar", "", true, null, null,
            "mvn:org.talend.libraries/mysql/6.0.0");
    ModuleNeeded m2 = new ModuleNeeded("tMysqlInput", "mysql.jar", "", true, null, null,
            "mvn:org.talend.libraries/mysql/6.1.0");
    ModuleNeeded m3 = new ModuleNeeded("tMyComponent1", "test.jar", "", true, null, null,
            "mvn:org.talend.libraries/test/6.0.0");
    ModuleNeeded m4 = new ModuleNeeded("tMyComponent2", "test.jar", "", true, null, null,
            "mvn:org.talend.libraries/test/6.0.0");
    ModuleNeeded m5 = new ModuleNeeded("tMyComponent3", "test.exe", "", true, null, null,
            "mvn:org.talend.libraries/test/6.0.0");
    neededModules.add(m1);
    neededModules.add(m2);
    neededModules.add(m3);
    neededModules.add(m4);
    neededModules.add(m5);
    List<ModuleToInstall> toInstall1 = new ArrayList<ModuleToInstall>();
    IRunnableWithProgress notInstalledModulesRunnable = RemoteModulesHelper.getInstance()
            .getNotInstalledModulesRunnable(neededModules, toInstall1, false);
    notInstalledModulesRunnable.run(new NullProgressMonitor());
    assertEquals(4, toInstall1.size());
    for (int i = 0; i < toInstall1.size(); i++) {
        final ModuleToInstall m = toInstall1.get(i);
        switch (i) {
        case 0:
            assertEquals(m.getName(), "mysql.jar");
            assertEquals(m.getMavenUri(), "mvn:org.talend.libraries/mysql/6.0.0/jar");
            assertEquals(m.getContext(), "tMysqlInput");
            break;
        case 1:
            assertEquals(m.getName(), "mysql.jar");
            assertEquals(m.getMavenUri(), "mvn:org.talend.libraries/mysql/6.1.0/jar");
            assertEquals(m.getContext(), "tMysqlInput");
            break;
        case 2:
            assertEquals(m.getName(), "test.exe");
            assertEquals(m.getMavenUri(), "mvn:org.talend.libraries/test/6.0.0/exe");
            assertEquals(m.getContext(), "tMyComponent3");
            break;
        case 3:
            assertEquals(m.getName(), "test.jar");
            assertEquals(m.getMavenUri(), "mvn:org.talend.libraries/test/6.0.0/jar");
            assertEquals(m.getContext(), "tMyComponent1 | tMyComponent2");
            break;
        }
    }

}

From source file:org.talend.mdm.repository.core.service.ConsoleProgressService.java

License:Open Source License

public void run(boolean fork, boolean cancelable, IRunnableWithProgress runnable)
        throws InvocationTargetException, InterruptedException {
    runnable.run(new NullProgressMonitor());

}

From source file:org.talend.sqlbuilder.util.UIUtils.java

License:Open Source License

/**
 * DOC dev Comment method "runWithProgress".
 * //ww  w .java  2 s  .co m
 * @param operation
 * @param fork
 * @param monitor
 * @param shell
 */
public static void runWithProgress(final IRunnableWithProgress operation, final boolean fork,
        final IProgressMonitor monitor, final Shell shell) {
    final IRunnableWithProgress progress = new IRunnableWithProgress() {

        @Override
        public void run(final IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
            // monitor.beginTask("test task", scale * total);
            // SubProgressMonitor sm = new SubProgressMonitor(monitor, 1 * scale);
            Thread t = new Thread() {

                @Override
                public void run() {
                    try {
                        operation.run(monitor);
                    } catch (Exception e) {
                        SqlBuilderPlugin.log(Messages.getString("UIUtils.logMessage1"), e); //$NON-NLS-1$
                    }
                }
            };
            t.start();
            try {
                t.join();
            } catch (Exception e) {
                // TODO: handle exception
            }
        }
    };

    Runnable run = new Runnable() {

        @Override
        public void run() {
            try {
                ModalContext.run(progress, fork, monitor, shell.getDisplay());
            } catch (Exception e) {
                SqlBuilderPlugin.log(Messages.getString("UIUtils.logMessage2"), e); //$NON-NLS-1$
            }
        }
    };

    BusyIndicator.showWhile(Display.getDefault(), run);
}

From source file:org.talend.updates.runtime.engine.factory.PluginOptionalMissingJarsExtraUpdatesFactory.java

License:Open Source License

@Override
public void retrieveUninstalledExtraFeatures(IProgressMonitor monitor,
        Set<ExtraFeature> uninstalledExtraFeatures) throws Exception {

    SubMonitor mainSubMonitor = SubMonitor.convert(monitor, 2);
    List<ModuleNeeded> unistalledModulesNeeded = ModulesNeededProvider
            .filterOutRequiredModulesForBundle(ModulesNeededProvider.getUnistalledModulesNeeded());
    if (monitor.isCanceled()) {
        return;//  w w w .  j a  va 2  s. c  o  m
    } // else keep going
    mainSubMonitor.worked(1);
    if (!unistalledModulesNeeded.isEmpty()) {

        // fetch missing jar information from remote web site.
        ArrayList<ModuleToInstall> modulesRequiredToBeInstalled = new ArrayList<ModuleToInstall>();
        // IRunnableWithProgress should not be part of
        // jface because it adds graphical
        // dependencies.
        IRunnableWithProgress notInstalledModulesRunnable = RemoteModulesHelper.getInstance()
                .getNotInstalledModulesRunnable(unistalledModulesNeeded, modulesRequiredToBeInstalled, true);
        if (notInstalledModulesRunnable != null) {// some data need to be fetched
            try {
                notInstalledModulesRunnable.run(mainSubMonitor.newChild(1));
            } catch (InvocationTargetException e) {
                log.error("failed to fetch missing third parties jars information", e); //$NON-NLS-1$
                return;
            } catch (InterruptedException e) {
                log.error("failed to fetch missing third parties jars information", e); //$NON-NLS-1$
                return;
            }
        } // else all data already fetched so keep going
        if (mainSubMonitor.isCanceled()) {
            return;
        } // else keep going.
        ArrayList<ModuleToInstall> modulesForAutomaticInstall = TalendWebServiceUpdateExtraFeature
                .filterAllAutomaticInstallableModules(modulesRequiredToBeInstalled);
        if (modulesForAutomaticInstall.isEmpty()) {
            return;
        } else {
            addToSet(uninstalledExtraFeatures,
                    new TalendWebServiceUpdateExtraFeature(modulesForAutomaticInstall,
                            Messages.getString("missing.optional.third.parties.libs.feature.name"), Messages //$NON-NLS-1$
                                    .getString("missing.optional.third.parties.libs.feature.description"), //$NON-NLS-1$
                            false/* mustInstall */));
        }
    } // else nothing to install so nothing to install ;)

}

From source file:org.talend.updates.runtime.engine.factory.PluginRequiredMissingJarsExtraUpdatesFactory.java

License:Open Source License

@Override
public void retrieveUninstalledExtraFeatures(IProgressMonitor monitor,
        Set<ExtraFeature> uninstalledExtraFeatures) throws Exception {

    SubMonitor mainSubMonitor = SubMonitor.convert(monitor, 2);

    // get all misssing jars
    List<ModuleNeeded> allUninstalledModules = ModulesNeededProvider
            .getAllNoInstalledModulesNeededExtensionsForPlugin(mainSubMonitor.newChild(1));
    if (monitor.isCanceled()) {
        return;//from   www . j a  v  a  2  s  .c  om
    } // else keep going
      // fetch missing jar information from remote web site.
    ArrayList<ModuleToInstall> modulesRequiredToBeInstalled = new ArrayList<ModuleToInstall>();
    IRunnableWithProgress notInstalledModulesRunnable = RemoteModulesHelper.getInstance()
            .getNotInstalledModulesRunnable(allUninstalledModules, modulesRequiredToBeInstalled, true);// IRunnableWithProgress should not be part
                                                                                                                                                                                            // of
                                                                                                                                                                                            // jface because it adds graphical
                                                                                                                                                                                            // dependencies.
    if (notInstalledModulesRunnable != null) {// some data need to be fetched
        try {
            notInstalledModulesRunnable.run(mainSubMonitor.newChild(1));
        } catch (InvocationTargetException e) {
            log.error("failed to fetch missing third parties jars information", e); //$NON-NLS-1$
            return;
        } catch (InterruptedException e) {
            log.error("failed to fetch missing third parties jars information", e); //$NON-NLS-1$
            return;
        }
    } // else all data already fetched so keep going
    if (mainSubMonitor.isCanceled()) {
        return;
    } // else keep going.
    ArrayList<ModuleToInstall> modulesForAutomaticInstall = TalendWebServiceUpdateExtraFeature
            .filterAllAutomaticInstallableModules(modulesRequiredToBeInstalled);
    if (modulesForAutomaticInstall.isEmpty()) {
        return;
    } else {
        addToSet(uninstalledExtraFeatures,
                new TalendWebServiceUpdateExtraFeature(modulesForAutomaticInstall,
                        Messages.getString("missing.third.parties.libs.feature.name"), Messages //$NON-NLS-1$
                                .getString("missing.third.parties.libs.feature.description"), //$NON-NLS-1$
                        true/* mustInstall */));
    }

}

From source file:org.talend.updates.runtime.ui.feature.form.item.AbstractFeatureListInfoItem.java

License:Open Source License

protected void executeInstall(IProgressMonitor monitor, boolean runInModelContext) {
    try {//w  ww .j av  a 2  s. com
        preInstall(monitor);
        IFeatureItem featureItem = getFeatureItem();
        IRunnableWithProgress installProgress = new IRunnableWithProgress() {

            @Override
            public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
                installFeature(monitor, featureItem);
            }
        };
        if (runInModelContext) {
            getCheckListener().run(true, true, installProgress);
        } else {
            installProgress.run(monitor);
        }
        afterInstalled(monitor);
    } catch (Exception e) {
        ExceptionHandler.process(e);
    }
}