ucar.unidata.ui
Class XmlUi

java.lang.Object
  extended by ucar.unidata.ui.XmlUi
All Implemented Interfaces:
ActionListener, ItemListener, EventListener
Direct Known Subclasses:
IdvXmlUi

public class XmlUi
extends Object
implements ActionListener, ItemListener

This class can create a UI from a "skin" xml. See the file ../apps/example/docs/xmlui.html for further details.


Nested Class Summary
static interface XmlUi.ActionHandler
          Interface to pass ActionEvents to along with this XmlUI object
static class XmlUi.CardPanel
          Class CardPanel Holds a card layout state
 
Field Summary
static String ACTION_MENUPOPUP
          Action command for popping up a menu
static String ACTION_SETBORDER
          Action procedure
static String ACTION_SETTEXT
          Action procedure
static String ACTION_UI_FLIP
          Action command for flpping through a card layout
static String ACTION_UI_FOCUS
          Action command for flpping through a card layout
static String ACTION_UI_GROUP_NEXT
          Action procedure
static String ACTION_UI_GROUP_PREV
          Action procedure
static String[] ALIGN_NAMES
          alignment names
static int[] ALIGN_VALUES
          corresponding alignment values
static String[] ANCHOR_NAMES
          grid bag anchors
static int[] ANCHOR_VALUES
          corresponding grid bag anchor values
static String ATTR_ACTION
          xml attribute name
static String ATTR_ACTIONTEMPLATE
          xml attribute name
static String ATTR_ALIGN
          xml attribute name
static String ATTR_ANCHOR
          xml attribute name
static String ATTR_BGCOLOR
          xml attribute name
static String ATTR_BORDER
          xml attribute name
static String ATTR_BORDER_BOTTOM
          xml attribute name
static String ATTR_BORDER_COLOR
          xml attribute name
static String ATTR_BORDER_HINSET
          xml attribute name
static String ATTR_BORDER_INSET
          xml attribute name
static String ATTR_BORDER_LEFT
          xml attribute name
static String ATTR_BORDER_RIGHT
          xml attribute name
static String ATTR_BORDER_THICKNESS
          xml attribute name
static String ATTR_BORDER_TITLE
          xml attribute name
static String ATTR_BORDER_TOP
          xml attribute name
static String ATTR_BORDER_VINSET
          xml attribute name
static String ATTR_BSPACE
          Bottom space for insets
static String ATTR_CATEGORY
          Category attribute for treepanel
static String ATTR_CATEGORYCOMPONENT
          Used to define that the component is the category component for a tree panel
static String ATTR_CLASS
          xml attribute name
static String ATTR_COLS
          xml attribute name
static String ATTR_COLWIDTHS
          xml attribute name
static String ATTR_CONTINUOUS
          xml attribute name
static String ATTR_DEFAULT
          xml attribute name
static String ATTR_DIVIDER
          xml attribute name
static String ATTR_DOWNIMAGE
          xml attribute name
static String ATTR_EDITABLE
          Used for the combobox tag to define if the combobox is editable
static String ATTR_EVENT
          xml attribute name
static String ATTR_FGCOLOR
          xml attribute name
static String ATTR_FILL
          xml attribute name
static String ATTR_FLOAT
          xml attribute name
static String ATTR_FONTFACE
          xml attribute name
static String ATTR_FONTSIZE
          xml attribute name
static String ATTR_FONTSTYLE
          xml attribute name
static String ATTR_GROUP
          xml attribute name
static String ATTR_HEIGHT
          xml attribute name
static String ATTR_HPOSITION
          xml attribute name
static String ATTR_HSCROLL
          xml attribute name
static String ATTR_HSPACE
          xml attribute name
static String ATTR_ICON
          xml attribute name
static String ATTR_ID
          xml attribute name
static String ATTR_IDREF
          xml attribute name
static String ATTR_IMAGE
          xml attribute name
static String ATTR_IMAGEHEIGHT
          xml attribute name
static String ATTR_IMAGEWIDTH
          xml attribute name
static String ATTR_KEYPRESS
          xml attribute name
static String ATTR_LABEL
          xml attribute name
static String ATTR_LAYOUT
          xml attribute name
static String ATTR_LSPACE
          Left space for insets
static String ATTR_MARGIN
          xml attribute name
static String ATTR_MNEMONIC
          xml attribute name
static String ATTR_MOUSE_CLICK
          xml attribute name
static String ATTR_MOUSE_ENTER
          xml attribute name
static String ATTR_MOUSE_EXIT
          xml attribute name
static String ATTR_NAME
          xml attribute name
