Java Code Examples for org.eclipse.core.resources.WorkspaceJob#setUser()

The following examples show how to use org.eclipse.core.resources.WorkspaceJob#setUser() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DefinitionContributionItem.java    From neoscada with Eclipse Public License 1.0 6 votes vote down vote up
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 ();
}
 
Example 2
Source File: BuilderUtilities.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * 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();
}
 
Example 3
Source File: WorkspaceModelsManager.java    From gama with GNU General Public License v3.0 6 votes vote down vote up
public static void linkSampleModelsToWorkspace() {

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

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

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

	}
 
Example 4
Source File: RefreshAction.java    From gama with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void run() {
	if (super.getSelectedResources().isEmpty()) {
		final WorkspaceJob job = new WorkspaceJob("Refreshing the GAMA Workspace") {

			@Override
			public IStatus runInWorkspace(final IProgressMonitor monitor) throws CoreException {
				final IRefreshHandler refresh = WorkbenchHelper.getService(IRefreshHandler.class);
				if (refresh != null) {
					refresh.completeRefresh(resources);
				}
				return OK_STATUS;
			};
		};
		job.setUser(true);
		job.schedule();
	} else {
		super.run();
	}
}
 
Example 5
Source File: MarkerUtil.java    From spotbugs with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Create an Eclipse marker for given BugInstance.
 *
 * @param javaProject
 *            the project
 * @param monitor
 */
public static void createMarkers(final IJavaProject javaProject, final SortedBugCollection theCollection, final ISchedulingRule rule,
        IProgressMonitor monitor) {
    if (monitor.isCanceled()) {
        return;
    }
    final List<MarkerParameter> bugParameters = createBugParameters(javaProject, theCollection, monitor);
    if (monitor.isCanceled()) {
        return;
    }
    WorkspaceJob wsJob = new WorkspaceJob("Creating SpotBugs markers") {

        @Override
        public IStatus runInWorkspace(IProgressMonitor monitor1) throws CoreException {
            IProject project = javaProject.getProject();
            try {
                new MarkerReporter(bugParameters, theCollection, project).run(monitor1);
            } catch (CoreException e) {
                FindbugsPlugin.getDefault().logException(e, "Core exception on add marker");
                return e.getStatus();
            }
            return monitor1.isCanceled() ? Status.CANCEL_STATUS : Status.OK_STATUS;
        }
    };
    wsJob.setRule(rule);
    wsJob.setSystem(true);
    wsJob.setUser(false);
    wsJob.schedule();
}
 
Example 6
Source File: BuilderUtilities.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Schedules a full rebuild on all projects in the workspace that have any of
 * the specified natures.
 */
public static void scheduleRebuildAll(final String... natureIds) {
  final IWorkspace workspace = ResourcesPlugin.getWorkspace();
  WorkspaceJob buildJob = new WorkspaceJob("Building workspace projects") {
    @Override
    public boolean belongsTo(Object family) {
      return ResourcesPlugin.FAMILY_MANUAL_BUILD.equals(family);
    }

    @Override
    public IStatus runInWorkspace(IProgressMonitor monitor)
        throws CoreException {
      for (IProject project : workspace.getRoot().getProjects()) {
        for (String natureId : natureIds) {
          if (NatureUtils.hasNature(project, natureId)) {
            project.build(IncrementalProjectBuilder.FULL_BUILD, monitor);
            break;
          }
        }
      }

      return Status.OK_STATUS;
    }
  };

  buildJob.setRule(workspace.getRuleFactory().buildRule());
  buildJob.setUser(true);
  buildJob.schedule();
}