public class FileEditorManagerImpl extends FileEditorManagerEx implements PersistentStateComponent<Element>, Disposable
Disposable.Parent
Modifier and Type | Field and Description |
---|---|
static Key<java.lang.Boolean> |
CLOSING_TO_REOPEN |
static java.lang.String |
FILE_EDITOR_MANAGER |
SEPARATOR_DISABLED, USE_CURRENT_WINDOW
Constructor and Description |
---|
FileEditorManagerImpl(Project project) |
Modifier and Type | Method and Description |
---|---|
void |
addBottomComponent(FileEditor editor,
javax.swing.JComponent component)
Adds the specified component below the editor and paints a separator line above it.
|
void |
addFileEditorManagerListener(FileEditorManagerListener listener)
Adds specified
listener |
void |
addFileEditorManagerListener(FileEditorManagerListener listener,
Disposable parentDisposable) |
void |
addSelectionRecord(VirtualFile file,
EditorWindow window) |
void |
addTopComponent(FileEditor editor,
javax.swing.JComponent component)
Adds the specified component above the editor and paints a separator line below it.
|
void |
changeSplitterOrientation() |
void |
closeAllFiles()
Closes all files IN ACTIVE SPLITTER (window).
|
void |
closeFile(VirtualFile file)
Closes all editors opened for the file.
|
void |
closeFile(VirtualFile file,
boolean moveFocus,
boolean closeAllCopies) |
void |
closeFile(VirtualFile file,
EditorWindow window)
Closes editors for the file opened in particular window.
|
void |
closeFile(VirtualFile file,
EditorWindow window,
boolean transferFocus) |
void |
createSplitter(int orientation,
EditorWindow window) |
void |
dispose()
Usually not invoked directly, see class javadoc.
|
void |
fireSelectionChanged(EditorComposite newSelectedComposite) |
Promise<EditorWindow> |
getActiveWindow()
Asynchronous version of
FileEditorManagerEx.getCurrentWindow() . |
FileEditor [] |
getAllEditors() |
FileEditor [] |
getAllEditors(VirtualFile file) |
java.util.Set<EditorsSplitters> |
getAllSplitters() |
javax.swing.JComponent |
getComponent() |
VirtualFile |
getCurrentFile() |
EditorWindow |
getCurrentWindow()
Synchronous version of
FileEditorManagerEx.getActiveWindow() . |
FileEditor [] |
getEditors(VirtualFile file) |
Pair<FileEditor[],FileEditorProvider[]> |
getEditorsWithProviders(VirtualFile file) |
VirtualFile |
getFile(FileEditor editor) |
java.awt.Color |
getFileColor(VirtualFile file) |
java.lang.String |
getFileTooltipText(VirtualFile file) |
EditorsSplitters |
getMainSplitters() |
EditorWindow |
getNextWindow(EditorWindow window) |
VirtualFile [] |
getOpenFiles() |
javax.swing.JComponent |
getPreferredFocusedComponent() |
EditorWindow |
getPrevWindow(EditorWindow window) |
Project |
getProject()
Returns the project with which the file editor manager is associated.
|
ActionCallback |
getReady(java.lang.Object requestor) |
FileEditor |
getSelectedEditor() |
FileEditor |
getSelectedEditor(VirtualFile file) |
FileEditor [] |
getSelectedEditors() |
FileEditorWithProvider |
getSelectedEditorWithProvider(VirtualFile file) |
VirtualFile [] |
getSelectedFiles() |
Editor |
getSelectedTextEditor() |
Editor |
getSelectedTextEditor(boolean lockfree) |
java.util.List<Pair<VirtualFile,EditorWindow>> |
getSelectionHistory() |
VirtualFile [] |
getSiblings(VirtualFile file) |
EditorsSplitters |
getSplitters() |
EditorsSplitters |
getSplittersFor(java.awt.Component c) |
Element |
getState() |
java.util.List<javax.swing.JComponent> |
getTopComponents(FileEditor editor) |
EditorWindow [] |
getWindows() |
int |
getWindowSplitCount() |
boolean |
hasOpenedFile() |
boolean |
hasOpenFiles() |
boolean |
hasSplitOrUndockedWindows() |
void |
initDockableContentFactory() |
boolean |
isChanged(EditorComposite editor) |
static boolean |
isDumbAware(FileEditor editor) |
boolean |
isFileOpen(VirtualFile file) |
boolean |
isInsideChange() |
boolean |
isInSplitter() |
boolean |
isProblem(VirtualFile file) |
void |
loadState(Element state)
This method is called when new component state is loaded.
|
ActionCallback |
notifyPublisher(java.lang.Runnable runnable) |
java.util.List<FileEditor> |
openEditor(OpenFileDescriptor descriptor,
boolean focusEditor)
Must be called from EDT.
|
Pair<FileEditor[],FileEditorProvider[]> |
openFileImpl2(EditorWindow window,
VirtualFile file,
boolean focusEditor) |
Pair<FileEditor[],FileEditorProvider[]> |
openFileInNewWindow(VirtualFile file) |
Pair<FileEditor[],FileEditorProvider[]> |
openFileWithProviders(VirtualFile file,
boolean focusEditor,
boolean searchForSplitter) |
Pair<FileEditor[],FileEditorProvider[]> |
openFileWithProviders(VirtualFile file,
boolean focusEditor,
EditorWindow window) |
Editor |
openTextEditor(OpenFileDescriptor descriptor,
boolean focusEditor)
Works as
FileEditorManager.openFile(VirtualFile, boolean) but forces opening of text editor (see TextEditor ). |
protected void |
projectOpened(MessageBusConnection connection) |
void |
removeBottomComponent(FileEditor editor,
javax.swing.JComponent component) |
void |
removeFileEditorManagerListener(FileEditorManagerListener listener)
Removes specified
listener |
void |
removeTopComponent(FileEditor editor,
javax.swing.JComponent component) |
void |
setCurrentWindow(EditorWindow window) |
void |
setSelectedEditor(VirtualFile file,
java.lang.String fileEditorProviderId)
Selects a specified file editor tab for the specified editor.
|
void |
unsplitAllWindow() |
void |
unsplitWindow() |
protected void |
updateFileIcon(VirtualFile file)
Updates tab icon for the specified
file . |
void |
updateFilePresentation(VirtualFile file)
Refreshes the text, colors and icon of the editor tabs representing the specified file.
|
getData, getInstanceEx, openFile, openFile, refreshIcons, registerExtraEditorDataProvider, runWhenLoaded
getInstance, navigateToTextEditor
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
initializeComponent, noStateLoaded
public static final Key<java.lang.Boolean> CLOSING_TO_REOPEN
public static final java.lang.String FILE_EDITOR_MANAGER
public FileEditorManagerImpl(Project project)
public void dispose()
Disposable
dispose
in interface Disposable
public void initDockableContentFactory()
public static boolean isDumbAware(FileEditor editor)
public javax.swing.JComponent getComponent()
getComponent
in class FileEditorManagerEx
JComponent
which represent the place where all editors are locatedpublic EditorsSplitters getMainSplitters()
public java.util.Set<EditorsSplitters> getAllSplitters()
public javax.swing.JComponent getPreferredFocusedComponent()
getPreferredFocusedComponent
in class FileEditorManagerEx
FileEditor.getPreferredFocusedComponent()
but it also tracks (and remember) focus movement inside tabbed container.EditorComposite.getPreferredFocusedComponent()
public java.awt.Color getFileColor(VirtualFile file)
file
which corresponds to the
file's statuspublic boolean isProblem(VirtualFile file)
public java.lang.String getFileTooltipText(VirtualFile file)
public void updateFilePresentation(VirtualFile file)
FileEditorManagerEx
updateFilePresentation
in class FileEditorManagerEx
file
- the file to refresh.protected void updateFileIcon(VirtualFile file)
file
. The file
should be opened in the myEditor, otherwise the method throws an assertion.public VirtualFile getFile(FileEditor editor)
getFile
in class FileEditorManagerEx
public void unsplitWindow()
unsplitWindow
in class FileEditorManagerEx
public void unsplitAllWindow()
unsplitAllWindow
in class FileEditorManagerEx
public int getWindowSplitCount()
getWindowSplitCount
in class FileEditorManagerEx
public boolean hasSplitOrUndockedWindows()
hasSplitOrUndockedWindows
in class FileEditorManagerEx
public EditorWindow [] getWindows()
getWindows
in class FileEditorManagerEx
public EditorWindow getNextWindow(EditorWindow window)
getNextWindow
in class FileEditorManagerEx
public EditorWindow getPrevWindow(EditorWindow window)
getPrevWindow
in class FileEditorManagerEx
public void createSplitter(int orientation, EditorWindow window)
createSplitter
in class FileEditorManagerEx
public void changeSplitterOrientation()
changeSplitterOrientation
in class FileEditorManagerEx
public boolean isInSplitter()
isInSplitter
in class FileEditorManagerEx
public boolean hasOpenedFile()
hasOpenedFile
in class FileEditorManagerEx
public VirtualFile getCurrentFile()
getCurrentFile
in class FileEditorManagerEx
public Promise<EditorWindow> getActiveWindow()
FileEditorManagerEx
FileEditorManagerEx.getCurrentWindow()
. Execution happens after focus settle down. Can be invoked on any thread.getActiveWindow
in class FileEditorManagerEx
public EditorWindow getCurrentWindow()
FileEditorManagerEx
FileEditorManagerEx.getActiveWindow()
. Will return null
if invoked not from EDT.getCurrentWindow
in class FileEditorManagerEx
public void setCurrentWindow(EditorWindow window)
setCurrentWindow
in class FileEditorManagerEx
public void closeFile(VirtualFile file, EditorWindow window, boolean transferFocus)
public void closeFile(VirtualFile file, EditorWindow window)
FileEditorManagerEx
closeFile
in class FileEditorManagerEx
file
- file to be closed. Cannot be null.public void closeFile(VirtualFile file)
FileEditorManager
closeFile
in class FileEditorManager
file
- file to be closed.public void closeFile(VirtualFile file, boolean moveFocus, boolean closeAllCopies)
public Pair<FileEditor[],FileEditorProvider[]> openFileWithProviders(VirtualFile file, boolean focusEditor, boolean searchForSplitter)
openFileWithProviders
in class FileEditorManagerEx
public Pair<FileEditor[],FileEditorProvider[]> openFileInNewWindow(VirtualFile file)
public Pair<FileEditor[],FileEditorProvider[]> openFileWithProviders(VirtualFile file, boolean focusEditor, EditorWindow window)
openFileWithProviders
in class FileEditorManagerEx
public Pair<FileEditor[],FileEditorProvider[]> openFileImpl2(EditorWindow window, VirtualFile file, boolean focusEditor)
public ActionCallback notifyPublisher(java.lang.Runnable runnable)
notifyPublisher
in class FileEditorManagerEx
public void setSelectedEditor(VirtualFile file, java.lang.String fileEditorProviderId)
FileEditorManager
setSelectedEditor
in class FileEditorManager
file
- a file to switch the file editor tab for. The function does nothing if the file is not currently open in the editor.fileEditorProviderId
- the ID of the file editor to open; matches the return value of
FileEditorProvider.getEditorTypeId()
public java.util.List<FileEditor> openEditor(OpenFileDescriptor descriptor, boolean focusEditor)
FileEditorManager
openEditor
in class FileEditorManager
public Project getProject()
FileEditorManager
getProject
in class FileEditorManager
public Editor openTextEditor(OpenFileDescriptor descriptor, boolean focusEditor)
FileEditorManager
FileEditorManager.openFile(VirtualFile, boolean)
but forces opening of text editor (see TextEditor
).
If several text editors are opened, including the default one, default text editor is focused (if requested) and returned.
Must be called from EDT.openTextEditor
in class FileEditorManager
null
in case if text editor wasn't opened.public Editor getSelectedTextEditor()
getSelectedTextEditor
in class FileEditorManager
null
in case
there is no selected editor at all or selected editor is not a text one.
Must be called from EDT.public Editor getSelectedTextEditor(boolean lockfree)
public boolean isFileOpen(VirtualFile file)
isFileOpen
in class FileEditorManager
true
if file
is opened, false
otherwisepublic VirtualFile [] getOpenFiles()
getOpenFiles
in class FileEditorManager
public boolean hasOpenFiles()
hasOpenFiles
in class FileEditorManager
public VirtualFile [] getSelectedFiles()
getSelectedFiles
in class FileEditorManager
public FileEditor [] getSelectedEditors()
getSelectedEditors
in class FileEditorManager
public EditorsSplitters getSplitters()
getSplitters
in class FileEditorManagerEx
public FileEditor getSelectedEditor()
getSelectedEditor
in class FileEditorManager
null
if there is no selected editor at all.public FileEditor getSelectedEditor(VirtualFile file)
getSelectedEditor
in class FileEditorManager
null
if file
is not opened.public FileEditorWithProvider getSelectedEditorWithProvider(VirtualFile file)
getSelectedEditorWithProvider
in class FileEditorManagerEx
public Pair<FileEditor[],FileEditorProvider[]> getEditorsWithProviders(VirtualFile file)
getEditorsWithProviders
in class FileEditorManagerEx
public FileEditor [] getEditors(VirtualFile file)
getEditors
in class FileEditorManager
file
public FileEditor [] getAllEditors(VirtualFile file)
getAllEditors
in class FileEditorManager
file
public FileEditor [] getAllEditors()
getAllEditors
in class FileEditorManager
public java.util.List<javax.swing.JComponent> getTopComponents(FileEditor editor)
public void addTopComponent(FileEditor editor, javax.swing.JComponent component)
FileEditorManager
true
:
component.putClientProperty(SEPARATOR_DISABLED, true);Otherwise, a separator line will be painted by a
SEPARATOR_ABOVE_COLOR
or
TEARLINE_COLOR
if it is not set.
This method allows to add several components above the editor.
To change an order of components the specified component may implement the
Weighted
interface.
addTopComponent
in class FileEditorManager
public void removeTopComponent(FileEditor editor, javax.swing.JComponent component)
removeTopComponent
in class FileEditorManager
public void addBottomComponent(FileEditor editor, javax.swing.JComponent component)
FileEditorManager
true
:
component.putClientProperty(SEPARATOR_DISABLED, true);Otherwise, a separator line will be painted by a
SEPARATOR_BELOW_COLOR
or
TEARLINE_COLOR
if it is not set.
This method allows to add several components below the editor.
To change an order of components the specified component may implement the
Weighted
interface.
addBottomComponent
in class FileEditorManager
public void removeBottomComponent(FileEditor editor, javax.swing.JComponent component)
removeBottomComponent
in class FileEditorManager
public void addFileEditorManagerListener(FileEditorManagerListener listener)
FileEditorManager
listener
addFileEditorManagerListener
in class FileEditorManager
listener
- listener to be addedpublic void addFileEditorManagerListener(FileEditorManagerListener listener, Disposable parentDisposable)
addFileEditorManagerListener
in class FileEditorManager
public void removeFileEditorManagerListener(FileEditorManagerListener listener)
FileEditorManager
listener
removeFileEditorManagerListener
in class FileEditorManager
listener
- listener to be removedprotected void projectOpened(MessageBusConnection connection)
public Element getState()
getState
in interface PersistentStateComponent<Element>
null
value indicates
that the returned state won't be stored, as a result previously stored state will be used.XmlSerializer
public void loadState(Element state)
PersistentStateComponent
State object should be used directly, defensive copying is not required.
loadState
in interface PersistentStateComponent<Element>
state
- loaded component stateXmlSerializerUtil.copyBean(Object, Object)
public void fireSelectionChanged(EditorComposite newSelectedComposite)
public boolean isChanged(EditorComposite editor)
isChanged
in class FileEditorManagerEx
public boolean isInsideChange()
isInsideChange
in class FileEditorManagerEx
public void closeAllFiles()
FileEditorManagerEx
closeAllFiles
in class FileEditorManagerEx
DockManager.getContainers()
,
DockContainer.closeAll()
public VirtualFile [] getSiblings(VirtualFile file)
getSiblings
in class FileEditorManagerEx
file
itself) that belong
to the same tabbed container. The method returns empty array if file
is not open. The returned files have the same order as they have in the
tabbed container.public EditorsSplitters getSplittersFor(java.awt.Component c)
getSplittersFor
in class FileEditorManagerEx
public java.util.List<Pair<VirtualFile,EditorWindow>> getSelectionHistory()
public void addSelectionRecord(VirtualFile file, EditorWindow window)
public ActionCallback getReady(java.lang.Object requestor)