private void updateListClosedParts(VirtualFile file) { if (closedParts.isEmpty()) { return; } for (EditorPartPresenter closedEditorPart : closedParts) { Path path = closedEditorPart.getEditorInput().getFile().getLocation(); if (path.equals(file.getLocation())) { closedParts.remove(closedEditorPart); return; } } }
@Nullable @Override public EditorTab getTabByPath(@NotNull Path path) { for (TabItem tab : parts.keySet()) { EditorTab editorTab = (EditorTab) tab; Path currentPath = editorTab.getFile().getLocation(); if (currentPath.equals(path)) { return editorTab; } } return null; }
@Override public void onInitializationFailed() { openEditorCallback.onInitializationFailed(); removeFromOpeningFilesList(file.getLocation(), editorPartStack); if (!openingEditorsPathsToStacks.containsKey(editorPartStack) && editorPartStack.getParts().isEmpty()) { editorMultiPartStack.removePartStack(editorPartStack); } } };
@Nullable public PartPresenter getPartByPath(Path path) { for (TabItem tab : parts.keySet()) { EditorTab editorTab = (EditorTab) tab; Path currentPath = editorTab.getFile().getLocation(); if (currentPath.equals(path)) { return parts.get(tab); } } return null; }
@Override public void onActivePartChanged(ActivePartChangedEvent event) { PartPresenter activePart = event.getActivePart(); if (!(activePart instanceof EditorPartPresenter)) { return; } EditorPartPresenter activeEditor = (EditorPartPresenter) activePart; Path path = activeEditor.getEditorInput().getFile().getLocation(); if (editorGroups.containsKey(path)) { editorGroups.get(path).onActiveEditorChanged(activeEditor); } }
/** Indicates if line of code to add breakpoint at is executable. */ private boolean isLineEmpty(final VirtualFile activeFile, int lineNumber) { EditorPartPresenter editor = getEditorForFile(activeFile.getLocation().toString()); if (editor instanceof TextEditor) { Document document = ((TextEditor) editor).getDocument(); return document.getLineContent(lineNumber - 1).trim().isEmpty(); } return false; }
/** {@inheritDoc} */ @Override public void onFileOperation(FileEvent event) { if (event.getOperationType() != FileEvent.FileOperation.CLOSE) { return; } final Path eventFilePath = event.getFile().getLocation(); final Path filePath = input.getFile().getLocation(); if (filePath.equals(eventFilePath)) { workspaceAgent.removePart(this); } } }
@Override public void onEditorDirtyStateChanged(EditorDirtyStateChangedEvent event) { EditorPartPresenter changedEditor = event.getEditor(); if (changedEditor == null || changedEditor.isDirty()) { // we sync 'dirty' state of editors only for case when content of an active editor IS SAVED return; } Path changedEditorPath = changedEditor.getEditorInput().getFile().getLocation(); if (editorGroups.containsKey(changedEditorPath)) { editorGroups.get(changedEditorPath).onEditorDirtyStateChanged(changedEditor); } }
@Override public void onFileOperation(FileEvent event) { if (event.getOperationType() == CLOSE && textEditor != null && textEditor.getDocument() != null && textEditor.getDocument().getFile().getLocation().equals(event.getFile().getLocation())) { isActiveLinkedEditor = false; } }
private void processFileClose( EditorPartPresenter closingEditor, List<EditorPartPresenter> openedEditors, Path path) { for (final EditorPartPresenter editor : openedEditors) { final Path editorFilePath = editor.getEditorInput().getFile().getLocation(); if (Objects.equals(path, editorFilePath) && closingEditor != editor) { return; } } clientServerEventService.sendFileTrackingStopEvent(path.toString()); } });
private void closeOpenedEditor(Path path) { final EditorAgent editorAgent = editorAgentProvider.get(); final List<EditorPartPresenter> openedEditors = editorAgent.getOpenedEditors(); for (EditorPartPresenter openEditor : openedEditors) { if (openEditor.getEditorInput().getFile().getLocation().equals(path)) { editorAgent.closeEditor(openEditor); } } } }
/** {@inheritDoc} */ @Override public void actionPerformed(ActionEvent e) { EditorTab editorTab = getEditorTab(e); if (editorTab == null) { return; } final VirtualFile editorFile = getEditorFile(e); final EditorPartPresenter openedEditor = editorAgent.getOpenedEditor(editorFile.getLocation()); editorAgent.closeEditor(openedEditor); } }
protected void findInOpenedEditors( final Location location, final AsyncCallback<VirtualFile> callback) { for (EditorPartPresenter editor : editorAgent.getOpenedEditors()) { VirtualFile file = editor.getEditorInput().getFile(); String filePath = file.getLocation().toString(); if (filePath.equals(location.getTarget())) { callback.onSuccess(file); return; } } callback.onFailure(new IllegalArgumentException("There is no opened editors for " + location)); }
@Override public void onEditorOpened(EditorPartPresenter editor) { editorPartStack.addPart(editor); editorMultiPartStack.setActivePart(editor); openedEditors.add(editor); removeFromOpeningFilesList(file.getLocation(), editorPartStack); openEditorCallback.onEditorOpened(editor); eventBus.fireEvent(new EditorOpenedEvent(file, editor)); eventBus.fireEvent(FileEvent.createFileOpenedEvent(file)); }
/** {@inheritDoc} */ @Override public Promise<String> expand() { final EditorPartPresenter editor = getActiveEditor(); if (editor == null) { return promises.resolve(""); } return promises.resolve(editor.getEditorInput().getFile().getLocation().toString()); } }
private boolean isResourceOpened(final Resource resource) { if (!resource.isFile()) { return false; } File file = (File) resource; for (EditorPartPresenter editor : editorAgent.getOpenedEditors()) { Path editorPath = editor.getEditorInput().getFile().getLocation(); if (editorPath.equals(file.getLocation())) { return true; } } return false; }
private void closeRelatedEditors(Resource resource) { if (!resource.isProject()) { return; } final List<EditorPartPresenter> openedEditors = editorAgent.getOpenedEditors(); for (EditorPartPresenter editor : openedEditors) { if (resource.getLocation().isPrefixOf(editor.getEditorInput().getFile().getLocation())) { editorAgent.closeEditor(editor); } } }
/** {@inheritDoc} */ @Override public Promise<String> expand() { final EditorPartPresenter editor = getActiveEditor(); if (editor == null) { return promises.resolve(""); } final Path absolutePath = appContext.getProjectsRoot().append(editor.getEditorInput().getFile().getLocation()); return promises.resolve(absolutePath.toString()); } }
private void save() { if (ACTIVATED == mode && editor.isDirty()) { editor.doSave(); } VirtualFile file = editor.getEditorInput().getFile(); Project project = getProject(file); if (project == null) { return; } String filePath = file.getLocation().toString(); String projectPath = project.getPath(); synchronizeWorkingCopy(filePath, projectPath); }
private void setSuspendedLocation(Location location) { deleteSuspendedLocation(); suspendedLocation = location; EditorPartPresenter editor = getEditorForFile(location.getTarget()); if (editor != null) { VirtualFile activeFile = editor.getEditorInput().getFile(); BreakpointRenderer renderer = getBreakpointRendererForFile(activeFile.getLocation().toString()); if (renderer != null) { renderer.setLineActive(location.getLineNumber() - 1, true); } } }