本文整理汇总了Java中org.eclipse.core.resources.IProjectDescription.getName方法的典型用法代码示例。如果您正苦于以下问题:Java IProjectDescription.getName方法的具体用法?Java IProjectDescription.getName怎么用?Java IProjectDescription.getName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.core.resources.IProjectDescription
的用法示例。
在下文中一共展示了IProjectDescription.getName方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getLocalPath
import org.eclipse.core.resources.IProjectDescription; //导入方法依赖的package包/类
@Override
public String getLocalPath(final ImportFolder selectedPath, final ImportOptions importOptions)
throws CoreException {
/*
* download the .project file
*/
final VersionControlClient vcClient = importOptions.getTFSWorkspace().getClient();
final String localTemporaryDotProjectFilePath =
selectedPath.getExistingProjectMetadataFileItem().downloadFileToTempLocation(
vcClient,
IProjectDescription.DESCRIPTION_FILE_NAME).getAbsolutePath();
/*
* parse in the .project file and create an IProjectDescription
*/
final IProjectDescription temporaryProjectDescription =
importOptions.getEclipseWorkspace().loadProjectDescription(new Path(localTemporaryDotProjectFilePath));
/*
* the projectName comes from the IProjectDescription
*/
final String projectName = temporaryProjectDescription.getName();
/*
* Make sure that there are no existing projects with this name.
* (This would be a mapping failure later, better to catch it now
* with a better explanation.)
*/
final IProject existingProject = importOptions.getEclipseWorkspace().getRoot().getProject(projectName);
if (existingProject != null && existingProject.exists()) {
throw new RuntimeException(
MessageFormat.format(
Messages.getString("ImportLocalPathStrategy.ProjectWithSameNameExistsFormat"), //$NON-NLS-1$
selectedPath.getFullPath(),
projectName));
}
return importOptions.getEclipseWorkspace().getRoot().getLocation().append(projectName).toOSString();
}
示例2: importDir
import org.eclipse.core.resources.IProjectDescription; //导入方法依赖的package包/类
private void importDir(java.nio.file.Path dir, IProgressMonitor m) {
SubMonitor monitor = SubMonitor.convert(m, 4);
IWorkspace workspace = ResourcesPlugin.getWorkspace();
IPath dotProjectPath = new Path(dir.resolve(DESCRIPTION_FILE_NAME).toAbsolutePath().toString());
IProjectDescription descriptor;
try {
descriptor = workspace.loadProjectDescription(dotProjectPath);
String name = descriptor.getName();
if (!descriptor.hasNature(JavaCore.NATURE_ID)) {
return;
}
IProject project = workspace.getRoot().getProject(name);
if (project.exists()) {
IPath existingProjectPath = project.getLocation();
existingProjectPath = fixDevice(existingProjectPath);
dotProjectPath = fixDevice(dotProjectPath);
if (existingProjectPath.equals(dotProjectPath.removeLastSegments(1))) {
project.open(IResource.NONE, monitor.newChild(1));
project.refreshLocal(IResource.DEPTH_INFINITE, monitor.newChild(1));
return;
} else {
project = findUniqueProject(workspace, name);
descriptor.setName(project.getName());
}
}
project.create(descriptor, monitor.newChild(1));
project.open(IResource.NONE, monitor.newChild(1));
} catch (CoreException e) {
JavaLanguageServerPlugin.log(e.getStatus());
throw new RuntimeException(e);
} finally {
monitor.done();
}
}
示例3: createOrImportProject
import org.eclipse.core.resources.IProjectDescription; //导入方法依赖的package包/类
private IProject createOrImportProject(File directory, IWorkspaceRoot workspaceRoot,
IProgressMonitor progressMonitor) throws Exception {
IProjectDescription desc = null;
File expectedProjectDescriptionFile = new File(directory, IProjectDescription.DESCRIPTION_FILE_NAME);
if (expectedProjectDescriptionFile.exists()) {
desc = ResourcesPlugin.getWorkspace()
.loadProjectDescription(new Path(expectedProjectDescriptionFile.getAbsolutePath()));
String expectedName = desc.getName();
IProject projectWithSameName = workspaceRoot.getProject(expectedName);
if (projectWithSameName.exists()) {
if (projectWithSameName.getLocation().toFile().equals(directory)) {
// project seems already there
return projectWithSameName;
}
throw new Exception(NLS.bind(
AngularCLIMessages.AbstractProjectCommandInterpreter_anotherProjectWithSameNameExists_description,
expectedName));
}
} else {
String projectName = directory.getName();
if (workspaceRoot.getProject(directory.getName()).exists()) {
int i = 1;
do {
projectName = directory.getName() + '(' + i + ')';
i++;
} while (workspaceRoot.getProject(projectName).exists());
}
desc = ResourcesPlugin.getWorkspace().newProjectDescription(projectName);
}
desc.setLocation(new Path(directory.getAbsolutePath()));
IProject res = workspaceRoot.getProject(desc.getName());
res.create(desc, progressMonitor);
return res;
}
示例4: moveProject
import org.eclipse.core.resources.IProjectDescription; //导入方法依赖的package包/类
@Override
public boolean moveProject(
final IResourceTree tree,
final IProject source,
final IProjectDescription target,
final int updateFlags,
final IProgressMonitor progressMonitor) {
log.trace(MessageFormat.format("moveProject: {0}", source.getFullPath())); //$NON-NLS-1$
progressMonitor.beginTask(
MessageFormat.format(Messages.getString("TFSMoveDeleteHook.MovingProjectFormat"), source.getFullPath()), //$NON-NLS-1$
10);
log.info(MessageFormat.format("Rename detected from project {0} to {1}", source, target)); //$NON-NLS-1$
try {
/*
* Renaming the project only. Does not move folders, only sets the
* new name in the .project file.
*/
if (target.getName() != source.getName()) {
target.setLocation(source.getLocation());
tree.standardMoveProject(source, target, updateFlags, new SubProgressMonitor(progressMonitor, 10));
return true;
} else {
/*
* User is attempting to relocate the project. This gets hairy
* and would involve changing WF mappings in order to pend a
* rename.
*/
tree.failed(
new Status(
IStatus.ERROR,
TFSEclipseClientPlugin.PLUGIN_ID,
0,
MessageFormat.format(
Messages.getString("TFSMoveDeleteHook.MovingProjectNotSupportedInProductFormat"), //$NON-NLS-1$
ProductInformation.getCurrent().toString()),
null));
return true;
}
} finally {
progressMonitor.done();
}
}
示例5: createProject
import org.eclipse.core.resources.IProjectDescription; //导入方法依赖的package包/类
@Override
protected IProject createProject(final String localPath, final ImportOptions importOptions)
throws CoreException {
final IPath projectRootPath = new Path(localPath);
final IProjectDescription description = importOptions.getEclipseWorkspace().loadProjectDescription(
projectRootPath.append(IProjectDescription.DESCRIPTION_FILE_NAME));
final String projectName = description.getName();
description.setLocation(projectRootPath);
final IProject eclipseProject = importOptions.getEclipseWorkspace().getRoot().getProject(projectName);
/*
* If this project is NOT to be beneath the workspace root, then we
* need to specify the project description specifically.
*/
final IPath workspaceRootLocation = importOptions.getEclipseWorkspace().getRoot().getLocation();
/*
* We can only import into the workspace root if the path is
* workspaceroot/projectname
*/
if (LocalPath.equals(
projectRootPath.toOSString(),
LocalPath.combine(workspaceRootLocation.toOSString(), projectName))) {
/* Must not pass description if path is in workspace root. */
eclipseProject.create(null, null);
}
/*
* Otherwise, the import is into the workspace root, and the
* directory name is not the project name -- fail here. The UI
* should have caught this ahead of time.
*/
else if (LocalPath.isChild(workspaceRootLocation.toOSString(), projectRootPath.toOSString())) {
throw new CoreException(
new Status(IStatus.ERROR, TFSEclipseClientPlugin.PLUGIN_ID, 0, MessageFormat.format(
//@formatter:off
Messages.getString("ImportOpenProjectStrategy.ProjectIsMappedInEclipserootButInWrongFolderNameFormat"), //$NON-NLS-1$
//@formatter:on
projectName,
projectRootPath.lastSegment(),
projectName), null));
}
/* Outside the workspace root, users can do whatever they want. */
else {
/*
* Must pass description if the path is not in workspace root.
*/
eclipseProject.create(description, null);
}
return eclipseProject;
}