static String ATTR_ONETOUCHEXPANDABLE
          xml attribute name
static String ATTR_ORIENTATION
          xml attribute name
static String ATTR_OVERIMAGE
          xml attribute name
static String ATTR_PLACE
          xml attribute name
static String ATTR_PREF_HEIGHT
          xml attribute name
static String ATTR_PREF_WIDTH
          xml attribute name
static String ATTR_RESIZEWEIGHT
          xml attribute name
static String ATTR_ROWHEIGHTS
          xml attribute name
static String ATTR_ROWS
          xml attribute name
static String ATTR_RSPACE
          Right space for insets
static String ATTR_SELECTIMAGE
          xml attribute name
static String ATTR_SPACE
          xml attribute name
static String ATTR_TABBORDERBOTTOM
          xml attribute name
static String ATTR_TABBORDERLEFT
          xml attribute name
static String ATTR_TABBORDERRIGHT
          xml attribute name
static String ATTR_TABBORDERTOP
          xml attribute name
static String ATTR_TABINSETS
          xml attribute name
static String ATTR_TABNESTED
          xml attribute name
static String ATTR_TABPAD
          xml attribute name
static String ATTR_TABPLACE
          xml attribute name
static String ATTR_TABTOOLTIP
          xml attribute name
static String ATTR_TAGCLASS
          xml attribute name
static String ATTR_TEMPLATE
          xml attribute name
static String ATTR_TEXT
          xml attribute name
static String ATTR_TITLE
          xml attribute name
static String ATTR_TOOLTIP
          xml attribute name
static String ATTR_TREEWIDTH
          xml attribute name
static String ATTR_TSPACE
          Top space for insets
static String ATTR_URL
          xml attribute name
static String ATTR_USESPLITPANE
          xml attribute name
static String ATTR_VALUE
          xml attribute name
static String ATTR_VPOSITION
          xml attribute name
static String ATTR_VSCROLL
          xml attribute name
static String ATTR_VSPACE
          xml attribute name
static String ATTR_WIDTH
          xml attribute name
static String ATTR_X
          xml attribute name
static String ATTR_Y
          xml attribute name
static String BORDER_BEVEL
          border type
static String BORDER_BEVEL_LOWERED
          border type
static String BORDER_BEVEL_RAISED
          border type
static String BORDER_BUTTON
          border type
static String BORDER_EMPTY
          border type
static String BORDER_ETCHED
          border type
static String BORDER_ETCHED_LOWERED
          border type
static String BORDER_ETCHED_RAISED
          border type
static String BORDER_LINE
          border type
static String BORDER_MATTE
          border type
static String BORDER_TITLED
          border type
static String[] FILL_NAMES
          fill names
static int[] FILL_VALUES
          corresponding fill valus
static String[] FLOWLAYOUT_NAMES
          flow layout names
static int[] FLOWLAYOUT_VALUES
          corresponding flow layout values
static String[] HPOS_NAMES
          alignment names
static int[] HPOS_VALUES
          corresponding alignment values
static int[] HSCROLL_VALUES
          corresponding scroll type values
static String LAYOUT_BORDER
          layout type
static String LAYOUT_CARD
          layout type
static String LAYOUT_FLOW
          layout type
static String LAYOUT_GRAPHPAPER
          layout type
static String LAYOUT_GRID
          layout type
static String LAYOUT_GRIDBAG
          layout type
static String LAYOUT_INSET
          layout type
static String LAYOUT_WRAP
          layout type
static int NOVALUE
          Special value
static String NULLSTRING
          More clear then going (String) null.
protected  Hashtable properties
          Holds the properties
static String[] SCROLL_NAMES
          scroll type names
static String[] SPLITPANE_NAMES
          split pane orientation
static int[] SPLITPANE_VALUES
          corresponding split pane values
static String[] TABPLACE_NAMES
          tab place names
static int[] TABPLACE_VALUES
          corresponding tab place values
static String TAG_BUTTON
          xml tag
static String TAG_BUTTONTABBEDPANE
          xml tag
static String TAG_CARDPANEL
          xml tag
static String TAG_CHECKBOX
          xml tag
static String TAG_COMBOBOX
          Xml tag for creating a combobox
static String TAG_COMPONENT
          xml tag
static String TAG_COMPONENTS
          xml tag
static String TAG_FILLER
          xml tag
static String TAG_HTML
          For showing html text.
static String TAG_IMAGE
          xml tag
static String TAG_IMPORT
          xml tag
static String TAG_ITEM
          xml tag
static String TAG_LABEL
          xml tag
static String TAG_MENU
          xml tag
