net.infonode.docking

Class DockingWindow

public abstract class DockingWindow extends BasePanel

This is the base class for all types of docking windows. The windows are structured in a tree, typically with a RootWindow at the root. Each DockingWindow has a window parent and a number of child windows.

Warning: the non-public methods in this class can be changed in non-compatible ways in future versions.

Version: $Revision: 1.119 $

Author: $Author: jesper $

Constructor Summary
protected DockingWindow(WindowItem windowItem)
Method Summary
protected DropActionacceptChildDrop(Point p, DockingWindow window)
protected DropActionacceptInteriorDrop(Point p, DockingWindow window)
protected booleanacceptsSplitWith(DockingWindow window)
protected DropActionacceptSplitDrop(Point p, DockingWindow window, int splitDistance)
voidaddListener(DockingWindowListener listener)
Adds a listener which will reveive events for this window and all child windows.
voidaddTabMouseButtonListener(MouseButtonListener listenerDocking)

Adds a listener that receives mouse button events for window tabs.

protected DockingWindowaddWindow(DockingWindow window)
protected voidaddWindowItem(DockingWindow w, int index)
protected voidafterWindowRemoved(DockingWindow window)
protected voidbeforeDrop(DockingWindow target)
protected static voidbeginOptimize(DockingWindow window)
protected static voidbeginUpdateModel()
protected booleanchildInsideTab()
protected voidchildRemoved(DockingWindow child)
protected voidcleanUpModel()
protected voidclearChildrenFocus(DockingWindow child, View view)
protected voidclearFocus(View view)
voidclose()

Removes this window from it's window parent.

voidcloseWithAbort()
Same as close, but the windowClosing method of the window listeners will be called before closing the window, giving them the possibility to abort the close operation.
protected abstract PropertyMapcreatePropertyObject()
protected DropActioncreateTabWindow(DockingWindow window)
protected voiddetach()
protected DropActiondoAcceptDrop(Point p, DockingWindow window)
voiddock()

Docks the window to the RootWindow to the location it had before it was undocked.

If the window can't be docked to the exact same location, a good approximation is performed.

voiddockWithAbort()
Same as dock, but the windowDocking method of the window listeners will be called before docking the window, giving them the possibility to abort the dock operation.
protected abstract voiddoRemoveWindow(DockingWindow window)
protected abstract voiddoReplace(DockingWindow oldWindow, DockingWindow newWindow)
protected static voidendOptimize()
protected static voidendUpdateModel()
protected voidfireTitleChanged()
protected voidfireViewFocusChanged(View previouslyFocusedView, View focusedView)
protected voidfireWindowHidden(DockingWindow window)
protected voidfireWindowShown(DockingWindow window)
protected DockingWindow[]getAncestors()
protected DockingWindowgetBestFittedWindow(DockingWindow parentWindow)
protected intgetChildEdgeDepth(DockingWindow window, Direction dir)
abstract DockingWindowgetChildWindow(int index)
Returns the child window with index index.
abstract intgetChildWindowCount()
Returns the number of child windows.
intgetChildWindowIndex(DockingWindow window)
Returns the index of a child windows.
protected DockingWindowgetContentWindow(DockingWindow parent)
protected intgetEdgeDepth(Direction dir)
abstract IcongetIcon()
Returns the icon for this window.
DockingWindowgetLastFocusedChildWindow()
Returns the child window that last contained focus.
protected DockingWindowgetLocationWindow()
protected DockingWindowgetOptimizedWindow()
Returns the result after removing unnecessary tab windows which contains only one tab.
WindowPopupMenuFactorygetPopupMenuFactory()
Returns the popup menu factory for this window.
protected DockingWindowgetPreferredFocusChild()
DirectiongetPreferredMinimizeDirection()

Gets the preferred minimize direction of this window.

