org.eclipse.ui.progress.IProgressService Java Examples

The following examples show how to use org.eclipse.ui.progress.IProgressService. 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: DeployArtifactsHandler.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
@Execute
public void deploy(@Named(IServiceConstants.ACTIVE_SHELL) Shell activeShell,
        RepositoryAccessor repositoryAccessor, IProgressService progressService)
        throws InvocationTargetException, InterruptedException {

    progressService.busyCursorWhile(monitor -> {
        repositoryModel = new RepositoryModelBuilder().create(repositoryAccessor);
    });

    SelectArtifactToDeployPage page = new SelectArtifactToDeployPage(repositoryModel,
            new EnvironmentProviderFactory().getEnvironmentProvider());
    if (defaultSelection != null) {
        page.setDefaultSelectedElements(defaultSelection.stream()
                .map(fStore -> asArtifact(fStore))
                .filter(Objects::nonNull)
                .collect(Collectors.toSet()));
    }
    Optional<IStatus> result = createWizard(newWizard(), page,
            repositoryAccessor,
            Messages.selectArtifactToDeployTitle,
            Messages.selectArtifactToDeploy)
                    .open(activeShell, Messages.deploy);
    if (result.isPresent()) {
        openStatusDialog(activeShell, result.get(), repositoryAccessor);
    }
}
 
Example #2
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 #3
Source File: ContractInputControllerTest.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
@Test
public void should_open_an_error_dialog_if_remove_operation_failed() throws Exception {
    final IProgressService mockProgressService = mock(IProgressService.class);
    contractInputController = spy(new ContractInputController(mockProgressService));
    doReturn(new TransactionalEditingDomainImpl(new ProcessItemProviderAdapterFactory())).when(contractInputController).editingDomain(any(Contract.class));

    final Contract contract = aContract().havingInput(aContractInput()).in(aTask()).build();
    observableValue.setValue(contract);
    when(viewer.getSelection()).thenReturn(new StructuredSelection(contract.getInputs()));
    final InvocationTargetException error = new InvocationTargetException(new Throwable());
    doThrow(error).when(mockProgressService).run(anyBoolean(), anyBoolean(), any(IRunnableWithProgress.class));

    contractInputController.remove(viewer);

    verify(contractInputController).openErrorDialog(error);
}
 
Example #4
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 #5
Source File: ContractPropertySection.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
@Inject
public ContractPropertySection(final ISharedImages sharedImages,
        final IEclipseContext eclipseContext,
        final ContractContainerAdaptableSelectionProvider selectionProvider,
        final PoolAdaptableSelectionProvider poolSelectionProvider,
        final RepositoryAccessor repositoryAccessor,
        final FieldToContractInputMappingOperationBuilder fieldToContractInputMappingOperationBuilder,
        final FieldToContractInputMappingExpressionBuilder fieldToContractInputMappingExpressionBuilder,
        final ContractConstraintBuilder contractConstraintBuilder,
        final IProgressService progressService) {
    this.eclipseContext = eclipseContext;
    this.repositoryAccessor = repositoryAccessor;
    this.selectionProvider = selectionProvider;
    this.poolSelectionProvider = poolSelectionProvider;
    this.progressService = progressService;
    this.sharedImages = sharedImages;
    this.fieldToContractInputMappingOperationBuilder = fieldToContractInputMappingOperationBuilder;
    this.fieldToContractInputMappingExpressionBuilder = fieldToContractInputMappingExpressionBuilder;
    this.contractConstraintBuilder = contractConstraintBuilder;
}
 
Example #6
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 #7
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 #8
Source File: TestDocumentRefactoring.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
private void refactorDocument(final Pool pool) throws InvocationTargetException, InterruptedException {
    final Document documentToRefactor = pool.getDocuments().get(0);
    final RefactorDocumentOperation refactorOperation = new RefactorDocumentOperation(RefactoringOperationType.UPDATE);
    refactorOperation.setEditingDomain(TransactionUtil.getEditingDomain(pool));
    final Document newDocument = EcoreUtil.copy(documentToRefactor);
    newDocument.setName(newDocumentName);
    refactorOperation.addItemToRefactor(newDocument, documentToRefactor);
    final IProgressService service = PlatformUI.getWorkbench().getProgressService();
    service.busyCursorWhile(refactorOperation);
    final Document documentRefactored = pool.getDocuments().get(0);
    assertEquals(newDocument.getName(), documentRefactored.getName());
    testDocumentInExpressionsRefactored(documentRefactored, 2, pool);
    final Document currentDoc = refactorDocumentTypeAndMultiplicity(pool, documentRefactored);
    testRemoveDocumentRefactoring(currentDoc, pool);

}
 
