Java 类org.eclipse.core.resources.WorkspaceJob 实例源码

项目:neoscada    文件:DefinitionContributionItem.java   
protected void run ( final String name ) throws URISyntaxException
{
    final WorkspaceJob job = new WorkspaceJob ( String.format ( "Run recipe: %s", name ) ) {

        @Override
        public IStatus runInWorkspace ( final IProgressMonitor monitor ) throws CoreException
        {
            try
            {
                RecipeHelper.processFile ( DefinitionContributionItem.this.parent, DefinitionContributionItem.this.definition, getProfile (), monitor );
            }
            catch ( final Exception e )
            {
                logger.warn ( "Failed to process", e );
                return StatusHelper.convertStatus ( Activator.PLUGIN_ID, e );
            }
            return Status.OK_STATUS;
        }
    };
    job.setUser ( true );
    job.setSystem ( false );
    job.schedule ();
}
项目:gw4e.project    文件:ResourceManager.java   
/**
 * @param folder
 * @param filetorefresh
 * @return
 * @throws CoreException
 * @throws InterruptedException
 */
public static IResource resfreshFileInContainer(IContainer folder, String filetorefresh)
        throws CoreException, InterruptedException {
    final IResource buildfile = find(folder, filetorefresh);
    Job job = new WorkspaceJob("Refresh folders") {
        public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException {
            if (buildfile != null && buildfile.exists()) {
                try {
                    buildfile.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
                } catch (CoreException e) {
                    ResourceManager.logException(e);
                }
            }
            return Status.OK_STATUS;
        }
    };
    job.setUser(true);
    job.schedule();

    return buildfile;
}
项目:gw4e.project    文件:ResourceManager.java   
/**
 * @param file
 */
public static void updateBuildPolicyFileFor(IFile file) {
    Job job = new WorkspaceJob("Updating Build Policies from " + file.getName()) {
        @Override
        public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException {
            ICompilationUnit compilationUnit = JavaCore.createCompilationUnitFrom(file);
            if (compilationUnit != null) {
                if (JDTManager.isGraphWalkerExecutionContextClass(compilationUnit)) {
                    updateBuildPolicyFileForCompilatioUnit(compilationUnit);
                }
            }
            return Status.OK_STATUS;
        }
    };
    job.setUser(true);
    job.setRule(file.getProject());
    job.schedule();
}
项目:gw4e.project    文件:TestConvertor.java   
public void apply() throws CoreException {
    Job job = new WorkspaceJob("GW4E Conversion Job") {
        @Override
        public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException {
            try {
                _apply(monitor);
            } catch (Exception e) {
                DialogManager.displayErrorMessage(MessageUtil.getString("project_conversion"), MessageUtil.getString("an_error_has_occured_while_configuring_the_project"), e);
                ResourceManager.logException(e);
            }
            return Status.OK_STATUS;
        }
    };
    job.setRule(testInterface.getJavaProject().getProject());
    job.setUser(true);
    job.schedule();
}
项目:gw4e.project    文件:BuildPolicyManager.java   
/**
 * @param project
 * @param buildPolicyFile
 * @param graphFilePath
 * @param updatedGenerators
 * @throws IOException
 * @throws CoreException
 * @throws InterruptedException
 */
