Java 类org.eclipse.core.runtime.OperationCanceledException 实例源码

项目:n4js    文件:ResourceUIValidatorExtension.java   
private void addMarkers(IFile file, Resource resource, CheckMode mode, IProgressMonitor monitor)
        throws OperationCanceledException {
    try {
        List<Issue> list = getValidator(resource).validate(resource, mode, getCancelIndicator(monitor));
        if (monitor.isCanceled()) {
            throw new OperationCanceledException();
        }
        deleteMarkers(file, mode, monitor);
        if (monitor.isCanceled()) {
            throw new OperationCanceledException();
        }
        createMarkers(file, list, getMarkerCreator(resource), getMarkerTypeProvider(resource));
    } catch (OperationCanceledError error) {
        throw error.getWrapped();
    } catch (CoreException e) {
        LOGGER.error(e.getMessage(), e);
    }
}
项目:AgentWorkbench    文件:P2OperationsHandler.java   
/**
 * Queries a repository for a specific {@link IInstallableUnit} (IU).
 *
 * @param repositoryURI the repository URI
 * @param installableUnitID the ID of the IU
 * @return the {@link IQueryResult}
 */
private IQueryResult<IInstallableUnit> queryRepositoryForInstallableUnit(URI repositoryURI, String installableUnitID) {

    // --- Load the repository ------------
    IQueryResult<IInstallableUnit> queryResult = null;
    try {
        IMetadataRepository metadataRepository = this.getMetadataRepositoryManager().loadRepository(repositoryURI, this.getProgressMonitor());
        // --- Query for the IU of interest -----
        if (metadataRepository != null) {
            queryResult = metadataRepository.query(QueryUtil.createIUQuery(installableUnitID), this.getProgressMonitor());
        }

    } catch (ProvisionException | OperationCanceledException e) {
        System.err.println("Error loading the repository at " + repositoryURI);
        e.printStackTrace();
    }

    return queryResult;
}
项目:gemoc-studio-modeldebugging    文件:AddRemoveGemocSequentialLanguageNatureHandler.java   
public static void addAsMainNature(IProject project, String natureID, IProgressMonitor monitor) throws CoreException{
    if (monitor != null && monitor.isCanceled()) {
        throw new OperationCanceledException();
    }
    if (!project.hasNature(natureID)) {
        IProjectDescription description = project.getDescription();
        String[] natures = description.getNatureIds();
        String[] newNatures = new String[natures.length + 1];
        System.arraycopy(natures, 0, newNatures, 1, natures.length);
        newNatures[0] = natureID;
        description.setNatureIds(newNatures);
        project.setDescription(description, null);
    } else {
        if (monitor != null) {
            monitor.worked(1);
        }
    }
}
项目:Hydrograph    文件:JobCopyParticipant.java   
@Override
public Change createChange(IProgressMonitor pm) throws CoreException, OperationCanceledException {

    copyToPath=getArguments().getDestination().toString();
    IWorkspaceRoot workSpaceRoot = ResourcesPlugin.getWorkspace().getRoot();
    IProject project = workSpaceRoot.getProject(copyToPath.split("/")[1]);
    IFolder jobFolder = project.getFolder(copyToPath.substring(copyToPath.indexOf('/', 2)));
    previousJobFiles=new ArrayList<>();
    for (IResource iResource : jobFolder.members()) {
        if (!(iResource instanceof IFolder)) {
            IFile iFile = (IFile) iResource;
             if (iFile.getFileExtension().equalsIgnoreCase(Messages.JOB_EXT)) {
                 previousJobFiles.add(iFile);
             }
        }
    }
    copiedFileList.add(modifiedResource);
    return null;
}
项目:ec4e    文件:EditorConfigSearchQuery.java   
@Override
public IStatus run(IProgressMonitor monitor) throws OperationCanceledException {
    startTime = System.currentTimeMillis();
    AbstractTextSearchResult textResult = (AbstractTextSearchResult) getSearchResult();
    textResult.removeAll();

    try {

        IContainer dir = configFile.getParent();
        dir.accept(new AbstractSectionPatternVisitor(section) {

            @Override
            protected void collect(IResourceProxy proxy) {
                Match match = new FileMatch((IFile) proxy.requestResource());
                result.addMatch(match);
            }
        }, IResource.NONE);

        return Status.OK_STATUS;
    } catch (Exception ex) {
        return new Status(IStatus.ERROR, EditorConfigPlugin.PLUGIN_ID, ex.getMessage(), ex);
    }
}
项目:solidity-ide    文件:SolidityBuilderParticipant.java   
@Override
public void build(IBuildContext context, IProgressMonitor monitor) throws CoreException {
    SubMonitor progress = SubMonitor.convert(monitor);
    if (!prefs.isCompilerEnabled()) {
        return;
    }
    final List<IResourceDescription.Delta> deltas = getRelevantDeltas(context);
    if (deltas.isEmpty()) {
        return;
    }
    if (progress.isCanceled()) {
        throw new OperationCanceledException();
    }
    progress.beginTask("Compiling solidity...", deltas.size());

    List<URI> uris = deltas.stream().map(delta -> delta.getUri()).collect(Collectors.toList());
    compiler.compile(uris, progress);
    context.getBuiltProject().refreshLocal(IProject.DEPTH_INFINITE, progress);
    progress.done();

}
项目:team-explorer-everywhere    文件:CloseProjectsCommand.java   
/**
 * {@inheritDoc}
 */
