hypercast.util
Class HypercastConfigurator

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--javax.swing.JComponent
                    |
                    +--javax.swing.JPanel
                          |
                          +--hypercast.util.HypercastConfigurator
All Implemented Interfaces:
javax.accessibility.Accessible, java.awt.event.ActionListener, java.util.EventListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.awt.event.MouseListener, java.io.Serializable, javax.swing.event.TreeSelectionListener

public class HypercastConfigurator
extends javax.swing.JPanel
implements java.awt.event.ActionListener, javax.swing.event.TreeSelectionListener, java.awt.event.MouseListener

This class defines a Hypercast configuration file generator. It can generates a new Hypercast configuration file from a Hypercast schema file, or from a existing configuration file. It contains a GUI for the users to edit the contents of a configuration file.

See Also:
Serialized Form

Field Summary
static int COMBOX_HEIGHT
           
static int COMBOX_WIDTH
           
static boolean debug
          Debug flag.
static java.lang.String DEFAULT_FILENAME
          The name of the default configulation file.
static int FRAME_HEIGHT
           
static int FRAME_WIDTH
          static constants for GUI components.
static int LABEL_HEIGHT
           
static int LABEL_WIDTH
           
static java.lang.String ROOT_ATTRIBUTE_ELEMENT_NAME
          The root element name in the schema file.
static int SPINNER_HEIGHT
           
static int SPINNER_WIDTH
           
static int SPINNERFORNUMBER_WIDTH
           
static int TEXTFIELD_HEIGHT
           
static int TEXTFIELD_WIDTH
           
 
Fields inherited from class javax.swing.JComponent
TOOL_TIP_TEXT_KEY, 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
HypercastConfigurator()
          Contructor.
HypercastConfigurator(java.io.File schemafile)
          Contructor.
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent e)
          Callback for menu items.
static void collapseAll(javax.swing.JTree tree)
           
static void collapseAll(javax.swing.JTree tree, java.lang.Object node)
           
static void collapseAll(javax.swing.JTree tree, javax.swing.tree.TreePath path)
           
static void expandAll(javax.swing.JTree tree)
           
static void expandAll(javax.swing.JTree tree, java.lang.Object node)
           
static void expandAll(javax.swing.JTree tree, javax.swing.tree.TreePath path)
           
static java.util.Collection extremalPaths(javax.swing.tree.TreeModel data, javax.swing.tree.TreePath path, java.util.Collection result)
          The "extremal paths" of the tree model's subtree starting at path.
static org.w3c.dom.Element findPropertyElement(org.w3c.dom.Document doc)
          Find the property Element in the given Document.
static org.w3c.dom.Element findPropertyElement(org.w3c.dom.Document doc, java.lang.String rootElementName)
          Find the property Element in the given Document.
static java.util.Vector getChildrenOfComplexElement(org.w3c.dom.Element e)
          Get children of this Element.
 java.util.Properties getDefaultProperties()
          Build the defaultvalue properties object from schema file.
static org.w3c.dom.Element getRestrictionElement(org.w3c.dom.Element e)
          Get the Element which defines restrition for given simpleType Element.
static boolean hasChoiceOnChildren(org.w3c.dom.Element e)
          Check if this Element has a sequence of children.
 void initializeDisplay()
          Initialize GUI parameters and display GUI.
static boolean isComplexElement(org.w3c.dom.Element e)
          Check if this Element has a "complex" child.
static void main(java.lang.String[] args)
           
 void mouseClicked(java.awt.event.MouseEvent e)
          The callback for mouse click event on a tree node.
 void mouseEntered(java.awt.event.MouseEvent e)
          The callback for mouse enter event on a tree node.
 void mouseExited(java.awt.event.MouseEvent e)
          The callback for mouse exit event on a tree node.
 void mousePressed(java.awt.event.MouseEvent e)
          The callback for mouse press event on a tree node.
 void mouseReleased(java.awt.event.MouseEvent e)
          The callback for mouse release event on a tree node.
 void stateChanged(javax.swing.event.ChangeEvent e)
          The callback for ToggleButtons; sets the appropriate ones visible.
 void updateDependent(javax.swing.JPanel jp, javax.swing.JTree jtree, javax.swing.tree.DefaultMutableTreeNode parentNode)
          Update the number and displaying of child nodes which are dependents under given tree node in the jtree.
 void updateDependent(javax.swing.JPanel jp, javax.swing.JTree jtree, javax.swing.tree.DefaultMutableTreeNode parentNode, int dependentNum, java.lang.String dependentName)
          Update the number and displaying of dependent nodes (they have the same name as the given parameter) in the jtree.
 void valueChanged(javax.swing.event.TreeSelectionEvent e)
          The callback for tree node selection.
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, 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, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, 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, paintImmediately, paintImmediately, print, printAll, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, 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, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, 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, remove, remove, removeAll, removeContainerListener, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setLayout, transferFocusBackward, transferFocusDownCycle, validate
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, contains, createImage, createImage, createVolatileImage, createVolatileImage, dispatchEvent, enable, 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, 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
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

