[Ejtools-cvs] libraries/adwt/src/main/org/ejtools/adwt/service HistoryService.java,1.4,1.5 HistorySe
Brought to you by:
letiemble
Update of /cvsroot/ejtools/libraries/adwt/src/main/org/ejtools/adwt/service In directory sc8-pr-cvs1:/tmp/cvs-serv8980/adwt/src/main/org/ejtools/adwt/service Modified Files: HistoryService.java HistoryServiceProvider.java MDIDesktopPane.java MenuBarService.java ToolBarServiceProvider.java Log Message: Address Todo #755528 Remove @created tags Index: HistoryService.java =================================================================== RCS file: /cvsroot/ejtools/libraries/adwt/src/main/org/ejtools/adwt/service/HistoryService.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** HistoryService.java 15 Sep 2003 22:37:14 -0000 1.4 --- HistoryService.java 27 Nov 2003 00:51:45 -0000 1.5 *************** *** 1,46 **** ! /* ! * EJTools, the Enterprise Java Tools ! * ! * Distributable under LGPL license. ! * See terms of license at www.gnu.org. ! */ ! package org.ejtools.adwt.service; ! ! import java.net.URL; ! ! /** ! * Description of the Class ! * ! * @author Laurent Etiemble ! * @version $Revision$ ! * @todo Javadoc to complete ! */ ! public interface HistoryService ! { ! /** ! * Description of the Method ! * ! * @param url Description of Parameter ! * @param context Description of Parameter ! */ ! public void push(URL url, Object context); ! ! ! /** ! * Description of the Class ! * ! * @author letiembl ! * @version $Revision$ ! * @created 7 novembre 2001 ! */ ! public interface Holder ! { ! /** ! * Description of the Method ! * ! * @param url Description of Parameter ! * @param context Description of Parameter ! */ ! public void loadResource(URL url, Object context); ! } ! } --- 1,45 ---- ! /* ! * EJTools, the Enterprise Java Tools ! * ! * Distributable under LGPL license. ! * See terms of license at www.gnu.org. ! */ ! package org.ejtools.adwt.service; ! ! import java.net.URL; ! ! /** ! * Description of the Class ! * ! * @author Laurent Etiemble ! * @version $Revision$ ! * @todo Javadoc to complete ! */ ! public interface HistoryService ! { ! /** ! * Description of the Method ! * ! * @param url Description of Parameter ! * @param context Description of Parameter ! */ ! public void push(URL url, Object context); ! ! ! /** ! * Description of the Class ! * ! * @author letiembl ! * @version $Revision$ ! */ ! public interface Holder ! { ! /** ! * Description of the Method ! * ! * @param url Description of Parameter ! * @param context Description of Parameter ! */ ! public void loadResource(URL url, Object context); ! } ! } Index: HistoryServiceProvider.java =================================================================== RCS file: /cvsroot/ejtools/libraries/adwt/src/main/org/ejtools/adwt/service/HistoryServiceProvider.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** HistoryServiceProvider.java 15 Sep 2003 22:37:14 -0000 1.4 --- HistoryServiceProvider.java 27 Nov 2003 00:51:45 -0000 1.5 *************** *** 1,272 **** ! /* ! * EJTools, the Enterprise Java Tools ! * ! * Distributable under LGPL license. ! * See terms of license at www.gnu.org. ! */ ! package org.ejtools.adwt.service; ! ! import java.beans.beancontext.BeanContextServices; ! import java.net.URL; ! import java.util.Iterator; ! import java.util.Vector; ! ! import javax.swing.Action; ! ! import org.apache.log4j.Logger; ! import org.ejtools.adwt.action.Command; ! import org.ejtools.adwt.action.CommandAction; ! import org.ejtools.adwt.action.file.FileHistoryAction; ! import org.ejtools.adwt.action.file.FileHistoryActionTop; ! import org.ejtools.beans.beancontext.CustomBeanContextServiceProvider; ! import org.ejtools.util.KeyLimitedStack; ! ! /** ! * Description of the Class ! * ! * @author Laurent Etiemble ! * @version $Revision$ ! * @todo Javadoc to complete ! */ ! public class HistoryServiceProvider extends CustomBeanContextServiceProvider implements HistoryService ! { ! /** Description of the Field */ ! protected HistoryService.Holder holder = null; ! /** Description of the Field */ ! protected int maxHistory; ! /** Description of the Field */ ! protected Vector menus = null; ! /** Description of the Field */ ! protected HistoryService service = null; ! /** Description of the Field */ ! protected KeyLimitedStack stack = null; ! /** Description of the Field */ ! private static Logger logger = Logger.getLogger(HistoryServiceProvider.class); ! /** Description of the Field */ ! protected final static int MAX_WIDTH = 30; ! ! ! /** ! * Constructor for the HistoryServiceProvider object ! * ! * @param maxHistory Description of Parameter ! * @param holder Description of Parameter ! */ ! public HistoryServiceProvider(HistoryService.Holder holder, int maxHistory) ! { ! this.service = this; ! this.holder = holder; ! this.maxHistory = maxHistory; ! this.stack = new KeyLimitedStack(maxHistory); ! this.menus = new Vector(maxHistory); ! } ! ! ! /** ! * Gets the currentServiceSelectors attribute of the HistoryServiceProvider object ! * ! * @param bcs Description of Parameter ! * @param serviceClass Description of Parameter ! * @return The currentServiceSelectors value ! */ ! public Iterator getCurrentServiceSelectors(BeanContextServices bcs, Class serviceClass) ! { ! return new Vector().iterator(); ! } ! ! ! /** ! * Gets the service attribute of the HistoryServiceProvider object ! * ! * @param bcs Description of Parameter ! * @param requestor Description of Parameter ! * @param serviceClass Description of Parameter ! * @param serviceSelector Description of Parameter ! * @return The service value ! */ ! public Object getService(BeanContextServices bcs, Object requestor, Class serviceClass, Object serviceSelector) ! { ! return service; ! } ! ! ! /** ! * Description of the Method ! * ! * @param url Description of Parameter ! * @param context Description of Parameter ! */ ! public void push(URL url, Object context) ! { ! this.stack.push(new HistoryContext(url, context)); ! ! for (int i = 0; i < stack.size(); i++) ! { ! HistoryContext hc = (HistoryContext) this.stack.elementAt(i); ! URL theUrl = hc.getURL(); ! String s = theUrl.toString(); ! ! if (s.length() > MAX_WIDTH) ! { ! s = "" + (i + 1) + ": " + theUrl.getProtocol() + "..." + s.substring(s.length() - 25); ! } ! else ! { ! s = "" + (i + 1) + ": " + theUrl.toString(); ! } ! ! CommandAction action = (CommandAction) menus.elementAt(i); ! action.putValue(Action.NAME, s); ! action.setEnabled(true); ! } ! } ! ! ! /** ! * Description of the Method ! * ! * @param bcs Description of Parameter ! * @param requestor Description of Parameter ! * @param service Description of Parameter ! */ ! public void releaseService(BeanContextServices bcs, Object requestor, Object service) { } ! ! ! /** ! * @return The serviceClass value ! */ ! protected Class[] getServiceClass() ! { ! return new Class[]{HistoryService.class}; ! } ! ! ! /** Description of the Method */ ! protected void initializeBeanContextResources() ! { ! super.initializeBeanContextResources(); ! ! CommandAction action; ! ! for (int i = 0; i < this.maxHistory; i++) ! { ! if (i == 0) ! { ! action = new FileHistoryActionTop( ! new FileHistoryCommand(i) ! ); ! } ! else ! { ! action = new FileHistoryAction( ! new FileHistoryCommand(i) ! ); ! } ! action.setEnabled(false); ! menus.add(action); ! this.add(action); ! } ! ! logger.debug("HistoryService added"); ! } ! ! ! /** ! * Description of the Class ! * ! * @author letiembl ! * @version $Revision$ ! * @created 7 novembre 2001 ! */ ! private class FileHistoryCommand implements Command ! { ! /** Description of the Field */ ! private int position; ! ! ! /** ! * Constructor for the FileHistoryCommand object ! * ! * @param position Description of Parameter ! */ ! public FileHistoryCommand(int position) ! { ! this.position = position; ! } ! ! ! /** Description of the Method */ ! public void execute() ! { ! HistoryContext hc = (HistoryContext) HistoryServiceProvider.this.stack.elementAt(position); ! logger.info("Loading " + hc.getURL()); ! HistoryServiceProvider.this.holder.loadResource(hc.getURL(), hc.getContext()); ! } ! } ! ! ! /** ! * Description of the Class ! * ! * @author letiembl ! * @version $Revision$ ! * @created 7 novembre 2001 ! */ ! private class HistoryContext ! { ! /** Description of the Field */ ! private Object context; ! /** Description of the Field */ ! private URL url; ! ! ! /** ! * Constructor for the HistoryContext object ! * ! * @param url Description of Parameter ! * @param context Description of Parameter ! */ ! public HistoryContext(URL url, Object context) ! { ! this.url = url; ! this.context = context; ! } ! ! ! /** ! * Description of the Method ! * ! * @param o Description of Parameter ! * @return Description of the Returned Value ! */ ! public boolean equals(Object o) ! { ! logger.debug("Object to test " + ((HistoryContext) o).getURL().toString()); ! logger.debug("The URL " + this.url.toString()); ! return ((HistoryContext) o).getURL().equals(this.url); ! } ! ! ! /** ! * Gets the context attribute of the HistoryContext object ! * ! * @return The context value ! */ ! public Object getContext() ! { ! return this.context; ! } ! ! ! /** ! * Gets the uRL attribute of the HistoryContext object ! * ! * @return The uRL value ! */ ! public URL getURL() ! { ! return this.url; ! } ! } ! } ! --- 1,270 ---- ! /* ! * EJTools, the Enterprise Java Tools ! * ! * Distributable under LGPL license. ! * See terms of license at www.gnu.org. ! */ ! package org.ejtools.adwt.service; ! ! import java.beans.beancontext.BeanContextServices; ! import java.net.URL; ! import java.util.Iterator; ! import java.util.Vector; ! ! import javax.swing.Action; ! ! import org.apache.log4j.Logger; ! import org.ejtools.adwt.action.Command; ! import org.ejtools.adwt.action.CommandAction; ! import org.ejtools.adwt.action.file.FileHistoryAction; ! import org.ejtools.adwt.action.file.FileHistoryActionTop; ! import org.ejtools.beans.beancontext.CustomBeanContextServiceProvider; ! import org.ejtools.util.KeyLimitedStack; ! ! /** ! * Description of the Class ! * ! * @author Laurent Etiemble ! * @version $Revision$ ! * @todo Javadoc to complete ! */ ! public class HistoryServiceProvider extends CustomBeanContextServiceProvider implements HistoryService ! { ! /** Description of the Field */ ! protected HistoryService.Holder holder = null; ! /** Description of the Field */ ! protected int maxHistory; ! /** Description of the Field */ ! protected Vector menus = null; ! /** Description of the Field */ ! protected HistoryService service = null; ! /** Description of the Field */ ! protected KeyLimitedStack stack = null; ! /** Description of the Field */ ! private static Logger logger = Logger.getLogger(HistoryServiceProvider.class); ! /** Description of the Field */ ! protected final static int MAX_WIDTH = 30; ! ! ! /** ! * Constructor for the HistoryServiceProvider object ! * ! * @param maxHistory Description of Parameter ! * @param holder Description of Parameter ! */ ! public HistoryServiceProvider(HistoryService.Holder holder, int maxHistory) ! { ! this.service = this; ! this.holder = holder; ! this.maxHistory = maxHistory; ! this.stack = new KeyLimitedStack(maxHistory); ! this.menus = new Vector(maxHistory); ! } ! ! ! /** ! * Gets the currentServiceSelectors attribute of the HistoryServiceProvider object ! * ! * @param bcs Description of Parameter ! * @param serviceClass Description of Parameter ! * @return The currentServiceSelectors value ! */ ! public Iterator getCurrentServiceSelectors(BeanContextServices bcs, Class serviceClass) ! { ! return new Vector().iterator(); ! } ! ! ! /** ! * Gets the service attribute of the HistoryServiceProvider object ! * ! * @param bcs Description of Parameter ! * @param requestor Description of Parameter ! * @param serviceClass Description of Parameter ! * @param serviceSelector Description of Parameter ! * @return The service value ! */ ! public Object getService(BeanContextServices bcs, Object requestor, Class serviceClass, Object serviceSelector) ! { ! return service; ! } ! ! ! /** ! * Description of the Method ! * ! * @param url Description of Parameter ! * @param context Description of Parameter ! */ ! public void push(URL url, Object context) ! { ! this.stack.push(new HistoryContext(url, context)); ! ! for (int i = 0; i < stack.size(); i++) ! { ! HistoryContext hc = (HistoryContext) this.stack.elementAt(i); ! URL theUrl = hc.getURL(); ! String s = theUrl.toString(); ! ! if (s.length() > MAX_WIDTH) ! { ! s = "" + (i + 1) + ": " + theUrl.getProtocol() + "..." + s.substring(s.length() - 25); ! } ! else ! { ! s = "" + (i + 1) + ": " + theUrl.toString(); ! } ! ! CommandAction action = (CommandAction) menus.elementAt(i); ! action.putValue(Action.NAME, s); ! action.setEnabled(true); ! } ! } ! ! ! /** ! * Description of the Method ! * ! * @param bcs Description of Parameter ! * @param requestor Description of Parameter ! * @param service Description of Parameter ! */ ! public void releaseService(BeanContextServices bcs, Object requestor, Object service) { } ! ! ! /** ! * @return The serviceClass value ! */ ! protected Class[] getServiceClass() ! { ! return new Class[]{HistoryService.class}; ! } ! ! ! /** Description of the Method */ ! protected void initializeBeanContextResources() ! { ! super.initializeBeanContextResources(); ! ! CommandAction action; ! ! for (int i = 0; i < this.maxHistory; i++) ! { ! if (i == 0) ! { ! action = new FileHistoryActionTop( ! new FileHistoryCommand(i) ! ); ! } ! else ! { ! action = new FileHistoryAction( ! new FileHistoryCommand(i) ! ); ! } ! action.setEnabled(false); ! menus.add(action); ! this.add(action); ! } ! ! logger.debug("HistoryService added"); ! } ! ! ! /** ! * Description of the Class ! * ! * @author letiembl ! * @version $Revision$ ! */ ! private class FileHistoryCommand implements Command ! { ! /** Description of the Field */ ! private int position; ! ! ! /** ! * Constructor for the FileHistoryCommand object ! * ! * @param position Description of Parameter ! */ ! public FileHistoryCommand(int position) ! { ! this.position = position; ! } ! ! ! /** Description of the Method */ ! public void execute() ! { ! HistoryContext hc = (HistoryContext) HistoryServiceProvider.this.stack.elementAt(position); ! logger.info("Loading " + hc.getURL()); ! HistoryServiceProvider.this.holder.loadResource(hc.getURL(), hc.getContext()); ! } ! } ! ! ! /** ! * Description of the Class ! * ! * @author letiembl ! * @version $Revision$ ! */ ! private class HistoryContext ! { ! /** Description of the Field */ ! private Object context; ! /** Description of the Field */ ! private URL url; ! ! ! /** ! * Constructor for the HistoryContext object ! * ! * @param url Description of Parameter ! * @param context Description of Parameter ! */ ! public HistoryContext(URL url, Object context) ! { ! this.url = url; ! this.context = context; ! } ! ! ! /** ! * Description of the Method ! * ! * @param o Description of Parameter ! * @return Description of the Returned Value ! */ ! public boolean equals(Object o) ! { ! logger.debug("Object to test " + ((HistoryContext) o).getURL().toString()); ! logger.debug("The URL " + this.url.toString()); ! return ((HistoryContext) o).getURL().equals(this.url); ! } ! ! ! /** ! * Gets the context attribute of the HistoryContext object ! * ! * @return The context value ! */ ! public Object getContext() ! { ! return this.context; ! } ! ! ! /** ! * Gets the uRL attribute of the HistoryContext object ! * ! * @return The uRL value ! */ ! public URL getURL() ! { ! return this.url; ! } ! } ! } ! Index: MDIDesktopPane.java =================================================================== RCS file: /cvsroot/ejtools/libraries/adwt/src/main/org/ejtools/adwt/service/MDIDesktopPane.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** MDIDesktopPane.java 15 Sep 2003 22:37:14 -0000 1.4 --- MDIDesktopPane.java 27 Nov 2003 00:51:45 -0000 1.5 *************** *** 1,574 **** ! /* ! * EJTools, the Enterprise Java Tools ! * ! * Distributable under LGPL license. ! * See terms of license at www.gnu.org. ! */ ! package org.ejtools.adwt.service; ! ! import java.awt.Component; ! import java.awt.Dimension; [...1115 lines suppressed...] ! ! int frameHeight = bounds.height / numRows; ! for (curRow = 0; curRow < numRows; curRow++) ! { ! while (frames[i].isIcon()) ! { ! // find the next visible frame ! i++; ! } ! ! frames[i].setBounds(curCol * frameWidth, curRow * frameHeight, frameWidth, frameHeight); ! i++; ! } ! } ! } ! } ! } ! ! } ! Index: MenuBarService.java =================================================================== RCS file: /cvsroot/ejtools/libraries/adwt/src/main/org/ejtools/adwt/service/MenuBarService.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** MenuBarService.java 15 Sep 2003 22:37:14 -0000 1.4 --- MenuBarService.java 27 Nov 2003 00:51:45 -0000 1.5 *************** *** 1,61 **** ! /* ! * EJTools, the Enterprise Java Tools ! * ! * Distributable under LGPL license. ! * See terms of license at www.gnu.org. ! */ ! package org.ejtools.adwt.service; ! ! import javax.swing.JMenuBar; ! ! /** ! * Description of the Class ! * ! * @author Laurent Etiemble ! * @version $Revision$ ! * @todo Javadoc to complete ! */ ! public interface MenuBarService extends ToolBarService ! { ! /** Description of the Field */ ! public final static int NO_LAYOUT = 0; ! /** Description of the Field */ ! public final static int SEPARATOR_BEFORE = 1; ! /** Description of the Field */ ! public final static int SEPARATOR_AFTER = 2; ! ! ! /** ! * Adds a feature to the MenuBarListener attribute of the MenuBarService object ! * ! * @param mbsl The feature to be added to the MenuBarListener attribute ! */ ! public void addMenuBarListener(MenuBarService.Listener mbsl); ! ! ! /** ! * Description of the Method ! * ! * @param mbsl Description of Parameter ! */ ! public void removeMenuBarListener(MenuBarService.Listener mbsl); ! ! ! /** ! * Description of the Class ! * ! * @author letiembl ! * @version $Revision$ ! * @created 5 novembre 2001 ! */ ! public interface Listener ! { ! /** ! * Description of the Method ! * ! * @param menuBar Description of Parameter ! */ ! public void update(JMenuBar menuBar); ! } ! } ! --- 1,60 ---- ! /* ! * EJTools, the Enterprise Java Tools ! * ! * Distributable under LGPL license. ! * See terms of license at www.gnu.org. ! */ ! package org.ejtools.adwt.service; ! ! import javax.swing.JMenuBar; ! ! /** ! * Description of the Class ! * ! * @author Laurent Etiemble ! * @version $Revision$ ! * @todo Javadoc to complete ! */ ! public interface MenuBarService extends ToolBarService ! { ! /** Description of the Field */ ! public final static int NO_LAYOUT = 0; ! /** Description of the Field */ ! public final static int SEPARATOR_BEFORE = 1; ! /** Description of the Field */ ! public final static int SEPARATOR_AFTER = 2; ! ! ! /** ! * Adds a feature to the MenuBarListener attribute of the MenuBarService object ! * ! * @param mbsl The feature to be added to the MenuBarListener attribute ! */ ! public void addMenuBarListener(MenuBarService.Listener mbsl); ! ! ! /** ! * Description of the Method ! * ! * @param mbsl Description of Parameter ! */ ! public void removeMenuBarListener(MenuBarService.Listener mbsl); ! ! ! /** ! * Description of the Class ! * ! * @author letiembl ! * @version $Revision$ ! */ ! public interface Listener ! { ! /** ! * Description of the Method ! * ! * @param menuBar Description of Parameter ! */ ! public void update(JMenuBar menuBar); ! } ! } ! Index: ToolBarServiceProvider.java =================================================================== RCS file: /cvsroot/ejtools/libraries/adwt/src/main/org/ejtools/adwt/service/ToolBarServiceProvider.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** ToolBarServiceProvider.java 15 Sep 2003 22:37:14 -0000 1.4 --- ToolBarServiceProvider.java 27 Nov 2003 00:51:45 -0000 1.5 *************** *** 1,277 **** ! /* ! * EJTools, the Enterprise Java Tools ! * ! * Distributable under LGPL license. ! * See terms of license at www.gnu.org. ! */ ! package org.ejtools.adwt.service; ! ! import java.awt.Container; ! import java.beans.beancontext.BeanContextServices; ! import java.util.Hashtable; ! import java.util.Iterator; ! import java.util.Vector; ! ! import javax.swing.Action; ! import javax.swing.Icon; ! import javax.swing.JButton; ! import javax.swing.JToolBar; ! ! import org.apache.log4j.Logger; ! import org.ejtools.adwt.action.CommandAction; ! import org.ejtools.beans.beancontext.CustomBeanContextServiceProvider; ! ! /** ! * Description of the Class ! * ! * @author Laurent Etiemble ! * @version $Revision$ ! * @todo Javadoc to complete ! */ ! public class ToolBarServiceProvider extends CustomBeanContextServiceProvider implements ToolBarService ! { ! /** Description of the Field */ ! private Hashtable bars = new Hashtable(); ! /** Description of the Field */ ! private boolean bigIcons = false; ! /** Description of the Field */ ! private ToolBarService service = null; ! /** Description of the Field */ ! private JToolBar toolBar = new JToolBar(); ! /** Description of the Field */ ! private static Logger logger = Logger.getLogger(ToolBarServiceProvider.class); ! ! ! /** Constructor for the ToolBarServiceProvider object */ ! public ToolBarServiceProvider() ! { ! this.service = this; ! } ! ! ! /** ! * Gets the container attribute of the ToolBarServiceProvider object ! * ! * @return The container value ! */ ! public Container getContainer() ! { ! return this.toolBar; ! } ! ! ! /** ! * Gets the currentServiceSelectors attribute of the ApplicationServiceProvider object ! * ! * @param bcs Description of Parameter ! * @param serviceClass Description of Parameter ! * @return The currentServiceSelectors value ! */ ! public Iterator getCurrentServiceSelectors(BeanContextServices bcs, Class serviceClass) ! { ! return new Vector().iterator(); ! } ! ! ! /** ! * Gets the service attribute of the ApplicationServiceProvider object ! * ! * @param bcs Description of Parameter ! * @param requestor Description of Parameter ! * @param serviceClass Description of Parameter ! * @param serviceSelector Description of Parameter ! * @return The service value ! */ ! public Object getService(BeanContextServices bcs, Object requestor, Class serviceClass, Object serviceSelector) ! { ! return service; ! } ! ! ! /** ! * Description of the Method ! * ! * @param action Description of Parameter ! */ ! public void register(CommandAction action) ! { ! String menu = action.getMenu(); ! JToolBarWrapper bar = (JToolBarWrapper) this.bars.get(menu); ! ! if (bar == null) ! { ! bar = new JToolBarWrapper(); ! bar.setFloatable(false); ! ! this.bars.put(menu, bar); ! ! if (this.toolBar.getComponentCount() > 0) ! { ! this.toolBar.addSeparator(); ! } ! ! this.toolBar.add(bar); ! } ! ! JButton button = bar.add(action); ! ! Object o = null; ! if (this.bigIcons) ! { ! o = action.getValue(CommandAction.ICON); ! } ! else ! { ! o = action.getValue(Action.SMALL_ICON); ! } ! if (o != null) ! { ! button.setIcon((Icon) o); ! } ! if (action.getValue(CommandAction.TOOLTIP) != null) ! { ! button.setToolTipText((String) action.getValue(CommandAction.TOOLTIP)); ! } ! ! toolBar.validate(); ! logger.debug("Button registered"); ! } ! ! ! /** ! * Description of the Method ! * ! * @param bcs Description of Parameter ! * @param requestor Description of Parameter ! * @param service Description of Parameter ! */ ! public void releaseService(BeanContextServices bcs, Object requestor, Object service) { } ! ! ! /** ! * Sets the bigIcons. ! * ! * @param bigIcons The bigIcons to set ! */ ! public void setBigIcons(boolean bigIcons) ! { ! if (this.bars.size() > 0) ! { ! throw new IllegalStateException("Cannot change icon size if buttons are registered"); ! } ! this.bigIcons = bigIcons; ! } ! ! ! /** ! * Description of the Method ! * ! * @param action Description of Parameter ! */ ! public void unregister(CommandAction action) ! { ! String menu = action.getMenu(); ! JToolBarWrapper bar = (JToolBarWrapper) this.bars.get(menu); ! ! if (bar == null) ! { ! return; ! } ! ! bar.remove(action); ! toolBar.validate(); ! logger.debug("Button unregistered"); ! } ! ! ! /** ! * @return The serviceClass value ! */ ! protected Class[] getServiceClass() ! { ! return new Class[]{ToolBarService.class}; ! } ! ! ! /** ! * Description of the Class ! * ! * @author laurent ! * @version $Revision$ ! * @created 29 d?cembre 2001 ! */ ! protected class JToolBarWrapper extends JToolBar ! { ! /** Description of the Field */ ! protected Hashtable buttons = new Hashtable(); ! ! ! /** Constructor for JToolBarWrapper. */ ! public JToolBarWrapper() ! { ! super(); ! this.setBorder(null); ! } ! ! ! /** ! * Constructor for JToolBarWrapper. ! * ! * @param orientation ! */ ! public JToolBarWrapper(int orientation) ! { ! super(orientation); ! } ! ! ! /** ! * Constructor for JToolBarWrapper. ! * ! * @param name ! */ ! public JToolBarWrapper(String name) ! { ! super(name); ! } ! ! ! /** ! * Constructor for JToolBarWrapper. ! * ! * @param name ! * @param orientation ! */ ! public JToolBarWrapper(String name, int orientation) ! { ! super(name, orientation); ! } ! ! ! /** ! * Description of the Method ! * ! * @param action Description of Parameter ! * @return Description of the Returned Value ! */ ! public JButton add(Action action) ! { ! JButton button = super.add(action); ! this.buttons.put(action, button); ! return button; ! } ! ! ! /** ! * Description of the Method ! * ! * @param action Description of Parameter ! */ ! public void remove(Action action) ! { ! JButton button = (JButton) this.buttons.get(action); ! this.remove(button); ! } ! } ! } ! --- 1,276 ---- ! /* ! * EJTools, the Enterprise Java Tools ! * ! * Distributable under LGPL license. ! * See terms of license at www.gnu.org. ! */ ! package org.ejtools.adwt.service; ! ! import java.awt.Container; ! import java.beans.beancontext.BeanContextServices; ! import java.util.Hashtable; ! import java.util.Iterator; ! import java.util.Vector; ! ! import javax.swing.Action; ! import javax.swing.Icon; ! import javax.swing.JButton; ! import javax.swing.JToolBar; ! ! import org.apache.log4j.Logger; ! import org.ejtools.adwt.action.CommandAction; ! import org.ejtools.beans.beancontext.CustomBeanContextServiceProvider; ! ! /** ! * Description of the Class ! * ! * @author Laurent Etiemble ! * @version $Revision$ ! * @todo Javadoc to complete ! */ ! public class ToolBarServiceProvider extends CustomBeanContextServiceProvider implements ToolBarService ! { ! /** Description of the Field */ ! private Hashtable bars = new Hashtable(); ! /** Description of the Field */ ! private boolean bigIcons = false; ! /** Description of the Field */ ! private ToolBarService service = null; ! /** Description of the Field */ ! private JToolBar toolBar = new JToolBar(); ! /** Description of the Field */ ! private static Logger logger = Logger.getLogger(ToolBarServiceProvider.class); ! ! ! /** Constructor for the ToolBarServiceProvider object */ ! public ToolBarServiceProvider() ! { ! this.service = this; ! } ! ! ! /** ! * Gets the container attribute of the ToolBarServiceProvider object ! * ! * @return The container value ! */ ! public Container getContainer() ! { ! return this.toolBar; ! } ! ! ! /** ! * Gets the currentServiceSelectors attribute of the ApplicationServiceProvider object ! * ! * @param bcs Description of Parameter ! * @param serviceClass Description of Parameter ! * @return The currentServiceSelectors value ! */ ! public Iterator getCurrentServiceSelectors(BeanContextServices bcs, Class serviceClass) ! { ! return new Vector().iterator(); ! } ! ! ! /** ! * Gets the service attribute of the ApplicationServiceProvider object ! * ! * @param bcs Description of Parameter ! * @param requestor Description of Parameter ! * @param serviceClass Description of Parameter ! * @param serviceSelector Description of Parameter ! * @return The service value ! */ ! public Object getService(BeanContextServices bcs, Object requestor, Class serviceClass, Object serviceSelector) ! { ! return service; ! } ! ! ! /** ! * Description of the Method ! * ! * @param action Description of Parameter ! */ ! public void register(CommandAction action) ! { ! String menu = action.getMenu(); ! JToolBarWrapper bar = (JToolBarWrapper) this.bars.get(menu); ! ! if (bar == null) ! { ! bar = new JToolBarWrapper(); ! bar.setFloatable(false); ! ! this.bars.put(menu, bar); ! ! if (this.toolBar.getComponentCount() > 0) ! { ! this.toolBar.addSeparator(); ! } ! ! this.toolBar.add(bar); ! } ! ! JButton button = bar.add(action); ! ! Object o = null; ! if (this.bigIcons) ! { ! o = action.getValue(CommandAction.ICON); ! } ! else ! { ! o = action.getValue(Action.SMALL_ICON); ! } ! if (o != null) ! { ! button.setIcon((Icon) o); ! } ! if (action.getValue(CommandAction.TOOLTIP) != null) ! { ! button.setToolTipText((String) action.getValue(CommandAction.TOOLTIP)); ! } ! ! toolBar.validate(); ! logger.debug("Button registered"); ! } ! ! ! /** ! * Description of the Method ! * ! * @param bcs Description of Parameter ! * @param requestor Description of Parameter ! * @param service Description of Parameter ! */ ! public void releaseService(BeanContextServices bcs, Object requestor, Object service) { } ! ! ! /** ! * Sets the bigIcons. ! * ! * @param bigIcons The bigIcons to set ! */ ! public void setBigIcons(boolean bigIcons) ! { ! if (this.bars.size() > 0) ! { ! throw new IllegalStateException("Cannot change icon size if buttons are registered"); ! } ! this.bigIcons = bigIcons; ! } ! ! ! /** ! * Description of the Method ! * ! * @param action Description of Parameter ! */ ! public void unregister(CommandAction action) ! { ! String menu = action.getMenu(); ! JToolBarWrapper bar = (JToolBarWrapper) this.bars.get(menu); ! ! if (bar == null) ! { ! return; ! } ! ! bar.remove(action); ! toolBar.validate(); ! logger.debug("Button unregistered"); ! } ! ! ! /** ! * @return The serviceClass value ! */ ! protected Class[] getServiceClass() ! { ! return new Class[]{ToolBarService.class}; ! } ! ! ! /** ! * Description of the Class ! * ! * @author laurent ! * @version $Revision$ ! */ ! protected class JToolBarWrapper extends JToolBar ! { ! /** Description of the Field */ ! protected Hashtable buttons = new Hashtable(); ! ! ! /** Constructor for JToolBarWrapper. */ ! public JToolBarWrapper() ! { ! super(); ! this.setBorder(null); ! } ! ! ! /** ! * Constructor for JToolBarWrapper. ! * ! * @param orientation ! */ ! public JToolBarWrapper(int orientation) ! { ! super(orientation); ! } ! ! ! /** ! * Constructor for JToolBarWrapper. ! * ! * @param name ! */ ! public JToolBarWrapper(String name) ! { ! super(name); ! } ! ! ! /** ! * Constructor for JToolBarWrapper. ! * ! * @param name ! * @param orientation ! */ ! public JToolBarWrapper(String name, int orientation) ! { ! super(name, orientation); ! } ! ! ! /** ! * Description of the Method ! * ! * @param action Description of Parameter ! * @return Description of the Returned Value ! */ ! public JButton add(Action action) ! { ! JButton button = super.add(action); ! this.buttons.put(action, button); ! return button; ! } ! ! ! /** ! * Description of the Method ! * ! * @param action Description of Parameter ! */ ! public void remove(Action action) ! { ! JButton button = (JButton) this.buttons.get(action); ! this.remove(button); ! } ! } ! } ! |