/** {@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"); }
/** {@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); }
/** {@inheritDoc} */ public Object execute(CommandLine commandLine) throws Exception { String name = commandLine.getValue(Options.PROJECT_OPTION); IProject project = ProjectUtils.getProject(name, true); String setting = commandLine.getValue(Options.SETTING_OPTION); Preferences preferences = getPreferences(); if (commandLine.hasOption(Options.VALUE_OPTION)) { String value = commandLine.getValue(Options.VALUE_OPTION); preferences.setValue(project, setting, value); return null; } return preferences.getValue(project, setting); }
/** * Gets a java project by name. * * @param project The name of the project. * @return The project. */ public static IJavaProject getJavaProject(String project) throws Exception { return getJavaProject(ProjectUtils.getProject(project, true)); }