當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。