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());
}
}
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();
}
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);
}
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);
}
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());
}
}
Aggregations