本文整理匯總了Java中org.eclipse.core.resources.WorkspaceJob.setRule方法的典型用法代碼示例。如果您正苦於以下問題:Java WorkspaceJob.setRule方法的具體用法?Java WorkspaceJob.setRule怎麽用?Java WorkspaceJob.setRule使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.eclipse.core.resources.WorkspaceJob
的用法示例。
在下文中一共展示了WorkspaceJob.setRule方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: performFinish
import org.eclipse.core.resources.WorkspaceJob; //導入方法依賴的package包/類
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;
}
示例2: scheduleRebuild
import org.eclipse.core.resources.WorkspaceJob; //導入方法依賴的package包/類
/**
* 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();
}
示例3: executeURI
import org.eclipse.core.resources.WorkspaceJob; //導入方法依賴的package包/類
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;
}
示例4: scheduleRebuildAll
import org.eclipse.core.resources.WorkspaceJob; //導入方法依賴的package包/類
/**
* 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();
}
示例5: resourceChanged
import org.eclipse.core.resources.WorkspaceJob; //導入方法依賴的package包/類
/**
* Process the event into changes and kick off a job to handle those changes.
*/
@Override
public void resourceChanged(IResourceChangeEvent event) {
final Map<IResource, List<CHANGE_TYPE>> changes = new AutoListMap<IResource, CHANGE_TYPE>(IResource.class);
resourceDeltaChanged(event.getDelta(), changes);
int count = changes.size();
if (count != 0) {
final String message;
if (count == 1) {
IResource resourceName = changes.keySet().iterator().next();
message = "Checking " + resourceName.getName() + " for profiles";
} else {
message = "Checking " + count + " resources for profiles";
}
WorkspaceJob job = new WorkspaceJob(message) {
@Override
@SuppressWarnings("unused")
public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException {
synchronized (disposeLock) {
if (synchronizer != null) {
return handleResourceChanges(changes, message, monitor);
}
}
return Status.OK_STATUS;
}
};
// job.setSystem(true); // SPF-6488: Hide resource checking
job.setRule(project);
job.schedule();
}
}
示例6: violationsRemoved
import org.eclipse.core.resources.WorkspaceJob; //導入方法依賴的package包/類
@Override
public void violationsRemoved(Set<ViolationTracker> violations) {
final List<IMarker> markers = new ArrayList<IMarker>();
synchronized (violationToMarkerMap) {
for (ViolationTracker violationTracker : violations) {
IMarker marker = violationToMarkerMap.remove(violationTracker);
if (marker != null) {
markers.add(marker);
Violation violation = violationTracker.getViolation();
if (violation != null) {
removeMarkerFromViolationElements(violation, marker);
}
}
}
}
if (!markers.isEmpty()) {
WorkspaceJob job = new WorkspaceJob("marker removal") {
/**
* @throws CoreException
*/
@Override
public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException {
removeMarkers(markers);
return Status.OK_STATUS;
}
};
job.setRule(resource);
job.schedule();
}
}
示例7: resourceChanged
import org.eclipse.core.resources.WorkspaceJob; //導入方法依賴的package包/類
@Override
public void resourceChanged(IResourceChangeEvent event) {
if (event.getType() == IResourceChangeEvent.POST_CHANGE) {
try {
if (workspace.isTreeLocked()) {
// do nothing
return;
} else {
treeGotUnlocked = true;
}
WorkspaceJob job = new WorkspaceJob("marker updating") {
/**
* @throws CoreException
*/
@Override
public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException {
updateMarkers(markerAttributes);
return Status.OK_STATUS;
}
};
job.setRule(resource);
job.schedule();
} finally {
if(treeGotUnlocked) {
workspace.removeResourceChangeListener(this);
}
}
}
}
示例8: handleRetrieveResults
import org.eclipse.core.resources.WorkspaceJob; //導入方法依賴的package包/類
private void handleRetrieveResults(RetrieveResultExt retrieveResultHandler, IProgressMonitor monitor)
throws InterruptedException, IOException {
if (retrieveResultHandler == null) {
if (logger.isInfoEnabled()) {
logger.info("No results to handle - retrieveResultHandler is null");
}
return;
}
if (retrieveResultHandler.hasMessages()) {
for (RetrieveMessage retrieveMessage : retrieveResultHandler.getMessageHandler().getMessages()) {
logger.warn(
"Failed to retrieve: '" + retrieveMessage.getFileName() + "': " + retrieveMessage.getProblem());
}
}
final ProjectPackageList projectPackageList = retrieveResultHandler.getProjectPackageList();
if (Utils.isEmpty(projectPackageList)) {
if (logger.isDebugEnabled()) {
logger.debug("No results to handle - project package list is empty");
}
return;
}
monitorCheckSubTask(monitor, Messages.getString("Components.Generating"));
projectPackageList.setProject(getProjectModel().getProject());
projectPackageList
.generateComponents(retrieveResultHandler.getZipFile(), retrieveResultHandler.getFileMetadataHandler());
monitorCheckSubTask(monitor, Messages.getString("Components.Saving"));
WorkspaceJob job =
new ForceProjectRefreshJob.ForceProjectRefreshProject(projectPackageList, projectPackageList.getProject());
job.setRule(projectPackageList.getProject());
job.schedule();
monitorCheck(monitor);
}
示例9: createMarkers
import org.eclipse.core.resources.WorkspaceJob; //導入方法依賴的package包/類
/**
* 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 FindBugs 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();
}
示例10: executeURI
import org.eclipse.core.resources.WorkspaceJob; //導入方法依賴的package包/類
public Object executeURI(final URI uri) {
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 xtextEditor.getDocument().readOnly(
new IUnitOfWork<IStatus, XtextResource>() {
@Override
public IStatus exec(XtextResource resource) throws Exception {
EObject eobj = resource.getResourceSet().getEObject(uri, true);
if (eobj instanceof Element) {
return runJob((Element) eobj, monitor);
} else {
return Status.CANCEL_STATUS;
}
}
});
}
};
job.setRule(ResourcesPlugin.getWorkspace().getRoot());
job.schedule();
return null;
}
示例11: executeURI
import org.eclipse.core.resources.WorkspaceJob; //導入方法依賴的package包/類
public Object executeURI(final URI uri) {
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 xtextEditor.getDocument().readOnly(new IUnitOfWork<IStatus, XtextResource>() {
@Override
public IStatus exec(XtextResource resource) throws Exception {
EObject eobj = resource.getResourceSet().getEObject(uri, true);
if (eobj instanceof Element) {
return runJob((Element) eobj, monitor);
} else {
return Status.CANCEL_STATUS;
}
}
});
}
};
job.setRule(ResourcesPlugin.getWorkspace().getRoot());
job.schedule();
return null;
}
示例12: executeURI
import org.eclipse.core.resources.WorkspaceJob; //導入方法依賴的package包/類
public Object executeURI(final URI uri) {
final XtextEditor xtextEditor = EditorUtils.getActiveXtextEditor();
if (xtextEditor == null) {
return null;
}
if (!saveChanges(window.getActivePage().getDirtyEditors())) {
return null;
}
WorkspaceJob job = getWorkspaceJob(xtextEditor, uri);
job.setRule(ResourcesPlugin.getWorkspace().getRoot());
job.schedule();
return null;
}
示例13: scheduleRemoveZipFiles
import org.eclipse.core.resources.WorkspaceJob; //導入方法依賴的package包/類
private void scheduleRemoveZipFiles(final IJavaProject javaProject) {
WorkspaceJob removeZipsJob = new WorkspaceJob("removeGradleZips") {
@Override
public IStatus runInWorkspace(IProgressMonitor monitor)
throws CoreException {
translatePlugins();
GradlePluginUtils.removeZipLibrariesFromProject(javaProject, new NullProgressMonitor());
IResource buildFile = javaProject.getProject().getFile(GradlePluginConstants.MAIN_BUILD_FILE);
//the build file might not be phisically present
if (!buildFile.exists()) {
return Status.OK_STATUS;
}
//markers should be removed regardless there are orphan nodes or not.
removeMarkers(buildFile);
if (orphanPlugins != null) {
addBuildScriptMarkers(orphanPlugins, buildFile);
}
return Status.OK_STATUS;
}
};
removeZipsJob.setUser(false);
removeZipsJob.setPriority(Job.SHORT);
removeZipsJob.setRule(ResourcesPlugin.getWorkspace().getRoot());
removeZipsJob.schedule();
}
示例14: makeActions
import org.eclipse.core.resources.WorkspaceJob; //導入方法依賴的package包/類
protected void makeActions() {
IShellProvider shellProvider = new IShellProvider() {
@Override
public Shell getShell() {
return shell;
}
};
refreshAction = new RefreshAction(shellProvider) {
@Override
public void run() {
final IStatus[] errorStatus = new IStatus[1];
errorStatus[0] = Status.OK_STATUS;
final WorkspaceModifyOperation op = (WorkspaceModifyOperation) createOperation(errorStatus);
WorkspaceJob job = new WorkspaceJob("refesh") {
@Override
public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException {
try {
op.run(monitor);
if (shell != null && !shell.isDisposed()) {
shell.getDisplay().asyncExec(new Runnable() {
@Override
public void run() {
StructuredViewer viewer = getActionSite().getStructuredViewer();
if (viewer != null && viewer.getControl() != null && !viewer.getControl()
.isDisposed()) {
viewer.refresh();
}
}
});
}
} catch (InvocationTargetException e) {
String msg = NLS.bind("Exception in {0}. run: {1}", getClass().getName(),
e.getTargetException());
throw new CoreException(new Status(IStatus.ERROR, Activator.PLUGIN_ID,
IStatus.ERROR, msg, e.getTargetException()));
} catch (InterruptedException ex) {
return Status.CANCEL_STATUS;
}
return errorStatus[0];
}
};
ISchedulingRule rule = op.getRule();
if (rule != null) {
job.setRule(rule);
}
job.setUser(true);
job.schedule();
}
};
refreshAction.setDisabledImageDescriptor(getImageDescriptor("icons/refresh_nav_disabled.gif"));
refreshAction.setImageDescriptor(getImageDescriptor("icons/refresh_nav_enabled.gif"));
refreshAction.setActionDefinitionId(IWorkbenchCommandConstants.FILE_REFRESH);
}
示例15: advisorsUpdated
import org.eclipse.core.resources.WorkspaceJob; //導入方法依賴的package包/類
@Override
public void advisorsUpdated() {
final Map<IMarker, Map<String, Object>> markerAttributes = new LinkedHashMap<IMarker, Map<String, Object>>();
synchronized (violationToMarkerMap) {
for (Iterator<Map.Entry<ViolationTracker, IMarker>> it = violationToMarkerMap.entrySet().iterator(); it.hasNext();) {
Map.Entry<ViolationTracker, IMarker> entry = it.next();
ViolationTracker violation = entry.getKey();
if (violation != null) {
try {
IMarker marker = entry.getValue();
if (marker.exists()) {
Map<String, Object> newAttributes = getAttributes(violation);
Map<?,?> oldAttributes = marker.getAttributes();
if (!oldAttributes.equals(newAttributes)) {
markerAttributes.put(marker, newAttributes);
Resource resource = plan.eResource();
List<EPlanElement> oldCulprits = EPlanUtils.getCulprits(marker, resource);
List<EPlanElement> newCulprits = EPlanUtils.getCulprits(newAttributes, resource);
if (!oldCulprits.equals(newCulprits)) {
updateViolationElementsMarkers(oldCulprits, newCulprits, marker);
}
}
} else {
it.remove();
}
} catch (Exception e) {
LogUtil.error("managing marker updates", e);
}
}
}
}
final IWorkspace workspace = ResourcesPlugin.getWorkspace();
/*
if the resource tree is locked, add a listener to check for POST_CHANGE
events and see if the tree has become unlocked. Remove the listener
when it has performed the desired task.
*/
if (!markerAttributes.isEmpty()) {
if (workspace.isTreeLocked()) {
workspace.addResourceChangeListener(new Listener(markerAttributes, workspace));
} else {
WorkspaceJob job = new WorkspaceJob("marker updating") {
/**
* @throws CoreException
*/
@Override
public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException {
updateMarkers(markerAttributes);
return Status.OK_STATUS;
}
};
job.setRule(resource);
job.schedule();
}
}
}