@Override
protected IStatus doRun(final IProgressMonitor progressMonitor) throws Exception {
    progressMonitor.beginTask(getName(), projects.length);

    for (int i = 0; i < projects.length; i++) {
        final IProgressMonitor projectMonitor = new SubProgressMonitor(progressMonitor, 1);

        projectMonitor.setTaskName(
            MessageFormat.format(
                Messages.getString("CloseProjectsCommand.ClosingProjectFormat"), //$NON-NLS-1$
                projects[i].getName()));

        try {
            projects[i].close(projectMonitor);
        } catch (final OperationCanceledException e) {
            return Status.CANCEL_STATUS;
        }

        if (progressMonitor.isCanceled()) {
            return Status.CANCEL_STATUS;
        }
    }

    return Status.OK_STATUS;
}
项目:google-cloud-eclipse    文件:FacetUtil.java   
/**
 * Modifies the set of project facets in the configured project by performing the series of
 * configured facets actions.
 *
 * @param monitor a progress monitor, or null if progress reporting and cancellation are not desired
 * @throws CoreException if anything goes wrong while applying facet actions
 */
public void install(IProgressMonitor monitor) throws CoreException {
  SubMonitor subMonitor = SubMonitor.convert(monitor, 100);

  // Workaround deadlock bug described in Eclipse bug (https://bugs.eclipse.org/511793).
  // There are graph update jobs triggered by the completion of the CreateProjectOperation
  // above (from resource notifications) and from other resource changes from modifying the
  // project facets. So we force the dependency graph to defer updates
  try {
    IDependencyGraph.INSTANCE.preUpdate();
    try {
      Job.getJobManager().join(DependencyGraphImpl.GRAPH_UPDATE_JOB_FAMILY,
          subMonitor.newChild(10));
    } catch (OperationCanceledException | InterruptedException ex) {
      logger.log(Level.WARNING, "Exception waiting for WTP Graph Update job", ex);
    }

    facetedProject.modify(facetInstallSet, subMonitor.newChild(90));
  } finally {
    IDependencyGraph.INSTANCE.postUpdate();
  }
}
项目:google-cloud-eclipse    文件:CreateAppEngineWtpProject.java   
private static void enableMavenNature(IProject newProject, IProgressMonitor monitor)
    throws CoreException {
  SubMonitor subMonitor = SubMonitor.convert(monitor, 30);

  // Workaround deadlock bug described in Eclipse bug (https://bugs.eclipse.org/511793).
  try {
    IDependencyGraph.INSTANCE.preUpdate();
    try {
      Job.getJobManager().join(DependencyGraphImpl.GRAPH_UPDATE_JOB_FAMILY,
          subMonitor.newChild(8));
    } catch (OperationCanceledException | InterruptedException ex) {
      logger.log(Level.WARNING, "Exception waiting for WTP Graph Update job", ex);
    }

    ResolverConfiguration resolverConfiguration = new ResolverConfiguration();
    MavenPlugin.getProjectConfigurationManager().enableMavenNature(newProject,
        resolverConfiguration, subMonitor.newChild(20));
  } finally {
    IDependencyGraph.INSTANCE.postUpdate();
  }

  // M2E will cleverly set "target/<artifact ID>-<version>/WEB-INF/classes" as a new Java output
  // folder; delete the default old folder.
  newProject.getFolder("build").delete(true /* force */, subMonitor.newChild(2));
}
项目:google-cloud-eclipse    文件:WarPublisher.java   
public static void publishExploded(IProject project, IPath destination,
    IPath safeWorkDirectory, IProgressMonitor monitor) throws CoreException {
  Preconditions.checkNotNull(project, "project is null"); //$NON-NLS-1$
  Preconditions.checkNotNull(destination, "destination is null"); //$NON-NLS-1$
  Preconditions.checkArgument(!destination.isEmpty(), "destination is empty path"); //$NON-NLS-1$
  Preconditions.checkNotNull(safeWorkDirectory, "safeWorkDirectory is null"); //$NON-NLS-1$
  if (monitor.isCanceled()) {
    throw new OperationCanceledException();
  }

  SubMonitor subMonitor = SubMonitor.convert(monitor, 100);
  subMonitor.setTaskName(Messages.getString("task.name.publish.war"));

  IModuleResource[] resources =
      flattenResources(project, safeWorkDirectory, subMonitor.newChild(10));
  PublishUtil.publishFull(resources, destination, subMonitor.newChild(90));
}
项目:google-cloud-eclipse    文件:WarPublisher.java   
public static void publishWar(IProject project, IPath destination, IPath safeWorkDirectory,
    IProgressMonitor monitor) throws CoreException {
  Preconditions.checkNotNull(project, "project is null"); //$NON-NLS-1$
  Preconditions.checkNotNull(destination, "destination is null"); //$NON-NLS-1$
  Preconditions.checkArgument(!destination.isEmpty(), "destination is empty path"); //$NON-NLS-1$
  Preconditions.checkNotNull(safeWorkDirectory, "safeWorkDirectory is null"); //$NON-NLS-1$
  if (monitor.isCanceled()) {
    throw new OperationCanceledException();
  }

  SubMonitor subMonitor = SubMonitor.convert(monitor, 100);
  subMonitor.setTaskName(Messages.getString("task.name.publish.war"));

  IModuleResource[] resources =
      flattenResources(project, safeWorkDirectory, subMonitor.newChild(10));
  PublishUtil.publishZip(resources, destination, subMonitor.newChild(90));
}
项目:google-cloud-eclipse    文件:CloudSdkStagingHelper.java   
/**
 * @param explodedWarDirectory the input of the staging operation
 * @param stagingDirectory where the result of the staging operation will be written
 * @param cloudSdk executes the staging operation
 */