Example #9
Source File: TestDocumentRefactoring.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
private Document refactorDocumentTypeAndMultiplicity(final Pool pool, final Document document)
        throws InvocationTargetException, InterruptedException {
    final Document newDocument = EcoreUtil.copy(document);
    newDocument.setMultiple(true);
    newDocument.setDocumentType(DocumentType.EXTERNAL);
    final RefactorDocumentOperation refactorOperation = new RefactorDocumentOperation(RefactoringOperationType.UPDATE);
    refactorOperation.setEditingDomain(TransactionUtil.getEditingDomain(pool));
    refactorOperation.addItemToRefactor(newDocument, document);
    final IProgressService service = PlatformUI.getWorkbench().getProgressService();
    service.busyCursorWhile(refactorOperation);
    final Document documentRefactored = pool.getDocuments().get(0);
    assertEquals(newDocument.getName(), documentRefactored.getName());
    assertEquals(newDocument.getDocumentType(), documentRefactored.getDocumentType());
    return documentRefactored;

}
 
Example #10
Source File: FindAction.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
private void performNewSearch(IJavaElement element) throws JavaModelException, InterruptedException {
	JavaSearchQuery query= new JavaSearchQuery(createQuery(element));
	if (query.canRunInBackground()) {
		/*
		 * This indirection with Object as parameter is needed to prevent the loading
		 * of the Search plug-in: the VM verifies the method call and hence loads the
		 * types used in the method signature, eventually triggering the loading of
		 * a plug-in (in this case ISearchQuery results in Search plug-in being loaded).
		 */
		SearchUtil.runQueryInBackground(query);
	} else {
		IProgressService progressService= PlatformUI.getWorkbench().getProgressService();
		/*
		 * This indirection with Object as parameter is needed to prevent the loading
		 * of the Search plug-in: the VM verifies the method call and hence loads the
		 * types used in the method signature, eventually triggering the loading of
		 * a plug-in (in this case it would be ISearchQuery).
		 */
		IStatus status= SearchUtil.runQueryInForeground(progressService, query);
		if (status.matches(IStatus.ERROR | IStatus.INFO | IStatus.WARNING)) {
			ErrorDialog.openError(getShell(), SearchMessages.Search_Error_search_title, SearchMessages.Search_Error_search_message, status);
		}
	}
}
 
Example #11
Source File: NLSAccessorConfigurationDialog.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
protected void browseForAccessorClass() {
	IProgressService service= PlatformUI.getWorkbench().getProgressService();
	IPackageFragmentRoot root= fAccessorPackage.getSelectedFragmentRoot();

	IJavaSearchScope scope= root != null ? SearchEngine.createJavaSearchScope(new IJavaElement[] { root }) : SearchEngine.createWorkspaceScope();

	FilteredTypesSelectionDialog  dialog= new FilteredTypesSelectionDialog (getShell(), false,
		service, scope, IJavaSearchConstants.CLASS);
	dialog.setTitle(NLSUIMessages.NLSAccessorConfigurationDialog_Accessor_Selection);
	dialog.setMessage(NLSUIMessages.NLSAccessorConfigurationDialog_Choose_the_accessor_file);
	dialog.setInitialPattern("*Messages"); //$NON-NLS-1$
	if (dialog.open() == Window.OK) {
		IType selectedType= (IType) dialog.getFirstResult();
		if (selectedType != null) {
			fAccessorClassName.setText(selectedType.getElementName());
			fAccessorPackage.setSelected(selectedType.getPackageFragment());
		}
	}


}
 
Example #12
Source File: VisualizeTxtUMLPage.java    From txtUML with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public void createControl(Composite parent) {
	if (progressBar) {
		IProgressService progressService = PlatformUI.getWorkbench().getProgressService();
		try {
			progressService.runInUI(progressService, new IRunnableWithProgress() {

				@Override
				public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
					createPage(parent, monitor);
				}

			}, ResourcesPlugin.getWorkspace().getRoot());
		} catch (InvocationTargetException | InterruptedException e) {
			Logger.sys.error(e.getMessage());
		}
	} else {
		createPage(parent, null);
	}
}
 
Example #13
Source File: RefactoringWizardOpenOperation_NonForking.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * CHANGED to protected
 * CHANGED do not fork as we are keeping the resource lock.
 */
