Search in sources :

Example 1 with PackagingElementFactory

use of com.intellij.packaging.elements.PackagingElementFactory in project intellij-community by JetBrains.

the class ExtractedDirectoryElementType method chooseAndCreate.

@NotNull
public List<? extends PackagingElement<?>> chooseAndCreate(@NotNull ArtifactEditorContext context, @NotNull Artifact artifact, @NotNull CompositePackagingElement<?> parent) {
    final FileChooserDescriptor descriptor = new FileChooserDescriptor(false, true, true, false, true, true) {

        @Override
        public boolean isFileSelectable(VirtualFile file) {
            if (file.isInLocalFileSystem() && file.isDirectory())
                return false;
            return super.isFileSelectable(file);
        }
    };
    final VirtualFile[] files = FileChooser.chooseFiles(descriptor, context.getProject(), null);
    final List<PackagingElement<?>> list = new ArrayList<>();
    final PackagingElementFactory factory = PackagingElementFactory.getInstance();
    for (VirtualFile file : files) {
        list.add(factory.createExtractedDirectory(file));
    }
    return list;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) FileChooserDescriptor(com.intellij.openapi.fileChooser.FileChooserDescriptor) ArrayList(java.util.ArrayList) PackagingElement(com.intellij.packaging.elements.PackagingElement) CompositePackagingElement(com.intellij.packaging.elements.CompositePackagingElement) PackagingElementFactory(com.intellij.packaging.elements.PackagingElementFactory) NotNull(org.jetbrains.annotations.NotNull)

Example 2 with PackagingElementFactory

use of com.intellij.packaging.elements.PackagingElementFactory 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 PackagingElementFactory

use of com.intellij.packaging.elements.PackagingElementFactory 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)

Example 4 with PackagingElementFactory

use of com.intellij.packaging.elements.PackagingElementFactory in project google-cloud-intellij by GoogleCloudPlatform.

the class AppEngineStandardSupportProvider method findOrCreateWebArtifact.

@NotNull
static Artifact findOrCreateWebArtifact(AppEngineStandardFacet appEngineStandardFacet) {
    Module module = appEngineStandardFacet.getModule();
    ArtifactType webArtifactType = AppEngineStandardWebIntegration.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)

Aggregations

PackagingElementFactory (com.intellij.packaging.elements.PackagingElementFactory)4 NotNull (org.jetbrains.annotations.NotNull)4 Module (com.intellij.openapi.module.Module)3 Artifact (com.intellij.packaging.artifacts.Artifact)3 ArtifactType (com.intellij.packaging.artifacts.ArtifactType)3 ArtifactManager (com.intellij.packaging.artifacts.ArtifactManager)2 PackagingElement (com.intellij.packaging.elements.PackagingElement)2 ArrayList (java.util.ArrayList)2 FileChooserDescriptor (com.intellij.openapi.fileChooser.FileChooserDescriptor)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 CompositePackagingElement (com.intellij.packaging.elements.CompositePackagingElement)1 LinkedHashSet (java.util.LinkedHashSet)1