本文整理汇总了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());
}
示例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;
}
示例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);
}
示例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();
}