protected RefactoringStatus checkInitialConditions(Refactoring refactoring, Shell parent, String title,
		IRunnableContext context) throws InterruptedException {
	try {
		CheckConditionsOperation cco = new CheckConditionsOperation(refactoring,
				CheckConditionsOperation.INITIAL_CONDITONS);
		WorkbenchRunnableAdapter workbenchRunnableAdapter = new WorkbenchRunnableAdapter(cco, ResourcesPlugin
				.getWorkspace().getRoot());
		/* CHANGE: don't fork (or use busyCursorWhile) as this will cause a deadlock */
		if (context == null) {
			PlatformUI.getWorkbench().getProgressService().run(false, true, workbenchRunnableAdapter);
		} else if (context instanceof IProgressService) {
			((IProgressService) context).run(false, true, workbenchRunnableAdapter);
		} else {
			context.run(false, true, workbenchRunnableAdapter);
		}
		return cco.getStatus();
	} catch (InvocationTargetException e) {
		ExceptionHandler.handle(e, parent, title, RefactoringUIMessages.RefactoringUI_open_unexpected_exception);
		return RefactoringStatus
				.createFatalErrorStatus(RefactoringUIMessages.RefactoringUI_open_unexpected_exception);
	}
}
 
Example #14
Source File: EMFEditWithRefactorObservables.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
public static IObservableFactory valueWithRefactorFactory(final Realm realm, final EStructuralFeature eStructuralFeature, IRefactorOperationFactory refactorOperationFactory,
        IProgressService progressService) {
    return new IObservableFactory()
    {

        @Override
        public IObservable createObservable(final Object target)
        {
            final TransactionalEditingDomain editingDomain = TransactionUtil.getEditingDomain(target);
            return new ObservableValueWithRefactor(editingDomain, (EObject) target, eStructuralFeature, refactorOperationFactory, progressService);
        }
    };
}
 
Example #15
Source File: EMFEditWithRefactorObservables.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
public static DetailObservableValueWithRefactor observeDetailValueWithRefactor(Realm realm,
        IObservableValue value, 
        EStructuralFeature eStructuralFeature,
        IRefactorOperationFactory refactorOperationFactory,
        IProgressService progressService) {
    return new DetailObservableValueWithRefactor(value, valueWithRefactorFactory(realm, eStructuralFeature, refactorOperationFactory, progressService), eStructuralFeature);
    
}
 
Example #16
Source File: EMFEditWithRefactorObservables.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
public static ObservableValueWithRefactor observeValueWithRefactor(
        final EditingDomain editingDomain,
        final EObject target,
        final EStructuralFeature eStructuralFeature,
        final IRefactorOperationFactory refactorOperationFactory,
        final IProgressService progressService) {
    return new ObservableValueWithRefactor(editingDomain, target, eStructuralFeature, refactorOperationFactory, progressService);
}
 
Example #17
Source File: TestParametersRefactoring.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
private void refactorParameter(final List<Pool> pools, final List<Parameter> pool1Parameters,
        final List<Parameter> pool2Parameters,
        final List<Operation> pool1Operations,
        final List<Operation> pool2Operations) throws InvocationTargetException, InterruptedException {
    final Parameter parameterToRefactor = pool1Parameters.get(0);
    final Parameter parameterWithSameName = pool2Parameters.get(0);
    final String parameterWithSameNameName = parameterWithSameName.getName();
    final String secondParameterOldName = pool1Parameters.get(1).getName();
    Configuration localeConfiguration = getLocalConfiguration(pools.get(0));
    final String parameterValue = localeConfiguration.getParameters().get(0).getValue();
    final RefactorParametersOperation op = new RefactorParametersOperation(pools.get(0));
    op.setEditingDomain(TransactionUtil.getEditingDomain(pools.get(0)));
    final Parameter newParameter = EcoreUtil.copy(parameterToRefactor);
    newParameter.setName(newParameterName);
    op.addItemToRefactor(newParameter, parameterToRefactor);
    final IProgressService service = PlatformUI.getWorkbench().getProgressService();
    service.busyCursorWhile(op);
    localeConfiguration = getLocalConfiguration(pools.get(0));
    assertEquals("refactoring first parameter also changed second parameter", secondParameterOldName,
            pool1Parameters.get(1).getName());
    assertEquals("parameter reference has not beeen refactored", newParameterName,
            pool1Operations.get(0).getRightOperand().getName());
    assertEquals("second parameter reference should not have changed", secondParameterOldName,
            pool1Operations.get(1).getRightOperand().getName());
    assertEquals("parameter with same name in second pool should not have changed", parameterWithSameNameName,
            parameterWithSameName.getName());
    assertEquals("parameter reference in second pool should not have been refactored", parameterWithSameNameName,
            pool2Operations.get(0).getRightOperand()
                    .getName());
    assertEquals("parameter name in configuration has not been refactored", newParameterName,
            localeConfiguration.getParameters().get(0).getName());
    assertEquals("refactored parameter has no value anymore", parameterValue,
            localeConfiguration.getParameters().get(0).getValue());
}
 
