Search in sources :

Example 1 with ArtifactType

use of com.intellij.packaging.artifacts.ArtifactType in project intellij-community by JetBrains.

the class ArtifactConfigurable method createTopRightComponent.

@Override
protected JComponent createTopRightComponent() {
    final ComboBox artifactTypeBox = new ComboBox();
    for (ArtifactType type : ArtifactType.getAllTypes()) {
        artifactTypeBox.addItem(type);
    }
    artifactTypeBox.setRenderer(new ArtifactTypeCellRenderer(artifactTypeBox.getRenderer()));
    artifactTypeBox.setSelectedItem(getArtifact().getArtifactType());
    artifactTypeBox.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            final ArtifactType selected = (ArtifactType) artifactTypeBox.getSelectedItem();
            if (selected != null && !Comparing.equal(selected, getArtifact().getArtifactType())) {
                getEditor().setArtifactType(selected);
            }
        }
    });
    final JPanel panel = new JPanel(new FlowLayout());
    panel.add(new JLabel("Type: "));
    panel.add(artifactTypeBox);
    return panel;
}
Also used : ActionListener(java.awt.event.ActionListener) ComboBox(com.intellij.openapi.ui.ComboBox) ArtifactType(com.intellij.packaging.artifacts.ArtifactType) ActionEvent(java.awt.event.ActionEvent)

Example 2 with ArtifactType

use of com.intellij.packaging.artifacts.ArtifactType in project intellij-community by JetBrains.

the class AppEngineSupportProvider method findOrCreateWebArtifact.

@NotNull
private static Artifact findOrCreateWebArtifact(AppEngineFacet appEngineFacet) {
    Module module = appEngineFacet.getModule();
    ArtifactType webArtifactType = AppEngineWebIntegration.getInstance().getAppEngineWebArtifactType();
    final Collection<Artifact> artifacts = ArtifactUtil.getArtifactsContainingModuleOutput(module);
    for (Artifact artifact : artifacts) {
        if (webArtifactType.equals(artifact.getArtifactType())) {
            return artifact;
        }
    }
    ArtifactManager artifactManager = ArtifactManager.getInstance(module.getProject());
    PackagingElementFactory elementFactory = PackagingElementFactory.getInstance();
    ArtifactRootElement<?> root = elementFactory.createArtifactRootElement();
    elementFactory.getOrCreateDirectory(root, "WEB-INF/classes").addOrFindChild(elementFactory.createModuleOutput(module));
    return artifactManager.addArtifact(module.getName(), webArtifactType, root);
}
Also used : ArtifactManager(com.intellij.packaging.artifacts.ArtifactManager) ArtifactType(com.intellij.packaging.artifacts.ArtifactType) PackagingElementFactory(com.intellij.packaging.elements.PackagingElementFactory) Module(com.intellij.openapi.module.Module) Artifact(com.intellij.packaging.artifacts.Artifact) NotNull(org.jetbrains.annotations.NotNull)

Example 3 with ArtifactType

use of com.intellij.packaging.artifacts.ArtifactType in project intellij-community by JetBrains.

the class ArtifactPackagingElement method getSubstitution.

public List<? extends PackagingElement<?>> getSubstitution(@NotNull PackagingElementResolvingContext context, @NotNull ArtifactType artifactType) {
    final Artifact artifact = findArtifact(context);
    if (artifact != null) {
        final ArtifactType type = artifact.getArtifactType();
        List<? extends PackagingElement<?>> substitution = type.getSubstitution(artifact, context, artifactType);
        if (substitution != null) {
            return substitution;
        }
        final List<PackagingElement<?>> elements = new ArrayList<>();
        final CompositePackagingElement<?> rootElement = artifact.getRootElement();
        if (rootElement instanceof ArtifactRootElement<?>) {
            elements.addAll(rootElement.getChildren());
        } else {
            elements.add(rootElement);
        }
        return elements;
    }
    return null;
}
Also used : ArtifactType(com.intellij.packaging.artifacts.ArtifactType) ArrayList(java.util.ArrayList) Artifact(com.intellij.packaging.artifacts.Artifact)

Example 4 with ArtifactType

use of com.intellij.packaging.artifacts.ArtifactType in project intellij-community by JetBrains.

the class LayoutTreeComponent method putIntoDefaultLocations.

