Search in sources :

Example 1 with LayoutTreeSelection

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

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

the class InlineArtifactAction method actionPerformed.

@Override
public void actionPerformed(AnActionEvent e) {
    final LayoutTreeComponent treeComponent = myEditor.getLayoutTreeComponent();
    final LayoutTreeSelection selection = treeComponent.getSelection();
    final PackagingElement<?> element = selection.getElementIfSingle();
    final PackagingElementNode<?> node = selection.getNodeIfSingle();
    if (node == null || !(element instanceof ArtifactPackagingElement))
        return;
    final CompositePackagingElement<?> parent = node.getParentElement(element);
    final CompositePackagingElementNode parentNode = node.getParentNode();
    if (parent == null || parentNode == null) {
        return;
    }
    if (!treeComponent.checkCanModifyChildren(parent, parentNode, Collections.singletonList(node)))
        return;
    treeComponent.editLayout(() -> {
        parent.removeChild(element);
        final ArtifactEditorContext context = myEditor.getContext();
        final Artifact artifact = ((ArtifactPackagingElement) element).findArtifact(context);
        if (artifact != null) {
            final CompositePackagingElement<?> rootElement = artifact.getRootElement();
            if (rootElement instanceof ArtifactRootElement<?>) {
                for (PackagingElement<?> child : rootElement.getChildren()) {
                    parent.addOrFindChild(ArtifactUtil.copyWithChildren(child, context.getProject()));
                }
            } else {
                parent.addOrFindChild(ArtifactUtil.copyWithChildren(rootElement, context.getProject()));
            }
        }
    });
    treeComponent.rebuildTree();
}
Also used : LayoutTreeSelection(com.intellij.openapi.roots.ui.configuration.artifacts.LayoutTreeSelection) ArtifactPackagingElement(com.intellij.packaging.impl.elements.ArtifactPackagingElement) ArtifactRootElement(com.intellij.packaging.elements.ArtifactRootElement) CompositePackagingElementNode(com.intellij.openapi.roots.ui.configuration.artifacts.nodes.CompositePackagingElementNode) ArtifactEditorContext(com.intellij.packaging.ui.ArtifactEditorContext) Artifact(com.intellij.packaging.artifacts.Artifact) LayoutTreeComponent(com.intellij.openapi.roots.ui.configuration.artifacts.LayoutTreeComponent)

Example 3 with LayoutTreeSelection

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

the class RenamePackagingElementAction method update.

@Override
public void update(AnActionEvent e) {
    final LayoutTreeSelection selection = myArtifactEditor.getLayoutTreeComponent().getSelection();
    final PackagingElement<?> element = selection.getElementIfSingle();
    final boolean visible = element instanceof RenameablePackagingElement && ((RenameablePackagingElement) element).canBeRenamed();
    e.getPresentation().setEnabled(visible);
    e.getPresentation().setVisible(visible);
}
Also used : LayoutTreeSelection(com.intellij.openapi.roots.ui.configuration.artifacts.LayoutTreeSelection) RenameablePackagingElement(com.intellij.packaging.elements.RenameablePackagingElement)

Example 4 with LayoutTreeSelection

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

the class RenamePackagingElementAction method actionPerformed.

@Override
public void actionPerformed(AnActionEvent e) {
    final LayoutTreeSelection selection = myArtifactEditor.getLayoutTreeComponent().getSelection();
    final PackagingElementNode<?> node = selection.getNodeIfSingle();
    final PackagingElement<?> element = selection.getElementIfSingle();
    if (node == null || element == null)
        return;
    if (!myArtifactEditor.getLayoutTreeComponent().checkCanModify(element, node))
        return;
    final TreePath path = selection.getPath(node);
    myArtifactEditor.getLayoutTreeComponent().startRenaming(path);
}
Also used : LayoutTreeSelection(com.intellij.openapi.roots.ui.configuration.artifacts.LayoutTreeSelection) TreePath(javax.swing.tree.TreePath)

