當前位置: 首頁>>代碼示例>>Java>>正文


Java IWorkspace.getRoot方法代碼示例

本文整理匯總了Java中org.eclipse.core.resources.IWorkspace.getRoot方法的典型用法代碼示例。如果您正苦於以下問題:Java IWorkspace.getRoot方法的具體用法?Java IWorkspace.getRoot怎麽用?Java IWorkspace.getRoot使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.eclipse.core.resources.IWorkspace的用法示例。


在下文中一共展示了IWorkspace.getRoot方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: createProjectPluginResource

import org.eclipse.core.resources.IWorkspace; //導入方法依賴的package包/類
public IProject createProjectPluginResource(String projectName, IProgressMonitor monitor) throws CoreException {
	IWorkspace myWorkspace = ResourcesPlugin.getWorkspace();
	IWorkspaceRoot myWorkspaceRoot = myWorkspace.getRoot();
	IProject resourceProject = myWorkspaceRoot.getProject(projectName);
	
	if (!resourceProject.exists()) {		
		if(myWorkspaceRoot.getLocation().toFile().equals(new Path(Engine.PROJECTS_PATH).toFile())){
			logDebug("createProjectPluginResource : project is in the workspace folder");
			
			resourceProject.create(monitor);
		}else{
			logDebug("createProjectPluginResource: project isn't in the workspace folder");
	
			IPath projectPath = new Path(Engine.PROJECTS_PATH + "/" + projectName).makeAbsolute();
			IProjectDescription description = myWorkspace.newProjectDescription(projectName);
			description.setLocation(projectPath);
			resourceProject.create(description, monitor);
		}
	}
	
	return resourceProject;
}
 
開發者ID:convertigo,項目名稱:convertigo-eclipse,代碼行數:23,代碼來源:ConvertigoPlugin.java

示例2: addProjectsToList

import org.eclipse.core.resources.IWorkspace; //導入方法依賴的package包/類
private void addProjectsToList() {
	IWorkspace workspace = ResourcesPlugin.getWorkspace();
	IWorkspaceRoot root = workspace.getRoot();
	IProject[] projects = root.getProjects();
	
	for (IProject project : projects){
		try {
			if (project.isNatureEnabled("jasonide.jasonNature")){
				projectsList.add(project.getName());
			}
		} catch (CoreException e) {
			//e.printStackTrace();
			//MessageDialog.openError(shell, "CoreException", e.getMessage());
		}
	}
}
 
開發者ID:jason-lang,項目名稱:jason-eclipse-plugin,代碼行數:17,代碼來源:JasonWizardPage.java

示例3: getResource

import org.eclipse.core.resources.IWorkspace; //導入方法依賴的package包/類
/**
 * get the IResource corresponding to the given file. Given file does not
 * need to exist.
 * 
 * @param file
 * @param isDirectory
 *            if true, an IContainer will be returned, otherwise an IFile
 *            will be returned
 * @return
 */
public static IResource getResource(File file, boolean isDirectory) {
	if (file == null) return null;
    IWorkspace workspace = ResourcesPlugin.getWorkspace();
    IWorkspaceRoot workspaceRoot = workspace.getRoot();

    IPath pathEclipse = new Path(file.getAbsolutePath());

    IResource resource = null;

    if (isDirectory) {
        resource = workspaceRoot.getContainerForLocation(pathEclipse);
    } else {
        resource = workspaceRoot.getFileForLocation(pathEclipse);
    }
    return resource;
}
 
開發者ID:subclipse,項目名稱:subclipse,代碼行數:27,代碼來源:File2Resource.java

示例4: scanForCompilationUnits

import org.eclipse.core.resources.IWorkspace; //導入方法依賴的package包/類
/**
 * Traverses the workspace for CompilationUnits.
 * 
 * @return the list of all CompilationUnits in the workspace
 */
public static List<ICompilationUnit> scanForCompilationUnits() {
	IWorkspace workspace = ResourcesPlugin.getWorkspace();
	if (workspace == null) {
		System.out.println("No workspace");
		return null;
	}
	IWorkspaceRoot root = workspace.getRoot();
	if (root == null) {
		System.out.println("No workspace root");
		return null;
	}

	IJavaModel javaModel = JavaCore.create(root);
	if (javaModel == null) {
		System.out.println("No Java Model in workspace");
		return null;
	}

	// Get all CompilationUnits
	return WorkspaceUtilities.collectCompilationUnits(javaModel);
}
 
開發者ID:aroog,項目名稱:code,代碼行數:27,代碼來源:WorkspaceUtilities.java

示例5: getIFileFromResource

