Java 类com.intellij.openapi.fileTypes.INativeFileType 实例源码

项目:consulo    文件:NavigationUtil.java   
public static boolean openFileWithPsiElement(PsiElement element, boolean searchForOpen, boolean requestFocus) {
  boolean openAsNative = false;
  if (element instanceof PsiFile) {
    VirtualFile virtualFile = ((PsiFile)element).getVirtualFile();
    if (virtualFile != null) {
      openAsNative = virtualFile.getFileType() instanceof INativeFileType || virtualFile.getFileType() == UnknownFileType.INSTANCE;
    }
  }

  if (searchForOpen) {
    element.putUserData(FileEditorManager.USE_CURRENT_WINDOW, null);
  }
  else {
    element.putUserData(FileEditorManager.USE_CURRENT_WINDOW, true);
  }

  if (openAsNative || !activatePsiElementIfOpen(element, searchForOpen, requestFocus)) {
    final NavigationItem navigationItem = (NavigationItem)element;
    if (!navigationItem.canNavigate()) return false;
    navigationItem.navigate(requestFocus);
    return true;
  }

  element.putUserData(FileEditorManager.USE_CURRENT_WINDOW, null);
  return false;
}
项目:intellij-ce-playground    文件:OpenFileDescriptor.java   
private boolean navigateInEditorOrNativeApp(@NotNull Project project, boolean requestFocus) {
  FileType type = FileTypeManager.getInstance().getKnownFileTypeOrAssociate(myFile,project);
  if (type == null || !myFile.isValid()) return false;

  if (type instanceof INativeFileType) {
    return ((INativeFileType) type).openFileInAssociatedApplication(project, myFile);
  }

  return navigateInEditor(project, requestFocus);
}
项目:intellij-ce-playground    文件:AutoScrollToSourceHandler.java   
protected void scrollToSource(final Component tree) {
  DataContext dataContext=DataManager.getInstance().getDataContext(tree);
  getReady(dataContext).doWhenDone(new Runnable() {
    @Override
    public void run() {
      DataContext context = DataManager.getInstance().getDataContext(tree);
      final VirtualFile vFile = CommonDataKeys.VIRTUAL_FILE.getData(context);
      if (vFile != null) {
        // Attempt to navigate to the virtual file with unknown file type will show a modal dialog
        // asking to register some file type for this file. This behaviour is undesirable when autoscrolling.
        if (vFile.getFileType() == FileTypes.UNKNOWN || vFile.getFileType() instanceof INativeFileType) return;

        //IDEA-84881 Don't autoscroll to very large files
        if (vFile.getLength() > PersistentFSConstants.getMaxIntellisenseFileSize()) return;
      }
      Navigatable[] navigatables = CommonDataKeys.NAVIGATABLE_ARRAY.getData(context);
      if (navigatables != null) {
        if (navigatables.length > 1) {
          return;
        }
        for (Navigatable navigatable : navigatables) {
          // we are not going to open modal dialog during autoscrolling
          if (!navigatable.canNavigateToSource()) return;
        }
      }
      OpenSourceUtil.navigate(false, true, navigatables);
    }
  });
}
项目:tools-idea    文件:OpenFileDescriptor.java   
private boolean navigateInEditor(@NotNull Project project, boolean requestFocus) {
  FileType type = FileTypeManager.getInstance().getKnownFileTypeOrAssociate(myFile,project);
  if (type == null || !myFile.isValid()) return false;

  if (type instanceof INativeFileType) {
    return ((INativeFileType) type).openFileInAssociatedApplication(project, myFile);
  }

  return navigateInRequestedEditor() || navigateInAnyFileEditor(project, requestFocus);
}
项目:tools-idea    文件:AutoScrollToSourceHandler.java   
protected void scrollToSource(final Component tree) {
  DataContext dataContext=DataManager.getInstance().getDataContext(tree);
  getReady(dataContext).doWhenDone(new Runnable() {
    @Override
    public void run() {
      DataContext context = DataManager.getInstance().getDataContext(tree);
      final VirtualFile vFile = PlatformDataKeys.VIRTUAL_FILE.getData(context);
      if (vFile != null) {
        // Attempt to navigate to the virtual file with unknown file type will show a modal dialog
        // asking to register some file type for this file. This behaviour is undesirable when autoscrolling.
        if (vFile.getFileType() == FileTypes.UNKNOWN || vFile.getFileType() instanceof INativeFileType) return;

        //IDEA-84881 Don't autoscroll to very large files
        if (vFile.getLength() > PersistentFSConstants.getMaxIntellisenseFileSize()) return;
      }
      Navigatable[] navigatables = PlatformDataKeys.NAVIGATABLE_ARRAY.getData(context);
      if (navigatables != null) {
        if (navigatables.length > 1) {
          return;
        }
        for (Navigatable navigatable : navigatables) {
          // we are not going to open modal dialog during autoscrolling
          if (!navigatable.canNavigateToSource()) return;
        }
      }
      OpenSourceUtil.navigate(false, true, navigatables);
    }
  });
}
项目:consulo    文件:OpenFileDescriptor.java   
private boolean navigateInEditorOrNativeApp(@Nonnull Project project, boolean requestFocus) {
  FileType type = FileTypeManager.getInstance().getKnownFileTypeOrAssociate(myFile,project);
  if (type == null || !myFile.isValid()) return false;

  if (type instanceof INativeFileType) {
    return ((INativeFileType) type).openFileInAssociatedApplication(project, myFile);
  }

  return navigateInEditor(project, requestFocus);
}
项目:consulo    文件:AutoScrollToSourceHandler.java   
protected void scrollToSource(final Component tree) {
  DataContext dataContext=DataManager.getInstance().getDataContext(tree);
  getReady(dataContext).doWhenDone(new Runnable() {
    @Override
    public void run() {
      DataContext context = DataManager.getInstance().getDataContext(tree);
      final VirtualFile vFile = context.getData(PlatformDataKeys.VIRTUAL_FILE);
      if (vFile != null) {
        // Attempt to navigate to the virtual file with unknown file type will show a modal dialog
        // asking to register some file type for this file. This behaviour is undesirable when autoscrolling.
        if (vFile.getFileType() == UnknownFileType.INSTANCE || vFile.getFileType() instanceof INativeFileType) return;

        //IDEA-84881 Don't autoscroll to very large files
        if (vFile.getLength() > PersistentFSConstants.getMaxIntellisenseFileSize()) return;
      }
      Navigatable[] navigatables = context.getData(PlatformDataKeys.NAVIGATABLE_ARRAY);
      if (navigatables != null) {
        if (navigatables.length > 1) {
          return;
        }
        for (Navigatable navigatable : navigatables) {
          // we are not going to open modal dialog during autoscrolling
          if (!navigatable.canNavigateToSource()) return;
        }
      }
      OpenSourceUtil.openSourcesFrom(context, false);
    }
  });
}
项目:intellij-ce-playground    文件:ElementBase.java   
public static boolean isNativeFileType(FileType fileType) {
  return fileType instanceof INativeFileType && ((INativeFileType) fileType).useNativeIcon() || fileType instanceof UnknownFileType;
}
项目:intellij-ce-playground    文件:NativeIconProvider.java   
protected boolean isNativeFileType(VirtualFile file) {
  FileType type = file.getFileType();

  if (type instanceof INativeFileType) return ((INativeFileType)type).useNativeIcon();
  return type instanceof UnknownFileType && !file.isDirectory();
}
项目:tools-idea    文件:ElementBase.java   
public static boolean isNativeFileType(FileType fileType) {
  return fileType instanceof INativeFileType && ((INativeFileType) fileType).useNativeIcon() || fileType instanceof UnknownFileType;
}
项目:ali-idea-plugin    文件:AttachmentOpenAction.java   
public static void openAttachment(final Project project, String name, EntityRef parent, int size) {
    try {
        final File file;
        boolean agmLink = name.endsWith(".agmlink");
        if (agmLink) {
            // for the file to open correctly, there must be no trailing extension
            file = File.createTempFile("tmp", "_" + name.replaceFirst("\\.agmlink$", ""));
        } else {
            file = File.createTempFile("tmp", "_" + name);
        }
        final Runnable openFile = new Runnable() {
            @Override
            public void run() {
                String url = VirtualFileManager.constructUrl(LocalFileSystem.PROTOCOL, FileUtil.toSystemIndependentName(file.getAbsolutePath()));
                final VirtualFile virtualFile = VirtualFileManager.getInstance().refreshAndFindFileByUrl(url);
                UIUtil.invokeLaterIfNeeded(new Runnable() {
                    public void run() {
                        if(virtualFile != null) {
                            FileEditor[] editors = project.getComponent(FileEditorManager.class).openFile(virtualFile, true);
                            if(editors.length > 0) {
                                return;
                            }

                            FileType type = FileTypeManager.getInstance().getKnownFileTypeOrAssociate(virtualFile, project);
                            if (type instanceof INativeFileType && ((INativeFileType) type).openFileInAssociatedApplication(project, virtualFile)) {
                                return;
                            }
                        }
                        Messages.showWarningDialog("No editor seems to be associated with this file type. Try to download and open the file manually.", "Not Supported");
                    }
                });
            }
        };
        if (agmLink) {
            ProgressManager.getInstance().run(new AttachmentAgmLinkDownloadTask(project, file, name, size, parent, openFile));
        } else {
            ProgressManager.getInstance().run(new AttachmentDownloadTask(project, file, name, size, parent, openFile));
        }
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
}