org.formaria.editor.visualizer
Class ModelVisualiserTree

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.formaria.editor.visualizer.ModelVisualiserTree
All Implemented Interfaces:
java.awt.event.MouseListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, java.util.EventListener, javax.accessibility.Accessible, javax.swing.event.TreeSelectionListener, javax.swing.event.TreeWillExpandListener, ModelListener

public class ModelVisualiserTree
extends javax.swing.JPanel
implements javax.swing.event.TreeSelectionListener, java.awt.event.MouseListener, javax.swing.event.TreeWillExpandListener, ModelListener

Panel which contains the JTree representation of the DataModel. The JTree is contained within a scrollpane. The model is updated as data items are added from the ALib editor. Whenever a component is seleted the setActiveComponents fuction is called with a Vector of type ComponentSizer so that the data node for the component can be selected. Double clicking a node will cause the currently selected components data property to be set.

Copyright (c) Formaria Ltd., 2001-2006, This software is licensed under the GNU Public License (GPL), please see license.txt for more details. If you make commercial use of this software you must purchase a commercial license from Formaria.

$Revision: 1.14 $

See Also:
Serialized Form

Nested Class Summary
protected  class ModelVisualiserTree.VisualizerMutableTreeNode
           
 
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.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.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
ModelVisualiserTree(ModelVisualiserPanel mvp)
          Setup a BorderLayout manager.
 
Method Summary
 void addMessageNode(java.lang.String message)
           
 void addMouseListener(java.awt.event.MouseListener l)
           
 void addTreeSelectionListener(javax.swing.event.TreeSelectionListener l)
           
 void createTreeComp(java.lang.String selected)
          If the tree already exists remove it from the panel.
 void expandRoot()
          expand the root node.
 void expandSelectedNode(ModelVisualiserTree.VisualizerMutableTreeNode treeNode)
           
 void expandSelectedPath(java.lang.String path)
           
 java.lang.String getModelPath(DataModel model)
           
 javax.swing.tree.TreePath getSelectionPath()
           
 java.lang.String getStrippedPath()
          Strips the path of the value text
 java.lang.String getStrippedPath(javax.swing.tree.TreePath treePath)
           
 javax.swing.JTree getTreeComponent()
           
 void modelChanged()
          This is called when the model has beed updated from the Aria editor.
 void mouseClicked(java.awt.event.MouseEvent me)
           
 void mouseEntered(java.awt.event.MouseEvent me)
           
 void mouseExited(java.awt.event.MouseEvent me)
           
 void mousePressed(java.awt.event.MouseEvent me)
           
 void mouseReleased(java.awt.event.MouseEvent me)
           
 void refresh()
          Reconstruct the tree.
protected  void refreshTree()
          Refresh tree model representation
 void removeMouseListener(java.awt.event.MouseListener l)
           
 void removeTreeSelectionListener(javax.swing.event.TreeSelectionListener l)
           
 void setModelTreeListner(ModelTreeListener mtl)
           
 void setRootModel(DataModel root)
          Set the root mode node displayed by this visualizer
 void setSelectedPath(java.lang.String path)
           
 java.lang.String stripQuotes(java.lang.String str)
           
 void treeWillCollapse(javax.swing.event.TreeExpansionEvent event)
          Invoked whenever a node in the tree is about to be collapsed.
 void treeWillExpand(javax.swing.event.TreeExpansionEvent event)
          Invoked whenever a node in the tree is about to be expanded.
 void valueChanged(javax.swing.event.TreeSelectionEvent evt)
           
 
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, 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, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, 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, 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, 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
 

Constructor Detail

ModelVisualiserTree

public ModelVisualiserTree(ModelVisualiserPanel mvp)
Setup a BorderLayout manager. Call the function to create the tree with no selection.

Method Detail

getModelPath

public java.lang.String getModelPath(DataModel model)

addTreeSelectionListener

public void addTreeSelectionListener(javax.swing.event.TreeSelectionListener l)

removeTreeSelectionListener

public void removeTreeSelectionListener(javax.swing.event.TreeSelectionListener l)

addMouseListener

public void addMouseListener(java.awt.event.MouseListener l)
Overrides:
addMouseListener in class java.awt.Component

removeMouseListener

public void removeMouseListener(java.awt.event.MouseListener l)
Overrides:
removeMouseListener in class java.awt.Component

getSelectionPath

public javax.swing.tree.TreePath getSelectionPath()

setRootModel

public void setRootModel(DataModel root)
Set the root mode node displayed by this visualizer

Parameters:
root - the root of the node hierarchy

addMessageNode

public void addMessageNode(java.lang.String message)

refresh

public void refresh()
Reconstruct the tree. This is called when the model has been updated.


modelChanged

public void modelChanged()
This is called when the model has beed updated from the Aria editor.

Specified by:
modelChanged in interface ModelListener

createTreeComp

public void createTreeComp(java.lang.String selected)
If the tree already exists remove it from the panel. Get a reference to the DataModel base node. Contruct a new JTree and call the createTree function with the selected parameter.

Parameters:
selected - the path to the seleted DataModel node

setModelTreeListner

public void setModelTreeListner(ModelTreeListener mtl)

treeWillExpand

public void treeWillExpand(javax.swing.event.TreeExpansionEvent event)
                    throws javax.swing.tree.ExpandVetoException
Invoked whenever a node in the tree is about to be expanded.

Specified by:
treeWillExpand in interface javax.swing.event.TreeWillExpandListener
Throws:
javax.swing.tree.ExpandVetoException

treeWillCollapse

public void treeWillCollapse(javax.swing.event.TreeExpansionEvent event)
                      throws javax.swing.tree.ExpandVetoException
Invoked whenever a node in the tree is about to be collapsed.

Specified by:
treeWillCollapse in interface javax.swing.event.TreeWillExpandListener
Throws:
javax.swing.tree.ExpandVetoException

valueChanged

public void valueChanged(javax.swing.event.TreeSelectionEvent evt)
Specified by:
valueChanged in interface javax.swing.event.TreeSelectionListener

getStrippedPath

public java.lang.String getStrippedPath()
Strips the path of the value text

Returns:
the stripped path

getStrippedPath

public java.lang.String getStrippedPath(javax.swing.tree.TreePath treePath)

stripQuotes

public java.lang.String stripQuotes(java.lang.String str)

setSelectedPath

public void setSelectedPath(java.lang.String path)

expandSelectedPath

public void expandSelectedPath(java.lang.String path)

mouseClicked

public void mouseClicked(java.awt.event.MouseEvent me)
Specified by:
mouseClicked in interface java.awt.event.MouseListener

mousePressed

public void mousePressed(java.awt.event.MouseEvent me)
Specified by:
mousePressed in interface java.awt.event.MouseListener

mouseReleased

public void mouseReleased(java.awt.event.MouseEvent me)
Specified by:
mouseReleased in interface java.awt.event.MouseListener

mouseExited

public void mouseExited(java.awt.event.MouseEvent me)
Specified by:
mouseExited in interface java.awt.event.MouseListener

mouseEntered

public void mouseEntered(java.awt.event.MouseEvent me)
Specified by:
mouseEntered in interface java.awt.event.MouseListener

expandRoot

public void expandRoot()
expand the root node.


getTreeComponent

public javax.swing.JTree getTreeComponent()

refreshTree

protected void refreshTree()
Refresh tree model representation


expandSelectedNode

public void expandSelectedNode(ModelVisualiserTree.VisualizerMutableTreeNode treeNode)