public List<AbstractProjectConfigurator> getProjectConfigurators() throws CoreException { Map<String, AbstractProjectConfigurator> configuratorsMap = new LinkedHashMap<String, AbstractProjectConfigurator>(); for (AbstractProjectConfigurator configurator : AbstractLifecycleMapping.getProjectConfigurators()) { configuratorsMap.put(configurator.getId(), configurator); } Configuration config = lifecycleMappingPlugin.getConfiguration(); Element configuratorsDom = getChildElement((Element) config.getConfigurationNode(), "configurators"); List<AbstractProjectConfigurator> configurators = new ArrayList<AbstractProjectConfigurator>(); if (configuratorsDom != null) { for (Element configuratorDom : getChildren(configuratorsDom, "configurator")) { String configuratorId = configuratorDom.getAttribute("id"); AbstractProjectConfigurator configurator = configuratorsMap.get(configuratorId); if (configurator == null) { throw new IllegalArgumentException("Unknown configurator id=" + configuratorId); } configurators.add(configurator); } } return configurators; }
public void addProjectConfigurator() { List<AbstractProjectConfigurator> allConfigurators = new ArrayList<AbstractProjectConfigurator>( AbstractLifecycleMapping.getProjectConfigurators()); Configuration config = lifecycleMappingPlugin.getConfiguration(); Element configuratorsDom = getChildElement((Element) config.getConfigurationNode(), "configurators"); if (null != configuratorsDom) { Set<String> usedIds = new LinkedHashSet<String>(); for (Element configuratorDom : getChildren(configuratorsDom, "configurator")) { usedIds.add(configuratorDom.getAttribute("id")); } Iterator<AbstractProjectConfigurator> confItr = allConfigurators.iterator(); while (confItr.hasNext()) { if (usedIds.contains(confItr.next().getId())) { confItr.remove(); } } } if (!allConfigurators.isEmpty()) { ConfiguratorSelectionDialog dialog = new ConfiguratorSelectionDialog(pomEditor.getSite().getShell(), allConfigurators); dialog.setBlockOnOpen(true); dialog.open(); String selection = dialog.getSelectedConfigurator(); if (selection != null) { if (null == configuratorsDom) { configuratorsDom = config.getConfigurationNode().getOwnerDocument().createElement("configurators"); config.getConfigurationNode().appendChild(configuratorsDom); } Element configuratorDom = configuratorsDom.getOwnerDocument().createElement("configurator"); configuratorDom.setAttribute("id", selection); configuratorsDom.appendChild(configuratorDom); } } }