static String TAG_MENUBAR
          xml tag
static String TAG_MENUITEM
          xml tag
static String TAG_MENUPOPUP
          xml tag
static String TAG_PANEL
          xml tag
static String TAG_PROPERTIES
          xml tag
static String TAG_PROPERTY
          xml tag
static String TAG_RADIO
          xml tag
static String TAG_SCROLLER
          xml tag
static String TAG_SEPARATOR
          xml tag
static String TAG_SKIN
          Tag and attribute names for the skin xml
static String TAG_SPLITPANE
          xml tag
static String TAG_STYLE
          Holds a style definition
static String TAG_STYLES
          The xml section that holds the styles
static String TAG_TABBEDPANE
          xml tag
static String TAG_TEXTINPUT
          xml tag
static String TAG_TOGGLEBUTTON
          xml tag
static String TAG_TOOLBAR
          xml tag
static String TAG_TREEPANEL
          xml tag
static String TAG_UI
          xml tag
static String[] TOOLBAR_NAMES
          tool bar orientation names
static int[] TOOLBAR_VALUES
          corresponding toolbar orientation values
static String[] VPOS_NAMES
          alignment names
static int[] VPOS_VALUES
          corresponding alignment values
static int[] VSCROLL_VALUES
          corresponding scroll type values
 
Constructor Summary
XmlUi()
          default ctor
XmlUi(Element root, ActionListener actionListener)
          ctor
XmlUi(Element root, Element startNode, Hashtable idToComponent, ActionListener actionListener, Hashtable initProperties)
           
XmlUi(Element root, Hashtable idToComponent, ActionListener actionListener, Hashtable initProperties)
          Create the XmlUi processor.
XmlUi(String xml, Hashtable idToComponent, ActionListener actionListener)
          ctor
 
Method Summary
 void actionPerformed(ActionEvent event)
          handle event
 void addComponent(String id, Component comp)
          Add the given component to the idToComponent map.
 void addComponent(String id, Element component)
          Add the component
 Component createComponent(Element node, String id)
          Create the awt Component defined by the given skin node.
 void dispose()
          The destructor
static String extractOneArg(String cmd)
          utility to parse commands
static String[] extractTwoArgs(String cmd)
          utility to parse commands
 int getAlign(String align)
          Get the align value from the given string name
 String getAttr(Element node, String attr)
          Get the value of the given attribute on the node.
 boolean getAttr(Element node, String attr, boolean dflt)
          Get the attribute value
 Color getAttr(Element node, String attr, Color dflt)
          Get the attribute value
 double getAttr(Element node, String attr, double dflt)
          Get the attribute value
 ImageIcon getAttr(Element node, String attr, ImageIcon dflt)
          Get the attribute value
 int getAttr(Element node, String attr, int dflt)
          Get the attribute value
 String getAttr(Element node, String attr, String dflt)
          Get the attribute value
 Border getBorder(String type, Element node)
          Create the border
 Component getComponent(String id)
          Return the Component identified by id
 List getComponents()
          Get the list of components created
 Component getContents()
          Create, if needed, and return the gui
static Image getImage(String path)
          Create an image
 Image getImageAttr(Element node, String attr)
          Get image defined by attr name
 String getProperty(String name)
          Look up the property
 boolean hasComponent(String id)
          Does this object hold this component
static String inheritName(String attr)
          Get the inherited attribute name
protected  void initializeComponents(Element root)
          initialize
 void itemStateChanged(ItemEvent event)
          handle event
static void main(String[] args)
          test
 JComponent makeButton(String tag, Element node)
          Make a button
 void setRoot(Element root)
          Set the xml root and reinitialize
 void setStartNode(Element node)
           
protected  Component xmlToUi(Element node)
          Convert the given xml node tree to a gui component
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NULLSTRING

public static final String NULLSTRING
More clear then going (String) null.


ACTION_UI_FLIP

public static final String ACTION_UI_FLIP
Action command for flpping through a card layout

See Also:
Constant Field Values

ACTION_UI_FOCUS

public static final String ACTION_UI_FOCUS
Action command for flpping through a card layout

See Also:
Constant Field Values

ACTION_MENUPOPUP

public static final String ACTION_MENUPOPUP
Action command for popping up a menu

See Also:
Constant Field Values

ACTION_SETTEXT

public static final String ACTION_SETTEXT
Action procedure

See Also:
Constant Field Values

ACTION_SETBORDER

public static final String ACTION_SETBORDER
Action procedure

See Also:
Constant Field Values

ACTION_UI_GROUP_NEXT

