Search in sources :

Example 1 with PackagingNodeSource

use of com.intellij.openapi.roots.ui.configuration.artifacts.nodes.PackagingNodeSource in project intellij-community by JetBrains.

the class HideContentAction method actionPerformed.

@Override
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());
    }
}
Also used : LayoutTreeSelection(com.intellij.openapi.roots.ui.configuration.artifacts.LayoutTreeSelection) PackagingNodeSource(com.intellij.openapi.roots.ui.configuration.artifacts.nodes.PackagingNodeSource)

Example 2 with PackagingNodeSource

use of com.intellij.openapi.roots.ui.configuration.artifacts.nodes.PackagingNodeSource in project intellij-community by JetBrains.

the class LayoutTreeComponent method removeNodes.

public void removeNodes(final List<PackagingElementNode<?>> nodes) {
    Set<PackagingElement<?>> parents = new HashSet<>();
    for (PackagingElementNode<?> node : nodes) {
        final List<? extends PackagingElement<?>> toDelete = node.getPackagingElements();
        for (PackagingElement<?> element : toDelete) {
            final Collection<PackagingNodeSource> nodeSources = node.getNodeSource(element);
            if (nodeSources.isEmpty()) {
                final CompositePackagingElement<?> parent = node.getParentElement(element);
                if (parent != null) {
                    parents.add(parent);
                    parent.removeChild(element);
                }
            } else {
                Collection<PackagingNodeSource> rootSources = getRootNodeSources(nodeSources);
                for (PackagingNodeSource source : rootSources) {
                    parents.add(source.getSourceParentElement());
                    source.getSourceParentElement().removeChild(source.getSourceElement());
                }
            }
        }
    }
    final List<PackagingElementNode<?>> parentNodes = myTree.findNodes(parents);
    for (PackagingElementNode<?> parentNode : parentNodes) {
        myTree.addSubtreeToUpdate(parentNode);
    }
}
Also used : PackagingNodeSource(com.intellij.openapi.roots.ui.configuration.artifacts.nodes.PackagingNodeSource) PackagingElementNode(com.intellij.openapi.roots.ui.configuration.artifacts.nodes.PackagingElementNode) PackagingElement(com.intellij.packaging.elements.PackagingElement) DirectoryPackagingElement(com.intellij.packaging.impl.elements.DirectoryPackagingElement) CompositePackagingElement(com.intellij.packaging.elements.CompositePackagingElement)

Example 3 with PackagingNodeSource

use of com.intellij.openapi.roots.ui.configuration.artifacts.nodes.PackagingNodeSource in project intellij-community by JetBrains.

the class HideContentAction method update.

@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);
}
Also used : LayoutTreeSelection(com.intellij.openapi.roots.ui.configuration.artifacts.LayoutTreeSelection) PackagingNodeSource(com.intellij.openapi.roots.ui.configuration.artifacts.nodes.PackagingNodeSource)

Aggregations

PackagingNodeSource (com.intellij.openapi.roots.ui.configuration.artifacts.nodes.PackagingNodeSource)3 LayoutTreeSelection (com.intellij.openapi.roots.ui.configuration.artifacts.LayoutTreeSelection)2 PackagingElementNode (com.intellij.openapi.roots.ui.configuration.artifacts.nodes.PackagingElementNode)1 CompositePackagingElement (com.intellij.packaging.elements.CompositePackagingElement)1 PackagingElement (com.intellij.packaging.elements.PackagingElement)1 DirectoryPackagingElement (com.intellij.packaging.impl.elements.DirectoryPackagingElement)1