本文整理匯總了Java中org.eclipse.core.resources.WorkspaceJob.setUser方法的典型用法代碼示例。如果您正苦於以下問題:Java WorkspaceJob.setUser方法的具體用法?Java WorkspaceJob.setUser怎麽用?Java WorkspaceJob.setUser使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.eclipse.core.resources.WorkspaceJob
的用法示例。
在下文中一共展示了WorkspaceJob.setUser方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: run
import org.eclipse.core.resources.WorkspaceJob; //導入方法依賴的package包/類
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 ();
}
示例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: linkSampleModelsToWorkspace
import org.eclipse.core.resources.WorkspaceJob; //導入方法依賴的package包/類
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();
}
示例4: performFinish
import org.eclipse.core.resources.WorkspaceJob; //導入方法依賴的package包/類
@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;
}
示例5: 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();
}
示例6: run
import org.eclipse.core.resources.WorkspaceJob; //導入方法依賴的package包/類
@Override
public void run() {
final TreeSelection s = (TreeSelection) treeViewer.getSelection();
TreePath[] p = s.getPaths();
for (int i = 0; i < p.length; i++) {
final Object obj = p[i].getLastSegment();
if (isFileResource(obj)) {
if (preDownload((AFileResource) obj)) {
WorkspaceJob job = new WorkspaceJob("Open File In Editor") {
public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException {
try {
monitor.beginTask("Open File In Editor", IProgressMonitor.UNKNOWN);
dorun(obj, monitor);
} catch (Throwable e) {
UIUtils.showError(e);
} finally {
monitor.done();
}
return Status.OK_STATUS;
}
};
job.setUser(true);
job.schedule();
}
break;
}
}
}
示例7: run
import org.eclipse.core.resources.WorkspaceJob; //導入方法依賴的package包/類
@Override
public void run() {
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 Status.OK_STATUS;
};
};
job.setUser(true);
job.schedule();
}
示例8: executeCreateModels
import org.eclipse.core.resources.WorkspaceJob; //導入方法依賴的package包/類
public static void executeCreateModels(final EditorInputEMF alternative, final ModelType[] types){
WorkspaceJob job = new WorkspaceJob("Creating new models") {
@Override
public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException {
monitor.beginTask("Creating new models", 2 * types.length + 1);
ResourceSet modelResSet = new ResourceSetImpl();
ResourceSet diagramResSet = new ResourceSetImpl();
ModelUtils.createModels(modelResSet, diagramResSet, alternative.getResource(), types, monitor);
for(Resource res : modelResSet.getResources()){
alternative.addSubResource(ExplorerProjectPaths.getFileFromEmfResource(res));
}
monitor.subTask("Saving alternative");
alternative.save();
monitor.worked(1);
//IFile repFile = ExplorerProjectPaths.getNonexistingSubFile(alternative.getResource(), "model", ModelType.REPRESENTATIONS.getFileExtension());
//ResourceUtils.createSystemDiagramRepresentation((SystemImpl)alternative.getModelRootObject(ModelType.SYSTEM.getToolchainFileID()), repFile, modelResSet);
return new Status(IStatus.OK, Activator.PLUGIN_ID, "Creating new models done.");
}
};
job.setUser(true);
job.schedule();
}
示例9: executeImportModels
import org.eclipse.core.resources.WorkspaceJob; //導入方法依賴的package包/類
public static void executeImportModels(final EditorInputEMF alternative, final Resource[] resources, final boolean copy){
WorkspaceJob job = new WorkspaceJob("Copying models into alternative") {
@Override
public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException {
monitor.beginTask("Importing models into alternative", 6 * resources.length);
if (copy)
{
ExplorerProjectPaths.copyEMFResources(alternative.getResource(), resources, monitor);
}
for (Resource resource : resources)
{
IFile f = ExplorerProjectPaths.getFileFromEmfResource(resource);
alternative.addSubResource(f);
}
return new Status(IStatus.OK, Activator.PLUGIN_ID, "Copying models done.");
}
};
job.setUser(true);
job.schedule();
}
示例10: performFinish
import org.eclipse.core.resources.WorkspaceJob; //導入方法依賴的package包/類
@Override
public boolean performFinish() {
limboAlternatives.clear();
WorkspaceJob job = new WorkspaceJob("Project import") {
@Override
public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException {
try{
boolean done = importProject(monitor);
if(!done){
if(ia != null){ia.delete(); ia = null;};
if(ca != null){ca.delete(); ca = null;};
for(EditorInputEMF eir : limboAlternatives.values()){
eir.delete();
}
}
}
catch(Exception e){
e.printStackTrace();
return new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Error has occured during project import!");
}
return new Status(IStatus.OK, Activator.PLUGIN_ID, "Project has been imported");
}
};
job.setUser(true);
job.schedule();
return true;
}
示例11: 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();
}
示例12: 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();
}
示例13: 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);
}
示例14: performFinish
import org.eclipse.core.resources.WorkspaceJob; //導入方法依賴的package包/類
@Override
public boolean performFinish()
{
final List<Resource> selectedResources = _pageOne.getSelectedResources();
WorkspaceJob job = new WorkspaceJob("Creating Example projects")
{
@Override
public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException {
IProject cseProject = null;
for (Resource resource : selectedResources)
{
try
{
IProject project = ExampleService.getInstance().createExampleResourceProject(resource);
IFile propertyFile = ExplorerProjectPaths.getDashboardFile(project);
if (propertyFile != null && propertyFile.exists()) // TODO: check nature
{
cseProject = project;
}
} catch (Exception e)
{
e.printStackTrace();
}
}
if (cseProject != null)
{
selectExampleProject(cseProject);
}
return Status.OK_STATUS;
}
};
job.setUser(true);
job.schedule();
openMainPerspective();
return true;
}
示例15: selectionChanged
import org.eclipse.core.resources.WorkspaceJob; //導入方法依賴的package包/類
@Override
public void selectionChanged(IWorkbenchPart part, ISelection selection) {
if (this.viewer.isBusy()) {
return;
}
if (!(selection instanceof TreeSelection)) {
return;
}
if (selection.isEmpty())
return;
if (!isMuleProject(selection)) {
return;
}
final ISelection currentSelection = selection;
final String convertingMsg = "Listing gradle tasks...";
final WorkspaceJob refreshDevkitViewJob = new WorkspaceJob(convertingMsg) {
@Override
public IStatus runInWorkspace(final IProgressMonitor monitor) throws CoreException {
if (currentSelection instanceof IStructuredSelection) {
Object selected = ((IStructuredSelection) currentSelection).getFirstElement();
// sometimes project might be a simple project.
if (selected instanceof IJavaProject) {
// convert into a java project
selected = ((IJavaProject) selected).getProject();
}
if (selected instanceof IProject) {
project = (IProject) selected;
final GradleProject gradleProject = GradlePluginUtils.getProjectModelForProject(project);
Display.getDefault().asyncExec(new Runnable() {
@Override
public void run() {
viewer.setInput(gradleProject);
}
});
}
}
return Status.OK_STATUS;
}
};
refreshDevkitViewJob.setUser(false);
refreshDevkitViewJob.setPriority(Job.SHORT);
refreshDevkitViewJob.schedule();
}