Author: tchemit Date: 2008-08-09 10:26:44 +0000 (Sat, 09 Aug 2008) New Revision: 823 Added: trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/AbstractActionConfigurationResolver.java trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/ActionConfigConfigurationResolver.java trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/ActionConfigurationResolver.java trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/SelectActionConfigConfigurationResolver.java trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/ToggleActionConfigConfigurationResolver.java Removed: trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/initializer/AbstractActionConfigurationResolver.java trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/initializer/ActionConfigConfigurationResolver.java trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/initializer/ActionConfigurationResolver.java trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/initializer/SelectActionConfigConfigurationResolver.java trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/initializer/ToggleActionConfigConfigurationResolver.java Log: simplification du code : suppression du paquetage initializer Copied: trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/AbstractActionConfigurationResolver.java (from rev 820, trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/initializer/AbstractActionConfigurationResolver.java) =================================================================== --- trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/AbstractActionConfigurationResolver.java (rev 0) +++ trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/AbstractActionConfigurationResolver.java 2008-08-09 10:26:44 UTC (rev 823) @@ -0,0 +1,70 @@ +/** + * # #% Copyright (C) 2008 Code Lutin, Tony Chemit + * This program is free software; you + * can redistribute it and/or modify it under the terms of the GNU General + * Public License as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. This program is + * distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * PARTICULAR PURPOSE. See the GNU General Public License for more details. You + * should have received a copy of the GNU General Public License along with this + * program; if not, write to the Free Software Foundation, Inc., 59 Temple Place + * - Suite 330, Boston, MA 02111-1307, USA. + * # #% + */ +package org.codelutin.jaxx.action; + +import javax.swing.JComponent; + +/** + * Common abstract class of a resolver of action configuration. + * <p/> + * The class implements the logic of research of the configuration annotation. + * + * @author chemit + */ +public abstract class AbstractActionConfigurationResolver<A extends java.lang.annotation.Annotation, C extends JComponent> implements ActionConfigurationResolver<A, C> { + + /** the type of configuration's annotation */ + protected final Class<A> annotationImpl; + + /** the type of component that can fire an action */ + protected final Class<C> componentImpl; + + /** + * The typed method (on component) to apply configuration on the action and component. + * + * @param component the component which fires the action + * @param action the given action + * @return the configuration's annotation + */ + protected abstract A applyConfiguration0(C component, MyAbstractAction action); + + protected AbstractActionConfigurationResolver(Class<A> annotationImpl, Class<C> componentImpl) { + this.annotationImpl = annotationImpl; + this.componentImpl = componentImpl; + } + + public A resolveConfiguration(MyAbstractAction action) { + if (action.hasDelegate()) { + return resolveConfiguration(action.getDelegate()); + } + return action.getClass().getAnnotation(annotationImpl); + } + + @SuppressWarnings({"unchecked"}) + public A applyConfiguration(JComponent component, MyAbstractAction action) { + if (component != null && componentImpl.isAssignableFrom(component.getClass())) + return applyConfiguration0((C) component, action); + + return null; + } + + public Class<A> getAnnotationImpl() { + return annotationImpl; + } + + public Class<C> getComponentImpl() { + return componentImpl; + } +} Copied: trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/ActionConfigConfigurationResolver.java (from rev 820, trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/initializer/ActionConfigConfigurationResolver.java) =================================================================== --- trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/ActionConfigConfigurationResolver.java (rev 0) +++ trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/ActionConfigConfigurationResolver.java 2008-08-09 10:26:44 UTC (rev 823) @@ -0,0 +1,67 @@ +/** + * # #% Copyright (C) 2008 Code Lutin, Tony Chemit + * This program is free software; you + * can redistribute it and/or modify it under the terms of the GNU General + * Public License as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. This program is + * distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * PARTICULAR PURPOSE. See the GNU General Public License for more details. You + * should have received a copy of the GNU General Public License along with this + * program; if not, write to the Free Software Foundation, Inc., 59 Temple Place + * - Suite 330, Boston, MA 02111-1307, USA. + * # #% + */ +package org.codelutin.jaxx.action; + +import static org.codelutin.i18n.I18n._; + +import javax.swing.AbstractButton; +import javax.swing.Action; + +/** + * Implementation of configuration's resolver for annotation {@link ActionConfig} + * + * @author chemit + */ +public class ActionConfigConfigurationResolver extends AbstractActionConfigurationResolver<ActionConfig, AbstractButton> { + + public ActionConfigConfigurationResolver() { + super(ActionConfig.class, AbstractButton.class); + } + + protected ActionConfig applyConfiguration0(AbstractButton component, MyAbstractAction action) { + ActionConfig anno = resolveConfiguration(action); + if (anno == null) { + return null; + } + // inject les données + if (!anno.name().isEmpty()) { + //System.out.println("found action with name : " + anno.name()); + action.putValue(Action.NAME, _(anno.name())); + } + //if (!anno.shortDescription().isEmpty()) { + action.putValue(Action.SHORT_DESCRIPTION, _(anno.shortDescription())); + //} + if (!anno.smallIcon().isEmpty()) { + action.putValue(Action.SMALL_ICON, org.codelutin.jaxx.util.UIHelper.createImageIcon(anno.smallIcon())); + } + if (anno.mnemonic() != '\0') { + action.putValue(Action.MNEMONIC_KEY, anno.mnemonic()); + } else if (component != null) { + action.putValue(Action.MNEMONIC_KEY, component.getMnemonic()); + } + //TODO Convert it from String action.putValue(Action.ACCELERATOR_KEY, anno.accelerator()); + + if (component == null) { + action.putValue("hideActionText", anno.hideActionText()); + } else { + boolean actionText = component.getHideActionText(); + action.putValue("hideActionText", anno.hideActionText() || actionText); + } + action.putValue(Action.SELECTED_KEY, anno.selected()); + action.setEnabled(anno.enabled()); + + return anno; + } +} Copied: trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/ActionConfigurationResolver.java (from rev 820, trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/initializer/ActionConfigurationResolver.java) =================================================================== --- trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/ActionConfigurationResolver.java (rev 0) +++ trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/ActionConfigurationResolver.java 2008-08-09 10:26:44 UTC (rev 823) @@ -0,0 +1,52 @@ +/** + * # #% Copyright (C) 2008 Code Lutin, Tony Chemit + * This program is free software; you + * can redistribute it and/or modify it under the terms of the GNU General + * Public License as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. This program is + * distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * PARTICULAR PURPOSE. See the GNU General Public License for more details. You + * should have received a copy of the GNU General Public License along with this + * program; if not, write to the Free Software Foundation, Inc., 59 Temple Place + * - Suite 330, Boston, MA 02111-1307, USA. + * # #% + */ +package org.codelutin.jaxx.action; + +import javax.swing.JComponent; + +/** + * The contract to be realized to resolve an {@link MyAbstractAction} configuration. + * <p/> + * Configuration is done by a Annotation of type {@link A} placed on the action class. + * <p/> + * If the instanciated action box the real action, we should always search on the boxed action. + * <p/> + * Moreover, a action can only be fired by a certain type of component (for example a Button or a ComboBox), the class + * of the component type is given by the {@link C} class. + * + * @author chemit + */ +public interface ActionConfigurationResolver<A extends java.lang.annotation.Annotation, C extends JComponent> { + /** + * Search the annotation that configure the given action (or the boxed action). + * + * @param action current action + * @return the configuration of the action + */ + A resolveConfiguration(MyAbstractAction action); + + /** + * @param component widget that requires the action + * @param action given action + * @return the configuration of the action + */ + A applyConfiguration(JComponent component, MyAbstractAction action); + + /** @return the configuration annotation dealed by this resolver */ + Class<A> getAnnotationImpl(); + + /** @return the class of the component which can fired the action */ + Class<C> getComponentImpl(); +} Copied: trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/SelectActionConfigConfigurationResolver.java (from rev 820, trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/initializer/SelectActionConfigConfigurationResolver.java) =================================================================== --- trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/SelectActionConfigConfigurationResolver.java (rev 0) +++ trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/SelectActionConfigConfigurationResolver.java 2008-08-09 10:26:44 UTC (rev 823) @@ -0,0 +1,53 @@ +/** + * # #% Copyright (C) 2008 Code Lutin, Tony Chemit + * This program is free software; you + * can redistribute it and/or modify it under the terms of the GNU General + * Public License as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. This program is + * distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * PARTICULAR PURPOSE. See the GNU General Public License for more details. You + * should have received a copy of the GNU General Public License along with this + * program; if not, write to the Free Software Foundation, Inc., 59 Temple Place + * - Suite 330, Boston, MA 02111-1307, USA. + * # #% + */ +package org.codelutin.jaxx.action; + +import static org.codelutin.i18n.I18n._; + +import javax.swing.Action; +import javax.swing.JComboBox; + +/** + * Implementation of configuration's resolver for annotation {@link SelectActionConfig} + * + * @author chemit + */ +public class SelectActionConfigConfigurationResolver extends AbstractActionConfigurationResolver<SelectActionConfig, JComboBox> { + + public SelectActionConfigConfigurationResolver() { + super(SelectActionConfig.class, JComboBox.class); + } + + protected SelectActionConfig applyConfiguration0(JComboBox component, MyAbstractAction action) { + SelectActionConfig anno = resolveConfiguration(action); + if (anno == null) { + return null; + } + // inject les données + if (!anno.name().isEmpty()) { + action.putValue(Action.NAME, _(anno.name())); + } + if (!anno.shortDescription().isEmpty()) { + action.putValue(Action.SHORT_DESCRIPTION, _(anno.shortDescription())); + } else { + action.putValue(Action.SHORT_DESCRIPTION, _(component.getToolTipText())); + } + action.putValue("selectedIndex", anno.selectedIndex()); + //TODO Convert it from String action.putValue(Action.ACCELERATOR_KEY, anno.accelerator()); + action.setEnabled(anno.enabled()); + + return anno; + } +} \ No newline at end of file Copied: trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/ToggleActionConfigConfigurationResolver.java (from rev 820, trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/initializer/ToggleActionConfigConfigurationResolver.java) =================================================================== --- trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/ToggleActionConfigConfigurationResolver.java (rev 0) +++ trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/ToggleActionConfigConfigurationResolver.java 2008-08-09 10:26:44 UTC (rev 823) @@ -0,0 +1,79 @@ +/** + * # #% Copyright (C) 2008 Code Lutin, Tony Chemit + * This program is free software; you + * can redistribute it and/or modify it under the terms of the GNU General + * Public License as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. This program is + * distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * PARTICULAR PURPOSE. See the GNU General Public License for more details. You + * should have received a copy of the GNU General Public License along with this + * program; if not, write to the Free Software Foundation, Inc., 59 Temple Place + * - Suite 330, Boston, MA 02111-1307, USA. + * # #% + */ +package org.codelutin.jaxx.action; + +import static org.codelutin.i18n.I18n._; + +import javax.swing.AbstractButton; +import javax.swing.Action; + +/** + * Implementation of configuration's resolver for annotation {@link ToggleActionConfig} + * + * @author chemit + */ +public class ToggleActionConfigConfigurationResolver extends AbstractActionConfigurationResolver<ToggleActionConfig, AbstractButton> { + + public ToggleActionConfigConfigurationResolver() { + super(ToggleActionConfig.class, AbstractButton.class); + } + + protected ToggleActionConfig applyConfiguration0(AbstractButton component, MyAbstractAction action) { + ToggleActionConfig anno = resolveConfiguration(action); + if (anno == null) { + return null; + } + // inject les données + if (!anno.name().isEmpty()) { + //System.out.println("found action with name : " + anno.name()); + action.putValue(Action.NAME, _(anno.name())); + } + if (!anno.name2().isEmpty()) { + //System.out.println("found action with name2 : " + anno.name2()); + action.putValue(Action.NAME + "2", _(anno.name2())); + } + + if (!anno.shortDescription().isEmpty()) { + action.putValue(Action.SHORT_DESCRIPTION, _(anno.shortDescription())); + } + if (!anno.shortDescription2().isEmpty()) { + action.putValue(Action.SHORT_DESCRIPTION + "2", _(anno.shortDescription2())); + } + + if (!anno.smallIcon().isEmpty()) { + action.putValue(Action.SMALL_ICON, org.codelutin.jaxx.util.UIHelper.createImageIcon(anno.smallIcon())); + } + if (!anno.smallIcon2().isEmpty()) { + action.putValue(Action.SMALL_ICON + "2", org.codelutin.jaxx.util.UIHelper.createImageIcon(anno.smallIcon2())); + } + + if (anno.mnemonic() != '\0') { + action.putValue(Action.MNEMONIC_KEY, anno.mnemonic()); + } else if (component != null) { + action.putValue(Action.MNEMONIC_KEY, component.getMnemonic()); + } + if (anno.mnemonic2() != '\0') { + action.putValue(Action.MNEMONIC_KEY + "2", anno.mnemonic2()); + } + //TODO Convert it from String action.putValue(Action.ACCELERATOR_KEY, anno.accelerator()); + + + action.putValue("hideActionText", anno.hideActionText()); + action.putValue(Action.SELECTED_KEY, anno.selected()); + action.setEnabled(anno.enabled()); + + return anno; + } +} \ No newline at end of file Deleted: trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/initializer/AbstractActionConfigurationResolver.java =================================================================== --- trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/initializer/AbstractActionConfigurationResolver.java 2008-08-09 10:26:02 UTC (rev 822) +++ trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/initializer/AbstractActionConfigurationResolver.java 2008-08-09 10:26:44 UTC (rev 823) @@ -1,72 +0,0 @@ -/** - * # #% Copyright (C) 2008 Code Lutin, Tony Chemit - * This program is free software; you - * can redistribute it and/or modify it under the terms of the GNU General - * Public License as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. This program is - * distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A - * PARTICULAR PURPOSE. See the GNU General Public License for more details. You - * should have received a copy of the GNU General Public License along with this - * program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - * - Suite 330, Boston, MA 02111-1307, USA. - * # #% - */ -package org.codelutin.jaxx.action.initializer; - -import org.codelutin.jaxx.action.MyAbstractAction; - -import javax.swing.JComponent; - -/** - * Common abstract class of a resolver of action configuration. - * <p/> - * The class implements the logic of research of the configuration annotation. - * - * @author chemit - */ -public abstract class AbstractActionConfigurationResolver<A extends java.lang.annotation.Annotation, C extends JComponent> implements ActionConfigurationResolver<A, C> { - - /** the type of configuration's annotation */ - protected final Class<A> annotationImpl; - - /** the type of component that can fire an action */ - protected final Class<C> componentImpl; - - /** - * The typed method (on component) to apply configuration on the action and component. - * - * @param component the component which fires the action - * @param action the given action - * @return the configuration's annotation - */ - protected abstract A applyConfiguration0(C component, MyAbstractAction action); - - protected AbstractActionConfigurationResolver(Class<A> annotationImpl, Class<C> componentImpl) { - this.annotationImpl = annotationImpl; - this.componentImpl = componentImpl; - } - - public A resolveConfiguration(MyAbstractAction action) { - if (action.hasDelegate()) { - return resolveConfiguration(action.getDelegate()); - } - return action.getClass().getAnnotation(annotationImpl); - } - - @SuppressWarnings({"unchecked"}) - public A applyConfiguration(JComponent component, MyAbstractAction action) { - if (component != null && componentImpl.isAssignableFrom(component.getClass())) - return applyConfiguration0((C) component, action); - - return null; - } - - public Class<A> getAnnotationImpl() { - return annotationImpl; - } - - public Class<C> getComponentImpl() { - return componentImpl; - } -} Deleted: trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/initializer/ActionConfigConfigurationResolver.java =================================================================== --- trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/initializer/ActionConfigConfigurationResolver.java 2008-08-09 10:26:02 UTC (rev 822) +++ trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/initializer/ActionConfigConfigurationResolver.java 2008-08-09 10:26:44 UTC (rev 823) @@ -1,69 +0,0 @@ -/** - * # #% Copyright (C) 2008 Code Lutin, Tony Chemit - * This program is free software; you - * can redistribute it and/or modify it under the terms of the GNU General - * Public License as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. This program is - * distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A - * PARTICULAR PURPOSE. See the GNU General Public License for more details. You - * should have received a copy of the GNU General Public License along with this - * program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - * - Suite 330, Boston, MA 02111-1307, USA. - * # #% - */ -package org.codelutin.jaxx.action.initializer; - -import static org.codelutin.i18n.I18n._; -import org.codelutin.jaxx.action.ActionConfig; -import org.codelutin.jaxx.action.MyAbstractAction; - -import javax.swing.AbstractButton; -import javax.swing.Action; - -/** - * Implementation of configuration's resolver for annotation {@link ActionConfig} - * - * @author chemit - */ -public class ActionConfigConfigurationResolver extends AbstractActionConfigurationResolver<ActionConfig, AbstractButton> { - - public ActionConfigConfigurationResolver() { - super(ActionConfig.class, AbstractButton.class); - } - - protected ActionConfig applyConfiguration0(AbstractButton component, MyAbstractAction action) { - ActionConfig anno = resolveConfiguration(action); - if (anno == null) { - return null; - } - // inject les données - if (!anno.name().isEmpty()) { - //System.out.println("found action with name : " + anno.name()); - action.putValue(Action.NAME, _(anno.name())); - } - //if (!anno.shortDescription().isEmpty()) { - action.putValue(Action.SHORT_DESCRIPTION, _(anno.shortDescription())); - //} - if (!anno.smallIcon().isEmpty()) { - action.putValue(Action.SMALL_ICON, org.codelutin.jaxx.util.UIHelper.createImageIcon(anno.smallIcon())); - } - if (anno.mnemonic() != '\0') { - action.putValue(Action.MNEMONIC_KEY, anno.mnemonic()); - } else if (component != null) { - action.putValue(Action.MNEMONIC_KEY, component.getMnemonic()); - } - //TODO Convert it from String action.putValue(Action.ACCELERATOR_KEY, anno.accelerator()); - - if (component == null) { - action.putValue("hideActionText", anno.hideActionText()); - } else { - boolean actionText = component.getHideActionText(); - action.putValue("hideActionText", anno.hideActionText() || actionText); - } - action.putValue(Action.SELECTED_KEY, anno.selected()); - action.setEnabled(anno.enabled()); - - return anno; - } -} Deleted: trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/initializer/ActionConfigurationResolver.java =================================================================== --- trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/initializer/ActionConfigurationResolver.java 2008-08-09 10:26:02 UTC (rev 822) +++ trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/initializer/ActionConfigurationResolver.java 2008-08-09 10:26:44 UTC (rev 823) @@ -1,54 +0,0 @@ -/** - * # #% Copyright (C) 2008 Code Lutin, Tony Chemit - * This program is free software; you - * can redistribute it and/or modify it under the terms of the GNU General - * Public License as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. This program is - * distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A - * PARTICULAR PURPOSE. See the GNU General Public License for more details. You - * should have received a copy of the GNU General Public License along with this - * program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - * - Suite 330, Boston, MA 02111-1307, USA. - * # #% - */ -package org.codelutin.jaxx.action.initializer; - -import org.codelutin.jaxx.action.MyAbstractAction; - -import javax.swing.JComponent; - -/** - * The contract to be realized to resolve an {@link MyAbstractAction} configuration. - * <p/> - * Configuration is done by a Annotation of type {@link A} placed on the action class. - * <p/> - * If the instanciated action box the real action, we should always search on the boxed action. - * <p/> - * Moreover, a action can only be fired by a certain type of component (for example a Button or a ComboBox), the class - * of the component type is given by the {@link C} class. - * - * @author chemit - */ -public interface ActionConfigurationResolver<A extends java.lang.annotation.Annotation, C extends JComponent> { - /** - * Search the annotation that configure the given action (or the boxed action). - * - * @param action current action - * @return the configuration of the action - */ - A resolveConfiguration(MyAbstractAction action); - - /** - * @param component widget that requires the action - * @param action given action - * @return the configuration of the action - */ - A applyConfiguration(JComponent component, MyAbstractAction action); - - /** @return the configuration annotation dealed by this resolver */ - Class<A> getAnnotationImpl(); - - /** @return the class of the component which can fired the action */ - Class<C> getComponentImpl(); -} Deleted: trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/initializer/SelectActionConfigConfigurationResolver.java =================================================================== --- trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/initializer/SelectActionConfigConfigurationResolver.java 2008-08-09 10:26:02 UTC (rev 822) +++ trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/initializer/SelectActionConfigConfigurationResolver.java 2008-08-09 10:26:44 UTC (rev 823) @@ -1,55 +0,0 @@ -/** - * # #% Copyright (C) 2008 Code Lutin, Tony Chemit - * This program is free software; you - * can redistribute it and/or modify it under the terms of the GNU General - * Public License as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. This program is - * distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A - * PARTICULAR PURPOSE. See the GNU General Public License for more details. You - * should have received a copy of the GNU General Public License along with this - * program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - * - Suite 330, Boston, MA 02111-1307, USA. - * # #% - */ -package org.codelutin.jaxx.action.initializer; - -import static org.codelutin.i18n.I18n._; -import org.codelutin.jaxx.action.MyAbstractAction; -import org.codelutin.jaxx.action.SelectActionConfig; - -import javax.swing.Action; -import javax.swing.JComboBox; - -/** - * Implementation of configuration's resolver for annotation {@link SelectActionConfig} - * - * @author chemit - */ -public class SelectActionConfigConfigurationResolver extends AbstractActionConfigurationResolver<SelectActionConfig, JComboBox> { - - public SelectActionConfigConfigurationResolver() { - super(SelectActionConfig.class, JComboBox.class); - } - - protected SelectActionConfig applyConfiguration0(JComboBox component, MyAbstractAction action) { - SelectActionConfig anno = resolveConfiguration(action); - if (anno == null) { - return null; - } - // inject les données - if (!anno.name().isEmpty()) { - action.putValue(Action.NAME, _(anno.name())); - } - if (!anno.shortDescription().isEmpty()) { - action.putValue(Action.SHORT_DESCRIPTION, _(anno.shortDescription())); - } else { - action.putValue(Action.SHORT_DESCRIPTION, _(component.getToolTipText())); - } - action.putValue("selectedIndex", anno.selectedIndex()); - //TODO Convert it from String action.putValue(Action.ACCELERATOR_KEY, anno.accelerator()); - action.setEnabled(anno.enabled()); - - return anno; - } -} \ No newline at end of file Deleted: trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/initializer/ToggleActionConfigConfigurationResolver.java =================================================================== --- trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/initializer/ToggleActionConfigConfigurationResolver.java 2008-08-09 10:26:02 UTC (rev 822) +++ trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/initializer/ToggleActionConfigConfigurationResolver.java 2008-08-09 10:26:44 UTC (rev 823) @@ -1,81 +0,0 @@ -/** - * # #% Copyright (C) 2008 Code Lutin, Tony Chemit - * This program is free software; you - * can redistribute it and/or modify it under the terms of the GNU General - * Public License as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. This program is - * distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A - * PARTICULAR PURPOSE. See the GNU General Public License for more details. You - * should have received a copy of the GNU General Public License along with this - * program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - * - Suite 330, Boston, MA 02111-1307, USA. - * # #% - */ -package org.codelutin.jaxx.action.initializer; - -import static org.codelutin.i18n.I18n._; -import org.codelutin.jaxx.action.MyAbstractAction; -import org.codelutin.jaxx.action.ToggleActionConfig; - -import javax.swing.AbstractButton; -import javax.swing.Action; - -/** - * Implementation of configuration's resolver for annotation {@link ToggleActionConfig} - * - * @author chemit - */ -public class ToggleActionConfigConfigurationResolver extends AbstractActionConfigurationResolver<ToggleActionConfig, AbstractButton> { - - public ToggleActionConfigConfigurationResolver() { - super(ToggleActionConfig.class, AbstractButton.class); - } - - protected ToggleActionConfig applyConfiguration0(AbstractButton component, MyAbstractAction action) { - ToggleActionConfig anno = resolveConfiguration(action); - if (anno == null) { - return null; - } - // inject les données - if (!anno.name().isEmpty()) { - //System.out.println("found action with name : " + anno.name()); - action.putValue(Action.NAME, _(anno.name())); - } - if (!anno.name2().isEmpty()) { - //System.out.println("found action with name2 : " + anno.name2()); - action.putValue(Action.NAME + "2", _(anno.name2())); - } - - if (!anno.shortDescription().isEmpty()) { - action.putValue(Action.SHORT_DESCRIPTION, _(anno.shortDescription())); - } - if (!anno.shortDescription2().isEmpty()) { - action.putValue(Action.SHORT_DESCRIPTION + "2", _(anno.shortDescription2())); - } - - if (!anno.smallIcon().isEmpty()) { - action.putValue(Action.SMALL_ICON, org.codelutin.jaxx.util.UIHelper.createImageIcon(anno.smallIcon())); - } - if (!anno.smallIcon2().isEmpty()) { - action.putValue(Action.SMALL_ICON + "2", org.codelutin.jaxx.util.UIHelper.createImageIcon(anno.smallIcon2())); - } - - if (anno.mnemonic() != '\0') { - action.putValue(Action.MNEMONIC_KEY, anno.mnemonic()); - } else if (component != null) { - action.putValue(Action.MNEMONIC_KEY, component.getMnemonic()); - } - if (anno.mnemonic2() != '\0') { - action.putValue(Action.MNEMONIC_KEY + "2", anno.mnemonic2()); - } - //TODO Convert it from String action.putValue(Action.ACCELERATOR_KEY, anno.accelerator()); - - - action.putValue("hideActionText", anno.hideActionText()); - action.putValue(Action.SELECTED_KEY, anno.selected()); - action.setEnabled(anno.enabled()); - - return anno; - } -} \ No newline at end of file