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


Java IWorkspaceRoot.getProject方法代码示例

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


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

示例1: createProjectPluginResource

import org.eclipse.core.resources.IWorkspaceRoot; //导入方法依赖的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: createChange

import org.eclipse.core.resources.IWorkspaceRoot; //导入方法依赖的package包/类
@Override
public Change createChange(IProgressMonitor pm) throws CoreException, OperationCanceledException {
	
	copyToPath=getArguments().getDestination().toString();
	IWorkspaceRoot workSpaceRoot = ResourcesPlugin.getWorkspace().getRoot();
	IProject project = workSpaceRoot.getProject(copyToPath.split("/")[1]);
	IFolder jobFolder = project.getFolder(copyToPath.substring(copyToPath.indexOf('/', 2)));
	previousJobFiles=new ArrayList<>();
	for (IResource iResource : jobFolder.members()) {
		if (!(iResource instanceof IFolder)) {
			IFile iFile = (IFile) iResource;
			 if (iFile.getFileExtension().equalsIgnoreCase(Messages.JOB_EXT)) {
				 previousJobFiles.add(iFile);
			 }
		}
	}
	copiedFileList.add(modifiedResource);
	return null;
}
 
开发者ID:capitalone,项目名称:Hydrograph,代码行数:20,代码来源:JobCopyParticipant.java

示例3: doSaveAs

import org.eclipse.core.resources.IWorkspaceRoot; //导入方法依赖的package包/类
@Override
public void doSaveAs() {
	String jobId = getActiveProject() + "." + getJobName();
	DataViewerUtility.INSTANCE.closeDataViewerWindows(JobManager.INSTANCE.getPreviouslyExecutedJobs().get(jobId));
	
	deleteDebugFiles(jobId);
	
	Map<String, String> currentParameterMap = getCurrentParameterMap();
	IFile file=opeSaveAsDialog();
	saveJob(file,true);
	IWorkspaceRoot workSpaceRoot = ResourcesPlugin.getWorkspace().getRoot();
	IProject project = workSpaceRoot.getProject(getActiveProject());
	IFolder paramFolder = project.getFolder(Messages.PARAM);
	IFile filename=paramFolder.getFile(oldFileName.replace(Messages.JOBEXTENSION,Messages.PROPERTIES_EXTENSION));
	copyParameterFile(currentParameterMap,filename);
	
}
 
开发者ID:capitalone,项目名称:Hydrograph,代码行数:18,代码来源:ELTGraphicalEditor.java

示例4: deleteProject

import org.eclipse.core.resources.IWorkspaceRoot; //导入方法依赖的package包/类
public void deleteProject(String projectName) throws CoreException {
	IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
	IProject project = root.getProject(projectName);
	IPath location = project.getLocation();
	if (project.exists()) {
		delete(project);
	}
	if (location != null) {
		/*
		 * we do a hard cleanup here no matter if the project has existed in
		 * workspace before or not.
		 * 
		 */
		deleteRecursive(location.toFile());
	}
}
 
开发者ID:de-jcup,项目名称:egradle,代码行数:17,代码来源:EclipseResourceHelper.java

示例5: setUp

import org.eclipse.core.resources.IWorkspaceRoot; //导入方法依赖的package包/类
/**
 * Setup before test.
 * @throws Exception exception
 */
@Before
public void setUp() throws Exception {
  String data = "package test_proj;\n\npublic class newClass {\n\n}";
  IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
  project = root.getProject(TestUtils.generateRandomStr(5));
  if (!project.exists()) {
    project.create(null);
  }
  if (!project.isOpen()) {
    project.open(null);
  }
  file = project.getFile("test.java");
  if (!file.exists()) {
    byte[] bytes = data.getBytes();
    InputStream source = new ByteArrayInputStream(bytes);
    file.create(source, IResource.NONE, null);
  }
  removeMarkers = new RemoveMarkers();
}
 
开发者ID:coala,项目名称:coala-eclipse,代码行数:24,代码来源:RunCmdTest.java

示例6: setUp

import org.eclipse.core.resources.IWorkspaceRoot; //导入方法依赖的package包/类
/**
 * Setup before test.
 */
@Before
public void setUp() throws Exception {
  String data = "import os\npass";
  final String diff = "--- \n+++ \[email protected]@ -1,2 +0,0 @@\n-import os\n-pass\n";
  IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
  project = root.getProject(TestUtils.generateRandomStr(5));
  if (!project.exists()) {
    project.create(null);
  }
  if (!project.isOpen()) {
    project.open(null);
  }
  file = project.getFile("test.java");
  if (!file.exists()) {
    byte[] bytes = data.getBytes();
    InputStream source = new ByteArrayInputStream(bytes);
    file.create(source, IResource.NONE, null);
  }
  marker = file.createMarker("com.coala.core.problem");
  marker.setAttribute(IMarker.MESSAGE, "");
  marker.setAttribute("file", file.toString());
  marker.setAttribute("diff", diff);
}
 
开发者ID:coala,项目名称:coala-eclipse,代码行数:27,代码来源:QuickFixerTest.java

示例7: initialize

import org.eclipse.core.resources.IWorkspaceRoot; //导入方法依赖的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

示例8: findProject

