Search in sources :

Example 1 with ArtifactsTreeNode

use of com.intellij.openapi.roots.ui.configuration.artifacts.nodes.ArtifactsTreeNode in project intellij-community by JetBrains.

the class SourceItemFindUsagesAction method getSelectedElement.

@Override
protected ProjectStructureElement getSelectedElement() {
    final List<SourceItemNode> nodes = myTree.getSelectedSourceItemNodes();
    if (nodes.size() != 1)
        return null;
    ArtifactsTreeNode node = nodes.get(0);
    if (!(node instanceof SourceItemNode)) {
        return null;
    }
    PackagingSourceItem sourceItem = ((SourceItemNode) node).getSourceItem();
    if (sourceItem == null)
        return null;
    final StructureConfigurableContext context = getContext();
    if (sourceItem instanceof ModuleOutputSourceItem) {
        return new ModuleProjectStructureElement(context, ((ModuleOutputSourceItem) sourceItem).getModule());
    } else if (sourceItem instanceof LibrarySourceItem) {
        return new LibraryProjectStructureElement(context, ((LibrarySourceItem) sourceItem).getLibrary());
    } else if (sourceItem instanceof ArtifactSourceItem) {
        return myArtifactContext.getOrCreateArtifactElement(((ArtifactSourceItem) sourceItem).getArtifact());
    }
    return null;
}
Also used : PackagingSourceItem(com.intellij.packaging.ui.PackagingSourceItem) ModuleProjectStructureElement(com.intellij.openapi.roots.ui.configuration.projectRoot.daemon.ModuleProjectStructureElement) StructureConfigurableContext(com.intellij.openapi.roots.ui.configuration.projectRoot.StructureConfigurableContext) ArtifactsStructureConfigurableContext(com.intellij.openapi.roots.ui.configuration.artifacts.ArtifactsStructureConfigurableContext) ArtifactsTreeNode(com.intellij.openapi.roots.ui.configuration.artifacts.nodes.ArtifactsTreeNode) LibraryProjectStructureElement(com.intellij.openapi.roots.ui.configuration.projectRoot.daemon.LibraryProjectStructureElement)

Aggregations

ArtifactsStructureConfigurableContext (com.intellij.openapi.roots.ui.configuration.artifacts.ArtifactsStructureConfigurableContext)1 ArtifactsTreeNode (com.intellij.openapi.roots.ui.configuration.artifacts.nodes.ArtifactsTreeNode)1 StructureConfigurableContext (com.intellij.openapi.roots.ui.configuration.projectRoot.StructureConfigurableContext)1 LibraryProjectStructureElement (com.intellij.openapi.roots.ui.configuration.projectRoot.daemon.LibraryProjectStructureElement)1 ModuleProjectStructureElement (com.intellij.openapi.roots.ui.configuration.projectRoot.daemon.ModuleProjectStructureElement)1 PackagingSourceItem (com.intellij.packaging.ui.PackagingSourceItem)1