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

项目:neoscada    文件:CreateProjectOperation.java   
@Override
protected void execute ( final IProgressMonitor monitor ) throws CoreException, InvocationTargetException, InterruptedException
{
    monitor.beginTask ( "Creating project", 3 );

    createProject ( new SubProgressMonitor ( monitor, 1 ) );
    try
    {
        createContent ( new SubProgressMonitor ( monitor, 1 ) );
    }
    catch ( final IOException e )
    {
        throw new CoreException ( StatusHelper.convertStatus ( Activator.PLUGIN_ID, e ) );
    }
    this.info.getProject ().refreshLocal ( IResource.DEPTH_INFINITE, new SubProgressMonitor ( monitor, 1 ) );
}
项目:neoscada    文件:CreateProjectOperation.java   
protected void createProject ( final IProgressMonitor monitor ) throws CoreException
{
    monitor.beginTask ( "Create project", 2 );

    final IProject project = this.info.getProject ();

    final IProjectDescription desc = project.getWorkspace ().newProjectDescription ( project.getName () );
    desc.setLocation ( this.info.getProjectLocation () );
    desc.setNatureIds ( new String[] { Constants.PROJECT_NATURE_CONFIGURATION, PROJECT_NATURE_JS } );

    final ICommand jsCmd = desc.newCommand ();
    jsCmd.setBuilderName ( BUILDER_JS_VALIDATOR );

    final ICommand localBuilder = desc.newCommand ();
    localBuilder.setBuilderName ( Constants.PROJECT_BUILDER );

    desc.setBuildSpec ( new ICommand[] { jsCmd, localBuilder } );

    if ( !project.exists () )
    {
        project.create ( desc, new SubProgressMonitor ( monitor, 1 ) );
        project.open ( new SubProgressMonitor ( monitor, 1 ) );
    }
    monitor.done ();
}
项目:neoscada    文件:ClientTemplate.java   
@Override
public void execute ( final IProject project, final IPluginModelBase model, final IProgressMonitor monitor ) throws CoreException
{
    monitor.beginTask ( "Creating client", 5 );

    super.execute ( project, model, new SubProgressMonitor ( monitor, 1 ) ); // COUNT:1

    final Map<String, String> properties = new HashMap<> ();
    properties.put ( "pluginId", this.pluginId ); //$NON-NLS-1$
    properties.put ( "version", this.version ); //$NON-NLS-1$
    properties.put ( "mavenVersion", this.version.replaceFirst ( "\\.qualifier$", "-SNAPSHOT" ) ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$

    createParentProject ( project, properties, new SubProgressMonitor ( monitor, 1 ) ); // COUNT:1
    createProductProject ( project, properties, new SubProgressMonitor ( monitor, 1 ) ); // COUNT:1
    createFeatureProject ( project, properties, new SubProgressMonitor ( monitor, 1 ) ); // COUNT:1

    addFilteredResource ( project, "pom.xml", getResource ( "app-pom.xml" ), "UTF-8", properties, new SubProgressMonitor ( monitor, 1 ) ); // COUNT:1
}
项目:neoscada    文件:ClientTemplate.java   
private void createFeatureProject ( final IProject project, final Map<String, String> properties, final IProgressMonitor monitor ) throws CoreException
{
    monitor.beginTask ( "Creating feature project", 6 );

    final String name = this.pluginId + ".feature"; //$NON-NLS-1$
    final IProjectDescription desc = project.getWorkspace ().newProjectDescription ( name );

    final ICommand featureBuilder = desc.newCommand ();
    featureBuilder.setBuilderName ( "org.eclipse.pde.FeatureBuilder" ); //$NON-NLS-1$

    desc.setNatureIds ( new String[] { "org.eclipse.pde.FeatureNature" } ); //$NON-NLS-1$
    desc.setBuildSpec ( new ICommand[] {
            featureBuilder
    } );

    final IProject newProject = project.getWorkspace ().getRoot ().getProject ( name );
    newProject.create ( desc, new SubProgressMonitor ( monitor, 1 ) ); // COUNT:1
    newProject.open ( new SubProgressMonitor ( monitor, 1 ) ); // COUNT:1

    addFilteredResource ( newProject, "pom.xml", getResource ( "feature-pom.xml" ), "UTF-8", properties, new SubProgressMonitor ( monitor, 1 ) ); // COUNT:1
    addFilteredResource ( newProject, "feature.xml", getResource ( "feature/feature.xml" ), "UTF-8", properties, new SubProgressMonitor ( monitor, 1 ) ); // COUNT:1
    addFilteredResource ( newProject, "feature.properties", getResource ( "feature/feature.properties" ), "ISO-8859-1", properties, new SubProgressMonitor ( monitor, 1 ) ); // COUNT:1
    addFilteredResource ( newProject, "build.properties", getResource ( "feature/build.properties" ), "ISO-8859-1", properties, new SubProgressMonitor ( monitor, 1 ) ); // COUNT:1

    monitor.done ();
}
项目:neoscada    文件:WorldRunner.java   
public void process (
        @Named ( "phase" )
        final String phase,
        final World world, final IContainer output, final IProgressMonitor monitor ) throws Exception
{
    monitor.beginTask ( "Processing world", world.getNodes ().size () );

    for ( final Node node : world.getNodes () )
    {
        monitor.subTask ( String.format ( "Processing node: %s", Nodes.makeName ( node ) ) );
        if ( node instanceof ApplicationNode )
        {
            processNode ( phase, world, (ApplicationNode)node, output, new SubProgressMonitor ( monitor, 1 ) );
        }
    }

    monitor.done ();
}
项目:neoscada    文件:RecipeHelper.java   
public static void processFile ( final IContainer parent, final Definition definition, final Profile profile, final IProgressMonitor monitor ) throws Exception
{
    monitor.beginTask ( makeJobLabel ( definition, profile ), 100 );

    final IFolder output = parent.getFolder ( new Path ( "output" ) ); //$NON-NLS-1$
    if ( output.exists () )
    {
        output.delete ( true, new SubProgressMonitor ( monitor, 9 ) );
    }
    output.create ( true, true, new SubProgressMonitor ( monitor, 1 ) );

    final Builder builder = new Builder ( definition, profile );
    final Recipe recipe = builder.build ();

    try
    {
        final Map<String, Object> initialContent = new HashMap<String, Object> ();
        initialContent.put ( "output", output ); //$NON-NLS-1$

        recipe.execute ( initialContent, new SubProgressMonitor ( monitor, 90 ) );
    }
    finally
    {
        monitor.done ();
    }
}
项目:neoscada    文件:TaskRunner.java   
public void run ( final RunnerContext ctx, final IProgressMonitor monitor )
{
    monitor.beginTask ( "Executing task", this.task.getExecute ().size () );

    for ( final Execute execute : this.task.getExecute () )
    {
        final Executable runnable = convert ( execute, ctx );

        // inject sub progress monitor
        final SubProgressMonitor sm = new SubProgressMonitor ( monitor, 1 );
        ctx.getMap ().put ( KEY_PROGRESS_MONITOR, sm );

        runnable.run ( ctx );

        // remove sub progress monitor
        ctx.getMap ().remove ( KEY_PROGRESS_MONITOR );
        // step is complete
        sm.done ();
    }

    monitor.done ();
}
项目:neoscada    文件:RecipeImpl.java   
@Override
public void execute ( final Map<String, Object> initialContext, final IProgressMonitor monitor )
{
    final RunnerContext ctx = new RunnerContext ( this.properties );
    ctx.getMap ().putAll ( this.initialContent );
    ctx.getMap ().putAll ( initialContext );

    monitor.beginTask ( "Running recipe", this.tasks.size () * MONITOR_AMOUNT );

    try
    {
        for ( final TaskRunner task : this.tasks )
        {
            monitor.subTask ( task.getName () );
            task.run ( ctx, new SubProgressMonitor ( monitor, MONITOR_AMOUNT ) );
        }
    }
    finally
    {
        monitor.done ();
    }

}
项目:gemoc-studio    文件:AbstractNewProjectTemplateWizard.java   
/**
 * Implements the interface method by looping through template sections and
 * executing them sequentially.
 * 
 * @param project
 *            the project
 * @param monitor
 *            the progress monitor to track the execution progress as part
 *            of the overall new project creation operation
 * @return <code>true</code> if the wizard completed the operation with
 *         success, <code>false</code> otherwise.
 */
public boolean performFinish(IProject project,  IProgressMonitor monitor) {
    try {
        ITemplateSection[] sections = getTemplateSections();
        monitor.beginTask("", sections.length); //$NON-NLS-1$
        for (int i = 0; i < sections.length; i++) {
            sections[i].execute(project,  new SubProgressMonitor(monitor, 1));
        }
        //No reason to do this any more with the new editors
        //saveTemplateFile(project, null);
    } catch (CoreException e) {
        PDEPlugin.logException(e);
        return false;
    } finally {
        monitor.done();
    }
    return true;
}
项目:workspacemechanic    文件:MechanicService.java   
/**
 * Refreshes the list of {@link Task}s.
 */
private void updateTasks(IProgressMonitor monitor) {

  monitor.subTask("Looking For Tasks");

  // clear out the items
  collector.reset();
  scanner.scan(collector);

  monitor.subTask("Evaluating Tasks");
  monitor.worked(1);

  // test tasks and figure out which ones are blocked
  updateTaskStatus(new SubProgressMonitor(monitor, collector.getTasks().size()));

  monitor.worked(1);
}
项目: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;
}
项目:team-explorer-everywhere    文件:RenameMultipleCommand.java   
private Item queryItem(final IProgressMonitor progressMonitor, final String title, final String serverPath)
    throws Exception {
    final SubProgressMonitor queryMonitor = new SubProgressMonitor(progressMonitor, 1);
    final QueryItemsCommand queryCommand = new QueryItemsCommand(repository, new ItemSpec[] {
        new ItemSpec(serverPath, RecursionType.NONE)
    }, LatestVersionSpec.INSTANCE, DeletedState.NON_DELETED, ItemType.ANY, GetItemsOptions.UNSORTED);
    queryCommand.setName(title);

    final IStatus queryStatus = queryCommand.run(queryMonitor);

    if (!queryStatus.isOK()) {
        throw new CoreException(queryStatus);
    }

    if (queryCommand.getItemSets() == null || queryCommand.getItemSets().length != 1) {
        return null;
    }

    final Item[] subItems = queryCommand.getItemSets()[0].getItems();

    if (subItems == null || subItems.length != 1) {
        return null;
    }

    return subItems[0];
}
项目:eclemma    文件:TypeTraverser.java   
/**
 * Processes all types and methods reporting all types found to the given
 * {@link ITypeVisitor} instance.
 *
 * @param visitor
 *          type visitor
 * @param monitor
 *          progress monitor to report progress and allow cancelation
 * @throws JavaModelException
 *           thrown by the underlying Java model
 */