public static void stageStandard(IPath explodedWarDirectory, IPath stagingDirectory,
    CloudSdk cloudSdk, IProgressMonitor monitor) {
  if (monitor.isCanceled()) {
    throw new OperationCanceledException();
  }

  SubMonitor progress = SubMonitor.convert(monitor, 1);
  progress.setTaskName(Messages.getString("task.name.stage.project")); //$NON-NLS-1$

  DefaultStageStandardConfiguration stagingConfig = new DefaultStageStandardConfiguration();
  stagingConfig.setSourceDirectory(explodedWarDirectory.toFile());
  stagingConfig.setStagingDirectory(stagingDirectory.toFile());
  stagingConfig.setEnableJarSplitting(true);
  stagingConfig.setDisableUpdateCheck(true);

  CloudSdkAppEngineStandardStaging staging = new CloudSdkAppEngineStandardStaging(cloudSdk);
  staging.stageStandard(stagingConfig);

  progress.worked(1);
}
项目:google-cloud-eclipse    文件:CloudSdkStagingHelper.java   
/**
 * @param appEngineDirectory directory containing {@code app.yaml}
 * @param deployArtifact project to be deploy (such as WAR or JAR)
 * @param stagingDirectory where the result of the staging operation will be written
 * @throws AppEngineException when staging fails
 * @throws OperationCanceledException when user cancels the operation
 */