debug

public static final boolean debug
Debug flag.

See Also:
Constant Field Values

FRAME_WIDTH

public static final int FRAME_WIDTH
static constants for GUI components.

See Also:
Constant Field Values

FRAME_HEIGHT

public static final int FRAME_HEIGHT
See Also:
Constant Field Values

LABEL_WIDTH

public static final int LABEL_WIDTH
See Also:
Constant Field Values

LABEL_HEIGHT

public static final int LABEL_HEIGHT
See Also:
Constant Field Values

COMBOX_WIDTH

public static final int COMBOX_WIDTH
See Also:
Constant Field Values

COMBOX_HEIGHT

public static final int COMBOX_HEIGHT
See Also:
Constant Field Values

SPINNER_WIDTH

public static final int SPINNER_WIDTH
See Also:
Constant Field Values

SPINNER_HEIGHT

public static final int SPINNER_HEIGHT
See Also:
Constant Field Values

SPINNERFORNUMBER_WIDTH

public static final int SPINNERFORNUMBER_WIDTH
See Also:
Constant Field Values

TEXTFIELD_WIDTH

public static final int TEXTFIELD_WIDTH
See Also:
Constant Field Values

TEXTFIELD_HEIGHT

public static final int TEXTFIELD_HEIGHT
See Also:
Constant Field Values

ROOT_ATTRIBUTE_ELEMENT_NAME

public static final java.lang.String ROOT_ATTRIBUTE_ELEMENT_NAME
The root element name in the schema file.

See Also:
Constant Field Values

DEFAULT_FILENAME

public static final java.lang.String DEFAULT_FILENAME
The name of the default configulation file.

See Also:
Constant Field Values
Constructor Detail

HypercastConfigurator

public HypercastConfigurator()
Contructor.


HypercastConfigurator

public HypercastConfigurator(java.io.File schemafile)
Contructor.

Method Detail

initializeDisplay

public void initializeDisplay()
Initialize GUI parameters and display GUI.


main

public static void main(java.lang.String[] args)

stateChanged

public void stateChanged(javax.swing.event.ChangeEvent e)

The callback for ToggleButtons; sets the appropriate ones visible.

Parameters:
e - ChangeEvent for the button

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent e)

Callback for menu items.

Specified by:
actionPerformed in interface java.awt.event.ActionListener
Parameters:
e - ActionEvent object to determine which item called this.

getDefaultProperties

public java.util.Properties getDefaultProperties()
Build the defaultvalue properties object from schema file.


collapseAll

public static void collapseAll(javax.swing.JTree tree)

collapseAll

public static void collapseAll(javax.swing.JTree tree,
                               java.lang.Object node)

collapseAll

public static void collapseAll(javax.swing.JTree tree,
                               javax.swing.tree.TreePath path)

expandAll

public static void expandAll(javax.swing.JTree tree)

expandAll

public static void expandAll(javax.swing.JTree tree,
                             java.lang.Object node)

expandAll

public static void expandAll(javax.swing.JTree tree,
                             javax.swing.tree.TreePath path)

extremalPaths

public static java.util.Collection extremalPaths(javax.swing.tree.TreeModel data,
                                                 javax.swing.tree.TreePath path,
                                                 java.util.Collection result)
