Java Code Examples for org.eclipse.core.resources.WorkspaceJob#setRule()
The following examples show how to use
org.eclipse.core.resources.WorkspaceJob#setRule() .
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: BuilderUtilities.java From gwt-eclipse-plugin with Eclipse Public License 1.0 | 6 votes |
/** * 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 2
Source File: MarkerUtils.java From xds-ide with Eclipse Public License 1.0 | 5 votes |
public static void scheduleDeleteMarkers(IProject p){ WorkspaceJob deleteMarkersJob = new WorkspaceJob(Messages.BuilderUtils_DeleteMarkers) { @Override public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException { MarkerUtils.deleteBuildProblemMarkers(p, true, IResource.DEPTH_INFINITE); return Status.OK_STATUS; } }; //TODO : is this a correct scheduling rule? Perhaps we should include every individual IFile from project... deleteMarkersJob.setRule(ResourceUtils.createRule(Arrays.asList(p))); deleteMarkersJob.schedule(); }
Example 3
Source File: MarkerUtil.java From spotbugs with GNU Lesser General Public License v2.1 | 5 votes |
/** * 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 4
Source File: BuilderUtilities.java From gwt-eclipse-plugin with Eclipse Public License 1.0 | 5 votes |
/** * 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(); }
Example 5
Source File: MarkerManager.java From xds-ide with Eclipse Public License 1.0 | 4 votes |
/** * Creates a bunch of markers in the workspace as the single atomic operation - thus resulting in a single delta * @param fileToMarkerInfo * @param progressMonitor */ public static void commitParserMarkers(final Map<IFileStore, FileMarkerInfo> fileToMarkerInfo, IProgressMonitor progressMonitor) { int i = 0; final IFileStore[] files = new IFileStore[fileToMarkerInfo.size()]; IFile[] ifiles = new IFile[fileToMarkerInfo.size()]; for (Entry<IFileStore, FileMarkerInfo> keyValue : fileToMarkerInfo.entrySet()) { files[i] = keyValue.getKey(); ifiles[i] = keyValue.getValue().getIFile(); i++; } ISchedulingRule rule = ResourceUtils.createRule(Arrays.asList(ifiles)); WorkspaceJob job = new WorkspaceJob("Update markers job") { //$NON-NLS-1$ @Override public IStatus runInWorkspace(IProgressMonitor monitor){ for (int j = 0; j < files.length; j++) { FileMarkerInfo fileMarkerInfo = fileToMarkerInfo.get(files[j]); if (fileMarkerInfo != null) { IFile iFile = fileMarkerInfo.getIFile(); try { if (iFile.exists()) { Map<Integer, IMarker> offset2BuildMarker = createOffset2BuildMarkerMap(iFile); MarkerUtils.deleteParserProblemMarkers(iFile, IResource.DEPTH_INFINITE); Set<MarkerInfo> parserMarkers = fileMarkerInfo.getParserMarkers(); for (MarkerInfo parserMarker : parserMarkers) { if (offset2BuildMarker.containsKey(parserMarker.getCharStart())) { continue; } IMarker marker = iFile.createMarker(parserMarker.getType()); marker.setAttributes(parserMarker.getAttributes()); } } } catch (CoreException e) { LogHelper.logError(e); } } } return Status.OK_STATUS; } }; job.setRule(rule); job.schedule(); }
Example 6
Source File: ImportMavenSarlProjectWizard.java From sarl with Apache License 2.0 | 4 votes |
/** Create the import job. * * @param projects the projects to import. * @return the import job. */ protected WorkspaceJob createImportJob(Collection<MavenProjectInfo> projects) { final WorkspaceJob job = new ImportMavenSarlProjectsJob(projects, this.workingSets, this.importConfiguration); job.setRule(MavenPlugin.getProjectConfigurationManager().getRule()); return job; }