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);
}
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);
}
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);
}
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();
}
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);
}
Aggregations