import org.eclipse.core.resources.IWorkspaceRoot; //导入方法依赖的package包/类
protected IProject findProject ( final Protocol protocol, final IProject modelProject )
{
    if ( this.projectFormat == null )
    {
        return modelProject;
    }

    final IWorkspaceRoot root = modelProject.getWorkspace ().getRoot ();
    final String projectName = String.format ( this.projectFormat, protocol.getPackagePrefix (), protocol.getName () );
    return root.getProject ( projectName );
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:12,代码来源:AcceleoGenerateGeneratorAction.java

示例9: moveProjectPluginResource

import org.eclipse.core.resources.IWorkspaceRoot; //导入方法依赖的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.IWorkspaceRoot; //导入方法依赖的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.IWorkspaceRoot; //导入方法依赖的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: createProject

import org.eclipse.core.resources.IWorkspaceRoot; //导入方法依赖的package包/类
public static IJavaProject createProject(String name) throws CoreException {

		IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
		IProject project = root.getProject(name);
		if (!project.exists()) {
			project.create(new NullProgressMonitor());
		} else {
			project.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
		}

		if (!project.isOpen()) {
			project.open(new NullProgressMonitor());
		}

		IFolder binFolder = project.getFolder("bin");
		if (!binFolder.exists()) {
			createFolder(binFolder, false, true, new NullProgressMonitor());
		}
		IPath outputLocation = binFolder.getFullPath();

		addNatureToProject(project, JavaCore.NATURE_ID, new NullProgressMonitor());

		IJavaProject jproject = JavaCore.create(project);
		jproject.setOutputLocation(outputLocation, new NullProgressMonitor());

		IClasspathEntry[] entries = PreferenceConstants.getDefaultJRELibrary();

		jproject.setRawClasspath(entries, new NullProgressMonitor());

		return jproject;
	}
 
开发者ID:gw4e,项目名称:gw4e.project,代码行数:32,代码来源:ProjectHelper.java

示例13: testGenericEditorCanOpenCamelFile

import org.eclipse.core.resources.IWorkspaceRoot; //导入方法依赖的package包/类
@Test
public void testGenericEditorCanOpenCamelFile() throws Exception {
	IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
	IProject project = root.getProject(CamelLSPLoadedByExtensionPointIT.class.getSimpleName());
	project.create(null);
	project.open(null);
	IFile camelFile = project.getFile("camelFile.xml");
	camelFile.create(new ByteArrayInputStream("<from uri=\"\" xmlns=\"http://camel.apache.org/schema/spring\"></from>\n".getBytes()), IResource.FORCE, null);
	IEditorPart openEditor = IDE.openEditor(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(), camelFile, "org.eclipse.ui.genericeditor.GenericEditor");
	assertThat(openEditor).isInstanceOf(ExtensionBasedTextEditor.class);
}
 
开发者ID:lhein,项目名称:camel-language-server,代码行数:12,代码来源:CamelLSPLoadedByExtensionPointIT.java

示例14: execute

import org.eclipse.core.resources.IWorkspaceRoot; //导入方法依赖的package包/类
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
	List<IFile> jobFiles = new ArrayList<>();
	List<IFile> pastedFileList = new ArrayList<>();
	IWorkbenchPart part = HandlerUtil.getActivePart(event);
	if(part instanceof CommonNavigator){
		PasteAction action = new PasteAction(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActivePart().getSite());
		action.run();
		IWorkspaceRoot workSpaceRoot = ResourcesPlugin.getWorkspace().getRoot();
		IProject project = workSpaceRoot.getProject(JobCopyParticipant.getCopyToPath().split("/")[1]);
		IFolder jobFolder = project.getFolder(
				JobCopyParticipant.getCopyToPath().substring(JobCopyParticipant.getCopyToPath().indexOf('/', 2)));
		IFolder paramFolder = project.getFolder(PARAMETER_FOLDER_NAME);
		try {
			createCurrentJobFileList(jobFolder, jobFiles);
			pastedFileList=getPastedFileList(jobFiles);
			generateUniqueJobIdForPastedFiles(pastedFileList);
			createXmlFilesForPastedJobFiles(pastedFileList);
			List<String> copiedPropertiesList = getCopiedPropertiesList();
			createPropertiesFilesForPastedFiles(paramFolder, pastedFileList, copiedPropertiesList);
			JobCopyParticipant.cleanUpStaticResourcesAfterPasteOperation();

		} catch (CoreException  coreException) {
			logger.warn("Error while copy paste jobFiles",coreException.getMessage() );
		}
		
	}
	
	else if(part instanceof ELTGraphicalEditor){
		IEditorPart editor = HandlerUtil.getActiveEditor(event);
		((ELTGraphicalEditor)editor).pasteSelection();
	}
	
	return null;
}
 
开发者ID:capitalone,项目名称:Hydrograph,代码行数:36,代码来源:PasteHandler.java

示例15: createProject

import org.eclipse.core.resources.IWorkspaceRoot; //导入方法依赖的package包/类
protected IProject createProject(IProgressMonitor monitor) {
	IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
	IProject project = root.getProject(HELLO_WORLD);
	try {
		if (project.exists())
			project.delete(true, monitor);
		project.create(monitor);
		project.open(monitor);
		addNature(project);
	} catch (Exception ex) {
		ex.printStackTrace();
	}
	return project;
}
 
开发者ID:Yakindu,项目名称:solidity-ide,代码行数:15,代码来源:KickStartNewProjectAction.java


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