Search in sources :

Example 1 with PackagingElementNode

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

the class LayoutTree method configureUiHelper.

@Override
protected void configureUiHelper(TreeUIHelper helper) {
    final Convertor<TreePath, String> convertor = new Convertor<TreePath, String>() {

        @Override
        public String convert(final TreePath path) {
            final SimpleNode node = getNodeFor(path);
            if (node instanceof PackagingElementNode) {
                return ((PackagingElementNode<?>) node).getElementPresentation().getSearchName();
            }
            return "";
        }
    };
    new TreeSpeedSearch(this, convertor, true);
}
Also used : PackagingElementNode(com.intellij.openapi.roots.ui.configuration.artifacts.nodes.PackagingElementNode) TreePath(javax.swing.tree.TreePath) TreeSpeedSearch(com.intellij.ui.TreeSpeedSearch) Convertor(com.intellij.util.containers.Convertor) SimpleNode(com.intellij.ui.treeStructure.SimpleNode)

Example 2 with PackagingElementNode

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

the class LayoutTreeComponent method update.

@Override
public boolean update(DnDEvent aEvent) {
    aEvent.setDropPossible(false);
    aEvent.hideHighlighter();
    final Object object = aEvent.getAttachedObject();
    if (object instanceof PackagingElementDraggingObject) {
        final DefaultMutableTreeNode parent = findParentCompositeElementNode(aEvent.getRelativePoint().getPoint(myTree));
        if (parent != null) {
            final PackagingElementDraggingObject draggingObject = (PackagingElementDraggingObject) object;
            final PackagingElementNode node = getNode(parent);
            if (node != null && draggingObject.canDropInto(node)) {
                final PackagingElement element = node.getFirstElement();
                if (element instanceof CompositePackagingElement) {
                    draggingObject.setTargetNode(node);
                    draggingObject.setTargetElement((CompositePackagingElement<?>) element);
                    final Rectangle bounds = myTree.getPathBounds(TreeUtil.getPathFromRoot(parent));
                    aEvent.setHighlighting(new RelativeRectangle(myTree, bounds), DnDEvent.DropTargetHighlightingType.RECTANGLE);
                    aEvent.setDropPossible(true);
                }
            }
        }
    }
    return false;
}
Also used : PackagingElementNode(com.intellij.openapi.roots.ui.configuration.artifacts.nodes.PackagingElementNode) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) RelativeRectangle(com.intellij.ui.awt.RelativeRectangle) CompositePackagingElement(com.intellij.packaging.elements.CompositePackagingElement) RelativeRectangle(com.intellij.ui.awt.RelativeRectangle) PackagingElement(com.intellij.packaging.elements.PackagingElement) DirectoryPackagingElement(com.intellij.packaging.impl.elements.DirectoryPackagingElement) CompositePackagingElement(com.intellij.packaging.elements.CompositePackagingElement)

Example 3 with PackagingElementNode

use of com.intellij.openapi.roots.ui.configuration.artifacts.nodes.PackagingElementNode 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)

Aggregations

PackagingElementNode (com.intellij.openapi.roots.ui.configuration.artifacts.nodes.PackagingElementNode)3 CompositePackagingElement (com.intellij.packaging.elements.CompositePackagingElement)2 PackagingElement (com.intellij.packaging.elements.PackagingElement)2 DirectoryPackagingElement (com.intellij.packaging.impl.elements.DirectoryPackagingElement)2 PackagingNodeSource (com.intellij.openapi.roots.ui.configuration.artifacts.nodes.PackagingNodeSource)1 TreeSpeedSearch (com.intellij.ui.TreeSpeedSearch)1 RelativeRectangle (com.intellij.ui.awt.RelativeRectangle)1 SimpleNode (com.intellij.ui.treeStructure.SimpleNode)1 Convertor (com.intellij.util.containers.Convertor)1 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)1 TreePath (javax.swing.tree.TreePath)1