The "extremal paths" of the tree model's subtree starting at path. The extremal paths are those paths that a) are non-leaves and b) have only leaf children, if any. It suffices to know these to know all non-leaf paths in the subtree, and those are the ones that matter for expansion (since the concept of expan- sion only applies to non-leaves). The extremal paths of a leaves is an empty collection. This method uses the usual collection filling idiom, i.e. clear and then fill the collection that it is given, and for convenience return it. The extremal paths are stored in the order in which they appear in pre-order in the tree model.


valueChanged

public void valueChanged(javax.swing.event.TreeSelectionEvent e)

The callback for tree node selection.

Specified by:
valueChanged in interface javax.swing.event.TreeSelectionListener
Parameters:
e - TreeSelectionEvent event from the tree.

mouseClicked

public void mouseClicked(java.awt.event.MouseEvent e)

The callback for mouse click event on a tree node.

Specified by:
mouseClicked in interface java.awt.event.MouseListener
Parameters:
e - a MouseEvent event from the tree.

mouseEntered

public void mouseEntered(java.awt.event.MouseEvent e)

The callback for mouse enter event on a tree node.

It is ignored.

Specified by:
mouseEntered in interface java.awt.event.MouseListener
Parameters:
e - a MouseEvent event from the tree.

mouseExited

public void mouseExited(java.awt.event.MouseEvent e)

The callback for mouse exit event on a tree node.

It is ignored.

Specified by:
mouseExited in interface java.awt.event.MouseListener
Parameters:
e - a MouseEvent event from the tree.

mousePressed

public void mousePressed(java.awt.event.MouseEvent e)

The callback for mouse press event on a tree node.

It is ignored.

Specified by:
mousePressed in interface java.awt.event.MouseListener
Parameters:
e - a MouseEvent event from the tree.

mouseReleased

public void mouseReleased(java.awt.event.MouseEvent e)

The callback for mouse release event on a tree node.

It is ignored.

Specified by:
mouseReleased in interface java.awt.event.MouseListener
Parameters:
e - a MouseEvent event from the tree.

hasChoiceOnChildren

public static boolean hasChoiceOnChildren(org.w3c.dom.Element e)
Check if this Element has a sequence of children.


isComplexElement

public static boolean isComplexElement(org.w3c.dom.Element e)
Check if this Element has a "complex" child.


getChildrenOfComplexElement

public static java.util.Vector getChildrenOfComplexElement(org.w3c.dom.Element e)
Get children of this Element.


findPropertyElement

public static org.w3c.dom.Element findPropertyElement(org.w3c.dom.Document doc)
Find the property Element in the given Document. This Element is the starting point for building displaying tree. This method assume the schema file has fixed format to reach the property Element.

Parameters:
doc - A Document instance.
Returns:
the Element which has attribute "name = ROOT_ATTRIBUTE_ELEMENT_NAME".

findPropertyElement

public static org.w3c.dom.Element findPropertyElement(org.w3c.dom.Document doc,
                                                      java.lang.String rootElementName)
Find the property Element in the given Document. This Element is the starting point for building displaying tree. This method assume the schema file has fixed format to reach the property Element.

Parameters:
doc - A Document instance.
rootElementName - The Element name of the root for all attributes.
Returns:
the Element which has attribute "name = rootElemenName".

getRestrictionElement

public static org.w3c.dom.Element getRestrictionElement(org.w3c.dom.Element e)
Get the Element which defines restrition for given simpleType Element.

Parameters:
e - Element in the configuration document.
Returns:
the restrition definition Element.

updateDependent

public void updateDependent(javax.swing.JPanel jp,
                            javax.swing.JTree jtree,
                            javax.swing.tree.DefaultMutableTreeNode parentNode,
                            int dependentNum,
                            java.lang.String dependentName)
Update the number and displaying of dependent nodes (they have the same name as the given parameter) in the jtree.

Parameters:
jp - A JPanel instance for editing a tree node.
jtree - JTree instance which contains the given node.
parentNode - The parent of the dependent nodes.
dependentNum - The new number of dependent nodes.
dependentName - The name of dependent nodes.

updateDependent

public void updateDependent(javax.swing.JPanel jp,
                            javax.swing.JTree jtree,
                            javax.swing.tree.DefaultMutableTreeNode parentNode)
Update the number and displaying of child nodes which are dependents under given tree node in the jtree.

Parameters:
jp - A JPanel instance for editing a tree node.
jtree - JTree instance which contains the given node.
parentNode - The parent of the dependent nodes.