|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Object | +--com.smardec.asc.xmlbars.MenuToolBarManager
MenuToolBarManager builds menus and toolbars using the information from the xml.
It also supports enabling/disabling actions or group of actions, getting menus, toolbars and actions by id.
Sample usage:
MenuToolBarManager menuToolBarManager = new MenuToolBarManager(getClass().getClassLoader().getResourceAsStream("com/smardec/demo/asc/menutoolbar.xml"));
menuToolBarManager.buildMenuAndToolbar();
JMenuBar jMenuBarXml = menuToolBarManager.getMenuBarById("MenuBar.Main");
if (jMenuBarXml != null)
setJMenuBar(jMenuBarXml);
JAscToolBar jAscToolBarMain = menuToolBarManager.getToolBarById("ToolBar.Main");
if (jAscToolBarMain != null)
getContentPane().add(jAscToolBarMain, ToolbarDockLayout.North);
Xml file has the following structure:
<!--
The menutoolbar element is the root element of the menutoolbar.xml file.
It contains all the information used by com.smardec.asc.xmlbars.MenuToolBarManager
to build menus and toolbars.
-->
<!ELEMENT menutoolbar (actions, menubars, popups, toolbars)>
<!--
The actions element contains information about the actions.
-->
<!ELEMENT actions (action+)>
<!--
'icon-base-path' action's base path, used with 'icon' and 'large-icon'
to complete icon's path in action element.
-->
<!ATTLIST actions icon-base-path CDATA #IMPLIED >
<!--
The action element describes action that is used for menu items and toolbar buttons.
-->
<!ELEMENT action EMPTY>
<!--
'id' unique action id
'class' action's class derived from com.smardec.asc.xmlbars.BasicAction
that represents the action
'text' action's text, used for menu items and toolbar buttons,
overrides the corresponding attribute of the action
'mnemonic' action's mnemonic, used for menu items,
overrides the corresponding attribute of the action
'keystroke' action's keystroke, used for menu items,
overrides the corresponding attribute of the action
'icon', action's icon used for menu items and toolbar buttons,
overrides the corresponding attribute of the action
'large-icon' action's large icon, used for toolbar buttons,
overrides the corresponding attribute of the action
'tooltip', action's tooltip, used for menu items and toolbar buttons,
overrides the corresponding attribute of the action
'enabled', action's status, used to enable/disable action,
overrides the corresponding attribute of the action
'group-id', action's group id, used to manage group of actions,
overrides the corresponding attribute of the action
-->
<!ATTLIST action
id CDATA #REQUIRED
class CDATA #REQUIRED
text CDATA #IMPLIED
mnemonic CDATA #IMPLIED
keystroke CDATA #IMPLIED
icon CDATA #IMPLIED
large-icon CDATA #IMPLIED
tooltip CDATA #IMPLIED
enabled CDATA #IMPLIED
group-id CDATA #IMPLIED
>
<!--
The menubars element contains information about the menubars.
-->
<!ELEMENT menubars (menubar)>
<!--
The menubar element contains information about the menubar.
-->
<!ELEMENT menubar (items)>
<!--
'id' unique menubar id
-->
<!ATTLIST menubar id CDATA #REQUIRED>
<!--
The popups element contains information about the popup menus.
-->
<!ELEMENT popups (popupmenu)>
<!--
The popupmenu element contains information about the popup menu.
-->
<!ELEMENT popupmenu (items)>
<!--
'id' unique popup menu id
-->
<!ATTLIST popupmenu id CDATA #REQUIRED >
<!--
The toolbars element contains information about the toolbars.
-->
<!ELEMENT toolbars (toolbar)>
<!--
The toolbar element contains information about the toolbar.
-->
<!ELEMENT toolbar (items)>
<!--
'id' unique toolbar id
'orientation' specifies toolbar's orientation
'floatable' specifies toolbar's floatable property
'button-size' specifies toolbar's button size in pixels
-->
<!ATTLIST toolbar
id CDATA #REQUIRED
name CDATA #IMPLIED
orientation (horizontal | vertical) #IMPLIED
floatable (yes | true | no | false) #IMPLIED
button-size CDATA #IMPLIED
>
<!--
The items element contains information about the menu toolbar items.
-->
<!ELEMENT items (menu | item | separator)+>
<!--
The menu element contains information about the menu.
-->
<!ELEMENT menu (items?)>
<!--
'id' unique menu id
'text' specifies menu's text
'mnemonic' specifies menu's keyboard mnemonic
'class' class derived from javax.swing.JMenu that represents the menu with its
items and submenus, used to create dynamic menus like look&feel menu
-->
<!ATTLIST menu
id CDATA #REQUIRED
text CDATA #IMPLIED
mnemonic CDATA #IMPLIED
class CDATA #IMPLIED
>
<!--
The item element contains information about the menu or toolbar item.
-->
<!ELEMENT item EMPTY>
<!--
'action-id' specifies action for the item
'type' type of menu or toolbar item, 'AscCheckBox', 'AscRadioButton'
and 'IconicCheckBox' can be used for menu items, 'ToggleButton'
can be used for toolbar items
'button-group' specifies multiple-exclusion scope for radio button menu items
or toggle toolbar buttons
-->
<!ATTLIST item
action-id CDATA #REQUIRED
type (AscCheckBox | AscRadioButton |
IconicCheckBox | ToggleButton) #IMPLIED
button-group CDATA #IMPLIED
>
<!--
The separator element specifies separator for menu and toolbar items.
-->
<!ELEMENT separator EMPTY>
| Constructor Summary | |
MenuToolBarManager(java.io.InputStream inputStream)
Creates new MenuToolBarManager given the InputStream to read from. |
|
MenuToolBarManager(java.lang.String menuToolBarFileName)
Creates new MenuToolBarManager given the name of the xml file to read from. |
|
| Method Summary | |
void |
buildMenuAndToolbar()
Builds menus and toolbars using specified data. |
BasicAction |
getActionById(java.lang.String actionId)
Returns BasicAction object with specified action id actionId. |
java.util.Vector |
getActionsByGroupId(java.lang.String groupId)
Returns Vector of BasicAction objects with specified id groupId. |
javax.swing.JMenuBar |
getMenuBarById(java.lang.String menubarId)
Returns JMenuBar object with specified menu bar id menubarId. |
javax.swing.JMenu |
getMenuById(java.lang.String menuId)
Returns JMenu object with specified menu id menuId. |
javax.swing.JPopupMenu |
getPopupMenuById(java.lang.String popupMenuId)
Returns JPopupMenu object with specified popup menu id popupMenuId. |
JAscToolBar |
getToolBarById(java.lang.String toolbarId)
Returns JAscToolBar object with specified ToolBar id toolbarId. |
boolean |
isUseSmallToolBarIcons()
Idicates which icons MenuToolBarManager uses to create toolbar. |
void |
setGroupEnabled(java.lang.String groupId,
boolean newValue)
Enables or disables actions with specified groupId. |
void |
setUseSmallToolBarIcons(boolean useSmallToolBarIcons)
Specifies which icons MenuToolBarManager uses to create toolbar. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public MenuToolBarManager(java.lang.String menuToolBarFileName)
throws java.lang.Exception
MenuToolBarManager given the name of the xml file to read from.
menuToolBarFileName - xml file name to read data from
java.lang.Exception - if failed to read file
public MenuToolBarManager(java.io.InputStream inputStream)
throws java.lang.Exception
MenuToolBarManager given the InputStream to read from.
inputStream - InputStream to read from
java.lang.Exception - if failed to read stream| Method Detail |
public void buildMenuAndToolbar()
throws java.lang.Exception
java.lang.Exception - if failed to buildsetUseSmallToolBarIcons(boolean)public javax.swing.JMenuBar getMenuBarById(java.lang.String menubarId)
JMenuBar object with specified menu bar id menubarId.
menubarId - id of JMenuBar
JMenuBar object with specified menu bar id menubarId.public javax.swing.JPopupMenu getPopupMenuById(java.lang.String popupMenuId)
JPopupMenu object with specified popup menu id popupMenuId.
popupMenuId - id of JPopupMenu
JPopupMenu object with specified popup menu id popupMenuId.public javax.swing.JMenu getMenuById(java.lang.String menuId)
JMenu object with specified menu id menuId.
menuId - id of JMenu
JMenu object with specified menu id menuId.public JAscToolBar getToolBarById(java.lang.String toolbarId)
JAscToolBar object with specified ToolBar id toolbarId.
toolbarId - id of JAscToolBar
JAscToolBar object with specified ToolBar id toolbarId.public BasicAction getActionById(java.lang.String actionId)
BasicAction object with specified action id actionId.
actionId - id of BasicAction
BasicAction object with specified action id actionId.public java.util.Vector getActionsByGroupId(java.lang.String groupId)
Vector of BasicAction objects with specified id groupId.
groupId - id of actions' group
Vector of BasicAction objects with specified id groupId.
public void setGroupEnabled(java.lang.String groupId,
boolean newValue)
groupId.
groupId - group id to enable or disablenewValue - true to enable the actions with id groupId,
false to disable thempublic boolean isUseSmallToolBarIcons()
MenuToolBarManager uses to create toolbar. The default value is false.
The default is false.
true if MenuToolBarManager uses small icons, false - large icons.public void setUseSmallToolBarIcons(boolean useSmallToolBarIcons)
MenuToolBarManager uses to create toolbar. The default value is false.
buildMenuAndToolbar()
The default is false.
useSmallToolBarIcons - false otherwise
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||