public boolean checkCanRemove(final List<? extends PackagingElementNode<?>> nodes) { Set<PackagingNodeSource> rootSources = new HashSet<PackagingNodeSource>(); for (PackagingElementNode<?> node : nodes) { rootSources.addAll(getRootNodeSources(node.getNodeSources())); } if (!rootSources.isEmpty()) { final String message; if (rootSources.size() == 1) { final String name = rootSources.iterator().next().getPresentableName(); message = "The selected node belongs to '" + name + "' element. Do you want to remove the whole '" + name + "' element from the artifact?"; } else { message = "The selected node belongs to " + nodes.size() + " elements. Do you want to remove all these elements from the artifact?"; } final int answer = Messages.showYesNoDialog( myArtifactsEditor.getMainComponent(), message, "Remove Elements", null); if (answer != Messages.YES) return false; } return true; }
public boolean checkCanModify(final Collection<PackagingNodeSource> nodeSources) { if (nodeSources.isEmpty()) { return true; } if (nodeSources.size() > 1) { Messages.showErrorDialog( myArtifactsEditor.getMainComponent(), "The selected node consist of several elements so it cannot be edited.\nSwitch off 'Show content of elements' checkbox to edit the output layout."); } else { final PackagingNodeSource source = ContainerUtil.getFirstItem(nodeSources, null); if (source != null) { Messages.showErrorDialog( myArtifactsEditor.getMainComponent(), "The selected node belongs to '" + source.getPresentableName() + "' element so it cannot be edited.\nSwitch off 'Show content of elements' checkbox to edit the output layout."); } } return false; }