本文整理汇总了Java中com.intellij.openapi.fileChooser.FileElement类的典型用法代码示例。如果您正苦于以下问题:Java FileElement类的具体用法?Java FileElement怎么用?Java FileElement使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
FileElement类属于com.intellij.openapi.fileChooser包,在下文中一共展示了FileElement类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getChildren
import com.intellij.openapi.fileChooser.FileElement; //导入依赖的package包/类
public Object[] getChildren() {
if (myChildren == null) {
if (myFiles == null) {
myFiles = getFileSystemRoots();
}
List<FileElement> children = new ArrayList<FileElement>();
for (final VirtualFile file : myFiles) {
if (file != null) {
children.add(new FileElement(file, file.getPresentableUrl()));
}
}
myChildren = ArrayUtil.toObjectArray(children);
}
return myChildren;
}
示例2: getFileElementFor
import com.intellij.openapi.fileChooser.FileElement; //导入依赖的package包/类
@Nullable
private static FileElement getFileElementFor(@NotNull VirtualFile file) {
VirtualFile selectFile;
if ((file.getFileSystem() instanceof JarFileSystem) && file.getParent() == null) {
selectFile = JarFileSystem.getInstance().getVirtualFileForJar(file);
if (selectFile == null) {
return null;
}
}
else {
selectFile = file;
}
return new FileElement(selectFile, selectFile.getName());
}
示例3: collectSelectedElements
import com.intellij.openapi.fileChooser.FileElement; //导入依赖的package包/类
private <T> List<T> collectSelectedElements(final Function<FileElement, T> converter) {
final TreePath[] paths = myTree.getSelectionPaths();
if (paths == null) return Collections.emptyList();
final List<T> elements = ContainerUtil.newArrayList();
for (TreePath path : paths) {
final DefaultMutableTreeNode node = (DefaultMutableTreeNode)path.getLastPathComponent();
final Object userObject = node.getUserObject();
if (userObject instanceof FileNodeDescriptor) {
final T element = converter.fun(((FileNodeDescriptor)userObject).getElement());
if (element != null) {
elements.add(element);
}
}
}
return elements;
}
示例4: processSelectionChange
import com.intellij.openapi.fileChooser.FileElement; //导入依赖的package包/类
private void processSelectionChange() {
if (myListeners.size() == 0) return;
List<VirtualFile> selection = new ArrayList<VirtualFile>();
final TreePath[] paths = myTree.getSelectionPaths();
if (paths != null) {
for (TreePath each : paths) {
final Object last = each.getLastPathComponent();
if (last instanceof DefaultMutableTreeNode) {
final Object object = ((DefaultMutableTreeNode)last).getUserObject();
if (object instanceof FileNodeDescriptor) {
final FileElement element = ((FileNodeDescriptor)object).getElement();
final VirtualFile file = element.getFile();
if (file != null) {
selection.add(file);
}
}
}
}
}
fireSelection(selection);
}
示例5: customizeCellRenderer
import com.intellij.openapi.fileChooser.FileElement; //导入依赖的package包/类
@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);
final ContentEntryEditor editor = myTreeEditor.getContentEntryEditor();
if (editor != null) {
final Object userObject = ((DefaultMutableTreeNode)value).getUserObject();
if (userObject instanceof NodeDescriptor) {
final Object element = ((NodeDescriptor)userObject).getElement();
if (element instanceof FileElement) {
final VirtualFile file = ((FileElement)element).getFile();
if (file != null && file.isDirectory()) {
final ContentEntry contentEntry = editor.getContentEntry();
if (contentEntry != null) {
final String prefix = getPresentablePrefix(contentEntry, file);
if (!prefix.isEmpty()) {
append(" (" + prefix + ")", new SimpleTextAttributes(Font.PLAIN, JBColor.GRAY));
}
setIcon(updateIcon(contentEntry, file, getIcon()));
}
}
}
}
}
}
示例6: getSelectedFiles
import com.intellij.openapi.fileChooser.FileElement; //导入依赖的package包/类
@NotNull
protected final VirtualFile[] getSelectedFiles() {
final TreePath[] selectionPaths = myTree.getSelectionPaths();
if (selectionPaths == null) {
return VirtualFile.EMPTY_ARRAY;
}
final List<VirtualFile> selected = new ArrayList<VirtualFile>();
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()]);
}
示例7: customize
import com.intellij.openapi.fileChooser.FileElement; //导入依赖的package包/类
private boolean customize(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) {
if (!(value instanceof DefaultMutableTreeNode)) {
return false;
}
final DefaultMutableTreeNode node = (DefaultMutableTreeNode)value;
final Object userObject = node.getUserObject();
if (!(userObject instanceof NodeDescriptor)) {
return false;
}
final NodeDescriptor descriptor = (NodeDescriptor)userObject;
final Object element = descriptor.getElement();
if (!(element instanceof FileElement)) {
return false;
}
final FileElement fileElement = (FileElement)element;
if (!isExcluded(fileElement)) {
return false;
}
setIcon(IconLoader.getDisabledIcon(descriptor.getIcon()));
final String text = tree.convertValueToText(value, selected, expanded, leaf, row, hasFocus);
append(text, new SimpleTextAttributes(SimpleTextAttributes.STYLE_STRIKEOUT, tree.getForeground()));
return true;
}
示例8: customizeCellRenderer
import com.intellij.openapi.fileChooser.FileElement; //导入依赖的package包/类
@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);
final ContentEntryEditor editor = myTreeEditor.getContentEntryEditor();
if (editor != null) {
final Object userObject = ((DefaultMutableTreeNode)value).getUserObject();
if (userObject instanceof NodeDescriptor) {
final Object element = ((NodeDescriptor)userObject).getElement();
if (element instanceof FileElement) {
final VirtualFile file = ((FileElement)element).getFile();
if (file != null && file.isDirectory()) {
final ContentEntry contentEntry = editor.getContentEntry();
if (contentEntry != null) {
final String prefix = getPrefix(contentEntry, file);
if (!prefix.isEmpty()) {
append(" (" + prefix + ")", new SimpleTextAttributes(Font.PLAIN, JBColor.GRAY));
}
setIcon(updateIcon(contentEntry, file, getIcon()));
}
}
}
}
}
}
示例9: getFileElementFor
import com.intellij.openapi.fileChooser.FileElement; //导入依赖的package包/类
@Nullable
private static FileElement getFileElementFor(@Nonnull VirtualFile file) {
VirtualFile selectFile;
if ((file.getFileSystem() instanceof ArchiveFileSystem) && file.getParent() == null) {
selectFile = ArchiveVfsUtil.getVirtualFileForArchive(file);
if (selectFile == null) {
return null;
}
}
else {
selectFile = file;
}
return new FileElement(selectFile, selectFile.getName());
}
示例10: customizeCellRenderer
import com.intellij.openapi.fileChooser.FileElement; //导入依赖的package包/类
@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);
final ContentEntryEditor editor = myTreeEditor.getContentEntryEditor();
if (editor != null) {
final Object userObject = ((DefaultMutableTreeNode)value).getUserObject();
if (userObject instanceof NodeDescriptor) {
final Object element = ((NodeDescriptor)userObject).getElement();
if (element instanceof FileElement) {
final VirtualFile file = ((FileElement)element).getFile();
if (file != null && file.isDirectory()) {
final ContentEntry contentEntry = editor.getContentEntry();
if (contentEntry != null) {
setIcon(updateIcon(contentEntry, file, getIcon()));
}
}
}
}
}
}
示例11: getSelectedFiles
import com.intellij.openapi.fileChooser.FileElement; //导入依赖的package包/类
@Nonnull
protected final VirtualFile[] getSelectedFiles() {
final TreePath[] selectionPaths = myTree.getSelectionPaths();
if (selectionPaths == null) {
return VirtualFile.EMPTY_ARRAY;
}
final List<VirtualFile> selected = new ArrayList<VirtualFile>();
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()]);
}
示例12: FileNodeDescriptor
import com.intellij.openapi.fileChooser.FileElement; //导入依赖的package包/类
public FileNodeDescriptor(Project project,
@NotNull FileElement element,
NodeDescriptor parentDescriptor,
Icon closedIcon,
String name,
String comment) {
super(project, parentDescriptor);
myOriginalIcon = closedIcon;
myComment = comment;
myFileElement = element;
myName = name;
}
示例13: getSelectedFile
import com.intellij.openapi.fileChooser.FileElement; //导入依赖的package包/类
@Nullable
public VirtualFile getSelectedFile() {
final TreePath path = myTree.getSelectionPath();
if (path == null) return null;
final DefaultMutableTreeNode node = (DefaultMutableTreeNode)path.getLastPathComponent();
if (!(node.getUserObject() instanceof FileNodeDescriptor)) return null;
final FileElement element = ((FileNodeDescriptor)node.getUserObject()).getElement();
return element.getFile();
}
示例14: getSelectedFiles
import com.intellij.openapi.fileChooser.FileElement; //导入依赖的package包/类
@NotNull
public VirtualFile[] getSelectedFiles() {
final List<VirtualFile> files = collectSelectedElements(new NullableFunction<FileElement, VirtualFile>() {
@Override
public VirtualFile fun(final FileElement element) {
final VirtualFile file = element.getFile();
return file != null && file.isValid() ? file : null;
}
});
return VfsUtilCore.toVirtualFileArray(files);
}
示例15: treeExpanded
import com.intellij.openapi.fileChooser.FileElement; //导入依赖的package包/类
public void treeExpanded(final TreeExpansionEvent event) {
if (myTreeBuilder == null || !myTreeBuilder.isNodeBeingBuilt(event.getPath())) return;
TreePath path = event.getPath();
DefaultMutableTreeNode node = (DefaultMutableTreeNode)path.getLastPathComponent();
if (node.getUserObject() instanceof FileNodeDescriptor) {
FileNodeDescriptor nodeDescriptor = (FileNodeDescriptor)node.getUserObject();
final FileElement fileDescriptor = nodeDescriptor.getElement();
final VirtualFile virtualFile = fileDescriptor.getFile();
if (virtualFile != null) {
if (!myEverExpanded.contains(virtualFile)) {
if (virtualFile instanceof NewVirtualFile) {
((NewVirtualFile)virtualFile).markDirty();
}
myEverExpanded.add(virtualFile);
}
AbstractTreeStructure treeStructure = myTreeBuilder.getTreeStructure();
final boolean async = treeStructure != null && treeStructure.isToBuildChildrenInBackground(virtualFile);
DumbService.allowStartingDumbModeInside(DumbModePermission.MAY_START_MODAL, new Runnable() {
@Override
public void run() {
if (virtualFile instanceof NewVirtualFile) {
RefreshQueue.getInstance().refresh(async, false, null, ModalityState.stateForComponent(myTree), virtualFile);
}
else {
virtualFile.refresh(async, false);
}
}
});
}
}
}