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 checkCanModifyChildren( @NotNull PackagingElement<?> parentElement, @NotNull PackagingElementNode<?> parentNode, @NotNull Collection<? extends PackagingElementNode<?>> children) { final List<PackagingNodeSource> sources = new ArrayList<PackagingNodeSource>(parentNode.getNodeSource(parentElement)); for (PackagingElementNode<?> child : children) { sources.addAll(child.getNodeSources()); } return checkCanModify(sources); }
public void actionPerformed(AnActionEvent e) { final LayoutTreeSelection selection = myArtifactEditor.getLayoutTreeComponent().getSelection(); final PackagingElementNode<?> node = selection.getNodeIfSingle(); if (node == null) return; final Collection<PackagingNodeSource> sources = node.getNodeSources(); for (PackagingNodeSource source : sources) { myArtifactEditor.getSubstitutionParameters().doNotSubstitute(source.getSourceElement()); myArtifactEditor .getLayoutTreeComponent() .getLayoutTree() .addSubtreeToUpdate(source.getSourceParentNode()); } }
@Override public void update(AnActionEvent e) { final LayoutTreeSelection selection = myArtifactEditor.getLayoutTreeComponent().getSelection(); final PackagingElementNode<?> node = selection.getNodeIfSingle(); if (node != null) { final Collection<PackagingNodeSource> sources = node.getNodeSources(); if (!sources.isEmpty()) { String description; if (sources.size() == 1) { description = "Hide Content of '" + sources.iterator().next().getPresentableName() + "'"; } else { description = "Hide Content"; } e.getPresentation().setVisible(true); e.getPresentation().setText(description); return; } } e.getPresentation().setVisible(false); }