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


Java ResourcesPlugin.getWorkspace方法代码示例

本文整理汇总了Java中org.eclipse.core.resources.ResourcesPlugin.getWorkspace方法的典型用法代码示例。如果您正苦于以下问题:Java ResourcesPlugin.getWorkspace方法的具体用法?Java ResourcesPlugin.getWorkspace怎么用?Java ResourcesPlugin.getWorkspace使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.core.resources.ResourcesPlugin的用法示例。


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

示例1: setGW4ENature

import org.eclipse.core.resources.ResourcesPlugin; //导入方法依赖的package包/类
/**
 * Set the GW4E Nature to the passed project
 * 
 * @param project
 * @return
 * @throws CoreException
 */
public static IStatus setGW4ENature(IProject project) throws CoreException {
	IProjectDescription description = project.getDescription();
	String[] natures = description.getNatureIds();
	String[] newNatures = new String[natures.length + 1];
	System.arraycopy(natures, 0, newNatures, 0, natures.length);

	// add our id
	newNatures[natures.length] = GW4ENature.NATURE_ID;

	// validate the natures
	IWorkspace workspace = ResourcesPlugin.getWorkspace();
	IStatus status = workspace.validateNatureSet(newNatures);

	if (status.getCode() == IStatus.OK) {
		description.setNatureIds(newNatures);
		project.setDescription(description, null);
	}
	return status;
}
 
开发者ID:gw4e,项目名称:gw4e.project,代码行数:27,代码来源:GW4ENature.java

示例2: importProject