public void process(ITypeVisitor visitor, IProgressMonitor monitor)
    throws JavaModelException {
  if (isOnClasspath(root)) {
    IJavaElement[] children = root.getChildren();
    monitor.beginTask("", children.length); //$NON-NLS-1$
    for (final IJavaElement element : children) {
      if (monitor.isCanceled()) {
        break;
      }
      IProgressMonitor submonitor = new SubProgressMonitor(monitor, 1);
      processPackageFragment(visitor, (IPackageFragment) element, submonitor);
    }
  } else {
    TRACER.trace("Package fragment root {0} not on classpath.", //$NON-NLS-1$
        root.getPath());
  }
  monitor.done();
}
项目:subclipse    文件:SVNProjectSetCapability.java   
/**
 * Imports a existing SVN Project to the workbench
 * 
 * @param monitor
 *            project monitor
 * @return true if loaded, else false
 * @throws TeamException
 */

boolean importExistingProject(IProgressMonitor monitor)
        throws TeamException {
    if (directory == null) {
        return false;
    }
    try {
        monitor.beginTask("Importing", 3 * 1000);

        createExistingProject(new SubProgressMonitor(monitor, 1000));

        monitor.subTask("Refreshing " + project.getName());
        RepositoryProvider.map(project, SVNProviderPlugin.getTypeId());
        monitor.worked(1000);
        SVNWorkspaceRoot.setSharing(project, new SubProgressMonitor(
                monitor, 1000));

        return true;
    } catch (CoreException ce) {
        throw new SVNException("Failed to import External SVN Project"
                + ce, ce);
    } finally {
        monitor.done();
    }
}
项目:subclipse    文件:SVNProjectSetCapability.java   
/**
 * Creates a new project in the workbench from an existing one
 * 
 * @param monitor
 * @throws CoreException
 */

