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


Java IProjectDescription.getName方法代码示例

本文整理汇总了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();
}
 
开发者ID:Microsoft,项目名称:team-explorer-everywhere,代码行数:41,代码来源:ImportLocalPathStrategy.java

示例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();
	}
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:35,代码来源:EclipseProjectImporter.java

示例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;
}
 
开发者ID:angelozerr,项目名称:angular-eclipse,代码行数:36,代码来源:NgProjectJob.java

示例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();
    }
}
 
开发者ID:Microsoft,项目名称:team-explorer-everywhere,代码行数:46,代码来源:TFSMoveDeleteHook.java

示例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;
}
 
开发者ID:Microsoft,项目名称:team-explorer-everywhere,代码行数:56,代码来源:ImportOpenProjectStrategy.java


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