public static void update(IProject project, IFile buildPolicyFile, String graphFilePath,
        List<String> updatedGenerators) throws IOException, CoreException, InterruptedException {
    Job job = new WorkspaceJob("Updating policies") {
        public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException {
            try {
                _update(project, buildPolicyFile, graphFilePath, updatedGenerators, monitor);
            } catch (FileNotFoundException e) {
                ResourceManager.logException(e);
            }
            return Status.OK_STATUS;
        }
    };
    job.setRule(buildPolicyFile.getProject());
    job.setUser(true);
    job.schedule();
}
项目:gemoc-studio    文件:AbstractExampleWizard.java   
public boolean performFinish() {
    final Collection<ProjectDescriptor> projectDescriptors = getProjectDescriptors();

    WorkspaceJob job = new WorkspaceJob("Unzipping Projects") {
        @Override
        public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException {
            monitor.beginTask("Unzipping Projects", projectDescriptors.size());
            //System.out.println("Unzipping projects...");
            for ( ProjectDescriptor desc : projectDescriptors ) {
                unzipProject(desc, monitor);
                monitor.worked(1);
            }
            //System.out.println("Projects unzipped");
            return Status.OK_STATUS;
        }
    };
    job.setRule(ResourcesPlugin.getWorkspace().getRoot());
    job.schedule();
    return true;
}
项目:gemoc-studio    文件:AbstractExampleWizard.java   
public boolean performFinish() {
    final Collection<ProjectDescriptor> projectDescriptors = getProjectDescriptors();

    WorkspaceJob job = new WorkspaceJob("Unzipping Projects") {
        @Override
        public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException {
            monitor.beginTask("Unzipping Projects", projectDescriptors.size());
            //System.out.println("Unzipping projects...");
            for ( ProjectDescriptor desc : projectDescriptors ) {
                unzipProject(desc, monitor);
                monitor.worked(1);
            }
            //System.out.println("Projects unzipped");
            return Status.OK_STATUS;
        }
    };
    job.setRule(ResourcesPlugin.getWorkspace().getRoot());
    job.schedule();
    return true;
}
项目:google-cloud-eclipse    文件:UpdateCloudToolsEclipseProjectHandler.java   
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
  final IProject project = ProjectFromSelectionHelper.getFirstProject(event);
  if (!CloudToolsEclipseProjectUpdater.hasOldContainers(project)) {
    throw new ExecutionException(Messages.getString("project.appears.up.to.date")); //$NON-NLS-1$
  }
  Job updateJob = new WorkspaceJob(MessageFormat.format(Messages.getString("updating.project"), project.getName())) { //$NON-NLS-1$
    @Override
    public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException {
      return CloudToolsEclipseProjectUpdater.updateProject(project, SubMonitor.convert(monitor));
    }
  };
  updateJob.setRule(project.getWorkspace().getRoot());
  updateJob.setUser(true);
  updateJob.schedule();
  return null;
}
项目:google-cloud-eclipse    文件:CloudToolsEclipseProjectNotifier.java   
@Override
public void earlyStartup() {
  workbench = PlatformUI.getWorkbench();
  workspace = ResourcesPlugin.getWorkspace();

  Job projectUpdater = new WorkspaceJob(Messages.getString("updating.projects.jobname")) { //$NON-NLS-1$
    @Override
    public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException {
      SubMonitor progress = SubMonitor.convert(monitor, 40);
      progress.subTask(Messages.getString("searching.for.projects")); //$NON-NLS-1$
      Collection<IProject> projects = findCandidates(progress.newChild(10));
      if (projects.isEmpty()) {
        return Status.OK_STATUS;
      }
      projects = promptUser(projects, progress.newChild(5));
      if (projects.isEmpty()) {
        return Status.OK_STATUS;
      }
      progress.subTask(Messages.getString("updating.projects")); //$NON-NLS-1$
      return upgradeProjects(projects, progress.newChild(25));
    }
  };
  projectUpdater.setRule(workspace.getRoot());
  projectUpdater.setUser(true);
  projectUpdater.schedule(500);
}
项目:eclipse.jdt.ls    文件:DocumentLifeCycleHandler.java   
public DocumentLifeCycleHandler(JavaClientConnection connection, PreferenceManager preferenceManager, ProjectsManager projectsManager, boolean delayValidation) {
    this.connection = connection;
    this.preferenceManager = preferenceManager;
    this.projectsManager = projectsManager;
    this.sharedASTProvider = SharedASTProvider.getInstance();
    if (delayValidation) {
        this.validationTimer = new WorkspaceJob("Validate documents") {
            @Override
            public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException {
                return performValidation(monitor);
            }

            /* (non-Javadoc)
             * @see org.eclipse.core.runtime.jobs.Job#belongsTo(java.lang.Object)
             */
            @Override
            public boolean belongsTo(Object family) {
                return DOCUMENT_LIFE_CYCLE_JOBS.equals(family);
            }
        };
        this.validationTimer.setRule(ResourcesPlugin.getWorkspace().getRoot());
    }
}
项目:uefi_edk2_wizards_plugin    文件:ProjectStructureUpdater.java   
public static void setResourceChangeListeners(IProject newProjectHandle) {
    Edk2ModuleObservablesManager.getProjectModuleModificationObservable()
    .filter(event -> event.getProject() == newProjectHandle)
    .map(ev -> {
        return new WorkspaceJob("Updating project"){
            @Override 
            public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException {
                Edk2Module module = ev.getNewModule();

                updateIncludePaths(ev.getProject(), module);
                UpdateProjectStructureFromModuleDiff(ev.getProject(), ev.getOldModule(), module);
                ev.getProject().refreshLocal(IResource.DEPTH_INFINITE,monitor);

                return Status.OK_STATUS;
            }
        };
    })
    .subscribe(job -> job.schedule());
}
项目:gwt-eclipse-plugin    文件:BuilderUtilities.java   
/**
 * Schedules a full rebuild on a project.
 * 
 * @param project the project to rebuild
 */
