Java Code Examples for org.eclipse.ui.progress.IProgressService#run()

The following examples show how to use org.eclipse.ui.progress.IProgressService#run() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DeployApplicationAction.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
public int deployApplicationNodeContainer(Shell shell, ApplicationNodeContainer applicationNodeContainer,
        String[] onFinishButtons) {
    if (applicationNodeContainer.getApplications().isEmpty()) {
        MessageDialog.openInformation(shell, Messages.deployDoneTitle, Messages.nothingToDeploy);
        return Dialog.CANCEL;
    }
    final GetApiSessionOperation apiSessionOperation = new GetApiSessionOperation();
    try {
        final APISession apiSession = apiSessionOperation.execute();
        final ApplicationAPI applicationAPI = BOSEngineManager.getInstance().getApplicationAPI(apiSession);
        final IProgressService progressService = PlatformUI.getWorkbench().getProgressService();
        final DeployApplicationDescriptorOperation deployOperation = getDeployOperation(apiSession, applicationAPI,
                applicationNodeContainer);
        progressService.run(true, false, deployOperation);
        return openStatusDialog(shell, deployOperation, onFinishButtons);
    } catch (InvocationTargetException | InterruptedException | BonitaHomeNotSetException | ServerAPIException
            | UnknownAPITypeException e) {
        new ExceptionDialogHandler().openErrorDialog(shell, Messages.deployFailedTitle, e);
        return Dialog.CANCEL;
    } finally {
        apiSessionOperation.logout();
    }
}
 
Example 2
Source File: ConnectorConfigurationWizardPage.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
protected void checkImplementationDependencies(final ConnectorImplementation implementation) {
    if(!implementation.getJarDependencies().getJarDependency().isEmpty()){
        try {
            final IProgressService service =  PlatformUI.getWorkbench().getProgressService() ;
            service.run(true, false, new IRunnableWithProgress() {

                @Override
                public void run(final IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
                    monitor.beginTask(Messages.addingImplementationDependencies, IProgressMonitor.UNKNOWN) ;
                    final DependencyRepositoryStore depStore = RepositoryManager.getInstance().getRepositoryStore(DependencyRepositoryStore.class) ;
                    for(final String jarName : implementation.getJarDependencies().getJarDependency()){
                        if( depStore.getChild(jarName, true) == null){
                            final InputStream is = getResourceProvider().getDependencyInputStream(jarName) ;
                            if(is != null){
                                depStore.importInputStream(jarName, is) ;
                            }
                        }
                    }
                }
            }) ;
        } catch (final Exception e){
            BonitaStudioLog.error(e) ;
        }
    }
}
 
Example 3
Source File: ConfigurationWizard.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
public void setProcess(final AbstractProcess process) {
    this.process = process;
    final Configuration configuration = getConfigurationFromProcess(process, configurationName);
    if (configuration != null) {
        final IProgressService service = PlatformUI.getWorkbench().getProgressService();
        try {
            service.run(true, false, new IRunnableWithProgress() {

                @Override
                public void run(final IProgressMonitor monitor) throws InvocationTargetException,
                        InterruptedException {
                    new ConfigurationSynchronizer(process, configuration).synchronize(monitor);
                }
            });
        } catch (final InvocationTargetException | InterruptedException e) {
            BonitaStudioLog.error(e);
        }
        configurationWorkingCopy = emfModelUpdater.from(configuration).getWorkingCopy();
    }
}
 
Example 4
Source File: UIDesignerWorkspaceIntegrationIT.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
@Test
public void create_a_new_page_should_trigger_a_refresh_on_a_page_filestore() throws Exception {
    waitForServer();
    RepositoryAccessor repositoryAccessor = new RepositoryAccessor();
    repositoryAccessor.init();
    final CreateFormOperation createFormOperation = new CreateFormOperation(new PageDesignerURLFactory(
            InstanceScope.INSTANCE.getNode(BonitaStudioPreferencesPlugin.PLUGIN_ID)), repositoryAccessor);
    createFormOperation.setArtifactName("MyNewForm");
    final IProgressService service = PlatformUI.getWorkbench().getProgressService();
    service.run(true, false, createFormOperation);

    final WebPageRepositoryStore repositoryStore = RepositoryManager.getInstance()
            .getRepositoryStore(WebPageRepositoryStore.class);
    newPageResource = repositoryStore.getChild(createFormOperation.getNewArtifactId(), true).getResource()
            .getFile(createFormOperation.getNewArtifactId() + ".json");
    assertThat(newPageResource.exists()).overridingErrorMessage(
            "Workspace should be in sync with new page file").isTrue();
}
 
