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
July 2008
- 1 participants
- 124 discussions
[Buix-commits] r706 - trunk/lutinjaxx/util/src/main/java/org/codelutin/jaxx/util/config
by tchemit@users.labs.libre-entreprise.org 08 Jul '08
by tchemit@users.labs.libre-entreprise.org 08 Jul '08
08 Jul '08
Author: tchemit
Date: 2008-07-08 21:15:11 +0000 (Tue, 08 Jul 2008)
New Revision: 706
Modified:
trunk/lutinjaxx/util/src/main/java/org/codelutin/jaxx/util/config/CancelAction.java
trunk/lutinjaxx/util/src/main/java/org/codelutin/jaxx/util/config/DialogConfigUI.java
trunk/lutinjaxx/util/src/main/java/org/codelutin/jaxx/util/config/DialogConfigUIHandler.java
trunk/lutinjaxx/util/src/main/java/org/codelutin/jaxx/util/config/DialogConfigUIModel.java
trunk/lutinjaxx/util/src/main/java/org/codelutin/jaxx/util/config/ResetAction.java
trunk/lutinjaxx/util/src/main/java/org/codelutin/jaxx/util/config/SaveAction.java
Log:
use org.codelutin.jaxx:util module
Modified: trunk/lutinjaxx/util/src/main/java/org/codelutin/jaxx/util/config/CancelAction.java
===================================================================
--- trunk/lutinjaxx/util/src/main/java/org/codelutin/jaxx/util/config/CancelAction.java 2008-07-08 21:14:58 UTC (rev 705)
+++ trunk/lutinjaxx/util/src/main/java/org/codelutin/jaxx/util/config/CancelAction.java 2008-07-08 21:15:11 UTC (rev 706)
@@ -14,9 +14,9 @@
*/
package org.codelutin.jaxx.util.config;
-import org.codelutin.ui.AbstractUIAction;
-import org.codelutin.ui.DialogUI;
-import org.codelutin.ui.UIHelper;
+import org.codelutin.jaxx.util.AbstractUIAction;
+import org.codelutin.jaxx.util.DialogUI;
+import org.codelutin.jaxx.util.UIHelper;
import java.awt.event.ActionEvent;
Modified: trunk/lutinjaxx/util/src/main/java/org/codelutin/jaxx/util/config/DialogConfigUI.java
===================================================================
--- trunk/lutinjaxx/util/src/main/java/org/codelutin/jaxx/util/config/DialogConfigUI.java 2008-07-08 21:14:58 UTC (rev 705)
+++ trunk/lutinjaxx/util/src/main/java/org/codelutin/jaxx/util/config/DialogConfigUI.java 2008-07-08 21:15:11 UTC (rev 706)
@@ -14,7 +14,7 @@
*/
package org.codelutin.jaxx.util.config;
-import org.codelutin.ui.DialogUI;
+import org.codelutin.jaxx.util.DialogUI;
import javax.swing.AbstractButton;
import javax.swing.JCheckBox;
Modified: trunk/lutinjaxx/util/src/main/java/org/codelutin/jaxx/util/config/DialogConfigUIHandler.java
===================================================================
--- trunk/lutinjaxx/util/src/main/java/org/codelutin/jaxx/util/config/DialogConfigUIHandler.java 2008-07-08 21:14:58 UTC (rev 705)
+++ trunk/lutinjaxx/util/src/main/java/org/codelutin/jaxx/util/config/DialogConfigUIHandler.java 2008-07-08 21:15:11 UTC (rev 706)
@@ -14,7 +14,7 @@
*/
package org.codelutin.jaxx.util.config;
-import org.codelutin.ui.DialogUIHandler;
+import org.codelutin.jaxx.util.DialogUIHandler;
import org.codelutin.util.ConverterUtil;
import org.codelutin.util.config.Config;
import org.codelutin.util.config.Property;
Modified: trunk/lutinjaxx/util/src/main/java/org/codelutin/jaxx/util/config/DialogConfigUIModel.java
===================================================================
--- trunk/lutinjaxx/util/src/main/java/org/codelutin/jaxx/util/config/DialogConfigUIModel.java 2008-07-08 21:14:58 UTC (rev 705)
+++ trunk/lutinjaxx/util/src/main/java/org/codelutin/jaxx/util/config/DialogConfigUIModel.java 2008-07-08 21:15:11 UTC (rev 706)
@@ -14,7 +14,7 @@
*/
package org.codelutin.jaxx.util.config;
-import org.codelutin.ui.DialogUIModel;
+import org.codelutin.jaxx.util.DialogUIModel;
import org.codelutin.util.config.Config;
import java.util.EnumSet;
Modified: trunk/lutinjaxx/util/src/main/java/org/codelutin/jaxx/util/config/ResetAction.java
===================================================================
--- trunk/lutinjaxx/util/src/main/java/org/codelutin/jaxx/util/config/ResetAction.java 2008-07-08 21:14:58 UTC (rev 705)
+++ trunk/lutinjaxx/util/src/main/java/org/codelutin/jaxx/util/config/ResetAction.java 2008-07-08 21:15:11 UTC (rev 706)
@@ -14,9 +14,9 @@
*/
package org.codelutin.jaxx.util.config;
-import org.codelutin.ui.AbstractUIAction;
-import org.codelutin.ui.DialogUI;
-import org.codelutin.ui.UIHelper;
+import org.codelutin.jaxx.util.AbstractUIAction;
+import org.codelutin.jaxx.util.DialogUI;
+import org.codelutin.jaxx.util.UIHelper;
import java.awt.event.ActionEvent;
Modified: trunk/lutinjaxx/util/src/main/java/org/codelutin/jaxx/util/config/SaveAction.java
===================================================================
--- trunk/lutinjaxx/util/src/main/java/org/codelutin/jaxx/util/config/SaveAction.java 2008-07-08 21:14:58 UTC (rev 705)
+++ trunk/lutinjaxx/util/src/main/java/org/codelutin/jaxx/util/config/SaveAction.java 2008-07-08 21:15:11 UTC (rev 706)
@@ -14,9 +14,9 @@
*/
package org.codelutin.jaxx.util.config;
-import org.codelutin.ui.AbstractUIAction;
-import org.codelutin.ui.DialogUI;
-import org.codelutin.ui.UIHelper;
+import org.codelutin.jaxx.util.AbstractUIAction;
+import org.codelutin.jaxx.util.DialogUI;
+import org.codelutin.jaxx.util.UIHelper;
import java.awt.event.ActionEvent;
1
0
[Buix-commits] r705 - in trunk/lutinjaxx/util/src/main/java/org/codelutin: jaxx/util util
by tchemit@users.labs.libre-entreprise.org 08 Jul '08
by tchemit@users.labs.libre-entreprise.org 08 Jul '08
08 Jul '08
Author: tchemit
Date: 2008-07-08 21:14:58 +0000 (Tue, 08 Jul 2008)
New Revision: 705
Added:
trunk/lutinjaxx/util/src/main/java/org/codelutin/jaxx/util/AbstractUIAction.java
trunk/lutinjaxx/util/src/main/java/org/codelutin/jaxx/util/DialogUI.java
trunk/lutinjaxx/util/src/main/java/org/codelutin/jaxx/util/DialogUIDef.java
trunk/lutinjaxx/util/src/main/java/org/codelutin/jaxx/util/DialogUIHandler.java
trunk/lutinjaxx/util/src/main/java/org/codelutin/jaxx/util/DialogUIModel.java
trunk/lutinjaxx/util/src/main/java/org/codelutin/jaxx/util/FactoryWindowListener.java
trunk/lutinjaxx/util/src/main/java/org/codelutin/jaxx/util/FormElement.java
trunk/lutinjaxx/util/src/main/java/org/codelutin/jaxx/util/ShowUIAction.java
trunk/lutinjaxx/util/src/main/java/org/codelutin/jaxx/util/UIFactory.java
trunk/lutinjaxx/util/src/main/java/org/codelutin/jaxx/util/UIHelper.java
trunk/lutinjaxx/util/src/main/java/org/codelutin/jaxx/util/UIProvider.java
Removed:
trunk/lutinjaxx/util/src/main/java/org/codelutin/util/AbstractUIAction.java
trunk/lutinjaxx/util/src/main/java/org/codelutin/util/DialogUI.java
trunk/lutinjaxx/util/src/main/java/org/codelutin/util/DialogUIDef.java
trunk/lutinjaxx/util/src/main/java/org/codelutin/util/DialogUIHandler.java
trunk/lutinjaxx/util/src/main/java/org/codelutin/util/DialogUIModel.java
trunk/lutinjaxx/util/src/main/java/org/codelutin/util/FactoryWindowListener.java
trunk/lutinjaxx/util/src/main/java/org/codelutin/util/FormElement.java
trunk/lutinjaxx/util/src/main/java/org/codelutin/util/ShowUIAction.java
trunk/lutinjaxx/util/src/main/java/org/codelutin/util/UIFactory.java
trunk/lutinjaxx/util/src/main/java/org/codelutin/util/UIHelper.java
trunk/lutinjaxx/util/src/main/java/org/codelutin/util/UIProvider.java
Log:
use org.codelutin.jaxx:util module
Copied: trunk/lutinjaxx/util/src/main/java/org/codelutin/jaxx/util/AbstractUIAction.java (from rev 700, trunk/lutinjaxx/util/src/main/java/org/codelutin/util/AbstractUIAction.java)
===================================================================
--- trunk/lutinjaxx/util/src/main/java/org/codelutin/jaxx/util/AbstractUIAction.java (rev 0)
+++ trunk/lutinjaxx/util/src/main/java/org/codelutin/jaxx/util/AbstractUIAction.java 2008-07-08 21:14:58 UTC (rev 705)
@@ -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.util;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/** @author chemit */
+public abstract class AbstractUIAction<H extends DialogUIHandler<?, ?>> extends javax.swing.AbstractAction {
+
+ protected static Log log = LogFactory.getLog(AbstractUIAction.class);
+
+ protected transient DialogUI<? extends H> ui;
+
+ private static final long serialVersionUID = 1L;
+
+ protected AbstractUIAction(String name, javax.swing.Icon icon, DialogUI<? extends H> ui) {
+ super(name, icon);
+ this.ui = ui;
+ }
+
+ protected H getHandler() {
+ checkInit();
+ return ui.getHandler();
+ }
+
+ protected void setUi(DialogUI<? extends H> ui) {
+ this.ui = ui;
+ }
+
+ public DialogUI<? extends H> getUi() {
+ return ui;
+ }
+
+ protected void checkInit() throws IllegalStateException {
+ /*if (ui == null) {
+ throw new IllegalStateException("no handler, nor ui referenced in " + this);
+ } */
+ }
+
+}
Copied: trunk/lutinjaxx/util/src/main/java/org/codelutin/jaxx/util/DialogUI.java (from rev 700, trunk/lutinjaxx/util/src/main/java/org/codelutin/util/DialogUI.java)
===================================================================
--- trunk/lutinjaxx/util/src/main/java/org/codelutin/jaxx/util/DialogUI.java (rev 0)
+++ trunk/lutinjaxx/util/src/main/java/org/codelutin/jaxx/util/DialogUI.java 2008-07-08 21:14:58 UTC (rev 705)
@@ -0,0 +1,129 @@
+/**
+ * ##% 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.util;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import javax.swing.AbstractAction;
+import javax.swing.AbstractButton;
+import javax.swing.ImageIcon;
+import javax.swing.JDialog;
+import java.awt.event.WindowEvent;
+import java.awt.event.WindowListener;
+import java.lang.reflect.Constructor;
+
+/**
+ * A abstract dialog contract to be realised by a dialogUI (WindowEvent adapter)
+ * <p/>
+ * TODO : make jaxx authorized implementing interface for root tag :)
+ *
+ * @author chemit
+ */
+public abstract class DialogUI<H extends DialogUIHandler> extends JDialog implements WindowListener {
+
+ protected static Log log = LogFactory.getLog(DialogUI.class);
+
+ public javax.swing.AbstractAction newAction(Class<?> actionClass, Object... params) {
+ Constructor<?> constructor = null;
+ for (Constructor<?> cons : actionClass.getConstructors()) {
+ Class<?>[] prototype = cons.getParameterTypes();
+ if (prototype.length > 0 && DialogUI.class.isAssignableFrom(prototype[0])) {
+ // use this constructor
+ constructor = cons;
+ break;
+ }
+ }
+ if (constructor == null) {
+ throw new IllegalStateException("could not find a matching constructor for " + actionClass);
+ }
+
+ // wrap params
+ Object[] parameters = new Object[1 + params.length];
+ parameters[0] = this;
+ System.arraycopy(params, 0, parameters, 1, params.length);
+ try {
+ AbstractAction action = (AbstractAction) constructor.newInstance(parameters);
+ if (log.isInfoEnabled()) {
+ log.info(action);
+ }
+ return action;
+ } catch (Exception e) {
+ throw new IllegalStateException("could not init the action " + actionClass + " for reason : " + e.getMessage());
+ }
+ }
+
+ private H handler;
+
+ public abstract AbstractButton getHelp();
+
+ public abstract Object getObjectById(java.lang.String s);
+
+ protected DialogUI() {
+ UIHelper.setQuitAction(this);
+ addWindowListener(this);
+ //TODO will be handled by jaxx with javax.help...
+ //getHelp().setAction(newAction(HelpAction.class));
+ }
+
+ public H getHandler() {
+ return handler;
+ }
+
+ public void setHandler(H handler) {
+ this.handler = handler;
+ }
+
+ protected ImageIcon createActionIcon(String name) {
+ return UIHelper.createActionIcon(name);
+ }
+
+ public void windowOpened(WindowEvent e) {
+ }
+
+ public void windowClosed(WindowEvent e) {
+ }
+
+ public void windowClosing(WindowEvent e) {
+ }
+
+ public void windowIconified(WindowEvent e) {
+ }
+
+ public void windowDeiconified(WindowEvent e) {
+ }
+
+ public void windowActivated(WindowEvent e) {
+ }
+
+ public void windowDeactivated(WindowEvent e) {
+ }
+
+ @Override
+ public synchronized void addWindowListener(WindowListener l) {
+ super.addWindowListener(l);
+ if (log.isDebugEnabled()) {
+ log.debug("after added (" + getWindowListeners().length + ") : " + l);
+ }
+ }
+
+ @Override
+ public synchronized void removeWindowListener(WindowListener l) {
+ super.removeWindowListener(l);
+ if (log.isDebugEnabled()) {
+ log.debug("after removed (" + getWindowListeners().length + ") : " + l);
+ }
+ }
+}
\ No newline at end of file
Copied: trunk/lutinjaxx/util/src/main/java/org/codelutin/jaxx/util/DialogUIDef.java (from rev 700, trunk/lutinjaxx/util/src/main/java/org/codelutin/util/DialogUIDef.java)
===================================================================
--- trunk/lutinjaxx/util/src/main/java/org/codelutin/jaxx/util/DialogUIDef.java (rev 0)
+++ trunk/lutinjaxx/util/src/main/java/org/codelutin/jaxx/util/DialogUIDef.java 2008-07-08 21:14:58 UTC (rev 705)
@@ -0,0 +1,235 @@
+/**
+ * ##% 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.util;
+
+import static org.codelutin.i18n.I18n._;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import javax.swing.ImageIcon;
+import java.lang.reflect.Constructor;
+
+/**
+ * Definition of an ui, with his model, handler and ui class definitions.
+ * <p/>
+ * The class contains also a shared instace of concrete ui.
+ *
+ * @author chemit
+ */
+public class DialogUIDef<M extends DialogUIModel, U extends DialogUI<H>, H extends DialogUIHandler<M, U>> implements java.io.Serializable {
+
+ static protected final Log log = LogFactory.getLog(DialogUIDef.class);
+
+ public static <M extends DialogUIModel, U extends DialogUI<H>, H extends DialogUIHandler<M, U>> DialogUIDef<M, U, H> newDef(Class<H> handlerClass, Class<U> uiClass, Class<M> modelClass, String showActionLibelle, String showActionTip, String uiTitle) {
+ DialogUIDef<M, U, H> result;
+ result = new DialogUIDef<M, U, H>(handlerClass, uiClass, modelClass, showActionLibelle, showActionTip, uiTitle);
+ return result;
+ }
+
+ /**
+ * model class
+ */
+ private final Class<M> modelClass;
+
+ /**
+ * handler class
+ */
+ private final Class<H> handlerClass;
+
+ /**
+ * abstract ui class
+ */
+ private final Class<U> uiClass;
+
+ /**
+ * concrete lookup ui class
+ */
+ private Class<? extends U> uiImplClass;
+
+ /**
+ * shared instance of ui
+ */
+ protected U uiInstance;
+
+ /**
+ * unique name of ui def
+ */
+ protected final String name;
+
+ protected final String uiTitle;
+ protected final String showActionLibelle;
+ protected final String showActionTip;
+
+ protected ImageIcon showUIActionIcon;
+
+
+ private static final long serialVersionUID = 1L;
+
+ private DialogUIDef(Class<H> handlerClass, Class<U> uiClass, Class<M> modelClass,
+ String showActionLibelle, String showActionTip, String uiTitle) {
+ this.handlerClass = handlerClass;
+ this.uiClass = uiClass;
+ this.modelClass = modelClass;
+ this.showActionLibelle = showActionLibelle;
+ this.name = uiClass.getSimpleName().toLowerCase();
+ this.showActionTip = showActionTip;
+ this.uiTitle = uiTitle;
+ }
+
+ public Class<U> getUiClass() {
+ return uiClass;
+ }
+
+ public Class<H> getHandlerClass() {
+ return handlerClass;
+ }
+
+ public Class<M> getModelClass() {
+ return modelClass;
+ }
+
+ public Class<? extends U> getUiImplClass() {
+ return uiImplClass;
+ }
+
+ public String getUiTitle() {
+ return _(uiTitle);
+ }
+
+ public String getShowActionLibelle() {
+ return _(showActionLibelle);
+ }
+
+ public String getShowActionTip() {
+ return _(showActionTip);
+ }
+
+ public ImageIcon getShowUIActionIcon() {
+ if (showUIActionIcon == null) {
+ showUIActionIcon = UIHelper.createActionIcon("show-" + name);
+ }
+ return showUIActionIcon;
+ }
+
+ @SuppressWarnings({"unchecked"})
+ public void setUiImplClass(Class<?> uiImplClass) {
+ this.uiImplClass = (Class<? extends U>) uiImplClass;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ return this == o || o instanceof DialogUIDef && uiClass.equals(((DialogUIDef) o).uiClass);
+ }
+
+ @Override
+ public int hashCode() {
+ return uiClass.hashCode();
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder(super.toString()).append('<');
+ sb.append(printClass("handler", handlerClass, true));
+ sb.append(printClass("model", modelClass, true));
+ sb.append(printClass("ui", uiClass, true));
+ sb.append(printClass("uiImpl", uiImplClass, false));
+ return sb.toString();
+ }
+
+ protected U getUiInstance() {
+ // no lazy instanciation, to control ui instanciation...
+ /*if (uiInstance == null) {
+ if (uiImplClass == null) {
+ throw new IllegalStateException("no concrete ui impl found in " + this);
+ }
+ synchronized (this) {
+ try {
+ uiInstance = uiImplClass.newInstance();
+ } catch (Exception e) {
+ throw new IllegalStateException("could not instanciate ui " + this,e);
+ }
+ }
+ }*/
+ return uiInstance;
+ }
+
+ protected void setUiInstance(U uiInstance) {
+ this.uiInstance = uiInstance;
+ }
+
+ protected U newUI() {
+ if (uiImplClass == null) {
+ throw new IllegalStateException("no concrete ui impl found in " + this);
+ }
+ try {
+ U result = uiImplClass.newInstance();
+ log.info(result);
+ return result;
+ } catch (Exception e) {
+ throw new IllegalStateException("could not instanciate ui " + this, e);
+ }
+ }
+
+ protected M newModel() {
+ if (modelClass == null) {
+ throw new IllegalStateException("no model impl found in " + this);
+ }
+ try {
+ M model = modelClass.newInstance();
+ log.info(model);
+ return model;
+ } catch (Exception e) {
+ throw new IllegalStateException("could not instanciate ui " + this, e);
+ }
+ }
+
+ protected H newHandler(U ui, M model, Object... params) {
+ if (handlerClass == null) {
+ throw new IllegalStateException("no handler impl found in " + this);
+ }
+ try {
+ Class[] prototype = getHandlerPrototype(params);
+ Object[] parameters = getHandlerParameters(ui, model, params);
+ H result = handlerClass.getConstructor(prototype).newInstance(parameters);
+ log.info(result);
+ return result;
+ } catch (Exception e) {
+ throw new IllegalStateException("could not instanciate ui " + this, e);
+ }
+ }
+
+ protected Object[] getHandlerParameters(U ui, M model, Object[] params) {
+ Object[] result = new Object[2 + params.length];
+ result[0] = ui;
+ result[1] = model;
+ System.arraycopy(params, 0, result, 2, params.length);
+ return result;
+ }
+
+ protected Class[] getHandlerPrototype(Object[] params) {
+ int length = params.length;
+ for (Constructor<?> constructor : handlerClass.getConstructors()) {
+ Class<?>[] prototype = constructor.getParameterTypes();
+ if (prototype.length == 2 + length && prototype[0] == uiClass && prototype[1] == modelClass) {
+ return prototype;
+ }
+ }
+ throw new IllegalStateException("could not find a matching constructor in " + handlerClass);
+ }
+
+ protected String printClass(String s, Class<?> aClass, boolean notLast) {
+ return s + ':' + (aClass == null ? null : aClass.getSimpleName()) + (notLast ? ", " : ">");
+ }
+}
Copied: trunk/lutinjaxx/util/src/main/java/org/codelutin/jaxx/util/DialogUIHandler.java (from rev 700, trunk/lutinjaxx/util/src/main/java/org/codelutin/util/DialogUIHandler.java)
===================================================================
--- trunk/lutinjaxx/util/src/main/java/org/codelutin/jaxx/util/DialogUIHandler.java (rev 0)
+++ trunk/lutinjaxx/util/src/main/java/org/codelutin/jaxx/util/DialogUIHandler.java 2008-07-08 21:14:58 UTC (rev 705)
@@ -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.util;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.awt.event.WindowListener;
+import java.beans.PropertyChangeListener;
+
+/**
+ * DialogUI handler
+ *
+ * @author chemit
+ */
+public abstract class DialogUIHandler<M extends DialogUIModel, U extends DialogUI<? extends DialogUIHandler>> implements PropertyChangeListener {
+
+ protected static Log log = LogFactory.getLog(DialogUIHandler.class);
+
+ /** ui handled */
+ private U ui;
+
+ /** model handled */
+ private M model;
+
+ protected DialogUIHandler(U ui, M model) {
+ this.ui = ui;
+ this.model = model;
+ }
+
+ public U getUi() {
+ return ui;
+ }
+
+ public M getModel() {
+ return model;
+ }
+
+ public void init() {
+ if (model == null) {
+ throw new IllegalStateException("no model was defined for " + this);
+ }
+ model.addPropertyChangeListener(this);
+ }
+
+ public void dispose() {
+ model.dispose();
+ for (WindowListener windowListener : getUi().getWindowListeners()) {
+ getUi().removeWindowListener(windowListener);
+ }
+ }
+
+ @Override
+ protected void finalize() throws Throwable {
+ super.finalize();
+ dispose();
+ }
+}
\ No newline at end of file
Copied: trunk/lutinjaxx/util/src/main/java/org/codelutin/jaxx/util/DialogUIModel.java (from rev 700, trunk/lutinjaxx/util/src/main/java/org/codelutin/util/DialogUIModel.java)
===================================================================
--- trunk/lutinjaxx/util/src/main/java/org/codelutin/jaxx/util/DialogUIModel.java (rev 0)
+++ trunk/lutinjaxx/util/src/main/java/org/codelutin/jaxx/util/DialogUIModel.java 2008-07-08 21:14:58 UTC (rev 705)
@@ -0,0 +1,97 @@
+/**
+ * ##% 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.util;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.beans.PropertyChangeListener;
+import java.beans.PropertyChangeSupport;
+
+/**
+ * Abstract ui model, with property change support.
+ *
+ * @author chemit
+ */
+public abstract class DialogUIModel {
+
+ static protected final Log log = LogFactory.getLog(DialogUIModel.class);
+
+ /** support for change properties support */
+ protected PropertyChangeSupport changeSupport;
+
+ public synchronized void addPropertyChangeListener(String propertyName, PropertyChangeListener listener) {
+ if (listener == null) {
+ return;
+ }
+ if (changeSupport == null) {
+ changeSupport = new PropertyChangeSupport(this);
+ }
+ changeSupport.addPropertyChangeListener(propertyName, listener);
+ }
+
+ public synchronized void addPropertyChangeListener(PropertyChangeListener listener) {
+ if (listener == null) {
+ return;
+ }
+ if (changeSupport == null) {
+ changeSupport = new PropertyChangeSupport(this);
+ }
+ changeSupport.addPropertyChangeListener(listener);
+ }
+
+ public synchronized void removePropertyChangeListener(PropertyChangeListener listener) {
+ if (listener == null || changeSupport == null) {
+ return;
+ }
+ changeSupport.removePropertyChangeListener(listener);
+ }
+
+ public synchronized void removePropertyChangeListeners() {
+ if (changeSupport == null) {
+ return;
+ }
+ for (PropertyChangeListener listener : getPropertyChangeListeners()) {
+ changeSupport.removePropertyChangeListener(listener);
+ }
+ }
+
+ public synchronized PropertyChangeListener[] getPropertyChangeListeners() {
+ if (changeSupport == null) {
+ return new PropertyChangeListener[0];
+ }
+ return changeSupport.getPropertyChangeListeners();
+ }
+
+ public void firePropertyChange(String propertyName, Object oldValue, Object newValue) {
+ if (changeSupport == null || (oldValue == null && newValue == null) ||
+ (oldValue != null && oldValue.equals(newValue))) {
+ return;
+ }
+ changeSupport.firePropertyChange(propertyName, oldValue, newValue);
+ }
+
+ public void dispose() {
+ for (PropertyChangeListener listener : changeSupport.getPropertyChangeListeners()) {
+ changeSupport.removePropertyChangeListener(listener);
+ }
+ }
+
+ @Override
+ protected void finalize() throws Throwable {
+ super.finalize();
+ dispose();
+ }
+}
\ No newline at end of file
Copied: trunk/lutinjaxx/util/src/main/java/org/codelutin/jaxx/util/FactoryWindowListener.java (from rev 700, trunk/lutinjaxx/util/src/main/java/org/codelutin/util/FactoryWindowListener.java)
===================================================================
--- trunk/lutinjaxx/util/src/main/java/org/codelutin/jaxx/util/FactoryWindowListener.java (rev 0)
+++ trunk/lutinjaxx/util/src/main/java/org/codelutin/jaxx/util/FactoryWindowListener.java 2008-07-08 21:14:58 UTC (rev 705)
@@ -0,0 +1,86 @@
+/**
+ * # #% 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.util;
+
+import static org.codelutin.ui.UIFactory.log;
+
+import java.awt.event.WindowAdapter;
+import java.awt.event.WindowEvent;
+
+/**
+ * A windowListenr for ui managed by {@link org.codelutin.ui.UIFactory}.
+ * <p/>
+ * To be used when all ui from factory are closed, via {@link #allWindowsClosed(java.awt.event.WindowEvent)} method.
+ *
+ * @author chemit
+ */
+public abstract class FactoryWindowListener extends WindowAdapter {
+
+ /**
+ * method to be invoked when all ui registred in factory are really disposed.
+ *
+ * @param e event
+ */
+ public abstract void allWindowsClosed(WindowEvent e);
+
+ /** underlying factory of ui */
+ private UIFactory factory;
+
+ /** flag to make sure {@link #allWindowsClosed(java.awt.event.WindowEvent)} is called only once. */
+ private boolean wasClosed;
+
+ @Override
+ public void windowClosed(WindowEvent e) {
+ if (UIFactory.log.isDebugEnabled()) {
+ UIFactory.log.debug(this + " : " + e);
+ }
+ if (e.getWindow().isVisible()) {
+ // only deal with real closed and none visible windows...
+ return;
+ }
+ for (DialogUIDef def : factory.getDefs()) {
+ DialogUI ui = def.uiInstance;
+ if (ui != null && ui.isVisible()) {
+ // at least one ui visible, do not close all
+ return;
+ }
+ }
+
+ if (wasClosed) {
+ // make sure to process only once
+ return;
+ }
+ if (UIFactory.log.isInfoEnabled()) {
+ UIFactory.log.info("closing factory listener " + this);
+ }
+
+ synchronized (this) {
+ try {
+ allWindowsClosed(e);
+ } finally {
+ wasClosed = true;
+ factory.removeFactoryWindowListener(this);
+ }
+ }
+ }
+
+ protected UIFactory getFactory() {
+ return factory;
+ }
+
+ protected void setFactory(UIFactory factory) {
+ this.factory = factory;
+ }
+}
Copied: trunk/lutinjaxx/util/src/main/java/org/codelutin/jaxx/util/FormElement.java (from rev 700, trunk/lutinjaxx/util/src/main/java/org/codelutin/util/FormElement.java)
===================================================================
--- trunk/lutinjaxx/util/src/main/java/org/codelutin/jaxx/util/FormElement.java (rev 0)
+++ trunk/lutinjaxx/util/src/main/java/org/codelutin/jaxx/util/FormElement.java 2008-07-08 21:14:58 UTC (rev 705)
@@ -0,0 +1,29 @@
+/**
+ * # #% 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.util;
+
+/** @author chemit */
+public interface FormElement<U extends DialogUI> {
+
+ String name();
+
+ int ordinal();
+
+ Object getValue(U ui);
+
+ void setValue(U ui, String value);
+
+ javax.swing.JLabel getLabel(U ui);
+}
Copied: trunk/lutinjaxx/util/src/main/java/org/codelutin/jaxx/util/ShowUIAction.java (from rev 700, trunk/lutinjaxx/util/src/main/java/org/codelutin/util/ShowUIAction.java)
===================================================================
--- trunk/lutinjaxx/util/src/main/java/org/codelutin/jaxx/util/ShowUIAction.java (rev 0)
+++ trunk/lutinjaxx/util/src/main/java/org/codelutin/jaxx/util/ShowUIAction.java 2008-07-08 21:14:58 UTC (rev 705)
@@ -0,0 +1,135 @@
+/**
+ * # #% 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.util;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.awt.Dimension;
+import java.awt.Point;
+import java.awt.event.ActionEvent;
+
+/** @author chemit */
+public abstract class ShowUIAction<M extends DialogUIModel, U extends DialogUI<H>, H extends DialogUIHandler<M, U>> extends javax.swing.AbstractAction {
+
+ protected static Log log = LogFactory.getLog(AbstractUIAction.class);
+
+ protected transient DialogUI<?> ui;
+
+ private static final long serialVersionUID = 1L;
+
+ protected DialogUIDef<M, U, H> uiDef;
+
+ protected transient UIFactory factory;
+
+ protected String position;
+
+ protected boolean undecorated = true;
+
+ protected U initUI(ActionEvent e) {
+ return getFactory().getUI(uiDef);
+ }
+
+ public ShowUIAction(DialogUI<?> ui, DialogUIDef<M, U, H> uiDef, UIFactory factory, boolean showText) {
+ super(uiDef.getShowActionLibelle(), uiDef.getShowUIActionIcon());
+ this.ui = ui;
+ this.uiDef = uiDef;
+ String name = (String) getValue(NAME);
+ putValue(DISPLAYED_MNEMONIC_INDEX_KEY, name.length() - 1);
+ putValue(ACCELERATOR_KEY, (int) name.charAt(name.length() - 1));
+ if (!showText) {
+ putValue(NAME, null);
+ }
+ putValue(SHORT_DESCRIPTION, uiDef.getShowActionTip());
+ this.factory = factory;
+ }
+
+ public DialogUI<?> getUi() {
+ return ui;
+ }
+
+ public DialogUIDef<M, U, H> getUiDef() {
+ return uiDef;
+ }
+
+ public UIFactory getFactory() {
+ return factory;
+ }
+
+ public void setUiDef(DialogUIDef<M, U, H> uiDef) {
+ this.uiDef = uiDef;
+ }
+
+ public void setPosition(String position) {
+ this.position = position;
+ }
+
+ public void setUndecorated(boolean undecorated) {
+ this.undecorated = undecorated;
+ }
+
+ public void actionPerformed(java.awt.event.ActionEvent e) {
+ checkInit();
+ U ui = initUI(e);
+ ui.setTitle(uiDef.getUiTitle());
+ log.info(ui.getTitle());
+ //TODO ui.setUndecorated(undecorated);
+ setPosition(this.getUi(), ui, position);
+
+ ui.setVisible(true);
+ }
+
+ protected void setPosition(javax.swing.JDialog parentUI, javax.swing.JDialog ui, String position) {
+ if (position == null || parentUI == null) {
+ return;
+ }
+ Point parentLocation = parentUI.getLocationOnScreen();
+ Dimension parentSize = parentUI.getSize();
+
+ if (position.equals("bottom-left")) {
+ int top = (int) (parentLocation.getY() + parentSize.getHeight());
+ int left = (int) (parentLocation.getX());
+ Point newLocation = new Point(left, top);
+ newLocation.setLocation(left, top);
+ ui.setLocation(newLocation);
+ return;
+ }
+ if (position.equals("top-left")) {
+ int top = (int) (parentLocation.getY());
+ int left = (int) (parentLocation.getX());
+ Point newLocation = new Point(left, top);
+ newLocation.setLocation(left, top);
+ ui.setLocation(newLocation);
+ return;
+ }
+ if (position.equals("top-right")) {
+ int top = (int) (parentLocation.getY());
+ int left = (int) (parentLocation.getX() + parentSize.getWidth());
+ Point newLocation = new Point(left, top);
+ newLocation.setLocation(left, top);
+ ui.setLocation(newLocation);
+ return;
+ }
+ if (position.equals(("center"))) {
+ //TODO
+ }
+ }
+
+ protected void checkInit() throws IllegalStateException {
+ if (factory == null) {
+ throw new IllegalStateException("no factory found in " + this);
+ }
+ }
+}
\ No newline at end of file
Copied: trunk/lutinjaxx/util/src/main/java/org/codelutin/jaxx/util/UIFactory.java (from rev 700, trunk/lutinjaxx/util/src/main/java/org/codelutin/util/UIFactory.java)
===================================================================
--- trunk/lutinjaxx/util/src/main/java/org/codelutin/jaxx/util/UIFactory.java (rev 0)
+++ trunk/lutinjaxx/util/src/main/java/org/codelutin/jaxx/util/UIFactory.java 2008-07-08 21:14:58 UTC (rev 705)
@@ -0,0 +1,184 @@
+/**
+/**
+ * ##% 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.util;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.codelutin.util.StringUtil;
+
+import javax.swing.event.EventListenerList;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.ServiceLoader;
+
+/**
+ * Factory for UI, using a cache and a provider to find ui implementations.
+ *
+ * @author chemit
+ */
+public class UIFactory {
+
+ static protected final Log log = LogFactory.getLog(UIFactory.class);
+
+ private final String applicationName;
+
+ private final DialogUIDef[] defs;
+
+ private final EventListenerList listeners;
+
+ public UIFactory(String applicationName, DialogUIDef[] defs, FactoryWindowListener... listeners) {
+ this.applicationName = applicationName;
+ this.listeners = new EventListenerList();
+ for (FactoryWindowListener listener : listeners) {
+ listener.setFactory(this);
+ addFactoryWindowListener(listener);
+ }
+ this.defs = defs;
+ long t0 = System.nanoTime();
+ if (log.isDebugEnabled()) {
+ log.debug("start at " + new java.util.Date());
+ }
+ try {
+ init();
+ } catch (Exception e) {
+ log.error(e);
+ throw new RuntimeException(e);
+ } finally {
+ if (log.isDebugEnabled()) {
+ log.info("end in " + StringUtil.convertTime(t0, System.nanoTime()));
+ }
+ }
+ }
+
+ public void addFactoryWindowListener(FactoryWindowListener l) {
+ listeners.add(FactoryWindowListener.class, l);
+ if (log.isDebugEnabled()) {
+ log.debug("after added (" + listeners.getListenerCount() + ") : " + l);
+ }
+ }
+
+ public void removeFactoryWindowListener(FactoryWindowListener l) {
+ listeners.remove(FactoryWindowListener.class, l);
+ for (DialogUIDef def : getDefs()) {
+ if (def.uiInstance != null) {
+ def.uiInstance.removeWindowListener(l);
+ }
+ }
+ if (log.isDebugEnabled()) {
+ log.debug(" after removed (" + listeners.getListenerCount() + ") : " + l);
+ }
+ if (listeners.getListenerCount(FactoryWindowListener.class) == 0) {
+ // close for real factory
+ close();
+ }
+ }
+
+ public void close() {
+ log.info(this + " at " + new java.util.Date());
+ for (DialogUIDef<?, ?, ?> def : defs) {
+ DialogUI<?> ui = def.uiInstance;
+ if (ui != null) {
+ ui.getHandler().dispose();
+ def.uiInstance = null;
+ }
+ }
+ if (listeners.getListenerCount(FactoryWindowListener.class) > 0) {
+ log.warn("some listeners where not properly removed, force deletion...");
+ for (FactoryWindowListener listener : listeners.getListeners(FactoryWindowListener.class)) {
+ removeFactoryWindowListener(listener);
+ }
+ }
+
+ }
+
+ protected void init() {
+
+ UIProvider[] providers = detectProviders();
+
+ for (DialogUIDef<?, ?, ?> def : defs) {
+ initDef(providers, def);
+ if (def.getUiImplClass() == null) {
+ throw new IllegalStateException("could not find implementation for ui def " + def);
+ }
+ }
+ }
+
+ protected void initDef(UIProvider[] providers, DialogUIDef<?, ?, ?> def) {
+ for (UIProvider provider : providers) {
+ Class<?> uiImplClass = provider.findUIImplementation(def);
+ if (uiImplClass != null) {
+ if (log.isDebugEnabled()) {
+ log.debug("init done for " + def);
+ }
+ // ui implementation was found
+ break;
+ }
+ }
+ }
+
+ protected UIProvider[] detectProviders() {
+ long t0 = System.nanoTime();
+ List<UIProvider> providers = new ArrayList<UIProvider>();
+ for (UIProvider provider : ServiceLoader.load(UIProvider.class)) {
+ if (applicationName.equals(provider.getApplicationName())) {
+ if (log.isDebugEnabled()) {
+ log.debug("provider detected [" + provider + ']');
+ }
+ providers.add(provider);
+ }
+ }
+ log.info("found " + providers.size() + " ui provider(s) in " + StringUtil.convertTime(t0, System.nanoTime()) + " : " + providers);
+ return providers.toArray(new UIProvider[providers.size()]);
+ }
+
+ protected DialogUIDef[] getDefs() {
+ return defs;
+ }
+
+ @Override
+ protected void finalize() throws Throwable {
+ super.finalize();
+ close();
+ }
+
+ public <M extends DialogUIModel, U extends DialogUI<H>, H extends DialogUIHandler<M, U>> U getUI(DialogUIDef<M, U, H> uiType, Object... params) {
+ U ui = uiType.uiInstance;
+ if (ui == null) {
+ try {
+ ui = uiType.newUI();
+ M model = uiType.newModel();
+ H handler = uiType.newHandler(ui, model, params);
+ registerUI(uiType, ui, handler);
+ } catch (Exception e) {
+ throw new IllegalStateException("could not instanciate ui handler " + uiType + " for reason : " + e.getMessage(), e);
+ }
+ }
+ return ui;
+ }
+
+ protected <M extends DialogUIModel, U extends DialogUI<H>, H extends DialogUIHandler<M, U>> void registerUI(DialogUIDef<M, U, H> uiType, U ui, H handler) {
+ ui.setHandler(handler);
+ handler.init();
+ uiType.setUiInstance(ui);
+ for (FactoryWindowListener listener : listeners.getListeners(FactoryWindowListener.class)) {
+ if (log.isDebugEnabled()) {
+ log.debug("----- addFactoryWindowListener " + listener + " to " + ui);
+ }
+ ui.addWindowListener(listener);
+ }
+ }
+
+}
\ No newline at end of file
Copied: trunk/lutinjaxx/util/src/main/java/org/codelutin/jaxx/util/UIHelper.java (from rev 700, trunk/lutinjaxx/util/src/main/java/org/codelutin/util/UIHelper.java)
===================================================================
--- trunk/lutinjaxx/util/src/main/java/org/codelutin/jaxx/util/UIHelper.java (rev 0)
+++ trunk/lutinjaxx/util/src/main/java/org/codelutin/jaxx/util/UIHelper.java 2008-07-08 21:14:58 UTC (rev 705)
@@ -0,0 +1,70 @@
+/*
+* ##% Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 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.util;
+
+import javax.swing.AbstractAction;
+import javax.swing.Action;
+import javax.swing.ImageIcon;
+import javax.swing.JComponent;
+import javax.swing.JDialog;
+import javax.swing.JRootPane;
+import javax.swing.KeyStroke;
+import java.awt.event.ActionEvent;
+
+/**
+ * Ui helper class.
+ *
+ * @author tony
+ */
+public class UIHelper {
+
+ public static ImageIcon createImageIcon(String path) {
+ java.net.URL imgURL = UIHelper.class.getResource("/icons/" + path);
+ if (imgURL != null) {
+ return new ImageIcon(imgURL);
+ } else {
+ throw new IllegalArgumentException("could not find icon " + path);
+ }
+ }
+
+ /**
+ * Attach to <code>ui</code> an abort action,accessible by <code>ESC</code> key.
+ *
+ * @param ui ui
+ */
+ public static void setQuitAction(final JDialog ui) {
+ JRootPane rootPane = ui.getRootPane();
+
+ Action quitAction = new AbstractAction("quit") {
+ private static final long serialVersionUID = -869095664995763057L;
+
+ public void actionPerformed(ActionEvent e) {
+ ui.dispose();
+ }
+ };
+ rootPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("ESCAPE"), "quit");
+ rootPane.getActionMap().put("quit", quitAction);
+ ui.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
+ }
+
+ public static ImageIcon createActionIcon(String name) {
+ return createImageIcon("action-" + name + ".png");
+ }
+
+}
Copied: trunk/lutinjaxx/util/src/main/java/org/codelutin/jaxx/util/UIProvider.java (from rev 700, trunk/lutinjaxx/util/src/main/java/org/codelutin/util/UIProvider.java)
===================================================================
--- trunk/lutinjaxx/util/src/main/java/org/codelutin/jaxx/util/UIProvider.java (rev 0)
+++ trunk/lutinjaxx/util/src/main/java/org/codelutin/jaxx/util/UIProvider.java 2008-07-08 21:14:58 UTC (rev 705)
@@ -0,0 +1,86 @@
+/**
+ * # #% 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.util;
+
+/** @author chemit */
+public abstract class UIProvider {
+
+ /** the name of application using this provider */
+ protected String applicationName;
+
+ /** the name of ui implementation used by this provider */
+ protected String providerName;
+
+ /** array of ui implementations */
+ protected Class<?>[] implementations;
+
+ protected UIProvider(String applicationName, String providerName, Class<?>... implementations) {
+ this.applicationName = applicationName;
+ this.providerName = providerName;
+ this.implementations = implementations;
+ }
+
+ public String getProviderName() {
+ return providerName;
+ }
+
+ public String getApplicationName() {
+ return applicationName;
+ }
+
+ public Class<?>[] getImplementations() {
+ return implementations;
+ }
+
+ public Class<?> findUIImplementation(DialogUIDef<?, ?, ?> def) {
+ Class<? extends DialogUI<?>> uiClass = def.getUiClass();
+ for (Class<?> klass : implementations) {
+ if (uiClass.isAssignableFrom(klass)) {
+ def.setUiImplClass(klass);
+ return klass;
+ }
+ }
+ return null;
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder(super.toString()).append('<');
+ sb.append(printClass("application", applicationName, true));
+ sb.append(printClass("provider", providerName, true));
+ sb.append(printClass("uis", implementations.length, false));
+ return sb.toString();
+ }
+
+ protected String printClass(String s, Object aClass, boolean notLast) {
+ return s + ':' + (aClass == null ? null : aClass) + (notLast ? ", " : ">");
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (!(o instanceof UIProvider)) return false;
+
+ UIProvider that = (UIProvider) o;
+ return applicationName.equals(that.applicationName) && providerName.equals(that.providerName);
+
+ }
+
+ @Override
+ public int hashCode() {
+ return (31 * applicationName.hashCode()) + providerName.hashCode();
+ }
+
+}
\ No newline at end of file
Deleted: trunk/lutinjaxx/util/src/main/java/org/codelutin/util/AbstractUIAction.java
===================================================================
--- trunk/lutinjaxx/util/src/main/java/org/codelutin/util/AbstractUIAction.java 2008-07-08 21:14:13 UTC (rev 704)
+++ trunk/lutinjaxx/util/src/main/java/org/codelutin/util/AbstractUIAction.java 2008-07-08 21:14:58 UTC (rev 705)
@@ -1,53 +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.ui;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-/** @author chemit */
-public abstract class AbstractUIAction<H extends DialogUIHandler<?, ?>> extends javax.swing.AbstractAction {
-
- protected static Log log = LogFactory.getLog(AbstractUIAction.class);
-
- protected transient DialogUI<? extends H> ui;
-
- private static final long serialVersionUID = 1L;
-
- protected AbstractUIAction(String name, javax.swing.Icon icon, DialogUI<? extends H> ui) {
- super(name, icon);
- this.ui = ui;
- }
-
- protected H getHandler() {
- checkInit();
- return ui.getHandler();
- }
-
- protected void setUi(DialogUI<? extends H> ui) {
- this.ui = ui;
- }
-
- public DialogUI<? extends H> getUi() {
- return ui;
- }
-
- protected void checkInit() throws IllegalStateException {
- /*if (ui == null) {
- throw new IllegalStateException("no handler, nor ui referenced in " + this);
- } */
- }
-
-}
Deleted: trunk/lutinjaxx/util/src/main/java/org/codelutin/util/DialogUI.java
===================================================================
--- trunk/lutinjaxx/util/src/main/java/org/codelutin/util/DialogUI.java 2008-07-08 21:14:13 UTC (rev 704)
+++ trunk/lutinjaxx/util/src/main/java/org/codelutin/util/DialogUI.java 2008-07-08 21:14:58 UTC (rev 705)
@@ -1,129 +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.ui;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import javax.swing.AbstractAction;
-import javax.swing.AbstractButton;
-import javax.swing.ImageIcon;
-import javax.swing.JDialog;
-import java.awt.event.WindowEvent;
-import java.awt.event.WindowListener;
-import java.lang.reflect.Constructor;
-
-/**
- * A abstract dialog contract to be realised by a dialogUI (WindowEvent adapter)
- * <p/>
- * TODO : make jaxx authorized implementing interface for root tag :)
- *
- * @author chemit
- */
-public abstract class DialogUI<H extends DialogUIHandler> extends JDialog implements WindowListener {
-
- protected static Log log = LogFactory.getLog(DialogUI.class);
-
- public javax.swing.AbstractAction newAction(Class<?> actionClass, Object... params) {
- Constructor<?> constructor = null;
- for (Constructor<?> cons : actionClass.getConstructors()) {
- Class<?>[] prototype = cons.getParameterTypes();
- if (prototype.length > 0 && DialogUI.class.isAssignableFrom(prototype[0])) {
- // use this constructor
- constructor = cons;
- break;
- }
- }
- if (constructor == null) {
- throw new IllegalStateException("could not find a matching constructor for " + actionClass);
- }
-
- // wrap params
- Object[] parameters = new Object[1 + params.length];
- parameters[0] = this;
- System.arraycopy(params, 0, parameters, 1, params.length);
- try {
- AbstractAction action = (AbstractAction) constructor.newInstance(parameters);
- if (log.isInfoEnabled()) {
- log.info(action);
- }
- return action;
- } catch (Exception e) {
- throw new IllegalStateException("could not init the action " + actionClass + " for reason : " + e.getMessage());
- }
- }
-
- private H handler;
-
- public abstract AbstractButton getHelp();
-
- public abstract Object getObjectById(java.lang.String s);
-
- protected DialogUI() {
- UIHelper.setQuitAction(this);
- addWindowListener(this);
- //TODO will be handled by jaxx with javax.help...
- //getHelp().setAction(newAction(HelpAction.class));
- }
-
- public H getHandler() {
- return handler;
- }
-
- public void setHandler(H handler) {
- this.handler = handler;
- }
-
- protected ImageIcon createActionIcon(String name) {
- return UIHelper.createActionIcon(name);
- }
-
- public void windowOpened(WindowEvent e) {
- }
-
- public void windowClosed(WindowEvent e) {
- }
-
- public void windowClosing(WindowEvent e) {
- }
-
- public void windowIconified(WindowEvent e) {
- }
-
- public void windowDeiconified(WindowEvent e) {
- }
-
- public void windowActivated(WindowEvent e) {
- }
-
- public void windowDeactivated(WindowEvent e) {
- }
-
- @Override
- public synchronized void addWindowListener(WindowListener l) {
- super.addWindowListener(l);
- if (log.isDebugEnabled()) {
- log.debug("after added (" + getWindowListeners().length + ") : " + l);
- }
- }
-
- @Override
- public synchronized void removeWindowListener(WindowListener l) {
- super.removeWindowListener(l);
- if (log.isDebugEnabled()) {
- log.debug("after removed (" + getWindowListeners().length + ") : " + l);
- }
- }
-}
\ No newline at end of file
Deleted: trunk/lutinjaxx/util/src/main/java/org/codelutin/util/DialogUIDef.java
===================================================================
--- trunk/lutinjaxx/util/src/main/java/org/codelutin/util/DialogUIDef.java 2008-07-08 21:14:13 UTC (rev 704)
+++ trunk/lutinjaxx/util/src/main/java/org/codelutin/util/DialogUIDef.java 2008-07-08 21:14:58 UTC (rev 705)
@@ -1,235 +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.ui;
-
-import static org.codelutin.i18n.I18n._;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import javax.swing.ImageIcon;
-import java.lang.reflect.Constructor;
-
-/**
- * Definition of an ui, with his model, handler and ui class definitions.
- * <p/>
- * The class contains also a shared instace of concrete ui.
- *
- * @author chemit
- */
-public class DialogUIDef<M extends DialogUIModel, U extends DialogUI<H>, H extends DialogUIHandler<M, U>> implements java.io.Serializable {
-
- static protected final Log log = LogFactory.getLog(DialogUIDef.class);
-
- public static <M extends DialogUIModel, U extends DialogUI<H>, H extends DialogUIHandler<M, U>> DialogUIDef<M, U, H> newDef(Class<H> handlerClass, Class<U> uiClass, Class<M> modelClass, String showActionLibelle, String showActionTip, String uiTitle) {
- DialogUIDef<M, U, H> result;
- result = new DialogUIDef<M, U, H>(handlerClass, uiClass, modelClass, showActionLibelle, showActionTip, uiTitle);
- return result;
- }
-
- /**
- * model class
- */
- private final Class<M> modelClass;
-
- /**
- * handler class
- */
- private final Class<H> handlerClass;
-
- /**
- * abstract ui class
- */
- private final Class<U> uiClass;
-
- /**
- * concrete lookup ui class
- */
- private Class<? extends U> uiImplClass;
-
- /**
- * shared instance of ui
- */
- protected U uiInstance;
-
- /**
- * unique name of ui def
- */
- protected final String name;
-
- protected final String uiTitle;
- protected final String showActionLibelle;
- protected final String showActionTip;
-
- protected ImageIcon showUIActionIcon;
-
-
- private static final long serialVersionUID = 1L;
-
- private DialogUIDef(Class<H> handlerClass, Class<U> uiClass, Class<M> modelClass,
- String showActionLibelle, String showActionTip, String uiTitle) {
- this.handlerClass = handlerClass;
- this.uiClass = uiClass;
- this.modelClass = modelClass;
- this.showActionLibelle = showActionLibelle;
- this.name = uiClass.getSimpleName().toLowerCase();
- this.showActionTip = showActionTip;
- this.uiTitle = uiTitle;
- }
-
- public Class<U> getUiClass() {
- return uiClass;
- }
-
- public Class<H> getHandlerClass() {
- return handlerClass;
- }
-
- public Class<M> getModelClass() {
- return modelClass;
- }
-
- public Class<? extends U> getUiImplClass() {
- return uiImplClass;
- }
-
- public String getUiTitle() {
- return _(uiTitle);
- }
-
- public String getShowActionLibelle() {
- return _(showActionLibelle);
- }
-
- public String getShowActionTip() {
- return _(showActionTip);
- }
-
- public ImageIcon getShowUIActionIcon() {
- if (showUIActionIcon == null) {
- showUIActionIcon = UIHelper.createActionIcon("show-" + name);
- }
- return showUIActionIcon;
- }
-
- @SuppressWarnings({"unchecked"})
- public void setUiImplClass(Class<?> uiImplClass) {
- this.uiImplClass = (Class<? extends U>) uiImplClass;
- }
-
- @Override
- public boolean equals(Object o) {
- return this == o || o instanceof DialogUIDef && uiClass.equals(((DialogUIDef) o).uiClass);
- }
-
- @Override
- public int hashCode() {
- return uiClass.hashCode();
- }
-
- @Override
- public String toString() {
- StringBuilder sb = new StringBuilder(super.toString()).append('<');
- sb.append(printClass("handler", handlerClass, true));
- sb.append(printClass("model", modelClass, true));
- sb.append(printClass("ui", uiClass, true));
- sb.append(printClass("uiImpl", uiImplClass, false));
- return sb.toString();
- }
-
- protected U getUiInstance() {
- // no lazy instanciation, to control ui instanciation...
- /*if (uiInstance == null) {
- if (uiImplClass == null) {
- throw new IllegalStateException("no concrete ui impl found in " + this);
- }
- synchronized (this) {
- try {
- uiInstance = uiImplClass.newInstance();
- } catch (Exception e) {
- throw new IllegalStateException("could not instanciate ui " + this,e);
- }
- }
- }*/
- return uiInstance;
- }
-
- protected void setUiInstance(U uiInstance) {
- this.uiInstance = uiInstance;
- }
-
- protected U newUI() {
- if (uiImplClass == null) {
- throw new IllegalStateException("no concrete ui impl found in " + this);
- }
- try {
- U result = uiImplClass.newInstance();
- log.info(result);
- return result;
- } catch (Exception e) {
- throw new IllegalStateException("could not instanciate ui " + this, e);
- }
- }
-
- protected M newModel() {
- if (modelClass == null) {
- throw new IllegalStateException("no model impl found in " + this);
- }
- try {
- M model = modelClass.newInstance();
- log.info(model);
- return model;
- } catch (Exception e) {
- throw new IllegalStateException("could not instanciate ui " + this, e);
- }
- }
-
- protected H newHandler(U ui, M model, Object... params) {
- if (handlerClass == null) {
- throw new IllegalStateException("no handler impl found in " + this);
- }
- try {
- Class[] prototype = getHandlerPrototype(params);
- Object[] parameters = getHandlerParameters(ui, model, params);
- H result = handlerClass.getConstructor(prototype).newInstance(parameters);
- log.info(result);
- return result;
- } catch (Exception e) {
- throw new IllegalStateException("could not instanciate ui " + this, e);
- }
- }
-
- protected Object[] getHandlerParameters(U ui, M model, Object[] params) {
- Object[] result = new Object[2 + params.length];
- result[0] = ui;
- result[1] = model;
- System.arraycopy(params, 0, result, 2, params.length);
- return result;
- }
-
- protected Class[] getHandlerPrototype(Object[] params) {
- int length = params.length;
- for (Constructor<?> constructor : handlerClass.getConstructors()) {
- Class<?>[] prototype = constructor.getParameterTypes();
- if (prototype.length == 2 + length && prototype[0] == uiClass && prototype[1] == modelClass) {
- return prototype;
- }
- }
- throw new IllegalStateException("could not find a matching constructor in " + handlerClass);
- }
-
- protected String printClass(String s, Class<?> aClass, boolean notLast) {
- return s + ':' + (aClass == null ? null : aClass.getSimpleName()) + (notLast ? ", " : ">");
- }
-}
Deleted: trunk/lutinjaxx/util/src/main/java/org/codelutin/util/DialogUIHandler.java
===================================================================
--- trunk/lutinjaxx/util/src/main/java/org/codelutin/util/DialogUIHandler.java 2008-07-08 21:14:13 UTC (rev 704)
+++ trunk/lutinjaxx/util/src/main/java/org/codelutin/util/DialogUIHandler.java 2008-07-08 21:14:58 UTC (rev 705)
@@ -1,70 +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.ui;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import java.awt.event.WindowListener;
-import java.beans.PropertyChangeListener;
-
-/**
- * DialogUI handler
- *
- * @author chemit
- */
-public abstract class DialogUIHandler<M extends DialogUIModel, U extends DialogUI<? extends DialogUIHandler>> implements PropertyChangeListener {
-
- protected static Log log = LogFactory.getLog(DialogUIHandler.class);
-
- /** ui handled */
- private U ui;
-
- /** model handled */
- private M model;
-
- protected DialogUIHandler(U ui, M model) {
- this.ui = ui;
- this.model = model;
- }
-
- public U getUi() {
- return ui;
- }
-
- public M getModel() {
- return model;
- }
-
- public void init() {
- if (model == null) {
- throw new IllegalStateException("no model was defined for " + this);
- }
- model.addPropertyChangeListener(this);
- }
-
- public void dispose() {
- model.dispose();
- for (WindowListener windowListener : getUi().getWindowListeners()) {
- getUi().removeWindowListener(windowListener);
- }
- }
-
- @Override
- protected void finalize() throws Throwable {
- super.finalize();
- dispose();
- }
-}
\ No newline at end of file
Deleted: trunk/lutinjaxx/util/src/main/java/org/codelutin/util/DialogUIModel.java
===================================================================
--- trunk/lutinjaxx/util/src/main/java/org/codelutin/util/DialogUIModel.java 2008-07-08 21:14:13 UTC (rev 704)
+++ trunk/lutinjaxx/util/src/main/java/org/codelutin/util/DialogUIModel.java 2008-07-08 21:14:58 UTC (rev 705)
@@ -1,97 +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.ui;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import java.beans.PropertyChangeListener;
-import java.beans.PropertyChangeSupport;
-
-/**
- * Abstract ui model, with property change support.
- *
- * @author chemit
- */
-public abstract class DialogUIModel {
-
- static protected final Log log = LogFactory.getLog(DialogUIModel.class);
-
- /** support for change properties support */
- protected PropertyChangeSupport changeSupport;
-
- public synchronized void addPropertyChangeListener(String propertyName, PropertyChangeListener listener) {
- if (listener == null) {
- return;
- }
- if (changeSupport == null) {
- changeSupport = new PropertyChangeSupport(this);
- }
- changeSupport.addPropertyChangeListener(propertyName, listener);
- }
-
- public synchronized void addPropertyChangeListener(PropertyChangeListener listener) {
- if (listener == null) {
- return;
- }
- if (changeSupport == null) {
- changeSupport = new PropertyChangeSupport(this);
- }
- changeSupport.addPropertyChangeListener(listener);
- }
-
- public synchronized void removePropertyChangeListener(PropertyChangeListener listener) {
- if (listener == null || changeSupport == null) {
- return;
- }
- changeSupport.removePropertyChangeListener(listener);
- }
-
- public synchronized void removePropertyChangeListeners() {
- if (changeSupport == null) {
- return;
- }
- for (PropertyChangeListener listener : getPropertyChangeListeners()) {
- changeSupport.removePropertyChangeListener(listener);
- }
- }
-
- public synchronized PropertyChangeListener[] getPropertyChangeListeners() {
- if (changeSupport == null) {
- return new PropertyChangeListener[0];
- }
- return changeSupport.getPropertyChangeListeners();
- }
-
- public void firePropertyChange(String propertyName, Object oldValue, Object newValue) {
- if (changeSupport == null || (oldValue == null && newValue == null) ||
- (oldValue != null && oldValue.equals(newValue))) {
- return;
- }
- changeSupport.firePropertyChange(propertyName, oldValue, newValue);
- }
-
- public void dispose() {
- for (PropertyChangeListener listener : changeSupport.getPropertyChangeListeners()) {
- changeSupport.removePropertyChangeListener(listener);
- }
- }
-
- @Override
- protected void finalize() throws Throwable {
- super.finalize();
- dispose();
- }
-}
\ No newline at end of file
Deleted: trunk/lutinjaxx/util/src/main/java/org/codelutin/util/FactoryWindowListener.java
===================================================================
--- trunk/lutinjaxx/util/src/main/java/org/codelutin/util/FactoryWindowListener.java 2008-07-08 21:14:13 UTC (rev 704)
+++ trunk/lutinjaxx/util/src/main/java/org/codelutin/util/FactoryWindowListener.java 2008-07-08 21:14:58 UTC (rev 705)
@@ -1,86 +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.ui;
-
-import static org.codelutin.ui.UIFactory.log;
-
-import java.awt.event.WindowAdapter;
-import java.awt.event.WindowEvent;
-
-/**
- * A windowListenr for ui managed by {@link org.codelutin.ui.UIFactory}.
- * <p/>
- * To be used when all ui from factory are closed, via {@link #allWindowsClosed(java.awt.event.WindowEvent)} method.
- *
- * @author chemit
- */
-public abstract class FactoryWindowListener extends WindowAdapter {
-
- /**
- * method to be invoked when all ui registred in factory are really disposed.
- *
- * @param e event
- */
- public abstract void allWindowsClosed(WindowEvent e);
-
- /** underlying factory of ui */
- private UIFactory factory;
-
- /** flag to make sure {@link #allWindowsClosed(java.awt.event.WindowEvent)} is called only once. */
- private boolean wasClosed;
-
- @Override
- public void windowClosed(WindowEvent e) {
- if (log.isDebugEnabled()) {
- log.debug(this + " : " + e);
- }
- if (e.getWindow().isVisible()) {
- // only deal with real closed and none visible windows...
- return;
- }
- for (DialogUIDef def : factory.getDefs()) {
- DialogUI ui = def.uiInstance;
- if (ui != null && ui.isVisible()) {
- // at least one ui visible, do not close all
- return;
- }
- }
-
- if (wasClosed) {
- // make sure to process only once
- return;
- }
- if (log.isInfoEnabled()) {
- log.info("closing factory listener " + this);
- }
-
- synchronized (this) {
- try {
- allWindowsClosed(e);
- } finally {
- wasClosed = true;
- factory.removeFactoryWindowListener(this);
- }
- }
- }
-
- protected UIFactory getFactory() {
- return factory;
- }
-
- protected void setFactory(UIFactory factory) {
- this.factory = factory;
- }
-}
Deleted: trunk/lutinjaxx/util/src/main/java/org/codelutin/util/FormElement.java
===================================================================
--- trunk/lutinjaxx/util/src/main/java/org/codelutin/util/FormElement.java 2008-07-08 21:14:13 UTC (rev 704)
+++ trunk/lutinjaxx/util/src/main/java/org/codelutin/util/FormElement.java 2008-07-08 21:14:58 UTC (rev 705)
@@ -1,29 +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.ui;
-
-/** @author chemit */
-public interface FormElement<U extends DialogUI> {
-
- String name();
-
- int ordinal();
-
- Object getValue(U ui);
-
- void setValue(U ui, String value);
-
- javax.swing.JLabel getLabel(U ui);
-}
Deleted: trunk/lutinjaxx/util/src/main/java/org/codelutin/util/ShowUIAction.java
===================================================================
--- trunk/lutinjaxx/util/src/main/java/org/codelutin/util/ShowUIAction.java 2008-07-08 21:14:13 UTC (rev 704)
+++ trunk/lutinjaxx/util/src/main/java/org/codelutin/util/ShowUIAction.java 2008-07-08 21:14:58 UTC (rev 705)
@@ -1,135 +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.ui;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import java.awt.Dimension;
-import java.awt.Point;
-import java.awt.event.ActionEvent;
-
-/** @author chemit */
-public abstract class ShowUIAction<M extends DialogUIModel, U extends DialogUI<H>, H extends DialogUIHandler<M, U>> extends javax.swing.AbstractAction {
-
- protected static Log log = LogFactory.getLog(AbstractUIAction.class);
-
- protected transient DialogUI<?> ui;
-
- private static final long serialVersionUID = 1L;
-
- protected DialogUIDef<M, U, H> uiDef;
-
- protected transient UIFactory factory;
-
- protected String position;
-
- protected boolean undecorated = true;
-
- protected U initUI(ActionEvent e) {
- return getFactory().getUI(uiDef);
- }
-
- public ShowUIAction(DialogUI<?> ui, DialogUIDef<M, U, H> uiDef, UIFactory factory, boolean showText) {
- super(uiDef.getShowActionLibelle(), uiDef.getShowUIActionIcon());
- this.ui = ui;
- this.uiDef = uiDef;
- String name = (String) getValue(NAME);
- putValue(DISPLAYED_MNEMONIC_INDEX_KEY, name.length() - 1);
- putValue(ACCELERATOR_KEY, (int) name.charAt(name.length() - 1));
- if (!showText) {
- putValue(NAME, null);
- }
- putValue(SHORT_DESCRIPTION, uiDef.getShowActionTip());
- this.factory = factory;
- }
-
- public DialogUI<?> getUi() {
- return ui;
- }
-
- public DialogUIDef<M, U, H> getUiDef() {
- return uiDef;
- }
-
- public UIFactory getFactory() {
- return factory;
- }
-
- public void setUiDef(DialogUIDef<M, U, H> uiDef) {
- this.uiDef = uiDef;
- }
-
- public void setPosition(String position) {
- this.position = position;
- }
-
- public void setUndecorated(boolean undecorated) {
- this.undecorated = undecorated;
- }
-
- public void actionPerformed(java.awt.event.ActionEvent e) {
- checkInit();
- U ui = initUI(e);
- ui.setTitle(uiDef.getUiTitle());
- log.info(ui.getTitle());
- //TODO ui.setUndecorated(undecorated);
- setPosition(this.getUi(), ui, position);
-
- ui.setVisible(true);
- }
-
- protected void setPosition(javax.swing.JDialog parentUI, javax.swing.JDialog ui, String position) {
- if (position == null || parentUI == null) {
- return;
- }
- Point parentLocation = parentUI.getLocationOnScreen();
- Dimension parentSize = parentUI.getSize();
-
- if (position.equals("bottom-left")) {
- int top = (int) (parentLocation.getY() + parentSize.getHeight());
- int left = (int) (parentLocation.getX());
- Point newLocation = new Point(left, top);
- newLocation.setLocation(left, top);
- ui.setLocation(newLocation);
- return;
- }
- if (position.equals("top-left")) {
- int top = (int) (parentLocation.getY());
- int left = (int) (parentLocation.getX());
- Point newLocation = new Point(left, top);
- newLocation.setLocation(left, top);
- ui.setLocation(newLocation);
- return;
- }
- if (position.equals("top-right")) {
- int top = (int) (parentLocation.getY());
- int left = (int) (parentLocation.getX() + parentSize.getWidth());
- Point newLocation = new Point(left, top);
- newLocation.setLocation(left, top);
- ui.setLocation(newLocation);
- return;
- }
- if (position.equals(("center"))) {
- //TODO
- }
- }
-
- protected void checkInit() throws IllegalStateException {
- if (factory == null) {
- throw new IllegalStateException("no factory found in " + this);
- }
- }
-}
\ No newline at end of file
Deleted: trunk/lutinjaxx/util/src/main/java/org/codelutin/util/UIFactory.java
===================================================================
--- trunk/lutinjaxx/util/src/main/java/org/codelutin/util/UIFactory.java 2008-07-08 21:14:13 UTC (rev 704)
+++ trunk/lutinjaxx/util/src/main/java/org/codelutin/util/UIFactory.java 2008-07-08 21:14:58 UTC (rev 705)
@@ -1,184 +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.ui;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.codelutin.util.StringUtil;
-
-import javax.swing.event.EventListenerList;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.ServiceLoader;
-
-/**
- * Factory for UI, using a cache and a provider to find ui implementations.
- *
- * @author chemit
- */
-public class UIFactory {
-
- static protected final Log log = LogFactory.getLog(UIFactory.class);
-
- private final String applicationName;
-
- private final DialogUIDef[] defs;
-
- private final EventListenerList listeners;
-
- public UIFactory(String applicationName, DialogUIDef[] defs, FactoryWindowListener... listeners) {
- this.applicationName = applicationName;
- this.listeners = new EventListenerList();
- for (FactoryWindowListener listener : listeners) {
- listener.setFactory(this);
- addFactoryWindowListener(listener);
- }
- this.defs = defs;
- long t0 = System.nanoTime();
- if (log.isDebugEnabled()) {
- log.debug("start at " + new java.util.Date());
- }
- try {
- init();
- } catch (Exception e) {
- log.error(e);
- throw new RuntimeException(e);
- } finally {
- if (log.isDebugEnabled()) {
- log.info("end in " + StringUtil.convertTime(t0, System.nanoTime()));
- }
- }
- }
-
- public void addFactoryWindowListener(FactoryWindowListener l) {
- listeners.add(FactoryWindowListener.class, l);
- if (log.isDebugEnabled()) {
- log.debug("after added (" + listeners.getListenerCount() + ") : " + l);
- }
- }
-
- public void removeFactoryWindowListener(FactoryWindowListener l) {
- listeners.remove(FactoryWindowListener.class, l);
- for (DialogUIDef def : getDefs()) {
- if (def.uiInstance != null) {
- def.uiInstance.removeWindowListener(l);
- }
- }
- if (log.isDebugEnabled()) {
- log.debug(" after removed (" + listeners.getListenerCount() + ") : " + l);
- }
- if (listeners.getListenerCount(FactoryWindowListener.class) == 0) {
- // close for real factory
- close();
- }
- }
-
- public void close() {
- log.info(this + " at " + new java.util.Date());
- for (DialogUIDef<?, ?, ?> def : defs) {
- DialogUI<?> ui = def.uiInstance;
- if (ui != null) {
- ui.getHandler().dispose();
- def.uiInstance = null;
- }
- }
- if (listeners.getListenerCount(FactoryWindowListener.class) > 0) {
- log.warn("some listeners where not properly removed, force deletion...");
- for (FactoryWindowListener listener : listeners.getListeners(FactoryWindowListener.class)) {
- removeFactoryWindowListener(listener);
- }
- }
-
- }
-
- protected void init() {
-
- UIProvider[] providers = detectProviders();
-
- for (DialogUIDef<?, ?, ?> def : defs) {
- initDef(providers, def);
- if (def.getUiImplClass() == null) {
- throw new IllegalStateException("could not find implementation for ui def " + def);
- }
- }
- }
-
- protected void initDef(UIProvider[] providers, DialogUIDef<?, ?, ?> def) {
- for (UIProvider provider : providers) {
- Class<?> uiImplClass = provider.findUIImplementation(def);
- if (uiImplClass != null) {
- if (log.isDebugEnabled()) {
- log.debug("init done for " + def);
- }
- // ui implementation was found
- break;
- }
- }
- }
-
- protected UIProvider[] detectProviders() {
- long t0 = System.nanoTime();
- List<UIProvider> providers = new ArrayList<UIProvider>();
- for (UIProvider provider : ServiceLoader.load(UIProvider.class)) {
- if (applicationName.equals(provider.getApplicationName())) {
- if (log.isDebugEnabled()) {
- log.debug("provider detected [" + provider + ']');
- }
- providers.add(provider);
- }
- }
- log.info("found " + providers.size() + " ui provider(s) in " + StringUtil.convertTime(t0, System.nanoTime()) + " : " + providers);
- return providers.toArray(new UIProvider[providers.size()]);
- }
-
- protected DialogUIDef[] getDefs() {
- return defs;
- }
-
- @Override
- protected void finalize() throws Throwable {
- super.finalize();
- close();
- }
-
- public <M extends DialogUIModel, U extends DialogUI<H>, H extends DialogUIHandler<M, U>> U getUI(DialogUIDef<M, U, H> uiType, Object... params) {
- U ui = uiType.uiInstance;
- if (ui == null) {
- try {
- ui = uiType.newUI();
- M model = uiType.newModel();
- H handler = uiType.newHandler(ui, model, params);
- registerUI(uiType, ui, handler);
- } catch (Exception e) {
- throw new IllegalStateException("could not instanciate ui handler " + uiType + " for reason : " + e.getMessage(), e);
- }
- }
- return ui;
- }
-
- protected <M extends DialogUIModel, U extends DialogUI<H>, H extends DialogUIHandler<M, U>> void registerUI(DialogUIDef<M, U, H> uiType, U ui, H handler) {
- ui.setHandler(handler);
- handler.init();
- uiType.setUiInstance(ui);
- for (FactoryWindowListener listener : listeners.getListeners(FactoryWindowListener.class)) {
- if (log.isDebugEnabled()) {
- log.debug("----- addFactoryWindowListener " + listener + " to " + ui);
- }
- ui.addWindowListener(listener);
- }
- }
-
-}
\ No newline at end of file
Deleted: trunk/lutinjaxx/util/src/main/java/org/codelutin/util/UIHelper.java
===================================================================
--- trunk/lutinjaxx/util/src/main/java/org/codelutin/util/UIHelper.java 2008-07-08 21:14:13 UTC (rev 704)
+++ trunk/lutinjaxx/util/src/main/java/org/codelutin/util/UIHelper.java 2008-07-08 21:14:58 UTC (rev 705)
@@ -1,70 +0,0 @@
-/*
-* ##% Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 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.ui;
-
-import javax.swing.AbstractAction;
-import javax.swing.Action;
-import javax.swing.ImageIcon;
-import javax.swing.JComponent;
-import javax.swing.JDialog;
-import javax.swing.JRootPane;
-import javax.swing.KeyStroke;
-import java.awt.event.ActionEvent;
-
-/**
- * Ui helper class.
- *
- * @author tony
- */
-public class UIHelper {
-
- public static ImageIcon createImageIcon(String path) {
- java.net.URL imgURL = UIHelper.class.getResource("/icons/" + path);
- if (imgURL != null) {
- return new ImageIcon(imgURL);
- } else {
- throw new IllegalArgumentException("could not find icon " + path);
- }
- }
-
- /**
- * Attach to <code>ui</code> an abort action,accessible by <code>ESC</code> key.
- *
- * @param ui ui
- */
- public static void setQuitAction(final JDialog ui) {
- JRootPane rootPane = ui.getRootPane();
-
- Action quitAction = new AbstractAction("quit") {
- private static final long serialVersionUID = -869095664995763057L;
-
- public void actionPerformed(ActionEvent e) {
- ui.dispose();
- }
- };
- rootPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("ESCAPE"), "quit");
- rootPane.getActionMap().put("quit", quitAction);
- ui.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
- }
-
- public static ImageIcon createActionIcon(String name) {
- return createImageIcon("action-" + name + ".png");
- }
-
-}
Deleted: trunk/lutinjaxx/util/src/main/java/org/codelutin/util/UIProvider.java
===================================================================
--- trunk/lutinjaxx/util/src/main/java/org/codelutin/util/UIProvider.java 2008-07-08 21:14:13 UTC (rev 704)
+++ trunk/lutinjaxx/util/src/main/java/org/codelutin/util/UIProvider.java 2008-07-08 21:14:58 UTC (rev 705)
@@ -1,86 +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.ui;
-
-/** @author chemit */
-public abstract class UIProvider {
-
- /** the name of application using this provider */
- protected String applicationName;
-
- /** the name of ui implementation used by this provider */
- protected String providerName;
-
- /** array of ui implementations */
- protected Class<?>[] implementations;
-
- protected UIProvider(String applicationName, String providerName, Class<?>... implementations) {
- this.applicationName = applicationName;
- this.providerName = providerName;
- this.implementations = implementations;
- }
-
- public String getProviderName() {
- return providerName;
- }
-
- public String getApplicationName() {
- return applicationName;
- }
-
- public Class<?>[] getImplementations() {
- return implementations;
- }
-
- public Class<?> findUIImplementation(DialogUIDef<?, ?, ?> def) {
- Class<? extends DialogUI<?>> uiClass = def.getUiClass();
- for (Class<?> klass : implementations) {
- if (uiClass.isAssignableFrom(klass)) {
- def.setUiImplClass(klass);
- return klass;
- }
- }
- return null;
- }
-
- @Override
- public String toString() {
- StringBuilder sb = new StringBuilder(super.toString()).append('<');
- sb.append(printClass("application", applicationName, true));
- sb.append(printClass("provider", providerName, true));
- sb.append(printClass("uis", implementations.length, false));
- return sb.toString();
- }
-
- protected String printClass(String s, Object aClass, boolean notLast) {
- return s + ':' + (aClass == null ? null : aClass) + (notLast ? ", " : ">");
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) return true;
- if (!(o instanceof UIProvider)) return false;
-
- UIProvider that = (UIProvider) o;
- return applicationName.equals(that.applicationName) && providerName.equals(that.providerName);
-
- }
-
- @Override
- public int hashCode() {
- return (31 * applicationName.hashCode()) + providerName.hashCode();
- }
-
-}
\ No newline at end of file
1
0
[Buix-commits] r704 - in trunk/lutinjaxx/util/src/main/java/org/codelutin: jaxx/util/config util/config
by tchemit@users.labs.libre-entreprise.org 08 Jul '08
by tchemit@users.labs.libre-entreprise.org 08 Jul '08
08 Jul '08
Author: tchemit
Date: 2008-07-08 21:14:13 +0000 (Tue, 08 Jul 2008)
New Revision: 704
Added:
trunk/lutinjaxx/util/src/main/java/org/codelutin/jaxx/util/config/CancelAction.java
trunk/lutinjaxx/util/src/main/java/org/codelutin/jaxx/util/config/DialogConfigUI.java
trunk/lutinjaxx/util/src/main/java/org/codelutin/jaxx/util/config/DialogConfigUIHandler.java
trunk/lutinjaxx/util/src/main/java/org/codelutin/jaxx/util/config/DialogConfigUIModel.java
trunk/lutinjaxx/util/src/main/java/org/codelutin/jaxx/util/config/ResetAction.java
trunk/lutinjaxx/util/src/main/java/org/codelutin/jaxx/util/config/SaveAction.java
Removed:
trunk/lutinjaxx/util/src/main/java/org/codelutin/util/config/CancelAction.java
trunk/lutinjaxx/util/src/main/java/org/codelutin/util/config/DialogConfigUI.java
trunk/lutinjaxx/util/src/main/java/org/codelutin/util/config/DialogConfigUIHandler.java
trunk/lutinjaxx/util/src/main/java/org/codelutin/util/config/DialogConfigUIModel.java
trunk/lutinjaxx/util/src/main/java/org/codelutin/util/config/ResetAction.java
trunk/lutinjaxx/util/src/main/java/org/codelutin/util/config/SaveAction.java
Log:
use org.codelutin.jaxx:util module
Copied: trunk/lutinjaxx/util/src/main/java/org/codelutin/jaxx/util/config/CancelAction.java (from rev 700, trunk/lutinjaxx/util/src/main/java/org/codelutin/util/config/CancelAction.java)
===================================================================
--- trunk/lutinjaxx/util/src/main/java/org/codelutin/jaxx/util/config/CancelAction.java (rev 0)
+++ trunk/lutinjaxx/util/src/main/java/org/codelutin/jaxx/util/config/CancelAction.java 2008-07-08 21:14:13 UTC (rev 704)
@@ -0,0 +1,43 @@
+/**
+ * ##% 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.util.config;
+
+import org.codelutin.ui.AbstractUIAction;
+import org.codelutin.ui.DialogUI;
+import org.codelutin.ui.UIHelper;
+
+import java.awt.event.ActionEvent;
+
+/** @author chemit */
+public class CancelAction<E extends Enum<E>, H extends DialogConfigUIHandler<E, ?, ?>> extends AbstractUIAction<H> {
+ private static final long serialVersionUID = 1L;
+
+ public CancelAction(DialogUI<? extends H> dialogUI, boolean showLabel) {
+ super(null, UIHelper.createActionIcon("cancel-config"), dialogUI);
+ if (showLabel) {
+ String text = org.codelutin.i18n.I18n._("lutinui.config.cancel");
+ putValue(NAME, text);
+ putValue(DISPLAYED_MNEMONIC_INDEX_KEY, 0);
+ putValue(MNEMONIC_KEY, (int) text.charAt(0));
+ }
+ String libelle = org.codelutin.i18n.I18n._("lutinui.config.cancel.tooltip");
+ putValue(SHORT_DESCRIPTION, libelle);
+
+ }
+
+ public void actionPerformed(ActionEvent e) {
+ getUi().dispose();
+ }
+}
\ No newline at end of file
Copied: trunk/lutinjaxx/util/src/main/java/org/codelutin/jaxx/util/config/DialogConfigUI.java (from rev 700, trunk/lutinjaxx/util/src/main/java/org/codelutin/util/config/DialogConfigUI.java)
===================================================================
--- trunk/lutinjaxx/util/src/main/java/org/codelutin/jaxx/util/config/DialogConfigUI.java (rev 0)
+++ trunk/lutinjaxx/util/src/main/java/org/codelutin/jaxx/util/config/DialogConfigUI.java 2008-07-08 21:14:13 UTC (rev 704)
@@ -0,0 +1,105 @@
+/**
+ * ##% 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.util.config;
+
+import org.codelutin.ui.DialogUI;
+
+import javax.swing.AbstractButton;
+import javax.swing.JCheckBox;
+import javax.swing.JComboBox;
+import javax.swing.JComponent;
+import javax.swing.JLabel;
+import javax.swing.JPasswordField;
+import javax.swing.JRadioButton;
+import javax.swing.JTextField;
+
+/**
+ * A abstract dialog contract to be realised by a dialogUI (WindowEvent adapter)
+ * <p/>
+ * TODO : make jaxx authorized implementing interface for root tag :)
+ *
+ * @author chemit
+ */
+public abstract class DialogConfigUI<E extends Enum<E>, H extends DialogConfigUIHandler<E, ?, ?>> extends DialogUI<H> {
+
+ public abstract AbstractButton getOk();
+
+ public abstract AbstractButton getReset();
+
+ public abstract AbstractButton getCancel();
+
+ public JComponent getElement(E key) {
+ Object id = getObjectById(key.name());
+ if (id == null) {
+ log.error(new NullPointerException("no widget for key "+key));
+ return null;
+ }
+ if (!(id instanceof JComponent)) {
+ throw new IllegalArgumentException(id + " is not a JComponent");
+ }
+ return (JComponent) id;
+ }
+
+ public Object getElementValue(E key) {
+ JComponent o = getElement(key);
+ if (o instanceof JPasswordField) {
+ return new String(((JPasswordField) o).getPassword());
+ }
+ if (o instanceof JTextField) {
+ return ((JTextField) o).getText();
+ }
+ if (o instanceof JRadioButton) {
+ return ((JRadioButton) o).isSelected();
+ }
+ if (o instanceof JCheckBox) {
+ return ((JCheckBox) o).isSelected();
+ }
+
+ if (o instanceof JComboBox) {
+ return ((JComboBox) o).getSelectedItem();
+ }
+ return "";
+ }
+
+ public void setElementValue(E key, Object value) {
+ JComponent o = getElement(key);
+
+ String strValue = value == null ? "" : String.valueOf(value);
+ if (o instanceof JPasswordField) {
+ ((JPasswordField) o).setText(strValue);
+ }
+ if (o instanceof JTextField) {
+ ((JTextField) o).setText(strValue);
+ }
+ if (o instanceof JRadioButton) {
+ ((JRadioButton) o).setSelected(Boolean.valueOf(strValue.isEmpty() ? "false" : strValue));
+ }
+ if (o instanceof JCheckBox) {
+ ((JCheckBox) o).setSelected(Boolean.valueOf(strValue.isEmpty() ? "false" : strValue));
+ }
+ if (o instanceof JComboBox) {
+ ((JComboBox) o).setSelectedItem(value);
+ }
+ }
+
+ public JLabel getElementLabel(E key) {
+ return (JLabel) getObjectById(key.name() + "Label");
+ }
+
+ public void doCheck(E key) {
+ getHandler().doCheck(key);
+ }
+
+}
\ No newline at end of file
Copied: trunk/lutinjaxx/util/src/main/java/org/codelutin/jaxx/util/config/DialogConfigUIHandler.java (from rev 700, trunk/lutinjaxx/util/src/main/java/org/codelutin/util/config/DialogConfigUIHandler.java)
===================================================================
--- trunk/lutinjaxx/util/src/main/java/org/codelutin/jaxx/util/config/DialogConfigUIHandler.java (rev 0)
+++ trunk/lutinjaxx/util/src/main/java/org/codelutin/jaxx/util/config/DialogConfigUIHandler.java 2008-07-08 21:14:13 UTC (rev 704)
@@ -0,0 +1,156 @@
+/**
+ * ##% 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.util.config;
+
+import org.codelutin.ui.DialogUIHandler;
+import org.codelutin.util.ConverterUtil;
+import org.codelutin.util.config.Config;
+import org.codelutin.util.config.Property;
+
+import javax.swing.JComponent;
+import java.awt.Color;
+import java.beans.PropertyChangeEvent;
+import java.util.EnumMap;
+import java.util.EnumSet;
+
+/**
+ * DialogUI handler
+ *
+ * @author chemit
+ */
+public abstract class DialogConfigUIHandler<E extends Enum<E>, M extends DialogConfigUIModel<E, ?>, U extends DialogConfigUI<E, ?>> extends DialogUIHandler<M, U> {
+
+ protected DialogConfigUIHandler(U ui, M model) {
+ super(ui, model);
+ }
+
+ public void propertyChange(PropertyChangeEvent evt) {
+ if (log.isDebugEnabled()) {
+ log.debug(evt.getPropertyName() + " old:" + evt.getOldValue() + ", new:" + evt.getNewValue());
+ }
+ String action = evt.getPropertyName();
+
+ if (DialogConfigUIModel.CONFIG_PROPERTY_CHANGED.equals(action)) {
+ // update ui with model values,
+ populateUI();
+ // revalidate form
+ doCheckAll();
+ return;
+ }
+
+ if (DialogConfigUIModel.MODIFIED_PROPERTY_CHANGED.equals(action)) {
+ Boolean newValue = (Boolean) evt.getNewValue();
+ boolean modified = newValue != null && newValue;
+ getUi().getReset().setEnabled(modified);
+ getUi().getOk().setEnabled(modified && getModel().isConfigValid());
+ return;
+ }
+
+ if (DialogConfigUIModel.UNVALID_PROPERTY_CHANGED.equals(action)) {
+ updateUI();
+ return;
+ }
+
+ throw new IllegalStateException("unimplemented property changed : " + evt + " for " + this);
+ }
+
+ public void doCheck(E key) {
+ Object uiValue = getUi().getElementValue(key);
+ DialogConfigUIModel<E, ?> model = getModel();
+ Object currentValue = model.getCurrent().getProperty(key);
+ if (currentValue == null) {
+ currentValue = "";
+ } else {
+ currentValue = String.valueOf(currentValue);
+ }
+
+ model.validateProperty(key, uiValue);
+ model.changeModifiedState(key, uiValue, currentValue);
+ }
+
+ public void doCheckAll() {
+ DialogConfigUIModel<E, ?> model = getModel();
+ EnumSet<E> unvalids = EnumSet.noneOf(model.klass);
+ for (E e : model.getCheckedKeysSet()) {
+ Object uiValue = getUi().getElementValue(e);
+ if (!model.isValid(e, uiValue)) {
+ unvalids.add(e);
+ }
+ }
+ model.setUnvalids(unvalids);
+ unvalids.clear();
+ }
+
+ protected boolean prepareSave() {
+ DialogConfigUI<E, ?> ui = getUi();
+ DialogConfigUIModel<E, ?> model = getModel();
+
+ Config<E> current = model.getCurrent();
+
+ if (!model.isConfigValid()) {
+ log.warn("do not save a unvalid config : " + model.getUnvalids());
+ return false;
+ }
+
+ if (!model.isModified()) {
+ log.warn("nothing to save");
+ return false;
+ }
+ EnumSet<E> toTreate = model.getCheckedKeysSet();
+ // transfert checkable values from ui to model
+ for (E key : model.getModifieds()) {
+ if (!toTreate.contains(key)) {
+ continue;
+ }
+ Object value = ui.getElementValue(key);
+ Class<?> type = ((Property) key).getType();
+ Object newValue = ConverterUtil.convert(type, value);
+ current.setProperty(key, newValue);
+ }
+
+ return true;
+ }
+
+ protected void populateUI() {
+ U ui = getUi();
+ EnumMap<E, Object> map = getModel().getCurrent().getProperties();
+ for (E e : getModel().getCheckedKeysSet()) {
+ Object value = map.get(e);
+ populateUI(ui, e, value);
+ }
+ }
+
+ protected void populateUI(U ui, E key, Object value) {
+ ui.setElementValue(key, value);
+ }
+
+ protected void updateUI() {
+ EnumSet<E> unvalids = getModel().getUnvalids();
+ for (E key : unvalids) {
+ setLabelColor(key, false);
+ }
+ for (E key : EnumSet.complementOf(unvalids)) {
+ setLabelColor(key, true);
+ }
+ }
+
+ protected void setLabelColor(E key, boolean valid) {
+ JComponent component = getUi().getElementLabel(key);
+ if (component != null && component.isVisible()) {
+ component.setForeground(valid ? Color.black : Color.red);
+ }
+ }
+
+}
\ No newline at end of file
Copied: trunk/lutinjaxx/util/src/main/java/org/codelutin/jaxx/util/config/DialogConfigUIModel.java (from rev 700, trunk/lutinjaxx/util/src/main/java/org/codelutin/util/config/DialogConfigUIModel.java)
===================================================================
--- trunk/lutinjaxx/util/src/main/java/org/codelutin/jaxx/util/config/DialogConfigUIModel.java (rev 0)
+++ trunk/lutinjaxx/util/src/main/java/org/codelutin/jaxx/util/config/DialogConfigUIModel.java 2008-07-08 21:14:13 UTC (rev 704)
@@ -0,0 +1,220 @@
+/**
+ * ##% 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.util.config;
+
+import org.codelutin.ui.DialogUIModel;
+import org.codelutin.util.config.Config;
+
+import java.util.EnumSet;
+
+/**
+ * Abstract config ui model.
+ *
+ * @author chemit
+ */
+public abstract class DialogConfigUIModel<E extends Enum<E>, C extends Config<E>> extends DialogUIModel {
+
+ public static final String CONFIG_PROPERTY_CHANGED = "config";
+ public static final String MODIFIED_PROPERTY_CHANGED = "modify";
+ public static final String UNVALID_PROPERTY_CHANGED = "unvalid";
+
+ /** @return a empty config */
+ protected abstract C newConfig();
+
+ /**
+ * @param key property key
+ * @param value value to validate
+ * @return <code>true</code> if given value is valid for property, <code>false>/code> otherwise
+ */
+ protected abstract boolean isValid(E key, Object value);
+
+ /**
+ * object used to init model and save model, this is an external object.
+ * <p/>
+ * The object must have bean read-write properties for each value of E
+ */
+ protected Object src;
+
+ /** current config used in model */
+ protected C current;
+
+ /** set of modified properties */
+ protected EnumSet<E> modifieds;
+
+ /** set of unvalid properties */
+ protected EnumSet<E> unvalids;
+
+ /** enum class */
+ protected Class<E> klass;
+
+ /** set of key not to check */
+ protected EnumSet<E> uncheckedKeys;
+
+ /** set of all keys checkable */
+ protected EnumSet<E> checkedKeysSet;
+
+ protected DialogConfigUIModel(Class<E> klass) {
+ this.klass = klass;
+ this.current = newConfig();
+ this.modifieds = EnumSet.noneOf(klass);
+ this.unvalids = EnumSet.noneOf(klass);
+ }
+
+ public EnumSet<E> getCheckedKeysSet() {
+ if (checkedKeysSet == null) {
+ if (uncheckedKeys != null) {
+ checkedKeysSet = EnumSet.complementOf(uncheckedKeys);
+ } else {
+ checkedKeysSet = EnumSet.allOf(klass);
+ }
+ }
+ return checkedKeysSet;
+ }
+
+ public Object getSrc() {
+ return src;
+ }
+
+ public C getCurrent() {
+ return current;
+ }
+
+ public EnumSet<E> getUnivserse() {
+ return getCurrent().getUniverse();
+ }
+
+ public EnumSet<E> getModifieds() {
+ return modifieds;
+ }
+
+ public EnumSet<E> getUnvalids() {
+ return unvalids;
+ }
+
+ public boolean isModified() {
+ return !modifieds.isEmpty();
+ }
+
+ public boolean isConfigValid() {
+ return unvalids.isEmpty();
+ }
+
+ public void populate(Object src) {
+ this.src = src;
+ this.current = newConfig();
+ if (src != null) {
+ this.current.copyFrom(src);
+ }
+ this.modifieds.clear();
+ this.unvalids.clear();
+ setModified(false);
+ firePropertyChange(CONFIG_PROPERTY_CHANGED, null, this);
+ }
+
+ public void reset() {
+ populate(src);
+ }
+
+ public void setModified(boolean modified) {
+ firePropertyChange(MODIFIED_PROPERTY_CHANGED, null, modified);
+ }
+
+ public void setUnvalid(boolean unvalid) {
+ firePropertyChange(UNVALID_PROPERTY_CHANGED, null, unvalid);
+ }
+
+ public void addModified(E key) {
+ if (!modifieds.contains(key)) {
+ modifieds.add(key);
+ log.debug(key);
+ }
+ setModified(!modifieds.isEmpty());
+ }
+
+ public void removeModified(E key) {
+
+ if (modifieds.contains(key)) {
+ modifieds.remove(key);
+ }
+ setModified(!modifieds.isEmpty());
+ }
+
+ public void removeModified(EnumSet<E> keys) {
+ for (E key : keys) {
+ if (modifieds.contains(key)) {
+ modifieds.remove(key);
+ }
+ }
+ setModified(!modifieds.isEmpty());
+ }
+
+ public void setUnvalids(EnumSet<E> keys) {
+ for (E key : keys) {
+ if (!unvalids.contains(key)) {
+ unvalids.add(key);
+ }
+ }
+ for (E key : EnumSet.complementOf(keys)) {
+ if (unvalids.contains(key)) {
+ unvalids.remove(key);
+ }
+ }
+ setUnvalid(!unvalids.isEmpty());
+ }
+
+
+ public void addUnvalid(E key) {
+ if (!unvalids.contains(key)) {
+ unvalids.add(key);
+ }
+ setUnvalid(!unvalids.isEmpty());
+ }
+
+ public void removeUnvalid(E key) {
+ if (unvalids.contains(key)) {
+ unvalids.remove(key);
+ }
+ setUnvalid(!unvalids.isEmpty());
+ }
+
+ public void save() {
+ current.copyTo(src, modifieds);
+ modifieds.clear();
+ // redisplay config
+ firePropertyChange(CONFIG_PROPERTY_CHANGED, null, this);
+ }
+
+ public void changeModifiedState(E key, Object uiValue, Object currentValue) {
+ if (uiValue!=null && uiValue.equals(currentValue)) {
+ removeModified(key);
+ } else {
+ addModified(key);
+ }
+ }
+
+ public void clear(E key) {
+ log.info(key);
+ modifieds.remove(key);
+ unvalids.remove(key);
+ }
+
+ protected void validateProperty(E key, Object uiValue) {
+ if (isValid(key, uiValue)) {
+ removeUnvalid(key);
+ } else {
+ addUnvalid(key);
+ }
+ }
+}
\ No newline at end of file
Copied: trunk/lutinjaxx/util/src/main/java/org/codelutin/jaxx/util/config/ResetAction.java (from rev 700, trunk/lutinjaxx/util/src/main/java/org/codelutin/util/config/ResetAction.java)
===================================================================
--- trunk/lutinjaxx/util/src/main/java/org/codelutin/jaxx/util/config/ResetAction.java (rev 0)
+++ trunk/lutinjaxx/util/src/main/java/org/codelutin/jaxx/util/config/ResetAction.java 2008-07-08 21:14:13 UTC (rev 704)
@@ -0,0 +1,43 @@
+/**
+ * ##% 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.util.config;
+
+import org.codelutin.ui.AbstractUIAction;
+import org.codelutin.ui.DialogUI;
+import org.codelutin.ui.UIHelper;
+
+import java.awt.event.ActionEvent;
+
+/** @author chemit */
+public class ResetAction<E extends Enum<E>, H extends DialogConfigUIHandler<E, ?, ?>> extends AbstractUIAction<H> {
+ private static final long serialVersionUID = 1L;
+
+ public ResetAction(DialogUI<? extends H> dialogUI, boolean showLabel) {
+ super(null, UIHelper.createActionIcon("reset-config"), dialogUI);
+ if (showLabel) {
+ String text = org.codelutin.i18n.I18n._("lutinui.config.reset");
+ putValue(NAME, text);
+ putValue(DISPLAYED_MNEMONIC_INDEX_KEY, 0);
+ putValue(MNEMONIC_KEY, (int) text.charAt(0));
+ }
+ String libelle = org.codelutin.i18n.I18n._("lutinui.config.reset.tooltip");
+ putValue(SHORT_DESCRIPTION, libelle);
+
+ }
+
+ public void actionPerformed(ActionEvent e) {
+ getHandler().getModel().reset();
+ }
+}
\ No newline at end of file
Copied: trunk/lutinjaxx/util/src/main/java/org/codelutin/jaxx/util/config/SaveAction.java (from rev 700, trunk/lutinjaxx/util/src/main/java/org/codelutin/util/config/SaveAction.java)
===================================================================
--- trunk/lutinjaxx/util/src/main/java/org/codelutin/jaxx/util/config/SaveAction.java (rev 0)
+++ trunk/lutinjaxx/util/src/main/java/org/codelutin/jaxx/util/config/SaveAction.java 2008-07-08 21:14:13 UTC (rev 704)
@@ -0,0 +1,50 @@
+/**
+ * ##% 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.util.config;
+
+import org.codelutin.ui.AbstractUIAction;
+import org.codelutin.ui.DialogUI;
+import org.codelutin.ui.UIHelper;
+
+import java.awt.event.ActionEvent;
+
+/** @author chemit */
+public class SaveAction<E extends Enum<E>, H extends DialogConfigUIHandler<E, ?, ?>> extends AbstractUIAction<H> {
+ private static final long serialVersionUID = 1L;
+
+ public SaveAction(DialogUI<? extends H> dialogUI, boolean showLabel) {
+ super(null, UIHelper.createActionIcon("save-config"), dialogUI);
+ if (showLabel) {
+ String text = org.codelutin.i18n.I18n._("lutinui.config.save");
+ putValue(NAME, text);
+ putValue(DISPLAYED_MNEMONIC_INDEX_KEY, 0);
+ putValue(MNEMONIC_KEY, (int) text.charAt(0));
+ }
+ String libelle = org.codelutin.i18n.I18n._("lutinui.config.save.tooltip");
+ putValue(SHORT_DESCRIPTION, libelle);
+ }
+
+ public void actionPerformed(ActionEvent e) {
+
+ if (getHandler().prepareSave()) {
+
+ // save model to src
+ getHandler().getModel().save();
+
+ // close ui
+ getUi().dispose();
+ }
+ }
+}
Deleted: trunk/lutinjaxx/util/src/main/java/org/codelutin/util/config/CancelAction.java
===================================================================
--- trunk/lutinjaxx/util/src/main/java/org/codelutin/util/config/CancelAction.java 2008-07-08 21:13:41 UTC (rev 703)
+++ trunk/lutinjaxx/util/src/main/java/org/codelutin/util/config/CancelAction.java 2008-07-08 21:14:13 UTC (rev 704)
@@ -1,43 +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.ui.config;
-
-import org.codelutin.ui.AbstractUIAction;
-import org.codelutin.ui.DialogUI;
-import org.codelutin.ui.UIHelper;
-
-import java.awt.event.ActionEvent;
-
-/** @author chemit */
-public class CancelAction<E extends Enum<E>, H extends DialogConfigUIHandler<E, ?, ?>> extends AbstractUIAction<H> {
- private static final long serialVersionUID = 1L;
-
- public CancelAction(DialogUI<? extends H> dialogUI, boolean showLabel) {
- super(null, UIHelper.createActionIcon("cancel-config"), dialogUI);
- if (showLabel) {
- String text = org.codelutin.i18n.I18n._("lutinui.config.cancel");
- putValue(NAME, text);
- putValue(DISPLAYED_MNEMONIC_INDEX_KEY, 0);
- putValue(MNEMONIC_KEY, (int) text.charAt(0));
- }
- String libelle = org.codelutin.i18n.I18n._("lutinui.config.cancel.tooltip");
- putValue(SHORT_DESCRIPTION, libelle);
-
- }
-
- public void actionPerformed(ActionEvent e) {
- getUi().dispose();
- }
-}
\ No newline at end of file
Deleted: trunk/lutinjaxx/util/src/main/java/org/codelutin/util/config/DialogConfigUI.java
===================================================================
--- trunk/lutinjaxx/util/src/main/java/org/codelutin/util/config/DialogConfigUI.java 2008-07-08 21:13:41 UTC (rev 703)
+++ trunk/lutinjaxx/util/src/main/java/org/codelutin/util/config/DialogConfigUI.java 2008-07-08 21:14:13 UTC (rev 704)
@@ -1,105 +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.ui.config;
-
-import org.codelutin.ui.DialogUI;
-
-import javax.swing.AbstractButton;
-import javax.swing.JCheckBox;
-import javax.swing.JComboBox;
-import javax.swing.JComponent;
-import javax.swing.JLabel;
-import javax.swing.JPasswordField;
-import javax.swing.JRadioButton;
-import javax.swing.JTextField;
-
-/**
- * A abstract dialog contract to be realised by a dialogUI (WindowEvent adapter)
- * <p/>
- * TODO : make jaxx authorized implementing interface for root tag :)
- *
- * @author chemit
- */
-public abstract class DialogConfigUI<E extends Enum<E>, H extends DialogConfigUIHandler<E, ?, ?>> extends DialogUI<H> {
-
- public abstract AbstractButton getOk();
-
- public abstract AbstractButton getReset();
-
- public abstract AbstractButton getCancel();
-
- public JComponent getElement(E key) {
- Object id = getObjectById(key.name());
- if (id == null) {
- log.error(new NullPointerException("no widget for key "+key));
- return null;
- }
- if (!(id instanceof JComponent)) {
- throw new IllegalArgumentException(id + " is not a JComponent");
- }
- return (JComponent) id;
- }
-
- public Object getElementValue(E key) {
- JComponent o = getElement(key);
- if (o instanceof JPasswordField) {
- return new String(((JPasswordField) o).getPassword());
- }
- if (o instanceof JTextField) {
- return ((JTextField) o).getText();
- }
- if (o instanceof JRadioButton) {
- return ((JRadioButton) o).isSelected();
- }
- if (o instanceof JCheckBox) {
- return ((JCheckBox) o).isSelected();
- }
-
- if (o instanceof JComboBox) {
- return ((JComboBox) o).getSelectedItem();
- }
- return "";
- }
-
- public void setElementValue(E key, Object value) {
- JComponent o = getElement(key);
-
- String strValue = value == null ? "" : String.valueOf(value);
- if (o instanceof JPasswordField) {
- ((JPasswordField) o).setText(strValue);
- }
- if (o instanceof JTextField) {
- ((JTextField) o).setText(strValue);
- }
- if (o instanceof JRadioButton) {
- ((JRadioButton) o).setSelected(Boolean.valueOf(strValue.isEmpty() ? "false" : strValue));
- }
- if (o instanceof JCheckBox) {
- ((JCheckBox) o).setSelected(Boolean.valueOf(strValue.isEmpty() ? "false" : strValue));
- }
- if (o instanceof JComboBox) {
- ((JComboBox) o).setSelectedItem(value);
- }
- }
-
- public JLabel getElementLabel(E key) {
- return (JLabel) getObjectById(key.name() + "Label");
- }
-
- public void doCheck(E key) {
- getHandler().doCheck(key);
- }
-
-}
\ No newline at end of file
Deleted: trunk/lutinjaxx/util/src/main/java/org/codelutin/util/config/DialogConfigUIHandler.java
===================================================================
--- trunk/lutinjaxx/util/src/main/java/org/codelutin/util/config/DialogConfigUIHandler.java 2008-07-08 21:13:41 UTC (rev 703)
+++ trunk/lutinjaxx/util/src/main/java/org/codelutin/util/config/DialogConfigUIHandler.java 2008-07-08 21:14:13 UTC (rev 704)
@@ -1,156 +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.ui.config;
-
-import org.codelutin.ui.DialogUIHandler;
-import org.codelutin.util.ConverterUtil;
-import org.codelutin.util.config.Config;
-import org.codelutin.util.config.Property;
-
-import javax.swing.JComponent;
-import java.awt.Color;
-import java.beans.PropertyChangeEvent;
-import java.util.EnumMap;
-import java.util.EnumSet;
-
-/**
- * DialogUI handler
- *
- * @author chemit
- */
-public abstract class DialogConfigUIHandler<E extends Enum<E>, M extends DialogConfigUIModel<E, ?>, U extends DialogConfigUI<E, ?>> extends DialogUIHandler<M, U> {
-
- protected DialogConfigUIHandler(U ui, M model) {
- super(ui, model);
- }
-
- public void propertyChange(PropertyChangeEvent evt) {
- if (log.isDebugEnabled()) {
- log.debug(evt.getPropertyName() + " old:" + evt.getOldValue() + ", new:" + evt.getNewValue());
- }
- String action = evt.getPropertyName();
-
- if (DialogConfigUIModel.CONFIG_PROPERTY_CHANGED.equals(action)) {
- // update ui with model values,
- populateUI();
- // revalidate form
- doCheckAll();
- return;
- }
-
- if (DialogConfigUIModel.MODIFIED_PROPERTY_CHANGED.equals(action)) {
- Boolean newValue = (Boolean) evt.getNewValue();
- boolean modified = newValue != null && newValue;
- getUi().getReset().setEnabled(modified);
- getUi().getOk().setEnabled(modified && getModel().isConfigValid());
- return;
- }
-
- if (DialogConfigUIModel.UNVALID_PROPERTY_CHANGED.equals(action)) {
- updateUI();
- return;
- }
-
- throw new IllegalStateException("unimplemented property changed : " + evt + " for " + this);
- }
-
- public void doCheck(E key) {
- Object uiValue = getUi().getElementValue(key);
- DialogConfigUIModel<E, ?> model = getModel();
- Object currentValue = model.getCurrent().getProperty(key);
- if (currentValue == null) {
- currentValue = "";
- } else {
- currentValue = String.valueOf(currentValue);
- }
-
- model.validateProperty(key, uiValue);
- model.changeModifiedState(key, uiValue, currentValue);
- }
-
- public void doCheckAll() {
- DialogConfigUIModel<E, ?> model = getModel();
- EnumSet<E> unvalids = EnumSet.noneOf(model.klass);
- for (E e : model.getCheckedKeysSet()) {
- Object uiValue = getUi().getElementValue(e);
- if (!model.isValid(e, uiValue)) {
- unvalids.add(e);
- }
- }
- model.setUnvalids(unvalids);
- unvalids.clear();
- }
-
- protected boolean prepareSave() {
- DialogConfigUI<E, ?> ui = getUi();
- DialogConfigUIModel<E, ?> model = getModel();
-
- Config<E> current = model.getCurrent();
-
- if (!model.isConfigValid()) {
- log.warn("do not save a unvalid config : " + model.getUnvalids());
- return false;
- }
-
- if (!model.isModified()) {
- log.warn("nothing to save");
- return false;
- }
- EnumSet<E> toTreate = model.getCheckedKeysSet();
- // transfert checkable values from ui to model
- for (E key : model.getModifieds()) {
- if (!toTreate.contains(key)) {
- continue;
- }
- Object value = ui.getElementValue(key);
- Class<?> type = ((Property) key).getType();
- Object newValue = ConverterUtil.convert(type, value);
- current.setProperty(key, newValue);
- }
-
- return true;
- }
-
- protected void populateUI() {
- U ui = getUi();
- EnumMap<E, Object> map = getModel().getCurrent().getProperties();
- for (E e : getModel().getCheckedKeysSet()) {
- Object value = map.get(e);
- populateUI(ui, e, value);
- }
- }
-
- protected void populateUI(U ui, E key, Object value) {
- ui.setElementValue(key, value);
- }
-
- protected void updateUI() {
- EnumSet<E> unvalids = getModel().getUnvalids();
- for (E key : unvalids) {
- setLabelColor(key, false);
- }
- for (E key : EnumSet.complementOf(unvalids)) {
- setLabelColor(key, true);
- }
- }
-
- protected void setLabelColor(E key, boolean valid) {
- JComponent component = getUi().getElementLabel(key);
- if (component != null && component.isVisible()) {
- component.setForeground(valid ? Color.black : Color.red);
- }
- }
-
-}
\ No newline at end of file
Deleted: trunk/lutinjaxx/util/src/main/java/org/codelutin/util/config/DialogConfigUIModel.java
===================================================================
--- trunk/lutinjaxx/util/src/main/java/org/codelutin/util/config/DialogConfigUIModel.java 2008-07-08 21:13:41 UTC (rev 703)
+++ trunk/lutinjaxx/util/src/main/java/org/codelutin/util/config/DialogConfigUIModel.java 2008-07-08 21:14:13 UTC (rev 704)
@@ -1,220 +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.ui.config;
-
-import org.codelutin.ui.DialogUIModel;
-import org.codelutin.util.config.Config;
-
-import java.util.EnumSet;
-
-/**
- * Abstract config ui model.
- *
- * @author chemit
- */
-public abstract class DialogConfigUIModel<E extends Enum<E>, C extends Config<E>> extends DialogUIModel {
-
- public static final String CONFIG_PROPERTY_CHANGED = "config";
- public static final String MODIFIED_PROPERTY_CHANGED = "modify";
- public static final String UNVALID_PROPERTY_CHANGED = "unvalid";
-
- /** @return a empty config */
- protected abstract C newConfig();
-
- /**
- * @param key property key
- * @param value value to validate
- * @return <code>true</code> if given value is valid for property, <code>false>/code> otherwise
- */
- protected abstract boolean isValid(E key, Object value);
-
- /**
- * object used to init model and save model, this is an external object.
- * <p/>
- * The object must have bean read-write properties for each value of E
- */
- protected Object src;
-
- /** current config used in model */
- protected C current;
-
- /** set of modified properties */
- protected EnumSet<E> modifieds;
-
- /** set of unvalid properties */
- protected EnumSet<E> unvalids;
-
- /** enum class */
- protected Class<E> klass;
-
- /** set of key not to check */
- protected EnumSet<E> uncheckedKeys;
-
- /** set of all keys checkable */
- protected EnumSet<E> checkedKeysSet;
-
- protected DialogConfigUIModel(Class<E> klass) {
- this.klass = klass;
- this.current = newConfig();
- this.modifieds = EnumSet.noneOf(klass);
- this.unvalids = EnumSet.noneOf(klass);
- }
-
- public EnumSet<E> getCheckedKeysSet() {
- if (checkedKeysSet == null) {
- if (uncheckedKeys != null) {
- checkedKeysSet = EnumSet.complementOf(uncheckedKeys);
- } else {
- checkedKeysSet = EnumSet.allOf(klass);
- }
- }
- return checkedKeysSet;
- }
-
- public Object getSrc() {
- return src;
- }
-
- public C getCurrent() {
- return current;
- }
-
- public EnumSet<E> getUnivserse() {
- return getCurrent().getUniverse();
- }
-
- public EnumSet<E> getModifieds() {
- return modifieds;
- }
-
- public EnumSet<E> getUnvalids() {
- return unvalids;
- }
-
- public boolean isModified() {
- return !modifieds.isEmpty();
- }
-
- public boolean isConfigValid() {
- return unvalids.isEmpty();
- }
-
- public void populate(Object src) {
- this.src = src;
- this.current = newConfig();
- if (src != null) {
- this.current.copyFrom(src);
- }
- this.modifieds.clear();
- this.unvalids.clear();
- setModified(false);
- firePropertyChange(CONFIG_PROPERTY_CHANGED, null, this);
- }
-
- public void reset() {
- populate(src);
- }
-
- public void setModified(boolean modified) {
- firePropertyChange(MODIFIED_PROPERTY_CHANGED, null, modified);
- }
-
- public void setUnvalid(boolean unvalid) {
- firePropertyChange(UNVALID_PROPERTY_CHANGED, null, unvalid);
- }
-
- public void addModified(E key) {
- if (!modifieds.contains(key)) {
- modifieds.add(key);
- log.debug(key);
- }
- setModified(!modifieds.isEmpty());
- }
-
- public void removeModified(E key) {
-
- if (modifieds.contains(key)) {
- modifieds.remove(key);
- }
- setModified(!modifieds.isEmpty());
- }
-
- public void removeModified(EnumSet<E> keys) {
- for (E key : keys) {
- if (modifieds.contains(key)) {
- modifieds.remove(key);
- }
- }
- setModified(!modifieds.isEmpty());
- }
-
- public void setUnvalids(EnumSet<E> keys) {
- for (E key : keys) {
- if (!unvalids.contains(key)) {
- unvalids.add(key);
- }
- }
- for (E key : EnumSet.complementOf(keys)) {
- if (unvalids.contains(key)) {
- unvalids.remove(key);
- }
- }
- setUnvalid(!unvalids.isEmpty());
- }
-
-
- public void addUnvalid(E key) {
- if (!unvalids.contains(key)) {
- unvalids.add(key);
- }
- setUnvalid(!unvalids.isEmpty());
- }
-
- public void removeUnvalid(E key) {
- if (unvalids.contains(key)) {
- unvalids.remove(key);
- }
- setUnvalid(!unvalids.isEmpty());
- }
-
- public void save() {
- current.copyTo(src, modifieds);
- modifieds.clear();
- // redisplay config
- firePropertyChange(CONFIG_PROPERTY_CHANGED, null, this);
- }
-
- public void changeModifiedState(E key, Object uiValue, Object currentValue) {
- if (uiValue!=null && uiValue.equals(currentValue)) {
- removeModified(key);
- } else {
- addModified(key);
- }
- }
-
- public void clear(E key) {
- log.info(key);
- modifieds.remove(key);
- unvalids.remove(key);
- }
-
- protected void validateProperty(E key, Object uiValue) {
- if (isValid(key, uiValue)) {
- removeUnvalid(key);
- } else {
- addUnvalid(key);
- }
- }
-}
\ No newline at end of file
Deleted: trunk/lutinjaxx/util/src/main/java/org/codelutin/util/config/ResetAction.java
===================================================================
--- trunk/lutinjaxx/util/src/main/java/org/codelutin/util/config/ResetAction.java 2008-07-08 21:13:41 UTC (rev 703)
+++ trunk/lutinjaxx/util/src/main/java/org/codelutin/util/config/ResetAction.java 2008-07-08 21:14:13 UTC (rev 704)
@@ -1,43 +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.ui.config;
-
-import org.codelutin.ui.AbstractUIAction;
-import org.codelutin.ui.DialogUI;
-import org.codelutin.ui.UIHelper;
-
-import java.awt.event.ActionEvent;
-
-/** @author chemit */
-public class ResetAction<E extends Enum<E>, H extends DialogConfigUIHandler<E, ?, ?>> extends AbstractUIAction<H> {
- private static final long serialVersionUID = 1L;
-
- public ResetAction(DialogUI<? extends H> dialogUI, boolean showLabel) {
- super(null, UIHelper.createActionIcon("reset-config"), dialogUI);
- if (showLabel) {
- String text = org.codelutin.i18n.I18n._("lutinui.config.reset");
- putValue(NAME, text);
- putValue(DISPLAYED_MNEMONIC_INDEX_KEY, 0);
- putValue(MNEMONIC_KEY, (int) text.charAt(0));
- }
- String libelle = org.codelutin.i18n.I18n._("lutinui.config.reset.tooltip");
- putValue(SHORT_DESCRIPTION, libelle);
-
- }
-
- public void actionPerformed(ActionEvent e) {
- getHandler().getModel().reset();
- }
-}
\ No newline at end of file
Deleted: trunk/lutinjaxx/util/src/main/java/org/codelutin/util/config/SaveAction.java
===================================================================
--- trunk/lutinjaxx/util/src/main/java/org/codelutin/util/config/SaveAction.java 2008-07-08 21:13:41 UTC (rev 703)
+++ trunk/lutinjaxx/util/src/main/java/org/codelutin/util/config/SaveAction.java 2008-07-08 21:14:13 UTC (rev 704)
@@ -1,50 +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.ui.config;
-
-import org.codelutin.ui.AbstractUIAction;
-import org.codelutin.ui.DialogUI;
-import org.codelutin.ui.UIHelper;
-
-import java.awt.event.ActionEvent;
-
-/** @author chemit */
-public class SaveAction<E extends Enum<E>, H extends DialogConfigUIHandler<E, ?, ?>> extends AbstractUIAction<H> {
- private static final long serialVersionUID = 1L;
-
- public SaveAction(DialogUI<? extends H> dialogUI, boolean showLabel) {
- super(null, UIHelper.createActionIcon("save-config"), dialogUI);
- if (showLabel) {
- String text = org.codelutin.i18n.I18n._("lutinui.config.save");
- putValue(NAME, text);
- putValue(DISPLAYED_MNEMONIC_INDEX_KEY, 0);
- putValue(MNEMONIC_KEY, (int) text.charAt(0));
- }
- String libelle = org.codelutin.i18n.I18n._("lutinui.config.save.tooltip");
- putValue(SHORT_DESCRIPTION, libelle);
- }
-
- public void actionPerformed(ActionEvent e) {
-
- if (getHandler().prepareSave()) {
-
- // save model to src
- getHandler().getModel().save();
-
- // close ui
- getUi().dispose();
- }
- }
-}
1
0
[Buix-commits] r703 - trunk/lutinjaxx/util/src/main/java/org/codelutin/jaxx/util
by tchemit@users.labs.libre-entreprise.org 08 Jul '08
by tchemit@users.labs.libre-entreprise.org 08 Jul '08
08 Jul '08
Author: tchemit
Date: 2008-07-08 21:13:41 +0000 (Tue, 08 Jul 2008)
New Revision: 703
Added:
trunk/lutinjaxx/util/src/main/java/org/codelutin/jaxx/util/config/
Log:
use org.codelutin.jaxx:util module
1
0
[Buix-commits] r702 - trunk/lutinjaxx/util/src/main/java/org/codelutin/jaxx
by tchemit@users.labs.libre-entreprise.org 08 Jul '08
by tchemit@users.labs.libre-entreprise.org 08 Jul '08
08 Jul '08
Author: tchemit
Date: 2008-07-08 21:13:17 +0000 (Tue, 08 Jul 2008)
New Revision: 702
Added:
trunk/lutinjaxx/util/src/main/java/org/codelutin/jaxx/util/
Log:
use org.codelutin.jaxx:util module
1
0
[Buix-commits] r701 - in trunk/lutinjaxx/core: . src/main/java/jaxx/compiler
by tchemit@users.labs.libre-entreprise.org 08 Jul '08
by tchemit@users.labs.libre-entreprise.org 08 Jul '08
08 Jul '08
Author: tchemit
Date: 2008-07-08 21:11:25 +0000 (Tue, 08 Jul 2008)
New Revision: 701
Modified:
trunk/lutinjaxx/core/pom.xml
trunk/lutinjaxx/core/src/main/java/jaxx/compiler/JAXXCompiler.java
Log:
use org.codelutin.jaxx:util module
Modified: trunk/lutinjaxx/core/pom.xml
===================================================================
--- trunk/lutinjaxx/core/pom.xml 2008-07-08 21:10:57 UTC (rev 700)
+++ trunk/lutinjaxx/core/pom.xml 2008-07-08 21:11:25 UTC (rev 701)
@@ -35,7 +35,12 @@
</plugins>
</build>
- <dependencies>
+ <dependencies>
+ <dependency>
+ <groupId>org.codelutin.jaxx</groupId>
+ <artifactId>util</artifactId>
+ </dependency>
+
<!-- pour acceder aux BeansInfos swing via Introspector -->
<dependency>
<groupId>com.sun</groupId>
Modified: trunk/lutinjaxx/core/src/main/java/jaxx/compiler/JAXXCompiler.java
===================================================================
--- trunk/lutinjaxx/core/src/main/java/jaxx/compiler/JAXXCompiler.java 2008-07-08 21:10:57 UTC (rev 700)
+++ trunk/lutinjaxx/core/src/main/java/jaxx/compiler/JAXXCompiler.java 2008-07-08 21:11:25 UTC (rev 701)
@@ -107,7 +107,7 @@
staticImports.add("jaxx.runtime.swing.VBox");
staticImports.add("jaxx.runtime.swing.Table");
staticImports.add("static org.codelutin.i18n.I18n._");
- staticImports.add("static org.codelutin.ui.UIHelper.createImageIcon");
+ staticImports.add("static org.codelutin.jaxx.util.UIHelper.createImageIcon");
}
private static DefaultObjectHandler firstPassClassTagHandler = new DefaultObjectHandler(ClassDescriptorLoader.getClassDescriptor(Object.class));
1
0
[Buix-commits] r700 - trunk/lutinjaxx/util/src/main/java/org/codelutin
by tchemit@users.labs.libre-entreprise.org 08 Jul '08
by tchemit@users.labs.libre-entreprise.org 08 Jul '08
08 Jul '08
Author: tchemit
Date: 2008-07-08 21:10:57 +0000 (Tue, 08 Jul 2008)
New Revision: 700
Added:
trunk/lutinjaxx/util/src/main/java/org/codelutin/util/
Removed:
trunk/lutinjaxx/util/src/main/java/org/codelutin/ui/
Log:
rename to util package
Copied: trunk/lutinjaxx/util/src/main/java/org/codelutin/util (from rev 697, trunk/lutinjaxx/util/src/main/java/org/codelutin/ui)
1
0
[Buix-commits] r699 - trunk/lutinjaxx/util/src/main/java/org/codelutin
by tchemit@users.labs.libre-entreprise.org 08 Jul '08
by tchemit@users.labs.libre-entreprise.org 08 Jul '08
08 Jul '08
Author: tchemit
Date: 2008-07-08 21:07:46 +0000 (Tue, 08 Jul 2008)
New Revision: 699
Added:
trunk/lutinjaxx/util/src/main/java/org/codelutin/jaxx/
Log:
add lutinui in jaxx:util
1
0
[Buix-commits] r698 - in trunk: lutinjaxx/util/src/main/resources lutinui/src/main/resources
by tchemit@users.labs.libre-entreprise.org 08 Jul '08
by tchemit@users.labs.libre-entreprise.org 08 Jul '08
08 Jul '08
Author: tchemit
Date: 2008-07-08 21:05:29 +0000 (Tue, 08 Jul 2008)
New Revision: 698
Added:
trunk/lutinjaxx/util/src/main/resources/i18n/
trunk/lutinjaxx/util/src/main/resources/icons/
Removed:
trunk/lutinui/src/main/resources/i18n/
trunk/lutinui/src/main/resources/icons/
Log:
add lutinui in jaxx:util
Copied: trunk/lutinjaxx/util/src/main/resources/i18n (from rev 690, trunk/lutinui/src/main/resources/i18n)
Copied: trunk/lutinjaxx/util/src/main/resources/icons (from rev 690, trunk/lutinui/src/main/resources/icons)
1
0
[Buix-commits] r697 - in trunk: lutinjaxx/util/src/main/java lutinui/src/main/java
by tchemit@users.labs.libre-entreprise.org 08 Jul '08
by tchemit@users.labs.libre-entreprise.org 08 Jul '08
08 Jul '08
Author: tchemit
Date: 2008-07-08 21:03:22 +0000 (Tue, 08 Jul 2008)
New Revision: 697
Added:
trunk/lutinjaxx/util/src/main/java/org/
Removed:
trunk/lutinui/src/main/java/org/
Log:
add lutinui in jaxx:util
Copied: trunk/lutinjaxx/util/src/main/java/org (from rev 690, trunk/lutinui/src/main/java/org)
1
0