public static void scheduleRebuild(final IProject project) {
  WorkspaceJob buildJob = new WorkspaceJob("Building " + project.getName()) {
    @Override
    public boolean belongsTo(Object family) {
      return ResourcesPlugin.FAMILY_MANUAL_BUILD.equals(family);
    }

    @Override
    public IStatus runInWorkspace(IProgressMonitor monitor)
        throws CoreException {
      project.build(IncrementalProjectBuilder.FULL_BUILD, monitor);
      return Status.OK_STATUS;
    }
  };

  buildJob.setRule(ResourcesPlugin.getWorkspace().getRuleFactory().buildRule());
  buildJob.setUser(true);
  buildJob.schedule();
}
项目:gwt-eclipse-plugin    文件:WebAppProjectCreator.java   
private void jobSetupFacets(final IProject project) {
  // Facet setup is done in a workspace job since this can be long running,
  // hence shouldn't be from the UI thread.
  WorkspaceJob setupFacetsJob = new WorkspaceJob("Setting up facets") {
    @Override
    public IStatus runInWorkspace(IProgressMonitor monitor) {
      try {
        // Create faceted project
        IFacetedProject facetedProject = ProjectFacetsManager.create(project, true, monitor);
        // Add Java facet by default
        IProjectFacet javaFacet = ProjectFacetsManager.getProjectFacet(FACET_JST_JAVA);
        facetedProject.installProjectFacet(javaFacet.getDefaultVersion(), null, monitor);
        return Status.OK_STATUS;
      } catch (CoreException e) {
        // Log and continue
        GdtPlugin.getLogger().logError(e);
        return new Status(IStatus.ERROR, GdtPlugin.PLUGIN_ID, e.toString(), e);
      }
    }
  };
  setupFacetsJob.schedule();
}
项目:pep-tools    文件:RefactoringSupport.java   
public static void renameProduct(final IProductModel productModel, final String newId) {
    Job job = new WorkspaceJob("Renaming Product") {
        @Override
        public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException {
            productModel.getProduct().setId(newId);
            ((IEditableModel) productModel).save();

            IResource productFile = productModel.getUnderlyingResource();
            productFile.move(getNewLocation(productFile, newId + ".product"), false, monitor);

            return Status.OK_STATUS;
        }
    };
    job.setRule(ResourcesPlugin.getWorkspace().getRoot());
    job.schedule();
}
项目:pep-tools    文件:RefactoringSupport.java   
public static void internalRenamePlugin(final IPluginModelBase pluginModel, final String newName) {
    Job renamePluginJob = new WorkspaceJob("Renaming Plugin") {
        @Override
        public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException {
            // rename plugin
            setPluginId(pluginModel, newName);

            // update references
            String oldName = pluginModel.getPluginBase().getId();
            updatePluginReferences(oldName, newName);

            return Status.OK_STATUS;
        }
    };
    renamePluginJob.setRule(ResourcesPlugin.getWorkspace().getRoot());
    renamePluginJob.schedule();
}
项目:pep-tools    文件:RefactoringSupport.java   
public static void internalRenameFeature(final IFeatureModel featureModel, final String newName) {
    Job renameFeatureJob = new WorkspaceJob("Renaming Feature") {
        @Override
        public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException {
            // update references
            String oldName = featureModel.getFeature().getId();
            updateFeatureReferences(oldName, newName);

            // rename feature
            featureModel.getFeature().setId(newName);
            ((IEditableModel) featureModel).save();

            return Status.OK_STATUS;
        }
    };
    renameFeatureJob.setRule(ResourcesPlugin.getWorkspace().getRoot());
    renameFeatureJob.schedule();
}
项目:pep-tools    文件:RefactoringSupport.java   
private static void renameProject(final IProject project, final String newName) {
    Job renameProjectJob = new WorkspaceJob("Renaming Project") {
        @Override
        public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException {
            IPath newLocation = getNewLocation(project, newName);

            // update linked resources
            updateLinkedResources(project, newName);

            // rename/move project
            IProjectDescription description = project.getDescription();
            description.setName(newName);

            if (newLocation != null) {
                description.setLocation(newLocation);
            }

            project.move(description, IResource.FORCE | IResource.SHALLOW, monitor);

            return Status.OK_STATUS;
        }
    };
    renameProjectJob.setRule(ResourcesPlugin.getWorkspace().getRoot());
    renameProjectJob.schedule();
}
项目:gama    文件:WorkspaceModelsManager.java   
public static void linkSampleModelsToWorkspace() {

        final WorkspaceJob job = new WorkspaceJob("Updating the Built-in Models Library") {

            @Override
            public IStatus runInWorkspace(final IProgressMonitor monitor) {
                System.out.println("Asynchronous link of models library...");
                GAMA.getGui().refreshNavigator();
                return GamaBundleLoader.ERRORED ? Status.CANCEL_STATUS : Status.OK_STATUS;
            }

        };
        job.setUser(true);
        job.schedule();

    }
