Thread: [Ejtools-cvs] CVS: libraries/adwt/src/main/net/sourceforge/ejtools/awt/action Command.java,1.2,1.3 C
Brought to you by:
letiemble
From: Laurent E. <let...@us...> - 2002-05-05 20:09:59
|
Update of /cvsroot/ejtools/libraries/adwt/src/main/net/sourceforge/ejtools/awt/action In directory usw-pr-cvs1:/tmp/cvs-serv7792/adwt/src/main/net/sourceforge/ejtools/awt/action Modified Files: Command.java CommandAction.java Log Message: Add some JavaDocs Index: Command.java =================================================================== RCS file: /cvsroot/ejtools/libraries/adwt/src/main/net/sourceforge/ejtools/awt/action/Command.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Command.java 30 Apr 2002 21:06:52 -0000 1.2 --- Command.java 5 May 2002 20:09:56 -0000 1.3 *************** *** 10,20 **** * Interface needed to implement to Command Pattern. * ! * @author letiemble ! * @created 29 décembre 2001 ! * @version $Revision$ */ public interface Command { ! /** Method to implement executed by the action. */ public void execute(); } --- 10,20 ---- * Interface needed to implement to Command Pattern. * ! * @author letiemble ! * @created 29 décembre 2001 ! * @version $Revision$ */ public interface Command { ! /** Method to implement executed by the action. */ public void execute(); } Index: CommandAction.java =================================================================== RCS file: /cvsroot/ejtools/libraries/adwt/src/main/net/sourceforge/ejtools/awt/action/CommandAction.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** CommandAction.java 30 Apr 2002 21:06:52 -0000 1.2 --- CommandAction.java 5 May 2002 20:09:56 -0000 1.3 *************** *** 28,71 **** /** ! * Description of the Class * ! * @author letiemble ! * @created 2 novembre 2001 ! * @version $Revision$ ! * @todo Javadoc to complete */ public class CommandAction extends BeanContextChildSupport implements Action { ! /** Description of the Field */ ! private static Category logger = Category.getInstance(CommandAction.class); ! /** Description of the Field */ protected boolean inToolBar = false; ! /** Description of the Field */ protected String menu = null; ! /** Description of the Field */ ! protected int menuMnemonic = 0; ! /** Description of the Field */ protected String menuAccelerator = null; ! /** Description of the Field */ protected int menuLayout = MenuBarService.NO_LAYOUT; ! /** Description of the Field */ ! protected String icon = null; ! /** Description of the Field */ ! protected AbstractAction action = null; ! /** Description of the Field */ ! protected Command command; ! /** Description of the Field */ protected JMenuItem menuitem; ! /** Description of the Field */ protected ResourceBundle res; /** ! * Constructor for the CommandAction object * ! * @param command Description of Parameter ! * @param name Description of Parameter ! * @param res Description of Parameter */ public CommandAction(Command command, ResourceBundle res, String name) --- 28,71 ---- /** ! * Description of the Class * ! * @author letiemble ! * @created 2 novembre 2001 ! * @version $Revision$ ! * @todo Javadoc to complete */ public class CommandAction extends BeanContextChildSupport implements Action { ! /** Description of the Field */ ! protected AbstractAction action = null; ! /** Description of the Field */ ! protected Command command; ! /** Description of the Field */ ! protected String icon = null; ! /** Description of the Field */ protected boolean inToolBar = false; ! /** Description of the Field */ protected String menu = null; ! /** Description of the Field */ protected String menuAccelerator = null; ! /** Description of the Field */ protected int menuLayout = MenuBarService.NO_LAYOUT; ! /** Description of the Field */ ! protected int menuMnemonic = 0; ! /** Description of the Field */ protected JMenuItem menuitem; ! /** Description of the Field */ protected ResourceBundle res; + /** Description of the Field */ + private static Category logger = Category.getInstance(CommandAction.class); /** ! * Constructor for the CommandAction object * ! * @param command Description of Parameter ! * @param name Description of Parameter ! * @param res Description of Parameter */ public CommandAction(Command command, ResourceBundle res, String name) *************** *** 86,473 **** /** ! * Sets the enabled attribute of the CommandAction object * ! * @param b The new enabled value */ ! public void setEnabled(boolean b) { ! this.action.setEnabled(b); } /** ! * Constructor for the setIcon object * ! * @param icon Description of Parameter */ ! public final void setIcon(String icon) { ! if ((icon != null) && (!"".equals(icon))) { ! try { ! Icon image = new ImageIcon(getClass().getResource(icon)); ! this.putValue(Action.SMALL_ICON, image); } ! catch (Exception e) { } } } /** ! * Constructor for the setMenu object * ! * @param menu Description of Parameter */ ! public final void setMenu(String menu) { ! if ((menu != null) && (!"".equals(menu))) ! { ! this.menu = menu; ! } } /** ! * Setter for the menuMnemonic attribute * ! * @param menuMnemonic The new value for menuMnemonic attribute */ ! public final void setMenuMnemonic(String menuMnemonic) { ! if ((menu != menuMnemonic) && (!"".equals(menuMnemonic))) ! { ! this.menuMnemonic = Integer.parseInt(res.getString(menuMnemonic)); ! } } /** ! * Setter for the menuAccelerator attribute * ! * @param menuAccelerator The new value for menuAccelerator attribute */ ! public final void setMenuAccelerator(String menuAccelerator) { ! if ((menu != menuAccelerator) && (!"".equals(menuAccelerator))) ! { ! this.menuAccelerator = res.getString(menuAccelerator); ! } } /** ! * Sets the menuLayout attribute of the CommandAction object * ! * @param menuLayout The new menuLayout value */ ! public final void setMenuLayout(int menuLayout) { ! this.menuLayout = menuLayout; } /** ! * Sets the toolBar attribute of the CommandAction object * ! * @param inToolBar The new toolBar value */ ! public final void setToolBar(boolean inToolBar) { ! this.inToolBar = inToolBar; } /** ! * Gets the value attribute of the CommandAction object * ! * @param key Description of Parameter ! * @return The value value */ ! public Object getValue(String key) ! { ! return this.action.getValue(key); ! } /** ! * Getter for the resourceBundle attribute * ! * @return The value of resourceBundle attribute */ ! public ResourceBundle getResourceBundle() ! { ! return this.res; ! } /** ! * Gets the enabled attribute of the CommandAction object * ! * @return The enabled value */ ! public boolean isEnabled() { ! return this.action.isEnabled(); } ! /** ! * Gets the menu attribute of the CommandAction object ! * ! * @return The menu value ! */ ! public final String getMenu() { ! return this.menu; } /** ! * Gets the menuLayout attribute of the CommandAction object * ! * @return The menuLayout value */ ! public final int getMenuLayout() { ! return this.menuLayout; } ! /** ! * Gets the toolbar attribute of the CommandAction object ! * ! * @return The toolbar value ! */ ! public final boolean getToolBar() { ! return this.inToolBar; } /** ! * Getter for the menuItem attribute * ! * @return The value */ ! public JMenuItem getMenuItem() { ! if (this.menuitem == null) { ! logger.debug("Building MenuItem"); ! ! this.menuitem = new JMenuItem(this); ! if (this.menuMnemonic != 0) { ! this.menuitem.setMnemonic(this.menuMnemonic); } ! if (this.menuAccelerator != null) { ! this.menuitem.setAccelerator(KeyStroke.getKeyStroke(menuAccelerator)); } } - return this.menuitem; } /** ! * Description of the Method * ! * @param key Description of Parameter ! * @param value Description of Parameter */ ! public void putValue(String key, Object value) { ! this.action.putValue(key, value); } /** ! * Adds a feature to the PropertyChangeListener attribute of the ! * CommandAction object * ! * @param listener The feature to be added to the PropertyChangeListener ! * attribute */ ! public void addPropertyChangeListener(PropertyChangeListener listener) { ! this.action.addPropertyChangeListener(listener); } /** ! * Description of the Method * ! * @param listener Description of Parameter */ ! public void removePropertyChangeListener(PropertyChangeListener listener) { ! this.action.removePropertyChangeListener(listener); } /** ! * Description of the Method * ! * @param bcsre Description of Parameter */ ! public void serviceRevoked(BeanContextServiceRevokedEvent bcsre) { } /** ! * actionPerformed is what executed the command. actionPerformed is called ! * whenever the action is acted upon. * ! * @param e the action event */ ! public void actionPerformed(ActionEvent e) { ! this.action.actionPerformed(e); } /** ! * Description of the Method * ! * @param bcsae Description of Parameter */ ! public void serviceAvailable(BeanContextServiceAvailableEvent bcsae) { } /** ! * This method sets the action's command object. * ! * @param newValue the command for this action to act upon */ ! protected final void setCommand(Command newValue) { ! this.command = newValue; } /** ! * Setter for the resourceBundle attribute * ! * @param newValue The new value for resourceBundle attribute */ ! protected final void setResourceBundle(ResourceBundle newValue) { ! this.res = newValue; } /** ! * This method retrieves the encapsulated command. * ! * @return Command */ ! protected final Command getCommand() ! { ! return this.command; ! } ! ! ! /** Description of the Method */ ! protected void initializeBeanContextResources() { ! BeanContextServices context = (BeanContextServices) getBeanContext(); ! this.register(context); } ! /** Description of the Method */ ! protected void releaseBeanContextResources() { ! BeanContextServices context = (BeanContextServices) getBeanContext(); ! this.unregister(context); } /** ! * Description of the Method * ! * @param context Description of Parameter */ ! protected void register(BeanContextServices context) { ! // Set up MenuBar ! if ((context.hasService(MenuBarService.class)) && (this.menu != null) && (!"".equals(this.menu))) ! { ! logger.debug("Using service MenuBarService"); ! try ! { ! MenuBarService service = (MenuBarService) context.getService(this, this, MenuBarService.class, this, this); ! service.register(this); ! } ! catch (Exception e) ! { ! logger.error("Error during utilisation of service MenuBarService (" + e.getMessage() + ")"); ! e.printStackTrace(); ! } ! } ! ! // Set up ToolBar ! if ((context.hasService(ToolBarService.class)) && this.inToolBar) ! { ! logger.debug("Using service ToolBarService"); ! try ! { ! ToolBarService service = (ToolBarService) context.getService(this, this, ToolBarService.class, this, this); ! service.register(this); ! } ! catch (Exception e) ! { ! logger.error("Error during utilisation of service ToolBarService (" + e.getMessage() + ")"); ! e.printStackTrace(); ! } ! } } /** ! * Description of the Method * ! * @param context Description of Parameter */ ! protected void unregister(BeanContextServices context) { ! // Set up MenuBar ! if ((context.hasService(MenuBarService.class)) && (this.menu != null) && (!"".equals(this.menu))) ! { ! logger.debug("Using service MenuBarService"); ! try ! { ! MenuBarService service = (MenuBarService) context.getService(this, this, MenuBarService.class, this, this); ! service.unregister(this); ! } ! catch (Exception e) ! { ! logger.error("Error during utilisation of service MenuBarService (" + e.getMessage() + ")"); ! e.printStackTrace(); ! } ! } ! ! // Set up ToolBar ! if ((context.hasService(ToolBarService.class)) && inToolBar) ! { ! logger.debug("Using service ToolBarService"); ! try ! { ! ToolBarService service = (ToolBarService) context.getService(this, this, ToolBarService.class, this, this); ! service.unregister(this); ! } ! catch (Exception e) ! { ! logger.error("Error during utilisation of service ToolBarService (" + e.getMessage() + ")"); ! e.printStackTrace(); ! } ! } } } --- 86,469 ---- /** ! * actionPerformed is what executed the command. actionPerformed is called ! * whenever the action is acted upon. * ! * @param e the action event */ ! public void actionPerformed(ActionEvent e) { ! this.action.actionPerformed(e); } /** ! * Adds a feature to the PropertyChangeListener attribute of the ! * CommandAction object * ! * @param listener The feature to be added to the PropertyChangeListener ! * attribute */ ! public void addPropertyChangeListener(PropertyChangeListener listener) { ! this.action.addPropertyChangeListener(listener); ! } ! ! ! /** ! * Getter for the menuItem attribute ! * ! * @return The value ! */ ! public JMenuItem getMenuItem() ! { ! if (this.menuitem == null) { ! logger.debug("Building MenuItem"); ! ! this.menuitem = new JMenuItem(this); ! ! if (this.menuMnemonic != 0) { ! this.menuitem.setMnemonic(this.menuMnemonic); } ! if (this.menuAccelerator != null) { + this.menuitem.setAccelerator(KeyStroke.getKeyStroke(menuAccelerator)); } } + return this.menuitem; } /** ! * Getter for the resourceBundle attribute * ! * @return The value of resourceBundle attribute */ ! public ResourceBundle getResourceBundle() { ! return this.res; } /** ! * Gets the value attribute of the CommandAction object * ! * @param key Description of Parameter ! * @return The value value */ ! public Object getValue(String key) { ! return this.action.getValue(key); } /** ! * Gets the enabled attribute of the CommandAction object * ! * @return The enabled value */ ! public boolean isEnabled() { ! return this.action.isEnabled(); } /** ! * Description of the Method * ! * @param key Description of Parameter ! * @param value Description of Parameter */ ! public void putValue(String key, Object value) { ! this.action.putValue(key, value); } /** ! * Description of the Method * ! * @param listener Description of Parameter */ ! public void removePropertyChangeListener(PropertyChangeListener listener) { ! this.action.removePropertyChangeListener(listener); } /** ! * Description of the Method * ! * @param bcsae Description of Parameter */ ! public void serviceAvailable(BeanContextServiceAvailableEvent bcsae) { } /** ! * Description of the Method * ! * @param bcsre Description of Parameter */ ! public void serviceRevoked(BeanContextServiceRevokedEvent bcsre) { } /** ! * Sets the enabled attribute of the CommandAction object * ! * @param b The new enabled value */ ! public void setEnabled(boolean b) { ! this.action.setEnabled(b); } ! /** Description of the Method */ ! protected void initializeBeanContextResources() { ! BeanContextServices context = (BeanContextServices) getBeanContext(); ! this.register(context); } /** ! * Description of the Method * ! * @param context Description of Parameter */ ! protected void register(BeanContextServices context) { ! // Set up MenuBar ! if ((context.hasService(MenuBarService.class)) && (this.menu != null) && (!"".equals(this.menu))) ! { ! logger.debug("Using service MenuBarService"); ! try ! { ! MenuBarService service = (MenuBarService) context.getService(this, this, MenuBarService.class, this, this); ! service.register(this); ! } ! catch (Exception e) ! { ! logger.error("Error during utilisation of service MenuBarService (" + e.getMessage() + ")"); ! e.printStackTrace(); ! } ! } ! ! // Set up ToolBar ! if ((context.hasService(ToolBarService.class)) && this.inToolBar) ! { ! logger.debug("Using service ToolBarService"); ! try ! { ! ToolBarService service = (ToolBarService) context.getService(this, this, ToolBarService.class, this, this); ! service.register(this); ! } ! catch (Exception e) ! { ! logger.error("Error during utilisation of service ToolBarService (" + e.getMessage() + ")"); ! e.printStackTrace(); ! } ! } } ! /** Description of the Method */ ! protected void releaseBeanContextResources() { ! BeanContextServices context = (BeanContextServices) getBeanContext(); ! this.unregister(context); } /** ! * Description of the Method * ! * @param context Description of Parameter */ ! protected void unregister(BeanContextServices context) { ! // Set up MenuBar ! if ((context.hasService(MenuBarService.class)) && (this.menu != null) && (!"".equals(this.menu))) { ! logger.debug("Using service MenuBarService"); ! try ! { ! MenuBarService service = (MenuBarService) context.getService(this, this, MenuBarService.class, this, this); ! service.unregister(this); ! } ! catch (Exception e) ! { ! logger.error("Error during utilisation of service MenuBarService (" + e.getMessage() + ")"); ! e.printStackTrace(); ! } ! } ! // Set up ToolBar ! if ((context.hasService(ToolBarService.class)) && inToolBar) ! { ! logger.debug("Using service ToolBarService"); ! try { ! ToolBarService service = (ToolBarService) context.getService(this, this, ToolBarService.class, this, this); ! service.unregister(this); } ! catch (Exception e) { ! logger.error("Error during utilisation of service ToolBarService (" + e.getMessage() + ")"); ! e.printStackTrace(); } } } /** ! * Gets the menu attribute of the CommandAction object * ! * @return The menu value */ ! public final String getMenu() { ! return this.menu; } /** ! * Gets the menuLayout attribute of the CommandAction object * ! * @return The menuLayout value */ ! public final int getMenuLayout() { ! return this.menuLayout; } /** ! * Gets the toolbar attribute of the CommandAction object * ! * @return The toolbar value */ ! public final boolean getToolBar() { ! return this.inToolBar; } /** ! * Constructor for the setIcon object * ! * @param icon Description of Parameter */ ! public final void setIcon(String icon) { + if ((icon != null) && (!"".equals(icon))) + { + try + { + Icon image = new ImageIcon(getClass().getResource(icon)); + this.putValue(Action.SMALL_ICON, image); + } + catch (Exception e) + { + } + } } /** ! * Constructor for the setMenu object * ! * @param menu Description of Parameter */ ! public final void setMenu(String menu) { ! if ((menu != null) && (!"".equals(menu))) ! { ! this.menu = menu; ! } } /** ! * Setter for the menuAccelerator attribute * ! * @param menuAccelerator The new value for menuAccelerator attribute */ ! public final void setMenuAccelerator(String menuAccelerator) { + if ((menu != menuAccelerator) && (!"".equals(menuAccelerator))) + { + this.menuAccelerator = res.getString(menuAccelerator); + } } /** ! * Sets the menuLayout attribute of the CommandAction object * ! * @param menuLayout The new menuLayout value */ ! public final void setMenuLayout(int menuLayout) { ! this.menuLayout = menuLayout; } /** ! * Setter for the menuMnemonic attribute * ! * @param menuMnemonic The new value for menuMnemonic attribute */ ! public final void setMenuMnemonic(String menuMnemonic) { ! if ((menu != menuMnemonic) && (!"".equals(menuMnemonic))) ! { ! this.menuMnemonic = Integer.parseInt(res.getString(menuMnemonic)); ! } } /** ! * Sets the toolBar attribute of the CommandAction object * ! * @param inToolBar The new toolBar value */ ! public final void setToolBar(boolean inToolBar) { ! this.inToolBar = inToolBar; } ! /** ! * This method retrieves the encapsulated command. ! * ! * @return Command ! */ ! protected final Command getCommand() { ! return this.command; } /** ! * This method sets the action's command object. * ! * @param newValue the command for this action to act upon */ ! protected final void setCommand(Command newValue) { ! this.command = newValue; } /** ! * Setter for the resourceBundle attribute * ! * @param newValue The new value for resourceBundle attribute */ ! protected final void setResourceBundle(ResourceBundle newValue) { ! this.res = newValue; } } |