void createExistingProject(IProgressMonitor monitor)
        throws CoreException {
    String projectName = project.getName();
    IProjectDescription description;

    try {
        monitor.beginTask("Creating " + projectName, 2 * 1000);

        description = ResourcesPlugin.getWorkspace()
                .loadProjectDescription(
                        new Path(directory + File.separatorChar
                                + ".project")); //$NON-NLS-1$

        description.setName(projectName);
        project.create(description, new SubProgressMonitor(monitor,
                1000));
        project.open(new SubProgressMonitor(monitor, 1000));
    } finally {
        monitor.done();
    }
}
项目:subclipse    文件:RepositoryProviderOperation.java   
public void execute(IProgressMonitor monitor) throws SVNException, InterruptedException {
    Map table = getProviderMapping(getResources());
    Set keySet = table.keySet();
    monitor.beginTask(null, keySet.size() * 1000);
    Iterator iterator = keySet.iterator();
    while (iterator.hasNext()) {
        IProgressMonitor subMonitor = new SubProgressMonitor(monitor, 1000);
        SVNTeamProvider provider = (SVNTeamProvider)iterator.next();
        List list = (List)table.get(provider);
        IResource[] providerResources = (IResource[])list.toArray(new IResource[list.size()]);
        ISchedulingRule rule = getSchedulingRule(provider);
        try {
            Job.getJobManager().beginRule(rule, monitor);
            monitor.setTaskName(getTaskName(provider));
            execute(provider, providerResources, subMonitor);
        } finally {
            Job.getJobManager().endRule(rule);
        }
    }
}
项目:subclipse    文件:RepositoryManager.java   
/**
 * Add the given resources to their associated providers.
 * This schedules the resources for addition; they still need to be committed.
 */
public void add(IResource[] resources, IProgressMonitor monitor) throws TeamException {

    if (monitor == null) {
        monitor = new NullProgressMonitor();
    }
    Map table = getProviderMapping(resources);

    // some of the resources are not associated with shared projects
    if (table.get(null) != null) {
        throw new SVNException(Policy.bind("RepositoryManager.addErrorNotAssociated"));  //$NON-NLS-1$
    }

    // iterate through the svn providers
    Set keySet = table.keySet();
    monitor.beginTask("", keySet.size() * 1000); //$NON-NLS-1$
    monitor.setTaskName(Policy.bind("RepositoryManager.adding")); //$NON-NLS-1$
    Iterator iterator = keySet.iterator();
    while (iterator.hasNext()) {
        IProgressMonitor subMonitor = new SubProgressMonitor(monitor, 1000);
        SVNTeamProvider provider = (SVNTeamProvider)iterator.next();
        List list = (List)table.get(provider);
        IResource[] providerResources = (IResource[])list.toArray(new IResource[list.size()]);
        provider.add(providerResources, IResource.DEPTH_ZERO, subMonitor);
    }       
}
项目:subclipse    文件:RepositoryManager.java   
/**
 * Commit the given resources to their associated providers.
 * 
 * @param resources  the resources to commit
 * @param monitor  the progress monitor
 */