public void putIntoDefaultLocations(@NotNull final List<? extends PackagingSourceItem> items) {
    final List<PackagingElement<?>> toSelect = new ArrayList<>();
    editLayout(() -> {
        final CompositePackagingElement<?> rootElement = getArtifact().getRootElement();
        final ArtifactType artifactType = getArtifact().getArtifactType();
        for (PackagingSourceItem item : items) {
            final String path = artifactType.getDefaultPathFor(item);
            if (path != null) {
                final CompositePackagingElement<?> parent;
                if (path.endsWith(URLUtil.JAR_SEPARATOR)) {
                    parent = PackagingElementFactory.getInstance().getOrCreateArchive(rootElement, StringUtil.trimEnd(path, URLUtil.JAR_SEPARATOR));
                } else {
                    parent = PackagingElementFactory.getInstance().getOrCreateDirectory(rootElement, path);
                }
                final List<? extends PackagingElement<?>> elements = item.createElements(myContext);
                toSelect.addAll(parent.addOrFindChildren(elements));
            }
        }
    });
    myArtifactsEditor.getSourceItemsTree().rebuildTree();
    updateAndSelect(myTree.getRootPackagingNode(), toSelect);
}
Also used : PackagingSourceItem(com.intellij.packaging.ui.PackagingSourceItem) ArtifactType(com.intellij.packaging.artifacts.ArtifactType) PackagingElement(com.intellij.packaging.elements.PackagingElement) DirectoryPackagingElement(com.intellij.packaging.impl.elements.DirectoryPackagingElement) CompositePackagingElement(com.intellij.packaging.elements.CompositePackagingElement)

Example 5 with ArtifactType

use of com.intellij.packaging.artifacts.ArtifactType in project intellij-community by JetBrains.

the class ModuleSourceItemGroup method createElements.

@Override
@NotNull
public List<? extends PackagingElement<?>> createElements(@NotNull ArtifactEditorContext context) {
    final Set<Module> modules = new LinkedHashSet<>();
    collectDependentModules(myModule, modules, context);
    final Artifact artifact = context.getArtifact();
    final ArtifactType artifactType = artifact.getArtifactType();
    Set<PackagingSourceItem> items = new LinkedHashSet<>();
    for (Module module : modules) {
        for (PackagingSourceItemsProvider provider : PackagingSourceItemsProvider.EP_NAME.getExtensions()) {
            final ModuleSourceItemGroup parent = new ModuleSourceItemGroup(module);
            for (PackagingSourceItem sourceItem : provider.getSourceItems(context, artifact, parent)) {
                if (artifactType.isSuitableItem(sourceItem) && sourceItem.isProvideElements()) {
                    items.add(sourceItem);
                }
            }
        }
    }
    List<PackagingElement<?>> result = new ArrayList<>();
    final PackagingElementFactory factory = PackagingElementFactory.getInstance();
    for (PackagingSourceItem item : items) {
        final String path = artifactType.getDefaultPathFor(item.getKindOfProducedElements());
        if (path != null) {
            result.addAll(factory.createParentDirectories(path, item.createElements(context)));
        }
    }
    return result;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) ArrayList(java.util.ArrayList) PackagingElement(com.intellij.packaging.elements.PackagingElement) Artifact(com.intellij.packaging.artifacts.Artifact) ArtifactType(com.intellij.packaging.artifacts.ArtifactType) PackagingElementFactory(com.intellij.packaging.elements.PackagingElementFactory) Module(com.intellij.openapi.module.Module) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

ArtifactType (com.intellij.packaging.artifacts.ArtifactType)8 Artifact (com.intellij.packaging.artifacts.Artifact)4 Module (com.intellij.openapi.module.Module)3 PackagingElementFactory (com.intellij.packaging.elements.PackagingElementFactory)3 NotNull (org.jetbrains.annotations.NotNull)3 ArtifactManager (com.intellij.packaging.artifacts.ArtifactManager)2 PackagingElement (com.intellij.packaging.elements.PackagingElement)2 ArrayList (java.util.ArrayList)2 ComboBox (com.intellij.openapi.ui.ComboBox)1 CompositePackagingElement (com.intellij.packaging.elements.CompositePackagingElement)1 DirectoryPackagingElement (com.intellij.packaging.impl.elements.DirectoryPackagingElement)1 PackagingSourceItem (com.intellij.packaging.ui.PackagingSourceItem)1 ActionEvent (java.awt.event.ActionEvent)1 ActionListener (java.awt.event.ActionListener)1 LinkedHashSet (java.util.LinkedHashSet)1