Jaxx-commits
Threads by month
- ----- 2026 -----
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2005 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2004 -----
- December
- November
- October
- September
- August
- 3898 discussions
[Buix-commits] r800 - trunk/lutinjaxx/core/src/main/java/jaxx/tags
by tchemit@users.labs.libre-entreprise.org 28 Jul '08
by tchemit@users.labs.libre-entreprise.org 28 Jul '08
28 Jul '08
Author: tchemit
Date: 2008-07-28 09:13:35 +0000 (Mon, 28 Jul 2008)
New Revision: 800
Modified:
trunk/lutinjaxx/core/src/main/java/jaxx/tags/DefaultComponentHandler.java
Log:
fix bug : tagHandler is not always found...
reformat
log
Modified: trunk/lutinjaxx/core/src/main/java/jaxx/tags/DefaultComponentHandler.java
===================================================================
--- trunk/lutinjaxx/core/src/main/java/jaxx/tags/DefaultComponentHandler.java 2008-07-25 21:23:01 UTC (rev 799)
+++ trunk/lutinjaxx/core/src/main/java/jaxx/tags/DefaultComponentHandler.java 2008-07-28 09:13:35 UTC (rev 800)
@@ -10,6 +10,8 @@
import jaxx.compiler.JAXXCompiler;
import jaxx.reflect.ClassDescriptor;
import jaxx.reflect.ClassDescriptorLoader;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.w3c.dom.Element;
import java.awt.Component;
@@ -20,13 +22,17 @@
import java.beans.IntrospectionException;
import java.io.IOException;
import java.lang.reflect.Field;
+import java.util.Arrays;
import java.util.List;
-import java.util.Arrays;
public class DefaultComponentHandler extends DefaultObjectHandler {
+ /** log */
+ protected static final Log log = LogFactory.getLog(DefaultComponentHandler.class);
+
private String containerDelegate;
- private static final List<String> I18N_ATTRIBUTES = Arrays.asList("text","title","toolTipText");
+ private static final List<String> I18N_ATTRIBUTES = Arrays.asList("text", "title", "toolTipText");
+
public DefaultComponentHandler(ClassDescriptor beanClass) {
super(beanClass);
ClassDescriptorLoader.checkSupportClass(getClass(), beanClass, Component.class);
@@ -46,7 +52,12 @@
if (tagHandler instanceof DefaultComponentHandler) {
containerDelegate = ((DefaultComponentHandler) tagHandler).getContainerDelegate();
} else {
- System.out.println("could not find componentHandler for "+getBeanClass());
+ tagHandler = TagManager.getTagHandler(getBeanClass());
+ if (tagHandler instanceof DefaultComponentHandler) {
+ containerDelegate = ((DefaultComponentHandler) tagHandler).getContainerDelegate();
+ } else {
+ log.warn("could not find componentHandler for " + getBeanClass());
+ }
}
}
}
@@ -194,7 +205,7 @@
// ajout du support i18n
if (I18N_ATTRIBUTES.contains(name)) {
if (valueCode.contains("_(") || valueCode.contains(")")) {
- compiler.reportWarning("\n\tjaxx supports i18n, no need to add explicit call to I18n._ for attribute '"+name+"' in component '"+id+"'");
+ compiler.reportWarning("\n\tjaxx supports i18n, no need to add explicit call to I18n._ for attribute '" + name + "' in component '" + id + "'");
} else {
valueCode = "_(" + valueCode + ")";
}
1
0
[Buix-commits] r799 - in trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action: factory initializer
by tchemit@users.labs.libre-entreprise.org 25 Jul '08
by tchemit@users.labs.libre-entreprise.org 25 Jul '08
25 Jul '08
Author: tchemit
Date: 2008-07-25 21:23:01 +0000 (Fri, 25 Jul 2008)
New Revision: 799
Added:
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
Removed:
trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/initializer/AbstractActionInitializer.java
trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/initializer/ActionConfigInitializer.java
trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/initializer/ActionInitializer.java
trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/initializer/SelectActionConfigInitializer.java
trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/initializer/ToggleActionConfigInitializer.java
Modified:
trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/factory/AbstractActionFactory.java
Log:
rename ActionInitializer to ActionConfigurationResolver
Modified: trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/factory/AbstractActionFactory.java
===================================================================
--- trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/factory/AbstractActionFactory.java 2008-07-25 21:21:46 UTC (rev 798)
+++ trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/factory/AbstractActionFactory.java 2008-07-25 21:23:01 UTC (rev 799)
@@ -23,11 +23,11 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.codelutin.jaxx.action.MyAbstractAction;
-import org.codelutin.jaxx.action.initializer.AbstractActionInitializer;
-import org.codelutin.jaxx.action.initializer.ActionConfigInitializer;
-import org.codelutin.jaxx.action.initializer.ActionInitializer;
-import org.codelutin.jaxx.action.initializer.SelectActionConfigInitializer;
-import org.codelutin.jaxx.action.initializer.ToggleActionConfigInitializer;
+import org.codelutin.jaxx.action.initializer.AbstractActionConfigurationResolver;
+import org.codelutin.jaxx.action.initializer.ActionConfigConfigurationResolver;
+import org.codelutin.jaxx.action.initializer.ActionConfigurationResolver;
+import org.codelutin.jaxx.action.initializer.SelectActionConfigConfigurationResolver;
+import org.codelutin.jaxx.action.initializer.ToggleActionConfigConfigurationResolver;
import javax.swing.AbstractButton;
import javax.swing.Action;
@@ -68,22 +68,22 @@
/** dictionary of instanciated actions */
private Map<String, A> cache;
- protected final ActionConfigInitializer actionConfigInitializer;
- protected final ToggleActionConfigInitializer toggleActionConfigInitializer;
- protected final SelectActionConfigInitializer selectActionConfigInitializer;
+ protected final ActionConfigConfigurationResolver actionConfigInitializer;
+ protected final ToggleActionConfigConfigurationResolver toggleActionConfigInitializer;
+ protected final SelectActionConfigConfigurationResolver selectActionConfigInitializer;
- protected List<AbstractActionInitializer> configurationResolvers;
+ protected List<AbstractActionConfigurationResolver> configurationResolvers;
protected AbstractActionFactory(Class<A> baseImpl) {
this.baseImpl = baseImpl;
this.impls = init();
this.cache = new TreeMap<String, A>();
- this.configurationResolvers = new java.util.ArrayList<AbstractActionInitializer>();
+ this.configurationResolvers = new java.util.ArrayList<AbstractActionConfigurationResolver>();
- this.toggleActionConfigInitializer = registerInitializer(ToggleActionConfigInitializer.class);
- this.actionConfigInitializer = registerInitializer(ActionConfigInitializer.class);
- this.selectActionConfigInitializer = registerInitializer(SelectActionConfigInitializer.class);
+ this.toggleActionConfigInitializer = registerInitializer(ToggleActionConfigConfigurationResolver.class);
+ this.actionConfigInitializer = registerInitializer(ActionConfigConfigurationResolver.class);
+ this.selectActionConfigInitializer = registerInitializer(SelectActionConfigConfigurationResolver.class);
}
public Class<A> getBaseImpl() {
@@ -178,33 +178,33 @@
}
// recherche de l'annotation de configuration
- ActionInitializer<?, ?> initializer = resolveActionConfiguration(result);
+ ActionConfigurationResolver<?, ?> configurationResolver = resolveActionConfiguration(result);
- if (initializer != null) {
- initializer.applyConfiguration(component, result);
+ if (configurationResolver != null) {
+ configurationResolver.applyConfiguration(component, result);
}
try {
- if (initializer != null) {
- if (AbstractButton.class.isAssignableFrom(initializer.getComponentImpl())) {
- finalizeNewAction((AbstractButton) component, result, initializer);
+ if (configurationResolver != null) {
+ if (AbstractButton.class.isAssignableFrom(configurationResolver.getComponentImpl())) {
+ finalizeNewAction((AbstractButton) component, result, configurationResolver);
}
- if (JComboBox.class.isAssignableFrom(initializer.getComponentImpl())) {
- finalizeNewAction((JComboBox) component, result, initializer);
+ if (JComboBox.class.isAssignableFrom(configurationResolver.getComponentImpl())) {
+ finalizeNewAction((JComboBox) component, result, configurationResolver);
}
return result;
}
if (component == null || component instanceof AbstractButton) {
- finalizeNewAction((AbstractButton) component, result, initializer);
+ finalizeNewAction((AbstractButton) component, result, configurationResolver);
return result;
}
if (component instanceof JComboBox) {
- finalizeNewAction((JComboBox) component, result, initializer);
+ finalizeNewAction((JComboBox) component, result, configurationResolver);
}
} finally {
// save result in cache
@@ -280,14 +280,14 @@
}
/**
- * @param component le button o� rattacher l'action
- * @param action action
- * @param initializer initializer
+ * @param component le button o� rattacher l'action
+ * @param action action
+ * @param configurationResolver initializer
*/
- protected void finalizeNewAction(AbstractButton component, MyAbstractAction action, ActionInitializer<?, ?> initializer) {
+ protected void finalizeNewAction(AbstractButton component, MyAbstractAction action, ActionConfigurationResolver<?, ?> configurationResolver) {
- if (initializer == null) {
- // no initializer matching,
+ if (configurationResolver == null) {
+ // no configurationResolver matching,
if (component != null) {
action.putValue(Action.ACTION_COMMAND_KEY, component.getName());
action.putValue(Action.SHORT_DESCRIPTION, component.getToolTipText());
@@ -323,13 +323,13 @@
}
/**
- * @param component le select box o� rattacher l'action
- * @param action action
- * @param initializer initializer
+ * @param component le select box o� rattacher l'action
+ * @param action action
+ * @param configurationResolver initializer
*/
- protected void finalizeNewAction(JComboBox component, MyAbstractAction action, ActionInitializer<?, ?> initializer) {
+ protected void finalizeNewAction(JComboBox component, MyAbstractAction action, ActionConfigurationResolver<?, ?> configurationResolver) {
- if (initializer == null) {
+ if (configurationResolver == null) {
action.putValue(Action.ACTION_COMMAND_KEY, component.getName());
action.putValue(Action.SHORT_DESCRIPTION, component.getToolTipText());
//result.putValue("selectedIndex", component.getSelectedIndex());
@@ -337,8 +337,8 @@
}
- protected ActionInitializer resolveActionConfiguration(MyAbstractAction action) {
- for (ActionInitializer resolver : configurationResolvers) {
+ protected ActionConfigurationResolver resolveActionConfiguration(MyAbstractAction action) {
+ for (ActionConfigurationResolver resolver : configurationResolvers) {
if (resolver.resolveConfiguration(action) != null) {
return resolver;
}
@@ -346,7 +346,7 @@
return null;
}
- protected <I extends AbstractActionInitializer> I registerInitializer(Class<I> initizalizer) {
+ protected <I extends AbstractActionConfigurationResolver> I registerInitializer(Class<I> initizalizer) {
try {
I instance = initizalizer.newInstance();
configurationResolvers.add(instance);
Copied: trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/initializer/AbstractActionConfigurationResolver.java (from rev 797, trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/initializer/AbstractActionInitializer.java)
===================================================================
--- trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/initializer/AbstractActionConfigurationResolver.java (rev 0)
+++ trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/initializer/AbstractActionConfigurationResolver.java 2008-07-25 21:23:01 UTC (rev 799)
@@ -0,0 +1,72 @@
+/**
+ * # #% 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/AbstractActionInitializer.java
===================================================================
--- trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/initializer/AbstractActionInitializer.java 2008-07-25 21:21:46 UTC (rev 798)
+++ trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/initializer/AbstractActionInitializer.java 2008-07-25 21:23:01 UTC (rev 799)
@@ -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 AbstractActionInitializer<A extends java.lang.annotation.Annotation, C extends JComponent> implements ActionInitializer<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 AbstractActionInitializer(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/initializer/ActionConfigConfigurationResolver.java (from rev 797, trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/initializer/ActionConfigInitializer.java)
===================================================================
--- trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/initializer/ActionConfigConfigurationResolver.java (rev 0)
+++ trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/initializer/ActionConfigConfigurationResolver.java 2008-07-25 21:23:01 UTC (rev 799)
@@ -0,0 +1,69 @@
+/**
+ * # #% 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/ActionConfigInitializer.java
===================================================================
--- trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/initializer/ActionConfigInitializer.java 2008-07-25 21:21:46 UTC (rev 798)
+++ trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/initializer/ActionConfigInitializer.java 2008-07-25 21:23:01 UTC (rev 799)
@@ -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 ActionConfigInitializer extends AbstractActionInitializer<ActionConfig, AbstractButton> {
-
- public ActionConfigInitializer() {
- 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/initializer/ActionConfigurationResolver.java (from rev 797, trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/initializer/ActionInitializer.java)
===================================================================
--- trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/initializer/ActionConfigurationResolver.java (rev 0)
+++ trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/initializer/ActionConfigurationResolver.java 2008-07-25 21:23:01 UTC (rev 799)
@@ -0,0 +1,54 @@
+/**
+ * # #% 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/ActionInitializer.java
===================================================================
--- trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/initializer/ActionInitializer.java 2008-07-25 21:21:46 UTC (rev 798)
+++ trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/initializer/ActionInitializer.java 2008-07-25 21:23:01 UTC (rev 799)
@@ -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 ActionInitializer<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/initializer/SelectActionConfigConfigurationResolver.java (from rev 797, trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/initializer/SelectActionConfigInitializer.java)
===================================================================
--- trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/initializer/SelectActionConfigConfigurationResolver.java (rev 0)
+++ trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/initializer/SelectActionConfigConfigurationResolver.java 2008-07-25 21:23:01 UTC (rev 799)
@@ -0,0 +1,55 @@
+/**
+ * # #% 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/SelectActionConfigInitializer.java
===================================================================
--- trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/initializer/SelectActionConfigInitializer.java 2008-07-25 21:21:46 UTC (rev 798)
+++ trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/initializer/SelectActionConfigInitializer.java 2008-07-25 21:23:01 UTC (rev 799)
@@ -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 SelectActionConfigInitializer extends AbstractActionInitializer<SelectActionConfig, JComboBox> {
-
- public SelectActionConfigInitializer() {
- 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/initializer/ToggleActionConfigConfigurationResolver.java (from rev 797, trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/initializer/ToggleActionConfigInitializer.java)
===================================================================
--- trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/initializer/ToggleActionConfigConfigurationResolver.java (rev 0)
+++ trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/initializer/ToggleActionConfigConfigurationResolver.java 2008-07-25 21:23:01 UTC (rev 799)
@@ -0,0 +1,81 @@
+/**
+ * # #% 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
Deleted: trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/initializer/ToggleActionConfigInitializer.java
===================================================================
--- trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/initializer/ToggleActionConfigInitializer.java 2008-07-25 21:21:46 UTC (rev 798)
+++ trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/initializer/ToggleActionConfigInitializer.java 2008-07-25 21:23:01 UTC (rev 799)
@@ -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 ToggleActionConfigInitializer extends AbstractActionInitializer<ToggleActionConfig, AbstractButton> {
-
- public ToggleActionConfigInitializer() {
- 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
1
0
[Buix-commits] r798 - trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/factory
by tchemit@users.labs.libre-entreprise.org 25 Jul '08
by tchemit@users.labs.libre-entreprise.org 25 Jul '08
25 Jul '08
Author: tchemit
Date: 2008-07-25 21:21:46 +0000 (Fri, 25 Jul 2008)
New Revision: 798
Modified:
trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/factory/AbstractActionFactory.java
trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/factory/ActionFactory.java
Log:
ActionInitializer must be search annotation of instance of Action, and not on his class since Action could not be holder of configuration (with delegation)...
add javadoc.
Modified: trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/factory/AbstractActionFactory.java
===================================================================
--- trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/factory/AbstractActionFactory.java 2008-07-25 21:20:58 UTC (rev 797)
+++ trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/factory/AbstractActionFactory.java 2008-07-25 21:21:46 UTC (rev 798)
@@ -29,7 +29,6 @@
import org.codelutin.jaxx.action.initializer.SelectActionConfigInitializer;
import org.codelutin.jaxx.action.initializer.ToggleActionConfigInitializer;
-import javax.swing.AbstractAction;
import javax.swing.AbstractButton;
import javax.swing.Action;
import javax.swing.Icon;
@@ -73,14 +72,14 @@
protected final ToggleActionConfigInitializer toggleActionConfigInitializer;
protected final SelectActionConfigInitializer selectActionConfigInitializer;
- protected List<AbstractActionInitializer> registredInitializers;
+ protected List<AbstractActionInitializer> configurationResolvers;
protected AbstractActionFactory(Class<A> baseImpl) {
this.baseImpl = baseImpl;
this.impls = init();
this.cache = new TreeMap<String, A>();
- this.registredInitializers = new java.util.ArrayList<AbstractActionInitializer>();
+ this.configurationResolvers = new java.util.ArrayList<AbstractActionInitializer>();
this.toggleActionConfigInitializer = registerInitializer(ToggleActionConfigInitializer.class);
this.actionConfigInitializer = registerInitializer(ActionConfigInitializer.class);
@@ -103,7 +102,6 @@
if (log.isDebugEnabled()) {
log.debug("for ui " + ui.getClass());
}
- //List<A> result = new ArrayList<A>();
for (Map.Entry<String, Class<? extends MyAbstractAction>> entry : implsEntrySet()) {
String actionKey = entry.getKey();
Object comp = ui.getObjectById(actionKey);
@@ -142,7 +140,6 @@
Boolean value = (Boolean) action.getValue("hideActionText");
component.setHideActionText(value != null && value);
action.setEnabled(true);
- //result.add(action);
continue;
}
// is JComboBox
@@ -154,9 +151,7 @@
if (val != null && val != -1 && val < component.getItemCount() && val != component.getSelectedIndex()) {
component.setSelectedIndex(val);
}
- //result.add(action);
}
- //return (A[]) result.toArray(new MyAbstractAction[result.size()]);
}
/**
@@ -183,10 +178,10 @@
}
// recherche de l'annotation de configuration
- ActionInitializer<?, ?> initializer = findInitializer(result.getClass());
+ ActionInitializer<?, ?> initializer = resolveActionConfiguration(result);
if (initializer != null) {
- initializer.initAction(component, result);
+ initializer.applyConfiguration(component, result);
}
try {
@@ -342,10 +337,10 @@
}
- protected ActionInitializer findInitializer(Class<? extends AbstractAction> action) {
- for (ActionInitializer registredInitializer : registredInitializers) {
- if (registredInitializer.getAnnotation(action) != null) {
- return registredInitializer;
+ protected ActionInitializer resolveActionConfiguration(MyAbstractAction action) {
+ for (ActionInitializer resolver : configurationResolvers) {
+ if (resolver.resolveConfiguration(action) != null) {
+ return resolver;
}
}
return null;
@@ -354,7 +349,7 @@
protected <I extends AbstractActionInitializer> I registerInitializer(Class<I> initizalizer) {
try {
I instance = initizalizer.newInstance();
- registredInitializers.add(instance);
+ configurationResolvers.add(instance);
return instance;
} catch (Exception e) {
throw new RuntimeException(e);
Modified: trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/factory/ActionFactory.java
===================================================================
--- trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/factory/ActionFactory.java 2008-07-25 21:20:58 UTC (rev 797)
+++ trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/factory/ActionFactory.java 2008-07-25 21:21:46 UTC (rev 798)
@@ -108,7 +108,7 @@
void fireAction(String actionKey, Object source);
/**
- * Fire an action given his action's key, his source and the reaal action.
+ * Fire an action given his action's key, his source and the real action.
* <p/>
* This is a convinient method when you need to modified action before fire it.
*
1
0
[Buix-commits] r797 - trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/initializer
by tchemit@users.labs.libre-entreprise.org 25 Jul '08
by tchemit@users.labs.libre-entreprise.org 25 Jul '08
25 Jul '08
Author: tchemit
Date: 2008-07-25 21:20:58 +0000 (Fri, 25 Jul 2008)
New Revision: 797
Modified:
trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/initializer/AbstractActionInitializer.java
trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/initializer/ActionConfigInitializer.java
trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/initializer/ActionInitializer.java
trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/initializer/SelectActionConfigInitializer.java
trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/initializer/ToggleActionConfigInitializer.java
Log:
ActionInitializer must be search annotation of instance of Action, and not on his class since Action could not be holder of configuration (with delegation)...
add javadoc.
Modified: trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/initializer/AbstractActionInitializer.java
===================================================================
--- trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/initializer/AbstractActionInitializer.java 2008-07-25 17:55:55 UTC (rev 796)
+++ trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/initializer/AbstractActionInitializer.java 2008-07-25 21:20:58 UTC (rev 797)
@@ -14,35 +14,50 @@
*/
package org.codelutin.jaxx.action.initializer;
-import javax.swing.AbstractAction;
+import org.codelutin.jaxx.action.MyAbstractAction;
+
import javax.swing.JComponent;
/**
- * Initializer of a MyAbstractAction described by a typed Annotation <code>A</code> and for a certain type
- * <code>C</code> of component.
+ * 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 AbstractActionInitializer<A extends java.lang.annotation.Annotation, C extends JComponent> implements ActionInitializer<A, C> {
- final Class<A> annotationImpl;
- final Class<C> componentImpl;
+ /** the type of configuration's annotation */
+ protected final Class<A> annotationImpl;
- protected abstract A initAction0(C component, AbstractAction action);
+ /** 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 AbstractActionInitializer(Class<A> annotationImpl, Class<C> componentImpl) {
this.annotationImpl = annotationImpl;
this.componentImpl = componentImpl;
}
- public A getAnnotation(Class<? extends AbstractAction> action) {
- return action.getAnnotation(annotationImpl);
+ public A resolveConfiguration(MyAbstractAction action) {
+ if (action.hasDelegate()) {
+ return resolveConfiguration(action.getDelegate());
+ }
+ return action.getClass().getAnnotation(annotationImpl);
}
@SuppressWarnings({"unchecked"})
- public A initAction(JComponent component, AbstractAction action) {
+ public A applyConfiguration(JComponent component, MyAbstractAction action) {
if (component != null && componentImpl.isAssignableFrom(component.getClass()))
- return initAction0((C) component, action);
+ return applyConfiguration0((C) component, action);
return null;
}
Modified: trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/initializer/ActionConfigInitializer.java
===================================================================
--- trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/initializer/ActionConfigInitializer.java 2008-07-25 17:55:55 UTC (rev 796)
+++ trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/initializer/ActionConfigInitializer.java 2008-07-25 21:20:58 UTC (rev 797)
@@ -16,20 +16,24 @@
import static org.codelutin.i18n.I18n._;
import org.codelutin.jaxx.action.ActionConfig;
+import org.codelutin.jaxx.action.MyAbstractAction;
-import javax.swing.AbstractAction;
import javax.swing.AbstractButton;
import javax.swing.Action;
-/** @author chemit */
+/**
+ * Implementation of configuration's resolver for annotation {@link ActionConfig}
+ *
+ * @author chemit
+ */
public class ActionConfigInitializer extends AbstractActionInitializer<ActionConfig, AbstractButton> {
public ActionConfigInitializer() {
super(ActionConfig.class, AbstractButton.class);
}
- protected ActionConfig initAction0(AbstractButton component, AbstractAction action) {
- ActionConfig anno = getAnnotation(action.getClass());
+ protected ActionConfig applyConfiguration0(AbstractButton component, MyAbstractAction action) {
+ ActionConfig anno = resolveConfiguration(action);
if (anno == null) {
return null;
}
Modified: trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/initializer/ActionInitializer.java
===================================================================
--- trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/initializer/ActionInitializer.java 2008-07-25 17:55:55 UTC (rev 796)
+++ trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/initializer/ActionInitializer.java 2008-07-25 21:20:58 UTC (rev 797)
@@ -14,17 +14,41 @@
*/
package org.codelutin.jaxx.action.initializer;
-import javax.swing.AbstractAction;
+import org.codelutin.jaxx.action.MyAbstractAction;
+
import javax.swing.JComponent;
-/** @author chemit */
+/**
+ * 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 ActionInitializer<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);
- A getAnnotation(Class<? extends AbstractAction> action);
+ /**
+ * @param component widget that requires the action
+ * @param action given action
+ * @return the configuration of the action
+ */
+ A applyConfiguration(JComponent component, MyAbstractAction action);
- A initAction(JComponent component, AbstractAction 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();
}
Modified: trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/initializer/SelectActionConfigInitializer.java
===================================================================
--- trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/initializer/SelectActionConfigInitializer.java 2008-07-25 17:55:55 UTC (rev 796)
+++ trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/initializer/SelectActionConfigInitializer.java 2008-07-25 21:20:58 UTC (rev 797)
@@ -15,21 +15,25 @@
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.AbstractAction;
import javax.swing.Action;
import javax.swing.JComboBox;
-/** @author chemit */
+/**
+ * Implementation of configuration's resolver for annotation {@link SelectActionConfig}
+ *
+ * @author chemit
+ */
public class SelectActionConfigInitializer extends AbstractActionInitializer<SelectActionConfig, JComboBox> {
public SelectActionConfigInitializer() {
super(SelectActionConfig.class, JComboBox.class);
}
- protected SelectActionConfig initAction0(JComboBox component, AbstractAction action) {
- SelectActionConfig anno = getAnnotation(action.getClass());
+ protected SelectActionConfig applyConfiguration0(JComboBox component, MyAbstractAction action) {
+ SelectActionConfig anno = resolveConfiguration(action);
if (anno == null) {
return null;
}
Modified: trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/initializer/ToggleActionConfigInitializer.java
===================================================================
--- trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/initializer/ToggleActionConfigInitializer.java 2008-07-25 17:55:55 UTC (rev 796)
+++ trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/initializer/ToggleActionConfigInitializer.java 2008-07-25 21:20:58 UTC (rev 797)
@@ -15,21 +15,25 @@
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.AbstractAction;
import javax.swing.AbstractButton;
import javax.swing.Action;
-/** @author chemit */
+/**
+ * Implementation of configuration's resolver for annotation {@link ToggleActionConfig}
+ *
+ * @author chemit
+ */
public class ToggleActionConfigInitializer extends AbstractActionInitializer<ToggleActionConfig, AbstractButton> {
public ToggleActionConfigInitializer() {
super(ToggleActionConfig.class, AbstractButton.class);
}
- protected ToggleActionConfig initAction0(AbstractButton component, AbstractAction action) {
- ToggleActionConfig anno = getAnnotation(action.getClass());
+ protected ToggleActionConfig applyConfiguration0(AbstractButton component, MyAbstractAction action) {
+ ToggleActionConfig anno = resolveConfiguration(action);
if (anno == null) {
return null;
}
1
0
[Buix-commits] r796 - trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/provider
by tchemit@users.labs.libre-entreprise.org 25 Jul '08
by tchemit@users.labs.libre-entreprise.org 25 Jul '08
25 Jul '08
Author: tchemit
Date: 2008-07-25 17:55:55 +0000 (Fri, 25 Jul 2008)
New Revision: 796
Modified:
trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/provider/ActionProvider.java
Log:
ActionProviderjavadoc
Modified: trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/provider/ActionProvider.java
===================================================================
--- trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/provider/ActionProvider.java 2008-07-25 17:55:34 UTC (rev 795)
+++ trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/provider/ActionProvider.java 2008-07-25 17:55:55 UTC (rev 796)
@@ -17,7 +17,9 @@
import org.codelutin.jaxx.action.MyAbstractAction;
/**
- * Contract to be realized by a provider of Actions
+ * Contract to be realized by a provider of Actions.
+ * <p/>
+ * A provider of actions
*
* @author chemit
*/
1
0
[Buix-commits] r795 - trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/factory
by tchemit@users.labs.libre-entreprise.org 25 Jul '08
by tchemit@users.labs.libre-entreprise.org 25 Jul '08
25 Jul '08
Author: tchemit
Date: 2008-07-25 17:55:34 +0000 (Fri, 25 Jul 2008)
New Revision: 795
Modified:
trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/factory/AbstractActionFactory.java
trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/factory/ActionFactory.java
Log:
ActionFactory javadoc
add methode newAction(String) to ActionFactory
Modified: trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/factory/AbstractActionFactory.java
===================================================================
--- trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/factory/AbstractActionFactory.java 2008-07-25 14:00:19 UTC (rev 794)
+++ trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/factory/AbstractActionFactory.java 2008-07-25 17:55:34 UTC (rev 795)
@@ -219,6 +219,10 @@
return result;
}
+ public A newAction(String actionKey) {
+ return newAction(actionKey, null);
+ }
+
public String[] getActionNames() {
return impls.keySet().toArray(new String[impls.size()]);
}
Modified: trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/factory/ActionFactory.java
===================================================================
--- trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/factory/ActionFactory.java 2008-07-25 14:00:19 UTC (rev 794)
+++ trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/factory/ActionFactory.java 2008-07-25 17:55:34 UTC (rev 795)
@@ -41,29 +41,92 @@
*/
Map<String, Class<? extends MyAbstractAction>> init();
+ /** @return the class of the base action of the factory. */
Class<A> getBaseImpl();
+ /** clear the cache of instanciated actions. */
void resetCache();
+ /**
+ * @param actionKey the key of an action
+ * @return the action with this key from cache, or <code>null</code> if this action is not in cache
+ */
A get(String actionKey);
+ /**
+ * For a given ui, load all actions registred in factory.
+ * <p/>
+ * The id of the widget in ui is directly mapped to a action key.
+ *
+ * @param ui the ui to treate
+ */
void loadActions(JAXXObject ui);
+ /**
+ * Obtain an action instance given his key and widget
+ *
+ * @param actionKey the key of action
+ * @param component the component using the action
+ * @return the instanciated action (could come from cache if already instanciated {@link #getActionFromCache(String)}
+ */
A newAction(String actionKey, JComponent component);
+ /**
+ * Obtain an action instance given his key (should call {@link #newAction(String, javax.swing.JComponent)}
+ * <p/>
+ * This is a convinient method when you want to obtain an action with no attached widget.
+ *
+ * @param actionKey the key of action
+ * @return the instanciated action (could come from cache if already instanciated {@link #getActionFromCache(String)}
+ */
+ A newAction(String actionKey);
+
+ /** @return the array of names of all actions known by the factory */
String[] getActionNames();
+ /** @return the set of all the action's classes known by the factory. */
Set<Entry<String, Class<? extends MyAbstractAction>>> implsEntrySet();
+ /** @return the set of all actions cached in factory indexed by their name */
Set<Entry<String, A>> cacheEntrySet();
+ /**
+ * Fire an action given his key, his source and tthe widget responsible of action
+ *
+ * @param actionKey the action's key
+ * @param source the object source of action
+ * @param component the component doing the action
+ */
void fireAction(String actionKey, Object source, JComponent component);
+ /**
+ * Fire an action given his key and his source, no widget are involved here
+ *
+ * @param actionKey the action's key
+ * @param source the object source of action
+ */
void fireAction(String actionKey, Object source);
+ /**
+ * Fire an action given his action's key, his source and the reaal action.
+ * <p/>
+ * This is a convinient method when you need to modified action before fire it.
+ *
+ * @param actionKey action's key
+ * @param source source of action
+ * @param action real action
+ */
void fireAction0(String actionKey, Object source, A action);
+ /**
+ * @param actionKey the action's key
+ * @return the action in cache or <code>null</code> if action is not in cache
+ */
MyAbstractAction getActionFromCache(String actionKey);
+ /**
+ * dispose all actions in cache using {@link org.codelutin.jaxx.action.MyAbstractAction#disposeUI()} on each
+ * action, then {@link #resetCache()}
+ */
void dispose();
}
1
0
[Buix-commits] r794 - in trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action: . factory
by tchemit@users.labs.libre-entreprise.org 25 Jul '08
by tchemit@users.labs.libre-entreprise.org 25 Jul '08
25 Jul '08
Author: tchemit
Date: 2008-07-25 14:00:19 +0000 (Fri, 25 Jul 2008)
New Revision: 794
Modified:
trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/MyAbstractAction.java
trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/factory/AbstractActionFactory.java
trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/factory/ActionFactory.java
Log:
add fireAction0 in ActionFactory contract
add setStatus method in MyAbstractAction
Modified: trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/MyAbstractAction.java
===================================================================
--- trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/MyAbstractAction.java 2008-07-25 13:58:48 UTC (rev 793)
+++ trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/MyAbstractAction.java 2008-07-25 14:00:19 UTC (rev 794)
@@ -16,6 +16,7 @@
import jaxx.runtime.JAXXObject;
import org.apache.commons.logging.LogFactory;
+import static org.codelutin.i18n.I18n._;
import javax.swing.AbstractAction;
import javax.swing.Action;
@@ -65,6 +66,7 @@
}
if (accepted) {
doAction(e);
+ setStatus(_("jaxx.action.done", getName()));
updateUI();
}
} catch (Exception e1) {
@@ -105,10 +107,21 @@
return delegate != null;
}
+ protected String getName() {
+ return (String) getValue(NAME);
+ }
+
protected String getActionName() {
return (String) getValue(ACTION_COMMAND_KEY);
}
+ protected void setStatus(String status) {
+ // do nothing from here
+ if (log.isDebugEnabled()) {
+ log.debug(status);
+ }
+ }
+
protected boolean beforeAction(ActionEvent evt) throws Exception {
boolean enabled = isEnabled();
if (enabled && hasDelegate()) {
Modified: trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/factory/AbstractActionFactory.java
===================================================================
--- trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/factory/AbstractActionFactory.java 2008-07-25 13:58:48 UTC (rev 793)
+++ trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/factory/AbstractActionFactory.java 2008-07-25 14:00:19 UTC (rev 794)
@@ -357,7 +357,7 @@
}
}
- protected void fireAction0(String actionKey, Object source, A action) {
+ public void fireAction0(String actionKey, Object source, A action) {
if (action == null) {
log.warn("could not find action " + actionKey);
return;
Modified: trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/factory/ActionFactory.java
===================================================================
--- trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/factory/ActionFactory.java 2008-07-25 13:58:48 UTC (rev 793)
+++ trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/factory/ActionFactory.java 2008-07-25 14:00:19 UTC (rev 794)
@@ -61,6 +61,8 @@
void fireAction(String actionKey, Object source);
+ void fireAction0(String actionKey, Object source, A action);
+
MyAbstractAction getActionFromCache(String actionKey);
void dispose();
1
0
[Buix-commits] r793 - trunk/lutinjaxx/maven/src/main/java
by tchemit@users.labs.libre-entreprise.org 25 Jul '08
by tchemit@users.labs.libre-entreprise.org 25 Jul '08
25 Jul '08
Author: tchemit
Date: 2008-07-25 13:58:48 +0000 (Fri, 25 Jul 2008)
New Revision: 793
Removed:
trunk/lutinjaxx/maven/src/main/java/jaxx/
Log:
no more use
1
0
[Buix-commits] r792 - trunk/lutinjaxx/jaxx-swing-action/src/main/resources/i18n
by tchemit@users.labs.libre-entreprise.org 25 Jul '08
by tchemit@users.labs.libre-entreprise.org 25 Jul '08
25 Jul '08
Author: tchemit
Date: 2008-07-25 13:58:29 +0000 (Fri, 25 Jul 2008)
New Revision: 792
Modified:
trunk/lutinjaxx/jaxx-swing-action/src/main/resources/i18n/jaxx-swing-action-en_GB.properties
trunk/lutinjaxx/jaxx-swing-action/src/main/resources/i18n/jaxx-swing-action-fr_FR.properties
Log:
i18n
Modified: trunk/lutinjaxx/jaxx-swing-action/src/main/resources/i18n/jaxx-swing-action-en_GB.properties
===================================================================
--- trunk/lutinjaxx/jaxx-swing-action/src/main/resources/i18n/jaxx-swing-action-en_GB.properties 2008-07-24 20:59:46 UTC (rev 791)
+++ trunk/lutinjaxx/jaxx-swing-action/src/main/resources/i18n/jaxx-swing-action-en_GB.properties 2008-07-25 13:58:29 UTC (rev 792)
@@ -1,3 +1,4 @@
+jaxx.action.done=Action ''{0}'' done.
jaxx.error.close.actions.file=Error while closing file of actions
jaxx.error.load.actions.class=Error while loading actions
jaxx.error.load.actions.file=Error while loading file of actions
Modified: trunk/lutinjaxx/jaxx-swing-action/src/main/resources/i18n/jaxx-swing-action-fr_FR.properties
===================================================================
--- trunk/lutinjaxx/jaxx-swing-action/src/main/resources/i18n/jaxx-swing-action-fr_FR.properties 2008-07-24 20:59:46 UTC (rev 791)
+++ trunk/lutinjaxx/jaxx-swing-action/src/main/resources/i18n/jaxx-swing-action-fr_FR.properties 2008-07-25 13:58:29 UTC (rev 792)
@@ -1,3 +1,4 @@
+jaxx.action.done=Action ''{0}'' termin\u00E9e.
jaxx.error.close.actions.file=Erreur lors de la fermeture du fichier d'actions
jaxx.error.load.actions.class=Erreur lors du chargement des actions
jaxx.error.load.actions.file=Erreur lors du chargement du fchier d'actions
1
0
[Buix-commits] r791 - in trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action: . factory
by tchemit@users.labs.libre-entreprise.org 24 Jul '08
by tchemit@users.labs.libre-entreprise.org 24 Jul '08
24 Jul '08
Author: tchemit
Date: 2008-07-24 20:59:46 +0000 (Thu, 24 Jul 2008)
New Revision: 791
Modified:
trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/MyAbstractAction.java
trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/factory/AbstractActionFactory.java
trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/factory/ActionFactory.java
trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/factory/ActionFactoryFromProvider.java
Log:
ActionFactory is typed with MyAbstractionAction
Modified: trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/MyAbstractAction.java
===================================================================
--- trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/MyAbstractAction.java 2008-07-24 19:18:03 UTC (rev 790)
+++ trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/MyAbstractAction.java 2008-07-24 20:59:46 UTC (rev 791)
@@ -18,8 +18,10 @@
import org.apache.commons.logging.LogFactory;
import javax.swing.AbstractAction;
+import javax.swing.Action;
import javax.swing.JComponent;
import java.awt.event.ActionEvent;
+import java.beans.PropertyChangeListener;
/** @author chemit */
public abstract class MyAbstractAction extends AbstractAction {
@@ -38,13 +40,13 @@
super(name);
}
- protected MyAbstractAction(String name, MyAbstractAction delegate) {
- super(name);
+ protected MyAbstractAction(MyAbstractAction delegate) {
+ super((String) delegate.getValue(Action.NAME));
this.delegate = delegate;
}
public void actionPerformed(java.awt.event.ActionEvent e) {
- if (delegate != null) {
+ if (hasDelegate()) {
// delegate to real action
delegate.actionPerformed(e);
return;
@@ -75,21 +77,21 @@
}
public String getI18nToolTipText() {
- if (delegate != null) {
+ if (hasDelegate()) {
return delegate.getI18nToolTipText();
}
return getPrefix() + ".action." + getActionName() + ".tooltip";
}
public void updateUI() {
- if (delegate != null) {
+ if (hasDelegate()) {
delegate.updateUI();
}
// nothing by default
}
public void disposeUI() {
- if (delegate != null) {
+ if (hasDelegate()) {
delegate.disposeUI();
}
// nothing by default
@@ -99,20 +101,24 @@
return delegate;
}
+ public boolean hasDelegate() {
+ return delegate != null;
+ }
+
protected String getActionName() {
return (String) getValue(ACTION_COMMAND_KEY);
}
protected boolean beforeAction(ActionEvent evt) throws Exception {
boolean enabled = isEnabled();
- if (enabled && delegate != null) {
+ if (enabled && hasDelegate()) {
return delegate.beforeAction(evt);
}
return enabled;
}
protected void doAction(ActionEvent evt) throws Exception {
- if (delegate != null) {
+ if (hasDelegate()) {
delegate.doAction(evt);
}
// nothing by default
@@ -126,7 +132,7 @@
}
protected void clear() {
- if (delegate != null) {
+ if (hasDelegate()) {
delegate.clear();
}
// nothing by default
@@ -136,4 +142,89 @@
log.error(e);
}
+ // -----------------------------------------------------------------------------
+ // --- super classe delegate methods -------------------------------------------
+ // -----------------------------------------------------------------------------
+
+ @Override
+ public Object getValue(String key) {
+ if (hasDelegate()) {
+ return delegate.getValue(key);
+ }
+ return super.getValue(key);
+ }
+
+ @Override
+ public void putValue(String key, Object newValue) {
+ if (hasDelegate()) {
+ delegate.putValue(key, newValue);
+ }
+ super.putValue(key, newValue);
+ }
+
+ @Override
+ public boolean isEnabled() {
+ if (hasDelegate()) {
+ return delegate.isEnabled();
+ }
+ return super.isEnabled();
+ }
+
+ @Override
+ public void setEnabled(boolean newValue) {
+ if (hasDelegate()) {
+ delegate.setEnabled(newValue);
+ }
+ super.setEnabled(newValue);
+ }
+
+ @Override
+ public Object[] getKeys() {
+ if (hasDelegate()) {
+ return getKeys();
+ }
+ return super.getKeys();
+ }
+
+ @Override
+ protected void firePropertyChange(String propertyName, Object oldValue, Object newValue) {
+ if (hasDelegate()) {
+ delegate.firePropertyChange(propertyName, oldValue, newValue);
+ }
+ super.firePropertyChange(propertyName, oldValue, newValue);
+ }
+
+ @Override
+ public synchronized void addPropertyChangeListener(PropertyChangeListener listener) {
+ if (hasDelegate()) {
+ delegate.addPropertyChangeListener(listener);
+ }
+ super.addPropertyChangeListener(listener);
+ }
+
+ @Override
+ public synchronized void removePropertyChangeListener(PropertyChangeListener listener) {
+ if (hasDelegate()) {
+ delegate.removePropertyChangeListener(listener);
+ }
+ super.removePropertyChangeListener(listener);
+ }
+
+ @Override
+ public synchronized PropertyChangeListener[] getPropertyChangeListeners() {
+ if (hasDelegate()) {
+ return delegate.getPropertyChangeListeners();
+ }
+ return super.getPropertyChangeListeners();
+ }
+
+ @Override
+ protected Object clone() throws CloneNotSupportedException {
+ if (hasDelegate()) {
+ return clone();
+ }
+ return super.clone();
+ }
+
+
}
Modified: trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/factory/AbstractActionFactory.java
===================================================================
--- trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/factory/AbstractActionFactory.java 2008-07-24 19:18:03 UTC (rev 790)
+++ trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/factory/AbstractActionFactory.java 2008-07-24 20:59:46 UTC (rev 791)
@@ -37,9 +37,9 @@
import javax.swing.JComponent;
import java.awt.event.ActionEvent;
import java.lang.reflect.InvocationTargetException;
-import java.util.ArrayList;
import java.util.List;
import java.util.Map;
+import java.util.Map.Entry;
import java.util.Set;
import java.util.TreeMap;
@@ -67,7 +67,7 @@
private Map<String, Class<? extends MyAbstractAction>> impls;
/** dictionary of instanciated actions */
- private Map<String, MyAbstractAction> cache;
+ private Map<String, A> cache;
protected final ActionConfigInitializer actionConfigInitializer;
protected final ToggleActionConfigInitializer toggleActionConfigInitializer;
@@ -79,7 +79,7 @@
protected AbstractActionFactory(Class<A> baseImpl) {
this.baseImpl = baseImpl;
this.impls = init();
- this.cache = new TreeMap<String, MyAbstractAction>();
+ this.cache = new TreeMap<String, A>();
this.registredInitializers = new java.util.ArrayList<AbstractActionInitializer>();
this.toggleActionConfigInitializer = registerInitializer(ToggleActionConfigInitializer.class);
@@ -95,15 +95,15 @@
cache.clear();
}
- public MyAbstractAction get(String actionKey) {
+ public A get(String actionKey) {
return cache.get(actionKey);
}
- public MyAbstractAction[] loadActions(JAXXObject ui) {
+ public void loadActions(JAXXObject ui) {
if (log.isDebugEnabled()) {
log.debug("for ui " + ui.getClass());
}
- List<MyAbstractAction> result = new ArrayList<MyAbstractAction>();
+ //List<A> result = new ArrayList<A>();
for (Map.Entry<String, Class<? extends MyAbstractAction>> entry : implsEntrySet()) {
String actionKey = entry.getKey();
Object comp = ui.getObjectById(actionKey);
@@ -116,7 +116,7 @@
}
if (comp instanceof AbstractButton) {
AbstractButton component = (AbstractButton) comp;
- MyAbstractAction action = newAction(actionKey, component);
+ A action = newAction(actionKey, component);
component.setAction(action);
@@ -142,21 +142,21 @@
Boolean value = (Boolean) action.getValue("hideActionText");
component.setHideActionText(value != null && value);
action.setEnabled(true);
- result.add(action);
+ //result.add(action);
continue;
}
// is JComboBox
JComboBox component = (JComboBox) comp;
- MyAbstractAction action = newAction(actionKey, component);
+ A action = newAction(actionKey, component);
component.setAction(action);
Integer val = (Integer) action.getValue("selectedIndex");
if (val != null && val != -1 && val < component.getItemCount() && val != component.getSelectedIndex()) {
component.setSelectedIndex(val);
}
- result.add(action);
+ //result.add(action);
}
- return result.toArray(new MyAbstractAction[result.size()]);
+ //return (A[]) result.toArray(new MyAbstractAction[result.size()]);
}
/**
@@ -165,9 +165,9 @@
* @param component le button o� rattacher l'action
* @return une nouvelle instance de l'action associ�e � sa clef.
*/
- public MyAbstractAction newAction(String actionKey, JComponent component) {
+ public A newAction(String actionKey, JComponent component) {
// try first in cache
- MyAbstractAction result = getActionFromCache(actionKey);
+ A result = getActionFromCache(actionKey);
if (result != null) {
return result;
}
@@ -227,12 +227,12 @@
return impls.entrySet();
}
- public Set<Map.Entry<String, MyAbstractAction>> cacheEntrySet() {
+ public Set<Entry<String, A>> cacheEntrySet() {
return cache.entrySet();
}
public void fireAction(String actionKey, Object source, JComponent component) {
- AbstractAction action = newAction(actionKey, component);
+ A action = newAction(actionKey, component);
fireAction0(actionKey, source, action);
}
@@ -244,14 +244,14 @@
* @param actionKey la clef de l'action
* @return l'action deja stockee dans le cache d'action, ou <code>null</code> si non trouv�e.
*/
- public MyAbstractAction getActionFromCache(String actionKey) {
+ public A getActionFromCache(String actionKey) {
// on v�rifie que l'action existe bien
checkRegistredAction(actionKey);
// try in cache
if (cache.containsKey(actionKey)) {
// use cached action
- MyAbstractAction action = cache.get(actionKey);
+ A action = cache.get(actionKey);
if (log.isDebugEnabled()) {
log.debug("use cache action " + action);
}
@@ -357,7 +357,7 @@
}
}
- protected void fireAction0(String actionKey, Object source, AbstractAction action) {
+ protected void fireAction0(String actionKey, Object source, A action) {
if (action == null) {
log.warn("could not find action " + actionKey);
return;
@@ -373,11 +373,16 @@
}
- protected MyAbstractAction newActionInstance(String actionKey) throws InstantiationException, IllegalAccessException, InvocationTargetException, NoSuchMethodException {
+ @SuppressWarnings({"unchecked"})
+ protected A newActionInstance(String actionKey) throws InstantiationException, IllegalAccessException, InvocationTargetException, NoSuchMethodException {
Class<? extends MyAbstractAction> klazz = impls.get(actionKey);
MyAbstractAction result;
result = klazz.getConstructor(String.class).newInstance(actionKey);
result.putValue(Action.ACTION_COMMAND_KEY, actionKey);
- return result;
+ if (!getBaseImpl().isAssignableFrom(klazz)) {
+ // the instanciated action must be boxed in the base Action of the factory
+ result = getBaseImpl().getConstructor(MyAbstractAction.class).newInstance(result);
+ }
+ return (A) result;
}
}
\ No newline at end of file
Modified: trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/factory/ActionFactory.java
===================================================================
--- trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/factory/ActionFactory.java 2008-07-24 19:18:03 UTC (rev 790)
+++ trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/factory/ActionFactory.java 2008-07-24 20:59:46 UTC (rev 791)
@@ -45,17 +45,17 @@
void resetCache();
- MyAbstractAction get(String actionKey);
+ A get(String actionKey);
- MyAbstractAction[] loadActions(JAXXObject ui);
+ void loadActions(JAXXObject ui);
- MyAbstractAction newAction(String actionKey, JComponent component);
+ A newAction(String actionKey, JComponent component);
String[] getActionNames();
Set<Entry<String, Class<? extends MyAbstractAction>>> implsEntrySet();
- Set<Entry<String, MyAbstractAction>> cacheEntrySet();
+ Set<Entry<String, A>> cacheEntrySet();
void fireAction(String actionKey, Object source, JComponent component);
Modified: trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/factory/ActionFactoryFromProvider.java
===================================================================
--- trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/factory/ActionFactoryFromProvider.java 2008-07-24 19:18:03 UTC (rev 790)
+++ trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/factory/ActionFactoryFromProvider.java 2008-07-24 20:59:46 UTC (rev 791)
@@ -25,6 +25,7 @@
import java.util.TreeMap;
/**
+ * TODO Do javadoc which is not up to date...
* A simple implementation of {@link AbstractActionFactory} using a properties file to
* load action mapping.
* <p/>
1
0