public void commit(IResource[] resources, String comment, boolean keepLocks, IProgressMonitor monitor) throws TeamException {
    if (monitor == null) {
        monitor = new NullProgressMonitor();
    }
    Map table = getProviderMapping(resources);
    Set keySet = table.keySet();
    monitor.beginTask("", keySet.size() * 1000); //$NON-NLS-1$
    monitor.setTaskName(Policy.bind("RepositoryManager.committing")); //$NON-NLS-1$
    Iterator iterator = keySet.iterator();
    while (iterator.hasNext()) {
        IProgressMonitor subMonitor = new SubProgressMonitor(monitor, 1000);
        SVNTeamProvider provider = (SVNTeamProvider)iterator.next();
        List list = (List)table.get(provider);
        IResource[] providerResources = (IResource[])list.toArray(new IResource[list.size()]);
        provider.checkin(providerResources, comment, keepLocks, IResource.DEPTH_INFINITE, subMonitor);
    }
}
项目:eclipse.jdt.ls    文件:RippleMethodFinder.java   
private ITypeHierarchy getCachedHierarchy(IType type, WorkingCopyOwner owner, IProgressMonitor monitor) throws JavaModelException {
    IType rep = fUnionFind.find(type);
    if (rep != null) {
        Collection<IType> collection = fRootReps.get(rep);
        for (Iterator<IType> iter = collection.iterator(); iter.hasNext();) {
            IType root = iter.next();
            ITypeHierarchy hierarchy = fRootHierarchies.get(root);
            if (hierarchy == null) {
                hierarchy = root.newTypeHierarchy(owner, new SubProgressMonitor(monitor, 1));
                fRootHierarchies.put(root, hierarchy);
            }
            if (hierarchy.contains(type)) {
                return hierarchy;
            }
        }
    }
    return null;
}
项目:mesfavoris    文件:ImportBookmarkFileOperation.java   
public void importBookmarkFile(BookmarkId parentId, String fileId, IProgressMonitor monitor)
        throws BookmarksException, IOException {
    try {
        monitor.beginTask("Importing bookmark folder", 100);
        if (applicationFolderId.isPresent()) {
            // add it to the application folder
            AddFileToFolderOperation addFileToFolderOperation = new AddFileToFolderOperation(drive);
            addFileToFolderOperation.addToFolder(applicationFolderId.get(), fileId);
        }
        DownloadHeadRevisionOperation downloadFileOperation = new DownloadHeadRevisionOperation(drive);
        FileContents contents = downloadFileOperation.downloadFile(fileId, new SubProgressMonitor(monitor, 80));
        IBookmarksTreeDeserializer deserializer = new BookmarksTreeJsonDeserializer();
        BookmarksTree bookmarksTree = deserializer.deserialize(
                new StringReader(new String(contents.getFileContents(), "UTF-8")),
                new SubProgressMonitor(monitor, 20));
        bookmarksService.addBookmarksTree(parentId, bookmarksTree, newBookmarksTree -> bookmarkMappingsStore.add(
                bookmarksTree.getRootFolder().getId(), contents.getFile().getId(),
                bookmarkMappingPropertiesProvider.getBookmarkMappingProperties(contents.getFile(), bookmarksTree)));
    } finally {
        monitor.done();
    }

}
项目:mesfavoris    文件:GDriveRemoteBookmarksStore.java   
@Override
public RemoteBookmarksTree load(BookmarkId bookmarkFolderId, IProgressMonitor monitor) throws IOException {
    Drive drive = gDriveConnectionManager.getDrive();
    String bookmarkDirId = gDriveConnectionManager.getApplicationFolderId();
    if (drive == null || bookmarkDirId == null) {
        throw new IllegalStateException("Not connected");
    }
    String fileId = bookmarkMappingsStore.getMapping(bookmarkFolderId).map(mapping -> mapping.getFileId())
            .orElseThrow(() -> new IllegalArgumentException("This folder has not been added to gDrive"));
    try {
        monitor.beginTask("Loading bookmark folder", 100);
        DownloadHeadRevisionOperation downloadFileOperation = new DownloadHeadRevisionOperation(drive);
        FileContents contents = downloadFileOperation.downloadFile(fileId, new SubProgressMonitor(monitor, 80));
        IBookmarksTreeDeserializer deserializer = new BookmarksTreeJsonDeserializer();
        BookmarksTree bookmarkFolderTree = deserializer.deserialize(
                new StringReader(new String(contents.getFileContents(), "UTF-8")),
                new SubProgressMonitor(monitor, 20));
        bookmarkMappingsStore.update(contents.getFile().getId(), bookmarkMappingPropertiesProvider
                .getBookmarkMappingProperties(contents.getFile(), bookmarkFolderTree));
        return new RemoteBookmarksTree(this, bookmarkFolderTree, contents.getFile().getEtag());
    } finally {
        monitor.done();
    }
}
项目:tlaplus    文件:TLCModelLaunchDelegate.java   
private void copyUserModuleOverride(IProgressMonitor monitor, int ticks, IProject project, IPath targetFolderPath,
        IFile tlaFile) throws CoreException {
    final IFile[] userModuleOverrides = ResourceHelper.getModuleOverrides(project, tlaFile);
    for (IFile userModuleOverride : userModuleOverrides) {
        try {
            userModuleOverride.copy(targetFolderPath.append(userModuleOverride.getProjectRelativePath()),
                    IResource.DERIVED | IResource.FORCE, new SubProgressMonitor(monitor, ticks));
        } catch (CoreException e) {
            // If the file could not be copied, the link is obviously stale
            // and has to be removed to not create any problems in the
            // future. A link gets stale if e.g. the user removed the module
            // override manually in the file system.
            userModuleOverride.delete(true, monitor);
        }
    }
}
项目:tlaplus    文件:ModelHelper.java   
/**
 * Copies the module files that are extended by specRootFile into the
 * folder given by targetFolderPath.
 * @param specRootFile the file corresponding to the root module
 * @param targetFolderPath the path of the folder to which the extended modules are to be copied
 * @param monitor - the progress monitor
 * @param STEP the unit of work this corresponds to in the progress monitor 
 * @param project the project that contains the specRootFile
 * @throws CoreException
 */
