Search in sources :

Example 11 with Artifact

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

the class BuildArtifactAction method actionPerformed.

@Override
public void actionPerformed(AnActionEvent e) {
    final Project project = getEventProject(e);
    if (project == null)
        return;
    final List<Artifact> artifacts = ArtifactUtil.getArtifactWithOutputPaths(project);
    if (artifacts.isEmpty())
        return;
    List<ArtifactPopupItem> items = new ArrayList<>();
    if (artifacts.size() > 1) {
        items.add(0, new ArtifactPopupItem(null, "All Artifacts", EmptyIcon.ICON_16));
    }
    Set<Artifact> selectedArtifacts = new HashSet<>(ArtifactsWorkspaceSettings.getInstance(project).getArtifactsToBuild());
    TIntArrayList selectedIndices = new TIntArrayList();
    if (Comparing.haveEqualElements(artifacts, selectedArtifacts) && selectedArtifacts.size() > 1) {
        selectedIndices.add(0);
        selectedArtifacts.clear();
    }
    for (Artifact artifact : artifacts) {
        final ArtifactPopupItem item = new ArtifactPopupItem(artifact, artifact.getName(), artifact.getArtifactType().getIcon());
        if (selectedArtifacts.contains(artifact)) {
            selectedIndices.add(items.size());
        }
        items.add(item);
    }
    final ProjectSettingsService projectSettingsService = ProjectSettingsService.getInstance(project);
    final ArtifactAwareProjectSettingsService settingsService = projectSettingsService instanceof ArtifactAwareProjectSettingsService ? (ArtifactAwareProjectSettingsService) projectSettingsService : null;
    final ChooseArtifactStep step = new ChooseArtifactStep(items, artifacts.get(0), project, settingsService);
    step.setDefaultOptionIndices(selectedIndices.toNativeArray());
    final ListPopupImpl popup = (ListPopupImpl) JBPopupFactory.getInstance().createListPopup(step);
    final KeyStroke editKeyStroke = KeymapUtil.getKeyStroke(CommonShortcuts.getEditSource());
    if (settingsService != null && editKeyStroke != null) {
        popup.registerAction("editArtifact", editKeyStroke, new AbstractAction() {

            @Override
            public void actionPerformed(ActionEvent e) {
                Object[] values = popup.getSelectedValues();
                popup.cancel();
                settingsService.openArtifactSettings(values.length > 0 ? ((ArtifactPopupItem) values[0]).getArtifact() : null);
            }
        });
    }
    popup.showCenteredInCurrentWindow(project);
}
Also used : ActionEvent(java.awt.event.ActionEvent) AnActionEvent(com.intellij.openapi.actionSystem.AnActionEvent) TIntArrayList(gnu.trove.TIntArrayList) Artifact(com.intellij.packaging.artifacts.Artifact) TIntArrayList(gnu.trove.TIntArrayList) Project(com.intellij.openapi.project.Project) ListPopupImpl(com.intellij.ui.popup.list.ListPopupImpl) ProjectSettingsService(com.intellij.openapi.roots.ui.configuration.ProjectSettingsService)

Example 12 with Artifact

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

the class ArtifactDeploymentRuntimeProviderBase method createDeploymentRuntime.

@Override
public CloudDeploymentRuntime createDeploymentRuntime(DeploymentSource source, CloudMultiSourceServerRuntimeInstance serverRuntime, DeploymentTask<? extends CloudDeploymentNameConfiguration> deploymentTask, DeploymentLogManager logManager) throws ServerRuntimeException {
    if (!(source instanceof ArtifactDeploymentSource)) {
        return null;
    }
    ArtifactDeploymentSource artifactSource = (ArtifactDeploymentSource) source;
    Artifact artifact = artifactSource.getArtifact();
    if (artifact == null) {
        throw new ServerRuntimeException("Artifact not found " + artifactSource.getArtifactPointer().getArtifactName());
    }
    String artifactPath = artifact.getOutputFilePath();
    if (artifactPath == null) {
        throw new ServerRuntimeException("Artifact output not found");
    }
    return doCreateDeploymentRuntime(artifactSource, new File(artifactPath), serverRuntime, deploymentTask, logManager);
}
Also used : ArtifactDeploymentSource(com.intellij.remoteServer.configuration.deployment.ArtifactDeploymentSource) File(java.io.File) Artifact(com.intellij.packaging.artifacts.Artifact)

Example 13 with Artifact

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

the class PutSourceItemIntoParentAndLinkViaManifestAction method update.

