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

The following examples show how to use org.eclipse.ui.progress.IProgressService#busyCursorWhile() . 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: 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 3
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 4
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();
    }
  }
}
 
Example 5
Source File: ExpressionViewer.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
private boolean executeRemoveOperation(final CompoundCommand cc) {
    boolean isExecuted = false;
    if (removeOperation != null) {
        removeOperation.setCompoundCommand(cc);
        final IProgressService service = PlatformUI.getWorkbench().getProgressService();
        try {
            service.busyCursorWhile(removeOperation);
            isExecuted = true;
        } catch (final InvocationTargetException | InterruptedException e) {
            BonitaStudioLog.error(e);
        }

    }
    return isExecuted;
}
 
Example 6
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 7
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 8
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);
}