protected abstract PropertyMapgetPropertyObject()
RootWindowgetRootWindow()
Returns the RootWindow which contains this window, null if there is none.
StringgetTitle()
Returns the title of this window.
protected booleangetUpdateModel()
protected WindowItemgetWindowItem()
DockingWindowgetWindowParent()
Returns the window parent of this window.
DockingWindowPropertiesgetWindowProperties()
Returns the properties for this window.
protected booleanhasParent(DockingWindow w)
protected voidinit()
protected booleaninsideTab()
protected voidinternalClose()
protected DockingWindowinternalReplaceChildWindow(DockingWindow oldWindow, DockingWindow newWindow)
protected booleanisChildShowingInRootWindow(DockingWindow child)
booleanisClosable()
Returns true if this window can be closed by the user.
booleanisDockable()
Returns true if this window can be docked to the root window from a floating window.
booleanisMaximizable()
Returns true if this window can be maximized by the user.
booleanisMaximized()
Returns true if this window has a root window and is maximized in that root window or in a floating window.
booleanisMinimizable()
Returns true if this window can be minimized by the user.
booleanisMinimized()
Returns true if this window is minimized, ie located in a WindowBar.
booleanisRestorable()
Returns true if this window can be restored by the user.
protected booleanisShowingInRootWindow()
booleanisUndockable()
Returns true if this window can be undocked to a floating window.
booleanisUndocked()
voidmakeVisible()
Makes this window visible.
voidmaximize()
Maximizes this window in its root window or in its floating window.
voidmaximizeWithAbort()
Same as maximize, but the windowMaximized method of the window listeners will be called before maximizing the window, giving them the possibility to abort the maximize operation.
voidminimize()
Minimizes this window.
voidminimize(Direction direction)
Minimizes this window to a WindowBarlocated in direction.
voidminimizeWithAbort()
Same as minimize, but the windowMinimizing method of the window listeners will be called before minimizing the window, giving them the possibility to abort the minimize operation.
voidminimizeWithAbort(Direction direction)
Same as minimize, but the windowMinimizing method of the window listeners will be called before minimizing the window, giving them the possibility to abort the minimize operation.
protected booleanneedsTitleWindow()
protected voidnotifyListeners(WindowAncestors ancestors)
protected DockingWindowoldRead(ObjectInputStream in, ReadContext context)
protected static voidoptimizeAfter(DockingWindow window, Runnable runnable)
protected voidoptimizeWindowLayout()
protected voidreadLocations(ObjectInputStream in, RootWindow rootWindow, int version)
protected voidremoveChildWindow(DockingWindow window)
voidremoveListener(DockingWindowListener listener)
Removes a previously added listener.
voidremoveTabMouseButtonListener(MouseButtonListener listenerDocking)
Removes a mouse button listener that has been previously added using the addTabMouseButtonListener.
protected voidremoveWindow(DockingWindow window)
voidreplaceChildWindow(DockingWindow oldWindow, DockingWindow newWindow)
Replaces a child window with another window.
voidrestore()
Restores this window to the location before it was minimized, maximized or closed.
voidrestoreFocus()
Requests that the last focused child window becomes visible and that focus is restored to the last focused component in that window.
voidrestoreWithAbort()
Same as restore, but the windowRestoring method of the window listeners will be called before restoring the window, giving them the possibility to abort the restore operation.
protected voidrootChanged(RootWindow oldRoot, RootWindow newRoot)
protected voidsetFocused(boolean focused)
protected voidsetLastMinimizedDirection(Direction direction)
voidsetPopupMenuFactory(WindowPopupMenuFactory popupMenuFactory)
Sets the popup menu factory for this window.
voidsetPreferredMinimizeDirection(Direction direction)

Sets the preferred minimize direction of this window.

protected voidshowChildWindow(DockingWindow window)
protected booleanshowsWindowTitle()
SplitWindowsplit(DockingWindow splitWithWindow, Direction direction, float dividerLocation)
Splits this window in the given direction.
protected DropActionsplit(DockingWindow window, Direction splitDir)
DockingWindowDraggerstartDrag(RootWindow dropTarget)
Starts a drag and drop operation for this window.
protected WindowAncestorsstoreAncestors()
StringtoString()
FloatingWindowundock(Point location)

Undocks this window from it's window parent i.e. creates a FloatingWindow containing this window.

The window can be docked again by calling dock.

This method will call the windowUndocked method of all the listeners of this window and all window ancestors.