项目:APICloud-Studio    文件:SyncApplicationDialog.java   
public void run(final CountDownLatch threadSignal) {
    for(Control c :composite.getChildren()) {
        if(c instanceof SyncApplicationComposite) {
            final SyncApplicationComposite sac = (SyncApplicationComposite)c;
            Job job = new WorkspaceJob("")
            {
                @Override
                public IStatus runInWorkspace(IProgressMonitor monitor)
                        throws CoreException {
                    try {
                        sac.run(threadSignal);
                    } catch (Exception e) {
                        return Status.CANCEL_STATUS;
                    }
                    return Status.OK_STATUS;
                }
            };
            job.schedule();
        }
    }

}
项目:APICloud-Studio    文件:SyncSVNPathActionDelegate.java   
@Override
public void run(IAction action) {
    Job job = new WorkspaceJob("refresh svn view")
    {
        @Override
        public IStatus runInWorkspace(IProgressMonitor monitor)
                throws CoreException {
            monitor.beginTask("refresh", 2);
            initData();
            monitor.worked(1);
            addSvnToView();
            monitor.worked(2);
            monitor.done();
            return Status.OK_STATUS;
        }
    };
    job.setPriority(Job.SHORT);
    job.setSystem(true);
    job.schedule(200L);
}
项目:APICloud-Studio    文件:AddSvnAndRefreshStartUp.java   
@Override
public void earlyStartup() {
    Job job = new WorkspaceJob("refresh svn view")
    {
        @Override
        public IStatus runInWorkspace(IProgressMonitor monitor)
                throws CoreException {
            monitor.beginTask("refresh", 4);
            initData();
            monitor.worked(1);
            saveFeatureInfo(ip, userName, cookie);
            monitor.worked(1);
            addSvnToView(ip, userName, cookie);
            monitor.worked(1);
            monitor.done();
            return Status.OK_STATUS;
        }
    };
    job.setPriority(Job.SHORT);
    job.setSystem(true);
    job.schedule(200L);
}
项目:cmake-eclipse-helper    文件:CMakeLauncher.java   
public void setupProject(final IProject project) {
    WorkspaceJob job = new WorkspaceJob("Setup CMakeProject " + project) {
        @Override
        public IStatus runInWorkspace(IProgressMonitor monitor)
                throws CoreException {
            try {
                doSetupProject(project, monitor);
                return Status.OK_STATUS;
            } catch (IOException e) {
                e.printStackTrace();
                return new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Unable to setup Project " + e.getLocalizedMessage());
            }
        }
    };
    job.schedule();
}
项目:cmake-eclipse-helper    文件:CMakeLauncher.java   
public void changeArchitecture(final IProject project, final String architecture) throws CoreException {
    WorkspaceJob job = new WorkspaceJob("Change Architecture of CMakeProject " + project) {
        @Override
        public IStatus runInWorkspace(IProgressMonitor monitor)
                throws CoreException {
            try {
                doChangeArchitecture(project, architecture, monitor);
                return Status.OK_STATUS;
            } catch (IOException e) {
                e.printStackTrace();
                return new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Unable to change architecture of Project " + e.getLocalizedMessage());
            }
        }
    };
    job.schedule();
}
项目:cmake-eclipse-helper    文件:CMakeLauncher.java   
public void changeBuildType(final IProject project, final String buildType) throws CoreException {
    WorkspaceJob job = new WorkspaceJob("Change Build-Type of CMakeProject " + project) {
        @Override
        public IStatus runInWorkspace(IProgressMonitor monitor)
                throws CoreException {
            try {
                doChangeBuildType(project, buildType, monitor);
                return Status.OK_STATUS;
            } catch (IOException e) {
                e.printStackTrace();
                return new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Unable to change build type of Project " + e.getLocalizedMessage());
            }
        }
    };
    job.schedule();
}
项目:cmake-eclipse-helper    文件:CMakeTouchDeltaVisitor.java   
public void postProcess() {
    WorkspaceJob job = new WorkspaceJob("Update derived sub-files") {

        @Override
        public IStatus runInWorkspace(IProgressMonitor monitor)
                throws CoreException {

            for(IFile file : toTouch) {
                // FIXME: Check if there is a more lightweight method to achieve good touching
                Activator.logInfo("touch " + file);
                try {
                    CharSequence sequence = FileContentIO.readFileContent(file);
                    FileContentIO.writeFileContent(file, sequence, monitor);
                } catch(Exception ce) {
                    ce.printStackTrace();
                }
            }
            return Status.OK_STATUS;
        }
    };
    job.schedule();
}
项目:cmake-eclipse-helper    文件:CMakeWizard.java   
@Override
public boolean performFinish() {
    final IProject project = createNewProject();
    if (mainPage != null) {
        final DirectoryEntry choice = mainPage.getChoice();

        WorkspaceJob job = new WorkspaceJob("Extract template for " + project) {
            @Override
            public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException {
                extract(project, choice);
                if (!project.hasNature(CMakeNature.ID)) {
                    new CMakeLauncher().setupProject(project);
                }
                return Status.OK_STATUS;
            }
        };
        job.schedule();
    }
    return true;
}
项目:thym    文件:ConvertToHybridProjectHandler.java   
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {

    IProject project = getProject(event);
    if(project != null ){
        final IProject theProject = project;//to pass to Job
        WorkspaceJob job = new WorkspaceJob(NLS.bind("Convert {0} to Hybrid Mobile project", project.getName())) {

            @Override
            public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException {
                HybridProjectCreator creator = new HybridProjectCreator();
                creator.convertProject(theProject, new NullProgressMonitor());
                return Status.OK_STATUS;
            }
        };
        job.schedule();
    }
    return null;
}
项目:Environment    文件:CloudScaleProjectWizard.java   
@Override
public boolean performFinish() {

    final boolean b = super.performFinish();

    WorkspaceJob job = new WorkspaceJob("Configuring Cloudscale project") {

        @Override
        public IStatus runInWorkspace(IProgressMonitor arg0) throws CoreException {
            if (b && getNewProject() != null) {
                IProject p = getNewProject();
                CloudScaleProjectSupport.createDefaultProject(p);
            }

            return Status.OK_STATUS;
        }
    };

    job.setUser(true);
    job.schedule();

    return b;
}
项目:Environment    文件:ToolchainAddon.java   
@PostConstruct
public void postConstruct(IEclipseContext context){
    //put dummy object at initialization

    context.declareModifiable(IActiveResources.class);
    context.modify(IActiveResources.class, new ActiveResources());

    //initialize project resources
    WorkspaceJob resourceInitJob = new WorkspaceJob("Cloudscale resources initialization") {

        @Override
        public IStatus runInWorkspace(IProgressMonitor arg0) throws CoreException {
            try{
                ResourceRegistry.getInstance().initialize();
            }
            catch(Exception e){
                e.printStackTrace();
                return new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage());
            }
            return Status.OK_STATUS;
        }
    };

    resourceInitJob.schedule(3000);
}
项目:jkind-xtext    文件:RunJRealizabilityHandler.java   
private void activateTerminateHandler(final IProgressMonitor monitor, final WorkspaceJob job) {
    final IHandlerService handlerService = (IHandlerService) window
            .getService(IHandlerService.class);
    window.getShell().getDisplay().syncExec(new Runnable() {
        @Override
        public void run() {
            final IHandlerActivation activation = handlerService.activateHandler(TERMINATE_ID,
                    new TerminateHandler(monitor));
            job.addJobChangeListener(new JobChangeAdapter() {
                @Override
                public void done(IJobChangeEvent event) {
                    window.getShell().getDisplay().syncExec(new Runnable() {
                        @Override
                        public void run() {
                            handlerService.deactivateHandler(activation);
                        }
                    });
                }
            });
        }
    });
}
项目:jkind-xtext    文件:RunJKindHandler.java   
private void activateTerminateHandler(final IProgressMonitor monitor, final WorkspaceJob job) {
    final IHandlerService handlerService = (IHandlerService) window
            .getService(IHandlerService.class);
    window.getShell().getDisplay().syncExec(new Runnable() {
        @Override
        public void run() {
            final IHandlerActivation activation = handlerService.activateHandler(TERMINATE_ID,
                    new TerminateHandler(monitor));
            job.addJobChangeListener(new JobChangeAdapter() {
                @Override
                public void done(IJobChangeEvent event) {
                    window.getShell().getDisplay().syncExec(new Runnable() {
                        @Override
                        public void run() {
                            handlerService.deactivateHandler(activation);
                        }
                    });
                }
            });
        }
    });
}
项目:q7.quality.mockups    文件:NestedDialog.java   
Builder workspaceJob() {
    final Runnable temp = this;
    return new Builder() {
        @Override
        public void run() {
            new WorkspaceJob("meh") {

                @Override
                public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException {
                    temp.run();
                    return Status.OK_STATUS;
                }
            }.schedule();
        }
    };
}
项目:k3    文件:AbstractExampleWizard.java   
public boolean performFinish() {
    final Collection<ProjectDescriptor> projectDescriptors = getProjectDescriptors();

    WorkspaceJob job = new WorkspaceJob("Unzipping Projects") {
        @Override
        public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException {
            monitor.beginTask("Unzipping Projects", projectDescriptors.size());
            //System.out.println("Unzipping projects...");
            for ( ProjectDescriptor desc : projectDescriptors ) {
                unzipProject(desc, monitor);
                monitor.worked(1);
            }
            //System.out.println("Projects unzipped");
            return Status.OK_STATUS;
        }
    };
    job.setRule(ResourcesPlugin.getWorkspace().getRoot());
    job.schedule();
    return true;
}
项目:kompren    文件:AbstractExampleWizard.java   
public boolean performFinish() {
    final Collection<ProjectDescriptor> projectDescriptors = getProjectDescriptors();

    WorkspaceJob job = new WorkspaceJob("Unzipping Projects") {
        @Override
        public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException {
            monitor.beginTask("Unzipping Projects", projectDescriptors.size());
            //System.out.println("Unzipping projects...");
            for ( ProjectDescriptor desc : projectDescriptors ) {
                unzipProject(desc, monitor);
                monitor.worked(1);
            }
            //System.out.println("Projects unzipped");
            return Status.OK_STATUS;
        }
    };
    job.setRule(ResourcesPlugin.getWorkspace().getRoot());
    job.schedule();
    return true;
}
项目:smaccm    文件:NoElementHandler.java   
public Object executeURI() {
    // 3/30/2016 MWW: This check is unnecessary for NoElement handlers.
    /*      
     final XtextEditor xtextEditor = EditorUtils.getActiveXtextEditor();
    if (xtextEditor == null) {
        return null;
    }
    */

    if (!saveChanges(window.getActivePage().getDirtyEditors())) {
        return null;
    }

    WorkspaceJob job = new WorkspaceJob(getJobName()) {
        @Override
        public IStatus runInWorkspace(final IProgressMonitor monitor) {
            return runJob(monitor);
        }
    };

    job.setRule(ResourcesPlugin.getWorkspace().getRoot());
    job.schedule();
    return null;
}
项目:gw4e.project    文件:ResourceManager.java   
/**
 * Touch the files located in the folder of the passed file
 * 
 * @param file
 */