public static void stageFlexible(IPath appEngineDirectory, IPath deployArtifact,
    IPath stagingDirectory, IProgressMonitor monitor) {
  if (monitor.isCanceled()) {
    throw new OperationCanceledException();
  }

  SubMonitor progress = SubMonitor.convert(monitor, 1);
  progress.setTaskName(Messages.getString("task.name.stage.project")); //$NON-NLS-1$

  DefaultStageFlexibleConfiguration stagingConfig = new DefaultStageFlexibleConfiguration();
  stagingConfig.setAppEngineDirectory(appEngineDirectory.toFile());
  stagingConfig.setArtifact(deployArtifact.toFile());
  stagingConfig.setStagingDirectory(stagingDirectory.toFile());

  CloudSdkAppEngineFlexibleStaging staging = new CloudSdkAppEngineFlexibleStaging();
  staging.stageFlexible(stagingConfig);

  progress.worked(1);
}
项目:google-cloud-eclipse    文件:FlexMavenPackagedProjectStagingDelegate.java   
@Override
protected IPath getDeployArtifact(IPath safeWorkingDirectory, IProgressMonitor monitor)
    throws CoreException {
  SubMonitor subMonitor = SubMonitor.convert(monitor, 100);

  try {
    ILaunchConfiguration config = createMavenPackagingLaunchConfiguration(project);
    ILaunch launch = config.launch("run", subMonitor.newChild(10));
    if (!waitUntilLaunchTerminates(launch, subMonitor.newChild(90))) {
      throw new OperationCanceledException();
    }
    return getFinalArtifactPath(project);
  } catch (InterruptedException ex) {
    throw new OperationCanceledException();
  }
}
项目:eclipse.jdt.ls    文件:MavenProjectImporter.java   
@Override
public boolean applies(IProgressMonitor monitor) throws OperationCanceledException, CoreException {
    PreferenceManager preferencesManager = JavaLanguageServerPlugin.getPreferencesManager();
    if (preferencesManager != null && !preferencesManager.getPreferences().isImportMavenEnabled()) {
        return false;
    }
    Set<MavenProjectInfo> files = getMavenProjectInfo(monitor);
    if (files != null) {
        Iterator<MavenProjectInfo> iter = files.iterator();
        while (iter.hasNext()) {
            MavenProjectInfo projectInfo = iter.next();
            File dir = projectInfo.getPomFile() == null ? null : projectInfo.getPomFile().getParentFile();
            if (dir != null && exclude(dir.toPath())) {
                iter.remove();
            }
        }
    }
    return files != null && !files.isEmpty();
}
项目:eclipse.jdt.ls    文件:ExtractMethodRefactoring.java   
@Override
public RefactoringStatus checkFinalConditions(IProgressMonitor pm) throws CoreException {
    pm.beginTask(RefactoringCoreMessages.ExtractMethodRefactoring_checking_new_name, 2);
    pm.subTask(EMPTY);

    RefactoringStatus result = checkMethodName();
    result.merge(checkParameterNames());
    result.merge(checkVarargOrder());
    pm.worked(1);
    if (pm.isCanceled()) {
        throw new OperationCanceledException();
    }

    BodyDeclaration node = fAnalyzer.getEnclosingBodyDeclaration();
    if (node != null) {
        fAnalyzer.checkInput(result, fMethodName, fDestination);
        pm.worked(1);
    }
    pm.done();
    return result;
}
项目:eclipse.jdt.ls    文件:CompletionHandler.java   
Either<List<CompletionItem>, CompletionList> completion(TextDocumentPositionParams position,
        IProgressMonitor monitor) {
    List<CompletionItem> completionItems = null;
    try {
        ICompilationUnit unit = JDTUtils.resolveCompilationUnit(position.getTextDocument().getUri());
        completionItems = this.computeContentAssist(unit,
                position.getPosition().getLine(),
                position.getPosition().getCharacter(), monitor);
    } catch (OperationCanceledException ignorable) {
        // No need to pollute logs when query is cancelled
        monitor.setCanceled(true);
    } catch (Exception e) {
        JavaLanguageServerPlugin.logException("Problem with codeComplete for " +  position.getTextDocument().getUri(), e);
        monitor.setCanceled(true);
    }
    CompletionList $ = new CompletionList();
    if (monitor.isCanceled()) {
        $.setIsIncomplete(true);
        completionItems = null;
        JavaLanguageServerPlugin.logInfo("Completion request cancelled");
    } else {
        JavaLanguageServerPlugin.logInfo("Completion request completed");
    }
    $.setItems(completionItems == null ? Collections.emptyList() : completionItems);
    return Either.forRight($);
}
项目:eclipse.jdt.ls    文件:JDTLanguageServer.java   
@Override
public CompletableFuture<Either<List<CompletionItem>, CompletionList>> completion(TextDocumentPositionParams position) {
    logInfo(">> document/completion");
    CompletionHandler handler = new CompletionHandler();
    final IProgressMonitor[] monitors = new IProgressMonitor[1];
    CompletableFuture<Either<List<CompletionItem>, CompletionList>> result = computeAsync((cc) -> {
        monitors[0] = toMonitor(cc);
        if (Boolean.getBoolean(JAVA_LSP_JOIN_ON_COMPLETION)) {
            try {
                Job.getJobManager().join(DocumentLifeCycleHandler.DOCUMENT_LIFE_CYCLE_JOBS, monitors[0]);
            } catch (OperationCanceledException ignorable) {
                // No need to pollute logs when query is cancelled
            } catch (InterruptedException e) {
                JavaLanguageServerPlugin.logException(e.getMessage(), e);
            }
        }
        return handler.completion(position, monitors[0]);
    });
    result.join();
    if (monitors[0].isCanceled()) {
        result.cancel(true);
    }
    return result;
}
项目:eclipse.jdt.ls    文件:JDTLanguageServer.java   
@Override
public CompletableFuture<CompletionItem> resolveCompletionItem(CompletionItem unresolved) {
    logInfo(">> document/resolveCompletionItem");
    CompletionResolveHandler handler = new CompletionResolveHandler(preferenceManager);
    final IProgressMonitor[] monitors = new IProgressMonitor[1];
    CompletableFuture<CompletionItem> result = computeAsync((cc) -> {
        monitors[0] = toMonitor(cc);
        if ((Boolean.getBoolean(JAVA_LSP_JOIN_ON_COMPLETION))) {
            try {
                Job.getJobManager().join(DocumentLifeCycleHandler.DOCUMENT_LIFE_CYCLE_JOBS, monitors[0]);
            } catch (OperationCanceledException ignorable) {
                // No need to pollute logs when query is cancelled
            } catch (InterruptedException e) {
                JavaLanguageServerPlugin.logException(e.getMessage(), e);
            }
        }
        return handler.resolve(unresolved, monitors[0]);
    });
    result.join();
    if (monitors[0].isCanceled()) {
        result.cancel(true);
    }
    return result;
}
项目:eclipse.jdt.ls    文件:JDTLanguageServer.java   
@Override
public CompletableFuture<List<? extends Location>> definition(TextDocumentPositionParams position) {
    logInfo(">> document/definition");
    NavigateToDefinitionHandler handler = new NavigateToDefinitionHandler(this.preferenceManager);
    return computeAsync((cc) -> {
        IProgressMonitor monitor = toMonitor(cc);
        try {
            Job.getJobManager().join(DocumentLifeCycleHandler.DOCUMENT_LIFE_CYCLE_JOBS, monitor);
        } catch (OperationCanceledException ignorable) {
            // No need to pollute logs when query is cancelled
        } catch (InterruptedException e) {
            JavaLanguageServerPlugin.logException(e.getMessage(), e);
        }
        return handler.definition(position, toMonitor(cc));
    });
}
项目:eclipse.jdt.ls    文件:JDTLanguageServer.java   
@Override
public CompletableFuture<List<? extends Command>> codeAction(CodeActionParams params) {
    logInfo(">> document/codeAction");
    CodeActionHandler handler = new CodeActionHandler();
    return computeAsync((cc) -> {
        IProgressMonitor monitor = toMonitor(cc);
        try {
            Job.getJobManager().join(DocumentLifeCycleHandler.DOCUMENT_LIFE_CYCLE_JOBS, monitor);
        } catch (OperationCanceledException ignorable) {
            // No need to pollute logs when query is cancelled
        } catch (InterruptedException e) {
            JavaLanguageServerPlugin.logException(e.getMessage(), e);
        }
        return handler.getCodeActionCommands(params, toMonitor(cc));
    });
}
项目:eclipse.jdt.ls    文件:JDTLanguageServer.java   
@Override
public CompletableFuture<List<? extends CodeLens>> codeLens(CodeLensParams params) {
    logInfo(">> document/codeLens");
    CodeLensHandler handler = new CodeLensHandler(preferenceManager);
    return computeAsync((cc) -> {
        IProgressMonitor monitor = toMonitor(cc);
        try {
            Job.getJobManager().join(DocumentLifeCycleHandler.DOCUMENT_LIFE_CYCLE_JOBS, monitor);
        } catch (OperationCanceledException ignorable) {
            // No need to pollute logs when query is cancelled
        } catch (InterruptedException e) {
            JavaLanguageServerPlugin.logException(e.getMessage(), e);
        }
        return handler.getCodeLensSymbols(params.getTextDocument().getUri(), monitor);
    });
}
项目:eclipse.jdt.ls    文件:JDTLanguageServer.java   
@Override
public CompletableFuture<CodeLens> resolveCodeLens(CodeLens unresolved) {
    logInfo(">> codeLens/resolve");
    CodeLensHandler handler = new CodeLensHandler(preferenceManager);
    return computeAsync((cc) -> {
        IProgressMonitor monitor = toMonitor(cc);
        try {
            Job.getJobManager().join(DocumentLifeCycleHandler.DOCUMENT_LIFE_CYCLE_JOBS, monitor);
        } catch (OperationCanceledException ignorable) {
            // No need to pollute logs when query is cancelled
        } catch (InterruptedException e) {
            JavaLanguageServerPlugin.logException(e.getMessage(), e);
        }
        return handler.resolve(unresolved, monitor);
    });
}
项目:xtext-core    文件:ReferenceFinder.java   
@Override
public void findReferences(
        TargetURIs targetURIs,
        Set<URI> candidates,
        IResourceAccess resourceAccess,
        IResourceDescriptions descriptions,
        Acceptor acceptor,
        IProgressMonitor monitor) {
    if (!targetURIs.isEmpty() && !candidates.isEmpty()) {
        SubMonitor subMonitor = SubMonitor.convert(monitor, targetURIs.size() / MONITOR_CHUNK_SIZE + 1);
        IProgressMonitor useMe = subMonitor.newChild(1);
        int i = 0;
        for (URI candidate : candidates) {
            if (subMonitor.isCanceled())
                throw new OperationCanceledException();
            IReferenceFinder languageSpecific = getLanguageSpecificReferenceFinder(candidate);
            doFindReferencesWith(languageSpecific, targetURIs, candidate, resourceAccess, descriptions, acceptor, useMe);
            i++;
            if (i % MONITOR_CHUNK_SIZE == 0) {
                useMe = subMonitor.newChild(1);
            }
        }
    }
}
项目:xtext-core    文件:ReferenceFinder.java   
@Override
public void findAllReferences(TargetURIs targetURIs, IResourceAccess resourceAccess,
        IResourceDescriptions indexData, Acceptor acceptor, IProgressMonitor monitor) {
    if (!targetURIs.isEmpty()) {
        Iterable<IResourceDescription> allResourceDescriptions = indexData.getAllResourceDescriptions();
        SubMonitor subMonitor = SubMonitor.convert(monitor, size(allResourceDescriptions) / MONITOR_CHUNK_SIZE + 1);
        IProgressMonitor useMe = subMonitor.newChild(1);
        int i = 0;
        for (IResourceDescription resourceDescription : allResourceDescriptions) {
            if (subMonitor.isCanceled())
                throw new OperationCanceledException();
            IReferenceFinder languageSpecific = getLanguageSpecificReferenceFinder(resourceDescription.getURI());
            languageSpecific.findReferences(targetURIs, resourceDescription, resourceAccess, acceptor, useMe);
            i++;
            if (i % MONITOR_CHUNK_SIZE == 0) {
                useMe = subMonitor.newChild(1);
            }
        }
    }
}
项目:xtext-core    文件:FileSystemAccessQueue.java   
protected FileSystemAccessRequest send(final FileSystemAccessRequest request) {
  try {
    boolean _isCanceled = this.monitor.isCanceled();
    if (_isCanceled) {
      throw new OperationCanceledException();
    }
    this.requestQueue.put(request);
    return request;
  } catch (final Throwable _t) {
    if (_t instanceof InterruptedException) {
      throw new OperationCanceledException();
    } else {
      throw Exceptions.sneakyThrow(_t);
    }
  }
}
项目:dsl-devkit    文件:RegistryBuilderParticipant.java   
/**
 * Builds all other registered (non-language specific) {@link IXtextBuilderParticipant}s.
 *
 * @param buildContext
 *          the {@link IBuildContext}, must not be {@code null}
 * @param monitor
 *          the {@link IProgressMonitor}, must not be {@code null}
 * @throws CoreException
 *           caused by an {@link IXtextBuilderParticipant}
 */
