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