org.freehep.xml.menus
Class XMLMenuBuilder

java.lang.Object
  extended by org.freehep.xml.menus.XMLMenuBuilder

public class XMLMenuBuilder
extends Object

Create a set of menus by reading an XML file.

Version:
$Id: XMLMenuBuilder.java 8584 2006-08-10 23:06:37Z duns $
Author:
Tony Johnson (tonyj@slac.stanford.edu), Peter Armstrong

Nested Class Summary
static class XMLMenuBuilder.IllegalDefaultClassException
           
 
Field Summary
static String LOCATION_PROPERTY
           
 
Constructor Summary
XMLMenuBuilder()
          Create an (empty) XMLMenuBuilder
 
Method Summary
 void build(URL xml)
          Build an XMLMenuSystem using the default SAX parser.
 void build(URL xml, XMLReader reader)
          Build an XMLMenuSystem
protected  Icon createIcon(String name)
          Override this method for customized icon creation.
protected  JMenu createMenu(String className)
          Override this method to create your own subclass of JMenu
protected  JMenuBar createMenuBar(String className)
          Override this method to create your own subclass of JMenuBar
protected  JMenuItem createMenuItem(String className, String name, String type, String command)
          Override this method to create your own subclass of JMenuItem
protected  JPopupMenu createPopupMenu(String className)
          Override this method to create your own subclass of JPopupMenu
protected  JToolBar createToolBar(String className)
          Override this method to create your own subclass of JToolBar
protected  AbstractButton createToolBarItem(String className, String name, String type, String command)
          Override this method to create your own subclass of JButton
 JMenuBar getMenuBar(String id)
          Get the menu bar with ID id
 JPopupMenu getPopupMenu(String id)
          Get the popup menu with ID id
 JToolBar getToolBar(String id)
          Get the tool bar with ID id
 JPopupMenu mergePopupMenu(String id, JPopupMenu menu)
          Merge the popup menu with ID id onto the end of an existing menu
static void setClassLoader(ClassLoader loader)
          Set the classloader that will be used to load classes named in the XML
 void setDefaultCheckBoxMenuItemClass(Class klass)
          sets the default class of checkbox menu items to be klass
 void setDefaultMenuBarClass(Class klass)
           
 void setDefaultMenuClass(Class klass)
          sets the default class of menus to be klass
 void setDefaultMenuItemClass(Class klass)
          sets the default class of menu items to be klass
 void setDefaultPopupMenuClass(Class klass)
          sets the default class of popup menus to be klass
 void setDefaultRadioMenuItemClass(Class klass)
          sets the default class of radio menu items to be klass
 void setDefaultToolBarClass(Class klass)
          sets the default class of toolbars to be klass
 void setDefaultToolBarItemClass(Class klass)
          sets the default class of menu items to be klass
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOCATION_PROPERTY

public static final String LOCATION_PROPERTY
See Also:
Constant Field Values
Constructor Detail

XMLMenuBuilder

public XMLMenuBuilder()
Create an (empty) XMLMenuBuilder

Method Detail

build

public void build(URL xml)
           throws SAXException,
                  IOException
Build an XMLMenuSystem using the default SAX parser.

Parameters:
xml - The URL from which to read the XML
Throws:
SAXException
IOException

build

public void build(URL xml,
                  XMLReader reader)
           throws SAXException,
                  IOException
Build an XMLMenuSystem

Parameters:
xml - The URL from which to read the XML
reader - The XMLReader to use to parse the XML
Throws:
SAXException
IOException

setDefaultMenuBarClass

public void setDefaultMenuBarClass(Class klass)
                            throws XMLMenuBuilder.IllegalDefaultClassException
Throws:
XMLMenuBuilder.IllegalDefaultClassException

setDefaultMenuClass

public void setDefaultMenuClass(Class klass)
                         throws XMLMenuBuilder.IllegalDefaultClassException
sets the default class of menus to be klass

Parameters:
klass - the new default class, must be a subclass of JMenu
Throws:
XMLMenuBuilder.IllegalDefaultClassException

setDefaultMenuItemClass

