dsto.dfc.swing.text
Class TermCustomizer

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by dsto.dfc.swing.forms.AbstractFormEditorComponent
                  extended by dsto.dfc.swing.text.TermCustomizer
All Implemented Interfaces:
FormEditor, ImageObserver, MenuContainer, Customizer, Serializable, Scrollable

public class TermCustomizer
extends AbstractFormEditorComponent
implements Scrollable

An editable rich text view of a Term. Shows the heirachy of CompositeTerm's and the text customizer for each term.

Version:
$Revision$
Author:
Matthew Phillips
See Also:
Term.getCustomizerFormat(), Serialized Form

Nested Class Summary
protected  class TermCustomizer.Document
          The document used for the text display.
 
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
protected static String ADD_IMAGE_URL
           
protected static String DELETE_IMAGE_URL
           
protected  TermCustomizer.Document document
           
protected  HashMap parentMap
           
protected  Term rootTerm
           
protected  ArrayList terms
           
protected  List termTemplates
           
 
Fields inherited from class dsto.dfc.swing.forms.AbstractFormEditorComponent
description
 
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
TermCustomizer()
           
 
Method Summary
 void addChangeListener(ChangeListener l)
           
protected  void addTerm(int termRow)
          Add a term at a given row in the term list.
 void commitEdits()
          Default implementation does nothing.
protected  void customizeTerm(String link)
          Customize a term property represented by a given link from its customizerFormat.
protected  Term customizeTermVisually(Term term, String property)
          Customize a property of a term using its customizer UI.
protected  void fireStateChanged()
           
 Object getEditorValue()
          Get the current value from the form editor.
 CompositeTerm getParent(Term child)
           
 Dimension getPreferredScrollableViewportSize()
           
 Term getRootTerm()
          Get the root term that is being edited.
 int getScrollableBlockIncrement(Rectangle visibleRect, int orientation, int direction)
           
 boolean getScrollableTracksViewportHeight()
           
 boolean getScrollableTracksViewportWidth()
           
 int getScrollableUnitIncrement(Rectangle visibleRect, int orientation, int direction)
           
 List getTermTemplates()
           
 JTextPane getTextPane()
           
 boolean isDirectEdit()
          True if the editor directly edits the value passed in with setValue ().
protected  void linkActivated(String link)
          Called when a hyperlink in the text pane is activated and delegates to customize/remove/addTerm ().
protected  void linkEntered(String link)
          Called when a hyperlink in the text pane is entered and shows tooltip.
protected  void linkExited(String link)
          Called when a hyperlink in the text pane is exited and clears tooltip.
 void removeChangeListener(ChangeListener l)
           
protected  void removeTerm(int termRow)
          Remove the term at a given row in the term list.
protected  void replaceTerm(Term term, Term newTerm, int termRow)
          Replace one term with another at the same location.
protected  Term selectTemplateTerm()
          Show a list of template terms and allow the user to select one.
 void setEditorValue(Object value)
          Sets the value to be displayed/edited by the form editor.
 void setRootTerm(Term newValue)
          Set the term that is to be edited.
 void setTermTemplates(List newValue)
          Set the list of template terms that is presented to the user when the add term button is clicked.
protected  void textifyTerm(ArrayList buffer, Term term, int level)
          Turn a term tree into its textual customizer form.
protected  void updateText()
          Rebuild the text view of the term tree.
 
Methods inherited from class dsto.dfc.swing.forms.AbstractFormEditorComponent
addFormEditorListener, fireEditComitted, fireEditCommitRequested, fireEditCommitted, getEditorComponent, getEditorDescription, getPreferredValueType, removeFormEditorListener, setEditorDescription, setObject
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getAccessibleContext, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, 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, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, paramString, 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, updateUI
 
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
 
Methods inherited from interface java.beans.Customizer
addPropertyChangeListener, removePropertyChangeListener
 

Field Detail

DELETE_IMAGE_URL

protected static final String DELETE_IMAGE_URL

ADD_IMAGE_URL

protected static final String ADD_IMAGE_URL

rootTerm

protected Term rootTerm

document

protected TermCustomizer.Document document

terms

protected ArrayList terms

parentMap

protected HashMap parentMap

termTemplates

protected List termTemplates
Constructor Detail

TermCustomizer

public TermCustomizer()
Method Detail

getParent

public CompositeTerm getParent(Term child)

getTermTemplates

public List getTermTemplates()

setTermTemplates

public void setTermTemplates(List newValue)
Set the list of template terms that is presented to the user when the add term button is clicked. All values in the list must be cloneable Term instances.


getTextPane

public JTextPane getTextPane()

setRootTerm