public static final String ACTION_UI_GROUP_NEXT
Action procedure

See Also:
Constant Field Values

ACTION_UI_GROUP_PREV

public static final String ACTION_UI_GROUP_PREV
Action procedure

See Also:
Constant Field Values

TAG_SKIN

public static final String TAG_SKIN
Tag and attribute names for the skin xml

See Also:
Constant Field Values

TAG_STYLES

public static final String TAG_STYLES
The xml section that holds the styles

See Also:
Constant Field Values

TAG_STYLE

public static final String TAG_STYLE
Holds a style definition

See Also:
Constant Field Values

TAG_UI

public static final String TAG_UI
xml tag

See Also:
Constant Field Values

TAG_CARDPANEL

public static final String TAG_CARDPANEL
xml tag

See Also:
Constant Field Values

TAG_COMBOBOX

public static final String TAG_COMBOBOX
Xml tag for creating a combobox

See Also:
Constant Field Values

TAG_COMPONENTS

public static final String TAG_COMPONENTS
xml tag

See Also:
Constant Field Values

TAG_COMPONENT

public static final String TAG_COMPONENT
xml tag

See Also:
Constant Field Values

TAG_BUTTON

public static final String TAG_BUTTON
xml tag

See Also:
Constant Field Values

TAG_RADIO

public static final String TAG_RADIO
xml tag

See Also:
Constant Field Values

TAG_CHECKBOX

public static final String TAG_CHECKBOX
xml tag

See Also:
Constant Field Values

TAG_FILLER

public static final String TAG_FILLER
xml tag

See Also:
Constant Field Values

TAG_HTML

public static final String TAG_HTML
For showing html text. Uses url attribute or contained text

See Also:
Constant Field Values

TAG_IMAGE

public static final String TAG_IMAGE
xml tag

See Also:
Constant Field Values

TAG_IMPORT

public static final String TAG_IMPORT
xml tag

See Also:
Constant Field Values

TAG_ITEM

public static final String TAG_ITEM
xml tag

See Also:
Constant Field Values

TAG_LABEL

public static final String TAG_LABEL
xml tag

See Also:
Constant Field Values

TAG_MENU

public static final String TAG_MENU
xml tag

See Also:
Constant Field Values

TAG_MENUPOPUP

public static final String TAG_MENUPOPUP
xml tag

See Also:
Constant Field Values

TAG_MENUBAR

public static final String TAG_MENUBAR
xml tag

See Also:
Constant Field Values

TAG_MENUITEM

public static final String TAG_MENUITEM
xml tag

See Also:
Constant Field Values

TAG_PANEL

public static final String TAG_PANEL
xml tag

See Also:
Constant Field Values

TAG_PROPERTIES

public static final String TAG_PROPERTIES
xml tag

See Also:
Constant Field Values

TAG_PROPERTY

public static final String TAG_PROPERTY
xml tag

See Also:
Constant Field Values

TAG_SCROLLER

public static final String TAG_SCROLLER
xml tag

See Also:
Constant Field Values

TAG_SEPARATOR

public static final String TAG_SEPARATOR
xml tag

See Also:
Constant Field Values

TAG_SPLITPANE

public static final String TAG_SPLITPANE
xml tag

See Also:
Constant Field Values

TAG_TABBEDPANE

public static final String TAG_TABBEDPANE
xml tag

See Also:
Constant Field Values

TAG_BUTTONTABBEDPANE

public static final String TAG_BUTTONTABBEDPANE
xml tag

See Also:
Constant Field Values

TAG_TREEPANEL

public static final String TAG_TREEPANEL
xml tag

See Also:
Constant Field Values

TAG_TEXTINPUT

public static final String TAG_TEXTINPUT
xml tag

See Also:
Constant Field Values

TAG_TOGGLEBUTTON

public static final String TAG_TOGGLEBUTTON
xml tag

See Also:
Constant Field Values

TAG_TOOLBAR

public static final String TAG_TOOLBAR
xml tag

See Also:
Constant Field Values

ATTR_ACTION

public static final String ATTR_ACTION
xml attribute name

See Also:
Constant Field Values

ATTR_CATEGORY

public static final String ATTR_CATEGORY
Category attribute for treepanel

See Also:
Constant Field Values

ATTR_CATEGORYCOMPONENT

public static final String ATTR_CATEGORYCOMPONENT
Used to define that the component is the category component for a tree panel

See Also:
Constant Field Values

ATTR_ACTIONTEMPLATE

public static final String ATTR_ACTIONTEMPLATE
xml attribute name

See Also:
Constant Field Values

ATTR_ALIGN

<