org.gjt.sp.jedit.gui
Class DockableWindowManager

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JPanel
                  extended by org.gjt.sp.jedit.gui.DockableWindowManager
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, javax.accessibility.Accessible, EBComponent

public class DockableWindowManager
extends javax.swing.JPanel
implements EBComponent

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:

A number of actions are automatically created for each dockable 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
See Also:
View.getDockableWindowManager(), Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JPanel
javax.swing.JPanel.AccessibleJPanel
 
Nested classes/interfaces inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
static java.lang.String BOTTOM
          Bottom position.
static java.lang.String FLOATING
          Floating position.
static java.lang.String LEFT
          Left position.
static java.lang.String RIGHT
          Right position.
 java.util.Stack showStack
           
static java.lang.String TOP
          Top position.
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
DockableWindowManager(View view, DockableWindowFactory factory, View.ViewConfig config)
          Creates a new dockable window manager.
 
Method Summary
 void addDockableWindow(java.lang.String name)
          Opens the specified dockable window.
 void close()
          Called when the view is being closed.
 void closeCurrentArea()
          Closes the most recently focused dockable.
 java.awt.event.KeyListener closeListener(java.lang.String dockableName)
          The actionEvent "close-docking-area" by default only works on windows that are docked.
 javax.swing.JPopupMenu createPopupMenu(DockableWindowContainer container, java.lang.String dockable, boolean clone)
           
 javax.swing.JComponent floatDockableWindow(java.lang.String name)
          Opens a new instance of the specified dockable window in a floating container.
 PanelWindowContainer getBottomDockingArea()
           
 javax.swing.JComponent getDockable(java.lang.String name)
          Returns the specified dockable window.
 java.lang.String getDockableTitle(java.lang.String name)
          Returns the title of the specified dockable window.
 javax.swing.JComponent getDockableWindow(java.lang.String name)
          Returns the specified dockable window.
 PanelWindowContainer getLeftDockingArea()
           
static java.lang.String[] getRegisteredDockableWindows()
           
 PanelWindowContainer getRightDockingArea()
           
 PanelWindowContainer getTopDockingArea()
           
 View getView()
          Returns this dockable window manager's view.
 void handleMessage(EBMessage msg)
          Handles a message sent on the EditBus.
 void hideDockableWindow(java.lang.String name)
          Hides the specified dockable window.
 void init()
          Initialises dockable window manager.
 boolean isDockableWindowDocked(java.lang.String name)
          Returns if the specified dockable window is docked into the view.
 boolean isDockableWindowVisible(java.lang.String name)
          Returns if the specified dockable window is visible.
 void paintChildren(java.awt.Graphics g)
           
 void removeDockableWindow(java.lang.String name)
          Hides the specified dockable window.
 void setDockableTitle(java.lang.String dockableName, java.lang.String newTitle)
          Changes the .longtitle property of a dockable window, which corresponds to the title shown when it is floating (not docked).
 void showDockableWindow(java.lang.String name)
          Opens the specified dockable window.
 void toggleDockableWindow(java.lang.String name)
          Toggles the visibility of the specified dockable window.
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

FLOATING

public static final java.lang.String FLOATING
Floating position.

Since:
jEdit 2.6pre3
See Also:
Constant Field Values

TOP

public static final java.lang.String TOP
Top position.

Since:
jEdit 2.6pre3
See Also:
Constant Field Values

LEFT

public static final java.lang.String LEFT
Left position.

Since:
jEdit 2.6pre3
See Also:
Constant Field Values

BOTTOM

public static final java.lang.String BOTTOM
Bottom position.

Since:
jEdit 2.6pre3
See Also:
Constant Field Values

RIGHT

public static final java.lang.String RIGHT
Right position.

Since:
jEdit 2.6pre3
See Also:
Constant Field Values

showStack

public java.util.Stack showStack
Constructor Detail

DockableWindowManager

public DockableWindowManager(View view,
                             DockableWindowFactory factory,
                             View.ViewConfig config)
Creates a new dockable window manager.