FloatingWindowundockWithAbort(Point location)
Same as undock, but the windowUndocking method of the window listeners will be called before undocking the window, giving them the possibility to abort the undock operation.
protected abstract voidupdate()
protected voidupdateButtonVisibility()
protected voidupdateWindowItem(RootWindow rootWindow)
protected voidupdateWindowItems()
protected voidwrite(ObjectOutputStream out, WriteContext context, ViewWriter viewWriter)
protected voidwriteLocations(ObjectOutputStream out)

Constructor Detail

DockingWindow

protected DockingWindow(WindowItem windowItem)

Method Detail

acceptChildDrop

protected DropAction acceptChildDrop(Point p, DockingWindow window)

acceptInteriorDrop

protected DropAction acceptInteriorDrop(Point p, DockingWindow window)

acceptsSplitWith

protected boolean acceptsSplitWith(DockingWindow window)

acceptSplitDrop

protected DropAction acceptSplitDrop(Point p, DockingWindow window, int splitDistance)

addListener

public void addListener(DockingWindowListener listener)
Adds a listener which will reveive events for this window and all child windows.

Parameters: listener the listener

Since: IDW 1.1.0

addTabMouseButtonListener

public void addTabMouseButtonListener(MouseButtonListener listenerDocking)

Adds a listener that receives mouse button events for window tabs. The listener will be called when a mouse button is pressed, clicked or released on a window tab of this window or a descendant of this window.

The listeners are called in the reverse order they were added, so the last added listener will be called first. When all the listeners of this window has been called, the event is propagated up to the window parent of this window, if there is one.

The MouseEventsource is the docking window connected to the tab in which the mouse event occured. The event point is the mouse coordinate where the event occured relative to the window.

Parameters: listenerDocking the listener

Since: IDW 1.3.0

addWindow

protected final DockingWindow addWindow(DockingWindow window)

addWindowItem

protected void addWindowItem(DockingWindow w, int index)

afterWindowRemoved

protected void afterWindowRemoved(DockingWindow window)

beforeDrop

protected void beforeDrop(DockingWindow target)

beginOptimize

protected static void beginOptimize(DockingWindow window)

beginUpdateModel

protected static void beginUpdateModel()

childInsideTab

protected boolean childInsideTab()

Returns: true if the child windows are inside tabs __exclude__

childRemoved

protected void childRemoved(DockingWindow child)

cleanUpModel

protected void cleanUpModel()

clearChildrenFocus

protected void clearChildrenFocus(DockingWindow child, View view)

clearFocus

protected void clearFocus(View view)

close

public void close()

Removes this window from it's window parent. If the window parent is a split window or a tab window with one child, it will be removed as well.

The location of this window is saved and the window can be restored to that location using the restore method.

This method will call the windowClosed method of all the listeners of this window and all window ancestors. The listeners of child windows will not be notified, for example closing a tab window containing views will not notify the listeners of views in that tab window.

closeWithAbort

public void closeWithAbort()
Same as close, but the windowClosing method of the window listeners will be called before closing the window, giving them the possibility to abort the close operation.

Throws: OperationAbortedException if the close operation was aborted by a window listener

Since: IDW 1.1.0

See Also: close windowClosing

createPropertyObject

protected abstract PropertyMap createPropertyObject()

createTabWindow

protected DropAction createTabWindow(DockingWindow window)

detach

protected final void detach()

doAcceptDrop

protected DropAction doAcceptDrop(Point p, DockingWindow window)

dock

public void dock()

Docks the window to the RootWindow to the location it had before it was undocked.

If the window can't be docked to the exact same location, a good approximation is performed. It's not guaranteed that the window is shown anywhere after this method has returned.

This method will call the windowDocked method of all the listeners of this window and all window ancestors. The listeners of child windows will not be notified, for example docking a tab window containing views will not notify the listeners of views in that tab window.

Since: IDW 1.4.0

dockWithAbort

public void dockWithAbort()
Same as dock, but the windowDocking method of the window listeners will be called before docking the window, giving them the possibility to abort the dock operation.

Throws: OperationAbortedException if the dock operation was aborted by a window listener

Since: IDW 1.4.0

See Also: dock windowDocking

doRemoveWindow

protected abstract void doRemoveWindow(DockingWindow window)

doReplace

protected abstract void doReplace(DockingWindow oldWindow, DockingWindow newWindow)