public static void touchFolderForRebuild(final IFile file) {
    Job job = new WorkspaceJob("Touch folders") {
        public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException {
            ResourceManager.touchFolderResources(file);
            return Status.OK_STATUS;
        }
    };
    job.schedule();
}
项目:gw4e.project    文件:SettingsManager.java   
/**
 * Return the the preference values for the passed project and key
 * 
 * @param project
 * @param key
 * @return
 */
public static String[] getValues(IProject project, String key, boolean projectScoped) {

    IEclipsePreferences projectPreferences = null;
    if (projectScoped) {
        projectPreferences = getProjectPreference(project);
    } else {
        projectPreferences = getGlobalPreference();
    }
    String values = projectPreferences.get(key, "");
    if ((values == null) || (values.trim().length() == 0) && projectScoped) {
        IEclipsePreferences globalPreferences = getGlobalPreference();
        values = globalPreferences.get(key, "");
        final String gloablValues = values;

        Job job = new WorkspaceJob("GW4E Configure Project Preference Job") {
            @Override
            public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException {
                SubMonitor subMonitor = SubMonitor.convert(monitor, 60);
                try {
                    putValues(project, key, fromString(gloablValues), projectScoped);
                    return Status.OK_STATUS;
                } catch (Exception e) {
                    ResourceManager.logException(e);
                    return Status.CANCEL_STATUS;
                } finally {
                    subMonitor.done();
                }
            }
        };
        job.setRule(project);
        job.setUser(true);
        job.schedule();
    }
    String[] ret = fromString(values);
    return ret;
}
项目:gw4e.project    文件:BuildPoliciesCache.java   
/**
 * @param graphFile
 * @throws CoreException
 * @throws IOException
 * @throws InterruptedException
 */
