use of com.intellij.packaging.elements.PackagingElement in project intellij-community by JetBrains.
the class LayoutTreeComponent method update.
@Override
public boolean update(DnDEvent aEvent) {
aEvent.setDropPossible(false);
aEvent.hideHighlighter();
final Object object = aEvent.getAttachedObject();
if (object instanceof PackagingElementDraggingObject) {
final DefaultMutableTreeNode parent = findParentCompositeElementNode(aEvent.getRelativePoint().getPoint(myTree));
if (parent != null) {
final PackagingElementDraggingObject draggingObject = (PackagingElementDraggingObject) object;
final PackagingElementNode node = getNode(parent);
if (node != null && draggingObject.canDropInto(node)) {
final PackagingElement element = node.getFirstElement();
if (element instanceof CompositePackagingElement) {
draggingObject.setTargetNode(node);
draggingObject.setTargetElement((CompositePackagingElement<?>) element);
final Rectangle bounds = myTree.getPathBounds(TreeUtil.getPathFromRoot(parent));
aEvent.setHighlighting(new RelativeRectangle(myTree, bounds), DnDEvent.DropTargetHighlightingType.RECTANGLE);
aEvent.setDropPossible(true);
}
}
}
}
return false;
}
use of com.intellij.packaging.elements.PackagingElement in project intellij-community by JetBrains.
the class LayoutTreeComponent method packInto.
public void packInto(@NotNull final List<? extends PackagingSourceItem> items, final String pathToJar) {
final List<PackagingElement<?>> toSelect = new ArrayList<>();
final CompositePackagingElement<?> rootElement = getArtifact().getRootElement();
editLayout(() -> {
final CompositePackagingElement<?> archive = PackagingElementFactory.getInstance().getOrCreateArchive(rootElement, pathToJar);
for (PackagingSourceItem item : items) {
final List<? extends PackagingElement<?>> elements = item.createElements(myContext);
archive.addOrFindChildren(elements);
}
toSelect.add(archive);
});
myArtifactsEditor.getSourceItemsTree().rebuildTree();
updateAndSelect(myTree.getRootPackagingNode(), toSelect);
}
use of com.intellij.packaging.elements.PackagingElement 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;
}
use of com.intellij.packaging.elements.PackagingElement 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);
}
}
use of com.intellij.packaging.elements.PackagingElement in project intellij-community by JetBrains.
the class ArtifactProjectStructureElement method getUsagesInElement.
@Override
public List<ProjectStructureElementUsage> getUsagesInElement() {
final Artifact artifact = myArtifactsStructureContext.getArtifactModel().getArtifactByOriginal(myOriginalArtifact);
final List<ProjectStructureElementUsage> usages = new ArrayList<>();
final CompositePackagingElement<?> rootElement = myArtifactsStructureContext.getRootElement(artifact);
ArtifactUtil.processPackagingElements(rootElement, null, new PackagingElementProcessor<PackagingElement<?>>() {
@Override
public boolean process(@NotNull PackagingElement<?> packagingElement, @NotNull PackagingElementPath path) {
ProjectStructureElement element = getProjectStructureElementFor(packagingElement, ArtifactProjectStructureElement.this.myContext, ArtifactProjectStructureElement.this.myArtifactsStructureContext);
if (element != null) {
usages.add(createUsage(packagingElement, element, path.getPathStringFrom("/", rootElement)));
}
return true;
}
}, myArtifactsStructureContext, false, artifact.getArtifactType());
return usages;
}
Aggregations