List of usage examples for com.intellij.openapi.fileEditor FileEditorManager getOpenFiles
public abstract VirtualFile @NotNull [] getOpenFiles();
From source file:com.intellij.codeInsight.CodeInsightTestCase.java
License:Apache License
@Override protected void tearDown() throws Exception { FileEditorManager editorManager = FileEditorManager.getInstance(myProject); VirtualFile[] openFiles = editorManager.getOpenFiles(); for (VirtualFile openFile : openFiles) { editorManager.closeFile(openFile); }/*from www. j a v a2s .c o m*/ myEditor = null; super.tearDown(); }
From source file:com.intellij.ide.favoritesTreeView.actions.AddAllOpenFilesToFavorites.java
License:Apache License
static ArrayList<PsiFile> getFilesToAdd(Project project) { ArrayList<PsiFile> result = new ArrayList<PsiFile>(); final FileEditorManager editorManager = FileEditorManager.getInstance(project); final PsiManager psiManager = PsiManager.getInstance(project); final VirtualFile[] openFiles = editorManager.getOpenFiles(); for (VirtualFile openFile : openFiles) { if (!openFile.isValid()) continue; final PsiFile psiFile = psiManager.findFile(openFile); if (psiFile != null) { result.add(psiFile);/* ww w.j av a 2 s .c om*/ } } return result; }
From source file:com.intellij.lang.jsgraphql.ide.project.JSGraphQLLanguageUIProjectService.java
License:Open Source License
public JSGraphQLLanguageUIProjectService(@NotNull final Project project) { myProject = project;// w w w.ja v a2s . c o m final MessageBusConnection messageBusConnection = project.getMessageBus().connect(this); // the restart action final AnAction restartInstanceAction = ActionManager.getInstance() .getAction(JSGraphQLRestartLanguageServiceAction.class.getName()); // tool window myToolWindowManager = new JSGraphQLLanguageToolWindowManager(project, GRAPH_QL_TOOL_WINDOW_NAME, GRAPH_QL_TOOL_WINDOW_NAME, JSGraphQLIcons.UI.GraphQLNode, restartInstanceAction); Disposer.register(this, this.myToolWindowManager); // listen for editor file tab changes to update the list of current errors messageBusConnection.subscribe(FileEditorManagerListener.FILE_EDITOR_MANAGER, this); // add editor headers to already open files since we've only just added the listener for fileOpened() final FileEditorManager fileEditorManager = FileEditorManager.getInstance(project); for (VirtualFile virtualFile : fileEditorManager.getOpenFiles()) { insertEditorHeaderComponentIfApplicable(fileEditorManager, virtualFile); } // listen for configuration changes messageBusConnection.subscribe(JSGraphQLConfigurationListener.TOPIC, this); // finally init the tool window tabs initToolWindow(); // and notify to configure the schema project.putUserData(JSGraphQLParserDefinition.JSGRAPHQL_ACTIVATED, true); EditorNotifications.getInstance(project).updateAllNotifications(); // make sure the GraphQL schema is shown in the project tree if not already if (!JSGraphQLSchemaDirectoryNode.isShownForProject(project)) { final ProjectView projectView = ProjectView.getInstance(project); if (projectView != null && projectView.getCurrentProjectViewPane() instanceof ProjectViewPane) { projectView.refresh(); } } }
From source file:com.intellij.lang.jsgraphql.ide.project.JSGraphQLLanguageUIProjectService.java
License:Open Source License
private void reloadEndpoints(List<JSGraphQLEndpoint> newEndpoints) { final FileEditorManager fileEditorManager = FileEditorManager.getInstance(myProject); for (VirtualFile file : fileEditorManager.getOpenFiles()) { for (FileEditor editor : fileEditorManager.getEditors(file)) { if (editor instanceof TextEditor) { final JSGraphQLEndpointsModel endpointsModel = ((TextEditor) editor).getEditor() .getUserData(JS_GRAPH_QL_ENDPOINTS_MODEL); if (endpointsModel != null) { endpointsModel.reload(newEndpoints); }// w w w . j a va 2 s.c o m } } } }
From source file:com.intellij.lang.jsgraphql.schema.ide.project.JSGraphQLSchemaLanguageProjectService.java
License:Open Source License
public JSGraphQLSchemaLanguageProjectService(@NotNull final Project project) { this.project = project; this.endpointNamedTypeRegistry = JSGraphQLEndpointNamedTypeRegistry.getService(project); final MessageBusConnection connection = project.getMessageBus().connect(this); connection.subscribe(FileEditorManagerListener.FILE_EDITOR_MANAGER, this); connection.subscribe(JSGraphQLLanguageServiceListener.TOPIC, this); // mark restored schema files as viewers final FileEditorManager fileEditorManager = FileEditorManager.getInstance(project); for (VirtualFile virtualFile : fileEditorManager.getOpenFiles()) { markSchemaFileAsViewer(fileEditorManager, virtualFile); }//from w w w . j a va 2 s . co m }
From source file:com.intellij.testFramework.fixtures.impl.CodeInsightTestFixtureImpl.java
License:Apache License
@Override public void tearDown() throws Exception { UIUtil.invokeAndWaitIfNeeded(new Runnable() { @Override//from ww w . j a v a 2s. c om public void run() { FileEditorManager editorManager = FileEditorManager.getInstance(getProject()); VirtualFile[] openFiles = editorManager.getOpenFiles(); for (VirtualFile openFile : openFiles) { editorManager.closeFile(openFile); } myEditor = null; myFile = null; myPsiManager = null; myInspections = null; myAvailableTools.clear(); try { myProjectFixture.tearDown(); myTempDirFixture.tearDown(); } catch (Exception e) { throw new RuntimeException(e); } } }); super.tearDown(); }
From source file:com.intellij.testFramework.LightPlatformCodeInsightTestCase.java
License:Apache License
@Override protected void tearDown() throws Exception { FileEditorManager editorManager = FileEditorManager.getInstance(getProject()); VirtualFile[] openFiles = editorManager.getOpenFiles(); for (VirtualFile openFile : openFiles) { editorManager.closeFile(openFile); }/* ww w . j a v a 2s .co m*/ deleteVFile(); myEditor = null; myFile = null; myVFile = null; super.tearDown(); }
From source file:com.kstenschke.referencer.parser.ParserFilesFolders.java
License:Apache License
/** * Get items regarding files / folder / paths * * @param e Action system event/* w w w.j ava 2 s .c om*/ * @return List of PHP items */ public static List<String> getReferenceItems(AnActionEvent e) { List<String> referenceItems = new ArrayList<String>(); final Project project = e.getData(PlatformDataKeys.PROJECT); Editor editor = e.getData(PlatformDataKeys.EDITOR); if (project != null && editor != null) { final Document document = editor.getDocument(); // Get line number the caret is in int caretOffset = editor.getCaretModel().getOffset(); int lineNumber = document.getLineNumber(caretOffset); // File path and name VirtualFile file = FileDocumentManager.getInstance().getFile(document); String filePath = (file != null) ? file.getPath() : ""; String filename = (file != null) ? file.getName() : ""; // Add items FileEditorManager fileEditorManager = FileEditorManager.getInstance(project); int amountOpenFiles = fileEditorManager.getOpenFiles().length; if (amountOpenFiles > 1) { referenceItems.add(StaticTexts.POPUP_ITEM_OPEN_FILES); } referenceItems.add(filePath); referenceItems.add(filePath + "::" + (lineNumber + 1)); referenceItems.add(filename); referenceItems.add(filename + "::" + (lineNumber + 1)); } return referenceItems; }
From source file:com.kstenschke.referencer.parser.ParserFilesFolders.java
License:Apache License
/** * @param fileEditorManager FileEditorManager * @return String with concatenated list of all files that are opened currently *///from www . j ava 2 s . c om public static String getAllOpenedFiles(FileEditorManager fileEditorManager) { String allOpenFiles = ""; List<VirtualFile> openFiles = Arrays.asList(fileEditorManager.getOpenFiles()); for (VirtualFile iteratedOpenFile : openFiles) { String curFilePath = iteratedOpenFile.toString().replace("file://", ""); allOpenFiles = allOpenFiles + "\n" + curFilePath; } return allOpenFiles; }
From source file:com.maddyhome.idea.vim.group.FileGroup.java
License:Open Source License
/** * Selects then next or previous editor//from w w w . j av a 2 s. c om * * @param count * @param context */ public boolean selectFile(int count, @NotNull DataContext context) { Project proj = PlatformDataKeys.PROJECT.getData(context); FileEditorManager fem = FileEditorManager.getInstance(proj); // API change - don't merge VirtualFile[] editors = fem.getOpenFiles(); if (count == 99) { count = editors.length - 1; } if (count < 0 || count >= editors.length) { return false; } fem.openFile(editors[count], true); return true; }