@Override
public void update(AnActionEvent e) {
    final Presentation presentation = e.getPresentation();
    final Artifact artifact = myArtifactEditor.getArtifact();
    final ParentElementsInfo parentInfo = findParentAndGrandParent(artifact);
    if (parentInfo != null) {
        presentation.setText("Put Into '" + parentInfo.getGrandparentArtifact().getName() + "' and link via manifest");
    }
    boolean enable = parentInfo != null;
    boolean isProvideElements = false;
    for (PackagingSourceItem item : mySourceItemsTree.getSelectedItems()) {
        isProvideElements |= item.isProvideElements();
        if (!item.getKindOfProducedElements().containsJarFiles()) {
            enable = false;
            break;
        }
    }
    enable &= isProvideElements;
    presentation.setVisible(enable);
    presentation.setEnabled(enable);
}
Also used : PackagingSourceItem(com.intellij.packaging.ui.PackagingSourceItem) Presentation(com.intellij.openapi.actionSystem.Presentation) Artifact(com.intellij.packaging.artifacts.Artifact)

Example 14 with Artifact

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

the class InlineArtifactAction method actionPerformed.

@Override
public void actionPerformed(AnActionEvent e) {
    final LayoutTreeComponent treeComponent = myEditor.getLayoutTreeComponent();
    final LayoutTreeSelection selection = treeComponent.getSelection();
    final PackagingElement<?> element = selection.getElementIfSingle();
    final PackagingElementNode<?> node = selection.getNodeIfSingle();
    if (node == null || !(element instanceof ArtifactPackagingElement))
        return;
    final CompositePackagingElement<?> parent = node.getParentElement(element);
    final CompositePackagingElementNode parentNode = node.getParentNode();
    if (parent == null || parentNode == null) {
        return;
    }
    if (!treeComponent.checkCanModifyChildren(parent, parentNode, Collections.singletonList(node)))
        return;
    treeComponent.editLayout(() -> {
        parent.removeChild(element);
        final ArtifactEditorContext context = myEditor.getContext();
        final Artifact artifact = ((ArtifactPackagingElement) element).findArtifact(context);
        if (artifact != null) {
            final CompositePackagingElement<?> rootElement = artifact.getRootElement();
            if (rootElement instanceof ArtifactRootElement<?>) {
                for (PackagingElement<?> child : rootElement.getChildren()) {
                    parent.addOrFindChild(ArtifactUtil.copyWithChildren(child, context.getProject()));
                }
            } else {
                parent.addOrFindChild(ArtifactUtil.copyWithChildren(rootElement, context.getProject()));
            }
        }
    });
    treeComponent.rebuildTree();
}
Also used : LayoutTreeSelection(com.intellij.openapi.roots.ui.configuration.artifacts.LayoutTreeSelection) ArtifactPackagingElement(com.intellij.packaging.impl.elements.ArtifactPackagingElement) ArtifactRootElement(com.intellij.packaging.elements.ArtifactRootElement) CompositePackagingElementNode(com.intellij.openapi.roots.ui.configuration.artifacts.nodes.CompositePackagingElementNode) ArtifactEditorContext(com.intellij.packaging.ui.ArtifactEditorContext) Artifact(com.intellij.packaging.artifacts.Artifact) LayoutTreeComponent(com.intellij.openapi.roots.ui.configuration.artifacts.LayoutTreeComponent)

Example 15 with Artifact

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

the class ArtifactProjectStructureElement method check.

@Override
public void check(final ProjectStructureProblemsHolder problemsHolder) {
    final Artifact artifact = myArtifactsStructureContext.getArtifactModel().getArtifactByOriginal(myOriginalArtifact);
    final ArtifactProblemsHolderImpl artifactProblemsHolder = new ArtifactProblemsHolderImpl(myArtifactsStructureContext, myOriginalArtifact, problemsHolder);
    artifact.getArtifactType().checkRootElement(myArtifactsStructureContext.getRootElement(myOriginalArtifact), artifact, artifactProblemsHolder);
}
Also used : Artifact(com.intellij.packaging.artifacts.Artifact)

Aggregations

Artifact (com.intellij.packaging.artifacts.Artifact)52 ArrayList (java.util.ArrayList)13 Project (com.intellij.openapi.project.Project)11 VirtualFile (com.intellij.openapi.vfs.VirtualFile)8 Module (com.intellij.openapi.module.Module)7 NotNull (org.jetbrains.annotations.NotNull)6 ArtifactManager (com.intellij.packaging.artifacts.ArtifactManager)5 File (java.io.File)5 PackagingElement (com.intellij.packaging.elements.PackagingElement)4 ArtifactCompileScope (com.intellij.packaging.impl.compiler.ArtifactCompileScope)4 ArtifactPackagingElement (com.intellij.packaging.impl.elements.ArtifactPackagingElement)4 Nullable (org.jetbrains.annotations.Nullable)4 ArtifactType (com.intellij.packaging.artifacts.ArtifactType)3 PackagingElementPath (com.intellij.packaging.impl.artifacts.PackagingElementPath)3 ReadAction (com.intellij.openapi.application.ReadAction)2 Result (com.intellij.openapi.application.Result)2 Pair (com.intellij.openapi.util.Pair)2 ModifiableArtifactModel (com.intellij.packaging.artifacts.ModifiableArtifactModel)2 CompositePackagingElement (com.intellij.packaging.elements.CompositePackagingElement)2 PackagingElementFactory (com.intellij.packaging.elements.PackagingElementFactory)2