本文整理汇总了Java中com.intellij.openapi.fileChooser.FileElement.getFile方法的典型用法代码示例。如果您正苦于以下问题:Java FileElement.getFile方法的具体用法?Java FileElement.getFile怎么用?Java FileElement.getFile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.openapi.fileChooser.FileElement
的用法示例。
在下文中一共展示了FileElement.getFile方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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);
}
示例2: 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()]);
}
示例3: 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()]);
}
示例4: 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();
}
示例5: 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);
}
}
});
}
}
}
示例6: getParentElement
import com.intellij.openapi.fileChooser.FileElement; //导入方法依赖的package包/类
@Nullable
public Object getParentElement(Object element) {
if (element instanceof FileElement) {
final FileElement fileElement = (FileElement)element;
final VirtualFile elementFile = getValidFile(fileElement);
if (elementFile != null && myRootElement.getFile() != null && myRootElement.getFile().equals(elementFile)) {
return null;
}
final VirtualFile parentElementFile = getValidFile(fileElement.getParent());
if (elementFile != null && parentElementFile != null) {
final VirtualFile parentFile = elementFile.getParent();
if (parentElementFile.equals(parentFile)) return fileElement.getParent();
}
VirtualFile file = fileElement.getFile();
if (file == null) return null;
VirtualFile parent = file.getParent();
if (parent != null && parent.getFileSystem() instanceof JarFileSystem && parent.getParent() == null) {
// parent of jar contents should be local jar file
String localPath = parent.getPath().substring(0,
parent.getPath().length() - JarFileSystem.JAR_SEPARATOR.length());
parent = LocalFileSystem.getInstance().findFileByPath(localPath);
}
if (parent != null && parent.isValid() && parent.equals(myRootElement.getFile())) {
return myRootElement;
}
if (parent == null) {
return myRootElement;
}
return new FileElement(parent, parent.getName());
}
return null;
}
示例7: isAlwaysShowPlus
import com.intellij.openapi.fileChooser.FileElement; //导入方法依赖的package包/类
@Override
protected boolean isAlwaysShowPlus(NodeDescriptor nodeDescriptor) {
Object element = nodeDescriptor.getElement();
if (element != null) {
FileElement descriptor = (FileElement)element;
VirtualFile file = descriptor.getFile();
if (file != null) {
if (myChooserDescriptor.isChooseJarContents() && FileElement.isArchive(file)) {
return true;
}
return file.isDirectory();
}
}
return true;
}
示例8: isExcluded
import com.intellij.openapi.fileChooser.FileElement; //导入方法依赖的package包/类
private boolean isExcluded(FileElement fileElement) {
final VirtualFile file = fileElement.getFile();
if (file == null) {
return false;
}
return isExcluded(file);
}
示例9: 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.containsKey(virtualFile)) {
if (virtualFile instanceof NewVirtualFile) {
((NewVirtualFile)virtualFile).markDirty();
}
myEverExpanded.put(virtualFile, virtualFile);
}
AbstractTreeStructure treeStructure = myTreeBuilder.getTreeStructure();
boolean async = treeStructure != null && treeStructure.isToBuildChildrenInBackground(virtualFile);
if (virtualFile instanceof NewVirtualFile) {
RefreshQueue.getInstance().refresh(async, false, null, ModalityState.stateForComponent(myTree), virtualFile);
}
else {
virtualFile.refresh(async, false);
}
}
}
}
示例10: getParentElement
import com.intellij.openapi.fileChooser.FileElement; //导入方法依赖的package包/类
@Nullable
public Object getParentElement(Object element) {
if (element instanceof FileElement) {
final FileElement fileElement = (FileElement)element;
final VirtualFile elementFile = getValidFile(fileElement);
if (elementFile != null && myRootElement.getFile() != null && myRootElement.getFile().equals(elementFile)) {
return null;
}
final VirtualFile parentElementFile = getValidFile(fileElement.getParent());
if (elementFile != null && parentElementFile != null) {
final VirtualFile parentFile = elementFile.getParent();
if (parentElementFile.equals(parentFile)) return fileElement.getParent();
}
VirtualFile file = fileElement.getFile();
if (file == null) return null;
VirtualFile parent = file.getParent();
if (parent != null && parent.getFileSystem() instanceof JarFileSystem && parent.getParent() == null) {
// parent of jar contents should be local jar file
String localPath = parent.getPath().substring(0,
parent.getPath().length() - JarFileSystem.JAR_SEPARATOR.length());
parent = LocalFileSystem.getInstance().findFileByPath(localPath);
}
if (parent != null && parent.isValid() && parent.equals(myRootElement.getFile())) {
return myRootElement;
}
if (parent == null) {
return myRootElement;
}
return new FileElement(parent, parent.getName());
}
return null;
}
示例11: isAlwaysShowPlus
import com.intellij.openapi.fileChooser.FileElement; //导入方法依赖的package包/类
protected boolean isAlwaysShowPlus(NodeDescriptor nodeDescriptor) {
final Object element = nodeDescriptor.getElement();
if (element != null) {
FileElement descriptor = (FileElement)element;
VirtualFile file = descriptor.getFile();
if (file != null) {
if (myChooserDescriptor.isChooseJarContents() && FileElement.isArchive(file)) {
return true;
}
return file.isDirectory();
}
}
return true;
}
示例12: getSelectedFile
import com.intellij.openapi.fileChooser.FileElement; //导入方法依赖的package包/类
@Override
@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();
}
示例13: treeExpanded
import com.intellij.openapi.fileChooser.FileElement; //导入方法依赖的package包/类
@Override
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);
if (virtualFile instanceof NewVirtualFile) {
RefreshQueue.getInstance().refresh(async, false, null, ModalityState.stateForComponent(myTree), virtualFile);
}
else {
virtualFile.refresh(async, false);
}
}
}
}
示例14: getParentElement
import com.intellij.openapi.fileChooser.FileElement; //导入方法依赖的package包/类
@Override
@Nullable
public Object getParentElement(Object element) {
if (element instanceof FileElement) {
final FileElement fileElement = (FileElement)element;
final VirtualFile elementFile = getValidFile(fileElement);
if (elementFile != null && myRootElement.getFile() != null && myRootElement.getFile().equals(elementFile)) {
return null;
}
final VirtualFile parentElementFile = getValidFile(fileElement.getParent());
if (elementFile != null && parentElementFile != null) {
final VirtualFile parentFile = elementFile.getParent();
if (parentElementFile.equals(parentFile)) return fileElement.getParent();
}
VirtualFile file = fileElement.getFile();
if (file == null) return null;
VirtualFile parent = file.getParent();
if (parent != null && parent.getFileSystem() instanceof ArchiveFileSystem && parent.getParent() == null) {
// parent of jar contents should be local jar file
String localPath = parent.getPath().substring(0,
parent.getPath().length() - ArchiveFileSystem.ARCHIVE_SEPARATOR.length());
parent = LocalFileSystem.getInstance().findFileByPath(localPath);
}
if (parent != null && parent.isValid() && parent.equals(myRootElement.getFile())) {
return myRootElement;
}
if (parent == null) {
return myRootElement;
}
return new FileElement(parent, parent.getName());
}
return null;
}
示例15: getChildElements
import com.intellij.openapi.fileChooser.FileElement; //导入方法依赖的package包/类
public Object[] getChildElements(Object nodeElement) {
if (!(nodeElement instanceof FileElement)) {
return ArrayUtil.EMPTY_OBJECT_ARRAY;
}
FileElement element = (FileElement)nodeElement;
VirtualFile file = element.getFile();
if (file == null || !file.isValid()) {
if (element == myRootElement) {
return myRootElement.getChildren();
}
return ArrayUtil.EMPTY_OBJECT_ARRAY;
}
VirtualFile[] children = null;
if (element.isArchive() && myChooserDescriptor.isChooseJarContents()) {
String path = file.getPath();
if (!(file.getFileSystem() instanceof JarFileSystem)) {
file = JarFileSystem.getInstance().findFileByPath(path + JarFileSystem.JAR_SEPARATOR);
}
if (file != null) {
children = file.getChildren();
}
}
else {
children = file.getChildren();
}
if (children == null) {
return ArrayUtil.EMPTY_OBJECT_ARRAY;
}
Set<FileElement> childrenSet = new HashSet<FileElement>();
for (VirtualFile child : children) {
if (myChooserDescriptor.isFileVisible(child, myShowHidden)) {
final FileElement childElement = new FileElement(child, child.getName());
childElement.setParent(element);
childrenSet.add(childElement);
}
}
return ArrayUtil.toObjectArray(childrenSet);
}