public void setRootTerm(Term newValue)
Set the term that is to be edited. Synonym for setEditorValue (newValue).


getRootTerm

public Term getRootTerm()
Get the root term that is being edited. Synonym for getEditorValue ().


getEditorValue

public Object getEditorValue()
                      throws IllegalFormatException
Description copied from interface: FormEditor
Get the current value from the form editor. At least one call to setValue () must be made beforehand.

Specified by:
getEditorValue in interface FormEditor
Specified by:
getEditorValue in class AbstractFormEditorComponent
Throws:
IllegalFormatException

setEditorValue

public void setEditorValue(Object value)
                    throws IllegalFormatException
Description copied from interface: FormEditor
Sets the value to be displayed/edited by the form editor.

Specified by:
setEditorValue in interface FormEditor
Specified by:
setEditorValue in class AbstractFormEditorComponent
Parameters:
value - The value to display.
Throws:
IllegalFormatException - if the value was not in the correct format for display by this editor. The source specified by the exception should be this FormEditor instance or a child.

isDirectEdit

public boolean isDirectEdit()
Description copied from interface: FormEditor
True if the editor directly edits the value passed in with setValue (). If false, the parent editor will be reponsible for retrieving the value from the editor and storing it.

Specified by:
isDirectEdit in interface FormEditor
Specified by:
isDirectEdit in class AbstractFormEditorComponent

commitEdits

public void commitEdits()
Description copied from class: AbstractFormEditorComponent
Default implementation does nothing.

Specified by:
commitEdits in interface FormEditor
Overrides:
commitEdits in class AbstractFormEditorComponent

getPreferredScrollableViewportSize

public Dimension getPreferredScrollableViewportSize()
Specified by:
getPreferredScrollableViewportSize in interface Scrollable

getScrollableUnitIncrement

public int getScrollableUnitIncrement(Rectangle visibleRect,
                                      int orientation,
                                      int direction)
Specified by:
getScrollableUnitIncrement in interface Scrollable

getScrollableBlockIncrement

public int getScrollableBlockIncrement(Rectangle visibleRect,
                                       int orientation,
                                       int direction)
Specified by:
getScrollableBlockIncrement in interface Scrollable

getScrollableTracksViewportWidth

public boolean getScrollableTracksViewportWidth()
Specified by:
getScrollableTracksViewportWidth in interface Scrollable

getScrollableTracksViewportHeight

public boolean getScrollableTracksViewportHeight()
Specified by:
getScrollableTracksViewportHeight in interface Scrollable

linkEntered

protected void linkEntered(String link)
Called when a hyperlink in the text pane is entered and shows tooltip.


linkExited

protected void linkExited(String link)
Called when a hyperlink in the text pane is exited and clears tooltip.


linkActivated

protected void linkActivated(String link)
Called when a hyperlink in the text pane is activated and delegates to customize/remove/addTerm ().


removeTerm

protected void removeTerm(int termRow)
Remove the term at a given row in the term list.

Parameters:
termRow - The absolute row of the term in the tree of terms.

addTerm

protected void addTerm(int termRow)
Add a term at a given row in the term list.

Parameters:
termRow - The absolute row of the term in the tree of terms.

replaceTerm

protected void replaceTerm(Term term,
                           Term newTerm,
                           int termRow)
                    throws IllegalArgumentException
Replace one term with another at the same location.

Parameters:
term - The old term.
newTerm - The new term.
termRow - The absolute row in the tree that term is at.
Throws:
IllegalArgumentException - if attempt is made to replace root term.

customizeTerm

protected void customizeTerm(String link)
Customize a term property represented by a given link from its customizerFormat.


customizeTermVisually

protected Term customizeTermVisually(Term term,
                                     String property)
Customize a property of a term using its customizer UI.

Parameters:
term - The term.
property - The property to be edited.
Returns:
The edited term, or null if editing was cancelled.

selectTemplateTerm

protected Term selectTemplateTerm()
Show a list of template terms and allow the user to select one.

Returns:
The selected term (an instance from termTemplates) or null if editor was cancelled.

updateText

protected void updateText()
Rebuild the text view of the term tree.


textifyTerm

protected void textifyTerm(ArrayList buffer,
                           Term term,
                           int level)
                    throws BadLocationException
Turn a term tree into its textual customizer form.

Parameters:
buffer - The buffer to add the generated ElementSpec's to.
term - The root of the term tree to textify.
level - The child nesting level (should be 0 for root).
Throws:
BadLocationException

removeChangeListener

public void removeChangeListener(ChangeListener l)

addChangeListener

public void addChangeListener(ChangeListener l)

fireStateChanged

protected void fireStateChanged()


Copyright © 2008 Commonwealth of Australia