protected void buildOtherParticipants(final IBuildContext buildContext, final IProgressMonitor monitor) throws CoreException {
  ImmutableList<IXtextBuilderParticipant> otherBuilderParticipants = getParticipants();
  if (otherBuilderParticipants.isEmpty()) {
    return;
  }
  SubMonitor progress = SubMonitor.convert(monitor, otherBuilderParticipants.size());
  progress.subTask(Messages.RegistryBuilderParticipant_InvokingBuildParticipants);
  for (final IXtextBuilderParticipant participant : otherBuilderParticipants) {
    if (progress.isCanceled()) {
      throw new OperationCanceledException();
    }
    try {
      if (initializeParticipant(participant)) {
        participant.build(buildContext, progress.newChild(1));
      }
      // CHECKSTYLE:CHECK-OFF IllegalCatchCheck we need to recover from any exception and continue the build
    } catch (Throwable throwable) {
      // CHECKSTYLE:CHECK-ON IllegalCatchCheck
      LOG.error("Error occurred during build of builder participant: " //$NON-NLS-1$
          + participant.getClass().getName(), throwable);
    }
  }
}
项目:dsl-devkit    文件:CheckExtensionGenerator.java   
/**
 * Performs modifications to the Plugin Model.
 *
 * @param modification
 *          a modification
 * @param monitor
 *          progress monitor
 */