Example 5
Source File: AddJarsHandler.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
@Override
public Object execute(final ExecutionEvent event) throws ExecutionException {

    final FileDialog fd = new FileDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), SWT.OPEN | SWT.MULTI);
    fd.setFilterExtensions(new String[] { "*.jar;*.zip" });
    if (filenames != null) {
        fd.setFilterNames(filenames);
    }
    if (fd.open() != null) {
        final DependencyRepositoryStore libStore = RepositoryManager.getInstance().getRepositoryStore(DependencyRepositoryStore.class);
        final String[] jars = fd.getFileNames();
        final IProgressService progressManager = PlatformUI.getWorkbench().getProgressService();
        final IRunnableWithProgress runnable = new ImportLibsOperation(libStore, jars, fd.getFilterPath());

        try {

            progressManager.run(true, false, runnable);
            progressManager.run(true, false, new IRunnableWithProgress() {

                @Override
                public void run(final IProgressMonitor monitor) throws InvocationTargetException,
                        InterruptedException {
                    RepositoryManager.getInstance().getCurrentRepository().build(monitor);
                }
            });
        } catch (final InvocationTargetException e1) {
            BonitaStudioLog.error(e1);
            if (e1.getCause() != null && e1.getCause().getMessage() != null) {
                MessageDialog.openError(Display.getDefault().getActiveShell(), org.bonitasoft.studio.dependencies.i18n.Messages.importJar, e1.getCause()
                        .getMessage());
            }
        } catch (final InterruptedException e2) {
            BonitaStudioLog.error(e2);
        }

    }
    return fd.getFileNames();
}
 
Example 6
Source File: ImportConnectorHandler.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    try {
        final FileDialog fileDialog = new FileDialog(Display.getDefault().getActiveShell(), SWT.OPEN);
        fileDialog.setFilterExtensions(new String[] { "*.zip" });
        fileDialog.setText(getDialogTitle());
        final String fileName = fileDialog.open();
        if (fileName != null) {
            final IProgressService service = PlatformUI.getWorkbench().getProgressService();
            final ImportConnectorArchiveOperation importOp = newImportOperation();
            importOp.setFile(new File(fileName));
            service.run(true, false, importOp);
            final IStatus status = importOp.getStatus();
            switch (status.getSeverity()) {
                case IStatus.OK:
                    MessageDialog.openInformation(Display.getDefault().getActiveShell(), getImportSuccessTitle(), getImportSuccessMessage());
                    break;
                case IStatus.WARNING:
                    MessageDialog.openWarning(Display.getDefault().getActiveShell(), getImportSuccessTitle(), status.getMessage());
                    break;
                case IStatus.ERROR:
                    MessageDialog.openError(Display.getDefault().getActiveShell(), getFailedImportTitle(),
                            Messages.bind(getFailedImportMessage(), status.getMessage()));
                    break;
                default:
                    break;
            }
        }
        return null;
    } catch (final Exception ex) {
        throw new ExecutionException(ex.getMessage(), ex);
    }
}
 
