org.bs.mdi.swing
Class SwingRootView

java.lang.Object
  extended byjava.awt.Component
      extended byjava.awt.Container
          extended byjavax.swing.JComponent
              extended byjavax.swing.JPanel
                  extended byorg.bs.mdi.swing.SwingRootView
All Implemented Interfaces:
Accessible, ActionObservable, ActionObserver, ActionProcessor, ImageObserver, MenuContainer, RootView, Serializable, View

public abstract class SwingRootView
extends JPanel
implements RootView

An implementation of a RootView using Swing technology.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class javax.swing.JPanel
JPanel.AccessibleJPanel
 
Nested classes inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
 
Nested classes inherited from class java.awt.Container
Container.AccessibleAWTContainer
 
Nested classes inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
 
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
SwingRootView()
          Creates a new root view.
 
Method Summary
 void actionPerformed(ActionObservable observable, Action action)
          Called from the ActionObservable when an action has been performed or redone.
 void actionUndone(ActionObservable observable, Action action)
          Called from the ActionObservable when an action has been undone.
 void addChild(View child)
          Adds a child element.
 void addObserver(ActionObserver observer)
          Registers this observer so that it will receive notification messages.
 void applyAction(Action action)
          Applies an action or perform a redo.
abstract  Action copy()
          Perform a "copy to clipboard" operation.
 int countChildren()
          Counts all child elements.
 int countObservers()
          Counts all registered observers.
abstract  Action cut()
          Perform a "cut to clipboard" operation.
abstract  void delete()
          Perform a delete operation.
 View getChild(int index)
          Gets the child element at the specified index.
 Data getData()
          Returns the Data object associated with this view.
 Document getDocument()
          Returns the document which this view is assigned to.
 View getParentView()
          Gets the parent View object, or null if there is no parent object (i.e. this is probably a RootView object).
 DocumentWindow getWindow()
          Returns the window which is displaying this view.
 boolean isCopyPossible()
          Returns true if content can be copied to the clipboard.
 boolean isCutPossible()
          Returns true if content can be cutted to the clipboard.
 boolean isDeletePossible()
          Returns true if content can be deleted.
 boolean isObserver(ActionObserver observer)
          Determines if the given observer is currently observing this object.
 boolean isPastePossible()
          Returns true if content can be pasted from the clipboard.
 void notifyObservers(Action action, boolean undo)
          Notifies the observers about an action which has been recently performed.
abstract  void paste(Action action)
          Perform a "paste from clipboard" operation.
 void removeChild(View child)
          Removes a child element.
 void removeObserver(ActionObserver observer)
          Un-registers this observer so that it will not receive notifications any longer.
 void setCopyPossible(boolean possible)
          Enables or disables copying to the clipboard.
 void setCutPossible(boolean possible)
          Enables or disables cutting to the clipboard.
 void setData(Data data)
          Associates this View with the given Data object.
 void setDeletePossible(boolean possible)
          Enables or disables deleting operations.
 void setPastePossible(boolean possible)
          Enables or disables pasting from the clipboard.
abstract  void syncWithData()
          Called from the Data object to indicate that the documents data has changed.
 void undoAction(Action action)
          Perform an undo.
 void windowChanged(DocumentWindow window)
          Called from within the framework to indicate that the view's window has changed.
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFont, setForeground, 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, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, 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, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, 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, processMouseEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, 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
 

Constructor Detail

SwingRootView

public SwingRootView()
Creates a new root view.

Method Detail

getDocument

public Document getDocument()
Description copied from interface: View
Returns the document which this view is assigned to. This is just a convenience function which is roughly equivalent to getData().getDocument.

Specified by:
getDocument in interface View
Returns:
the document

setData

public void setData(Data data)
Description copied from interface: View
Associates this View with the given Data object. This method also makes this view observe the data as well as the data observe the view.

Specified by:
setData in interface View
Parameters:
data - the Data object

getData

public Data getData()
Description copied from interface: View
Returns the Data object associated with this view.

Specified by:
getData in interface View
Returns:
the corresponding Data object

getParentView

public View getParentView()
Description copied from interface: View
Gets the parent View object, or null if there is no parent object (i.e. this is probably a RootView object).

Specified by:
getParentView in interface View
Returns:
the parent object

addChild

public void addChild(View child)
Description copied from interface: View
Adds a child element.

Specified by:
addChild in interface View
Parameters:
child - the child element

removeChild

public void removeChild(View child)
Description copied from interface: View
Removes a child element.

Specified by:
removeChild in interface View
Parameters:
child - the child element

countChildren

public int countChildren()
Description copied from interface: View
Counts all child elements.

Specified by:
countChildren in interface View
Returns:
the number of child elements

getChild

public View getChild(int index)
Description copied from interface: View
Gets the child element at the specified index.

Specified by:
getChild in interface View
Parameters:
index - the index
Returns:
the child element at the specified position

windowChanged

public void windowChanged(DocumentWindow window)
Description copied from interface: RootView
Called from within the framework to indicate that the view's window has changed. This method gives the view the opportunity to react upon this event.

Specified by:
windowChanged in interface RootView
Parameters:
window - the new window

getWindow

