Module jEdit

Class DockableWindowManager

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible
Direct Known Subclasses:
DockableWindowManagerImpl

public abstract class DockableWindowManager extends JPanel

Keeps track of all dockable windows for a single View, and provides an API for getting/showing/hiding them.

Each View has an instance of this class.

dockables.xml:

Dockable window definitions are read from dockables.xml files contained inside plugin JARs. A dockable definition file has the following form:

<?xml version="1.0"?>
<!DOCTYPE DOCKABLES SYSTEM "dockables.dtd">
<DOCKABLES>
    <DOCKABLE NAME="dockableName" MOVABLE="TRUE|FALSE">
        // Code to create the dockable
    </DOCKABLE>
</DOCKABLES>

The MOVABLE attribute specifies the behavior when the docking position of the dockable window is changed. If MOVABLE is TRUE, the existing instance of the dockable window is moved to the new docking position, and if the dockable window implements the DockableWindow interface (see DockableWindow), it is also notified about the change in docking position before it is moved. If MOVABLE is FALSE, the BeanShell code is invoked to get the instance of the dockable window to put in the new docking position. Typically, the BeanShell code returns a new instance of the dockable window, and the state of the existing instance is not preserved after the change. It is therefore recommended to set MOVABLE to TRUE for all dockables in order to make them preserve their state when they are moved. For backward compatibility reasons, this attribute is set to FALSE by default.

More than one <DOCKABLE> tag may be present. The code that creates the dockable can reference any BeanShell built-in variable (see BeanShell), along with a variable position whose value is one of FLOATING, TOP, LEFT, BOTTOM, and RIGHT.

The following properties must be defined for each dockable window:

  • dockableName.title - the string to show on the dockable button.
  • dockableName.label - The string to use for generating menu items and action names.
  • dockableName.longtitle - (optional) the string to use in the dockable's floating window title (when it is floating). If not specified, the dockableName.title property is used.
A number of actions are automatically created for each dockable window:
  • dockableName - opens the dockable window.
  • dockableName-toggle - toggles the dockable window's visibility.
  • dockableName-float - opens the dockable window in a new floating window.
Note that only the first action needs a label property, the rest have automatically-generated labels.

Implementation details:

When an instance of this class is initialized by the View class, it iterates through the list of registered dockable windows (from jEdit itself, and any loaded plugins) and examines options supplied by the user in the Global Options dialog box. Any plugins designated for one of the four docking positions are displayed.

To create an instance of a dockable window, the DockableWindowManager finds and executes the BeanShell code extracted from the appropriate dockables.xml file. This code will typically consist of a call to the constructor of the dockable window component. The result of the BeanShell expression, typically a newly constructed component, is placed in a window managed by this class.

