Package ucar.unidata.ui
Class XmlUi
java.lang.Object
ucar.unidata.ui.XmlUi
- All Implemented Interfaces:
ActionListener
,ItemListener
,EventListener
- Direct Known Subclasses:
IdvXmlUi
This class can create a UI from a "skin" xml.
See the file ../apps/example/docs/xmlui.html
for further details.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interface
Interface to pass ActionEvents to along with this XmlUI objectstatic class
Class CardPanel Holds a card layout state -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
Action command for popping up a menustatic final String
Action procedurestatic final String
Action procedurestatic final String
Action command for flpping through a card layoutstatic final String
Action command for flpping through a card layoutstatic final String
Action procedurestatic final String
Action procedurestatic final String[]
alignment namesstatic final int[]
corresponding alignment valuesstatic final String[]
grid bag anchorsstatic final int[]
corresponding grid bag anchor valuesstatic final String
xml attribute namestatic final String
xml attribute namestatic final String
xml attribute namestatic final String
xml attribute namestatic final String
xml attribute namestatic final String
xml attribute namestatic final String
xml attribute namestatic final String
xml attribute namestatic final String
xml attribute namestatic final String
xml attribute namestatic final String
xml attribute namestatic final String
xml attribute namestatic final String
xml attribute namestatic final String
xml attribute namestatic final String
xml attribute namestatic final String
xml attribute namestatic final String
Bottom space for insetsstatic final String
Category attribute for treepanelstatic final String
Used to define that the component is the category component for a tree panelstatic final String
xml attribute namestatic final String
xml attribute namestatic final String
xml attribute namestatic final String
xml attribute namestatic final String
xml attribute namestatic final String
xml attribute namestatic final String
xml attribute namestatic final String
Used for the combobox tag to define if the combobox is editablestatic final String
xml attribute namestatic final String
xml attribute namestatic final String
xml attribute namestatic final String
xml attribute namestatic final String
xml attribute namestatic final String
xml attribute namestatic final String
xml attribute namestatic final String
xml attribute namestatic final String
xml attribute namestatic final String
xml attribute namestatic final String
xml attribute namestatic final String
xml attribute namestatic final String
xml attribute namestatic final String
xml attribute namestatic final String
xml attribute namestatic final String
xml attribute namestatic final String
xml attribute namestatic final String
xml attribute namestatic final String
xml attribute namestatic final String
xml attribute namestatic final String
xml attribute namestatic final String
Left space for insetsstatic final String
xml attribute namestatic final String
xml attribute namestatic final String
xml attribute namestatic final String
xml attribute namestatic final String
xml attribute namestatic final String
xml attribute namestatic final String
xml attribute namestatic final String
xml attribute namestatic final String
xml attribute namestatic final String
xml attribute namestatic final String
xml attribute namestatic final String
xml attribute namestatic final String
xml attribute namestatic final String
xml attribute namestatic final String
xml attribute namestatic final String
Right space for insetsstatic final String
xml attribute namestatic final String
xml attribute namestatic final String
xml attribute namestatic final String
xml attribute namestatic final String
xml attribute namestatic final String
xml attribute namestatic final String
xml attribute namestatic final String
xml attribute namestatic final String
xml attribute namestatic final String
xml attribute namestatic final String
xml attribute namestatic final String
xml attribute namestatic final String
xml attribute namestatic final String
xml attribute namestatic final String
xml attribute namestatic final String
xml attribute namestatic final String
xml attribute namestatic final String
Top space for insetsstatic final String
xml attribute namestatic final String
xml attribute namestatic final String
xml attribute namestatic final String
xml attribute namestatic final String
xml attribute namestatic final String
xml attribute namestatic final String
xml attribute namestatic final String
xml attribute namestatic final String
xml attribute namestatic final String
border typestatic final String
border typestatic final String
border typestatic final String
border typestatic final String
border typestatic final String
border typestatic final String
border typestatic final String
border typestatic final String
border typestatic final String
border typestatic final String
border typestatic final String[]
fill namesstatic final int[]
corresponding fill valusstatic final String[]
flow layout namesstatic final int[]
corresponding flow layout valuesstatic final String[]
alignment namesstatic final int[]
corresponding alignment valuesstatic final int[]
corresponding scroll type valuesstatic final String
layout typestatic final String
layout typestatic final String
layout typestatic final String
layout typestatic final String
layout typestatic final String
layout typestatic final String
layout typestatic final String
layout typestatic final int
Special valuestatic final String
More clear then going (String) null.protected Hashtable
Holds the propertiesstatic final String[]
scroll type namesstatic final String[]
split pane orientationstatic final int[]
corresponding split pane valuesstatic final String[]
tab place namesstatic final int[]
corresponding tab place valuesstatic final String
xml tagstatic final String
xml tagstatic final String
xml tagstatic final String
xml tagstatic final String
Xml tag for creating a comboboxstatic final String
xml tagstatic final String
xml tagstatic final String
xml tagstatic final String
For showing html text.static final String
xml tagstatic final String
xml tagstatic final String
xml tagstatic final String
xml tagstatic final String
xml tagstatic final String
xml tagstatic final String
xml tagstatic final String
xml tagstatic final String
xml tagstatic final String
xml tagstatic final String
xml tagstatic final String
xml tagstatic final String
xml tagstatic final String
xml tagstatic final String
Tag and attribute names for the skin xmlstatic final String
xml tagstatic final String
Holds a style definitionstatic final String
The xml section that holds the stylesstatic final String
xml tagstatic final String
xml tagstatic final String
xml tagstatic final String
xml tagstatic final String
xml tagstatic final String
xml tagstatic final String[]
tool bar orientation namesstatic final int[]
corresponding toolbar orientation valuesstatic final String[]
alignment namesstatic final int[]
corresponding alignment valuesstatic final int[]
corresponding scroll type values -
Constructor Summary
ConstructorsConstructorDescriptionXmlUi()
default ctorXmlUi
(String xml, Hashtable idToComponent, ActionListener actionListener) ctorXmlUi
(Element root, ActionListener actionListener) ctorXmlUi
(Element root, Hashtable idToComponent, ActionListener actionListener, Hashtable initProperties) Create the XmlUi processor.XmlUi
(Element root, Element startNode, Hashtable idToComponent, ActionListener actionListener, Hashtable initProperties) -
Method Summary
Modifier and TypeMethodDescriptionvoid
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 componentcreateComponent
(Element node, String id) Create the awt Component defined by the given skin node.void
dispose()
The destructorstatic String
extractOneArg
(String cmd) utility to parse commandsstatic String[]
extractTwoArgs
(String cmd) utility to parse commandsint
Get the align value from the given string nameGet the value of the given attribute on the node.boolean
Get the attribute valuedouble
Get the attribute valueint
Get the attribute valueGet the attribute valueGet the attribute valueGet the attribute valueCreate the bordergetComponent
(String id) Return the Component identified by idGet the list of components createdCreate, if needed, and return the guistatic Image
Create an imagegetImageAttr
(Element node, String attr) Get image defined by attr namegetProperty
(String name) Look up the propertyboolean
hasComponent
(String id) Does this object hold this componentstatic String
inheritName
(String attr) static String
inheritNameOldWay
(String attr) Get the inherited attribute nameprotected void
initializeComponents
(Element root) initializevoid
itemStateChanged
(ItemEvent event) handle eventstatic void
testmakeButton
(String tag, Element node) Make a buttonvoid
Set the xml root and reinitializevoid
setStartNode
(Element node) protected Component
Convert the given xml node tree to a gui component
-
Field Details
-
NULLSTRING
More clear then going (String) null. -
ACTION_UI_FLIP
Action command for flpping through a card layout- See Also:
-
ACTION_UI_FOCUS
Action command for flpping through a card layout- See Also:
-
ACTION_MENUPOPUP
Action command for popping up a menu- See Also:
-
ACTION_SETTEXT
Action procedure- See Also:
-
ACTION_SETBORDER
Action procedure- See Also:
-
ACTION_UI_GROUP_NEXT
Action procedure- See Also:
-
ACTION_UI_GROUP_PREV
Action procedure- See Also:
-
TAG_SKIN
Tag and attribute names for the skin xml- See Also:
-
TAG_STYLES
The xml section that holds the styles- See Also:
-
TAG_STYLE
Holds a style definition- See Also:
-
TAG_UI
xml tag- See Also:
-
TAG_CARDPANEL
xml tag- See Also:
-
TAG_COMBOBOX
Xml tag for creating a combobox- See Also:
-
TAG_COMPONENTS
xml tag- See Also:
-
TAG_COMPONENT
xml tag- See Also:
-
TAG_BUTTON
xml tag- See Also:
-
TAG_RADIO
xml tag- See Also:
-
TAG_CHECKBOX
xml tag- See Also:
-
TAG_FILLER
xml tag- See Also:
-
TAG_HTML
For showing html text. Uses url attribute or contained text- See Also:
-
TAG_IMAGE
xml tag- See Also:
-
TAG_IMPORT
xml tag- See Also:
-
TAG_ITEM
xml tag- See Also:
-
TAG_LABEL
xml tag- See Also:
-
TAG_MENU
xml tag- See Also:
-
TAG_MENUPOPUP
xml tag- See Also:
-
TAG_MENUBAR
xml tag- See Also:
-
TAG_MENUITEM
xml tag- See Also:
-
TAG_PANEL
xml tag- See Also:
-
TAG_PROPERTIES
xml tag- See Also:
-
TAG_PROPERTY
xml tag- See Also:
-
TAG_SCROLLER
xml tag- See Also:
-
TAG_SEPARATOR
xml tag- See Also:
-
TAG_SPLITPANE
xml tag- See Also:
-
TAG_TABBEDPANE
xml tag- See Also:
-
TAG_BUTTONTABBEDPANE
xml tag- See Also:
-
TAG_TREEPANEL
xml tag- See Also:
-
TAG_TEXTINPUT
xml tag- See Also:
-
TAG_TOGGLEBUTTON
xml tag- See Also:
-
TAG_TOOLBAR
xml tag- See Also:
-
ATTR_ACTION
xml attribute name- See Also:
-
ATTR_CATEGORY
Category attribute for treepanel- See Also:
-
ATTR_CATEGORYCOMPONENT
Used to define that the component is the category component for a tree panel- See Also:
-
ATTR_ACTIONTEMPLATE
xml attribute name- See Also:
-
ATTR_ALIGN
xml attribute name- See Also:
-
ATTR_HPOSITION
xml attribute name- See Also:
-
ATTR_VPOSITION
xml attribute name- See Also:
-
ATTR_ANCHOR
xml attribute name- See Also:
-
ATTR_BGCOLOR
xml attribute name- See Also:
-
ATTR_BORDER
xml attribute name- See Also:
-
ATTR_BORDER_TITLE
xml attribute name- See Also:
-
ATTR_BORDER_COLOR
xml attribute name- See Also:
-
ATTR_BORDER_THICKNESS
xml attribute name- See Also:
-
ATTR_BORDER_INSET
xml attribute name- See Also:
-
ATTR_BORDER_HINSET
xml attribute name- See Also:
-
ATTR_BORDER_VINSET
xml attribute name- See Also:
-
ATTR_BORDER_TOP
xml attribute name- See Also:
-
ATTR_BORDER_LEFT
xml attribute name- See Also:
-
ATTR_BORDER_BOTTOM
xml attribute name- See Also:
-
ATTR_BORDER_RIGHT
xml attribute name- See Also:
-
ATTR_CLASS
xml attribute name- See Also:
-
ATTR_TAGCLASS
xml attribute name- See Also:
-
ATTR_COLS
xml attribute name- See Also:
-
ATTR_COLWIDTHS
xml attribute name- See Also:
-
ATTR_CONTINUOUS
xml attribute name- See Also:
-
ATTR_ONETOUCHEXPANDABLE
xml attribute name- See Also:
-
ATTR_DEFAULT
xml attribute name- See Also:
-
ATTR_DIVIDER
xml attribute name- See Also:
-
ATTR_DOWNIMAGE
xml attribute name- See Also:
-
ATTR_EDITABLE
Used for the combobox tag to define if the combobox is editable- See Also:
-
ATTR_EVENT
xml attribute name- See Also:
-
ATTR_FLOAT
xml attribute name- See Also:
-
ATTR_FGCOLOR
xml attribute name- See Also:
-
ATTR_FILL
xml attribute name- See Also:
-
ATTR_FONTSIZE
xml attribute name- See Also:
-
ATTR_FONTFACE
xml attribute name- See Also:
-
ATTR_FONTSTYLE
xml attribute name- See Also:
-
ATTR_GROUP
xml attribute name- See Also:
-
ATTR_HEIGHT
xml attribute name- See Also:
-
ATTR_HSCROLL
xml attribute name- See Also:
-
ATTR_IMAGEWIDTH
xml attribute name- See Also:
-
ATTR_IMAGEHEIGHT
xml attribute name- See Also:
-
ATTR_KEYPRESS
xml attribute name- See Also:
-
ATTR_MOUSE_ENTER
xml attribute name- See Also:
-
ATTR_MOUSE_EXIT
xml attribute name- See Also:
-
ATTR_MOUSE_CLICK
xml attribute name- See Also:
-
ATTR_NAME
xml attribute name- See Also:
-
ATTR_PREF_HEIGHT
xml attribute name- See Also:
-
ATTR_TSPACE
Top space for insets- See Also:
-
ATTR_BSPACE
Bottom space for insets- See Also:
-
ATTR_LSPACE
Left space for insets- See Also:
-
ATTR_RSPACE
Right space for insets- See Also:
-
ATTR_HSPACE
xml attribute name- See Also:
-
ATTR_ID
xml attribute name- See Also:
-
ATTR_IDREF
xml attribute name- See Also:
-
ATTR_IMAGE
xml attribute name- See Also:
-
ATTR_LABEL
xml attribute name- See Also:
-
ATTR_LAYOUT
xml attribute name- See Also:
-
ATTR_MARGIN
xml attribute name- See Also:
-
ATTR_MNEMONIC
xml attribute name- See Also:
-
ATTR_ORIENTATION
xml attribute name- See Also:
-
ATTR_OVERIMAGE
xml attribute name- See Also:
-
ATTR_PLACE
xml attribute name- See Also:
-
ATTR_PREF_WIDTH
xml attribute name- See Also:
-
ATTR_RESIZEWEIGHT
xml attribute name- See Also:
-
ATTR_ROWHEIGHTS
xml attribute name- See Also:
-
ATTR_ROWS
xml attribute name- See Also:
-
ATTR_SELECTIMAGE
xml attribute name- See Also:
-
ATTR_SPACE
xml attribute name- See Also:
-
ATTR_TABNESTED
xml attribute name- See Also:
-
ATTR_TABPLACE
xml attribute name- See Also:
-
ATTR_TABPAD
xml attribute name- See Also:
-
ATTR_TABINSETS
xml attribute name- See Also:
-
ATTR_TABBORDERLEFT
xml attribute name- See Also:
-
ATTR_TABBORDERBOTTOM
xml attribute name- See Also:
-
ATTR_TABBORDERRIGHT
xml attribute name- See Also:
-
ATTR_TABBORDERTOP
xml attribute name- See Also:
-
ATTR_ICON
xml attribute name- See Also:
-
ATTR_TEMPLATE
xml attribute name- See Also:
-
ATTR_TEXT
xml attribute name- See Also:
-
ATTR_TITLE
xml attribute name- See Also:
-
ATTR_TOOLTIP
xml attribute name- See Also:
-
ATTR_TABTOOLTIP
xml attribute name- See Also:
-
ATTR_URL
xml attribute name- See Also:
-
ATTR_VALUE
xml attribute name- See Also:
-
ATTR_VSCROLL
xml attribute name- See Also:
-
ATTR_VSPACE
xml attribute name- See Also:
-
ATTR_WIDTH
xml attribute name- See Also:
-
ATTR_TREEWIDTH
xml attribute name- See Also:
-
ATTR_USESPLITPANE
xml attribute name- See Also:
-
ATTR_X
xml attribute name- See Also:
-
ATTR_Y
xml attribute name- See Also:
-
BORDER_BUTTON
border type- See Also:
-
BORDER_TITLED
border type- See Also:
-
BORDER_BEVEL
border type- See Also:
-
BORDER_BEVEL_LOWERED
border type- See Also:
-
BORDER_BEVEL_RAISED
border type- See Also:
-
BORDER_EMPTY
border type- See Also:
-
BORDER_LINE
border type- See Also:
-
BORDER_ETCHED
border type- See Also:
-
BORDER_ETCHED_RAISED
border type- See Also:
-
BORDER_ETCHED_LOWERED
border type- See Also:
-
BORDER_MATTE
border type- See Also:
-
LAYOUT_BORDER
layout type- See Also:
-
LAYOUT_CARD
layout type- See Also:
-
LAYOUT_FLOW
layout type- See Also:
-
LAYOUT_GRAPHPAPER
layout type- See Also:
-
LAYOUT_GRID
layout type- See Also:
-
LAYOUT_GRIDBAG
layout type- See Also:
-
LAYOUT_INSET
layout type- See Also:
-
LAYOUT_WRAP
layout type- See Also:
-
FLOWLAYOUT_NAMES
flow layout names -
FLOWLAYOUT_VALUES
public static final int[] FLOWLAYOUT_VALUEScorresponding flow layout values -
FILL_NAMES
fill names -
FILL_VALUES
public static final int[] FILL_VALUEScorresponding fill valus -
TABPLACE_NAMES
tab place names -
TABPLACE_VALUES
public static final int[] TABPLACE_VALUEScorresponding tab place values -
TOOLBAR_NAMES
tool bar orientation names -
TOOLBAR_VALUES
public static final int[] TOOLBAR_VALUEScorresponding toolbar orientation values -
SPLITPANE_NAMES
split pane orientation -
SPLITPANE_VALUES
public static final int[] SPLITPANE_VALUEScorresponding split pane values -
ANCHOR_NAMES
grid bag anchors -
ANCHOR_VALUES
public static final int[] ANCHOR_VALUEScorresponding grid bag anchor values -
HPOS_NAMES
alignment names -
HPOS_VALUES
public static final int[] HPOS_VALUEScorresponding alignment values -
VPOS_NAMES
alignment names -
VPOS_VALUES
public static final int[] VPOS_VALUEScorresponding alignment values -
ALIGN_NAMES
alignment names -
ALIGN_VALUES
public static final int[] ALIGN_VALUEScorresponding alignment values -
SCROLL_NAMES
scroll type names -
VSCROLL_VALUES
public static final int[] VSCROLL_VALUEScorresponding scroll type values -
HSCROLL_VALUES
public static final int[] HSCROLL_VALUEScorresponding scroll type values -
properties
Holds the properties -
NOVALUE
public static final int NOVALUESpecial value- See Also:
-
-
Constructor Details
-
XmlUi
public XmlUi()default ctor -
XmlUi
ctor- Parameters:
xml
- The raw xmlidToComponent
- pre-defined id to component mapping. Allows you to have your own components that are referenced by the xmlactionListener
- Listener to pass events to
-
XmlUi
ctor- Parameters:
root
- xmlactionListener
- Listener to pass events to
-
XmlUi
public XmlUi(Element root, Hashtable idToComponent, ActionListener actionListener, Hashtable initProperties) Create the XmlUi processor. Root should point to a "skin" node. idToComponent is a Hashtable with application specific collection of id->java.awt.Component pairs. (May be null). actionListener - > route actions to it. (May be null).- Parameters:
root
- xml rootidToComponent
- pre-defined id to component mapping. Allows you to have your own components that are referenced by the xmlactionListener
- Listener to pass events toinitProperties
- initial properties
-
XmlUi
public XmlUi(Element root, Element startNode, Hashtable idToComponent, ActionListener actionListener, Hashtable initProperties)
-
-
Method Details
-
setStartNode
-
dispose
public void dispose()The destructor -
initializeComponents
initialize- Parameters:
root
- xml root
-
hasComponent
Does this object hold this component- Parameters:
id
- component id- Returns:
- do we currently have this component
-
addComponent
Add the component- Parameters:
id
- idcomponent
- component
-
addComponent
Add the given component to the idToComponent map. If the component already exists throw an IllegalStateException- Parameters:
id
-comp
-
-
getComponent
Return the Component identified by id- Parameters:
id
- component id- Returns:
- The component
-
getComponents
Get the list of components created- Returns:
- components
-
getAlign
Get the align value from the given string name- Parameters:
align
- name- Returns:
- align value
-
getAttr
Get the value of the given attribute on the node. This will first see if the node has the attribute. If not this will look into the styles. If still no value we will look up the xml tree to see if there is any attributes on nodes with the inherit prefix: i:attr_name If we find a value we will then convert any macros (defined with %...%)- Parameters:
node
- nodeattr
- attribute name- Returns:
- value or null if none found
-
inheritNameOldWay
Get the inherited attribute name- Parameters:
attr
- attr name- Returns:
- i:attr
-
inheritName
-
getAttr
Get the attribute value- Parameters:
node
- nodeattr
- attrdflt
- default- Returns:
- value or dflt
-
getAttr
Get the attribute value- Parameters:
node
- nodeattr
- attrdflt
- default- Returns:
- value or dflt
-
getAttr
Get the attribute value- Parameters:
node
- nodeattr
- attrdflt
- default- Returns:
- value or dflt
-
getAttr
Get the attribute value- Parameters:
node
- nodeattr
- attrdflt
- default- Returns:
- value or dflt
-
getAttr
Get the attribute value- Parameters:
node
- nodeattr
- attrdflt
- default- Returns:
- value or dflt
-
getAttr
Get the attribute value- Parameters:
node
- nodeattr
- attrdflt
- default- Returns:
- value or dflt
-
getBorder
Create the border- Parameters:
type
- border typenode
- xml node that holds any other attributes needed- Returns:
- The border
-
setRoot
Set the xml root and reinitialize- Parameters:
root
- xml root
-
getContents
Create, if needed, and return the gui- Returns:
- gui
-
getProperty
Look up the property- Parameters:
name
- property name- Returns:
- property value
-
xmlToUi
Convert the given xml node tree to a gui component- Parameters:
node
- node- Returns:
- gui
-
getImage
Create an image- Parameters:
path
- image path- Returns:
- image
-
getImageAttr
Get image defined by attr name- Parameters:
node
- nodeattr
- attr- Returns:
- image
-
createComponent
Create the awt Component defined by the given skin node.- Parameters:
node
- nodeid
- id- Returns:
- The component
-
makeButton
Make a button- Parameters:
tag
- tag namenode
- node- Returns:
- button
-
itemStateChanged
handle event- Specified by:
itemStateChanged
in interfaceItemListener
- Parameters:
event
- event
-
actionPerformed
handle event. This calls actionPerformedInner in a non-swing thread- Specified by:
actionPerformed
in interfaceActionListener
- Parameters:
event
- event
-
extractOneArg
utility to parse commands- Parameters:
cmd
- command- Returns:
- The arg
-
extractTwoArgs
utility to parse commands- Parameters:
cmd
- command- Returns:
- The args
-
main
test- Parameters:
args
- args
-