import org.eclipse.core.resources.ResourcesPlugin; //导入方法依赖的package包/类
private static IProject importProject(File probandsFolder, String projectName, boolean prepareDotProject)
		throws Exception {
	File projectSourceFolder = new File(probandsFolder, projectName);
	if (!projectSourceFolder.exists()) {
		throw new IllegalArgumentException("proband not found in " + projectSourceFolder);
	}

	if (prepareDotProject) {
		prepareDotProject(projectSourceFolder);
	}

	IProgressMonitor monitor = new NullProgressMonitor();
	IWorkspace workspace = ResourcesPlugin.getWorkspace();

	IProjectDescription newProjectDescription = workspace.newProjectDescription(projectName);
	IProject project = workspace.getRoot().getProject(projectName);
	project.create(newProjectDescription, monitor);
	project.open(monitor);
	if (!project.getLocation().toFile().exists()) {
		throw new IllegalArgumentException("test project correctly created in " + project.getLocation());
	}

	IOverwriteQuery overwriteQuery = new IOverwriteQuery() {
		@Override
		public String queryOverwrite(String file) {
			return ALL;
		}
	};
	ImportOperation importOperation = new ImportOperation(project.getFullPath(), projectSourceFolder,
			FileSystemStructureProvider.INSTANCE, overwriteQuery);
	importOperation.setCreateContainerStructure(false);
	importOperation.run(monitor);

	return project;
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:36,代码来源:ProjectUtils.java

示例3: dispose

import org.eclipse.core.resources.ResourcesPlugin; //导入方法依赖的package包/类
@Override
public void dispose() {
	selectionProvider.removeSelectionChangedListener(selectionChangedListener);
	selectionProvider = null;

	final IWorkspace workspace = ResourcesPlugin.getWorkspace();
	workspace.removeResourceChangeListener(openAction);
	workspace.removeResourceChangeListener(closeAction);
	workspace.removeResourceChangeListener(closeUnrelatedAction);
	super.dispose();
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:12,代码来源:N4JSProjectActionGroup.java

示例4: scheduleBuildIfNecessary

import org.eclipse.core.resources.ResourcesPlugin; //导入方法依赖的package包/类
/**
 * Schedules a build with the given projects. Does nothing if the {@link Platform platform} is not running, or the
 * iterable of projects is empty.
 *
 * @param toUpdate
 *            an iterable of projects to build.
 */
public void scheduleBuildIfNecessary(final Iterable<IProject> toUpdate) {
	if (Platform.isRunning() && !Iterables.isEmpty(toUpdate)) {
		final Workspace workspace = (Workspace) ResourcesPlugin.getWorkspace();
		final IBuildConfiguration[] projectsToReBuild = from(asList(workspace.getBuildOrder()))
				.filter(config -> Iterables.contains(toUpdate, config.getProject()))
				.toArray(IBuildConfiguration.class);

		if (!Arrays2.isEmpty(projectsToReBuild)) {
			new RebuildWorkspaceProjectsJob(projectsToReBuild).schedule();
		}
	}
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:20,代码来源:RebuildWorkspaceProjectsScheduler.java

示例5: toIFolder

import org.eclipse.core.resources.ResourcesPlugin; //导入方法依赖的package包/类
/**
 * Return the passed parameters (a file) as an IFolder
 * 
 * @param file
 * @return
 */
public static IFolder toIFolder(File file) {
	IWorkspace workspace = ResourcesPlugin.getWorkspace();
	IPath location = Path.fromOSString(file.getAbsolutePath());
	IFile ifile = workspace.getRoot().getFileForLocation(location);
	return workspace.getRoot().getFolder(ifile.getFullPath());
}
 
开发者ID:gw4e,项目名称:gw4e.project,代码行数:13,代码来源:ResourceManager.java

示例6: errorIsInProblemView

import org.eclipse.core.resources.ResourcesPlugin; //导入方法依赖的package包/类
public boolean errorIsInProblemView (String expected) throws CoreException {
	System.out.println("XXXXXXXXX errorIsInProblemView >"+expected+"<");
	IWorkspace workspace = ResourcesPlugin.getWorkspace();
	IResource resource = workspace.getRoot();
	IMarker[] markers = resource.findMarkers(null, true, IResource.DEPTH_INFINITE);
	for (IMarker m : markers) {
	    String msg = (String)m.getAttribute(IMarker.MESSAGE);
	    System.out.println(">"+msg+"<");
	    if (expected.equalsIgnoreCase(msg.trim())) return true;
	}		
	return false;
}
 
开发者ID:gw4e,项目名称:gw4e.project,代码行数:13,代码来源:ProblemView.java

示例7: addNature

import org.eclipse.core.resources.ResourcesPlugin; //导入方法依赖的package包/类
private void addNature(IProject project) throws CoreException{
	if(!project.hasNature(ProjectNature.NATURE_ID)){
		IProjectDescription description = project.getDescription();
		String[] prevNatures = description.getNatureIds();
		String[] newNatures = new String[prevNatures.length + 3];
		System.arraycopy(prevNatures, 0, newNatures, 0, prevNatures.length);
		newNatures[prevNatures.length] = ProjectNature.NATURE_ID;
		newNatures[prevNatures.length + 1] = JavaCore.NATURE_ID;
		newNatures[prevNatures.length + 2] = ORG_ECLIPSE_M2E_CORE_MAVEN2_NATURE;

		// validate the natures
		IWorkspace workspace = ResourcesPlugin.getWorkspace();
		IStatus status = workspace.validateNatureSet(newNatures); 
		ICommand javaBuildCommand= description.newCommand();
		javaBuildCommand.setBuilderName("org.eclipse.jdt.core.javabuilder");
		ICommand mavenBuildCommand= description.newCommand();
		mavenBuildCommand.setBuilderName("org.eclipse.m2e.core.maven2Builder");
		ICommand[] iCommand = {javaBuildCommand, mavenBuildCommand};
		description.setBuildSpec(iCommand); 
		// only apply new nature, if the status is ok
		if (status.getCode() == IStatus.OK) {
			description.setNatureIds(newNatures);
			project.setDescription(description, null);
		}
		logger.debug("Project nature added"); 
	}
}
 
开发者ID:capitalone,项目名称:Hydrograph,代码行数:28,代码来源:ProjectStructureCreator.java

示例8: deleteProjectPluginResource

import org.eclipse.core.resources.ResourcesPlugin; //导入方法依赖的package包/类
public void deleteProjectPluginResource(boolean deleteContent, String projectName) throws CoreException {
	cacheIProject.remove(projectName);
	IWorkspace myWorkspace = ResourcesPlugin.getWorkspace();
	IWorkspaceRoot myWorkspaceRoot = myWorkspace.getRoot();
	IProject resourceProject = myWorkspaceRoot.getProject(projectName);
	
	if (resourceProject.exists()) {
       	resourceProject.delete(deleteContent, false, null);
	}
}
 
开发者ID:convertigo,项目名称:convertigo-eclipse,代码行数:11,代码来源:ConvertigoPlugin.java

示例9: toIFile

import org.eclipse.core.resources.ResourcesPlugin; //导入方法依赖的package包/类
/**
 * Return the passed parameters (a file) as an IFile
 * 
 * @param file
 * @return
 */
public static IFile toIFile(File file) {
	IWorkspace workspace = ResourcesPlugin.getWorkspace();
	IPath location = Path.fromOSString(file.getAbsolutePath());
	IFile ifile = workspace.getRoot().getFileForLocation(location);
	return ifile;
}
 
开发者ID:gw4e,项目名称:gw4e.project,代码行数:13,代码来源:ResourceManager.java

示例10: validateFullResourcePath

import org.eclipse.core.resources.ResourcesPlugin; //导入方法依赖的package包/类
/**
 * @param resourcePath
 * @return
 */
protected boolean validateFullResourcePath(IPath resourcePath,Problem pb) {
	IWorkspace workspace = ResourcesPlugin.getWorkspace();

	IStatus result = workspace.validatePath(resourcePath.toString(),
			IResource.FOLDER);
	if (!result.isOK()) {
		pb.raiseProblem(result.getMessage(), Problem.PROBLEM_PATH_INVALID);
		return false;
	}


	return true;
}
 
开发者ID:gw4e,项目名称:gw4e.project,代码行数:18,代码来源:FolderSelectionGroup.java

示例11: validate

import org.eclipse.core.resources.ResourcesPlugin; //导入方法依赖的package包/类
private void validate() {
	IWorkspace workspace = ResourcesPlugin.getWorkspace();

	// check whether the project name is empty
	String projectName = projectData.projectName;
	if (projectName == null || projectName.trim().isEmpty()) {
		setErrorMessage("Project name must not be empty");
		setPageComplete(false);
		return;
	}

	// check whether the project name is valid
	final IStatus projectNameStatus = workspace.validateName(projectName, IResource.PROJECT);
	if (!projectNameStatus.isOK()) {
		setErrorMessage(projectNameStatus.getMessage());
		setPageComplete(false);
		return;
	}

	// check whether the project with the name already exists
	IProject handle = workspace.getRoot().getProject(projectData.projectName);
	if (handle.exists()) {
		setErrorMessage("A project with name '" + projectData.projectName + "' already exists in the workspace");
		setPageComplete(false);
		return;
	}

	// check whether the location is empty
	String location = projectData.projectLocation;
	if (location == null || location.isEmpty()) {
		setErrorMessage("Enter a location for the project.");
		setPageComplete(false);
		return;
	}

	// check whether the location is a syntactically correct path
	if (!Path.EMPTY.isValidPath(location)) {
		setErrorMessage("Invalid project contents directory");
		setPageComplete(false);
		return;
	}

	IPath projectPath = null;
	if (!useDefaultsButton.getSelection()) {
		projectPath = Path.fromOSString(location);
		if (!projectPath.toFile().exists()) {
			if (!canCreate(projectPath.toFile())) {
				setErrorMessage("Cannot create project content at the given external location.");
				setPageComplete(false);
				return;
			}
		}
	}

	// check whether the location is valid
	final IStatus locationStatus = workspace.validateProjectLocation(handle, projectPath);
	if (!locationStatus.isOK()) {
		setErrorMessage(locationStatus.getMessage());
		setPageComplete(false);
		return;
	}

	setErrorMessage(null);
	setPageComplete(true);
}
 
开发者ID:gluonhq,项目名称:ide-plugins,代码行数:66,代码来源:ConfigureGluonProjectPage.java

示例12: isValid

import org.eclipse.core.resources.ResourcesPlugin; //导入方法依赖的package包/类
@Override
public boolean isValid(ILaunchConfiguration config) {
	setErrorMessage(null);
	setMessage(null);
	IWorkspace workspace = ResourcesPlugin.getWorkspace();
	String modelName = _modelLocationText.getText().trim();
	if (modelName.length() > 0) {
		
		IResource modelIResource = workspace.getRoot().findMember(modelName);
		if (modelIResource == null || !modelIResource.exists()) {
			setErrorMessage(NLS.bind(LauncherMessages.SequentialMainTab_model_doesnt_exist, new String[] {modelName})); 
			return false;
		}
		if (modelName.equals("/")) {
			setErrorMessage(LauncherMessages.SequentialMainTab_Model_not_specified); 
			return false;
		}
		if (! (modelIResource instanceof IFile)) {
			setErrorMessage(NLS.bind(LauncherMessages.SequentialMainTab_invalid_model_file, new String[] {modelName})); 
			return false;
		}
	}
	if (modelName.length() == 0) {
		setErrorMessage(LauncherMessages.SequentialMainTab_Model_not_specified); 
		return false;
	}
	
	String languageName = _languageCombo.getText().trim();
	if (languageName.length() == 0) {
		setErrorMessage(LauncherMessages.SequentialMainTab_Language_not_specified); 
		return false;
	}
	else if(MelangeHelper.getEntryPoints(languageName).isEmpty()){
		setErrorMessage(LauncherMessages.SequentialMainTab_Language_main_methods_dont_exist); 
		return false;
	}
	
	String mainMethod = _entryPointMethodText.getText().trim();
	if (mainMethod.length() == 0) {
		setErrorMessage(LauncherMessages.SequentialMainTab_Language_main_method_not_selected); 
		return false;
	}
	
	String rootElement = _entryPointModelElementText.getText().trim();
	if (rootElement.length() == 0) {
		setErrorMessage(LauncherMessages.SequentialMainTab_Language_root_element_not_selected); 
		return false;
	}
	
	String[] params =MelangeHelper.getParametersType(mainMethod);
	String firstParam = MelangeHelper.lastSegment(params[0]);
	String rootEClass = getModel().getEObject(rootElement).eClass().getName();
	if( !(params.length == 1 && firstParam.equals(rootEClass)) ){
		setErrorMessage(LauncherMessages.SequentialMainTab_Language_incompatible_root_and_main); 
		return false;
	}
	
	return true;
}
 
开发者ID:eclipse,项目名称:gemoc-studio-modeldebugging,代码行数:60,代码来源:LaunchConfigurationMainTab.java

示例13: getWorkspace

import org.eclipse.core.resources.ResourcesPlugin; //导入方法依赖的package包/类
public static IWorkspace getWorkspace() {
	return ResourcesPlugin.getWorkspace();
}
 
开发者ID:de-jcup,项目名称:eclipse-batch-editor,代码行数:4,代码来源:EclipseUtil.java

示例14: build

import org.eclipse.core.resources.ResourcesPlugin; //导入方法依赖的package包/类
/**
 * Start a build on given project or workspace using given options.
 * 
 * @param javaProject Project which must be (full) build or null if all
 * workspace has to be built.
 * @param options Options used while building
 */
void build(final IJavaProject javaProject, Hashtable options, boolean noWarning) throws IOException, CoreException {
  if (DEBUG)
    System.out.print("\tstart build...");
  JavaCore.setOptions(options);
  if (PRINT)
    System.out.println("JavaCore options: " + options);

  // Build workspace if no project
  if (javaProject == null) {
    // single measure
    ENV.fullBuild();
  } else {
    if (PRINT)
      System.out.println("Project options: " + javaProject.getOptions(false));
    IWorkspaceRunnable compilation = new IWorkspaceRunnable() {
      public void run(IProgressMonitor monitor) throws CoreException {
        ENV.fullBuild(javaProject.getPath());
      }
    };
    IWorkspace workspace = ResourcesPlugin.getWorkspace();
    workspace.run(compilation, null/* don't take any lock */, IWorkspace.AVOID_UPDATE, null/*
                                                                                            * no
                                                                                            * progress
                                                                                            * available
                                                                                            * here
                                                                                            */);
  }

  // Verify markers
  IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
  IMarker[] markers = workspaceRoot.findMarkers(IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER, true, IResource.DEPTH_INFINITE);
  List resources = new ArrayList();
  List messages = new ArrayList();
  int warnings = 0;
  for (int i = 0, length = markers.length; i < length; i++) {
    IMarker marker = markers[i];
    switch (((Integer) marker.getAttribute(IMarker.SEVERITY)).intValue()) {
    case IMarker.SEVERITY_ERROR:
      resources.add(marker.getResource().getName());
      messages.add(marker.getAttribute(IMarker.MESSAGE));
      break;
    case IMarker.SEVERITY_WARNING:
      warnings++;
      if (noWarning) {
        resources.add(marker.getResource().getName());
        messages.add(marker.getAttribute(IMarker.MESSAGE));
      }
      break;
    }
  }
  workspaceRoot.deleteMarkers(IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER, true, IResource.DEPTH_INFINITE);

  // Assert result
  int size = messages.size();
  if (size > 0) {
    StringBuffer debugBuffer = new StringBuffer();
    for (int i = 0; i < size; i++) {
      debugBuffer.append(resources.get(i));
      debugBuffer.append(":\n\t");
      debugBuffer.append(messages.get(i));
      debugBuffer.append('\n');
    }
    System.out.println("Unexpected ERROR marker(s):\n" + debugBuffer.toString());
    System.out.println("--------------------");
    String target = javaProject == null ? "workspace" : javaProject.getElementName();
    // assertEquals("Found "+size+" unexpected errors while building "+target,
    // 0, size);
  }
  if (DEBUG)
    System.out.println("done");
}
 
开发者ID:RuiChen08,项目名称:dacapobench,代码行数:79,代码来源:FullSourceWorkspaceBuildTests.java

示例15: removeSaveParticipant

import org.eclipse.core.resources.ResourcesPlugin; //导入方法依赖的package包/类
/**
 * 
 */
private void removeSaveParticipant() {
	IWorkspace workspace = ResourcesPlugin.getWorkspace();
	workspace.removeResourceChangeListener(listener);
}
 
开发者ID:gw4e,项目名称:gw4e.project,代码行数:8,代码来源:Activator.java


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