Ejemplo n.º 1
0
  /** {@inheritDoc} */
  public Object execute(CommandLine commandLine) throws Exception {
    String name = commandLine.getValue(Options.PROJECT_OPTION);
    IProject project = ProjectUtils.getProject(name);
    String[] aliases = StringUtils.split(commandLine.getValue(Options.NATURE_OPTION), ',');

    IProjectDescription desc = project.getDescription();
    String[] natureIds = desc.getNatureIds();
    ArrayList<String> modified = new ArrayList<String>();
    ArrayList<String> newNatures = new ArrayList<String>();
    CollectionUtils.addAll(modified, natureIds);
    for (String alias : aliases) {
      String natureId = ProjectNatureFactory.getNatureForAlias(alias);
      if (natureId != null && !modified.contains(natureId)) {
        modified.add(natureId);
        newNatures.add(natureId);
      }
    }

    desc.setNatureIds((String[]) modified.toArray(new String[modified.size()]));
    project.setDescription(desc, new NullProgressMonitor());

    for (String nature : newNatures) {
      ProjectManager manager = ProjectManagement.getProjectManager(nature);
      if (manager != null) {
        manager.create(project, commandLine);
      }
    }

    return Services.getMessage("project.nature.added");
  }
Ejemplo n.º 2
0
  /** {@inheritDoc} */
  public Object execute(CommandLine commandLine) throws Exception {
    String name = commandLine.getValue(Options.PROJECT_OPTION);

    IProject project = ProjectUtils.getProject(name, true);
    ProjectManagement.refresh(project, commandLine);

    return Services.getMessage("project.refreshed", name);
  }