Parameters:
view - The view
factory - A DockableWindowFactory, usually DockableWindowFactory.getInstance().
config - A docking configuration
Since:
jEdit 2.6pre3
Method Detail

getRegisteredDockableWindows

public static java.lang.String[] getRegisteredDockableWindows()
Since:
jEdit 4.3pre2

init

public void init()
Initialises dockable window manager. Do not call this method directly.


closeListener

public java.awt.event.KeyListener closeListener(java.lang.String dockableName)
The actionEvent "close-docking-area" by default only works on windows that are docked. If you want your floatable plugins to also respond to this event, you need to add key listeners to each component in your plugin that usually has keyboard focus. This function returns a key listener which does exactly that. You should not need to call this method - it is used by FloatingWindowContainer.

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

floatDockableWindow

public javax.swing.JComponent floatDockableWindow(java.lang.String name)
Opens a new instance of the specified dockable window in a floating container.

Parameters:
name - The dockable window name
Returns:
The new dockable window instance
Since:
jEdit 4.1pre2

showDockableWindow

public void showDockableWindow(java.lang.String name)
Opens the specified dockable window.

Parameters:
name - The dockable window name
Since:
jEdit 2.6pre3

addDockableWindow

public void addDockableWindow(java.lang.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

hideDockableWindow

public void hideDockableWindow(java.lang.String name)
Hides the specified dockable window.

Parameters:
name - The dockable window name
Since:
jEdit 2.6pre3

removeDockableWindow

public void removeDockableWindow(java.lang.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(java.lang.String name)
Toggles the visibility of the specified dockable window.

Parameters:
name - The dockable window name

getDockableWindow

public javax.swing.JComponent getDockableWindow(java.lang.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

getDockable

public javax.swing.JComponent getDockable(java.lang.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. For historical reasons, this does the same thing as getDockableWindow(String).

Parameters:
name - The name of the dockable window
Since:
jEdit 4.0pre1

getDockableTitle

public java.lang.String getDockableTitle(java.lang.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(java.lang.String dockableName,
                             java.lang.String newTitle)
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:
dockableName - the name of the dockable, as specified in the dockables.xml
newTitle - the new .longtitle you want to see above it.
Since:
4.3pre5

isDockableWindowVisible

public boolean isDockableWindowVisible(java.lang.String name)
Returns if the specified dockable window is visible.

Parameters:
name - The dockable window name

isDockableWindowDocked

public boolean isDockableWindowDocked(java.lang.String name)
Returns if the specified dockable window is docked into the view.

Parameters:
name - The dockable's name
Since:
jEdit 4.0pre2

closeCurrentArea

public void closeCurrentArea()
Closes the most recently focused dockable.

Since:
jEdit 4.1pre3

close

public void close()
Called when the view is being closed.

Since:
jEdit 2.6pre3

getTopDockingArea

public PanelWindowContainer getTopDockingArea()

getLeftDockingArea

public PanelWindowContainer getLeftDockingArea()

getBottomDockingArea

public PanelWindowContainer getBottomDockingArea()

getRightDockingArea

public PanelWindowContainer getRightDockingArea()

createPopupMenu

public javax.swing.JPopupMenu createPopupMenu(DockableWindowContainer container,
                                              java.lang.String dockable,
                                              boolean clone)

paintChildren

public void paintChildren(java.awt.Graphics g)
Overrides:
paintChildren in class javax.swing.JComponent

handleMessage

public void handleMessage(EBMessage msg)
Description copied from interface: EBComponent
Handles a message sent on the EditBus. This method must specify the type of responses the plugin will have for various subclasses of the EBMessage class. Typically this is done with one or more if blocks that test whether the message is an instance of a derived message class in which the component has an interest. For example:
 if(msg instanceof BufferUpdate) {
     // a buffer's state has changed!
 }
 else if(msg instanceof ViewUpdate) {
     // a view's state has changed!
 }
 // ... and so on

Specified by:
handleMessage in interface EBComponent
Parameters:
msg - The message