public void modifyModel(final ModelModification modification, final IProgressMonitor monitor) {
  if (monitor.isCanceled()) {
    throw new OperationCanceledException();
  }
  try {
    PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() {
      @Override
      public void run() {
        PDEModelUtility.modifyModel(modification, monitor);
      }
    });
  } catch (SWTException e) {
    // If the build was cancelled while in syncExec() it will throw an SWTException
    if (monitor.isCanceled()) {
      throw new OperationCanceledException();
    } else {
      throw e;
    }
  }
}
项目:gwt-eclipse-plugin    文件:GwtSuperDevModeCodeServerLaunchUtil.java   
/**
 * Create a new GWT SDM Code Server Configuration. This will occur when running the debug
 * configuration from shortcut.
 */
public static ILaunchConfiguration createLaunchConfig(String launchConfigName, final IProject project)
    throws CoreException, OperationCanceledException {
  ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager();
  ILaunchConfigurationType type = manager.getLaunchConfigurationType(GwtSuperDevModeLaunchConfiguration.TYPE_ID);
  ILaunchConfigurationWorkingCopy launchConfig = type.newInstance(null, launchConfigName);

  // Project name
  LaunchConfigurationUtilities.setProjectName(launchConfig, project.getName());

  launchConfig.setMappedResources(new IResource[] {project});

  setDefaults(launchConfig, project);

  // Save the new launch configuration
  ILaunchConfiguration ilaunchConfig = launchConfig.doSave();

  return ilaunchConfig;
}
项目:typescript.java    文件:TypeScriptRenameProcessor.java   
@Override
public RefactoringStatus checkFinalConditions(IProgressMonitor pm, CheckConditionsContext context)
        throws CoreException, OperationCanceledException {
    RefactoringStatus status = new RefactoringStatus();
    // Consume "rename" tsserver command.
    try {
        rename = tsFile.rename(offset, isFindInComments(), isFindInStrings()).get(1000, TimeUnit.MILLISECONDS);
        RenameInfo info = rename.getInfo();
        if (!info.isCanRename()) {
            // Refactoring cannot be done.
            status.addError(info.getLocalizedErrorMessage());
        }
    } catch (Exception e) {
        status.addError(e.getMessage());
    }
    return status;
}
项目:typescript.java    文件:IDETypeScriptProject.java   
/**
 * Collect ts files to compile from the given ts files list.
 * 
 * @param updatedTsFiles
 *            list of TypeScript files which have changed.
 * @param tsFilesToCompile
 *            list of collected ts files to compile.
 * @param tsFilesToClose
 *            list of ts files to close.
 * @param client
 * @param subMonitor
 * @throws Exception
 */