Example 7
Source File: DuplicateDiagramAction.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
public void duplicate(MainProcess diagram) {
    String newProcessLabel = diagram.getName();
    String newProcessVersion = diagram.getVersion();
    DiagramRepositoryStore diagramRepositoryStore = repositoryAccessor.getRepositoryStore(DiagramRepositoryStore.class);
    final OpenNameAndVersionForDiagramDialog dialog = new OpenNameAndVersionForDiagramDialog(
            Display.getDefault().getActiveShell(),
            diagram, diagramRepositoryStore);
    dialog.forceNameUpdate();
    if (dialog.open() == Dialog.OK) {
        final Identifier identifier = dialog.getIdentifier();
        newProcessLabel = identifier.getName();
        newProcessVersion = dialog.getIdentifier().getVersion();
        List<ProcessesNameVersion> pools = dialog.getPools();
        final DuplicateDiagramOperation op = new DuplicateDiagramOperation();
        op.setDiagramToDuplicate(diagram);
        op.setNewDiagramName(newProcessLabel);
        op.setNewDiagramVersion(newProcessVersion);
        op.setPoolsRenamed(pools);
        final IProgressService service = PlatformUI.getWorkbench().getProgressService();
        try {
            service.run(true, false, op);
        } catch (InvocationTargetException | InterruptedException e) {
            throw new RuntimeException(e.getMessage(), e);
        }
        DiagramFileStore store = diagramRepositoryStore.getDiagram(newProcessLabel, newProcessVersion);
        store.open();
    }
}
 
Example 8
Source File: CreateLayoutHandler.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
@Execute
public void createLayout(@Named(IServiceConstants.ACTIVE_SHELL) Shell shell, PageDesignerURLFactory urlFactory,
        RepositoryAccessor repositoryAccessor) {
    CreateLayoutOperation operation = new CreateLayoutOperation(urlFactory, repositoryAccessor);
    IProgressService progressService = PlatformUI.getWorkbench().getProgressService();
    try {
        progressService.run(true, false, operation);
    } catch (InvocationTargetException | InterruptedException e) {
        new ExceptionDialogHandler().openErrorDialog(shell, Messages.createLayoutFailed, e);
    }
}
 
Example 9
Source File: CreatePageHandler.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
@Execute
public void createPage(@Named(IServiceConstants.ACTIVE_SHELL) Shell shell, PageDesignerURLFactory urlFactory,
        RepositoryAccessor repositoryAccessor) {
    CreatePageOperation operation = new CreatePageOperation(urlFactory, repositoryAccessor);
    IProgressService progressService = PlatformUI.getWorkbench().getProgressService();
    try {
        progressService.run(true, false, operation);
    } catch (InvocationTargetException | InterruptedException e) {
        new ExceptionDialogHandler().openErrorDialog(shell, Messages.createPageFailed, e);
    }
}
 
Example 10
Source File: RnContentProvider.java    From elexis-3-core with Eclipse Public License 1.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
public Object[] getElements(final Object inputElement){
	IProgressService progressService = PlatformUI.getWorkbench().getProgressService();
	try {
		progressService.run(true, true, new IRunnableWithProgress() {
			
			@Override
			public void run(final IProgressMonitor monitor){
				reload(monitor);
				if (monitor.isCanceled()) {
					monitor.done();
				}
				
				rlv.getSite().getShell().getDisplay().syncExec(new Runnable() {
					@Override
					public void run(){
						InvoiceListBottomComposite invoiceListeBottomComposite =
							rlv.getInvoiceListeBottomComposite();
						if (invoiceListeBottomComposite != null) {
							invoiceListeBottomComposite.update(Integer.toString(iPat),
								Integer.toString(iRn), mAmount.getAmountAsString(),
								mOpen.getAmountAsString());
						}
					}
				});
			}
		});
	} catch (Throwable ex) {
		ExHandler.handle(ex);
	}
	
	return result == null ? new Tree[0] : result;
}
 
Example 11
Source File: App.java    From olca-app with Mozilla Public License 2.0 5 votes vote down vote up
public static void runWithProgress(String name, Runnable runnable) {
	IProgressService progress = PlatformUI.getWorkbench()
			.getProgressService();
	try {
		progress.run(true, false, (monitor) -> {
			monitor.beginTask(name, IProgressMonitor.UNKNOWN);
			runnable.run();
			monitor.done();
		});
	} catch (InvocationTargetException | InterruptedException e) {
		log.error("Error while running progress " + name, e);
	}
}
 
Example 12
Source File: WorkbenchOperationExecutor.java    From goclipse with Eclipse Public License 1.0 4 votes vote down vote up
protected void doRunRunnableWithProgress(IRunnableWithProgress progressRunnable)
		throws InvocationTargetException, InterruptedException {
	IProgressService progressService = PlatformUI.getWorkbench().getProgressService();
	progressService.run(!executeInUIOnly, true, progressRunnable);
}