List of usage examples for com.intellij.openapi.fileChooser FileElement getFile
public final VirtualFile getFile()
From source file:com.perl5.lang.perl.idea.configuration.settings.sdk.PerlContentEntriesTreeEditor.java
License:Apache License
@NotNull
VirtualFile[] getSelectedFiles() {//ww w.j a v a 2s . c o m
final TreePath[] selectionPaths = myTree.getSelectionPaths();
if (selectionPaths == null) {
return VirtualFile.EMPTY_ARRAY;
}
final List<VirtualFile> selected = new ArrayList<>();
for (TreePath treePath : selectionPaths) {
final DefaultMutableTreeNode node = (DefaultMutableTreeNode) treePath.getLastPathComponent();
final Object nodeDescriptor = node.getUserObject();
if (!(nodeDescriptor instanceof FileNodeDescriptor)) {
return VirtualFile.EMPTY_ARRAY;
}
final FileElement fileElement = ((FileNodeDescriptor) nodeDescriptor).getElement();
final VirtualFile file = fileElement.getFile();
if (file != null) {
selected.add(file);
}
}
return selected.toArray(new VirtualFile[selected.size()]);
}
From source file:org.community.intellij.plugins.communitycase.history.browser.LogTreeFileSelectorRenderer.java
License:Apache License
@Override public void customizeCellRenderer(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) { super.customizeCellRenderer(tree, value, selected, expanded, leaf, row, hasFocus); if (value instanceof DefaultMutableTreeNode) { DefaultMutableTreeNode node = (DefaultMutableTreeNode) value; Object userObject = node.getUserObject(); if (userObject instanceof NodeDescriptor) { NodeDescriptor descriptor = (NodeDescriptor) userObject; Object element = descriptor.getElement(); if (element instanceof FileElement) { final FileElement fileElement = (FileElement) element; final VirtualFile file = fileElement.getFile(); if (myModules.contains(file)) { setIcon(expanded ? Icons.CONTENT_ROOT_ICON_OPEN : Icons.CONTENT_ROOT_ICON_CLOSED); }/*w ww . j av a 2 s . co m*/ } } } }