Search in sources :

Example 1 with ModifiableArtifact

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);
}
Also used : ModifiableArtifact(com.intellij.packaging.artifacts.ModifiableArtifact)

Example 2 with ModifiableArtifact

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();
}
Also used : ModifiableArtifact(com.intellij.packaging.artifacts.ModifiableArtifact)

Example 3 with ModifiableArtifact

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();
}
Also used : LayoutTreeSelection(com.intellij.openapi.roots.ui.configuration.artifacts.LayoutTreeSelection) ArtifactPackagingElement(com.intellij.packaging.impl.elements.ArtifactPackagingElement) ModifiableArtifact(com.intellij.packaging.artifacts.ModifiableArtifact) ArtifactPackagingElement(com.intellij.packaging.impl.elements.ArtifactPackagingElement) PackagingElement(com.intellij.packaging.elements.PackagingElement) CompositePackagingElement(com.intellij.packaging.elements.CompositePackagingElement) LayoutTreeComponent(com.intellij.openapi.roots.ui.configuration.artifacts.LayoutTreeComponent) Project(com.intellij.openapi.project.Project) ModifiableArtifactModel(com.intellij.packaging.artifacts.ModifiableArtifactModel)

Aggregations

ModifiableArtifact (com.intellij.packaging.artifacts.ModifiableArtifact)3 Project (com.intellij.openapi.project.Project)1 LayoutTreeComponent (com.intellij.openapi.roots.ui.configuration.artifacts.LayoutTreeComponent)1 LayoutTreeSelection (com.intellij.openapi.roots.ui.configuration.artifacts.LayoutTreeSelection)1 ModifiableArtifactModel (com.intellij.packaging.artifacts.ModifiableArtifactModel)1 CompositePackagingElement (com.intellij.packaging.elements.CompositePackagingElement)1 PackagingElement (com.intellij.packaging.elements.PackagingElement)1 ArtifactPackagingElement (com.intellij.packaging.impl.elements.ArtifactPackagingElement)1