ProjectStructureElement () { final List<SourceItemNode> nodes = myTree.getSelectedSourceItemNodes(); if (nodes.size() != 1) return null; SourceItemNode node = nodes.get(0); if (node == null) { return null; } PackagingSourceItem sourceItem = 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; }