use of com.intellij.packaging.artifacts.ModifiableArtifact in project intellij-community by JetBrains.
the class ArtifactEditorImpl method setArtifactType.
public void setArtifactType(ArtifactType artifactType) {
final ModifiableArtifact modifiableArtifact = myContext.getOrCreateModifiableArtifactModel().getOrCreateModifiableArtifact(myOriginalArtifact);
modifiableArtifact.setArtifactType(artifactType);
myPropertiesEditors.removeTabs(myTabbedPane);
myPropertiesEditors = new ArtifactPropertiesEditors(myContext, myOriginalArtifact, getArtifact());
myPropertiesEditors.addTabs(myTabbedPane);
final CompositePackagingElement<?> oldRootElement = getRootElement();
final CompositePackagingElement<?> newRootElement = artifactType.createRootElement(getArtifact().getName());
ArtifactUtil.copyChildren(oldRootElement, newRootElement, myProject);
myLayoutTreeComponent.setRootElement(newRootElement);
}
use of com.intellij.packaging.artifacts.ModifiableArtifact in project intellij-community by JetBrains.
the class ArtifactEditorImpl method apply.
public void apply() {
final ModifiableArtifact modifiableArtifact = myContext.getOrCreateModifiableArtifactModel().getOrCreateModifiableArtifact(myOriginalArtifact);
modifiableArtifact.setBuildOnMake(myBuildOnMakeCheckBox.isSelected());
modifiableArtifact.setOutputPath(getConfiguredOutputPath());
myPropertiesEditors.applyProperties();
myLayoutTreeComponent.saveElementProperties();
}
use of com.intellij.packaging.artifacts.ModifiableArtifact in project intellij-community by JetBrains.
the class ExtractArtifactAction 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 Collection<? extends PackagingElement> selectedElements = selection.getElements();
String initialName = "artifact";
if (selectedElements.size() == 1) {
initialName = PathUtil.suggestFileName(ContainerUtil.getFirstItem(selectedElements, null).createPresentation(myArtifactEditor.getContext()).getPresentableName());
}
IExtractArtifactDialog dialog = showDialog(treeComponent, initialName);
if (dialog == null)
return;
final Project project = myArtifactEditor.getContext().getProject();
final ModifiableArtifactModel model = myArtifactEditor.getContext().getOrCreateModifiableArtifactModel();
final ModifiableArtifact artifact = model.addArtifact(dialog.getArtifactName(), dialog.getArtifactType());
treeComponent.editLayout(() -> {
for (PackagingElement<?> element : selectedElements) {
artifact.getRootElement().addOrFindChild(ArtifactUtil.copyWithChildren(element, project));
}
for (PackagingElement element : selectedElements) {
parent.removeChild(element);
}
parent.addOrFindChild(new ArtifactPackagingElement(project, ArtifactPointerManager.getInstance(project).createPointer(artifact, myArtifactEditor.getContext().getArtifactModel())));
});
treeComponent.rebuildTree();
}
Aggregations