public static void copyExtendedModuleFiles(IFile specRootFile, IPath targetFolderPath, IProgressMonitor monitor,
        int STEP, IProject project) throws CoreException
{
    // get the list of dependent modules
    List<String> extendedModules = ToolboxHandle.getExtendedModules(specRootFile.getName());

    // iterate and copy modules that are needed for the spec
    IFile moduleFile = null;
    for (int i = 0; i < extendedModules.size(); i++)
    {
        String module = extendedModules.get(i);
        // only take care of user modules
        if (ToolboxHandle.isUserModule(module))
        {
            moduleFile = ResourceHelper.getLinkedFile(project, module, false);
            if (moduleFile != null)
            {
                moduleFile.copy(targetFolderPath.append(moduleFile.getProjectRelativePath()), IResource.DERIVED
                        | IResource.FORCE, new SubProgressMonitor(monitor, STEP / extendedModules.size()));
            }

            // TODO check the existence of copied files
        }
    }
}
项目:che    文件:ExtractTempRefactoring.java   
@Override
public RefactoringStatus checkInitialConditions(IProgressMonitor pm) throws CoreException {
  try {
    pm.beginTask("", 6); // $NON-NLS-1$

    RefactoringStatus result =
        Checks.validateModifiesFiles(
            ResourceUtil.getFiles(new ICompilationUnit[] {fCu}), getValidationContext());
    if (result.hasFatalError()) return result;

    if (fCompilationUnitNode == null) {
      fCompilationUnitNode =
          RefactoringASTParser.parseWithASTProvider(fCu, true, new SubProgressMonitor(pm, 3));
    } else {
      pm.worked(3);
    }

    result.merge(checkSelection(new SubProgressMonitor(pm, 3)));
    if (!result.hasFatalError() && isLiteralNodeSelected()) fReplaceAllOccurrences = false;
    return result;

  } finally {
    pm.done();
  }
}
项目:cft    文件:ServerHandler.java   
protected IRuntime createRuntime(IServerType st, IPath path, IProgressMonitor monitor, IOverwriteQuery query)
        throws CoreException {
    IRuntime runtime = ServerCore.findRuntime(runtimeName);
    if (runtime != null) {
        if (!query(query, NLS.bind(Messages.ServerHandler_QUERY_RUNTIME_EXISTS,
                runtimeName))) {
            monitor.worked(1);
            return runtime;
        }
        else {
            runtime.delete();
        }
    }
    IRuntimeWorkingCopy wc = st.getRuntimeType().createRuntime(runtimeName, new SubProgressMonitor(monitor, 1));
    wc.setName(runtimeName);

    if (path != null) {
        wc.setLocation(path);
    }

    runtime = wc.save(true, new SubProgressMonitor(monitor, 1));

    return runtime;
}
项目:cft    文件:ServerHandler.java   
private IServer createServer(IServerType st, IRuntime runtime, IProgressMonitor monitor, IOverwriteQuery query,
        ServerHandlerCallback callback) throws CoreException {
    IServer server = ServerCore.findServer(serverName);
    if (server != null) {
        if (!query(query,
                NLS.bind(Messages.ServerHandler_QUERY_SERVER_EXISTS, serverName))) {
            monitor.worked(1);
            return server;
        }
        else {
            IFolder serverConfiguration = server.getServerConfiguration();
            server.delete();
            if (serverConfiguration != null) {
                serverConfiguration.delete(true, true, monitor);
            }
        }
    }

    IServerWorkingCopy wc = st.createServer(serverName, null, runtime, new SubProgressMonitor(monitor, 1));
    wc.setName(serverName);
    if (callback != null) {
        callback.configureServer(wc);
    }
    server = wc.save(true, new SubProgressMonitor(monitor, 1));
    return server;
}
项目:APICloud-Studio    文件:RepositoryProviderOperation.java   
public void execute(IProgressMonitor monitor) throws SVNException, InterruptedException {
    Map table = getProviderMapping(getResources());
    Set keySet = table.keySet();
    monitor.beginTask(null, keySet.size() * 1000);
    Iterator iterator = keySet.iterator();
    while (iterator.hasNext()) {
        IProgressMonitor subMonitor = new SubProgressMonitor(monitor, 1000);
        SVNTeamProvider provider = (SVNTeamProvider)iterator.next();
        List list = (List)table.get(provider);
        IResource[] providerResources = (IResource[])list.toArray(new IResource[list.size()]);
        ISchedulingRule rule = getSchedulingRule(provider);
        try {
            Job.getJobManager().beginRule(rule, monitor);
            monitor.setTaskName(getTaskName(provider));
            execute(provider, providerResources, subMonitor);
        } finally {
            Job.getJobManager().endRule(rule);
        }
    }
}
项目:Migrate-Skeletal-Implementation-to-Interface-Refactoring    文件:SkeletalImplementatonClassRemovalUtils.java   
private static boolean superClassImplementsDestinationInterface(IType type, IType destinationInterface,
        Optional<IProgressMonitor> monitor) throws JavaModelException {
    monitor.ifPresent(m -> m.beginTask("Checking superclass ...", IProgressMonitor.UNKNOWN));
    try {
        if (type.getSuperclassName() != null) { // there's a superclass.
            ITypeHierarchy superTypeHierarchy = MigrateSkeletalImplementationToInterfaceRefactoringProcessor
                    .getSuperTypeHierarchy(type,
                            monitor.map(m -> new SubProgressMonitor(m, IProgressMonitor.UNKNOWN)));
            IType superclass = superTypeHierarchy.getSuperclass(type);
            return Arrays.stream(superTypeHierarchy.getAllSuperInterfaces(superclass))
                    .anyMatch(i -> i.equals(destinationInterface));
        }
    } finally {
        monitor.ifPresent(IProgressMonitor::done);
    }

    return true; // vacuously true since there's no superclass.
}
项目:Migrate-Skeletal-Implementation-to-Interface-Refactoring    文件:MigrateSkeletalImplementationToInterfaceRefactoringProcessor.java   
private RefactoringStatus checkCandidateDestinationInterfaces(IMethod sourceMethod,
        final Optional<IProgressMonitor> monitor) throws JavaModelException {
    RefactoringStatus status = new RefactoringStatus();

    IType[] interfaces = getCandidateDestinationInterfaces(sourceMethod,
            monitor.map(m -> new SubProgressMonitor(m, 1)));

    if (interfaces.length == 0)
        addErrorAndMark(status, PreconditionFailure.NoMethodsInTypesWithNoCandidateTargetTypes, sourceMethod,
                sourceMethod.getDeclaringType());
    else if (interfaces.length > 1)
        // TODO: For now, let's make sure there's only one candidate type
        // #129.
        addErrorAndMark(status, PreconditionFailure.NoMethodsInTypesWithMultipleCandidateTargetTypes, sourceMethod,
                sourceMethod.getDeclaringType());

    return status;
}
项目:che    文件:MoveCuUpdateCreator.java   
private static SearchResultGroup[] getReferences(
    ICompilationUnit unit, IProgressMonitor pm, RefactoringStatus status) throws CoreException {
  final SearchPattern pattern =
      RefactoringSearchEngine.createOrPattern(unit.getTypes(), IJavaSearchConstants.REFERENCES);
  if (pattern != null) {
    String binaryRefsDescription =
        Messages.format(
            RefactoringCoreMessages.ReferencesInBinaryContext_ref_in_binaries_description,
            BasicElementLabels.getFileName(unit));
    ReferencesInBinaryContext binaryRefs = new ReferencesInBinaryContext(binaryRefsDescription);
    Collector requestor = new Collector(((IPackageFragment) unit.getParent()), binaryRefs);
    IJavaSearchScope scope = RefactoringScopeFactory.create(unit, true, false);

    SearchResultGroup[] result =
        RefactoringSearchEngine.search(
            pattern, scope, requestor, new SubProgressMonitor(pm, 1), status);
    binaryRefs.addErrorIfNecessary(status);
    return result;
  }
  return new SearchResultGroup[] {};
}
项目:che    文件:JavaModelUtil.java   
/**
 * Applies an text edit to a compilation unit. Filed bug 117694 against jdt.core.
 *
 * @param cu the compilation unit to apply the edit to
 * @param edit the edit to apply
 * @param save is set, save the CU after the edit has been applied
 * @param monitor the progress monitor to use
 * @throws CoreException Thrown when the access to the CU failed
 * @throws ValidateEditException if validate edit fails
 */