private void collectTsFilesToCompile(List<IFile> updatedTsFiles, List<String> tsFilesToCompile,
        List<IFile> tsFilesToClose, ITypeScriptServiceClient client, SubMonitor subMonitor) throws Exception {
    SubMonitor loopMonitor = subMonitor.split(50).setWorkRemaining(updatedTsFiles.size());
    loopMonitor.subTask(TypeScriptCoreMessages.IDETypeScriptProject_compile_collecting_step);
    for (IFile tsFile : updatedTsFiles) {
        if (loopMonitor.isCanceled()) {
            throw new OperationCanceledException();
        }
        String filename = WorkbenchResourceUtil.getFileName(tsFile);
        loopMonitor
                .subTask(NLS.bind(TypeScriptCoreMessages.IDETypeScriptProject_compile_collecting_file, filename));
        if (!tsFilesToCompile.contains(filename)) {
            collectTsFilesToCompile(filename, client, tsFilesToCompile, tsFilesToClose, loopMonitor);
        }
        loopMonitor.worked(1);
        // loopMonitor.split(1);
    }
    // subMonitor.setWorkRemaining(50);
}
项目:cft    文件:CFUiUtil.java   
/**
 * Validates the given credentials. Throws {@link CoreException} if error
 * occurred during validation.
 * @param userName
 * @param password
 * @param urlText
 * @param displayURL
 * @param selfSigned true if its a server using self-signed certificate. If
 * this information is not known, set this to false
 * @param context
 * 
 * @throws CoreException if validation failed and error type cannot be
 * determined
 * @throws OperationCanceledException if validation is cancelled.
 */
public static void validateCredentials(final CloudFoundryServer cfServer, final String userName, final String password, final String urlText,
        final boolean displayURL, final boolean selfSigned, IRunnableContext context) throws CoreException,
        OperationCanceledException {

    try {
        ICoreRunnable coreRunner = new ICoreRunnable() {
            public void run(IProgressMonitor monitor) throws CoreException {
                String url = urlText;
                if (displayURL) {
                    url = getUrlFromDisplayText(urlText);
                }
                CloudFoundryServerBehaviour.validate(cfServer, url, userName, password, selfSigned, false, null, null, monitor);
            }
        };
        if (context != null) {
            runForked(coreRunner, context);
        }
        else {
            runForked(coreRunner);
        }
    }
    catch (CoreException ce) {
        throw CloudErrorUtil.checkSSLPeerUnverifiedException(ce);
    }
}
项目:che    文件:JavaRenameProcessor.java   
@Override
public final RefactoringStatus checkFinalConditions(
    IProgressMonitor pm, CheckConditionsContext context)
    throws CoreException, OperationCanceledException {
  ResourceChangeChecker checker =
      (ResourceChangeChecker) context.getChecker(ResourceChangeChecker.class);
  IResourceChangeDescriptionFactory deltaFactory = checker.getDeltaFactory();
  RefactoringStatus result = doCheckFinalConditions(pm, context);
  if (result.hasFatalError()) return result;
  IFile[] changed = getChangedFiles();
  for (int i = 0; i < changed.length; i++) {
    deltaFactory.change(changed[i]);
  }
  fRenameModifications = computeRenameModifications();
  fRenameModifications.buildDelta(deltaFactory);
  fRenameModifications.buildValidateEdits(
      (ValidateEditChecker) context.getChecker(ValidateEditChecker.class));
  return result;
}
项目:cft    文件:ConnectCommand.java   
private static Object openConnectDialogInJob(IServer selectedServer) {

        final CloudFoundryServer cloudServer = (CloudFoundryServer) selectedServer.loadAdapter(CloudFoundryServer.class, null);
        Job connectJob = new Job(Messages.ConnectCommand_JOB_CONN_SERVER) {
            @Override
            protected IStatus run(IProgressMonitor monitor) {
                try {
                    openConnectDialog(cloudServer, monitor);
                }
                catch (OperationCanceledException e) {
                    return Status.CANCEL_STATUS;
                }
//              catch (CoreException e) {
////                    Trace.trace(Trace.STRING_SEVERE, "Error calling connect() ", e);
//                  return new Status(IStatus.ERROR, CloudFoundryServerUiPlugin.PLUGIN_ID,
//                          NLS.bind(Messages.ConnectCommand_ERROR_CONNECT, e.getMessage()));
//              }
                return Status.OK_STATUS;
            }
        };
        connectJob.schedule();

        return null;
    }