import org.eclipse.core.resources.IWorkspace; //導入方法依賴的package包/類
private IFile getIFileFromResource() {
	Resource linkTargetResource = linkTarget.eResource();
	if (linkTargetResource == null) {
		return null;
	}
	URI resourceURI = linkTargetResource.getURI();
	if (linkTargetResource.getResourceSet() != null && linkTargetResource.getResourceSet().getURIConverter() != null) {
		resourceURI = linkTargetResource.getResourceSet().getURIConverter().normalize(resourceURI);
	}
	if (resourceURI.isPlatformResource()) {
		String platformString = resourceURI.toPlatformString(true);
		if (platformString != null) {
			IWorkspace workspace = ResourcesPlugin.getWorkspace();
			IWorkspaceRoot root = workspace.getRoot();
			return root.getFile(new Path(platformString));
		}
	}
	return null;
}
 
開發者ID:DarwinSPL,項目名稱:DarwinSPL,代碼行數:20,代碼來源:DwprofileHyperlink.java

示例6: initialize

import org.eclipse.core.resources.IWorkspace; //導入方法依賴的package包/類
private IProject initialize(String projectName) {
	IWorkspace workspace = ResourcesPlugin.getWorkspace();
	IWorkspaceRoot root = workspace.getRoot();
	IProject project = root.getProject(projectName);
	if (!project.exists())
		try {
			project.create(null);
			if (!project.isOpen())
				project.open(null);
			if (!project.hasNature("org.eclipse.xtext.ui.shared.xtextNature")) {
				IProjectDescription description = project.getDescription();
				description.setNatureIds(new String[] { "org.eclipse.xtext.ui.shared.xtextNature" });
				project.setDescription(description, null);
			}
		} catch (CoreException e) {
			e.printStackTrace();
		}
	return project;
}
 
開發者ID:ioanaverebi,項目名稱:Sparrow,代碼行數:20,代碼來源:ModelVisitor.java

示例7: getLayoutFile

import org.eclipse.core.resources.IWorkspace; //導入方法依賴的package包/類
/**
 * Returns the file object of the feature model
 * @param featureModel
 * @return
 */
private static File getLayoutFile(DwFeatureModelWrapped featureModel){
	IWorkspace workspace = ResourcesPlugin.getWorkspace();
	IWorkspaceRoot workspaceRoot = workspace.getRoot();
	
	IFile file = workspaceRoot.getFile(new Path(featureModel.getModel().eResource().getURI().toPlatformString(true)));
	
	IPath path = ((IPath)file.getFullPath().clone()).removeFileExtension().addFileExtension("hylayout");
	IResource resourceInRuntimeWorkspace = workspaceRoot.findMember(path.toString());

	if(resourceInRuntimeWorkspace != null){
		return new File(resourceInRuntimeWorkspace.getLocationURI());	
	}else{
		return null;
	}
}
 
開發者ID:DarwinSPL,項目名稱:DarwinSPL,代碼行數:21,代碼來源:DwFeatureModelLayoutFileUtil.java

示例8: createFileInPath

import org.eclipse.core.resources.IWorkspace; //導入方法依賴的package包/類
public static File createFileInPath(String fileName, IPath path){
	path = path.append(fileName);
	IWorkspace workspace = ResourcesPlugin.getWorkspace();
	IWorkspaceRoot workspaceRoot = workspace.getRoot();
	
	IFile outputFile = workspaceRoot.getFile(path);
	File file = new File(outputFile.getLocationURI());
	
	if(!file.exists())
		try {
			if(!file.createNewFile()){
				return null;
			}
		} catch (IOException e) {
			e.printStackTrace();
			return null;
		}
	
	return file;
}
 
開發者ID:DarwinSPL,項目名稱:DarwinSPL,代碼行數:21,代碼來源:DwEclipseWorkspaceUtil.java

示例9: moveProjectPluginResource

import org.eclipse.core.resources.IWorkspace; //導入方法依賴的package包/類
public void moveProjectPluginResource(String projectName, String newName) throws CoreException {
	cacheIProject.remove(projectName);
	IWorkspace myWorkspace = ResourcesPlugin.getWorkspace();
	IWorkspaceRoot myWorkspaceRoot = myWorkspace.getRoot();
	IProject resourceProject = myWorkspaceRoot.getProject(projectName);
	
	if (resourceProject.exists()) {
		IPath newProjectPath = new Path(Engine.PROJECTS_PATH + "/" + newName).makeAbsolute();
       	IProjectDescription description = myWorkspace.newProjectDescription(newName);
		description.setLocation(newProjectPath);
       	resourceProject.move(description, false, null);
	}
}
 