Since:
jEdit 2.6pre3
Version:
$Id: DockableWindowManager.java 23222 2013-09-29 20:43:34Z shlomy $
Author:
Slava Pestov, John Gellene (API documentation), Shlomy Reinstein (refactoring into a base and an impl)
See Also:
  • Field Details

  • Constructor Details

  • Method Details

    • setMainPanel

      public abstract void setMainPanel(JPanel panel)
    • showDockableWindow

      public abstract void showDockableWindow(String name)
    • hideDockableWindow

      public abstract void hideDockableWindow(String name)
    • disposeDockableWindow

      public abstract void disposeDockableWindow(String name)
      Completely dispose of a dockable - called when a plugin is unloaded, to remove all references to the its dockables.
    • floatDockableWindow

      public abstract JComponent floatDockableWindow(String name)
    • isDockableWindowDocked

      public abstract boolean isDockableWindowDocked(String name)
    • isDockableWindowVisible

      public abstract boolean isDockableWindowVisible(String name)
    • closeCurrentArea

      public abstract void closeCurrentArea()
    • getDockingLayout

      public abstract DockableWindowManager.DockingLayout getDockingLayout(View.ViewConfig config)
    • getLeftDockingArea

      public abstract DockableWindowManager.DockingArea getLeftDockingArea()
    • getRightDockingArea

      public abstract DockableWindowManager.DockingArea getRightDockingArea()
    • getTopDockingArea

      public abstract DockableWindowManager.DockingArea getTopDockingArea()
    • getBottomDockingArea

      public abstract DockableWindowManager.DockingArea getBottomDockingArea()
    • init

      public void init()
    • close

      public void close()
    • applyDockingLayout

      public void applyDockingLayout(DockableWindowManager.DockingLayout docking)
    • addDockableWindow

      public void addDockableWindow(String name)
      Opens the specified dockable window. As of jEdit 4.0pre1, has the same effect as calling showDockableWindow().
      Parameters:
      name - The dockable window name
      Since:
      jEdit 2.6pre3
    • removeDockableWindow

      public void removeDockableWindow(String name)
      Hides the specified dockable window. As of jEdit 4.2pre1, has the same effect as calling hideDockableWindow().
      Parameters:
      name - The dockable window name
      Since:
      jEdit 4.2pre1
    • toggleDockableWindow

      public void toggleDockableWindow(String name)
      Toggles the visibility of the specified dockable window.
      Parameters:
      name - The dockable window name
    • getDockableWindow

      public JComponent getDockableWindow(String name)
      Returns the specified dockable window. Note that this method will return null if the dockable has not been added yet. Make sure you call addDockableWindow(String) first.
      Parameters:
      name - The name of the dockable window
      Since:
      jEdit 4.1pre2
    • toggleDockAreas

      public void toggleDockAreas()
      Hides all visible dock areas, or shows them again, if the last time it was a hide.
      Since:
      jEdit 4.3pre16
    • willToggleHide

      public boolean willToggleHide()
      Returns:
      true if the next invocation of "toggle docked areas" will hide the dockables. false otherwise.
    • dockableTitleChanged

      public void dockableTitleChanged(String dockable, String newTitle)
    • closeListener

      public KeyListener closeListener(String dockableName)
      The actionEvent "close-docking-area" by default only works on dockable windows that have no special keyboard handling. If you have dockable widgets with input widgets and/or other fancy keyboard handling, those components may not respond to close docking area. You can add key listeners to each keyboard-handling component in your dockable that usually has keyboard focus. This function creates and returns a key listener which does exactly that. It is also used by FloatingWindowContainer when creating new floating windows.
      Parameters:
      dockableName - the name of your dockable
      Returns:
      a KeyListener you can add to that plugin's component.
      Since:
      jEdit 4.3pre6
    • getView

      public View getView()
      Returns this dockable window manager's view.
      Since:
      jEdit 4.0pre2
    • getDockable

      public JComponent getDockable(String name)
      Since:
      jEdit 4.3pre2
    • getDockableTitle

      public String getDockableTitle(String name)
      Returns the title of the specified dockable window.
      Parameters:
      name - The name of the dockable window.
      Since:
      jEdit 4.1pre5
    • setDockableTitle

      public void setDockableTitle(String dockable, String title)
      Changes the .longtitle property of a dockable window, which corresponds to the title shown when it is floating (not docked). Fires a change event that makes sure all floating dockables change their title.
      Parameters:
      dockable - the name of the dockable, as specified in the dockables.xml
      title - the new .longtitle you want to see above it.
      Since:
      4.3pre5
    • getRegisteredDockableWindows

      public static String[] getRegisteredDockableWindows()
    • getDockableWindowPluginName

      public static String getDockableWindowPluginName(String name)
    • setDockingLayout

      public void setDockingLayout(DockableWindowManager.DockingLayout docking)
    • handleDockableWindowUpdate

      public void handleDockableWindowUpdate(DockableWindowUpdate msg)
    • handlePropertiesChanged

      public void handlePropertiesChanged(PropertiesChanged msg)
    • handlePluginUpdate

      public void handlePluginUpdate(PluginUpdate pmsg)
    • longTitle

      public String longTitle(String name)
    • shortTitle

      public String shortTitle(String name)
    • applyAlternateLayout

      protected void applyAlternateLayout(boolean alternateLayout)
    • dockableLoaded

      protected void dockableLoaded(String dockableName, String position)
    • dockingPositionChanged

      protected void dockingPositionChanged(String dockableName, String oldPosition, String newPosition)
    • getAlternateLayoutProp

      protected boolean getAlternateLayoutProp()
    • propertiesChanged

      protected void propertiesChanged()
    • createDockable

      protected JComponent createDockable(String name)
    • getDockablePosition

      protected String getDockablePosition(String name)
    • focusDockable

      protected void focusDockable(String name)
    • getLongTitlePropertyName

      protected String getLongTitlePropertyName(String dockableName)