public void addNewPackagingElement(@NotNull PackagingElementType<?> type) { PackagingElementNode<?> parentNode = getParentNode(myTree.getSelection()); final PackagingElement<?> element = parentNode.getFirstElement(); final CompositePackagingElement<?> parent; if (element instanceof CompositePackagingElement<?>) { parent = (CompositePackagingElement<?>) element; } else { parent = getArtifact().getRootElement(); parentNode = myTree.getRootPackagingNode(); } if (!checkCanAdd(parent, parentNode)) return; final List<? extends PackagingElement<?>> children = type.chooseAndCreate(myContext, getArtifact(), parent); final PackagingElementNode<?> finalParentNode = parentNode; editLayout( new Runnable() { @Override public void run() { CompositePackagingElement<?> actualParent = getOrCreateModifiableParent(parent, finalParentNode); for (PackagingElement<?> child : children) { actualParent.addOrFindChild(child); } } }); updateAndSelect(parentNode, children); }
public void removeSelectedElements() { final LayoutTreeSelection selection = myTree.getSelection(); if (!checkCanRemove(selection.getNodes())) return; editLayout( new Runnable() { @Override public void run() { removeNodes(selection.getNodes()); } }); myArtifactsEditor.rebuildTries(); }
public LayoutTreeSelection getSelection() { return myTree.getSelection(); }