public DocumentWindow getWindow()
Description copied from interface: RootView
Returns the window which is displaying this view.

Specified by:
getWindow in interface RootView
Returns:
the window

copy

public abstract Action copy()
Description copied from interface: View
Perform a "copy to clipboard" operation. Converts the currently selected information to an action object and returns it.

Specified by:
copy in interface View
Returns:
the action object containing the copied information

cut

public abstract Action cut()
Description copied from interface: View
Perform a "cut to clipboard" operation. Converts the currently selected information to an action object and returns it.

Specified by:
cut in interface View
Returns:
the action object containing the cutted information

paste

public abstract void paste(Action action)
Description copied from interface: View
Perform a "paste from clipboard" operation. The information to be pasted is delivered via the "action" parameter.

Specified by:
paste in interface View
Parameters:
action - the action object containing the information to be pasted

delete

public abstract void delete()
Description copied from interface: View
Perform a delete operation.

Specified by:
delete in interface View

isCopyPossible

public final boolean isCopyPossible()
Description copied from interface: View
Returns true if content can be copied to the clipboard.

Specified by:
isCopyPossible in interface View
Returns:
true if a copy operation is possible

isCutPossible

public final boolean isCutPossible()
Description copied from interface: View
Returns true if content can be cutted to the clipboard.

Specified by:
isCutPossible in interface View
Returns:
true if a cut operation is possible

isPastePossible

public final boolean isPastePossible()
Description copied from interface: View
Returns true if content can be pasted from the clipboard.

Specified by:
isPastePossible in interface View
Returns:
true if a paste operation is possible

isDeletePossible

public final boolean isDeletePossible()
Description copied from interface: View
Returns true if content can be deleted.

Specified by:
isDeletePossible in interface View
Returns:
true if a delete operation is possible

setCopyPossible

public void setCopyPossible(boolean possible)
Description copied from interface: View
Enables or disables copying to the clipboard.

Specified by:
setCopyPossible in interface View
Parameters:
possible - true if copying is possible, false otherwise

setCutPossible

public void setCutPossible(boolean possible)
Description copied from interface: View
Enables or disables cutting to the clipboard.

Specified by:
setCutPossible in interface View
Parameters:
possible - true if cutting is possible, false otherwise

setPastePossible

public void setPastePossible(boolean possible)
Description copied from interface: View
Enables or disables pasting from the clipboard.

Specified by:
setPastePossible in interface View
Parameters:
possible - true if pasting is possible, false otherwise

setDeletePossible

public void setDeletePossible(boolean possible)
Description copied from interface: View
Enables or disables deleting operations.

Specified by:
setDeletePossible in interface View
Parameters:
possible - true if deleting is possible, false otherwise

syncWithData

public abstract void syncWithData()
Description copied from interface: View
Called from the Data object to indicate that the documents data has changed.

The view update or redraw its contents the reflect that changes.

Specified by:
syncWithData in interface View

addObserver

public void addObserver(ActionObserver observer)
Description copied from interface: ActionObservable
Registers this observer so that it will receive notification messages.

Specified by:
addObserver in interface ActionObservable
Parameters:
observer - the observer to be registered

removeObserver

public void removeObserver(ActionObserver observer)
Description copied from interface: ActionObservable
Un-registers this observer so that it will not receive notifications any longer.

Specified by:
removeObserver in interface ActionObservable
Parameters:
observer - the observer to be un-registered

countObservers

public int countObservers()
Description copied from interface: ActionObservable
Counts all registered observers.

Specified by:
countObservers in interface ActionObservable
Returns:
the number of registered observers.

isObserver

public boolean isObserver(ActionObserver observer)
Description copied from interface: ActionObservable
Determines if the given observer is currently observing this object.

Specified by:
isObserver in interface ActionObservable
Parameters:
observer - the observer
Returns:
true if the observer is currently observing this object, false otherwise

notifyObservers

public void notifyObservers(Action action,
                            boolean undo)
Description copied from interface: ActionObservable
Notifies the observers about an action which has been recently performed. Note that the implementation may use threading to deliver the notification messages.

Specified by:
notifyObservers in interface ActionObservable
Parameters:
action - the action which has been performed
undo - true if the action has been undone, false otherwise

actionPerformed

public void actionPerformed(ActionObservable observable,
                            Action action)
Description copied from interface: ActionObserver
Called from the ActionObservable when an action has been performed or redone.

Specified by:
actionPerformed in interface ActionObserver
Parameters:
observable - the observable which this notification originated from
action - the action which has been performed

actionUndone

public void actionUndone(ActionObservable observable,
                         Action action)
Description copied from interface: ActionObserver
Called from the ActionObservable when an action has been undone.

Specified by:
actionUndone in interface ActionObserver
Parameters:
observable - the observable which this notification originated from
action - the action which has been undone

applyAction

public void applyAction(Action action)
Description copied from interface: ActionProcessor
Applies an action or perform a redo.

Specified by:
applyAction in interface ActionProcessor
Parameters:
action - the action to be applied or redone

undoAction

public void undoAction(Action action)
Description copied from interface: ActionProcessor
Perform an undo.

Specified by:
undoAction in interface ActionProcessor
Parameters:
action - the action to be undone