Example 5 with LayoutTreeSelection

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

the class SurroundElementWithAction method actionPerformed.

@Override
public void actionPerformed(AnActionEvent e) {
    final LayoutTreeComponent treeComponent = myArtifactEditor.getLayoutTreeComponent();
    final LayoutTreeSelection selection = treeComponent.getSelection();
    final CompositePackagingElement<?> parent = selection.getCommonParentElement();
    if (parent == null)
        return;
    final PackagingElementNode<?> parentNode = selection.getNodes().get(0).getParentNode();
    if (parentNode == null)
        return;
    if (!treeComponent.checkCanModifyChildren(parent, parentNode, selection.getNodes())) {
        return;
    }
    final CompositePackagingElementType<?>[] types = PackagingElementFactory.getInstance().getCompositeElementTypes();
    final List<PackagingElement<?>> selected = selection.getElements();
    if (types.length == 1) {
        surroundWith(types[0], parent, selected, treeComponent);
    } else {
        JBPopupFactory.getInstance().createListPopup(new BaseListPopupStep<CompositePackagingElementType>("Surround With...", types) {

            @Override
            public Icon getIconFor(CompositePackagingElementType aValue) {
                return aValue.getCreateElementIcon();
            }

            @NotNull
            @Override
            public String getTextFor(CompositePackagingElementType value) {
                return value.getPresentableName();
            }

            @Override
            public PopupStep onChosen(final CompositePackagingElementType selectedValue, boolean finalChoice) {
                return doFinalStep(() -> surroundWith(selectedValue, parent, selected, treeComponent));
            }
        }).showInBestPositionFor(e.getDataContext());
    }
}
Also used : LayoutTreeSelection(com.intellij.openapi.roots.ui.configuration.artifacts.LayoutTreeSelection) BaseListPopupStep(com.intellij.openapi.ui.popup.util.BaseListPopupStep) CompositePackagingElementType(com.intellij.packaging.elements.CompositePackagingElementType) PackagingElement(com.intellij.packaging.elements.PackagingElement) CompositePackagingElement(com.intellij.packaging.elements.CompositePackagingElement) LayoutTreeComponent(com.intellij.openapi.roots.ui.configuration.artifacts.LayoutTreeComponent)

Aggregations

LayoutTreeSelection (com.intellij.openapi.roots.ui.configuration.artifacts.LayoutTreeSelection)8 LayoutTreeComponent (com.intellij.openapi.roots.ui.configuration.artifacts.LayoutTreeComponent)3 ArtifactPackagingElement (com.intellij.packaging.impl.elements.ArtifactPackagingElement)3 PackagingNodeSource (com.intellij.openapi.roots.ui.configuration.artifacts.nodes.PackagingNodeSource)2 CompositePackagingElement (com.intellij.packaging.elements.CompositePackagingElement)2 PackagingElement (com.intellij.packaging.elements.PackagingElement)2 Project (com.intellij.openapi.project.Project)1 CompositePackagingElementNode (com.intellij.openapi.roots.ui.configuration.artifacts.nodes.CompositePackagingElementNode)1 BaseListPopupStep (com.intellij.openapi.ui.popup.util.BaseListPopupStep)1 Artifact (com.intellij.packaging.artifacts.Artifact)1 ModifiableArtifact (com.intellij.packaging.artifacts.ModifiableArtifact)1 ModifiableArtifactModel (com.intellij.packaging.artifacts.ModifiableArtifactModel)1 ArtifactRootElement (com.intellij.packaging.elements.ArtifactRootElement)1 CompositePackagingElementType (com.intellij.packaging.elements.CompositePackagingElementType)1 RenameablePackagingElement (com.intellij.packaging.elements.RenameablePackagingElement)1 ArtifactEditorContext (com.intellij.packaging.ui.ArtifactEditorContext)1 TreePath (javax.swing.tree.TreePath)1