Example #18
Source File: InputNameObservableEditingSupport.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
public InputNameObservableEditingSupport(final ColumnViewer viewer,
        final IMessageManager messageManager,
        final DataBindingContext dbc,
        final IRefactorOperationFactory contractInputRefactorOperationFactory,
        final IProgressService progressService) {
    super(viewer, ProcessPackage.Literals.CONTRACT_INPUT__NAME, messageManager, dbc);
    this.progressService = progressService;
    this.contractInputRefactorOperationFactory = contractInputRefactorOperationFactory;
}
 
Example #19
Source File: ContractInputTypeEditingSupport.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
public ContractInputTypeEditingSupport(final ColumnViewer viewer, final IPropertySourceProvider propertySourceProvider,
        final ContractInputController controller, ContractInputRefactorOperationFactory refactorOperationFactory,
        IProgressService progressService,
        TransactionalEditingDomain.Factory transactionalEditingDomainFactory) {
    super(viewer, propertySourceProvider, ProcessPackage.Literals.CONTRACT_INPUT__TYPE.getName());
    this.controller = controller;
    this.contractInputRefactorOperationFactory = refactorOperationFactory;
    this.progressService = progressService;
    this.transactionalEditingDomainFactory = transactionalEditingDomainFactory;
}
 
Example #20
Source File: ContractInputTreeViewer.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
public ContractInputTreeViewer(final Composite parent, final FormToolkit toolkit, final IProgressService progressService,
        final ISharedImages sharedImages) {
    super(toolkit.createTree(parent, GTKStyleHandler.removeBorderFlag(SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI)));
    getTree().setData(SWTBotConstants.SWTBOT_WIDGET_ID_KEY, SWTBotConstants.SWTBOT_ID_CONTRACT_INPUT_TREE);
    this.progressService = progressService;
    this.sharedImages = sharedImages;
}
 
Example #21
Source File: CreateOrEditFormProposalListener.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
@Inject
public CreateOrEditFormProposalListener(final PageDesignerURLFactory pageDesignerURLFactory,
        final IProgressService progressService,
        final RepositoryAccessor repositoryAccessor,
        NewFormOperationFactoryDelegate operationFactory) {
    super(pageDesignerURLFactory, progressService, repositoryAccessor, operationFactory);
    this.progressService = progressService;
}
 
Example #22
Source File: TestParametersRefactoring.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
private void removeParameter(final List<Pool> pools, final List<Parameter> pool1Parameters,
        final List<Operation> operations)
        throws InvocationTargetException,
        InterruptedException {
    final RemoveParametersOperation op = new RemoveParametersOperation(pool1Parameters.get(0), pools.get(0));
    op.setEditingDomain(TransactionUtil.getEditingDomain(pools.get(0)));
    final IProgressService service = PlatformUI.getWorkbench().getProgressService();
    service.busyCursorWhile(op);
    assertEquals("parameter has not been removed", 1, pools.get(0).getParameters().size());
    assertEquals("parameter reference has not been removed", "", operations.get(0).getRightOperand().getName());
    final Configuration localeConfiguration = getLocalConfiguration(pools.get(0));
    assertEquals("parameter has not been removed correctly in ", 1, localeConfiguration.getParameters().size());
}
 
Example #23
Source File: TestDocumentRefactoring.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
private void testRemoveDocumentRefactoring(final Document document, final Pool pool)
        throws InvocationTargetException, InterruptedException {
    final RefactorDocumentOperation refactorOperation = new RefactorDocumentOperation(RefactoringOperationType.REMOVE);
    refactorOperation.setEditingDomain(TransactionUtil.getEditingDomain(pool));
    refactorOperation.addItemToRefactor(null, document);
    final IProgressService service = PlatformUI.getWorkbench().getProgressService();
    service.busyCursorWhile(refactorOperation);
    assertTrue(pool.getDocuments().isEmpty());
    final List<Task> tasks = ModelHelper.getAllItemsOfType(pool, ProcessPackage.Literals.TASK);
    final Task step1 = tasks.get(0);
    final Operation op = step1.getOperations().get(0);
    final Expression expr = op.getRightOperand();
    assertEquals(expr.getContent(), empty);
}
 