public void update(List<BuildPolicy> policies) throws CoreException, IOException, InterruptedException {
    Job job = new WorkspaceJob("Updating cache") {
        public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException {
            try {
                IFile fileCache = getCache();
                Properties p = ResourceManager.loadIFileAsProperties(fileCache,
                        getFileCacheName(resource.getProject().getName()));
                String serialized = serialize(policies);
                if (serialized == null) {
                    log("BuildPoliciesCache.update " + fileCache + " failed to updated for resource " + resource
                            + " " + policies.toString());
                    return Status.OK_STATUS;
                }
                p.put(resource.getName(), System.currentTimeMillis() + ":" + serialized);
                log("BuildPoliciesCache.update " + fileCache + " updated for resource " + resource + " "
                        + p.toString());
                save(p, monitor);
                return Status.OK_STATUS;
            } catch (Exception e) {
                ResourceManager.logException(e);
                return Status.CANCEL_STATUS;
            }
        }
    };
    job.setRule(resource.getProject());
    job.setUser(true);
    job.schedule();
}
项目:gw4e.project    文件:SetSyncPoliciesForFileMarkerResolution.java   
@Override
public void run(IMarker marker) {
    Job job = new WorkspaceJob("GW4E QuickFix Job") {
        @Override
        public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException {
            fix(marker, monitor);
            return Status.OK_STATUS;
        }
    };

    job.setRule(marker.getResource().getProject());
    job.setUser(true);
    job.schedule();
}
项目:gw4e.project    文件:AbstractBuildPoliciesMarkerResolution.java   
@Override
public void run(IMarker marker) {
    Job job = new WorkspaceJob("GW4E Fix Job") {
        @Override
        public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException {
            fix(marker, monitor);
            return Status.OK_STATUS;
        }
    };
    job.setRule(marker.getResource().getProject());
    job.setUser(true);
    job.schedule();
}