当前位置: 首页>>代码示例>>Java>>正文


Java IWorkspaceRunnable类代码示例

本文整理汇总了Java中org.eclipse.core.resources.IWorkspaceRunnable的典型用法代码示例。如果您正苦于以下问题:Java IWorkspaceRunnable类的具体用法?Java IWorkspaceRunnable怎么用?Java IWorkspaceRunnable使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


IWorkspaceRunnable类属于org.eclipse.core.resources包,在下文中一共展示了IWorkspaceRunnable类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: importProjects

import org.eclipse.core.resources.IWorkspaceRunnable; //导入依赖的package包/类
protected List<IProject> importProjects(Collection<String> paths) throws Exception {
	final List<IPath> roots = new ArrayList<>();
	for (String path : paths) {
		File file = copyFiles(path, true);
		roots.add(Path.fromOSString(file.getAbsolutePath()));
	}
	IWorkspaceRunnable runnable = new IWorkspaceRunnable() {
		@Override
		public void run(IProgressMonitor monitor) throws CoreException {
			projectsManager.initializeProjects(roots, monitor);
		}
	};
	JavaCore.run(runnable, null, monitor);
	waitForBackgroundJobs();
	return WorkspaceHelper.getAllProjects();
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:17,代码来源:AbstractProjectsManagerBasedTest.java

示例2: appendText

import org.eclipse.core.resources.IWorkspaceRunnable; //导入依赖的package包/类
public synchronized void appendText(final String text)
{
    try
    {
        ResourcesPlugin.getWorkspace().run(new IWorkspaceRunnable() {
            public void run(IProgressMonitor monitor) throws CoreException
            {
                // System.out.print(Thread.currentThread().getId() + " : " + message);
                outFile.appendContents(new ByteArrayInputStream(text.getBytes()), IResource.FORCE, monitor);
            }
        }, rule, IWorkspace.AVOID_UPDATE, new NullProgressMonitor());

        // if the console output is active, print to it
    } catch (CoreException e)
    {
        TLCActivator.logError("Error writing the TLC process output file for " + model.getName(), e);
    }

}
 
开发者ID:tlaplus,项目名称:tlaplus,代码行数:20,代码来源:FileProcessOutputSink.java

示例3: saveEditors

import org.eclipse.core.resources.IWorkspaceRunnable; //导入依赖的package包/类
public void saveEditors(final IRenameElementContext context) {
	new DisplayRunnable() {
		@Override
		protected void run() throws Exception {
			workspace.run(new IWorkspaceRunnable() {
				public void run(IProgressMonitor monitor) throws CoreException {
					IWorkbenchPage workbenchPage = getWorkbenchPage(context);
					if (prefs.isSaveAllBeforeRefactoring()) 
						workbenchPage.saveAllEditors(false);
					else
						saveDeclaringEditor(context, workbenchPage);
				}
			}, new NullProgressMonitor());
		}
	}.syncExec();
	syncUtil.waitForBuild(null);
}
 
开发者ID:cplutte,项目名称:bts,代码行数:18,代码来源:SaveHelper.java

示例4: runInWorkspace

import org.eclipse.core.resources.IWorkspaceRunnable; //导入依赖的package包/类
@Override
public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException {
	IWorkspaceRunnable workspaceRunnable = new IWorkspaceRunnable() {
		@Override
		public void run(IProgressMonitor pm) throws CoreException {
			try {
				run2(pm);
			} catch (Exception e) {
				// Re-throw as OperationCanceledException, which will be
				// caught and re-thrown as InterruptedException below.
				throw new OperationCanceledException(e.getMessage());
			}
			// CoreException and OperationCanceledException are propagated
		}
	};
	ResourcesPlugin.getWorkspace().run(workspaceRunnable,
			resource, IResource.NONE, monitor);

	return monitor.isCanceled()? Status.CANCEL_STATUS : Status.OK_STATUS;
}
 
开发者ID:iloveeclipse,项目名称:java-things,代码行数:21,代码来源:LockJob.java

示例5: delete

import org.eclipse.core.resources.IWorkspaceRunnable; //导入依赖的package包/类
/**
 * Removes an IJavaElement's resource. Retries if deletion failed (e.g. because the indexer still
 * locks the file).
 *
 * @param elem the element to delete
 * @throws CoreException if operation failed
 * @see #ASSERT_NO_MIXED_LINE_DELIMIERS
 */
public static void delete(final IJavaElement elem) throws CoreException {
  //		if (ASSERT_NO_MIXED_LINE_DELIMIERS)
  //			MixedLineDelimiterDetector.assertNoMixedLineDelimiters(elem);
  if (elem instanceof JavaProject) {
    ((JavaProject) elem).close();
    JavaModelManager.getJavaModelManager().removePerProjectInfo((JavaProject) elem, true);
  }
  JavaModelManager.getJavaModelManager().resetTemporaryCache();
  IWorkspaceRunnable runnable =
      new IWorkspaceRunnable() {
        public void run(IProgressMonitor monitor) throws CoreException {
          //				performDummySearch();
          if (elem instanceof IJavaProject) {
            IJavaProject jproject = (IJavaProject) elem;
            jproject.setRawClasspath(
                new IClasspathEntry[0], jproject.getProject().getFullPath(), null);
          }
          delete(elem.getResource());
        }
      };
  ResourcesPlugin.getWorkspace().run(runnable, null);
  //		emptyDisplayLoop();
}
 
开发者ID:eclipse,项目名称:che,代码行数:32,代码来源:JavaProjectHelper.java

示例6: clear

import org.eclipse.core.resources.IWorkspaceRunnable; //导入依赖的package包/类
/**
 * Removes all files in the project and sets the given classpath
 *
 * @param jproject The project to clear
 * @param entries The default class path to set
 * @throws Exception Clearing the project failed
 */
public static void clear(final IJavaProject jproject, final IClasspathEntry[] entries)
    throws Exception {
  //		performDummySearch();
  IWorkspaceRunnable runnable =
      new IWorkspaceRunnable() {
        public void run(IProgressMonitor monitor) throws CoreException {
          jproject.setRawClasspath(entries, null);

          IResource[] resources = jproject.getProject().members();
          for (int i = 0; i < resources.length; i++) {
            //					if (!resources[i].getName().startsWith(".")) {
            delete(resources[i]);
            //					}
          }
        }
      };
  ResourcesPlugin.getWorkspace().run(runnable, null);

  //		JavaProjectHelper.emptyDisplayLoop();
}
 
开发者ID:eclipse,项目名称:che,代码行数:28,代码来源:JavaProjectHelper.java

示例7: execute

import org.eclipse.core.resources.IWorkspaceRunnable; //导入依赖的package包/类
public void execute(IProgressMonitor m) throws CoreException {
	IProgressMonitor monitor;
	if (m == null)
		monitor = new NullProgressMonitor();
	else
		monitor = m;
	if (type == ResetType.HARD) {
		IWorkspaceRunnable action = new IWorkspaceRunnable() {
			public void run(IProgressMonitor actMonitor) throws CoreException {
				reset(actMonitor);
			}
		};
		// lock workspace to protect working tree changes
		ResourcesPlugin.getWorkspace().run(action, getSchedulingRule(),
				IWorkspace.AVOID_UPDATE, monitor);
	} else {
		reset(monitor);
	}
}
 
开发者ID:Genuitec,项目名称:gerrit-tools,代码行数:20,代码来源:ResetOperation.java

示例8: setRootConfigurationFolder

import org.eclipse.core.resources.IWorkspaceRunnable; //导入依赖的package包/类
static public synchronized void setRootConfigurationFolder(final File configFolder) throws CoreException {
	ConfigDispatcher.setConfigFolder(configFolder.getAbsolutePath());
	IWorkspaceRunnable runnable = new IWorkspaceRunnable() {
		public void run(IProgressMonitor monitor) throws CoreException {
			IProject defaultProject = ResourcesPlugin.getWorkspace().getRoot().getProject("config");
			if(!defaultProject.exists()) {
				initialize(defaultProject);
			}
			if(configFolder!=null) {
				folder = defaultProject.getFolder("config");
				if(folder.exists()) {
					folder.delete(true, null);
				}
				folder.createLink(configFolder.toURI(), IResource.ALLOW_MISSING_LOCAL, null);
			}
		}
	};
	ResourcesPlugin.getWorkspace().run(runnable, null);
}
 
开发者ID:andrey-desman,项目名称:openhab-hdl,代码行数:20,代码来源:ConfigurationFolderProvider.java

示例9: ChromiumLineBreakpoint

import org.eclipse.core.resources.IWorkspaceRunnable; //导入依赖的package包/类
/**
 * Constructs a line breakpoint on the given resource at the given line number
 * (line number is 1-based).
 *
 * @param resource file on which to set the breakpoint
 * @param lineNumber 1-based line number of the breakpoint
 * @throws CoreException if unable to create the breakpoint
 */
public ChromiumLineBreakpoint(final IResource resource, final int lineNumber,
    final String modelId) throws CoreException {
  IWorkspaceRunnable runnable = new IWorkspaceRunnable() {
    public void run(IProgressMonitor monitor) throws CoreException {
      IMarker marker = resource.createMarker(ChromiumDebugPlugin.BP_MARKER);
      setMarker(marker);
      marker.setAttribute(IBreakpoint.ENABLED, Boolean.TRUE);
      marker.setAttribute(IMarker.LINE_NUMBER, lineNumber);
      marker.setAttribute(IBreakpoint.ID, modelId);
      marker.setAttribute(IMarker.MESSAGE, NLS.bind(
          Messages.JsLineBreakpoint_MessageMarkerFormat, resource.getName(), lineNumber));
    }
  };
  run(getMarkerRule(resource), runnable);
}
 
开发者ID:jbosstools,项目名称:chromedevtools,代码行数:24,代码来源:ChromiumLineBreakpoint.java

示例10: savePlanResourceSet

import org.eclipse.core.resources.IWorkspaceRunnable; //导入依赖的package包/类
/**
 * Save the given plan in the workspace.
 * @param plan the plan to save
 * @param monitor a progress monitor
 */
protected final void savePlanResourceSet(final EPlan plan, final IProgressMonitor monitor) {
	final Resource planResource = plan.eResource();
	IFile file = EMFUtils.getFile(planResource);
	IProject project = file.getProject();
	try {
		IWorkspace workspace = project.getWorkspace();
		workspace.run(new IWorkspaceRunnable() {
			@Override
			public void run(IProgressMonitor m) {
				EMFUtils.save(planResource, "Saving the plan and associated files", monitor, getIgnorablePredicate());
			}
		}, project, IWorkspace.AVOID_UPDATE, null);
	} catch (CoreException e) {
		LogUtil.error(e);
	}
}
 
开发者ID:nasa,项目名称:OpenSPIFe,代码行数:22,代码来源:PlanPersister.java

示例11: writeProp

import org.eclipse.core.resources.IWorkspaceRunnable; //导入依赖的package包/类
private static void writeProp(final ProjectPropertyEvent event)
		throws CoreException {
	if (event.resource.exists()) {
		ws().run(new IWorkspaceRunnable() {
			@Override
			public void run(IProgressMonitor monitor) {
				try {
					if (event.resource.exists())
						writeProp(event.resource, event.key, event.value);
				} catch (Throwable t) {
					LogUtil.error(t);
				}
			}
		}, event.resource.getProject(), IWorkspace.AVOID_UPDATE, null);
	}
	
	projProps(event.resource).notifyListeners(event);
}
 
开发者ID:nasa,项目名称:OpenSPIFe,代码行数:19,代码来源:ProjectProperties.java

示例12: createFolderStructure

import org.eclipse.core.resources.IWorkspaceRunnable; //导入依赖的package包/类
protected void createFolderStructure() {
	final IFolder resourcesFolder = newProject.getFolder("Resources");
	final IFolder conditionsFolder = newProject.getFolder("Conditions");
	final boolean force = true;
	final boolean local = true;
	try {
		ResourcesPlugin.getWorkspace().run(new IWorkspaceRunnable() {

			@Override
			public void run(IProgressMonitor monitor) throws CoreException {
				resourcesFolder.create(force, local, monitor);
				conditionsFolder.create(force, local, monitor);
			}
			
		}, null);
	} catch (CoreException e) {
		e.printStackTrace();
	}		
}
 
开发者ID:nasa,项目名称:OpenSPIFe,代码行数:20,代码来源:NewSpifeProjectResourceWizard.java

示例13: setSelection

import org.eclipse.core.resources.IWorkspaceRunnable; //导入依赖的package包/类
/**
   * Set the selection and focus to the list of elements
   * @param elements the object to be selected and displayed
   */
  public void setSelection(final List<?> elements) {
      if (elements == null || elements.size() == 0)
          return;
try {
       ResourcesPlugin.getWorkspace().run(new IWorkspaceRunnable() {
       	public void run(IProgressMonitor monitor) throws CoreException {
       		fPackageViewer.refresh();
               IStructuredSelection selection= new StructuredSelection(elements);
               fPackageViewer.setSelection(selection, true);
               fPackageViewer.getTree().setFocus();

               if (elements.size() == 1 && elements.get(0) instanceof IJavaProject)
                   fPackageViewer.expandToLevel(elements.get(0), 1);
           }
       }, ResourcesPlugin.getWorkspace().getRoot(), IWorkspace.AVOID_UPDATE, new NullProgressMonitor());
      } catch (CoreException e) {
       JavaPlugin.log(e);
      }
  }
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:24,代码来源:DialogPackageExplorer.java

示例14: testRemoveEngineUsingName

import org.eclipse.core.resources.IWorkspaceRunnable; //导入依赖的package包/类
@Test
public void testRemoveEngineUsingName() throws CoreException {
	final HybridMobileEngine[] engines = new HybridMobileEngine[2];
	engines[0] = new HybridMobileEngine("android", "6.0.0", null);
	engines[1] = new HybridMobileEngine("ios", "4.4.0", null);
	manager.updateEngines(engines);
	JobUtils.waitForIdle();

	// Run on a IWorkspaceRunnable because it needs to sync with the udpateEngines
	// call.
	IWorkspaceRunnable runnable = new IWorkspaceRunnable() {

		@Override
		public void run(IProgressMonitor monitor) throws CoreException {
			manager.removeEngine(engines[0].getName(), monitor, true);
			Widget w = WidgetModel.getModel(testproject.hybridProject()).getWidgetForRead();
			assertEquals(1, w.getEngines().size());
			assertEquals(1, manager.getEngines().length);
			checkEnginesPersistedCorrectly(new HybridMobileEngine[] { engines[1] });
		}
	};
	IWorkspace ws = ResourcesPlugin.getWorkspace();
	ISchedulingRule rule = ws.getRuleFactory().modifyRule(testproject.getProject());
	ws.run(runnable, rule, 0, new NullProgressMonitor());
}
 
开发者ID:eclipse,项目名称:thym,代码行数:26,代码来源:HybridMobileEngineTests.java

示例15: testRemoveEngine

import org.eclipse.core.resources.IWorkspaceRunnable; //导入依赖的package包/类
@Test
public void testRemoveEngine() throws CoreException {
	final HybridMobileEngine[] engines = new HybridMobileEngine[2];
	engines[0] = new HybridMobileEngine("android", "6.0.0", null);
	engines[1] = new HybridMobileEngine("ios", "4.4.0", null);
	manager.updateEngines(engines);
	JobUtils.waitForIdle();

	// Run on a IWorkspaceRunnable because it needs to sync with the udpateEngines
	// call.
	IWorkspaceRunnable runnable = new IWorkspaceRunnable() {

		@Override
		public void run(IProgressMonitor monitor) throws CoreException {
			manager.removeEngine(engines[0], monitor, true);
			Widget w = WidgetModel.getModel(testproject.hybridProject()).getWidgetForRead();
			assertEquals(1, w.getEngines().size());
			checkEnginesPersistedCorrectly(new HybridMobileEngine[] { engines[1] });
		}
	};
	IWorkspace ws = ResourcesPlugin.getWorkspace();
	ISchedulingRule rule = ws.getRuleFactory().modifyRule(testproject.getProject());
	ws.run(runnable, rule, 0, new NullProgressMonitor());
}
 
开发者ID:eclipse,项目名称:thym,代码行数:25,代码来源:HybridMobileEngineTests.java


注:本文中的org.eclipse.core.resources.IWorkspaceRunnable类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。