本文整理匯總了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;
}
示例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;
}
示例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);
}
示例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());
}
}
示例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();
}
示例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);
}
示例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;
}
示例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 );
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}