use of com.intellij.ide.projectView.impl.nodes.NamedLibraryElement in project android by JetBrains.
the class AndroidTreeStructureProvider method modify.
@Override
@NotNull
public Collection<AbstractTreeNode> modify(@NotNull AbstractTreeNode parent, @NotNull Collection<AbstractTreeNode> children, ViewSettings settings) {
Project project = parent.getProject();
if (project != null && AndroidProjectInfo.getInstance(project).requiresAndroidModel()) {
if (parent instanceof NamedLibraryElementNode) {
NamedLibraryElement value = ((NamedLibraryElementNode) parent).getValue();
LibraryOrSdkOrderEntry orderEntry = value.getOrderEntry();
if (orderEntry instanceof JdkOrderEntry) {
Sdk sdk = ((JdkOrderEntry) orderEntry).getJdk();
if (sdk.getSdkType() instanceof JavaSdk) {
List<AbstractTreeNode> newChildren = Lists.newArrayList();
for (AbstractTreeNode child : children) {
if (isRtJar(child)) {
newChildren.add(child);
}
}
if (!newChildren.isEmpty()) {
myEventDispatcher.getMulticaster().nodeChanged(parent, newChildren);
return newChildren;
}
}
}
} else if (isRtJar(parent)) {
List<AbstractTreeNode> newChildren = Lists.newArrayList();
for (AbstractTreeNode child : children) {
if (child instanceof PsiDirectoryNode) {
VirtualFile file = ((PsiDirectoryNode) child).getVirtualFile();
if (file != null && ("java".equals(file.getName()) || "javax".equals(file.getName()))) {
newChildren.add(child);
}
}
}
if (!newChildren.isEmpty()) {
myEventDispatcher.getMulticaster().nodeChanged(parent, newChildren);
return newChildren;
}
}
}
return children;
}
use of com.intellij.ide.projectView.impl.nodes.NamedLibraryElement in project intellij-plugins by JetBrains.
the class FlexCompositeSdkProjectViewStructureProvider method modify.
@NotNull
@Override
public Collection<AbstractTreeNode> modify(@NotNull final AbstractTreeNode parent, @NotNull final Collection<AbstractTreeNode> children, final ViewSettings settings) {
if (!(parent instanceof ExternalLibrariesNode)) {
return children;
}
Set<Sdk> processedSdks = new HashSet<>();
Collection<AbstractTreeNode> result = new ArrayList<>();
for (AbstractTreeNode child : children) {
Object value = child.getValue();
if (!(value instanceof NamedLibraryElement)) {
result.add(child);
continue;
}
NamedLibraryElement libraryElement = (NamedLibraryElement) value;
OrderEntry orderEntry = libraryElement.getOrderEntry();
if (!(orderEntry instanceof JdkOrderEntry)) {
result.add(child);
continue;
}
Sdk sdk = ((JdkOrderEntry) orderEntry).getJdk();
if (!(sdk instanceof FlexCompositeSdk)) {
result.add(child);
continue;
}
Sdk[] sdks = ((FlexCompositeSdk) sdk).getSdks();
for (Sdk individualSdk : sdks) {
if (processedSdks.add(individualSdk)) {
IndividualSdkOrderEntry entry = new IndividualSdkOrderEntry(individualSdk, orderEntry.getOwnerModule());
result.add(new NamedLibraryElementNode(parent.getProject(), new NamedLibraryElement(null, entry), ((ExternalLibrariesNode) parent).getSettings()));
}
}
}
return result;
}
Aggregations