endOptimize

protected static void endOptimize()

endUpdateModel

protected static void endUpdateModel()

fireTitleChanged

protected void fireTitleChanged()

fireViewFocusChanged

protected void fireViewFocusChanged(View previouslyFocusedView, View focusedView)

fireWindowHidden

protected void fireWindowHidden(DockingWindow window)

fireWindowShown

protected void fireWindowShown(DockingWindow window)

getAncestors

protected DockingWindow[] getAncestors()

getBestFittedWindow

protected DockingWindow getBestFittedWindow(DockingWindow parentWindow)

getChildEdgeDepth

protected int getChildEdgeDepth(DockingWindow window, Direction dir)

getChildWindow

public abstract DockingWindow getChildWindow(int index)
Returns the child window with index index.

Parameters: index the child window index

Returns: the child window

getChildWindowCount

public abstract int getChildWindowCount()
Returns the number of child windows.

Returns: the number of child windows

getChildWindowIndex

public int getChildWindowIndex(DockingWindow window)
Returns the index of a child windows.

Parameters: window the child window

Returns: the index of the child window, -1 if the window is not a child of this window

getContentWindow

protected DockingWindow getContentWindow(DockingWindow parent)

getEdgeDepth

protected int getEdgeDepth(Direction dir)

getIcon

public abstract Icon getIcon()
Returns the icon for this window.

Returns: the icon

getLastFocusedChildWindow

public DockingWindow getLastFocusedChildWindow()
Returns the child window that last contained focus.

Returns: the child window that last contained focus, null if no child window has contained focus or the child has been removed from this window

getLocationWindow

protected DockingWindow getLocationWindow()

getOptimizedWindow

protected DockingWindow getOptimizedWindow()
Returns the result after removing unnecessary tab windows which contains only one tab.

Returns: the result after removing unnecessary tab windows which contains only one tab

getPopupMenuFactory

public WindowPopupMenuFactory getPopupMenuFactory()
Returns the popup menu factory for this window. If it's null the window parent popup menu factory will be used when the mouse popup trigger is activated on this window.

Returns: the popup menu factory for this window, null if there is none

getPreferredFocusChild

protected DockingWindow getPreferredFocusChild()

getPreferredMinimizeDirection

public Direction getPreferredMinimizeDirection()

Gets the preferred minimize direction of this window. See setPreferredMinimizeDirection for more information.

Returns: the preferred minimize direction of this window, null if the closest WindowBar is used

Since: IDW 1.3.0

getPropertyObject

protected abstract PropertyMap getPropertyObject()

getRootWindow

public RootWindow getRootWindow()
Returns the RootWindow which contains this window, null if there is none.

Returns: the RootWindow, null if there is none

getTitle

public String getTitle()
Returns the title of this window.

Returns: the window title

getUpdateModel

protected boolean getUpdateModel()

getWindowItem

protected WindowItem getWindowItem()

getWindowParent

public DockingWindow getWindowParent()
Returns the window parent of this window.

Returns: the window parent of this window

getWindowProperties

public DockingWindowProperties getWindowProperties()
Returns the properties for this window.

Returns: the properties for this window

hasParent

protected boolean hasParent(DockingWindow w)

init

protected void init()

insideTab

protected boolean insideTab()

Returns: true if this window is inside a tab __exclude__

internalClose

protected void internalClose()

internalReplaceChildWindow

protected DockingWindow internalReplaceChildWindow(DockingWindow oldWindow, DockingWindow newWindow)

isChildShowingInRootWindow

protected boolean isChildShowingInRootWindow(DockingWindow child)

isClosable

public boolean isClosable()
Returns true if this window can be closed by the user.

Returns: true if this window can be closed

Since: IDW 1.2.0

See Also: close closeWithAbort

isDockable

public boolean isDockable()
Returns true if this window can be docked to the root window from a floating window.

Returns: true if this window can be docked

Since: IDW 1.4.0

See Also: dock

isMaximizable

public boolean isMaximizable()
Returns true if this window can be maximized by the user.

Returns: true if this window can be maximized

Since: IDW 1.2.0

See Also: maximize

isMaximized