Example #24
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 #25
Source File: KGDrucker.java    From elexis-3-core with Eclipse Public License 1.0 5 votes vote down vote up
public void doPrint(Patient pat){
	this.patient = pat;
	kgPage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
	IProgressService progressService = PlatformUI.getWorkbench().getProgressService();
	
	try {
		kgp = (KGPrintView) kgPage.showView(KGPrintView.ID);
		progressService.runInUI(PlatformUI.getWorkbench().getProgressService(),
			new IRunnableWithProgress() {
				public void run(IProgressMonitor monitor){
					monitor.beginTask(Messages.KGDrucker_printEMR, 1); //$NON-NLS-1$
					// gw 23.7.2006 an neues Selectionmodell angepasst
					Patient actPatient = ElexisEventDispatcher.getSelectedPatient();
					if (kgp.doPrint(actPatient, monitor) == false) {
						ErrorDialog.openError(null, Messages.KGDrucker_errorPrinting,
							Messages.KGDrucker_couldntprint + patient.getLabel()
								+ Messages.KGDrucker_emr, null); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
						
					}
					
					monitor.done();
				}
			}, null);
		
		kgPage.hideView(kgp);
		
	} catch (Exception ex) {
		ElexisStatus status =
			new ElexisStatus(ElexisStatus.ERROR, Hub.PLUGIN_ID, ElexisStatus.CODE_NONE,
				Messages.KGDrucker_errorPrinting + ": " + Messages.KGDrucker_couldntShow, ex);
		StatusManager.getManager().handle(status);
	}
}
 
Example #26
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 #27
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 #28
Source File: JdtReferenceFinder.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
protected void performNewSearch(String label, Iterable<? extends IJavaElement> elements) throws JavaModelException, InterruptedException {
	CompositeSearchQuery compositeSearchQuery = createCompositeQuery(label, elements);
	if (compositeSearchQuery.canRunInBackground()) {
		SearchUtil.runQueryInBackground(compositeSearchQuery);
	} else {
		IProgressService progressService= PlatformUI.getWorkbench().getProgressService();
		IStatus status= SearchUtil.runQueryInForeground(progressService, compositeSearchQuery);
		if (status.matches(IStatus.ERROR | IStatus.INFO | IStatus.WARNING)) {
			ErrorDialog.openError(getShell(), SearchMessages.Search_Error_search_title, SearchMessages.Search_Error_search_message, status);
		}
	}
}
 
Example #29
Source File: FindReferencesInProjectAction.java    From typescript.java with MIT License 5 votes vote down vote up
private void findReferences(IResource resource, int offset, int length) {
	TypeScriptSearchQuery query = new TypeScriptSearchQuery(resource, offset);
	if (query.canRunInBackground()) {
		/*
		 * This indirection with Object as parameter is needed to prevent
		 * the loading of the Search plug-in: the VM verifies the method
		 * call and hence loads the types used in the method signature,
		 * eventually triggering the loading of a plug-in (in this case
		 * ISearchQuery results in Search plug-in being loaded).
		 */
		SearchUtil.runQueryInBackground(query);
	} else {
		IProgressService progressService = PlatformUI.getWorkbench().getProgressService();
		/*
		 * This indirection with Object as parameter is needed to prevent
		 * the loading of the Search plug-in: the VM verifies the method
		 * call and hence loads the types used in the method signature,
		 * eventually triggering the loading of a plug-in (in this case it
		 * would be ISearchQuery).
		 */
		IStatus status = SearchUtil.runQueryInForeground(progressService, query);
		if (status.matches(IStatus.ERROR | IStatus.INFO | IStatus.WARNING)) {
			ErrorDialog.openError(getShell(), SearchMessages.Search_Error_search_title,
					SearchMessages.Search_Error_search_message, status);
		}
	}
}
 
Example #30
Source File: LaunchConfigStarter.java    From eclipse-extras with Eclipse Public License 1.0 5 votes vote down vote up
private void terminateLaunches() {
  if( preferences.isTerminateBeforeRelaunch() ) {
    IProgressService progressService = PlatformUI.getWorkbench().getProgressService();
    try {
      progressService.busyCursorWhile( this::terminateLaunches );
    } catch( InvocationTargetException ite ) {
      handleException( ite.getCause() );
    } catch( InterruptedException ignore ) {
      Thread.interrupted();
    }
  }
}