use of com.intellij.openapi.roots.LibraryOrSdkOrderEntry 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.openapi.roots.LibraryOrSdkOrderEntry in project intellij-community by JetBrains.
the class PyTreeStructureProvider method getPythonSdk.
@Nullable
private static Sdk getPythonSdk(@NotNull AbstractTreeNode node) {
if (node instanceof NamedLibraryElementNode) {
final NamedLibraryElement value = ((NamedLibraryElementNode) node).getValue();
if (value != null) {
final LibraryOrSdkOrderEntry entry = value.getOrderEntry();
if (entry instanceof JdkOrderEntry) {
final Sdk sdk = ((JdkOrderEntry) entry).getJdk();
final SdkTypeId type = sdk.getSdkType();
if (type instanceof PythonSdkType) {
return sdk;
}
}
}
}
return null;
}
Aggregations