public static void applyEdit(
    ICompilationUnit cu, TextEdit edit, boolean save, IProgressMonitor monitor)
    throws CoreException, ValidateEditException {
  IFile file = (IFile) cu.getResource();
  if (!save || !file.exists()) {
    cu.applyTextEdit(edit, monitor);
  } else {
    if (monitor == null) {
      monitor = new NullProgressMonitor();
    }
    monitor.beginTask(CorextMessages.JavaModelUtil_applyedit_operation, 2);
    try {
      //                IStatus status= Resources.makeCommittable(file, null);
      //                if (!status.isOK()) {
      //                    throw new ValidateEditException(status);
      //                }

      cu.applyTextEdit(edit, new SubProgressMonitor(monitor, 1));

      cu.save(new SubProgressMonitor(monitor, 1), true);
    } finally {
      monitor.done();
    }
  }
}
项目:Migrate-Skeletal-Implementation-to-Interface-Refactoring    文件:MigrateSkeletalImplementationToInterfaceRefactoringProcessor.java   
private boolean isEquivalent(IMethod method, IMethod otherMethod, Optional<IProgressMonitor> monitor)
        throws JavaModelException {
    monitor.ifPresent(m -> m.beginTask("Checking method equivalence ...", 2));

    MethodDeclaration methodDeclaration = this.getMethodDeclaration(method,
            monitor.map(m -> new SubProgressMonitor(m, 1)));

    MethodDeclaration otherMethodDeclaration = this.getMethodDeclaration(otherMethod,
            monitor.map(m -> new SubProgressMonitor(m, 1)));

    monitor.ifPresent(IProgressMonitor::done);

    Block methodDeclarationBody = methodDeclaration.getBody();
    Block otherMethodDeclarationBody = otherMethodDeclaration.getBody();

    boolean match = methodDeclarationBody.subtreeMatch(new ASTMatcher(), otherMethodDeclarationBody);
    return match;
}
项目:dockerfoundry    文件:ServerHandler.java   
protected IRuntime createRuntime(IServerType st, IPath path, IProgressMonitor monitor, IOverwriteQuery query)
        throws CoreException {
    IRuntime runtime = ServerCore.findRuntime(runtimeName);
    if (runtime != null) {
        if (!query(query, NLS.bind(Messages.ServerHandler_QUERY_RUNTIME_EXISTS,
                runtimeName))) {
            monitor.worked(1);
            return runtime;
        }
        else {
            runtime.delete();
        }
    }
    IRuntimeWorkingCopy wc = st.getRuntimeType().createRuntime(runtimeName, new SubProgressMonitor(monitor, 1));
    wc.setName(runtimeName);

    if (path != null) {
        wc.setLocation(path);
    }

    runtime = wc.save(true, new SubProgressMonitor(monitor, 1));

    return runtime;
}
项目:dockerfoundry    文件:ServerHandler.java   
private IServer createServer(IServerType st, IRuntime runtime, IProgressMonitor monitor, IOverwriteQuery query,
        ServerHandlerCallback callback) throws CoreException {
    IServer server = ServerCore.findServer(serverName);
    if (server != null) {
        if (!query(query,
                NLS.bind(Messages.ServerHandler_QUERY_SERVER_EXISTS, serverName))) {
            monitor.worked(1);
            return server;
        }
        else {
            IFolder serverConfiguration = server.getServerConfiguration();
            server.delete();
            if (serverConfiguration != null) {
                serverConfiguration.delete(true, true, monitor);
            }
        }
    }

    IServerWorkingCopy wc = st.createServer(serverName, null, runtime, new SubProgressMonitor(monitor, 1));
    wc.setName(serverName);
    if (callback != null) {
        callback.configureServer(wc);
    }
    server = wc.save(true, new SubProgressMonitor(monitor, 1));
    return server;
}
项目:agui_eclipse_plugin    文件:AguiNature.java   
public static void addNatureToProjectDescription(IProject project,
        String natureId, IProgressMonitor monitor) throws CoreException {
    if (!project.hasNature(natureId)) {
        IProjectDescription description = project.getDescription();
        String[] natures = description.getNatureIds();
        String[] newNatures = new String[natures.length + 1];

        // Android natures always come first.
        if (natureId.equals(AguiNature.NATURE_ID)) {
            System.arraycopy(natures, 0, newNatures, 1, natures.length);
            newNatures[0] = natureId;
        } else {
            System.arraycopy(natures, 0, newNatures, 0, natures.length);
            newNatures[natures.length] = natureId;
        }

        description.setNatureIds(newNatures);
        project.setDescription(description, new SubProgressMonitor(monitor, 10)); // (FORCE, KEEP_HISTORY and AVOID_NATURE_CONFIG)
    }
}
项目:agui_eclipse_plugin    文件:AguiProjectMaker.java   
/**
 * Adds the given folder to the project's class path.
 *
 * @param javaProject The Java Project to update.
 * @param sourceFolders Template Parameters.
 * @param monitor An existing monitor.
 * @throws JavaModelException if the classpath could not be set.
 */
