kiwi.ui
Class WorkspaceEditor

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--javax.swing.JComponent
                    |
                    +--javax.swing.JInternalFrame
                          |
                          +--kiwi.ui.WorkspaceEditor

public abstract class WorkspaceEditor
extends JInternalFrame
implements ActionListener

An abstract class that defines common behavior for all workspace editors. This class should be extended to provide the appropriate user interface and behavior for editing a specific type of problem domain object. Editors are managed by a WorkspaceManager, which provides some rudimentary inter-editor coordination, persistence support, and other useful facilities.

Version:
1.1 (10/98)
Author:
Mark Lindner, PING Software Group
See Also:
WorkspaceManager, Serialized Form

Inner classes inherited from class javax.swing.JInternalFrame
JInternalFrame.AccessibleJInternalFrame, JInternalFrame.JDesktopIcon
 
Inner classes inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
 
Field Summary
protected  Object object
          The problem domain object associated with this editor.
 
Fields inherited from class javax.swing.JInternalFrame
closable, CONTENT_PANE_PROPERTY, desktopIcon, FRAME_ICON_PROPERTY, frameIcon, GLASS_PANE_PROPERTY, iconable, IS_CLOSED_PROPERTY, IS_ICON_PROPERTY, IS_MAXIMUM_PROPERTY, IS_SELECTED_PROPERTY, isClosed, isIcon, isMaximum, isSelected, LAYERED_PANE_PROPERTY, maximizable, MENU_BAR_PROPERTY, resizable, ROOT_PANE_PROPERTY, rootPane, rootPaneCheckingEnabled, title, TITLE_PROPERTY
 
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
 
Constructor Summary
WorkspaceEditor()
          Construct a new WorkspaceEditor with a default window title.
WorkspaceEditor(String title)
          Construct a new editable WorkspaceEditor with the given window title.
WorkspaceEditor(String title, boolean editable)
          Construct a new WorkspaceEditor with the given window title and editable mode.
 
Method Summary
 void actionPerformed(ActionEvent evt)
          Handle events.
 void beginFocus()
          Give keyboard focus to the first text input component in this editor.
protected abstract  Component buildEditingUI()
          Build the editing UI.
protected  JMenuBar buildMenuBar()
          Construct the menu bar for this editor.
 void copy()
          Invoke a copy action on this editor.
 void cut()
          Invoke a cut action on this editor.
protected  void fireStateChanged()
          Fire an editor state changed event.
 Object getObject()
          Get the current problem domain object associated with this editor, or null if there is no object associated with the editor.
protected  WorkspaceManager getWorkspaceManager()
          Get the WorkspaceManager for this editor.
 boolean hasUnsavedChanges()
          Determine if this editor is displaying unsaved changes.
 boolean isEditable()
          Determine if the editor is editable.
 void paste()
          Invoke a paste action on this editor.
protected  void registerMouseInputComponent(Component c)
          Register a mouse input component.
protected  void registerTextInputComponent(JTextComponent c)
          Register a text input component.
abstract  boolean save()
          Persist the edits made in this editor.
protected  void setChangesMade(boolean flag)
          Set the changes made flag on this editor.
protected  void setComment(String comment)
          Set the comment that appears in the top portion of the editor.
 void setObject(Object object)
          Set the problem domain object to be associated with this editor.
protected  void startEditing()
          Start editing in this editor.
protected  void stopEditing()
          Start editing in this editor.
protected abstract  void updateEditingUI()
          Update the editing UI.
 
Methods inherited from class javax.swing.JInternalFrame
addImpl, addInternalFrameListener, createRootPane, dispose, fireInternalFrameEvent, getAccessibleContext, getBackground, getContentPane, getDefaultCloseOperation, getDesktopIcon, getDesktopPane, getForeground, getFrameIcon, getGlassPane, getJMenuBar, getLayer, getLayeredPane, getMenuBar, getRootPane, getTitle, getUI, getUIClassID, getWarningString, isClosable, isClosed, isIcon, isIconifiable, isMaximizable, isMaximum, isResizable, isRootPaneCheckingEnabled, isSelected, moveToBack, moveToFront, pack, paramString, removeInternalFrameListener, reshape, setBackground, setClosable, setClosed, setContentPane, setDefaultCloseOperation, setDesktopIcon, setForeground, setFrameIcon, setGlassPane, setIcon, setIconifiable, setJMenuBar, setLayer, setLayeredPane, setLayout, setMaximizable, setMaximum, setMenuBar, setResizable, setRootPane, setRootPaneCheckingEnabled, setSelected, setTitle, setUI, setVisible, show, toBack, toFront, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getAlignmentX, getAlignmentY, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getGraphics, getHeight, getInsets, getInsets, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getRegisteredKeyStrokes, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getVisibleRect, getWidth, getX, getY, grabFocus, hasFocus, isDoubleBuffered, isFocusCycleRoot, isFocusTraversable, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, processComponentKeyEvent, processFocusEvent, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, resetKeyboardActions, revalidate, scrollRectToVisible, setAlignmentX, setAlignmentY, setAutoscrolls, setBorder, setDebugGraphicsOptions, setDoubleBuffered, setEnabled, setFont, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setUI, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getLayout, insets, invalidate, isAncestorOf, layout, list, list, locate, minimumSize, paintComponents, preferredSize, print, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addPropertyChangeListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, getBounds, getColorModel, getComponentOrientation, getCursor, getDropTarget, getFont, getFontMetrics, getInputContext, getInputMethodRequests, getLocale, getLocation, getLocationOnScreen, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hide, imageUpdate, inside, isDisplayable, isEnabled, isLightweight, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, printAll, processComponentEvent, processInputMethodEvent, processMouseEvent, remove, removeComponentListener, removeFocusListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setLocale, setLocation, setLocation, setName, setSize, setSize, show, size, toString, transferFocus
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