public boolean isMaximized()
Returns true if this window has a root window and is maximized in that root window or in a floating window.

Returns: true if this window has a root window and is maximized in that root window or in a floating window

Since: IDW 1.1.0

isMinimizable

public boolean isMinimizable()
Returns true if this window can be minimized by the user.

Returns: true if this window can be minimized

See Also: minimize

isMinimized

public boolean isMinimized()
Returns true if this window is minimized, ie located in a WindowBar.

Returns: true if this window is minimized

isRestorable

public boolean isRestorable()
Returns true if this window can be restored by the user.

Returns: true if this window can be restored

Since: IDW 1.2.0

See Also: restore

isShowingInRootWindow

protected boolean isShowingInRootWindow()

isUndockable

public boolean isUndockable()
Returns true if this window can be undocked to a floating window.

Returns: true if this window can be undocked

Since: IDW 1.4.0

See Also: undock

isUndocked

public boolean isUndocked()

makeVisible

public void makeVisible()
Makes this window visible. This causes the tabs of all TabWindow parents containing this window to be selected.

Since: IDW 1.1.0

maximize

public final void maximize()
Maximizes this window in its root window or in its floating window. If this window has no root window nothing happens. This method takes the window component and displays it at the top in the root window or in the floating window. It does NOT modify the window tree structure, ie the window parent remains the unchanged.

The location of this window is saved and the window can be restored to that location using the restore method.

Since: IDW 1.1.0

maximizeWithAbort

public void maximizeWithAbort()
Same as maximize, but the windowMaximized method of the window listeners will be called before maximizing the window, giving them the possibility to abort the maximize operation.

Throws: OperationAbortedException if the maximize operation was aborted by a window listener

Since: IDW 1.4.0

See Also: maximize windowMinimizing

minimize

public void minimize()
Minimizes this window. The window is minimized to the WindowBar in the preferred minimize direction, see setPreferredMinimizeDirection and getPreferredMinimizeDirection. If the WindowBar in that direction is not enabled, or the direction is null, thiw window is placed on the closest enabled WindowBar. If no suitable WindowBar was found or this window already is minimized, no action is performed.

The location of this window is saved and the window can be restored to that location using the restore method.

minimize

public void minimize(Direction direction)
Minimizes this window to a WindowBarlocated in direction. If no suitable WindowBarwas found or this window already is minimized, no action is performed.

The location of this window is saved and the window can be restored to that location using the restore method.

Parameters: direction the direction in which the window bar to be minimized to is located

minimizeWithAbort

public void minimizeWithAbort()
Same as minimize, but the windowMinimizing method of the window listeners will be called before minimizing the window, giving them the possibility to abort the minimize operation.

Throws: OperationAbortedException if the minimize operation was aborted by a window listener

Since: IDW 1.4.0

See Also: minimize windowMinimizing

minimizeWithAbort

public void minimizeWithAbort(Direction direction)
Same as minimize, but the windowMinimizing method of the window listeners will be called before minimizing the window, giving them the possibility to abort the minimize operation.

Throws: OperationAbortedException if the minimize operation was aborted by a window listener

Since: IDW 1.4.0

See Also: minimize windowMinimizing

needsTitleWindow

protected boolean needsTitleWindow()

notifyListeners

protected void notifyListeners(WindowAncestors ancestors)

oldRead

protected DockingWindow oldRead(ObjectInputStream in, ReadContext context)

optimizeAfter

protected static void optimizeAfter(DockingWindow window, Runnable runnable)

optimizeWindowLayout

protected void optimizeWindowLayout()

readLocations

protected final void readLocations(ObjectInputStream in, RootWindow rootWindow, int version)

removeChildWindow

protected final void removeChildWindow(DockingWindow window)

removeListener

public void removeListener(DockingWindowListener listener)
Removes a previously added listener.

Parameters: listener the listener

Since: IDW 1.1.0

removeTabMouseButtonListener

public void removeTabMouseButtonListener(MouseButtonListener listenerDocking)
Removes a mouse button listener that has been previously added using the addTabMouseButtonListener.

Parameters: listenerDocking the listener

Since: IDW 1.3.0

removeWindow

protected final void removeWindow(DockingWindow window)

replaceChildWindow

