Search in sources :

Example 1 with FileCopyPackagingElement

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

the class ExtractIntoDefaultLocationAction method actionPerformed.

@Override
public void actionPerformed(AnActionEvent e) {
    final String pathForClasses = myArtifactEditor.getArtifact().getArtifactType().getDefaultPathFor(PackagingElementOutputKind.DIRECTORIES_WITH_CLASSES);
    if (pathForClasses != null) {
        final List<PackagingElement<?>> extracted = new ArrayList<>();
        for (PackagingSourceItem item : mySourceItemsTree.getSelectedItems()) {
            final ArtifactEditorContext context = myArtifactEditor.getContext();
            final List<? extends PackagingElement<?>> elements = item.createElements(context);
            ArtifactUtil.processElementsWithSubstitutions(elements, context, context.getArtifactType(), PackagingElementPath.EMPTY, new PackagingElementProcessor<PackagingElement<?>>() {

                @Override
                public boolean process(@NotNull PackagingElement<?> element, @NotNull PackagingElementPath path) {
                    if (element instanceof FileCopyPackagingElement) {
                        final VirtualFile file = ((FileCopyPackagingElement) element).findFile();
                        if (file != null) {
                            final VirtualFile jarRoot = JarFileSystem.getInstance().getJarRootForLocalFile(file);
                            if (jarRoot != null) {
                                extracted.add(PackagingElementFactory.getInstance().createExtractedDirectory(jarRoot));
                            }
                        }
                    }
                    return true;
                }
            });
        }
        myArtifactEditor.getLayoutTreeComponent().putElements(pathForClasses, extracted);
    }
}
Also used : PackagingSourceItem(com.intellij.packaging.ui.PackagingSourceItem) VirtualFile(com.intellij.openapi.vfs.VirtualFile) ArrayList(java.util.ArrayList) FileCopyPackagingElement(com.intellij.packaging.impl.elements.FileCopyPackagingElement) PackagingElement(com.intellij.packaging.elements.PackagingElement) PackagingElementPath(com.intellij.packaging.impl.artifacts.PackagingElementPath) ArtifactEditorContext(com.intellij.packaging.ui.ArtifactEditorContext) FileCopyPackagingElement(com.intellij.packaging.impl.elements.FileCopyPackagingElement)

Example 2 with FileCopyPackagingElement

use of com.intellij.packaging.impl.elements.FileCopyPackagingElement in project intellij-plugins by JetBrains.

the class FlashBCOutputSourceItem method createElements.

@NotNull
public List<? extends PackagingElement<?>> createElements(@NotNull final ArtifactEditorContext context) {
    final String outputFilePath = myBc.getActualOutputFilePath();
    final String outputFolderPath = PathUtil.getParentPath(outputFilePath);
    switch(myType) {
        case OutputFile:
            return Collections.singletonList(new FileCopyPackagingElement(outputFilePath));
        case OutputFileAndHtmlWrapper:
            final List<PackagingElement<?>> result = new ArrayList<>();
            result.add(new FileCopyPackagingElement(outputFilePath));
            result.add(new FileCopyPackagingElement(outputFolderPath + "/" + BCUtils.getWrapperFileName(myBc)));
            final VirtualFile wrapperDir = LocalFileSystem.getInstance().findFileByPath(myBc.getWrapperTemplatePath());
            if (wrapperDir != null && wrapperDir.isDirectory()) {
                for (VirtualFile file : wrapperDir.getChildren()) {
                    if (!FlexCommonUtils.HTML_WRAPPER_TEMPLATE_FILE_NAME.equals(file.getName())) {
                        if (file.isDirectory()) {
                            final DirectoryCopyPackagingElement packagingElement = new DirectoryCopyPackagingElement(outputFolderPath + "/" + file.getName());
                            result.add(PackagingElementFactory.getInstance().createParentDirectories(file.getName(), packagingElement));
                        } else {
                            result.add(new FileCopyPackagingElement(outputFolderPath + "/" + file.getName()));
                        }
                    }
                }
            }
            return result;
        case OutputFolderContents:
            return Collections.singletonList(new DirectoryCopyPackagingElement(outputFolderPath));
        default:
            assert false;
            return Collections.emptyList();
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) ArrayList(java.util.ArrayList) FileCopyPackagingElement(com.intellij.packaging.impl.elements.FileCopyPackagingElement) PackagingElement(com.intellij.packaging.elements.PackagingElement) DirectoryCopyPackagingElement(com.intellij.packaging.impl.elements.DirectoryCopyPackagingElement) DirectoryCopyPackagingElement(com.intellij.packaging.impl.elements.DirectoryCopyPackagingElement) FileCopyPackagingElement(com.intellij.packaging.impl.elements.FileCopyPackagingElement) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

VirtualFile (com.intellij.openapi.vfs.VirtualFile)2 PackagingElement (com.intellij.packaging.elements.PackagingElement)2 FileCopyPackagingElement (com.intellij.packaging.impl.elements.FileCopyPackagingElement)2 ArrayList (java.util.ArrayList)2 PackagingElementPath (com.intellij.packaging.impl.artifacts.PackagingElementPath)1 DirectoryCopyPackagingElement (com.intellij.packaging.impl.elements.DirectoryCopyPackagingElement)1 ArtifactEditorContext (com.intellij.packaging.ui.ArtifactEditorContext)1 PackagingSourceItem (com.intellij.packaging.ui.PackagingSourceItem)1 NotNull (org.jetbrains.annotations.NotNull)1