private void setupSourceFolders(IJavaProject javaProject, String[] sourceFolders,
        IProgressMonitor monitor) throws JavaModelException {
    IProject project = javaProject.getProject();
    // get the list of entries.
    IClasspathEntry[] entries = javaProject.getRawClasspath();
    // remove the project as a source folder (This is the default)
    entries = removeSourceClasspath(entries, project);
    // add the source folders.
    for (String sourceFolder : sourceFolders) {
        IFolder srcFolder = project.getFolder(sourceFolder);
        // remove it first in case.
        entries = removeSourceClasspath(entries, srcFolder);
        entries = ProjectHelper.addEntryToClasspath(entries,
                JavaCore.newSourceEntry(srcFolder.getFullPath()));
    }
    javaProject.setRawClasspath(entries, new SubProgressMonitor(monitor, 10));
}
项目:synergyview    文件:NewProjectWizard.java   
/**
    * Creates the project.
    * 
    * @param description
    *            the description
    * @param projectHandle
    *            the project handle
    * @param monitor
    *            the monitor
    * @throws CoreException
    *             the core exception
    */
   public void createProject(IProjectDescription description, IProject projectHandle, IProgressMonitor monitor) throws CoreException {
try {
    monitor.beginTask(ResourceLoader.getString("DIALOG_PROGRESS_MESSAGE_NEW_PROJECT"), 5);

    projectHandle.create(description, new SubProgressMonitor(monitor, 1));

    if (monitor.isCanceled()) {
    throw new OperationCanceledException();
    }

    projectHandle.open(new SubProgressMonitor(monitor, 2));
    IFolder mediaFolder = projectHandle.getFolder(MediaRootNode.getMediaFolderName());
    mediaFolder.create(false, true, new SubProgressMonitor(monitor, 3));
} finally {
    monitor.done();
}
   }