開發者ID:convertigo,項目名稱:convertigo-eclipse,代碼行數:14,代碼來源:ConvertigoPlugin.java

示例10: closeProjectPluginResource

import org.eclipse.core.resources.IWorkspace; //導入方法依賴的package包/類
public void closeProjectPluginResource(String projectName) throws CoreException {
	cacheIProject.remove(projectName);
	IWorkspace myWorkspace = ResourcesPlugin.getWorkspace();
	IWorkspaceRoot myWorkspaceRoot = myWorkspace.getRoot();
	IProject resourceProject = myWorkspaceRoot.getProject(projectName);
	
	if (resourceProject.exists()) {
       	resourceProject.close(null);
	}
}
 
開發者ID:convertigo,項目名稱:convertigo-eclipse,代碼行數:11,代碼來源:ConvertigoPlugin.java

示例11: deleteProjectPluginResource

import org.eclipse.core.resources.IWorkspace; //導入方法依賴的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

示例12: errorIsInProblemView

import org.eclipse.core.resources.IWorkspace; //導入方法依賴的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

示例13: print

import org.eclipse.core.resources.IWorkspace; //導入方法依賴的package包/類
public void print() {
	try {
		IWorkspace workspace = ResourcesPlugin.getWorkspace();
		IResource resource = workspace.getRoot();
		IMarker[] markers = resource.findMarkers(IMarker.MARKER, true, IResource.DEPTH_INFINITE);
		for (IMarker m : markers) {
		    System.out.println("Message: " + m.getAttribute(IMarker.MESSAGE));
		}
	} catch (CoreException e) {
		e.printStackTrace();
	}
}
 
開發者ID:gw4e,項目名稱:gw4e.project,代碼行數:13,代碼來源:ProblemView.java

示例14: start

import org.eclipse.core.resources.IWorkspace; //導入方法依賴的package包/類
@Override
public void start(BundleContext context) {

	Visuflow.context = context;
	plugin = this;
	logger = new Logger(getLog());
	logger.info("Visuflow plug-in starting...");
	JimpleBreakpointManager.getInstance();

	// iterate over all projects in the workspace to find projects with the
	// visuflow nature. for these projects we trigger a full build to fill
	// the data model directly after the launch. there is also the ProjectListener,
	// which triggers a build for newly opened projects (e.g. opening a closed one or
	// importing a project etc.)
	// the builds are only executed, if the workspace is set to auto build
	IWorkspace workspace = ResourcesPlugin.getWorkspace();
	workspace.addResourceChangeListener(projectListener, IResourceChangeEvent.POST_CHANGE);
	if(workspace.isAutoBuilding()) {
		IWorkspaceRoot root = workspace.getRoot();
		try {
			root.accept(new IResourceVisitor() {
				@Override
				public boolean visit(IResource resource) throws CoreException {
					if(resource.getType() == IResource.PROJECT) {
						IProject project = (IProject) resource;
						projectListener.triggerBuild(project);
						return false;
					}
					return true;
				}
			});
		} catch (CoreException e) {
			logger.error("Error while trying to build visuflow projects", e);
		}
	}
}
 
開發者ID:VisuFlow,項目名稱:visuflow-plugin,代碼行數:37,代碼來源:Visuflow.java

示例15: getFirstJavaProject

import org.eclipse.core.resources.IWorkspace; //導入方法依賴的package包/類
/**
 * Get the first Java project, without requiring file to be open in editor
 * @return
 * XXX. Will this return an open project? 
 */
public static IJavaProject getFirstJavaProject() {
	IWorkspace workspace = ResourcesPlugin.getWorkspace();
	if (workspace == null) {
		System.out.println("No workspace");
		return null;
	}
	IWorkspaceRoot root = workspace.getRoot();
	if (root == null) {
		System.out.println("No workspace root");
		return null;
	}

	IJavaModel javacore = JavaCore.create(root);// this gets you the java version of the workspace
	IJavaProject project = null;
	if (javacore != null) {
		IJavaProject[] javaProjects = null;
           try {
            javaProjects = javacore.getJavaProjects();
           }
           catch (JavaModelException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
           }
		if (javaProjects != null && javaProjects.length == 1) {
			project = javaProjects [0];
			if (javaProjects.length > 1 ) {
				System.err.println("Multiple open projects");
			}
		}
	}

	WorkspaceUtilities.javaProject = project;
	
	return project;
}
 
開發者ID:aroog,項目名稱:code,代碼行數:41,代碼來源:WorkspaceUtilities.java


注:本文中的org.eclipse.core.resources.IWorkspace.getRoot方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。