public void setDefaultMenuItemClass(Class klass)
                             throws XMLMenuBuilder.IllegalDefaultClassException
sets the default class of menu items to be klass

Parameters:
klass - the new default class, must be a subclass of JMenuItem
Throws:
XMLMenuBuilder.IllegalDefaultClassException

setDefaultRadioMenuItemClass

public void setDefaultRadioMenuItemClass(Class klass)
                                  throws XMLMenuBuilder.IllegalDefaultClassException
sets the default class of radio menu items to be klass

Parameters:
klass - the new default class, must be a subclass of JMenuItem
Throws:
XMLMenuBuilder.IllegalDefaultClassException

setDefaultCheckBoxMenuItemClass

public void setDefaultCheckBoxMenuItemClass(Class klass)
                                     throws XMLMenuBuilder.IllegalDefaultClassException
sets the default class of checkbox menu items to be klass

Parameters:
klass - the new default class, must be a subclass of JMenuItem
Throws:
XMLMenuBuilder.IllegalDefaultClassException

setDefaultPopupMenuClass

public void setDefaultPopupMenuClass(Class klass)
                              throws XMLMenuBuilder.IllegalDefaultClassException
sets the default class of popup menus to be klass

Parameters:
klass - the new default class, must be a subclass of JPopupMenu
Throws:
XMLMenuBuilder.IllegalDefaultClassException

setDefaultToolBarClass

public void setDefaultToolBarClass(Class klass)
                            throws XMLMenuBuilder.IllegalDefaultClassException
sets the default class of toolbars to be klass

Parameters:
klass - the new default class, must be a subclass of JToolBar
Throws:
XMLMenuBuilder.IllegalDefaultClassException

setDefaultToolBarItemClass

public void setDefaultToolBarItemClass(Class klass)
                                throws XMLMenuBuilder.IllegalDefaultClassException
sets the default class of menu items to be klass

Parameters:
klass - the new default class, must be a subclass of JButton
Throws:
XMLMenuBuilder.IllegalDefaultClassException

createMenuBar

protected JMenuBar createMenuBar(String className)
                          throws SAXException
Override this method to create your own subclass of JMenuBar

Throws:
SAXException

createMenu

protected JMenu createMenu(String className)
                    throws SAXException
Override this method to create your own subclass of JMenu

Throws:
SAXException

createMenuItem

protected JMenuItem createMenuItem(String className,
                                   String name,
                                   String type,
                                   String command)
                            throws SAXException
Override this method to create your own subclass of JMenuItem

Throws:
SAXException

createPopupMenu

protected JPopupMenu createPopupMenu(String className)
                              throws SAXException
Override this method to create your own subclass of JPopupMenu

Throws:
SAXException

createToolBar

protected JToolBar createToolBar(String className)
                          throws SAXException
Override this method to create your own subclass of JToolBar

Throws:
SAXException

createToolBarItem

protected AbstractButton createToolBarItem(String className,
                                           String name,
                                           String type,
                                           String command)
                                    throws SAXException
Override this method to create your own subclass of JButton

Throws:
SAXException

createIcon

protected Icon createIcon(String name)
                   throws SAXException
Override this method for customized icon creation. The default implementation treats the argument as a relative or absolute URL. If relative it is interpreted relative to the URL of the menu file being read. If the icon cannot be found a "broken" icon is substituted.

Throws:
SAXException

getMenuBar

public JMenuBar getMenuBar(String id)
Get the menu bar with ID id


getToolBar

public JToolBar getToolBar(String id)
Get the tool bar with ID id


getPopupMenu

public JPopupMenu getPopupMenu(String id)
Get the popup menu with ID id


mergePopupMenu

public JPopupMenu mergePopupMenu(String id,
                                 JPopupMenu menu)
Merge the popup menu with ID id onto the end of an existing menu

Parameters:
id - The id of the popup menu
menu - The menu to be merged

setClassLoader

public static void setClassLoader(ClassLoader loader)
Set the classloader that will be used to load classes named in the XML



Copyright © 2000-2007 FreeHEP. All Rights Reserved.