Jaxx-commits
Threads by month
- ----- 2026 -----
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2005 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2004 -----
- December
- November
- October
- September
- August
- 3898 discussions
[Buix-commits] r607 - trunk/lutinui/src/main/java/org/codelutin/ui
by tchemit@users.labs.libre-entreprise.org 20 Apr '08
by tchemit@users.labs.libre-entreprise.org 20 Apr '08
20 Apr '08
Author: tchemit
Date: 2008-04-20 12:23:38 +0000 (Sun, 20 Apr 2008)
New Revision: 607
Modified:
trunk/lutinui/src/main/java/org/codelutin/ui/AbstractUIAction.java
trunk/lutinui/src/main/java/org/codelutin/ui/DialogUI.java
Log:
generic action factory in DialogUI.newAction
Modified: trunk/lutinui/src/main/java/org/codelutin/ui/AbstractUIAction.java
===================================================================
--- trunk/lutinui/src/main/java/org/codelutin/ui/AbstractUIAction.java 2008-04-20 10:49:03 UTC (rev 606)
+++ trunk/lutinui/src/main/java/org/codelutin/ui/AbstractUIAction.java 2008-04-20 12:23:38 UTC (rev 607)
@@ -23,32 +23,25 @@
protected static Log log = LogFactory.getLog(AbstractUIAction.class);
protected transient DialogUI<? extends H> ui;
- protected transient H handler;
private static final long serialVersionUID = 1L;
- protected AbstractUIAction(String name, javax.swing.Icon icon) {
+ protected AbstractUIAction(String name, javax.swing.Icon icon, DialogUI<? extends H> ui) {
super(name, icon);
+ this.ui = ui;
}
- public AbstractUIAction() {
- }
-
protected H getHandler() {
checkInit();
- if (handler == null) {
- handler = ui.getHandler();
- }
- return handler;
+ return ui.getHandler();
}
protected void setUi(DialogUI<? extends H> ui) {
this.ui = ui;
- this.handler = null;
}
protected void checkInit() throws IllegalStateException {
- if (handler == null && ui == null) {
+ if (ui == null) {
throw new IllegalStateException("no handler, nor ui referenced in " + this);
}
}
Modified: trunk/lutinui/src/main/java/org/codelutin/ui/DialogUI.java
===================================================================
--- trunk/lutinui/src/main/java/org/codelutin/ui/DialogUI.java 2008-04-20 10:49:03 UTC (rev 606)
+++ trunk/lutinui/src/main/java/org/codelutin/ui/DialogUI.java 2008-04-20 12:23:38 UTC (rev 607)
@@ -23,6 +23,7 @@
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)
@@ -35,16 +36,44 @@
protected static Log log = LogFactory.getLog(DialogUI.class);
+ public javax.swing.AbstractAction newAction(Class<? extends AbstractUIAction> 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();
- //TODO will be handled by jaxx with javax.help...
- protected abstract AbstractAction createHelpAction();
-
protected DialogUI() {
UIHelper.setQuitAction(this);
addWindowListener(this);
+ //TODO will be handled by jaxx with javax.help...
+ //getHelp().setAction(newAction(HelpAction.class));
}
public H getHandler() {
1
0
[Buix-commits] r606 - trunk/lutinui/src/main/java/org/codelutin/ui
by tchemit@users.labs.libre-entreprise.org 20 Apr '08
by tchemit@users.labs.libre-entreprise.org 20 Apr '08
20 Apr '08
Author: tchemit
Date: 2008-04-20 10:49:03 +0000 (Sun, 20 Apr 2008)
New Revision: 606
Modified:
trunk/lutinui/src/main/java/org/codelutin/ui/AbstractUIAction.java
Log:
imports
Modified: trunk/lutinui/src/main/java/org/codelutin/ui/AbstractUIAction.java
===================================================================
--- trunk/lutinui/src/main/java/org/codelutin/ui/AbstractUIAction.java 2008-04-20 10:47:40 UTC (rev 605)
+++ trunk/lutinui/src/main/java/org/codelutin/ui/AbstractUIAction.java 2008-04-20 10:49:03 UTC (rev 606)
@@ -16,8 +16,6 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.codelutin.ui.DialogUI;
-import org.codelutin.ui.DialogUIHandler;
/** @author chemit */
public abstract class AbstractUIAction<H extends DialogUIHandler<?, ?>> extends javax.swing.AbstractAction {
1
0
[Buix-commits] r605 - in trunk: lutinui/src/main/java/org/codelutin/ui lutinvcs/ui/common/src/main/java/org/codelutin/ui
by tchemit@users.labs.libre-entreprise.org 20 Apr '08
by tchemit@users.labs.libre-entreprise.org 20 Apr '08
20 Apr '08
Author: tchemit
Date: 2008-04-20 10:47:40 +0000 (Sun, 20 Apr 2008)
New Revision: 605
Added:
trunk/lutinui/src/main/java/org/codelutin/ui/AbstractUIAction.java
Removed:
trunk/lutinvcs/ui/common/src/main/java/org/codelutin/ui/AbstractUIAction.java
Log:
generalisation de l'AbstractAction
Copied: trunk/lutinui/src/main/java/org/codelutin/ui/AbstractUIAction.java (from rev 604, trunk/lutinvcs/ui/common/src/main/java/org/codelutin/ui/AbstractUIAction.java)
===================================================================
--- trunk/lutinui/src/main/java/org/codelutin/ui/AbstractUIAction.java (rev 0)
+++ trunk/lutinui/src/main/java/org/codelutin/ui/AbstractUIAction.java 2008-04-20 10:47:40 UTC (rev 605)
@@ -0,0 +1,58 @@
+/**
+ * # #% 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.ui.DialogUI;
+import org.codelutin.ui.DialogUIHandler;
+
+/** @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;
+ protected transient H handler;
+
+ private static final long serialVersionUID = 1L;
+
+ protected AbstractUIAction(String name, javax.swing.Icon icon) {
+ super(name, icon);
+ }
+
+ public AbstractUIAction() {
+ }
+
+ protected H getHandler() {
+ checkInit();
+ if (handler == null) {
+ handler = ui.getHandler();
+ }
+ return handler;
+ }
+
+ protected void setUi(DialogUI<? extends H> ui) {
+ this.ui = ui;
+ this.handler = null;
+ }
+
+ protected void checkInit() throws IllegalStateException {
+ if (handler == null && ui == null) {
+ throw new IllegalStateException("no handler, nor ui referenced in " + this);
+ }
+ }
+
+}
Deleted: trunk/lutinvcs/ui/common/src/main/java/org/codelutin/ui/AbstractUIAction.java
===================================================================
--- trunk/lutinvcs/ui/common/src/main/java/org/codelutin/ui/AbstractUIAction.java 2008-04-20 10:44:42 UTC (rev 604)
+++ trunk/lutinvcs/ui/common/src/main/java/org/codelutin/ui/AbstractUIAction.java 2008-04-20 10:47:40 UTC (rev 605)
@@ -1,58 +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.ui.DialogUI;
-import org.codelutin.ui.DialogUIHandler;
-
-/** @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;
- protected transient H handler;
-
- private static final long serialVersionUID = 1L;
-
- protected AbstractUIAction(String name, javax.swing.Icon icon) {
- super(name, icon);
- }
-
- public AbstractUIAction() {
- }
-
- protected H getHandler() {
- checkInit();
- if (handler == null) {
- handler = ui.getHandler();
- }
- return handler;
- }
-
- protected void setUi(DialogUI<? extends H> ui) {
- this.ui = ui;
- this.handler = null;
- }
-
- protected void checkInit() throws IllegalStateException {
- if (handler == null && ui == null) {
- throw new IllegalStateException("no handler, nor ui referenced in " + this);
- }
- }
-
-}
1
0
[Buix-commits] r604 - in trunk/lutinvcs/ui/common/src/main/java/org/codelutin: . ui vcs/ui/action vcs/ui/util
by tchemit@users.labs.libre-entreprise.org 20 Apr '08
by tchemit@users.labs.libre-entreprise.org 20 Apr '08
20 Apr '08
Author: tchemit
Date: 2008-04-20 10:44:42 +0000 (Sun, 20 Apr 2008)
New Revision: 604
Added:
trunk/lutinvcs/ui/common/src/main/java/org/codelutin/ui/
trunk/lutinvcs/ui/common/src/main/java/org/codelutin/ui/AbstractUIAction.java
Removed:
trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/util/AbstractUIAction.java
Modified:
trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/action/ChangeFileAction.java
trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/action/ChangeLocationAction.java
trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/action/ConfirmAction.java
trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/action/DiffAction.java
trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/action/HelpAction.java
trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/action/ShowConfigAction.java
trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/action/ShowMessagesAction.java
trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/action/TabUIAction.java
Log:
generalisation de l'AbstractAction
Copied: trunk/lutinvcs/ui/common/src/main/java/org/codelutin/ui/AbstractUIAction.java (from rev 603, trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/util/AbstractUIAction.java)
===================================================================
--- trunk/lutinvcs/ui/common/src/main/java/org/codelutin/ui/AbstractUIAction.java (rev 0)
+++ trunk/lutinvcs/ui/common/src/main/java/org/codelutin/ui/AbstractUIAction.java 2008-04-20 10:44:42 UTC (rev 604)
@@ -0,0 +1,58 @@
+/**
+ * # #% 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.ui.DialogUI;
+import org.codelutin.ui.DialogUIHandler;
+
+/** @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;
+ protected transient H handler;
+
+ private static final long serialVersionUID = 1L;
+
+ protected AbstractUIAction(String name, javax.swing.Icon icon) {
+ super(name, icon);
+ }
+
+ public AbstractUIAction() {
+ }
+
+ protected H getHandler() {
+ checkInit();
+ if (handler == null) {
+ handler = ui.getHandler();
+ }
+ return handler;
+ }
+
+ protected void setUi(DialogUI<? extends H> ui) {
+ this.ui = ui;
+ this.handler = null;
+ }
+
+ protected void checkInit() throws IllegalStateException {
+ if (handler == null && ui == null) {
+ throw new IllegalStateException("no handler, nor ui referenced in " + this);
+ }
+ }
+
+}
Modified: trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/action/ChangeFileAction.java
===================================================================
--- trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/action/ChangeFileAction.java 2008-04-20 10:43:20 UTC (rev 603)
+++ trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/action/ChangeFileAction.java 2008-04-20 10:44:42 UTC (rev 604)
@@ -16,9 +16,10 @@
import org.codelutin.vcs.ui.util.ui.AbstractTabOneFileUI;
import org.codelutin.vcs.ui.util.handler.AbstractTabOneFileUIHandler;
+import org.codelutin.ui.AbstractUIAction;
/** @author chemit */
-public class ChangeFileAction extends org.codelutin.vcs.ui.util.AbstractUIAction<AbstractTabOneFileUIHandler<?, ?>> {
+public class ChangeFileAction extends AbstractUIAction<AbstractTabOneFileUIHandler<?, ?>> {
protected boolean goPrevious;
Modified: trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/action/ChangeLocationAction.java
===================================================================
--- trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/action/ChangeLocationAction.java 2008-04-20 10:43:20 UTC (rev 603)
+++ trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/action/ChangeLocationAction.java 2008-04-20 10:44:42 UTC (rev 604)
@@ -17,9 +17,10 @@
import org.codelutin.vcs.type.VCSEntryLocation;
import org.codelutin.vcs.ui.util.ui.AbstractTabUI;
import org.codelutin.vcs.ui.util.handler.AbstractTabUIHandler;
+import org.codelutin.ui.AbstractUIAction;
/** @author chemit */
-public class ChangeLocationAction extends org.codelutin.vcs.ui.util.AbstractUIAction<AbstractTabUIHandler<?, ?>> {
+public class ChangeLocationAction extends AbstractUIAction<AbstractTabUIHandler<?, ?>> {
protected VCSEntryLocation location;
Modified: trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/action/ConfirmAction.java
===================================================================
--- trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/action/ConfirmAction.java 2008-04-20 10:43:20 UTC (rev 603)
+++ trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/action/ConfirmAction.java 2008-04-20 10:44:42 UTC (rev 604)
@@ -16,9 +16,10 @@
import org.codelutin.vcs.type.VCSAction;
import org.codelutin.vcs.ui.handler.ConfirmUIHandler;
+import org.codelutin.ui.AbstractUIAction;
/** @author chemit */
-public class ConfirmAction extends org.codelutin.vcs.ui.util.AbstractUIAction<ConfirmUIHandler> {
+public class ConfirmAction extends AbstractUIAction<ConfirmUIHandler> {
protected VCSAction action;
Modified: trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/action/DiffAction.java
===================================================================
--- trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/action/DiffAction.java 2008-04-20 10:43:20 UTC (rev 603)
+++ trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/action/DiffAction.java 2008-04-20 10:44:42 UTC (rev 604)
@@ -14,8 +14,11 @@
*/
package org.codelutin.vcs.ui.action;
+import org.codelutin.vcs.ui.handler.DiffUIHandler;
+import org.codelutin.ui.AbstractUIAction;
+
/** @author chemit */
-public class DiffAction extends org.codelutin.vcs.ui.util.AbstractUIAction<org.codelutin.vcs.ui.handler.DiffUIHandler> {
+public class DiffAction extends AbstractUIAction<DiffUIHandler> {
protected boolean goUp;
Modified: trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/action/HelpAction.java
===================================================================
--- trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/action/HelpAction.java 2008-04-20 10:43:20 UTC (rev 603)
+++ trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/action/HelpAction.java 2008-04-20 10:44:42 UTC (rev 604)
@@ -17,9 +17,10 @@
import static org.codelutin.i18n.I18n._;
import org.codelutin.ui.DialogUI;
import org.codelutin.ui.DialogUIHandler;
+import org.codelutin.ui.AbstractUIAction;
/** @author chemit */
-public class HelpAction extends org.codelutin.vcs.ui.util.AbstractUIAction<DialogUIHandler<?, ?>> {
+public class HelpAction extends AbstractUIAction<DialogUIHandler<?, ?>> {
public static <H extends DialogUIHandler<?, ?>> javax.swing.AbstractAction createAction(DialogUI<H> ui) {
HelpAction action = new HelpAction();
Modified: trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/action/ShowConfigAction.java
===================================================================
--- trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/action/ShowConfigAction.java 2008-04-20 10:43:20 UTC (rev 603)
+++ trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/action/ShowConfigAction.java 2008-04-20 10:44:42 UTC (rev 604)
@@ -18,12 +18,13 @@
import static org.codelutin.vcs.ui.VCSUIFactory.CONFIG_UI;
import org.codelutin.vcs.ui.util.handler.AbstractUIHandler;
import org.codelutin.vcs.ui.util.ui.AbstractUI;
+import org.codelutin.ui.AbstractUIAction;
import javax.swing.AbstractAction;
import java.awt.event.ActionEvent;
/** @author chemit */
-public class ShowConfigAction extends org.codelutin.vcs.ui.util.AbstractUIAction<AbstractUIHandler<?, ?>> {
+public class ShowConfigAction extends AbstractUIAction<AbstractUIHandler<?, ?>> {
public static <H extends AbstractUIHandler<?, ?>> AbstractAction createAction(AbstractUI<H> ui) {
ShowConfigAction action = new ShowConfigAction();
Modified: trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/action/ShowMessagesAction.java
===================================================================
--- trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/action/ShowMessagesAction.java 2008-04-20 10:43:20 UTC (rev 603)
+++ trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/action/ShowMessagesAction.java 2008-04-20 10:44:42 UTC (rev 604)
@@ -15,9 +15,10 @@
package org.codelutin.vcs.ui.action;
import org.codelutin.vcs.ui.handler.ConfirmUIHandler;
+import org.codelutin.ui.AbstractUIAction;
/** @author chemit */
-public class ShowMessagesAction extends org.codelutin.vcs.ui.util.AbstractUIAction<ConfirmUIHandler> {
+public class ShowMessagesAction extends AbstractUIAction<ConfirmUIHandler> {
private static final long serialVersionUID = 1L;
Modified: trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/action/TabUIAction.java
===================================================================
--- trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/action/TabUIAction.java 2008-04-20 10:43:20 UTC (rev 603)
+++ trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/action/TabUIAction.java 2008-04-20 10:44:42 UTC (rev 604)
@@ -18,12 +18,13 @@
import org.codelutin.vcs.type.VCSAction;
import org.codelutin.vcs.ui.util.handler.AbstractTabUIHandler;
import org.codelutin.vcs.ui.util.ui.AbstractTabUI;
+import org.codelutin.ui.AbstractUIAction;
import java.util.List;
/** @author chemit */
-public class TabUIAction extends org.codelutin.vcs.ui.util.AbstractUIAction<AbstractTabUIHandler<?, ?>> {
+public class TabUIAction extends AbstractUIAction<AbstractTabUIHandler<?, ?>> {
protected VCSAction action;
protected boolean useSelection;
Deleted: trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/util/AbstractUIAction.java
===================================================================
--- trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/util/AbstractUIAction.java 2008-04-20 10:43:20 UTC (rev 603)
+++ trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/util/AbstractUIAction.java 2008-04-20 10:44:42 UTC (rev 604)
@@ -1,58 +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.vcs.ui.util;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.codelutin.ui.DialogUI;
-import org.codelutin.ui.DialogUIHandler;
-
-/** @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;
- protected transient H handler;
-
- private static final long serialVersionUID = 1L;
-
- protected AbstractUIAction(String name, javax.swing.Icon icon) {
- super(name, icon);
- }
-
- public AbstractUIAction() {
- }
-
- protected H getHandler() {
- checkInit();
- if (handler == null) {
- handler = ui.getHandler();
- }
- return handler;
- }
-
- protected void setUi(DialogUI<? extends H> ui) {
- this.ui = ui;
- this.handler = null;
- }
-
- protected void checkInit() throws IllegalStateException {
- if (handler == null && ui == null) {
- throw new IllegalStateException("no handler, nor ui referenced in " + this);
- }
- }
-
-}
1
0
[Buix-commits] r603 - in trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui: action util
by tchemit@users.labs.libre-entreprise.org 20 Apr '08
by tchemit@users.labs.libre-entreprise.org 20 Apr '08
20 Apr '08
Author: tchemit
Date: 2008-04-20 10:43:20 +0000 (Sun, 20 Apr 2008)
New Revision: 603
Modified:
trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/action/HelpAction.java
trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/util/AbstractUIAction.java
Log:
generalisation de l'AbstractAction
Modified: trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/action/HelpAction.java
===================================================================
--- trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/action/HelpAction.java 2008-04-19 18:42:42 UTC (rev 602)
+++ trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/action/HelpAction.java 2008-04-20 10:43:20 UTC (rev 603)
@@ -15,13 +15,13 @@
package org.codelutin.vcs.ui.action;
import static org.codelutin.i18n.I18n._;
-import org.codelutin.vcs.ui.util.handler.AbstractUIHandler;
-import org.codelutin.vcs.ui.util.ui.AbstractUI;
+import org.codelutin.ui.DialogUI;
+import org.codelutin.ui.DialogUIHandler;
/** @author chemit */
-public class HelpAction extends org.codelutin.vcs.ui.util.AbstractUIAction<AbstractUIHandler<?, ?>> {
+public class HelpAction extends org.codelutin.vcs.ui.util.AbstractUIAction<DialogUIHandler<?, ?>> {
- public static <H extends AbstractUIHandler<?, ?>> javax.swing.AbstractAction createAction(AbstractUI<H> ui) {
+ public static <H extends DialogUIHandler<?, ?>> javax.swing.AbstractAction createAction(DialogUI<H> ui) {
HelpAction action = new HelpAction();
action.setUi(ui);
return action;
Modified: trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/util/AbstractUIAction.java
===================================================================
--- trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/util/AbstractUIAction.java 2008-04-19 18:42:42 UTC (rev 602)
+++ trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/util/AbstractUIAction.java 2008-04-20 10:43:20 UTC (rev 603)
@@ -16,15 +16,15 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.codelutin.vcs.ui.util.handler.AbstractUIHandler;
-import org.codelutin.vcs.ui.util.ui.AbstractUI;
+import org.codelutin.ui.DialogUI;
+import org.codelutin.ui.DialogUIHandler;
/** @author chemit */
-public abstract class AbstractUIAction<H extends AbstractUIHandler<?, ?>> extends javax.swing.AbstractAction {
+public abstract class AbstractUIAction<H extends DialogUIHandler<?, ?>> extends javax.swing.AbstractAction {
protected static Log log = LogFactory.getLog(AbstractUIAction.class);
- protected transient AbstractUI<? extends H> ui;
+ protected transient DialogUI<? extends H> ui;
protected transient H handler;
private static final long serialVersionUID = 1L;
@@ -44,7 +44,7 @@
return handler;
}
- protected void setUi(AbstractUI<? extends H> ui) {
+ protected void setUi(DialogUI<? extends H> ui) {
this.ui = ui;
this.handler = null;
}
1
0
[Buix-commits] r602 - in trunk/lutinvcs: core/src/main/resources tools/src/main/resources
by tchemit@users.labs.libre-entreprise.org 19 Apr '08
by tchemit@users.labs.libre-entreprise.org 19 Apr '08
19 Apr '08
Author: tchemit
Date: 2008-04-19 18:42:42 +0000 (Sat, 19 Apr 2008)
New Revision: 602
Removed:
trunk/lutinvcs/core/src/main/resources/META-INF/
trunk/lutinvcs/tools/src/main/resources/META-INF/
Log:
suppression META-INF servcies de log (deja positionne dans lutinutil)
1
0
[Buix-commits] r601 - in trunk/lutinvcs: provider/cvs/src/main/resources/META-INF/services provider/mock/src/main/resources/META-INF/services provider/svn/src/main/resources/META-INF/services ui/common/src/main/resources/META-INF/services
by tchemit@users.labs.libre-entreprise.org 19 Apr '08
by tchemit@users.labs.libre-entreprise.org 19 Apr '08
19 Apr '08
Author: tchemit
Date: 2008-04-19 18:41:50 +0000 (Sat, 19 Apr 2008)
New Revision: 601
Removed:
trunk/lutinvcs/provider/cvs/src/main/resources/META-INF/services/org.apache.commons.logging.LogFactory
trunk/lutinvcs/provider/mock/src/main/resources/META-INF/services/org.apache.commons.logging.LogFactory
trunk/lutinvcs/provider/svn/src/main/resources/META-INF/services/org.apache.commons.logging.LogFactory
trunk/lutinvcs/ui/common/src/main/resources/META-INF/services/org.apache.commons.logging.LogFactory
Log:
suppression META-INF servcies de log (deja positionne dans lutinutil)
Deleted: trunk/lutinvcs/provider/cvs/src/main/resources/META-INF/services/org.apache.commons.logging.LogFactory
===================================================================
--- trunk/lutinvcs/provider/cvs/src/main/resources/META-INF/services/org.apache.commons.logging.LogFactory 2008-04-19 18:41:31 UTC (rev 600)
+++ trunk/lutinvcs/provider/cvs/src/main/resources/META-INF/services/org.apache.commons.logging.LogFactory 2008-04-19 18:41:50 UTC (rev 601)
@@ -1 +0,0 @@
-org.codelutin.util.LutinLogFactory
\ No newline at end of file
Deleted: trunk/lutinvcs/provider/mock/src/main/resources/META-INF/services/org.apache.commons.logging.LogFactory
===================================================================
--- trunk/lutinvcs/provider/mock/src/main/resources/META-INF/services/org.apache.commons.logging.LogFactory 2008-04-19 18:41:31 UTC (rev 600)
+++ trunk/lutinvcs/provider/mock/src/main/resources/META-INF/services/org.apache.commons.logging.LogFactory 2008-04-19 18:41:50 UTC (rev 601)
@@ -1 +0,0 @@
-org.codelutin.util.LutinLogFactory
\ No newline at end of file
Deleted: trunk/lutinvcs/provider/svn/src/main/resources/META-INF/services/org.apache.commons.logging.LogFactory
===================================================================
--- trunk/lutinvcs/provider/svn/src/main/resources/META-INF/services/org.apache.commons.logging.LogFactory 2008-04-19 18:41:31 UTC (rev 600)
+++ trunk/lutinvcs/provider/svn/src/main/resources/META-INF/services/org.apache.commons.logging.LogFactory 2008-04-19 18:41:50 UTC (rev 601)
@@ -1 +0,0 @@
-org.codelutin.util.LutinLogFactory
\ No newline at end of file
Deleted: trunk/lutinvcs/ui/common/src/main/resources/META-INF/services/org.apache.commons.logging.LogFactory
===================================================================
--- trunk/lutinvcs/ui/common/src/main/resources/META-INF/services/org.apache.commons.logging.LogFactory 2008-04-19 18:41:31 UTC (rev 600)
+++ trunk/lutinvcs/ui/common/src/main/resources/META-INF/services/org.apache.commons.logging.LogFactory 2008-04-19 18:41:50 UTC (rev 601)
@@ -1 +0,0 @@
-org.codelutin.util.LutinLogFactory
\ No newline at end of file
1
0
19 Apr '08
Author: tchemit
Date: 2008-04-19 18:41:31 +0000 (Sat, 19 Apr 2008)
New Revision: 600
Added:
trunk/lutinvcs/ui/jaxx/src/main/resources/META-INF/services/org.codelutin.ui.UIProvider
Removed:
trunk/lutinvcs/ui/jaxx/src/main/resources/META-INF/services/org.codelutin.vcs.ui.VCSUIProvider
Modified:
trunk/lutinvcs/core/src/main/java/org/codelutin/vcs/VCSFactory.java
trunk/lutinvcs/core/src/main/java/org/codelutin/vcs/runner/VCSActionThread.java
trunk/lutinvcs/tools/src/test/java/org/codelutin/vcs/ConfigUITest.java
trunk/lutinvcs/tools/src/test/java/org/codelutin/vcs/UITest.java
trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/ConfigUI.java
trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/VCSUIFactory.java
trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/action/ChangeFileAction.java
trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/action/ChangeLocationAction.java
trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/action/ConfirmAction.java
trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/action/DiffAction.java
trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/action/HelpAction.java
trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/action/ShowConfigAction.java
trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/action/ShowMessagesAction.java
trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/action/TabUIAction.java
trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/handler/SynchUIHandler.java
trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/util/UIHelper.java
trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/util/handler/AbstractTabUIHandler.java
trunk/lutinvcs/ui/jaxx/src/main/uimodel/org/codelutin/vcs/ui/JaxxConfigUI.jaxx
trunk/lutinvcs/ui/jaxx/src/main/uimodel/org/codelutin/vcs/ui/JaxxVCSUIProvider.java
Log:
utilisation lutinui
Modified: trunk/lutinvcs/core/src/main/java/org/codelutin/vcs/VCSFactory.java
===================================================================
--- trunk/lutinvcs/core/src/main/java/org/codelutin/vcs/VCSFactory.java 2008-04-19 18:40:26 UTC (rev 599)
+++ trunk/lutinvcs/core/src/main/java/org/codelutin/vcs/VCSFactory.java 2008-04-19 18:41:31 UTC (rev 600)
@@ -25,7 +25,6 @@
import org.codelutin.vcs.event.VCSConnexionEvent;
import org.codelutin.vcs.event.VCSConnexionEventListener;
import org.codelutin.vcs.runner.VCSActionManager;
-import org.codelutin.vcs.type.VCSConnexionMode;
import java.util.ArrayList;
import java.util.List;
@@ -49,13 +48,13 @@
static protected VCSFactory instance;
/** providers availables */
- protected List<VCSProvider> providers;
+ protected final List<VCSProvider> providers;
/** connexions opened */
- protected List<VCSConnexion> connexions;
+ protected final List<VCSConnexion> connexions;
/** action manager */
- protected VCSActionManager actionManager;
+ protected final VCSActionManager actionManager;
public static VCSFactory getInstance() {
if (instance == null) {
@@ -73,11 +72,10 @@
* <p/>
* the method will produce a runtime exception if config is null and not init.
*
- * @param mode mode of connexion required
* @param config config to use @return the new connexion instance
* @return instanicate and init connexion (but not opened).
*/
- public static VCSConnexion newConnexion(VCSConnexionMode mode, VCSConnexionConfig config) {
+ public static VCSConnexion newConnexion(VCSConnexionConfig config) {
VCSFactory factory = getInstance();
@@ -85,7 +83,7 @@
VCSProvider<?, ?> provider = factory.getProvider(config.getType().toUpperCase());
// delegate instanciation of connexion to provider
- VCSConnexion connexion = provider.newConnection(mode, config);
+ VCSConnexion connexion = provider.newConnection(config.getMode(), config);
// init connexion
connexion.init(config);
@@ -134,18 +132,23 @@
protected VCSFactory() {
long t0 = System.nanoTime();
- providers = new ArrayList<VCSProvider>();
+ providers = detectProviders(t0);
+ actionManager = new VCSActionManager();
+ connexions = new ArrayList<VCSConnexion>();
+ }
+
+ protected List<VCSProvider> detectProviders(long t0) {
+ List<VCSProvider> providers = new ArrayList<VCSProvider>();
for (VCSProvider provider : ServiceLoader.load(VCSProvider.class)) {
providers.add(provider);
}
- log.info("found " + providers.size() + " provider(s) " + providers.toString() + " in " + StringUtil.convertTime(t0, System.nanoTime()));
+ log.info("found " + providers.size() + " vcs provider(s) in " + StringUtil.convertTime(t0, System.nanoTime()) + " : " + providers.toString());
if (log.isDebugEnabled()) {
for (VCSProvider provider : providers) {
log.debug(provider.getName() + " [" + provider + ']');
}
}
- actionManager = new VCSActionManager();
- connexions = new ArrayList<VCSConnexion>();
+ return providers;
}
}
\ No newline at end of file
Modified: trunk/lutinvcs/core/src/main/java/org/codelutin/vcs/runner/VCSActionThread.java
===================================================================
--- trunk/lutinvcs/core/src/main/java/org/codelutin/vcs/runner/VCSActionThread.java 2008-04-19 18:40:26 UTC (rev 599)
+++ trunk/lutinvcs/core/src/main/java/org/codelutin/vcs/runner/VCSActionThread.java 2008-04-19 18:41:31 UTC (rev 600)
@@ -62,7 +62,9 @@
VCSActionQueueItem item = null;
try {
while (run) {
- log.info("waiting for action...");
+ if (log.isDebugEnabled()) {
+ log.debug("waiting for action...");
+ }
item = queue.take();
// acquire a first item, thread becomes busy TODO should synchronize thread
fireStateBusy(false, true);
@@ -181,7 +183,9 @@
}
protected void fireStateBusy(Boolean oldState, Boolean newState) {
- log.info("old state : " + oldState + ", new state : " + newState);
+ if (log.isDebugEnabled()) {
+ log.debug("old state : " + oldState + ", new state : " + newState);
+ }
}
protected void updateState(VCSState state, VCSEntry[] entries) {
@@ -212,13 +216,17 @@
/** @param l the listener to add */
public void addVCSActionThreadEventListener(VCSActionThreadEventListener l) {
listeners.add(l);
- log.info("added listener on thread : " + listeners.size() + " : " + l);
+ if (log.isDebugEnabled()) {
+ log.debug("after added (" + listeners.size() + ") : " + l);
+ }
}
/** @param l the listener to remove */
public void removeVCSActionThreadEventListener(VCSActionThreadEventListener l) {
listeners.remove(l);
- log.info("removed listener on thread : " + listeners.size() + " : " + l);
+ if (log.isDebugEnabled()) {
+ log.debug("aftert removed (" + listeners.size() + ") : " + l);
+ }
}
}
Modified: trunk/lutinvcs/tools/src/test/java/org/codelutin/vcs/ConfigUITest.java
===================================================================
--- trunk/lutinvcs/tools/src/test/java/org/codelutin/vcs/ConfigUITest.java 2008-04-19 18:40:26 UTC (rev 599)
+++ trunk/lutinvcs/tools/src/test/java/org/codelutin/vcs/ConfigUITest.java 2008-04-19 18:41:31 UTC (rev 600)
@@ -16,32 +16,22 @@
import org.codelutin.vcs.ui.ConfigUI;
import org.codelutin.vcs.ui.VCSUIFactory;
-import org.codelutin.vcs.ui.model.ConfigUIModel;
-import java.io.File;
-import java.io.IOException;
-
/** @author chemit */
public class ConfigUITest {
- public static void main(String[] args) throws IOException, VCSException {
+ public static void main(String[] args) throws Exception {
RepositoryGenerator generator = new RepositoryGenerator();
- File root = generator.generateWorkingRepositoryPath();
+ VCSConnexion connexion = UITest.initMockVCS(generator, 0, 0, 0, 0);
- VCSConnexion connexion = UITest.initMockVCS(root);
+ ConfigUI ui = UITest.initUI(generator, connexion, VCSUIFactory.CONFIG_UI);
- UITest.initUI(generator, connexion);
-
connexion.open();
- ConfigUI ui = VCSUIFactory.newConfigUI();
+ ui.getHandler().getModel().populate(connexion.getConfig(), true, "tony", "chemit", "chemit(a)codelutin.com");
- ConfigUIModel model = ui.getHandler().getModel();
-
- model.populate(connexion.getConfig(), true, "tony", "chemit", "chemit(a)codelutin.com");
-
ui.setVisible(true);
}
}
\ No newline at end of file
Modified: trunk/lutinvcs/tools/src/test/java/org/codelutin/vcs/UITest.java
===================================================================
--- trunk/lutinvcs/tools/src/test/java/org/codelutin/vcs/UITest.java 2008-04-19 18:40:26 UTC (rev 599)
+++ trunk/lutinvcs/tools/src/test/java/org/codelutin/vcs/UITest.java 2008-04-19 18:41:31 UTC (rev 600)
@@ -14,67 +14,71 @@
*/
package org.codelutin.vcs;
-import org.codelutin.vcs.type.VCSConnexionMode;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.codelutin.ui.DialogUI;
+import org.codelutin.ui.DialogUIDef;
+import org.codelutin.ui.DialogUIHandler;
+import org.codelutin.ui.DialogUIModel;
import org.codelutin.vcs.ui.SynchUI;
import org.codelutin.vcs.ui.VCSUIFactory;
-import org.codelutin.vcs.ui.VCSUIFactory.VCSWindowListener;
-import org.codelutin.vcs.ui.util.model.AbstractTabUIModel;
-import org.codelutin.vcs.util.VCSConnexionConfigImpl;
+import java.awt.event.WindowEvent;
import java.io.File;
import java.io.IOException;
/** @author chemit */
public class UITest {
- public static void main(String[] args) throws IOException, VCSException {
+ static protected final Log log = LogFactory.getLog(UITest.class);
- RepositoryGenerator generator = new RepositoryGenerator();
+ public static void main(String[] args) throws Exception {
- File root = generator.generateWorkingRepositoryPath();
- generator.generateWorkingRepository(root, 10, 5, 10, 1024);
+ RepositoryGenerator generator = new RepositoryGenerator();
- VCSConnexion connexion = initMockVCS(root);
+ VCSConnexion connexion = initMockVCS(generator, 10, 5, 10, 1024);
- initUI(generator, connexion);
-
connexion.open();
- SynchUI ui = VCSUIFactory.newSynchUI();
+ SynchUI ui = initUI(generator, connexion, VCSUIFactory.SYNCH_UI);
- AbstractTabUIModel model = ui.getHandler().getModel();
+ ui.getHandler().getModel().populate(connexion);
- model.populate(connexion);
+ generator.generateStates(ui.getHandler().getModel().getEntriesModel());
- generator.generateStates(model.getEntriesModel());
-
ui.setVisible(true);
}
- public static VCSConnexion initMockVCS(final File root) {
- VCSConnexionConfig config = new VCSConnexionConfigImpl();
+ public static VCSConnexion initMockVCS(final RepositoryGenerator generator, int i, int i1, int i2, int i3) throws IOException {
+ final File root = generator.generateWorkingRepositoryPath();
+ if (i != 0) {
+ generator.generateWorkingRepository(root, i, i1, i2, i3);
+ }
+ VCSConnexionConfig config = new org.codelutin.vcs.util.VCSConnexionConfigImpl();
config.setKeyFile(new File("/home/tony/.ssh/id_dsa"));
config.setUserName("tchemit");
//config.setPassPhrase("pass");
config.setNoPassPhrase(true);
config.setType("MOCK");
config.setLocalDatabasePath(root);
- config.setConnexionMode(VCSConnexionMode.SSH);
- VCSConnexion connexion = VCSFactory.newConnexion(VCSConnexionMode.ANONYMOUS, config);
- connexion.init(config);
- return connexion;
+ config.setConnexionMode(org.codelutin.vcs.type.VCSConnexionMode.SSH);
+ return VCSFactory.newConnexion(config);
}
- protected static void initUI(final RepositoryGenerator generator, final VCSConnexion connexion) {
- VCSUIFactory.initFactory(connexion.getConfig(), new VCSWindowListener() {
+ protected static <M extends DialogUIModel, U extends DialogUI<H>, H extends DialogUIHandler<M, U>> U initUI(
+ final RepositoryGenerator generator, final VCSConnexion connexion, DialogUIDef<M, U, H> configUi) {
- protected void allWindowsClosed() {
+ VCSUIFactory.initFactory(connexion.getConfig(), new org.codelutin.ui.FactoryWindowListener() {
+ public void allWindowsClosed(WindowEvent e) {
+ if (log.isDebugEnabled()) {
+ log.debug(generator + " : " + e);
+ }
generator.deleteWorkingCopy(connexion.getWorkingCopy());
}
+ });
- protected void closeConnexion(VCSConnexion connexion) {
- }
- });
+
+ return VCSUIFactory.getUI(configUi);
}
}
\ No newline at end of file
Modified: trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/ConfigUI.java
===================================================================
--- trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/ConfigUI.java 2008-04-19 18:40:26 UTC (rev 599)
+++ trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/ConfigUI.java 2008-04-19 18:41:31 UTC (rev 600)
@@ -120,6 +120,7 @@
public abstract javax.swing.JPanel getSshPanel();
public abstract javax.swing.JScrollPane getIdentityScroll();
+
public boolean isConfigValid() {
return getHandler().isConfigValid();
}
Modified: trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/VCSUIFactory.java
===================================================================
--- trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/VCSUIFactory.java 2008-04-19 18:40:26 UTC (rev 599)
+++ trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/VCSUIFactory.java 2008-04-19 18:41:31 UTC (rev 600)
@@ -14,207 +14,90 @@
*/
package org.codelutin.vcs.ui;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.codelutin.util.StringUtil;
+import org.codelutin.ui.DialogUI;
+import org.codelutin.ui.DialogUIDef;
+import org.codelutin.ui.DialogUIHandler;
+import org.codelutin.ui.DialogUIModel;
+import org.codelutin.ui.FactoryWindowListener;
+import org.codelutin.ui.UIFactory;
import org.codelutin.vcs.VCSConnexion;
import org.codelutin.vcs.VCSConnexionConfig;
import org.codelutin.vcs.VCSFactory;
-import org.codelutin.vcs.ui.util.ui.AbstractUI;
+import org.codelutin.vcs.ui.handler.ChangelogUIHandler;
+import org.codelutin.vcs.ui.handler.ConfigUIHandler;
+import org.codelutin.vcs.ui.handler.ConfirmUIHandler;
+import org.codelutin.vcs.ui.handler.DiffUIHandler;
+import org.codelutin.vcs.ui.handler.GenerateSshKeyUIHandler;
+import org.codelutin.vcs.ui.handler.SynchUIHandler;
+import org.codelutin.vcs.ui.model.ChangelogUIModel;
+import org.codelutin.vcs.ui.model.ConfigUIModel;
+import org.codelutin.vcs.ui.model.ConfirmUIModel;
+import org.codelutin.vcs.ui.model.DiffUIModel;
+import org.codelutin.vcs.ui.model.GenerateSshKeyUIModel;
+import org.codelutin.vcs.ui.model.SynchUIModel;
-import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
-import java.awt.event.WindowListener;
-import java.lang.reflect.InvocationTargetException;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.ServiceLoader;
/**
* Factory if VCS UI, using a cache.
+ * <p/>
+ * To obtain a ui, use the method {@link #getUI(org.codelutin.ui.DialogUIDef)}.
+ * <p/>
+ * Before all, you must init the factory via {@link #initFactory(VCSConnexionConfig, FactoryWindowListener)} method.
*
* @author chemit
*/
-public class VCSUIFactory {
+public class VCSUIFactory extends UIFactory {
- static protected final Log log = LogFactory.getLog(VCSFactory.class);
+ public static final DialogUIDef<SynchUIModel, SynchUI, SynchUIHandler> SYNCH_UI = new DialogUIDef<SynchUIModel, SynchUI, SynchUIHandler>(SynchUIHandler.class, SynchUI.class, SynchUIModel.class);
+ public static final DialogUIDef<DiffUIModel, DiffUI, DiffUIHandler> DIFF_UI = new DialogUIDef<DiffUIModel, DiffUI, DiffUIHandler>(DiffUIHandler.class, DiffUI.class, DiffUIModel.class);
+ public static final DialogUIDef<ChangelogUIModel, ChangelogUI, ChangelogUIHandler> CHANGELOG_UI = new DialogUIDef<ChangelogUIModel, ChangelogUI, ChangelogUIHandler>(ChangelogUIHandler.class, ChangelogUI.class, ChangelogUIModel.class);
+ public static final DialogUIDef<ConfirmUIModel, ConfirmUI, ConfirmUIHandler> CONFIRM_UI = new DialogUIDef<ConfirmUIModel, ConfirmUI, ConfirmUIHandler>(ConfirmUIHandler.class, ConfirmUI.class, ConfirmUIModel.class);
+ public static final DialogUIDef<ConfigUIModel, ConfigUI, ConfigUIHandler> CONFIG_UI = new DialogUIDef<ConfigUIModel, ConfigUI, ConfigUIHandler>(ConfigUIHandler.class, ConfigUI.class, ConfigUIModel.class);
+ public static final DialogUIDef<GenerateSshKeyUIModel, GenerateSshKeyUI, GenerateSshKeyUIHandler> GENERATE_SHH_KEY_UI = new DialogUIDef<GenerateSshKeyUIModel, GenerateSshKeyUI, GenerateSshKeyUIHandler>(GenerateSshKeyUIHandler.class, GenerateSshKeyUI.class, GenerateSshKeyUIModel.class);
protected static VCSUIFactory instance;
-
- protected Map<VCSUI, AbstractUI> cache;
-
- protected ServiceLoader<VCSUIProvider> loader;
-
protected VCSConnexionConfig config;
+ protected static FactoryWindowListener closeConnextionsListener;
- protected WindowListener defaultWindowListener;
-
- protected WindowListener windowListener;
-
- public static void initFactory(VCSConnexionConfig config, VCSWindowListener myWindowAdapter) {
- getInstance().setConfig(config);
- getInstance().setWindowListener(myWindowAdapter);
+ public static void initFactory(VCSConnexionConfig config, FactoryWindowListener myWindowAdapter) {
+ if (instance != null) {
+ throw new IllegalStateException("factory " + instance + " was already init");
+ }
+ instance = new VCSUIFactory("vcs", config, getCloseConnextionsListener(), myWindowAdapter);
}
- public static SynchUI newSynchUI() {
- return (SynchUI) getInstance().newUI(VCSUI.synch);
+ public static <M extends DialogUIModel, U extends DialogUI<H>, H extends DialogUIHandler<M, U>> U getUI(DialogUIDef<M, U, H> uiType) {
+ return getInstance().getUI(uiType, getInstance().config);
}
- public static DiffUI newDiffUI() {
- return (DiffUI) getInstance().newUI(VCSUI.diff);
+ protected VCSUIFactory(String applicationName, VCSConnexionConfig config, FactoryWindowListener... listeners) {
+ super(applicationName, new DialogUIDef[]{SYNCH_UI, DIFF_UI, CHANGELOG_UI, CONFIRM_UI, CONFIG_UI, GENERATE_SHH_KEY_UI}, listeners);
+ this.config = config;
}
- public static ChangelogUI newChangelogUI() {
- return (ChangelogUI) getInstance().newUI(VCSUI.changelog);
- }
-
- public static ConfirmUI newConfirmUI() {
- return (ConfirmUI) getInstance().newUI(VCSUI.confirm);
- }
-
- public static ConfigUI newConfigUI() {
- return (ConfigUI) getInstance().newUI(VCSUI.config);
- }
-
- public static GenerateSshKeyUI newGenerateSshKeyUI() {
- return (GenerateSshKeyUI) getInstance().newUI(VCSUI.generateSshKey);
- }
-
- public void close() {
- if (cache != null) {
- cache.clear();
- cache = null;
- }
- if (loader != null) {
- loader.reload();
- loader = null;
- }
- }
-
- protected static VCSUIFactory getInstance() {
+ protected static VCSUIFactory getInstance() throws IllegalStateException {
if (instance == null) {
- instance = new VCSUIFactory();
- }
+ throw new IllegalStateException("factory " + VCSUIFactory.class + " was not init");
+ }
return instance;
}
- @Override
- protected void finalize() throws Throwable {
- super.finalize();
- close();
- }
-
- protected synchronized Map<VCSUI, AbstractUI> getCache() {
- if (cache == null) {
- cache = new HashMap<VCSUI, AbstractUI>();
- }
- return cache;
- }
-
- protected synchronized ServiceLoader<VCSUIProvider> getProviders() {
- if (loader == null) {
- long t0 = System.nanoTime();
-
- loader = ServiceLoader.load(VCSUIProvider.class);
- int nb = 0;
- for (VCSUIProvider provider : loader) {
- log.info(provider.getName() + " [" + provider + ']');
- nb++;
- }
- log.info("found " + nb + " ui provider(s) in " + StringUtil.convertTime(t0, System.nanoTime()));
- }
- return loader;
- }
-
- protected AbstractUI newUI(VCSUI uiType) {
-
- AbstractUI result = getInstance().getCache().get(uiType);
- if (result == null) {
- try {
- getCache().put(uiType, result = newUI0(uiType));
- result.addWindowListener(defaultWindowListener);
- if (windowListener != null) {
- result.addWindowListener(windowListener);
- }
- } catch (Exception e) {
- throw new IllegalStateException("could not instanciate ui handler " + uiType + " for reason : " + e.getMessage());
- }
- }
- return result;
- }
-
- protected AbstractUI newUI0(VCSUI uiType) throws IllegalAccessException, InstantiationException, NoSuchMethodException, InvocationTargetException {
- for (VCSUIProvider provider : getProviders()) {
- AbstractUI ui = provider.newUI(uiType);
- if (ui != null) {
-
- uiType.getHandlerClass().getConstructor(ui.getClass().getSuperclass(), VCSConnexionConfig.class).newInstance(ui, config);
- ui.getHandler().init();
- return ui;
- }
- }
- throw new IllegalStateException("could not find ui " + uiType);
- }
-
- protected VCSUIFactory() {
- defaultWindowListener = new VCSWindowListener() {
- protected void allWindowsClosed() {
- }
-
- protected void closeConnexion(VCSConnexion connexion) {
- log.info(connexion);
- connexion.close();
- }
- };
- }
-
- protected void setConfig(VCSConnexionConfig config) {
- this.config = config;
- }
-
- protected void setWindowListener(WindowListener windowListener) {
- this.windowListener = windowListener;
- }
-
- public static abstract class VCSWindowListener extends WindowAdapter {
-
- protected abstract void allWindowsClosed();
-
- protected abstract void closeConnexion(VCSConnexion connexion);
-
- private boolean wasClosed;
-
- @Override
- public void windowClosed(WindowEvent e) {
- if (log.isDebugEnabled()) {
- log.debug(e.getSource());
- }
- if (e.getWindow().isVisible()) {
- // only deal with real closed and none visible windows...
- return;
- }
- for (AbstractUI vcsui : VCSUIFactory.getInstance().cache.values()) {
- if (vcsui.isVisible()) {
- // at least one ui visible, do not kill connexions
- return;
- }
- }
- if (wasClosed) {
- // make sure to process once
- return;
- }
- log.info("kill connexions... (last ui : " + e.getSource() + ")");
- synchronized (this) {
- try {
+ protected static FactoryWindowListener getCloseConnextionsListener() {
+ if (closeConnextionsListener == null) {
+ closeConnextionsListener = new FactoryWindowListener() {
+ public void allWindowsClosed(WindowEvent e) {
+ if (log.isDebugEnabled()) {
+ log.debug(this + " for " + e);
+ }
// all ui are down, kill all connexions
for (VCSConnexion connexion : VCSFactory.getInstance().getConnexions()) {
- closeConnexion(connexion);
+ log.info("close connexion " + connexion);
+ connexion.close();
}
- allWindowsClosed();
- } finally {
- wasClosed = true;
}
- }
+ };
}
+ return closeConnextionsListener;
}
}
\ No newline at end of file
Modified: trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/action/ChangeFileAction.java
===================================================================
--- trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/action/ChangeFileAction.java 2008-04-19 18:40:26 UTC (rev 599)
+++ trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/action/ChangeFileAction.java 2008-04-19 18:41:31 UTC (rev 600)
@@ -16,11 +16,7 @@
import org.codelutin.vcs.ui.util.ui.AbstractTabOneFileUI;
import org.codelutin.vcs.ui.util.handler.AbstractTabOneFileUIHandler;
-import static org.codelutin.vcs.ui.util.UIHelper.createActionIcon;
-import javax.swing.AbstractAction;
-import java.awt.event.ActionEvent;
-
/** @author chemit */
public class ChangeFileAction extends org.codelutin.vcs.ui.util.AbstractUIAction<AbstractTabOneFileUIHandler<?, ?>> {
@@ -28,13 +24,13 @@
private static final long serialVersionUID = 1L;
- public static AbstractAction createAction(boolean location, AbstractTabOneFileUI<?> ui) {
+ public static javax.swing.AbstractAction createAction(boolean location, AbstractTabOneFileUI<?> ui) {
ChangeFileAction action = new ChangeFileAction(location);
action.setUi(ui);
return action;
}
- public void actionPerformed(ActionEvent e) {
+ public void actionPerformed(java.awt.event.ActionEvent e) {
checkInit();
if (goPrevious) {
getHandler().gotoPreviousFile();
@@ -48,7 +44,7 @@
}
protected ChangeFileAction(boolean location) {
- super(null, createActionIcon("file-" + (location ? "prev" : "next")));
+ super(null, org.codelutin.ui.UIHelper.createActionIcon("file-" + (location ? "prev" : "next")));
this.goPrevious = location;
//putValue(SHORT_DESCRIPTION, location.getTip());
//putValue(DISPLAYED_MNEMONIC_INDEX_KEY, 0);
Modified: trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/action/ChangeLocationAction.java
===================================================================
--- trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/action/ChangeLocationAction.java 2008-04-19 18:40:26 UTC (rev 599)
+++ trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/action/ChangeLocationAction.java 2008-04-19 18:41:31 UTC (rev 600)
@@ -17,11 +17,7 @@
import org.codelutin.vcs.type.VCSEntryLocation;
import org.codelutin.vcs.ui.util.ui.AbstractTabUI;
import org.codelutin.vcs.ui.util.handler.AbstractTabUIHandler;
-import org.codelutin.vcs.ui.util.UIHelper;
-import javax.swing.AbstractAction;
-import java.awt.event.ActionEvent;
-
/** @author chemit */
public class ChangeLocationAction extends org.codelutin.vcs.ui.util.AbstractUIAction<AbstractTabUIHandler<?, ?>> {
@@ -29,13 +25,13 @@
private static final long serialVersionUID = 1L;
- public static AbstractAction createAction(VCSEntryLocation location, AbstractTabUI<?> ui) {
+ public static javax.swing.AbstractAction createAction(VCSEntryLocation location, AbstractTabUI<?> ui) {
ChangeLocationAction action = new ChangeLocationAction(location);
action.setUi(ui);
return action;
}
- public void actionPerformed(ActionEvent e) {
+ public void actionPerformed(java.awt.event.ActionEvent e) {
checkInit();
if (location == null) {
return;
@@ -52,7 +48,7 @@
}
protected ChangeLocationAction(VCSEntryLocation location) {
- super(location.getLibelle(), UIHelper.createLocationIcon(location));
+ super(location.getLibelle(), org.codelutin.vcs.ui.util.UIHelper.createLocationIcon(location));
this.location = location;
putValue(SHORT_DESCRIPTION, location.getTip());
putValue(DISPLAYED_MNEMONIC_INDEX_KEY, 0);
Modified: trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/action/ConfirmAction.java
===================================================================
--- trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/action/ConfirmAction.java 2008-04-19 18:40:26 UTC (rev 599)
+++ trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/action/ConfirmAction.java 2008-04-19 18:41:31 UTC (rev 600)
@@ -15,13 +15,8 @@
package org.codelutin.vcs.ui.action;
import org.codelutin.vcs.type.VCSAction;
-import org.codelutin.vcs.ui.ConfirmUI;
import org.codelutin.vcs.ui.handler.ConfirmUIHandler;
-import org.codelutin.vcs.ui.util.UIHelper;
-import javax.swing.AbstractAction;
-import java.awt.event.ActionEvent;
-
/** @author chemit */
public class ConfirmAction extends org.codelutin.vcs.ui.util.AbstractUIAction<ConfirmUIHandler> {
@@ -29,13 +24,13 @@
private static final long serialVersionUID = 1L;
- public static AbstractAction createAction(VCSAction action, ConfirmUI ui) {
+ public static javax.swing.AbstractAction createAction(VCSAction action, org.codelutin.vcs.ui.ConfirmUI ui) {
ConfirmAction action1 = new ConfirmAction(action);
action1.setUi(ui);
return action1;
}
- public void actionPerformed(ActionEvent e) {
+ public void actionPerformed(java.awt.event.ActionEvent e) {
checkInit();
if (action == null) {
return;
@@ -52,8 +47,8 @@
case DELETE:
case REVERT:
case UPDATE:
- ConfirmUIHandler handler = getHandler();
- handler.doAction(getHandler().getUi().getCommitMessage().getText(), handler.getModel().getEntriesModel());
+ ConfirmUIHandler uiHandler = getHandler();
+ uiHandler.doAction(uiHandler.getUi().getCommitMessage().getText(), uiHandler.getModel().getEntriesModel());
return;
}
throw new IllegalStateException("could not perform action for action " + action + " (" + this + ')');
@@ -68,11 +63,10 @@
}
protected ConfirmAction(VCSAction action) {
- super(null, UIHelper.createActionIcon(action));
+ super(null, org.codelutin.vcs.ui.util.UIHelper.createActionIcon(action));
this.action = action;
//putValue(SHORT_DESCRIPTION, action.getTip());
putValue(DISPLAYED_MNEMONIC_INDEX_KEY, 0);
putValue(MNEMONIC_KEY, (int) (action.getLibelle()).charAt(0));
}
-
}
\ No newline at end of file
Modified: trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/action/DiffAction.java
===================================================================
--- trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/action/DiffAction.java 2008-04-19 18:40:26 UTC (rev 599)
+++ trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/action/DiffAction.java 2008-04-19 18:41:31 UTC (rev 600)
@@ -14,27 +14,20 @@
*/
package org.codelutin.vcs.ui.action;
-import org.codelutin.vcs.ui.DiffUI;
-import org.codelutin.vcs.ui.handler.DiffUIHandler;
-import static org.codelutin.vcs.ui.util.UIHelper.createActionIcon;
-
-import javax.swing.AbstractAction;
-import java.awt.event.ActionEvent;
-
/** @author chemit */
-public class DiffAction extends org.codelutin.vcs.ui.util.AbstractUIAction<DiffUIHandler> {
+public class DiffAction extends org.codelutin.vcs.ui.util.AbstractUIAction<org.codelutin.vcs.ui.handler.DiffUIHandler> {
protected boolean goUp;
private static final long serialVersionUID = 1L;
- public static AbstractAction createAction(boolean goUp, DiffUI ui) {
+ public static javax.swing.AbstractAction createAction(boolean goUp, org.codelutin.vcs.ui.DiffUI ui) {
DiffAction action1 = new DiffAction(goUp);
action1.setUi(ui);
return action1;
}
- public void actionPerformed(ActionEvent e) {
+ public void actionPerformed(java.awt.event.ActionEvent e) {
checkInit();
if (goUp) {
getHandler().gotoPreviousDiff();
@@ -52,7 +45,7 @@
}
protected DiffAction(boolean goUp) {
- super(null, createActionIcon("diff-" + (goUp ? "prev" : "next")));
+ super(null, org.codelutin.ui.UIHelper.createActionIcon("diff-" + (goUp ? "prev" : "next")));
this.goUp = goUp;
//putValue(SHORT_DESCRIPTION, action.getTip());
//putValue(DISPLAYED_MNEMONIC_INDEX_KEY, 0);
Modified: trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/action/HelpAction.java
===================================================================
--- trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/action/HelpAction.java 2008-04-19 18:40:26 UTC (rev 599)
+++ trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/action/HelpAction.java 2008-04-19 18:41:31 UTC (rev 600)
@@ -15,17 +15,13 @@
package org.codelutin.vcs.ui.action;
import static org.codelutin.i18n.I18n._;
-import org.codelutin.vcs.ui.util.ui.AbstractUI;
import org.codelutin.vcs.ui.util.handler.AbstractUIHandler;
-import static org.codelutin.vcs.ui.util.UIHelper.createActionIcon;
+import org.codelutin.vcs.ui.util.ui.AbstractUI;
-import javax.swing.AbstractAction;
-import java.awt.event.ActionEvent;
-
/** @author chemit */
public class HelpAction extends org.codelutin.vcs.ui.util.AbstractUIAction<AbstractUIHandler<?, ?>> {
- public static <H extends AbstractUIHandler<?, ?>> AbstractAction createAction(AbstractUI<H> ui) {
+ public static <H extends AbstractUIHandler<?, ?>> javax.swing.AbstractAction createAction(AbstractUI<H> ui) {
HelpAction action = new HelpAction();
action.setUi(ui);
return action;
@@ -33,13 +29,13 @@
private static final long serialVersionUID = 1L;
- public void actionPerformed(ActionEvent e) {
+ public void actionPerformed(java.awt.event.ActionEvent e) {
checkInit();
log.info("//TODO : " + this + ", " + ui);
}
protected HelpAction() {
- super(_("lutinvcs.action.help.libelle"), createActionIcon("help"));
+ super(_("lutinvcs.action.help.libelle"), org.codelutin.ui.UIHelper.createActionIcon("help"));
String name = (String) getValue(NAME);
putValue(DISPLAYED_MNEMONIC_INDEX_KEY, name.length() - 1);
putValue(ACCELERATOR_KEY, (int) name.charAt(name.length() - 1));
Modified: trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/action/ShowConfigAction.java
===================================================================
--- trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/action/ShowConfigAction.java 2008-04-19 18:40:26 UTC (rev 599)
+++ trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/action/ShowConfigAction.java 2008-04-19 18:41:31 UTC (rev 600)
@@ -15,9 +15,7 @@
package org.codelutin.vcs.ui.action;
import static org.codelutin.i18n.I18n._;
-import org.codelutin.vcs.ui.ConfigUI;
-import org.codelutin.vcs.ui.VCSUIFactory;
-import static org.codelutin.vcs.ui.util.UIHelper.createActionIcon;
+import static org.codelutin.vcs.ui.VCSUIFactory.CONFIG_UI;
import org.codelutin.vcs.ui.util.handler.AbstractUIHandler;
import org.codelutin.vcs.ui.util.ui.AbstractUI;
@@ -37,14 +35,14 @@
public void actionPerformed(ActionEvent e) {
checkInit();
- ConfigUI i = VCSUIFactory.newConfigUI();
+ org.codelutin.vcs.ui.ConfigUI ui = org.codelutin.vcs.ui.VCSUIFactory.getUI(CONFIG_UI);
// populate with common config
- i.getHandler().getModel().populate(i.getHandler().getConfig());
- i.setVisible(true);
+ ui.getHandler().getModel().populate(ui.getHandler().getConfig());
+ ui.setVisible(true);
}
protected ShowConfigAction() {
- super(_("lutinvcs.action.showconfig.libelle"), createActionIcon("showconfig"));
+ super(_("lutinvcs.action.showconfig.libelle"), org.codelutin.ui.UIHelper.createActionIcon("showconfig"));
String name = (String) getValue(NAME);
putValue(DISPLAYED_MNEMONIC_INDEX_KEY, name.length() - 1);
putValue(ACCELERATOR_KEY, (int) name.charAt(name.length() - 1));
Modified: trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/action/ShowMessagesAction.java
===================================================================
--- trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/action/ShowMessagesAction.java 2008-04-19 18:40:26 UTC (rev 599)
+++ trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/action/ShowMessagesAction.java 2008-04-19 18:41:31 UTC (rev 600)
@@ -14,49 +14,43 @@
*/
package org.codelutin.vcs.ui.action;
-import static org.codelutin.i18n.I18n._;
-import org.codelutin.vcs.ui.ConfirmUI;
import org.codelutin.vcs.ui.handler.ConfirmUIHandler;
-import org.codelutin.vcs.ui.util.UIHelper;
-import javax.swing.AbstractAction;
-import javax.swing.AbstractButton;
-import java.awt.event.ActionEvent;
-
/** @author chemit */
public class ShowMessagesAction extends org.codelutin.vcs.ui.util.AbstractUIAction<ConfirmUIHandler> {
private static final long serialVersionUID = 1L;
- public static AbstractAction createAction(ConfirmUI ui) {
+ public static javax.swing.AbstractAction createAction(org.codelutin.vcs.ui.ConfirmUI ui) {
ShowMessagesAction action1 = new ShowMessagesAction();
action1.setUi(ui);
return action1;
}
- public void actionPerformed(ActionEvent e) {
+ public void actionPerformed(java.awt.event.ActionEvent e) {
checkInit();
- String currentMessage = getHandler().getCurrentMessage();
+ ConfirmUIHandler uiHandler = getHandler();
+
+ String currentMessage = uiHandler.getCurrentMessage();
- if (!getHandler().getModel().containsMessage(currentMessage)) {
+ if (!uiHandler.getModel().containsMessage(currentMessage)) {
// save currentmessage in special 0 row
- getHandler().setMessage(0, false, true, currentMessage);
+ uiHandler.setMessage(0, false, true, currentMessage);
} else {
// select
- getHandler().getUi().getMessageSelectionModel().setValueIsAdjusting(true);
- getHandler().getUi().getMessages().setSelectedValue(currentMessage, true);
- getHandler().getUi().getMessageSelectionModel().setValueIsAdjusting(false);
+ uiHandler.getUi().getMessageSelectionModel().setValueIsAdjusting(true);
+ uiHandler.getUi().getMessages().setSelectedValue(currentMessage, true);
+ uiHandler.getUi().getMessageSelectionModel().setValueIsAdjusting(false);
}
- getHandler().getUi().getPopup().show((AbstractButton) e.getSource(), 0, 0);
- //log.info("//TODO:" + this + " : " + messages.size());
+ uiHandler.getUi().getPopup().show((javax.swing.AbstractButton) e.getSource(), 0, 0);
}
protected ShowMessagesAction() {
- super(null, UIHelper.createActionIcon("showmessages"));
- putValue(SHORT_DESCRIPTION, _("lutinvcs.action.showmessages.tip"));
+ super(null, org.codelutin.ui.UIHelper.createActionIcon("showmessages"));
+ putValue(SHORT_DESCRIPTION, org.codelutin.i18n.I18n._("lutinvcs.action.showmessages.tip"));
setEnabled(false);
}
Modified: trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/action/TabUIAction.java
===================================================================
--- trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/action/TabUIAction.java 2008-04-19 18:40:26 UTC (rev 599)
+++ trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/action/TabUIAction.java 2008-04-19 18:41:31 UTC (rev 600)
@@ -16,15 +16,12 @@
import org.codelutin.vcs.VCSEntry;
import org.codelutin.vcs.type.VCSAction;
-import org.codelutin.vcs.ui.util.ui.AbstractTabUI;
import org.codelutin.vcs.ui.util.handler.AbstractTabUIHandler;
-import org.codelutin.vcs.ui.util.AbstractVCSEntriesTableModel;
-import org.codelutin.vcs.ui.util.UIHelper;
+import org.codelutin.vcs.ui.util.ui.AbstractTabUI;
-import javax.swing.AbstractAction;
-import java.awt.event.ActionEvent;
import java.util.List;
+
/** @author chemit */
public class TabUIAction extends org.codelutin.vcs.ui.util.AbstractUIAction<AbstractTabUIHandler<?, ?>> {
@@ -33,19 +30,19 @@
private static final long serialVersionUID = 1L;
- public static AbstractAction createAction(VCSAction action, boolean useSelection, AbstractTabUI<?> ui) {
+ public static javax.swing.AbstractAction createAction(VCSAction action, boolean useSelection, AbstractTabUI<?> ui) {
TabUIAction action1 = new TabUIAction(action, useSelection);
action1.setUi(ui);
return action1;
}
- public void actionPerformed(ActionEvent e) {
+ public void actionPerformed(java.awt.event.ActionEvent e) {
checkInit();
if (action == null) {
return;
}
AbstractTabUIHandler<?, ?> handler = getHandler();
- AbstractVCSEntriesTableModel model = handler.getModel().getEntriesModel();
+ org.codelutin.vcs.ui.util.AbstractVCSEntriesTableModel model = handler.getModel().getEntriesModel();
List<VCSEntry> entries = model.filter(action, model.getDisplayedEntries(useSelection ? handler.getSelectionModel() : null));
switch (action) {
case CHANGELOG:
@@ -87,7 +84,7 @@
}
protected TabUIAction(VCSAction action, boolean useSelection) {
- super(null, UIHelper.createActionIcon(action));
+ super(null, org.codelutin.vcs.ui.util.UIHelper.createActionIcon(action));
this.useSelection = useSelection;
this.action = action;
//putValue(SHORT_DESCRIPTION, action.getTip());
Modified: trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/handler/SynchUIHandler.java
===================================================================
--- trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/handler/SynchUIHandler.java 2008-04-19 18:40:26 UTC (rev 599)
+++ trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/handler/SynchUIHandler.java 2008-04-19 18:41:31 UTC (rev 600)
@@ -1,15 +1,15 @@
package org.codelutin.vcs.ui.handler;
import static org.codelutin.i18n.I18n._;
+import org.codelutin.vcs.VCSConnexionConfig;
import org.codelutin.vcs.VCSEntry;
-import org.codelutin.vcs.VCSConnexionConfig;
import org.codelutin.vcs.event.VCSActionThreadEvent;
import org.codelutin.vcs.type.VCSAction;
import org.codelutin.vcs.type.VCSState;
import org.codelutin.vcs.ui.SynchUI;
import org.codelutin.vcs.ui.model.SynchUIModel;
+import org.codelutin.vcs.ui.util.AbstractVCSEntriesTableModel;
import org.codelutin.vcs.ui.util.handler.AbstractTabUIHandler;
-import org.codelutin.vcs.ui.util.AbstractVCSEntriesTableModel;
import javax.swing.AbstractButton;
import javax.swing.JPopupMenu;
@@ -24,18 +24,20 @@
/** @author chemit */
public class SynchUIHandler extends AbstractTabUIHandler<SynchUIModel, SynchUI> {
- public SynchUIHandler(SynchUI ui,VCSConnexionConfig config) {
- super(ui, new SynchUIModel(), config,true);
+ public SynchUIHandler(SynchUI ui, VCSConnexionConfig config) {
+ super(ui, new SynchUIModel(), config, true);
ui.setHandler(this);
}
public void onActionStarted(VCSActionThreadEvent event) {
- log.info(event);
+ if (log.isDebugEnabled()) {
+ log.debug(event);
+ }
}
public void onActionDone(VCSActionThreadEvent event) {
if (log.isDebugEnabled()) {
- log.info(event);
+ log.debug(event);
}
AbstractVCSEntriesTableModel entriesModel = getModel().getEntriesModel();
for (VCSEntry entry : event.getSource()) {
@@ -44,7 +46,9 @@
entriesModel.removeEntry(entry);
}
}
- log.info("notify table model changed " + this);
+ if (log.isDebugEnabled()) {
+ log.debug("notify table model changed " + this);
+ }
entriesModel.fireTableDataChanged();
}
Modified: trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/util/UIHelper.java
===================================================================
--- trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/util/UIHelper.java 2008-04-19 18:40:26 UTC (rev 599)
+++ trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/util/UIHelper.java 2008-04-19 18:41:31 UTC (rev 600)
@@ -104,12 +104,8 @@
return map;
}
- public static ImageIcon createActionIcon(String name) {
- return org.codelutin.ui.UIHelper.createImageIcon("action-" + name + ".png");
- }
-
public static ImageIcon createActionIcon(VCSAction location) {
- return createActionIcon(location.name().toLowerCase());
+ return org.codelutin.ui.UIHelper.createActionIcon(location.name().toLowerCase());
}
public static ImageIcon createLocationIcon(VCSEntryLocation location) {
Modified: trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/util/handler/AbstractTabUIHandler.java
===================================================================
--- trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/util/handler/AbstractTabUIHandler.java 2008-04-19 18:40:26 UTC (rev 599)
+++ trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/util/handler/AbstractTabUIHandler.java 2008-04-19 18:41:31 UTC (rev 600)
@@ -14,17 +14,17 @@
*/
package org.codelutin.vcs.ui.util.handler;
+import org.codelutin.vcs.VCSConnexionConfig;
import org.codelutin.vcs.VCSEntry;
import org.codelutin.vcs.VCSException;
-import org.codelutin.vcs.VCSConnexionConfig;
import org.codelutin.vcs.type.VCSAction;
import org.codelutin.vcs.ui.ChangelogUI;
import org.codelutin.vcs.ui.ConfirmUI;
import org.codelutin.vcs.ui.DiffUI;
import org.codelutin.vcs.ui.VCSUIFactory;
+import org.codelutin.vcs.ui.util.AbstractVCSEntriesTableModel;
import org.codelutin.vcs.ui.util.model.AbstractTabUIModel;
import org.codelutin.vcs.ui.util.ui.AbstractTabUI;
-import org.codelutin.vcs.ui.util.AbstractVCSEntriesTableModel;
import javax.swing.AbstractButton;
import javax.swing.ListSelectionModel;
@@ -36,8 +36,8 @@
/** @author chemit */
public abstract class AbstractTabUIHandler<M extends AbstractTabUIModel, U extends AbstractTabUI<? extends AbstractTabUIHandler>> extends AbstractBasicUIHandler<M, U> implements TableModelListener {
- protected AbstractTabUIHandler(U ui, M model, VCSConnexionConfig config,boolean useThreadListener) {
- super(ui, model,config, useThreadListener);
+ protected AbstractTabUIHandler(U ui, M model, VCSConnexionConfig config, boolean useThreadListener) {
+ super(ui, model, config, useThreadListener);
}
public void propertyChange(PropertyChangeEvent evt) {
@@ -58,13 +58,12 @@
protected abstract void afterLocationChanged();
-
protected void updateAction(EnumMap<VCSAction, Integer> actions, boolean hasActions, AbstractButton ui, VCSAction action) {
ui.setEnabled(hasActions && actions.containsKey(action) && actions.get(action) > 0);
}
public void showConfirmUI(VCSAction action, AbstractVCSEntriesTableModel model, List<VCSEntry> entries) {
- ConfirmUI ui = VCSUIFactory.newConfirmUI();
+ ConfirmUI ui = VCSUIFactory.getUI(VCSUIFactory.CONFIRM_UI);
if (log.isDebugEnabled()) {
log.debug("nb entries:" + entries.size());
}
@@ -74,7 +73,7 @@
}
public void showDiffUI(boolean useSelection, AbstractVCSEntriesTableModel model, List<VCSEntry> entries) {
- DiffUI ui = VCSUIFactory.newDiffUI();
+ DiffUI ui = VCSUIFactory.getUI(VCSUIFactory.DIFF_UI);
if (!useSelection) {
// take all entries
entries = model.filter(VCSAction.DIFF, model.getEntries());
@@ -89,7 +88,7 @@
}
public void showChangelogUI(boolean useSelection, AbstractVCSEntriesTableModel model, List<VCSEntry> entries) {
- ChangelogUI ui = VCSUIFactory.newChangelogUI();
+ ChangelogUI ui = VCSUIFactory.getUI(VCSUIFactory.CHANGELOG_UI);
if (!useSelection) {
// take all entries
entries = model.filter(VCSAction.CHANGELOG, model.getEntries());
Copied: trunk/lutinvcs/ui/jaxx/src/main/resources/META-INF/services/org.codelutin.ui.UIProvider (from rev 547, trunk/lutinvcs/ui/jaxx/src/main/resources/META-INF/services/org.codelutin.vcs.ui.VCSUIProvider)
===================================================================
--- trunk/lutinvcs/ui/jaxx/src/main/resources/META-INF/services/org.codelutin.ui.UIProvider (rev 0)
+++ trunk/lutinvcs/ui/jaxx/src/main/resources/META-INF/services/org.codelutin.ui.UIProvider 2008-04-19 18:41:31 UTC (rev 600)
@@ -0,0 +1 @@
+org.codelutin.vcs.ui.JaxxVCSUIProvider
\ No newline at end of file
Deleted: trunk/lutinvcs/ui/jaxx/src/main/resources/META-INF/services/org.codelutin.vcs.ui.VCSUIProvider
===================================================================
--- trunk/lutinvcs/ui/jaxx/src/main/resources/META-INF/services/org.codelutin.vcs.ui.VCSUIProvider 2008-04-19 18:40:26 UTC (rev 599)
+++ trunk/lutinvcs/ui/jaxx/src/main/resources/META-INF/services/org.codelutin.vcs.ui.VCSUIProvider 2008-04-19 18:41:31 UTC (rev 600)
@@ -1 +0,0 @@
-org.codelutin.vcs.ui.JaxxVCSUIProvider
\ No newline at end of file
Modified: trunk/lutinvcs/ui/jaxx/src/main/uimodel/org/codelutin/vcs/ui/JaxxConfigUI.jaxx
===================================================================
--- trunk/lutinvcs/ui/jaxx/src/main/uimodel/org/codelutin/vcs/ui/JaxxConfigUI.jaxx 2008-04-19 18:40:26 UTC (rev 599)
+++ trunk/lutinvcs/ui/jaxx/src/main/uimodel/org/codelutin/vcs/ui/JaxxConfigUI.jaxx 2008-04-19 18:41:31 UTC (rev 600)
@@ -1,4 +1,4 @@
-<ConfigUI title='lutinvcs.config.title'>
+<ConfigUI title='lutinvcs.config.title' modal='true'>
<!--ConfigUI title='lutinvcs.config.title' resizable='false'-->
<style source="config.css"/>
<script>
Modified: trunk/lutinvcs/ui/jaxx/src/main/uimodel/org/codelutin/vcs/ui/JaxxVCSUIProvider.java
===================================================================
--- trunk/lutinvcs/ui/jaxx/src/main/uimodel/org/codelutin/vcs/ui/JaxxVCSUIProvider.java 2008-04-19 18:40:26 UTC (rev 599)
+++ trunk/lutinvcs/ui/jaxx/src/main/uimodel/org/codelutin/vcs/ui/JaxxVCSUIProvider.java 2008-04-19 18:41:31 UTC (rev 600)
@@ -15,9 +15,15 @@
package org.codelutin.vcs.ui;
/** @author chemit */
-public class JaxxVCSUIProvider extends VCSUIProvider {
+public class JaxxVCSUIProvider extends org.codelutin.ui.UIProvider {
public JaxxVCSUIProvider() {
- super("jaxx", JaxxSynchUI.class, JaxxDiffUI.class, JaxxChangelogUI.class,JaxxConfirmUI.class,JaxxConfigUI.class,JaxxGenerateSshKeyUI.class);
+ super("vcs", "jaxx",
+ JaxxSynchUI.class,
+ JaxxDiffUI.class,
+ JaxxChangelogUI.class,
+ JaxxConfirmUI.class,
+ JaxxConfigUI.class,
+ JaxxGenerateSshKeyUI.class);
}
}
\ No newline at end of file
1
0
[Buix-commits] r599 - in trunk/lutinvcs: core/src/main/resources/META-INF tools/src/main/resources/META-INF
by tchemit@users.labs.libre-entreprise.org 19 Apr '08
by tchemit@users.labs.libre-entreprise.org 19 Apr '08
19 Apr '08
Author: tchemit
Date: 2008-04-19 18:40:26 +0000 (Sat, 19 Apr 2008)
New Revision: 599
Removed:
trunk/lutinvcs/core/src/main/resources/META-INF/services/
trunk/lutinvcs/tools/src/main/resources/META-INF/services/
Log:
suppression META-INF servcies de log (deja positionne dans lutinutil)
1
0
[Buix-commits] r598 - trunk/lutinui/src/main/java/org/codelutin/ui
by tchemit@users.labs.libre-entreprise.org 19 Apr '08
by tchemit@users.labs.libre-entreprise.org 19 Apr '08
19 Apr '08
Author: tchemit
Date: 2008-04-19 18:39:07 +0000 (Sat, 19 Apr 2008)
New Revision: 598
Modified:
trunk/lutinui/src/main/java/org/codelutin/ui/DialogUIDef.java
trunk/lutinui/src/main/java/org/codelutin/ui/DialogUIHandler.java
trunk/lutinui/src/main/java/org/codelutin/ui/DialogUIModel.java
trunk/lutinui/src/main/java/org/codelutin/ui/UIFactory.java
trunk/lutinui/src/main/java/org/codelutin/ui/UIProvider.java
Log:
mise en place provider sur ui parametrable par nom d'application
refactoring UIFactory: le ServiceLoader n'est pas conserv?\195?\169
Modified: trunk/lutinui/src/main/java/org/codelutin/ui/DialogUIDef.java
===================================================================
--- trunk/lutinui/src/main/java/org/codelutin/ui/DialogUIDef.java 2008-04-19 18:31:55 UTC (rev 597)
+++ trunk/lutinui/src/main/java/org/codelutin/ui/DialogUIDef.java 2008-04-19 18:39:07 UTC (rev 598)
@@ -14,13 +14,32 @@
*/
package org.codelutin.ui;
-/** @author chemit */
-public class DialogUIDef<M extends DialogUIModel, U extends DialogUI<?>, H extends DialogUIHandler<M, U>> {
+/**
+ * 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 {
- private final Class<U> uiClass;
+ /** 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;
+
+ private static final long serialVersionUID = 1L;
+
public DialogUIDef(Class<H> handlerClass, Class<U> uiClass, Class<M> modelClass) {
this.handlerClass = handlerClass;
this.uiClass = uiClass;
@@ -39,10 +58,18 @@
return modelClass;
}
+ public Class<? extends U> getUiImplClass() {
+ return uiImplClass;
+ }
+
+ @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
@@ -52,6 +79,35 @@
@Override
public String toString() {
- return super.toString() + "<model:" + modelClass + ", ui:" + uiClass + ", handler:" + handlerClass + '>';
+ 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() {
+ 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);
+ }
+ }
+ }
+ return uiInstance;
+ }
+
+ protected void setUiInstance(U uiInstance) {
+ this.uiInstance = uiInstance;
+ }
+
+ protected String printClass(String s, Class<?> aClass, boolean notLast) {
+ return s + ':' + (aClass == null ? null : aClass.getSimpleName()) + (notLast ? ", " : ">");
+ }
}
Modified: trunk/lutinui/src/main/java/org/codelutin/ui/DialogUIHandler.java
===================================================================
--- trunk/lutinui/src/main/java/org/codelutin/ui/DialogUIHandler.java 2008-04-19 18:31:55 UTC (rev 597)
+++ trunk/lutinui/src/main/java/org/codelutin/ui/DialogUIHandler.java 2008-04-19 18:39:07 UTC (rev 598)
@@ -17,6 +17,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import java.awt.event.WindowListener;
import java.beans.PropertyChangeListener;
/**
@@ -55,6 +56,15 @@
}
public void dispose() {
- model.removePropertyChangeListener(this);
+ 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
Modified: trunk/lutinui/src/main/java/org/codelutin/ui/DialogUIModel.java
===================================================================
--- trunk/lutinui/src/main/java/org/codelutin/ui/DialogUIModel.java 2008-04-19 18:31:55 UTC (rev 597)
+++ trunk/lutinui/src/main/java/org/codelutin/ui/DialogUIModel.java 2008-04-19 18:39:07 UTC (rev 598)
@@ -82,4 +82,16 @@
}
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
Modified: trunk/lutinui/src/main/java/org/codelutin/ui/UIFactory.java
===================================================================
--- trunk/lutinui/src/main/java/org/codelutin/ui/UIFactory.java 2008-04-19 18:31:55 UTC (rev 597)
+++ trunk/lutinui/src/main/java/org/codelutin/ui/UIFactory.java 2008-04-19 18:39:07 UTC (rev 598)
@@ -16,18 +16,16 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.codelutin.util.ListenerSet;
import org.codelutin.util.StringUtil;
-import java.awt.event.WindowAdapter;
-import java.awt.event.WindowEvent;
-import java.lang.reflect.InvocationTargetException;
-import java.util.HashMap;
-import java.util.Map;
+import javax.swing.event.EventListenerList;
+import java.lang.reflect.Constructor;
+import java.util.ArrayList;
+import java.util.List;
import java.util.ServiceLoader;
/**
- * Factory if VCS UI, using a cache.
+ * Factory for UI, using a cache and aprovider to find ui implementations.
*
* @author chemit
*/
@@ -35,95 +33,132 @@
static protected final Log log = LogFactory.getLog(UIFactory.class);
- protected static UIFactory instance;
+ private final String applicationName;
- protected Map<DialogUIDef, DialogUI> cache;
+ private final DialogUIDef[] defs;
- protected ServiceLoader<UIProvider> loader;
+ private final EventListenerList listeners;
- protected String applicationName;
-
- protected ListenerSet<FactoryWindowListener> listeners;
-
- public static void initFactory(String applicationName, FactoryWindowListener... listeners) {
- UIFactory factory = getInstance();
- synchronized (factory) {
- factory.applicationName = applicationName;
- for (FactoryWindowListener listener : listeners) {
- listener.setFactory(factory);
- factory.addFactoryWindowListener(listener);
+ 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(l);
+ listeners.add(FactoryWindowListener.class, l);
+ if (log.isDebugEnabled()) {
+ log.debug("after added (" + listeners.getListenerCount() + ") : " + l);
+ }
}
public void removeFactoryWindowListener(FactoryWindowListener l) {
- listeners.remove(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() {
- if (cache != null) {
- cache.clear();
- cache = null;
+ 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 (loader != null) {
- loader.reload();
- loader = 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);
+ }
}
- while (listeners.size() > 0) {
- removeFactoryWindowListener(listeners.iterator().next());
- }
}
- protected static UIFactory getInstance() {
- if (instance == null) {
- instance = new UIFactory();
+ 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);
+ }
}
- return instance;
}
- @Override
- protected void finalize() throws Throwable {
- super.finalize();
- close();
- }
-
- protected synchronized Map<DialogUIDef, DialogUI> getCache() {
- if (cache == null) {
- cache = new HashMap<DialogUIDef, DialogUI>();
+ 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;
+ }
}
- return cache;
}
- protected synchronized ServiceLoader<UIProvider> getProviders() {
- checkInit();
- if (loader == null) {
- long t0 = System.nanoTime();
-
- loader = ServiceLoader.load(UIProvider.class);
- int nb = 0;
- for (UIProvider provider : loader) {
- log.info(provider.getName() + " [" + provider + ']');
- nb++;
+ 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 " + nb + " ui provider(s) in " + StringUtil.convertTime(t0, System.nanoTime()));
}
- return loader;
+ log.info("found " + providers.size() + " ui provider(s) in " + StringUtil.convertTime(t0, System.nanoTime()) + " : " + providers);
+ return providers.toArray(new UIProvider[providers.size()]);
}
- protected DialogUI newUI(DialogUIDef uiType) {
+ protected DialogUIDef[] getDefs() {
+ return defs;
+ }
- DialogUI result = getInstance().getCache().get(uiType);
+ @Override
+ protected void finalize() throws Throwable {
+ super.finalize();
+ close();
+ }
+
+ protected <M extends DialogUIModel, U extends DialogUI<H>, H extends DialogUIHandler<M, U>> U getUI(DialogUIDef<M, U, H> uiType, Object... params) {
+ U result = uiType.uiInstance;
if (result == null) {
try {
- getCache().put(uiType, result = newUI0(uiType));
- for (FactoryWindowListener listener : listeners) {
- result.addWindowListener(listener);
- }
+ result = newUI(uiType, params);
} catch (Exception e) {
throw new IllegalStateException("could not instanciate ui handler " + uiType + " for reason : " + e.getMessage());
}
@@ -131,88 +166,37 @@
return result;
}
- protected DialogUI newUI0(DialogUIDef uiType, Object... params) throws IllegalAccessException, InstantiationException, NoSuchMethodException, InvocationTargetException {
- for (UIProvider provider : getProviders()) {
- DialogUI ui = provider.newUI(uiType);
- if (ui != null) {
- Class<?>[] prototype = getHandlerPrototype(ui.getClass(), params);
- Object[] parameters = getHandlerParameters(ui, params);
- uiType.getHandlerClass().getConstructor(prototype).newInstance(ui, parameters);
- ui.getHandler().init();
- return ui;
+ protected <M extends DialogUIModel, U extends DialogUI<H>, H extends DialogUIHandler<M, U>> U newUI(DialogUIDef<M, U, H> uiType, Object... params) throws IllegalStateException {
+ U ui = uiType.getUiInstance();
+ if (ui != null) {
+ Object[] parameters = getHandlerParameters(ui, params);
+ try {
+ Constructor<?> hConstructor = uiType.getHandlerClass().getConstructors()[0];
+ hConstructor.newInstance(parameters);
+ } catch (Exception e) {
+ throw new IllegalStateException("could not init ui " + uiType + " for reason :" + e.getMessage(), e);
}
+ ui.getHandler().init();
+ registerUI(ui);
+ return ui;
}
throw new IllegalStateException("could not find ui " + uiType);
}
- protected UIFactory() {
- listeners = new ListenerSet<FactoryWindowListener>();
- }
-
- protected Class<?>[] getHandlerPrototype(Class<? extends DialogUI> aClass, Object[] params) {
- Class<?>[] classes = new Class<?>[1 + params.length];
- classes[0] = aClass.getSuperclass();
- for (int i = 0; i < params.length; i++) {
- classes[i + 1] = params[i].getClass();
+ protected <U extends DialogUI> void registerUI(U ui) {
+ for (FactoryWindowListener listener : listeners.getListeners(FactoryWindowListener.class)) {
+ if (log.isDebugEnabled()) {
+ log.debug("----- addFactoryWindowListener " + listener + " to " + ui);
+ }
+ ui.addWindowListener(listener);
}
- return classes;
}
protected Object[] getHandlerParameters(DialogUI ui, Object[] params) {
- Object[] classes = new Object[1 + params.length];
- classes[0] = ui;
- System.arraycopy(params, 0, classes, 1, params.length);
- return classes;
+ Object[] result = new Object[1 + params.length];
+ result[0] = ui;
+ System.arraycopy(params, 0, result, 1, params.length);
+ return result;
}
- private void checkInit() throws IllegalStateException {
- if (applicationName == null) {
- throw new IllegalStateException("factory " + this + " was not init ");
- }
- }
-
- public static abstract class FactoryWindowListener extends WindowAdapter {
-
- protected abstract void allWindowsClosed();
-
- private UIFactory factory;
-
- private boolean wasClosed;
-
- public UIFactory getFactory() {
- return factory;
- }
-
- public void setFactory(UIFactory factory) {
- this.factory = factory;
- }
-
- @Override
- public void windowClosed(WindowEvent e) {
- if (log.isDebugEnabled()) {
- log.debug(e.getSource());
- }
- if (e.getWindow().isVisible()) {
- // only deal with real closed and none visible windows...
- return;
- }
- for (DialogUI vcsui : factory.getCache().values()) {
- if (vcsui.isVisible()) {
- // at least one ui visible, do not kill connexions
- return;
- }
- }
- if (wasClosed) {
- // make sure to process once
- return;
- }
- synchronized (this) {
- try {
- allWindowsClosed();
- } finally {
- wasClosed = true;
- }
- }
- }
- }
}
\ No newline at end of file
Modified: trunk/lutinui/src/main/java/org/codelutin/ui/UIProvider.java
===================================================================
--- trunk/lutinui/src/main/java/org/codelutin/ui/UIProvider.java 2008-04-19 18:31:55 UTC (rev 597)
+++ trunk/lutinui/src/main/java/org/codelutin/ui/UIProvider.java 2008-04-19 18:39:07 UTC (rev 598)
@@ -21,20 +21,19 @@
protected String applicationName;
/** the name of ui implementation used by this provider */
- protected String name;
+ protected String providerName;
/** array of ui implementations */
protected Class<?>[] implementations;
- protected UIProvider(String applicationName, String name, Class<?>... implementations) {
+ protected UIProvider(String applicationName, String providerName, Class<?>... implementations) {
this.applicationName = applicationName;
- this.name = name;
+ this.providerName = providerName;
this.implementations = implementations;
}
- /** @return the identifier of the ui provider (eg jaxx, swing, ...) */
- public String getName() {
- return name;
+ public String getProviderName() {
+ return providerName;
}
public String getApplicationName() {
@@ -45,24 +44,43 @@
return implementations;
}
- public <U extends DialogUI<?>, D extends DialogUIDef<?, U, ?>> U newUI(D def) throws InstantiationException, IllegalAccessException {
- Class<U> uiImpl = finImpl(def.getUiClass());
- return uiImpl != null ? uiImpl.newInstance() : null;
+ 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() {
- return super.toString() + " application:" + applicationName + ", provider:" + name + ", uis:" + (java.util.Arrays.toString(implementations));
+ 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();
}
- @SuppressWarnings({"unchecked"})
- private <X extends DialogUI> Class<X> finImpl(Class<X> uiType) {
- for (Class<?> klass : implementations) {
- if (uiType.isAssignableFrom(klass)) {
- return (Class<X>) klass;
- }
- }
- return null;
+ 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