我正在制作一个eclipse插件,我无法弄清楚如何在代码中更改项目的名称。当我的插件导入项目时,如果存在具有相同名称的项目,我想重命名项目。
有什么想法吗?
答案 0 :(得分:0)
答案 1 :(得分:0)
我认为这大致是所需的代码(改编自WizardProjectsImportPage
):
IWorkspace workspace = ResourcesPlugin.getWorkspace();
IProjectDescription description = workspace.loadProjectDescription(existing .project path);
description.setName("new project name"); // May not be necessary
description.setLocation(null); // Default location in the workspace
// Create new project handle
IProject project = workspace.getRoot().getProject("new project name");
// Create and open the project
project.create(description, progress monitor);
project.open(IResource.BACKGROUND_REFRESH, progress monitor);
/// TODO use org.eclipse.ui.wizards.datatransfer.ImportOperation to import project contents