项目:APICloud-Studio    文件:RepositoryManager.java   
/**
 * Add the given resources to their associated providers.
 * This schedules the resources for addition; they still need to be committed.
 */
public void add(IResource[] resources, IProgressMonitor monitor) throws TeamException {

    if (monitor == null) {
        monitor = new NullProgressMonitor();
    }
    Map table = getProviderMapping(resources);

    // some of the resources are not associated with shared projects
    if (table.get(null) != null) {
        throw new SVNException(Policy.bind("RepositoryManager.addErrorNotAssociated"));  //$NON-NLS-1$
    }

    // iterate through the svn providers
    Set keySet = table.keySet();
    monitor.beginTask("", keySet.size() * 1000); //$NON-NLS-1$
    monitor.setTaskName(Policy.bind("RepositoryManager.adding")); //$NON-NLS-1$
    Iterator iterator = keySet.iterator();
    while (iterator.hasNext()) {
        IProgressMonitor subMonitor = new SubProgressMonitor(monitor, 1000);
        SVNTeamProvider provider = (SVNTeamProvider)iterator.next();
        List list = (List)table.get(provider);
        IResource[] providerResources = (IResource[])list.toArray(new IResource[list.size()]);
        provider.add(providerResources, IResource.DEPTH_ZERO, subMonitor);
    }       
}
项目:che    文件:ModelProvider.java   
/**
 * Return a set of traversals that cover the given resource mappings. The provided mappings must
 * be from this provider or one of the providers this provider extends.
 *
 * <p>The default implementation accumulates the traversals from the given mappings. Subclasses
 * can override to provide a more optimal transformation.
 *
 * @param mappings the mappings being mapped to resources
 * @param context the context used to determine the set of traversals that cover the mappings
 * @param monitor a progress monitor, or <code>null</code> if progress reporting is not desired
 * @return a set of traversals that cover the given mappings
 * @exception CoreException
 */
public ResourceTraversal[] getTraversals(
    ResourceMapping[] mappings, ResourceMappingContext context, IProgressMonitor monitor)
    throws CoreException {
  try {
    monitor.beginTask("", 100 * mappings.length); // $NON-NLS-1$
    List<ResourceTraversal> traversals = new ArrayList<ResourceTraversal>();
    for (int i = 0; i < mappings.length; i++) {
      ResourceMapping mapping = mappings[i];
      traversals.addAll(
          Arrays.asList(mapping.getTraversals(context, new SubProgressMonitor(monitor, 100))));
    }
    return traversals.toArray(new ResourceTraversal[traversals.size()]);
  } finally {
    monitor.done();
  }
}
项目:che    文件:ProjectDescription.java   
public void createExistentResourceFromHandle(IResource resource, IProgressMonitor monitor)
    throws CoreException {
  Assert.isLegal(resource instanceof IProject);
  if (resource.exists()) {
    return;
  }
  IProject projectHandle = (IProject) resource;
  monitor.beginTask("", 200); // $NON-NLS-1$
  monitor.setTaskName(UndoMessages.FolderDescription_NewFolderProgress);
  if (projectDescription == null) {
    projectHandle.create(new SubProgressMonitor(monitor, 100));
  } else {
    projectHandle.create(projectDescription, new SubProgressMonitor(monitor, 100));
  }

  if (monitor.isCanceled()) {
    throw new OperationCanceledException();
  }
  if (openOnCreate) {
    projectHandle.open(IResource.NONE, new SubProgressMonitor(monitor, 100));
  }
  monitor.done();
}