com.japisoft.framework.application.descriptor
Class InterfaceBuilder

java.lang.Object
  extended bycom.japisoft.framework.application.descriptor.InterfaceBuilder

public class InterfaceBuilder
extends java.lang.Object

Builder for the user interface. This class works with an XML descriptor. It will create menu and submenus, toolbars, popup for your main application frame.

Version:
1.0
Author:
(c) 2003 JAPISoft

Field Summary
static java.lang.String MENU_RECENT_FILE
           
static java.lang.String MENU_RECENT_PROJECT
           
 boolean treeModified
           
 
Constructor Summary
InterfaceBuilder(java.net.URL input)
           
InterfaceBuilder(java.net.URL input, ActionBuilder builder)
           
 
Method Summary
 void buildUI(java.io.InputStream input)
          Build the user interface from this XML file descriptor
 javax.swing.Action getActionById(java.lang.String id)
           
 java.lang.String getActionClassName(java.lang.String alias)
           
 javax.swing.Icon getAppIcon()
           
 javax.swing.JMenu getMenu(java.lang.String id)
           
 javax.swing.JMenuBar getMenuBar()
           
 com.japisoft.fastparser.node.SimpleNode getMenuNode(java.lang.String id)
           
 java.util.ArrayList getModel(java.lang.String id)
           
 javax.swing.JPopupMenu getPopup(java.lang.String id)
           
 javax.swing.JToolBar getToolBarByGroup(java.lang.String group)
           
 javax.swing.JToolBar getToolBarById(java.lang.String id)
           
 boolean hasActionClassName(java.lang.String alias)
           
 boolean hasPopup(java.lang.String id)
           
 void insertMenuItemAtFirst(java.lang.String menuId, javax.swing.Action a, int limit)
          Add a menu item for this menu id.
 boolean isApplicationDocumentModified()
           
 boolean isEnabledActionForId(java.lang.String id)
          Check the enabled/disabled state for its id
 void removeMenuItemForParam(java.lang.String menuId, java.lang.String param)
          Remove the following children item matching this param
 void saveApplicationDocument()
          Save the current application document.
 void setActionClassAlias(java.lang.String alias, java.lang.String className)
          This is a way to not used a full class name in the file descriptor but rather an alias.
 void setApplicationDocumentModified()
          Force a document modification
 void setEnabledActionForAllGroup(boolean enabled)
          Enabled/Disabled all group
 void setEnabledActionForGroup(java.lang.String groupName, boolean enabled)
          Enabled/Disabled a set of action from this group name
 void setEnabledActionForId(java.lang.String id, boolean enabled)
          Enabled/Disabled an action from its id
 void setEnabledMenu(java.lang.String id, boolean enabled)
          Enabled/Disabled a complete menu for this name/id
 void setEnabledToolBarContentById(java.lang.String id, boolean enabled)
          Enabled/Disabled a toolbar content for this id
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MENU_RECENT_PROJECT

public static final java.lang.String MENU_RECENT_PROJECT
See Also:
Constant Field Values

MENU_RECENT_FILE

public static final java.lang.String MENU_RECENT_FILE
See Also:
Constant Field Values

treeModified

public boolean treeModified
Constructor Detail

InterfaceBuilder

public InterfaceBuilder(java.net.URL input,
                        ActionBuilder builder)
                 throws InterfaceBuilderException
Parameters:
input - An URL for loading the descriptor
builder - Update the default ActionBuilder by this one. This is useful when you need a custom behavior for building each action object
Throws:
InterfaceBuilderException - If the XML descriptor is a wrong one

InterfaceBuilder

public InterfaceBuilder(java.net.URL input)
                 throws InterfaceBuilderException
Parameters:
input - An URL for loading the descriptor
Throws:
InterfaceBuilderException - If the XML descriptor is a wrong one
Method Detail

buildUI

public void buildUI(java.io.InputStream input)
             throws InterfaceBuilderException
Build the user interface from this XML file descriptor

Throws:
InterfaceBuilderException

getAppIcon

public javax.swing.Icon getAppIcon()
Returns:
the main application icon

getMenuBar

public javax.swing.JMenuBar getMenuBar()
Returns:
the current menuBar

setEnabledActionForGroup

public void setEnabledActionForGroup(java.lang.String groupName,
                                     boolean enabled)
Enabled/Disabled a set of action from this group name


setEnabledActionForId

public void setEnabledActionForId(java.lang.String id,
                                  boolean enabled)
Enabled/Disabled an action from its id


isEnabledActionForId

public boolean isEnabledActionForId(java.lang.String id)
Check the enabled/disabled state for its id


setEnabledActionForAllGroup

public void setEnabledActionForAllGroup(boolean enabled)
Enabled/Disabled all group


getActionById

public javax.swing.Action getActionById(java.lang.String id)
Returns:
an action from this id name

getToolBarByGroup

public javax.swing.JToolBar getToolBarByGroup(java.lang.String group)
Returns:
a toolbar for this group

getToolBarById

public javax.swing.JToolBar getToolBarById(java.lang.String id)
Returns:
a toolbar from this name / id

setEnabledToolBarContentById

public void setEnabledToolBarContentById(java.lang.String id,
                                         boolean enabled)
Enabled/Disabled a toolbar content for this id


hasPopup

public boolean hasPopup(java.lang.String id)
Returns:
true if a popup if available for this name/id

getPopup

public javax.swing.JPopupMenu getPopup(java.lang.String id)
Returns:
a popup menu for this name/id

setActionClassAlias

public void setActionClassAlias(java.lang.String alias,
                                java.lang.String className)
This is a way to not used a full class name in the file descriptor but rather an alias. The real classname is then resolved here. This is a way to protect the final class name or to have more flexibility to choose a class when starting

Parameters:
alias - The action class alias
className - The final action class name

getActionClassName

public java.lang.String getActionClassName(java.lang.String alias)
Returns:
the real classname used from this action alias

hasActionClassName

public boolean hasActionClassName(java.lang.String alias)
Returns:
true if a classname is bound to this alias name

getModel

public java.util.ArrayList getModel(java.lang.String id)
Returns:
a set of action for this name / id

getMenu

public javax.swing.JMenu getMenu(java.lang.String id)
Returns:
a specific menu for this name / id

getMenuNode

public com.japisoft.fastparser.node.SimpleNode getMenuNode(java.lang.String id)
Returns:
the XML node managing this menu name / id

setEnabledMenu

public void setEnabledMenu(java.lang.String id,
                           boolean enabled)
Enabled/Disabled a complete menu for this name/id


isApplicationDocumentModified

public boolean isApplicationDocumentModified()
Returns:
true if the XML document has been modified

setApplicationDocumentModified

public void setApplicationDocumentModified()
Force a document modification


saveApplicationDocument

public void saveApplicationDocument()
                             throws InterfaceBuilderException
Save the current application document. It will work only if you have a document URL

Throws:
InterfaceBuilderException - If the operation is not possible

removeMenuItemForParam

public void removeMenuItemForParam(java.lang.String menuId,
                                   java.lang.String param)
Remove the following children item matching this param


insertMenuItemAtFirst

public void insertMenuItemAtFirst(java.lang.String menuId,
                                  javax.swing.Action a,
                                  int limit)
Add a menu item for this menu id. For dynamic usage