object

protected Object object
The problem domain object associated with this editor.
Constructor Detail

WorkspaceEditor

public WorkspaceEditor()
Construct a new WorkspaceEditor with a default window title. It is created as editable.

WorkspaceEditor

public WorkspaceEditor(String title)
Construct a new editable WorkspaceEditor with the given window title.
Parameters:
title - The title for the editor's window.

WorkspaceEditor

public WorkspaceEditor(String title,
                       boolean editable)
Construct a new WorkspaceEditor with the given window title and editable mode.
Parameters:
title - The title for the editor's window.
editable - A flag specifying whether the editor will be editable.
Method Detail

getWorkspaceManager

protected final WorkspaceManager getWorkspaceManager()
Get the WorkspaceManager for this editor. The method will return null if the editor has not yet been added to a workspace (that is, a JDesktopPane).

buildEditingUI

protected abstract Component buildEditingUI()
Build the editing UI. Subclasses must implement this method to build the user interface for the editor.

updateEditingUI

protected abstract void updateEditingUI()
Update the editing UI. Subclasses must implement this method to update the state of the user interface when a new problem domain object is associated with this editor.

setComment

protected void setComment(String comment)
Set the comment that appears in the top portion of the editor.

buildMenuBar

protected JMenuBar buildMenuBar()
Construct the menu bar for this editor. The default implementation returns null, which signifies that no menubar is needed.

beginFocus

public final void beginFocus()
Give keyboard focus to the first text input component in this editor. These components are registered via registerTextInputComponent().

actionPerformed

public void actionPerformed(ActionEvent evt)
Handle events. The default implementation of this method does nothing; subclassers may override it to handle specific user interface events.
Specified by:
actionPerformed in interface ActionListener

getObject

public final Object getObject()
Get the current problem domain object associated with this editor, or null if there is no object associated with the editor.
Returns:
The object currently associated with this editor.
See Also:
setObject(java.lang.Object)

setObject

public final void setObject(Object object)
Set the problem domain object to be associated with this editor. This method ultimately results in a call to updateEditingUI().
Parameters:
object - The new object to be associated with this editor.
See Also:
getObject()

hasUnsavedChanges

public final boolean hasUnsavedChanges()
Determine if this editor is displaying unsaved changes.
Returns:
true if there are unsaved changes, and false otherwise.
See Also:
setChangesMade(boolean)

setChangesMade

protected final void setChangesMade(boolean flag)
Set the changes made flag on this editor. The editor checks this flag at close time to determine if changes need to be saved.
Parameters:
flag - The new value for the flag.
See Also:
hasUnsavedChanges()

save

public abstract boolean save()
Persist the edits made in this editor.
Returns:
true if the save was successful and false otherwise.

isEditable

public final boolean isEditable()
Determine if the editor is editable.
Returns:
true if the editor is editable, and false otherwise.

registerTextInputComponent

protected final void registerTextInputComponent(JTextComponent c)
Register a text input component. This method is used by subclassers to notify the editor of input fields in the user interface. The editor uses this information when requesting focus, and also listens for keypress events on all of these components, setting the changes made flag to true when one occurs.
Parameters:
c - The component to register.
See Also:
registerMouseInputComponent(java.awt.Component)

registerMouseInputComponent

protected final void registerMouseInputComponent(Component c)
Register a mouse input component. This method is used by subclassers to notify the editor of components that change the state of the data being edited when they are clicked. The editor listens for mouse events on all of these components, setting the changes made flag to true when one occurs.
Parameters:
c - The component to register.
See Also:
registerTextInputComponent(javax.swing.text.JTextComponent)

startEditing

protected void startEditing()
Start editing in this editor. This method is called whenever the editor is activated in the workspace. The default implementation does nothing.
See Also:
stopEditing()

stopEditing

protected void stopEditing()
Start editing in this editor. This method is called whenever the editor is deactivated in the workspace. The default implementation does nothing.
See Also:
startEditing()

copy

public final void copy()
Invoke a copy action on this editor. The text in the text input component that currently has focus (if any) is copied to the system clipboard.

cut

public final void cut()
Invoke a cut action on this editor. The text in the text input component that currently has focus (if any) is moved to the system clipboard.

paste

public final void paste()
Invoke a paste action on this editor. The text in the system clipboard is copied to the text input component that currently has focus (if any).

fireStateChanged

protected final void fireStateChanged()
Fire an editor state changed event. Notifies listeners that the internal state of this editor has changed in some way.