public void replaceChildWindow(DockingWindow oldWindow, DockingWindow newWindow)
Replaces a child window with another window.

Parameters: oldWindow the child window to replaceChildWindow newWindow the window to replaceChildWindow it with

restore

public void restore()
Restores this window to the location before it was minimized, maximized or closed. If the window can't be restored to the exact same location, a good approximation is performed. It's not guaranteed that the window is shown anywhere after this method has returned.

restoreFocus

public void restoreFocus()
Requests that the last focused child window becomes visible and that focus is restored to the last focused component in that window. If no child window has had focus or the child window has been removed from this window, focus is transferred to a child component of this window.

Since: IDW 1.1.0

restoreWithAbort

public void restoreWithAbort()
Same as restore, but the windowRestoring method of the window listeners will be called before restoring the window, giving them the possibility to abort the restore operation.

Throws: OperationAbortedException if the restore operation was aborted by a window listener

Since: IDW 1.4.0

See Also: restore windowMinimizing

rootChanged

protected void rootChanged(RootWindow oldRoot, RootWindow newRoot)

setFocused

protected void setFocused(boolean focused)

setLastMinimizedDirection

protected void setLastMinimizedDirection(Direction direction)

setPopupMenuFactory

public void setPopupMenuFactory(WindowPopupMenuFactory popupMenuFactory)
Sets the popup menu factory for this window. If it's not null a popup menu will be created and shown when the mouse popup trigger is activated on this window.

Parameters: popupMenuFactory the popup menu factory, null if no popup menu should be shown

setPreferredMinimizeDirection

public void setPreferredMinimizeDirection(Direction direction)

Sets the preferred minimize direction of this window. If the WindowBar in this direction is enabled this window will be placed on that bar when minimize is called.

Note that a window will "remember" the last WindowBar it was added to so the preferred minimize direction is changed when the window is added to another WindowBar.

Parameters: direction the preferred minimize direction of this window, null (which is default value) means use the closest, enabled WindowBar

Since: IDW 1.3.0

showChildWindow

protected void showChildWindow(DockingWindow window)

showsWindowTitle

protected boolean showsWindowTitle()

split

public SplitWindow split(DockingWindow splitWithWindow, Direction direction, float dividerLocation)
Splits this window in the given direction. If this window is a View which is contained in a TabWindow with a single tab, the TabWindow will splitted instead of this View.

Parameters: splitWithWindow the splitWithWindow which to split with direction the split direction dividerLocation the relative split divider location (0 - 1)

Returns: the resulting split window

split

protected DropAction split(DockingWindow window, Direction splitDir)

startDrag

public DockingWindowDragger startDrag(RootWindow dropTarget)
Starts a drag and drop operation for this window.

Parameters: dropTarget the RootWindow in which the window can be dropped

Returns: an DockingWindowDragger object which controls the drag and drop operation

Since: IDW 1.3.0

storeAncestors

protected WindowAncestors storeAncestors()

toString

public String toString()

undock

public FloatingWindow undock(Point location)

Undocks this window from it's window parent i.e. creates a FloatingWindow containing this window.

The window can be docked again by calling dock.

This method will call the windowUndocked method of all the listeners of this window and all window ancestors. The listeners of child windows will not be notified, for example undocking a tab window containing views will not notify the listeners of views in that tab window.

Parameters: location floating window location in screen coordinates

Returns: the floating window containing the undocked window

Since: IDW 1.4.0

undockWithAbort

public FloatingWindow undockWithAbort(Point location)
Same as undock, but the windowUndocking method of the window listeners will be called before undocking the window, giving them the possibility to abort the undock operation.

Parameters: location floating window location in screen coordinates

Returns: the floating window containing the undocked window

Throws: OperationAbortedException if the undock operation was aborted by a window listener

Since: IDW 1.4.0

See Also: undock windowClosing

update

protected abstract void update()

updateButtonVisibility

protected void updateButtonVisibility()

updateWindowItem

protected void updateWindowItem(RootWindow rootWindow)

updateWindowItems

protected final void updateWindowItems()

write

protected void write(ObjectOutputStream out, WriteContext context, ViewWriter viewWriter)

writeLocations

protected void writeLocations(ObjectOutputStream out)