项目:che    文件:ProcessorBasedRefactoring.java   
protected void internalHandleException(Change change, Throwable e) {
  if (e instanceof OperationCanceledException) return;

  RefactoringParticipant participant = (RefactoringParticipant) fParticipantMap.get(change);
  if (participant != null) {
    disableParticipant(participant, e);
  } else if (fPreChangeParticipants != null) {
    // The main refactoring, get rid of any participants with pre changes
    IStatus status =
        new Status(
            IStatus.ERROR,
            RefactoringCorePlugin.getPluginId(),
            IRefactoringCoreStatusCodes.REFACTORING_EXCEPTION_DISABLED_PARTICIPANTS,
            RefactoringCoreMessages.ProcessorBasedRefactoring_prechange_participants_removed,
            e);
    ResourcesPlugin.log(status);
    Iterator it = fPreChangeParticipants.iterator();
    while (it.hasNext()) {
      participant = (RefactoringParticipant) it.next();
      disableParticipant(participant, null);
    }
  }
}
项目:cft    文件:PushApplicationOperation.java   
@Override
protected void onOperationCanceled(OperationCanceledException e, IProgressMonitor monitor) throws CoreException {

    // Bug 501186: When publish operation is canceled, ensure that the
    // unpublished module is properly handled at the server level. The
    // server always needs to be synchronized with Cloud Foundry, therefore
    // an update on the module will remove it from the server if the
    // associated CF app was never created
    getBehaviour().updateModuleWithAllCloudInfo(getFirstModule(), monitor);

    // Change in behavior:
    // NOTE - Set monitor canceled AFTER updating the module above, as to not cancel the update module operation:
    // If the CF wizard  (callback prepareForDeployment) is canceled by the user, then it should be effectively canceling the monitor
    // for the original publish operation that was initiated in the first place. That way, any adopter code with access to this monitor can
    // check this flag (monitor.isCanceled()) so they can react to the cancel.  One impact on this change is that it will prevent
    // other modules that are in Republish state from being published.  
    // Set monitor to canceled here and not in AbstractPublishApplicationOperation since this operation invokes the wizard.
    monitor.setCanceled(true);

    CloudFoundryPlugin.log(new Status(Status.INFO, CloudFoundryPlugin.PLUGIN_ID,
            "Operation cancelled during prepareForDeployment.", e)); //$NON-NLS-1$
}
项目:bts    文件:RenameElementProcessor.java   
@Override
public RefactoringStatus checkFinalConditions(IProgressMonitor monitor, CheckConditionsContext context)
        throws CoreException, OperationCanceledException {
    SubMonitor progress = SubMonitor.convert(monitor, 100);
    status = statusProvider.get();
    try {
        currentUpdateAcceptor = updateAcceptorProvider.get();
        transferChangeRedirector(currentUpdateAcceptor);
        Iterable<URI> dependentElementURIs = dependentElementsCalculator.getDependentElementURIs(targetElement,
                progress.newChild(1));
        Map<URI, URI> original2newElementURIs = renameElementTracker.renameAndTrack(
                concat(getElementURIs(), dependentElementURIs), newName, resourceSet,
                renameStrategy, progress.newChild(1));
        renameStrategy.createDeclarationUpdates(newName, resourceSet, currentUpdateAcceptor);

        renameArguments = new ElementRenameArguments(targetElementURI, newName, renameStrategy,
                original2newElementURIs);
        referenceUpdaterDispatcher.createReferenceUpdates(renameArguments, resourceSet, currentUpdateAcceptor,
                progress.newChild(98));
        status.merge(currentUpdateAcceptor.getRefactoringStatus());
    } catch (Exception exc) {
        handleException(exc, status);
    }
    return status.getRefactoringStatus();
}
项目:bts    文件:AbstractProcessorBasedRenameParticipant.java   
@Override
public RefactoringStatus checkConditions(IProgressMonitor pm, CheckConditionsContext context)
        throws OperationCanceledException {
    SubMonitor progress = SubMonitor.convert(pm).setWorkRemaining(100);
    try {
        for (RenameProcessor wrappedProcessor : wrappedProcessors) {
            List<Object> targetElements = Arrays.asList(wrappedProcessor.getElements());
            if (!disabledTargets.containsAll(targetElements)) {
                setNewName(wrappedProcessor, getNewName());
                status.merge(wrappedProcessor.checkInitialConditions(progress.newChild(20)));
                if(!status.getRefactoringStatus().hasFatalError())
                    status.merge(wrappedProcessor.checkFinalConditions(progress.newChild(80), context));
            }
        }
    } catch (Exception ce) {
        status.add(ERROR, "Error checking conditions in refactoring participant: {0}. See log for details", ce, LOG);
    }
    return status.getRefactoringStatus();
}
项目:java-things    文件:LockJob.java   
@Override
public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException {
    IWorkspaceRunnable workspaceRunnable = new IWorkspaceRunnable() {
        @Override
        public void run(IProgressMonitor pm) throws CoreException {
            try {
                run2(pm);
            } catch (Exception e) {
                // Re-throw as OperationCanceledException, which will be
                // caught and re-thrown as InterruptedException below.
                throw new OperationCanceledException(e.getMessage());
            }
            // CoreException and OperationCanceledException are propagated
        }
    };
    ResourcesPlugin.getWorkspace().run(workspaceRunnable,
            resource, IResource.NONE, monitor);

    return monitor.isCanceled()? Status.CANCEL_STATUS : Status.OK_STATUS;
}
项目:che    文件:PackageFragmentRootReorgChange.java   
@Override
public final Change perform(IProgressMonitor pm)
    throws CoreException, OperationCanceledException {
  pm.beginTask(getName(), 2);
  try {
    String newName = getNewResourceName();
    IPackageFragmentRoot root = getRoot();
    ResourceMapping mapping = JavaElementResourceMapping.create(root);
    final Change result =
        doPerformReorg(
            getDestinationProjectPath().append(newName), new SubProgressMonitor(pm, 1));
    markAsExecuted(root, mapping);
    return result;
  } finally {
    pm.done();
  }
}