當前位置: 首頁>>代碼示例>>Java>>正文


Java FileEditorManager.getSelectedEditor方法代碼示例

本文整理匯總了Java中com.intellij.openapi.fileEditor.FileEditorManager.getSelectedEditor方法的典型用法代碼示例。如果您正苦於以下問題:Java FileEditorManager.getSelectedEditor方法的具體用法?Java FileEditorManager.getSelectedEditor怎麽用?Java FileEditorManager.getSelectedEditor使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.intellij.openapi.fileEditor.FileEditorManager的用法示例。


在下文中一共展示了FileEditorManager.getSelectedEditor方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: updateIndentNotification

import com.intellij.openapi.fileEditor.FileEditorManager; //導入方法依賴的package包/類
public static void updateIndentNotification(@NotNull PsiFile file, boolean enforce) {
  VirtualFile vFile = file.getVirtualFile();
  if (vFile == null) return;

  if (!ApplicationManager.getApplication().isHeadlessEnvironment()
      || ApplicationManager.getApplication().isUnitTestMode() && myShowNotificationInTest)
  {
    Project project = file.getProject();
    FileEditorManager fileEditorManager = FileEditorManager.getInstance(project);
    FileEditor fileEditor = fileEditorManager.getSelectedEditor(vFile);
    if (fileEditor != null) {
      Boolean notifiedFlag = fileEditor.getUserData(NOTIFIED_FLAG);
      if (notifiedFlag == null || enforce) {
        fileEditor.putUserData(NOTIFIED_FLAG, Boolean.TRUE);
        EditorNotifications.getInstance(project).updateNotifications(vFile);
      }
    }
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:20,代碼來源:DetectedIndentOptionsNotificationProvider.java

示例2: getCorrectContext

import com.intellij.openapi.fileEditor.FileEditorManager; //導入方法依賴的package包/類
private static DataContext getCorrectContext(DataContext dataContext) {
  if (PlatformDataKeys.FILE_EDITOR.getData(dataContext) != null) {
    return dataContext;
  }
  Project project = CommonDataKeys.PROJECT.getData(dataContext);
  if (project == null) {
    return dataContext;
  }
  FileEditorManager editorManager = FileEditorManager.getInstance(project);
  VirtualFile[] files = editorManager.getSelectedFiles();
  if (files.length == 0) {
    return dataContext;
  }
  FileEditor fileEditor = editorManager.getSelectedEditor(files[0]);
  return fileEditor == null ? dataContext : DataManager.getInstance().getDataContext(fileEditor.getComponent());
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:17,代碼來源:MacroManager.java

示例3: isOpenAndSelected

import com.intellij.openapi.fileEditor.FileEditorManager; //導入方法依賴的package包/類
private boolean isOpenAndSelected() {
  FileEditorManager editorManager = FileEditorManager.getInstance(myProject);
  FileEditor selectedEditor = editorManager.getSelectedEditor(myVirtualFile);
  if (selectedEditor != null) {
    JComponent component = selectedEditor.getComponent();
    if (component.isVisible() && component.isShowing()) {
      Document document = FileDocumentManager.getInstance().getDocument(myVirtualFile);
      if (document != null) {
        PsiFile psiFile = PsiDocumentManager.getInstance(myProject).getPsiFile(document);
        if (psiFile != null) {
          DaemonCodeAnalyzerEx codeAnalyzer = DaemonCodeAnalyzerEx.getInstanceEx(myProject);
          //noinspection ConstantConditions
          boolean isRunning = method("isRunning").withReturnType(boolean.class).in(codeAnalyzer).invoke();
          return !isRunning;
        }
      }
    }
  }
  return false;
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:21,代碼來源:FileFixture.java

示例4: actionPerformed

import com.intellij.openapi.fileEditor.FileEditorManager; //導入方法依賴的package包/類
@Override
public void actionPerformed(AnActionEvent e) {
  final DataContext context = e.getDataContext();
  final VirtualFile file = CommonDataKeys.VIRTUAL_FILE.getData(context);
  final Project project = e.getProject();
  if (file == null || project == null) {
    return;
  }
  final TaskFile taskFile = StudyUtils.getTaskFile(project, file);
  if (taskFile == null) {
    return;
  }
  Editor editor = CommonDataKeys.EDITOR.getData(context);
  if (editor == null) {
    FileEditorManager instance = FileEditorManager.getInstance(project);
    if (!instance.isFileOpen(file)) {
      return;
    }
    FileEditor fileEditor = instance.getSelectedEditor(file);
    if (!(fileEditor instanceof TextEditor)) {
      return;
    }
    editor = ((TextEditor)fileEditor).getEditor();
  }
  List<AnswerPlaceholder> placeholders = new ArrayList<>(taskFile.getAnswerPlaceholders());
  final ClearPlaceholders action = new ClearPlaceholders(taskFile, placeholders, editor);
  EduUtils.runUndoableAction(project, ACTION_NAME, action, UndoConfirmationPolicy.REQUEST_CONFIRMATION);
}
 
開發者ID:medvector,項目名稱:educational-plugin,代碼行數:29,代碼來源:CCDeleteAllAnswerPlaceholdersAction.java

示例5: actionPerformed

import com.intellij.openapi.fileEditor.FileEditorManager; //導入方法依賴的package包/類
@Override
public void actionPerformed(AnActionEvent e) {
  final DataContext context = e.getDataContext();
  final VirtualFile file = CommonDataKeys.VIRTUAL_FILE.getData(context);
  final Project project = e.getProject();
  if (file == null || project == null) {
    return;
  }
  final TaskFile taskFile = CCProjectService.getInstance(project).getTaskFile(file);
  if (taskFile == null) {
    return;
  }
  Editor editor = CommonDataKeys.EDITOR.getData(context);
  if (editor == null) {
    FileEditorManager instance = FileEditorManager.getInstance(project);
    if (!instance.isFileOpen(file)) {
      return;
    }
    FileEditor fileEditor = instance.getSelectedEditor(file);
    if (!(fileEditor instanceof TextEditor)) {
      return;
    }
    editor = ((TextEditor)fileEditor).getEditor();
  }
  List<AnswerPlaceholder> placeholders = new ArrayList<AnswerPlaceholder>(taskFile.getAnswerPlaceholders());
  final ClearPlaceholders action = new ClearPlaceholders(taskFile, placeholders, editor, file, project);
  new WriteCommandAction(project, ACTION_NAME) {
    protected void run(@NotNull final Result result) throws Throwable {
      action.redo();
      UndoManager.getInstance(project).undoableActionPerformed(action);
    }

    @Override
    protected UndoConfirmationPolicy getUndoConfirmationPolicy() {
      return UndoConfirmationPolicy.REQUEST_CONFIRMATION;
    }
  }.execute();
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:39,代碼來源:CCDeleteAllAnswerPlaceholdersAction.java


注:本文中的com.intellij.openapi.fileEditor.FileEditorManager.getSelectedEditor方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。