Simexplorer-si-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
February 2008
- 2 participants
- 701 discussions
r1145 - in trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui: actions swing swing/actions swing/actions/history swing/actions/util swing/model
by tchemit@users.labs.libre-entreprise.org 20 Feb '08
by tchemit@users.labs.libre-entreprise.org 20 Feb '08
20 Feb '08
Author: tchemit
Date: 2008-02-20 18:46:01 +0000 (Wed, 20 Feb 2008)
New Revision: 1145
Added:
trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/SimExplorer.java
trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/SimExplorerConfig.java
trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/SimExplorerContext.java
trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/StorageServiceHelper.java
Modified:
trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/actions/SimExplorerAbstractOptionAction.java
trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/SimExplorerActionManager.java
trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/AboutAction.java
trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/ChangePageAction.java
trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/ChangeSizorAction.java
trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/CloseTabAction.java
trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/CollapseAllAction.java
trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/ConnectAction.java
trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/DeleteElementAction.java
trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/DetailToTreeAction.java
trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/DownloadAttachmentAction.java
trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/DownloadElementAction.java
trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/ExpandAllAction.java
trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/ExportElementAction.java
trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/ExportElementToLocalAction.java
trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/ExportElementToRemoteAction.java
trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/GoLastPageAction.java
trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/GoNextPageAction.java
trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/GoPreviousPageAction.java
trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/HelpAction.java
trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/ImportElementAction.java
trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/QuitAction.java
trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/ResetSearchAction.java
trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/SearchAction.java
trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/ShowDetailTabAction.java
trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/ShowLocalTabAction.java
trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/ShowRemoteTabAction.java
trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/ShowSynchronizeTabAction.java
trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/UnconnectAction.java
trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/history/HistoryAbstractAction.java
trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/history/HistoryDeleteAction.java
trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/history/HistoryNextAction.java
trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/history/HistoryPreviousAction.java
trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/history/HistoryUnconnectAction.java
trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/util/ChangeI18nAbstractAction.java
trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/util/ShowListTabAbstractAction.java
trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/util/ShowTabAbstractAction.java
trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/util/SimExplorerAbstractAction.java
trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/util/SimExplorerAbstractTabAction.java
trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/model/DataEntityModel.java
trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/model/DetailTabModel.java
trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/model/EntityTreeNode.java
trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/model/ListTabModel.java
trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/model/ListTableModel.java
trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/model/PaginationModel.java
trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/model/QueryModel.java
trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/model/SimExplorerTabModel.java
trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/model/SynchronizeTabModel.java
Log:
move ui to ui package
Modified: trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/actions/SimExplorerAbstractOptionAction.java
===================================================================
--- trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/actions/SimExplorerAbstractOptionAction.java 2008-02-20 18:45:27 UTC (rev 1144)
+++ trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/actions/SimExplorerAbstractOptionAction.java 2008-02-20 18:46:01 UTC (rev 1145)
@@ -18,9 +18,9 @@
package fr.cemagref.simexplorer.is.ui.actions;
-import fr.cemagref.simexplorer.is.ui.SimExplorer;
-import fr.cemagref.simexplorer.is.ui.SimExplorerContext;
import fr.cemagref.simexplorer.is.ui.SimExplorerOptionParser;
+import fr.cemagref.simexplorer.is.ui.swing.SimExplorer;
+import fr.cemagref.simexplorer.is.ui.swing.SimExplorerContext;
import org.codelutin.option.Option;
import org.codelutin.option.OptionAction;
Copied: trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/SimExplorer.java (from rev 1132, trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/SimExplorer.java)
===================================================================
--- trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/SimExplorer.java (rev 0)
+++ trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/SimExplorer.java 2008-02-20 18:46:01 UTC (rev 1145)
@@ -0,0 +1,153 @@
+/*
+* ##% Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008 Code Lutin,
+* Tony Chemit, Gabriel Landais
+*
+* 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 fr.cemagref.simexplorer.is.ui.swing;
+
+import fr.cemagref.simexplorer.is.exceptions.SimExplorerRuntimeException;
+import fr.cemagref.simexplorer.is.ui.swing.actions.util.SimExplorerAbstractAction;
+import fr.cemagref.simexplorer.is.ui.swing.ui.SimExplorerMainUI;
+import fr.cemagref.simexplorer.is.ui.swing.ui.SimExplorerTab;
+import fr.cemagref.simexplorer.is.ui.swing.ui.util.ErrorDialog;
+import org.codelutin.i18n.I18n;
+import org.codelutin.option.ui.ConfigTableModel;
+import org.codelutin.option.ui.ConfigUI;
+
+import java.awt.event.ActionEvent;
+import java.io.IOException;
+
+/**
+ * L'application principale
+ *
+ * @author chemit
+ */
+public class SimExplorer {
+
+ /** le context principal de l'application */
+ protected static SimExplorerContext context;
+
+ public static SimExplorerContext getContext() {
+ checkInitContext();
+ return context;
+ }
+
+ /**
+ * initialisation de l'application :
+ * <p/>
+ * chargement du context
+ *
+ * @param args les arguments passés à l'application
+ */
+ public static void init(String... args) {
+
+ // init context
+ context = new SimExplorerContext();
+
+ // init i18n
+ I18n.initISO88591();
+
+ // init parser
+ context.initParser(args);
+
+ // init config
+ context.initConfig();
+
+ // save config
+ try {
+ context.save();
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ /** Lancement de l'ui après init de l'application. */
+ public static void launch() {
+
+ // init ui
+ SimExplorerMainUI mainUI = SimExplorerMainUI.getUI();
+
+ SimExplorerConfig conf = getContext().getConfig();
+
+ if (conf.isShowLocalTab()) {
+ // show local tab
+ mainUI.getToggleTab_local().doClick();
+ }
+ if (conf.isAutoConnect()) {
+ try {
+ // try to connect
+ mainUI.getConnect().getAction().actionPerformed(new ActionEvent(mainUI, 0, "connect"));
+ // action will update ui if everything is correct
+ if (context.isConnected() && conf.isShowRemoteTab()) {
+ // show remote tab
+ mainUI.getToggleTab_remote().doClick();
+ }
+ } catch (Exception e) {
+ // ignore ?
+ System.err.println(e.getMessage());
+ }
+ }
+
+ // refresh ui accessibles actions
+ if (!context.isConnected()) {
+ ((SimExplorerAbstractAction)mainUI.getConnectAction(false)).updateUI();
+ }
+ mainUI.setVisible(true);
+ }
+
+ public static void dispose(boolean reload) {
+
+ SimExplorerTab.dispose();
+ SimExplorerActionManager.dispose();
+
+ ConfigUI.reloadUI();
+ ErrorDialog.disposeUI();
+ SimExplorerMainUI.getUI().disposeUI();
+ if (reload) {
+ launch();
+ }
+ }
+
+ public static void main(String... args) throws Exception {
+
+ // init application (parser,config,i18n,...)
+ init(args);
+
+ // launch actions required
+ context.getParser().doAllActions();
+
+ // show edit config if first launch
+ if (SimExplorer.context.isFirstLaunch()) {
+ ConfigUI.showUI(context.getConfig(), ConfigTableModel.TypeModel.all);
+ }
+
+ // launch ui only if required
+ if (!context.isQuit() && context.isLaunchUI()) {
+ launch();
+ }
+
+ }
+
+ public static void checkInitContext() {
+ if (context == null) {
+ throw new SimExplorerRuntimeException("context is null, you must init first the " + SimExplorer.class.getName() + " class via init method");
+ }
+ }
+
+ protected SimExplorer() {
+ // protected restricted access
+ }
+}
Modified: trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/SimExplorerActionManager.java
===================================================================
--- trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/SimExplorerActionManager.java 2008-02-20 18:45:27 UTC (rev 1144)
+++ trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/SimExplorerActionManager.java 2008-02-20 18:46:01 UTC (rev 1145)
@@ -19,6 +19,7 @@
package fr.cemagref.simexplorer.is.ui.swing;
import fr.cemagref.simexplorer.is.ui.swing.actions.util.SimExplorerAbstractAction;
+import fr.cemagref.simexplorer.is.ui.swing.ui.SimExplorerTab;
import jaxx.runtime.JAXXObject;
import jaxx.runtime.builder.ActionFactory;
import jaxx.runtime.builder.SimpleActionFactoryImpl;
@@ -34,7 +35,7 @@
* La classe responsable de l'enregistrement des actions disponibles
* dans l'application en délégeant à une ActionFactory.
* <p/>
- * On peut de plus via la méthode {@link #loadActions(JAXXObject, SimExplorerTab)} de charger
+ * On peut de plus via la méthode {@link #loadActions(JAXXObject, fr.cemagref.simexplorer.is.ui.swing.ui.SimExplorerTab)} de charger
* dans l'ui les actions connues.
*
* @author tony
@@ -83,16 +84,16 @@
* @return l'usine d'actions
* @see jaxx.runtime.builder.ActionFactory
*/
- protected static ActionFactory getFactory() {
+ public static ActionFactory getFactory() {
if (factory == null) {
// used a simple factory implementation
- factory = new SimpleActionFactoryImpl();
+ factory = new SimpleActionFactoryImpl();
}
return factory;
}
public static void fireAction(String actionKey, Object source) {
- fireAction(actionKey,source, (AbstractButton) null);
+ fireAction(actionKey, source, (AbstractButton) null);
}
public static AbstractAction newAction(String actionKey) {
@@ -103,10 +104,11 @@
getFactory().resetCache();
}
- public static void disposeUI() {
+ public static void dispose() {
+ resetCache();
for (String actionKey : getFactory().getActionNames()) {
SimExplorerAbstractAction action = (SimExplorerAbstractAction) newAction(actionKey);
- if (action!=null) {
+ if (action != null) {
action.disposeUI();
}
}
Copied: trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/SimExplorerConfig.java (from rev 1132, trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/SimExplorerConfig.java)
===================================================================
--- trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/SimExplorerConfig.java (rev 0)
+++ trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/SimExplorerConfig.java 2008-02-20 18:46:01 UTC (rev 1145)
@@ -0,0 +1,133 @@
+/*
+* ##% Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007 Code Lutin,
+* Tony Chemit, Gabriel Landais
+*
+* 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 fr.cemagref.simexplorer.is.ui.swing;
+
+import fr.cemagref.simexplorer.is.exceptions.SimExplorerRuntimeException;
+import fr.cemagref.simexplorer.is.ui.SimExplorerOptionParser;
+import fr.cemagref.simexplorer.is.ui.configs.SimExplorerAbstractConfigMain;
+import fr.cemagref.simexplorer.is.ui.options.SimExplorerOptionConfig;
+import fr.cemagref.simexplorer.is.ui.options.SimExplorerOptionConfigFile;
+import org.codelutin.i18n.CountryEnum;
+import org.codelutin.i18n.I18n;
+import static org.codelutin.i18n.I18n._;
+import org.codelutin.i18n.LanguageEnum;
+import org.codelutin.option.ConfigPropertyKey;
+import org.codelutin.option.OptionParser;
+
+import java.io.File;
+import java.io.IOException;
+
+/**
+ * L'implantation concrete de la config principale
+ *
+ * @author chemit
+ */
+public class SimExplorerConfig extends SimExplorerAbstractConfigMain {
+
+ public SimExplorerConfig() {
+ super();
+ String home = System.getProperty("user.home");
+ if (home == null) {
+ // this is a serious fatal error
+ throw new SimExplorerRuntimeException("simexplorer.error.user.home");
+ }
+ doInit();
+ }
+
+ public void init() throws IOException {
+ log.info("start for category [" + category + "] -------------------------");
+
+ SimExplorerOptionParser parser = SimExplorer.getContext().getParser();
+ initConfigFile(parser);
+ log.info("config file : " + getSource());
+ // chargement des valeurs par défaut
+ loadFromDefaultValue();
+ // après le chargement des valeurs par défaut
+ // la configuration n'est pas modifiée
+ clearModified();
+ // surcharge à partir du fichier de configuration de l'utilisateur
+ loadFromSource();
+ // surcharge à partir des propriétés système
+ loadFromSystem();
+ // surcharge à partir des propriétés de la jvm
+ loadFromJvm();
+ // surcharge à partir de l'option config de la ligne de commande
+ loadFromOptions(parser);
+ clearModified();
+ for (String s : this.toString().split("\n")) {
+ log.debug(s);
+ }
+ log.info("end for category [" + category + "] ---------------------------");
+ }
+
+ protected void initConfigFile(OptionParser parser) {
+ File file;
+ if (parser.isOptionEnabled(SimExplorerOptionParser.CONFIG_FILE_OPTION_KEY)) {
+ // surcharge config file
+ SimExplorerOptionConfigFile option = SimExplorerOptionParser.CONFIG_FILE_OPTION_KEY.getOptions().get(0);
+
+ file = option.getConfigFile();
+ } else {
+ String home = System.getProperty("user.home", "");
+ File root = new File(home);
+ file = new File(root, SimExplorerConfig.CONFIG_FILE_NAME_PROPERTY_KEY.getDefaultValue().getName());
+ if (!file.exists()) {
+ SimExplorer.getContext().setFirstLaunch(true);
+ try {
+ file.createNewFile();
+ } catch (IOException e) {
+ throw new SimExplorerRuntimeException(e);
+ }
+ }
+ }
+ if (containsKey(SimExplorerConfig.CONFIG_FILE_NAME_PROPERTY_KEY)) {
+ setProperty(SimExplorerConfig.CONFIG_FILE_NAME_PROPERTY_KEY, file);
+ }
+ setSource(file);
+ }
+
+ public void initI18n() {
+ I18n.initISO88591(getUserLanguage().name(), getUserCountry().name());
+ }
+
+ protected void loadFromOptions(SimExplorerOptionParser parser) {
+ if (!parser.isOptionEnabled(SimExplorerOptionParser.CONFIG_OPTION_KEY)) {
+ return;
+ }
+ // surcharge config file
+ for (SimExplorerOptionConfig option : SimExplorerOptionParser.CONFIG_OPTION_KEY.getOptions()) {
+ if (getCategory().equals(SimExplorerOptionParser.MAIN_CONFIG_KEY.getCategory())) {
+ ConfigPropertyKey<?> propKey = getPropertyKey(option.getKey());
+ if (propKey == null) {
+ // fatal error , could not found a matching configuration property
+ throw new SimExplorerRuntimeException(_("simexplorer.error.unfound.config.property", category, option.getKey()));
+ }
+ Object oldVal = propKey.getCurrentValue();
+ setProperty(propKey, option.getValue());
+ Object newVal = propKey.getCurrentValue();
+ log.info(_("simexplorer.change.config.property", category, propKey, oldVal, newVal));
+ }
+ }
+ }
+
+ public void setI18n(LanguageEnum language, CountryEnum country) {
+ setUserLanguage(language);
+ setUserCountry(country);
+ }
+}
\ No newline at end of file
Copied: trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/SimExplorerContext.java (from rev 1132, trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/SimExplorerContext.java)
===================================================================
--- trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/SimExplorerContext.java (rev 0)
+++ trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/SimExplorerContext.java 2008-02-20 18:46:01 UTC (rev 1145)
@@ -0,0 +1,198 @@
+/*
+* ##% Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008 Code Lutin,
+* Tony Chemit, Gabriel Landais
+*
+* 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 fr.cemagref.simexplorer.is.ui.swing;
+
+import fr.cemagref.simexplorer.is.exceptions.SimExplorerRuntimeException;
+import fr.cemagref.simexplorer.is.ui.SimExplorerOptionParser;
+import fr.cemagref.simexplorer.is.ui.actions.SimExplorerCommonActions;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.codelutin.option.ParserException;
+
+import java.io.BufferedOutputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+
+/**
+ * Le context de l'application, implanté en singleton.
+ * <p/>
+ * Contient la configuration de l'application, le parseur d'options,...
+ *
+ * @author chemit
+ */
+public class SimExplorerContext {
+
+ /** to use log facility, just put in your code: log.info(\"...\"); */
+ static private Log log = LogFactory.getLog(SimExplorerContext.class);
+
+ /**
+ * le parseur utilisé au démarrage pour récupérer les options passées
+ * par l'utilisateur.
+ */
+ protected SimExplorerOptionParser parser;
+
+ /** flag pour indiquer si 'lon veut quitter l'appli après les options */
+ protected boolean quit;
+
+ /** flag pour indiquer si l'on affiche ou non l'ui principale */
+ protected boolean launchUI = true;
+
+ /**
+ * flag pour indiquer une première utilisation de l'application (pas de
+ * fichier de configuration)
+ */
+ protected boolean firstLaunch;
+
+ /** le token pour la connexion au serveur distant */
+ protected String token;
+
+ /**
+ * @return le parseur utilisé pour parser les options de la ligne de
+ * commande.
+ */
+ public SimExplorerOptionParser getParser() {
+ if (parser == null) {
+ // creation du parseur
+ parser = new SimExplorerOptionParser();
+ // enregistrement des actions concretes
+ parser.registerActions(SimExplorerCommonActions.class);
+ // enregistrement des configs concretes
+ parser.registerConfig(SimExplorerConfig.class);
+ }
+ return parser;
+ }
+
+ /** @return la configuration de l'application */
+ public SimExplorerConfig getConfig() {
+ return (SimExplorerConfig) getParser().getMainConfig();
+ }
+
+ /**
+ * @return <code>true</code> si l'utilisateur est connecté,
+ * <code>false</code> sinon.
+ */
+ public boolean isConnected() {
+ return !(token == null || token.isEmpty());
+ }
+
+ /**
+ * Sauvegarde la configuration courante de l'utilisateur.
+ *
+ * @throws IOException si problème lors de l'écriture du fichier de configuration
+ */
+ public void save() throws IOException {
+ if (getConfig().getSource() == null) {
+ return;
+ }
+ BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(getConfig().getSource()));
+ try {
+ getConfig().save(out);
+ } finally {
+ out.flush();
+ out.close();
+ }
+ }
+
+ /**
+ * Sauvegarde la configuration de l'utilisateur sans soulever d'exception
+ * si un problème est survenu lors de l'opération.
+ */
+ public void saveSafely() {
+ try {
+ save();
+ } catch (Exception e) {
+ log.warn("simexplorer.error.unsafe.save.config" + e.getMessage(), e);
+ }
+ }
+
+ /**
+ * @return <code>true</code> si on doit quitter l'application (uniquement utilisé
+ * lors du démarrage de l'application lors de l'exécution des options
+ * utilisateurs)
+ */
+ public boolean isQuit() {
+ return quit;
+ }
+
+ /**
+ * @return <code>true</code> si on doit lancer l'ui au démarrage de
+ * l'application, après avoir traité toutes les options utilisateurs
+ */
+ public boolean isLaunchUI() {
+ return launchUI;
+ }
+
+ /**
+ * @return <code>true</code> s'il s'agit de la première utilisation de
+ * l'application (aucun de fichier de configuration trouvé)
+ */
+ public boolean isFirstLaunch() {
+ return firstLaunch;
+ }
+
+ /**
+ * @return le token utilisé pour identifié l'utilisateur sur le serveur distant.
+ * <p/>
+ * <b>Si est null ou vide cela veut que l'utilisateur n'est pas connecté.</b>
+ */
+ public String getToken() {
+ return token;
+ }
+
+ public void setQuit(boolean quit) {
+ this.quit = quit;
+ }
+
+ public void setLaunchUI(boolean launchUI) {
+ this.launchUI = launchUI;
+ }
+
+ public void setFirstLaunch(boolean firstLaunch) {
+ this.firstLaunch = firstLaunch;
+ }
+
+ public void setToken(String token) {
+ this.token = token;
+ }
+
+ /** restricted access constructor */
+ SimExplorerContext() {
+
+ }
+
+ /**
+ * Initialisation du parseur d'options.
+ *
+ * @param args les arguments passés au démarrage de l'application
+ */
+ void initParser(String... args) {
+ try {
+ getParser().doParse(args);
+ } catch (ParserException e) {
+ throw new SimExplorerRuntimeException(e);
+ } catch (IOException e) {
+ throw new SimExplorerRuntimeException(e);
+ }
+ }
+
+ /** Initialisation de la configuration utilisateur */
+ void initConfig() {
+ getConfig().initI18n();
+ }
+}
Copied: trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/StorageServiceHelper.java (from rev 1132, trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/StorageServiceHelper.java)
===================================================================
--- trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/StorageServiceHelper.java (rev 0)
+++ trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/StorageServiceHelper.java 2008-02-20 18:46:01 UTC (rev 1145)
@@ -0,0 +1,245 @@
+/*
+* ##% Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008 Code Lutin,
+* Tony Chemit, Gabriel Landais
+*
+* 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 fr.cemagref.simexplorer.is.ui.swing;
+
+import com.healthmarketscience.rmiio.SerializableInputStream;
+import fr.cemagref.simexplorer.is.entities.attachment.Attachment;
+import fr.cemagref.simexplorer.is.entities.data.LoggableElement;
+import fr.cemagref.simexplorer.is.entities.metadata.MetaData;
+import fr.cemagref.simexplorer.is.entities.metadata.Version;
+import fr.cemagref.simexplorer.is.exceptions.SimExplorerException;
+import fr.cemagref.simexplorer.is.exceptions.SimExplorerRuntimeException;
+import fr.cemagref.simexplorer.is.exceptions.UnreachableServiceException;
+import fr.cemagref.simexplorer.is.service.MockStorageServiceImpl;
+import fr.cemagref.simexplorer.is.service.StorageService;
+import fr.cemagref.simexplorer.is.service.StorageServiceClient;
+import static fr.cemagref.simexplorer.is.service.StorageServiceHelper.STORAGE_SERVICE_LOOKUP_NAME;
+
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import java.io.BufferedInputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.InputStream;
+import java.net.URI;
+import java.util.Properties;
+
+/**
+ * Une classe pour encapsuler les appels aux services Storage et leur initialisation.
+ *
+ * @author chemit
+ */
+public class StorageServiceHelper {
+
+ private final static boolean mock = false;
+
+ private final static String PROVIDER_URL = "java.naming.provider.url";
+ private final static String FACTORY_INITIAL = "java.naming.factory.initial";
+ private final static String FACTORY_URL_PKGS = "java.naming.factory.url.pkgs";
+
+ /** le service de données distant */
+ protected static StorageService remoteStorageService;
+
+ /** le service de données local */
+ protected static StorageService storageService;
+
+ /**
+ * @param context le context de l'application
+ * @param remote flag pour indiquer le type de service recherché (local ou remote)
+ * @return le service instancié et initialisé
+ * @throws UnreachableServiceException si service non joignable
+ */
+ public static StorageService getService(SimExplorerContext context, boolean remote) throws UnreachableServiceException {
+ StorageService service;
+ service = remote ? getRemoteStorageService(context) : getLocalStorageService();
+ if (service == null) {
+ throw new UnreachableServiceException("could not find service " + (remote ? "remote" : "local"));
+ }
+ return service;
+ }
+
+ public static int getCount(SimExplorerContext context, boolean remote, String query, boolean onlyLatest) {
+ StorageService service = getService(context, remote);
+ String token = context.getToken();
+ int size;
+ try {
+ if (query == null || query.isEmpty()) {
+ size = service.findApplicationsCount(token, onlyLatest);
+ } else {
+ size = service.findFullTextCount(token, query, onlyLatest);
+ }
+ return size;
+ } catch (SimExplorerException e) {
+ throw new SimExplorerRuntimeException(e);
+ }
+ }
+
+ public static String loginUser(SimExplorerContext context, boolean remote, String login, String hashPassword) throws UnreachableServiceException {
+ StorageService service = getService(context, remote);
+ try {
+ String token;
+ token = service.loginUser(login, hashPassword);
+ return token;
+ } catch (SimExplorerException e) {
+ throw new SimExplorerRuntimeException(e);
+ }
+ }
+
+ public static MetaData[] getData(SimExplorerContext context, boolean remote, boolean onlyLatest, String query, long newFirstIndex, int width, int rowOrder) {
+ StorageService service = getService(context, remote);
+ String token = context.getToken();
+ try {
+ MetaData[] data;
+ if (query == null || query.isEmpty()) {
+ data = service.findApplications(token, onlyLatest, (int) newFirstIndex, width, rowOrder);
+ } else {
+ data = service.findFullText(token, query, onlyLatest, (int) newFirstIndex, width, rowOrder);
+ }
+ return data;
+ } catch (SimExplorerException e) {
+ throw new SimExplorerRuntimeException(e);
+ }
+ }
+
+
+ public static LoggableElement getElement(SimExplorerContext context, boolean remote, String uuid, String version) {
+ try {
+ LoggableElement data;
+ data = getService(context, remote).getLoggableElement(context.getToken(), uuid, version);
+ return data;
+ } catch (SimExplorerException e1) {
+ throw new SimExplorerRuntimeException(e1);
+ }
+ }
+
+ public static void deleteElement(SimExplorerContext context, boolean remote, String uuid, String version) {
+ try {
+ getService(context, remote).deleteElement(context.getToken(), uuid, version);
+ } catch (SimExplorerException e1) {
+ throw new SimExplorerRuntimeException(e1);
+ }
+ }
+
+ public static MetaData getMetaData(SimExplorerContext context, boolean remote, String uuid, String version) {
+ try {
+ MetaData metas;
+ metas = getService(context, remote).getMetadata(context.getToken(), uuid, version);
+ return metas;
+ } catch (SimExplorerException e1) {
+ throw new SimExplorerRuntimeException(e1);
+ }
+ }
+
+
+ public static BufferedInputStream retrieveElementFull(SimExplorerContext context, boolean remote, String uuid, String version) {
+ try {
+ InputStream stream = getService(context, remote).retrieveElementFull(context.getToken(), uuid, version);
+ BufferedInputStream bis;
+ bis = new BufferedInputStream(stream);
+ return bis;
+ } catch (SimExplorerException e1) {
+ throw new SimExplorerRuntimeException(e1);
+ }
+ }
+
+ public static BufferedInputStream retrieveElementData(SimExplorerContext context, boolean remote, String uuid, String version, Attachment attachment) {
+ try {
+ InputStream stream = getService(context, remote).retrieveElementData(context.getToken(), uuid, version, attachment);
+ BufferedInputStream bis;
+ bis = new BufferedInputStream(stream);
+ return bis;
+ } catch (SimExplorerException e1) {
+ throw new SimExplorerRuntimeException(e1);
+ }
+ }
+
+ public static void importElement(SimExplorerContext context, boolean remote, File file) {
+ try {
+ SerializableInputStream zipStream;
+ zipStream = new SerializableInputStream(new FileInputStream(file));
+ getService(context, remote).saveElement(context.getToken(), zipStream);
+ } catch (Exception e) {
+ throw new SimExplorerRuntimeException(e);
+ }
+ }
+
+ public static Version[] getVersions(SimExplorerContext context, boolean remote, String uuid) {
+ try {
+ Version[] result;
+ result = getService(context, remote).getVersions(context.getToken(), uuid);
+ return result;
+ } catch (SimExplorerException e) {
+ throw new SimExplorerRuntimeException(e);
+ }
+ }
+
+ /** @return le service de storage locale */
+ protected static StorageService getLocalStorageService() {
+ if (storageService == null) {
+ if (mock) {
+ return storageService = new MockStorageServiceImpl(false);
+ }
+ try {
+ storageService = new StorageServiceClient();
+ } catch (Exception e) {
+ throw new SimExplorerRuntimeException(e);
+ }
+ }
+ return storageService;
+ }
+
+ /**
+ * @param context le context de l'application
+ * @return le service de storage distant
+ */
+ protected static StorageService getRemoteStorageService(SimExplorerContext context) {
+ if (remoteStorageService == null) {
+ if (mock) {
+ return remoteStorageService = new MockStorageServiceImpl(true);
+ }
+ try {
+ Properties props = initProperties(context.getConfig().getRemoteURI());
+ Context context2;
+ try {
+ context2 = new InitialContext(props);
+ } catch (Exception e) {
+ context2 = new InitialContext();
+ }
+ remoteStorageService = (StorageService) context2.lookup(STORAGE_SERVICE_LOOKUP_NAME);
+ } catch (NamingException e) {
+ // no remote service available
+ remoteStorageService = null;
+ }
+ }
+ return remoteStorageService;
+ }
+
+ protected static Properties initProperties(URI uri) {
+ Properties props = (Properties) System.getProperties().clone();
+ props.put(PROVIDER_URL, uri.toString());
+ props.put(FACTORY_INITIAL, "org.jnp.interfaces.NamingContextFactory");
+ props.put(FACTORY_URL_PKGS, "org.jnp.interfaces");
+ return props;
+ }
+
+ protected StorageServiceHelper() {
+ // no instance
+ }
+}
Modified: trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/AboutAction.java
===================================================================
--- trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/AboutAction.java 2008-02-20 18:45:27 UTC (rev 1144)
+++ trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/AboutAction.java 2008-02-20 18:46:01 UTC (rev 1145)
@@ -18,8 +18,8 @@
* ##% */
package fr.cemagref.simexplorer.is.ui.swing.actions;
+import fr.cemagref.simexplorer.is.exceptions.SimExplorerRuntimeException;
import fr.cemagref.simexplorer.is.ui.swing.actions.util.SimExplorerAbstractAction;
-import fr.cemagref.simexplorer.is.exceptions.SimExplorerRuntimeException;
import java.awt.event.ActionEvent;
@@ -48,6 +48,6 @@
@Override
protected void doAction(ActionEvent e) throws Exception {
super.doAction(e);
- throw new SimExplorerRuntimeException(this+" is not implemented yet!");
+ throw new SimExplorerRuntimeException(this + " is not implemented yet!");
}
}
\ No newline at end of file
Modified: trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/ChangePageAction.java
===================================================================
--- trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/ChangePageAction.java 2008-02-20 18:45:27 UTC (rev 1144)
+++ trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/ChangePageAction.java 2008-02-20 18:46:01 UTC (rev 1145)
@@ -18,13 +18,15 @@
* ##% */
package fr.cemagref.simexplorer.is.ui.swing.actions;
-import fr.cemagref.simexplorer.is.ui.swing.JListTab;
+import fr.cemagref.simexplorer.is.ui.swing.ui.JListTab;
import fr.cemagref.simexplorer.is.ui.swing.SimExplorerActionManager;
-import fr.cemagref.simexplorer.is.ui.swing.SimExplorerTab;
import fr.cemagref.simexplorer.is.ui.swing.actions.util.SimExplorerAbstractTabAction;
import fr.cemagref.simexplorer.is.ui.swing.model.ListTabModel;
-import fr.cemagref.simexplorer.is.ui.swing.model.PaginationModel;
import fr.cemagref.simexplorer.is.ui.swing.model.ListTableModel;
+import fr.cemagref.simexplorer.is.ui.swing.model.PaginationModel;
+import fr.cemagref.simexplorer.is.ui.swing.ui.SimExplorerTab;
+import jaxx.runtime.JAXXObject;
+import jaxx.runtime.swing.JAXXTab;
import javax.swing.AbstractAction;
import javax.swing.Action;
@@ -32,9 +34,6 @@
import javax.swing.JComponent;
import java.awt.event.ActionEvent;
-import jaxx.runtime.swing.JAXXTab;
-import jaxx.runtime.JAXXObject;
-
/**
* Action pour lancer une recherche d'application
*
@@ -60,11 +59,11 @@
@Override
protected boolean beforeAction(ActionEvent e) throws Exception {
SimExplorerTab myTab = findTab(e);
- if (myTab==null) {
+ if (myTab == null) {
return false;
}
JComboBox jComboBox = getChangePageComboBox(myTab.getUI());
- if (jComboBox==null || !jComboBox.isEnabled()) {
+ if (jComboBox == null || !jComboBox.isEnabled()) {
return false;
}
ListTabModel model = (ListTabModel) myTab.getModel();
@@ -89,14 +88,14 @@
pagination.setFirstIndex(newFirstIndex);
// update model
- model.updateTabModel(getContext(), (ListTableModel) ((JListTab) getUI()).getTable().getModel());
+ model.updateTabModel(getContext(), (ListTableModel) ((JListTab) getUI()).getTable().getModel(), false);
}
@Override
public void updateUI() {
super.updateUI();
// refresh ui
- getTab().updateUI();
+ getTab().updateUI(getContext(),getMainUI());
}
@Override
@@ -106,7 +105,7 @@
}
//TODO Suppress this code
- protected JComboBox getChangePageComboBox(JAXXTab myTab) {
+ protected JComboBox getChangePageComboBox(JAXXTab myTab) {
JComponent uiObject = getUIObject((String) getValue(Action.ACTION_COMMAND_KEY), (JAXXObject) myTab);
if (uiObject instanceof JComboBox) {
return (JComboBox) uiObject;
Modified: trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/ChangeSizorAction.java
===================================================================
--- trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/ChangeSizorAction.java 2008-02-20 18:45:27 UTC (rev 1144)
+++ trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/ChangeSizorAction.java 2008-02-20 18:46:01 UTC (rev 1145)
@@ -19,7 +19,7 @@
package fr.cemagref.simexplorer.is.ui.swing.actions;
import fr.cemagref.simexplorer.is.entities.metadata.MetaData;
-import fr.cemagref.simexplorer.is.ui.swing.JListTab;
+import fr.cemagref.simexplorer.is.ui.swing.ui.JListTab;
import fr.cemagref.simexplorer.is.ui.swing.actions.util.SimExplorerAbstractTabAction;
import fr.cemagref.simexplorer.is.ui.swing.model.ListTabModel;
import fr.cemagref.simexplorer.is.ui.swing.model.ListTableModel;
@@ -45,6 +45,7 @@
protected Integer newWidth;
protected ListTabModel model;
+
public ChangeSizorAction(String name) {
super(name);
}
@@ -73,18 +74,16 @@
} else {
getContext().getConfig().setLocalSizor(newWidth);
}
- // on supprime la pagination actuelle, elle sera recalculé dans l'update
- model.setPagination(null);
model.synch(remote, (MetaData) null);
// update model
- model.updateTabModel(getContext(), (ListTableModel) ((JListTab) getUI()).getTable().getModel());
+ model.updateTabModel(getContext(), (ListTableModel) ((JListTab) getUI()).getTable().getModel(), true);
}
@Override
public void updateUI() {
super.updateUI();
// refresh ui
- getTab().updateUI();
+ getTab().updateUI(getContext(),getMainUI());
}
@Override
@@ -92,7 +91,7 @@
// multi-tab action
setTab(null);
newWidth = null;
- model=null;
+ model = null;
}
protected JComboBox getComboBox() {
Modified: trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/CloseTabAction.java
===================================================================
--- trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/CloseTabAction.java 2008-02-20 18:45:27 UTC (rev 1144)
+++ trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/CloseTabAction.java 2008-02-20 18:46:01 UTC (rev 1145)
@@ -43,7 +43,7 @@
public CloseTabAction() {
super("closeTab");
}
-
+
public CloseTabAction(String name) {
super(name, "closeTab");
}
@@ -55,7 +55,7 @@
@Override
protected void doAction(ActionEvent e) throws Exception {
- getTab().closeTab(getTabContainer());
+ getTab().closeTab(getMainUI(), getTabContainer());
}
@Override
Modified: trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/CollapseAllAction.java
===================================================================
--- trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/CollapseAllAction.java 2008-02-20 18:45:27 UTC (rev 1144)
+++ trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/CollapseAllAction.java 2008-02-20 18:46:01 UTC (rev 1145)
@@ -18,9 +18,9 @@
* ##% */
package fr.cemagref.simexplorer.is.ui.swing.actions;
-import fr.cemagref.simexplorer.is.ui.swing.EntityTreeNodeHelper;
import fr.cemagref.simexplorer.is.ui.swing.actions.util.SimExplorerAbstractTabAction;
import fr.cemagref.simexplorer.is.ui.swing.model.EntityTreeNode;
+import fr.cemagref.simexplorer.is.ui.swing.ui.EntityTreeNodeHelper;
import javax.swing.JTree;
import java.awt.event.ActionEvent;
@@ -61,7 +61,7 @@
}
tree = getTreeForAction("collapseAll", getActionName());
- node = EntityTreeNodeHelper.getSelectedNodeOrRootNode(tree);
+ node = EntityTreeNodeHelper.getSelectedNodeOrRootNode(tree);
return !(node == null || node.isLeaf());
}
Modified: trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/ConnectAction.java
===================================================================
--- trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/ConnectAction.java 2008-02-20 18:45:27 UTC (rev 1144)
+++ trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/ConnectAction.java 2008-02-20 18:46:01 UTC (rev 1145)
@@ -22,17 +22,17 @@
import fr.cemagref.simexplorer.is.exceptions.SimExplorerRuntimeException;
import fr.cemagref.simexplorer.is.exceptions.UnreachableServiceException;
import fr.cemagref.simexplorer.is.service.AuthenticationServiceHelper;
-import fr.cemagref.simexplorer.is.ui.StorageServiceHelper;
-import fr.cemagref.simexplorer.is.ui.swing.DetailTabRefreshHelper;
-import fr.cemagref.simexplorer.is.ui.swing.JDetailTab;
-import fr.cemagref.simexplorer.is.ui.swing.JListTab;
-import fr.cemagref.simexplorer.is.ui.swing.ListTabRefreshHelper;
-import fr.cemagref.simexplorer.is.ui.swing.LoginUI;
-import fr.cemagref.simexplorer.is.ui.swing.SimExplorerMainUI;
-import fr.cemagref.simexplorer.is.ui.swing.SimExplorerTab;
+import fr.cemagref.simexplorer.is.ui.swing.ui.JDetailTab;
+import fr.cemagref.simexplorer.is.ui.swing.ui.JListTab;
+import fr.cemagref.simexplorer.is.ui.swing.ui.LoginUI;
+import fr.cemagref.simexplorer.is.ui.swing.StorageServiceHelper;
import fr.cemagref.simexplorer.is.ui.swing.actions.util.SimExplorerAbstractAction;
import fr.cemagref.simexplorer.is.ui.swing.model.DetailTabModel;
import fr.cemagref.simexplorer.is.ui.swing.model.ListTabModel;
+import fr.cemagref.simexplorer.is.ui.swing.ui.DetailTabRefreshHelper;
+import fr.cemagref.simexplorer.is.ui.swing.ui.ListTabRefreshHelper;
+import fr.cemagref.simexplorer.is.ui.swing.ui.SimExplorerMainUI;
+import fr.cemagref.simexplorer.is.ui.swing.ui.SimExplorerTab;
import static org.codelutin.i18n.I18n._;
import javax.swing.JOptionPane;
@@ -75,7 +75,7 @@
return false;
}
initLoginUI();
- return true;
+ return getService();
}
@Override
@@ -114,14 +114,14 @@
JDetailTab tabUI = (JDetailTab) SimExplorerTab.detail.getUI();
if (SimExplorerTab.detail.isTabVisible(container)) {
- DetailTabRefreshHelper.refreshSynchroniseAction(tabUI, model);
- DetailTabRefreshHelper.refreshExportAction(tabUI, model);
+ DetailTabRefreshHelper.refreshSynchroniseAction(getContext(), tabUI, model);
+ DetailTabRefreshHelper.refreshExportAction(getContext(),tabUI, model);
}
if (SimExplorerTab.local.isTabVisible(container)) {
ListTabModel localListModel = (ListTabModel) SimExplorerTab.local.getModel();
if (!localListModel.isEmpty()) {
- ListTabRefreshHelper.refreshListTablePopupMenu((JListTab) SimExplorerTab.local.getUI(), localListModel);
+ ListTabRefreshHelper.refreshListTablePopupMenu(getContext(), (JListTab) SimExplorerTab.local.getUI(), localListModel);
}
}
// }
@@ -135,8 +135,28 @@
}
}
+ protected boolean getService() {
+ // first test if service is enable
+ boolean ok = false;
+ while (true) {
+ try {
+ StorageServiceHelper.getService(getContext(), true);
+ ok = true;
+ break;
+ } catch (UnreachableServiceException e) {
+ if (failedToReachService()) {
+ break;
+ }
+ }
+ }
+ return ok;
+ }
+
+ protected boolean failedToReachService() {
+ int result = JOptionPane.showConfirmDialog(ui, _("simexplorer.login.retry"), _("simexplorer.error.service.failed"), JOptionPane.YES_NO_OPTION, JOptionPane.ERROR_MESSAGE);
+ return result == JOptionPane.NO_OPTION;
+ }
-
private class MyLoginUIHandler extends LoginUI.LoginUIHandler {
/**
* Tente de se connecter au service.
@@ -178,10 +198,6 @@
}
}
- protected boolean failedToReachService() {
- int result = JOptionPane.showConfirmDialog(ui, _("simexplorer.login.retry"), _("simexplorer.error.service.failed"), JOptionPane.YES_NO_OPTION, JOptionPane.ERROR_MESSAGE);
- return result == JOptionPane.NO_OPTION;
- }
protected boolean failedToConnect() {
int result = JOptionPane.showConfirmDialog(ui, _("simexplorer.login.retry"), _("simexplorer.error.login.failed"), JOptionPane.YES_NO_OPTION, JOptionPane.ERROR_MESSAGE);
@@ -190,20 +206,9 @@
public void doConnect() {
setCancel(false);
- // first test if service is enable
- while (true) {
- try {
- StorageServiceHelper.getService(getContext(), true);
- break;
- } catch (UnreachableServiceException e) {
- if (failedToReachService()) {
- setCancel(true);
- break;
- }
- }
- }
- if (isCancel()) {
- log.warn("could not find remote service ");
+ if (!getService()) {
+ log.warn("could not find remote service ");
+ setCancel(true);
return;
}
if (!connect(ui.getLogin().getText(), ui.getPassword().getPassword())) {
@@ -215,6 +220,7 @@
}
}
+
public void doCancel() {
setCancel(false);
ui.getLogin().setText(null);
Modified: trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/DeleteElementAction.java
===================================================================
--- trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/DeleteElementAction.java 2008-02-20 18:45:27 UTC (rev 1144)
+++ trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/DeleteElementAction.java 2008-02-20 18:46:01 UTC (rev 1145)
@@ -19,16 +19,16 @@
package fr.cemagref.simexplorer.is.ui.swing.actions;
import fr.cemagref.simexplorer.is.entities.data.LoggableElement;
-import fr.cemagref.simexplorer.is.ui.StorageServiceHelper;
-import fr.cemagref.simexplorer.is.ui.swing.JListTab;
+import fr.cemagref.simexplorer.is.ui.swing.ui.JListTab;
import fr.cemagref.simexplorer.is.ui.swing.SimExplorerActionManager;
-import fr.cemagref.simexplorer.is.ui.swing.SimExplorerTab;
-import fr.cemagref.simexplorer.is.ui.swing.SynchronizeTabRefreshHelper;
+import fr.cemagref.simexplorer.is.ui.swing.StorageServiceHelper;
import fr.cemagref.simexplorer.is.ui.swing.actions.util.SimExplorerAbstractTabAction;
import fr.cemagref.simexplorer.is.ui.swing.model.DataEntityModel;
import fr.cemagref.simexplorer.is.ui.swing.model.ListTabModel;
import fr.cemagref.simexplorer.is.ui.swing.model.ListTableModel;
import fr.cemagref.simexplorer.is.ui.swing.model.SynchronizeTabModel;
+import fr.cemagref.simexplorer.is.ui.swing.ui.SimExplorerTab;
+import fr.cemagref.simexplorer.is.ui.swing.ui.SynchronizeTabRefreshHelper;
import static org.codelutin.i18n.I18n._;
import javax.swing.JOptionPane;
@@ -107,7 +107,6 @@
if (SimExplorerTab.synchronize.isTabVisible(getTabContainer())) {
updateSynchronizeTab();
}
-
}
protected void updateListTab() {
@@ -125,9 +124,8 @@
model = (ListTabModel) tab.getModel();
ui = (JListTab) tab.getUI();
}
- model.setPagination(null);
- model.updateTabModel(getContext(), (ListTableModel) ui.getTable().getModel());
- tab.updateUI();
+ model.updateTabModel(getContext(), (ListTableModel) ui.getTable().getModel(), true);
+ tab.updateUI(getContext(),getMainUI());
}
protected void updateSynchronizeTab() {
@@ -144,7 +142,11 @@
if (item != null && item.getMetaData().getUuid() != null && item.getMetaData().getUuid().equals(selected.getUuid())) {
model.setRootNode(null, modelIsRemote);
}
- SynchronizeTabRefreshHelper.updateTree(getTabContainer(), oldLocalRoot, oldRemoteRoot);
+ if (model.getSource().isRemote() == modelIsRemote) {
+ // invalidate
+ model.getSource().setRemote(!modelIsRemote);
+ }
+ SynchronizeTabRefreshHelper.updateTree(getMainUI(), getTabContainer(), oldLocalRoot, oldRemoteRoot);
}
@Override
Modified: trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/DetailToTreeAction.java
===================================================================
--- trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/DetailToTreeAction.java 2008-02-20 18:45:27 UTC (rev 1144)
+++ trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/DetailToTreeAction.java 2008-02-20 18:46:01 UTC (rev 1145)
@@ -20,13 +20,13 @@
import fr.cemagref.simexplorer.is.entities.data.LoggableElement;
import fr.cemagref.simexplorer.is.entities.metadata.Version;
-import fr.cemagref.simexplorer.is.ui.StorageServiceHelper;
-import fr.cemagref.simexplorer.is.ui.swing.DetailTabRefreshHelper;
-import fr.cemagref.simexplorer.is.ui.swing.JDetailTab;
+import fr.cemagref.simexplorer.is.ui.swing.ui.JDetailTab;
+import fr.cemagref.simexplorer.is.ui.swing.StorageServiceHelper;
import fr.cemagref.simexplorer.is.ui.swing.actions.util.SimExplorerAbstractTabAction;
import fr.cemagref.simexplorer.is.ui.swing.model.DetailTabModel;
import fr.cemagref.simexplorer.is.ui.swing.model.EntityTreeNode;
-import fr.cemagref.simexplorer.is.ui.swing.EntityTreeNodeHelper;
+import fr.cemagref.simexplorer.is.ui.swing.ui.DetailTabRefreshHelper;
+import fr.cemagref.simexplorer.is.ui.swing.ui.EntityTreeNodeHelper;
import java.awt.event.ActionEvent;
Modified: trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/DownloadAttachmentAction.java
===================================================================
--- trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/DownloadAttachmentAction.java 2008-02-20 18:45:27 UTC (rev 1144)
+++ trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/DownloadAttachmentAction.java 2008-02-20 18:46:01 UTC (rev 1145)
@@ -19,11 +19,11 @@
package fr.cemagref.simexplorer.is.ui.swing.actions;
import fr.cemagref.simexplorer.is.entities.attachment.Attachment;
-import fr.cemagref.simexplorer.is.ui.StorageServiceHelper;
+import fr.cemagref.simexplorer.is.ui.swing.StorageServiceHelper;
import fr.cemagref.simexplorer.is.ui.swing.actions.util.DownloadAbstractAction;
import fr.cemagref.simexplorer.is.ui.swing.model.DetailTabModel;
+import static org.codelutin.i18n.I18n._;
import org.codelutin.util.FileUtil;
-import static org.codelutin.i18n.I18n._;
import java.io.BufferedInputStream;
import java.io.File;
@@ -61,7 +61,7 @@
return null;
}
// ask user path where to save data
- String dir = FileUtil.getDirectory(_("simexplorer.action.download.attachment", attachment.getFileName(),selected.getMeta().getName() + " [" + selected.getVersion() + "]"), _("simexplorer.choose.dir"));
+ String dir = FileUtil.getDirectory(_("simexplorer.action.download.attachment", attachment.getFileName(), selected.getMeta().getName() + " [" + selected.getVersion() + "]"), _("simexplorer.choose.dir"));
if (dir == null) {
// user cancel action
return null;
Modified: trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/DownloadElementAction.java
===================================================================
--- trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/DownloadElementAction.java 2008-02-20 18:45:27 UTC (rev 1144)
+++ trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/DownloadElementAction.java 2008-02-20 18:46:01 UTC (rev 1145)
@@ -18,7 +18,7 @@
* ##% */
package fr.cemagref.simexplorer.is.ui.swing.actions;
-import fr.cemagref.simexplorer.is.ui.StorageServiceHelper;
+import fr.cemagref.simexplorer.is.ui.swing.StorageServiceHelper;
import fr.cemagref.simexplorer.is.ui.swing.actions.util.DownloadAbstractAction;
import static org.codelutin.i18n.I18n._;
import org.codelutin.util.FileUtil;
Modified: trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/ExpandAllAction.java
===================================================================
--- trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/ExpandAllAction.java 2008-02-20 18:45:27 UTC (rev 1144)
+++ trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/ExpandAllAction.java 2008-02-20 18:46:01 UTC (rev 1145)
@@ -18,9 +18,9 @@
* ##% */
package fr.cemagref.simexplorer.is.ui.swing.actions;
-import fr.cemagref.simexplorer.is.ui.swing.EntityTreeNodeHelper;
import fr.cemagref.simexplorer.is.ui.swing.actions.util.SimExplorerAbstractTabAction;
import fr.cemagref.simexplorer.is.ui.swing.model.EntityTreeNode;
+import fr.cemagref.simexplorer.is.ui.swing.ui.EntityTreeNodeHelper;
import javax.swing.JTree;
import java.awt.event.ActionEvent;
@@ -61,7 +61,7 @@
return false;
}
tree = getTreeForAction("expandAll", getActionName());
- node = EntityTreeNodeHelper.getSelectedNodeOrRootNode(tree);
+ node = EntityTreeNodeHelper.getSelectedNodeOrRootNode(tree);
return !(node == null || node.isLeaf());
}
Modified: trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/ExportElementAction.java
===================================================================
--- trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/ExportElementAction.java 2008-02-20 18:45:27 UTC (rev 1144)
+++ trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/ExportElementAction.java 2008-02-20 18:46:01 UTC (rev 1145)
@@ -18,31 +18,32 @@
* ##% */
package fr.cemagref.simexplorer.is.ui.swing.actions;
+import fr.cemagref.simexplorer.is.entities.data.LoggableElement;
import fr.cemagref.simexplorer.is.service.StorageService;
-import fr.cemagref.simexplorer.is.ui.StorageServiceHelper;
-import fr.cemagref.simexplorer.is.ui.swing.JListTab;
-import fr.cemagref.simexplorer.is.ui.swing.SimExplorerActionManager;
-import fr.cemagref.simexplorer.is.ui.swing.SimExplorerTab;
+import fr.cemagref.simexplorer.is.ui.swing.ui.JListTab;
+import fr.cemagref.simexplorer.is.ui.swing.StorageServiceHelper;
import fr.cemagref.simexplorer.is.ui.swing.actions.util.SimExplorerAbstractTabAction;
import fr.cemagref.simexplorer.is.ui.swing.model.DataEntityModel;
import fr.cemagref.simexplorer.is.ui.swing.model.DetailTabModel;
import fr.cemagref.simexplorer.is.ui.swing.model.ListTabModel;
import fr.cemagref.simexplorer.is.ui.swing.model.ListTableModel;
import fr.cemagref.simexplorer.is.ui.swing.model.SimExplorerTabModel;
+import fr.cemagref.simexplorer.is.ui.swing.model.SynchronizeTabModel;
+import fr.cemagref.simexplorer.is.ui.swing.ui.SimExplorerTab;
+import fr.cemagref.simexplorer.is.ui.swing.ui.SynchronizeTabRefreshHelper;
import jaxx.runtime.builder.TabModel;
import static org.codelutin.i18n.I18n.n_;
import java.awt.event.ActionEvent;
/**
- * Action pour exporter une application
+ * Action pour exporter un élément
*
* @author chemit
*/
@jaxx.runtime.builder.ActionConfig(
actionCommand = "exportElement",
name = "simexplorer.action.exportElement",
- //shortDescription = "simexplorer.action.exportElement.tooltip",
longDescription = "simexplorer.action.exportElement.help",
smallIcon = "action/export-element.png",
mnemonic = 'x',
@@ -50,11 +51,14 @@
)
public class ExportElementAction extends SimExplorerAbstractTabAction {
- private static final long serialVersionUID = 7535647131305304738L;
-
+ /** le modèle de sélection */
protected DataEntityModel selected;
+ /** le service d'origine */
+ protected StorageService fromService;
+ /** le service où exporter */
+ protected StorageService toService;
- protected StorageService fromService, toService;
+ private static final long serialVersionUID = 7535647131305304738L;
public ExportElementAction(String name) {
super(name);
@@ -62,7 +66,6 @@
@Override
public String getI18nToolTipText() {
-
return getI18nToolTipText(selected != null && selected.isRemote());
}
@@ -121,34 +124,46 @@
@Override
public void updateUI() {
- // on doit invalider les données apres un export
+
+ updateListTab();
+
+ // update detail model (delegue a l'action d'historique quand elle sera presente)
+
+ if (SimExplorerTab.synchronize.isTabVisible(getTabContainer())) {
+ updateSynchronizeTab();
+ }
+ }
+
+ protected void updateListTab() {
ListTabModel model;
JListTab ui;
SimExplorerTab tab;
- if (selected.isRemote()) {
- // reinit de la liste locale
- tab = SimExplorerTab.local;
- model = (ListTabModel) tab.getModel();
- ui = (JListTab) tab.getUI();
- } else {
- // reninit de la liste remote
- tab = SimExplorerTab.remote;
- model = (ListTabModel) tab.getModel();
- ui = (JListTab) tab.getUI();
- }
+ boolean remote = selected.isRemote();
+
+ tab = SimExplorerTab.getListTab(remote);
+ model = SimExplorerTab.getListModel(remote);
+ ui = SimExplorerTab.getListUI(remote);
+
// pour reforcer le calcul de la liste
- model.setPagination(null);
- model.updateTabModel(getContext(), (ListTableModel) ui.getTable().getModel());
- tab.updateUI();
- boolean wasVisible = SimExplorerTab.synchronize.isTabVisible(getTabContainer());
- if (wasVisible) {
- SimExplorerActionManager.fireAction("showTab_synchronize", e.getSource());
- if (getTab() != SimExplorerTab.synchronize) {
- SimExplorerTab.synchronize.closeTab(getTabContainer());
- getTab().showTab(getTabContainer());
- }
+ model.updateTabModel(getContext(), (ListTableModel) ui.getTable().getModel(), true);
+ tab.updateUI(getContext(),getMainUI());
+ }
+
+ protected void updateSynchronizeTab() {
+
+ SimExplorerTab tab = SimExplorerTab.synchronize;
+ SynchronizeTabModel model = (SynchronizeTabModel) tab.getModel();
+
+ LoggableElement oldLocalRoot = model.getRootNode(false);
+ LoggableElement oldRemoteRoot = model.getRootNode(true);
+ LoggableElement item;
+ boolean modelIsRemote = !selected.isRemote();
+
+ item = model.getRootNode(modelIsRemote);
+ if (item != null && item.getMetaData().getUuid() != null && item.getMetaData().getUuid().equals(selected.getUuid())) {
+ model.setRootNode(null, modelIsRemote);
}
-
+ SynchronizeTabRefreshHelper.updateTree(getMainUI(), getTabContainer(), oldLocalRoot, oldRemoteRoot);
}
@Override
Modified: trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/ExportElementToLocalAction.java
===================================================================
--- trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/ExportElementToLocalAction.java 2008-02-20 18:45:27 UTC (rev 1144)
+++ trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/ExportElementToLocalAction.java 2008-02-20 18:46:01 UTC (rev 1145)
@@ -20,13 +20,13 @@
import fr.cemagref.simexplorer.is.entities.EntityHelper;
import fr.cemagref.simexplorer.is.entities.data.LoggableElement;
+import fr.cemagref.simexplorer.is.ui.swing.model.DataEntityModel;
import fr.cemagref.simexplorer.is.ui.swing.model.SynchronizeTabModel;
-import fr.cemagref.simexplorer.is.ui.swing.model.DataEntityModel;
import java.awt.event.ActionEvent;
/**
- * Action pour exporter une application
+ * Action pour exporter un élément vers la base locale
*
* @author chemit
*/
@@ -56,7 +56,7 @@
boolean result;
if (result = EntityHelper.Action.EXPORT.accept(element)) {
selected = new DataEntityModel();
- selected.synch(true,element);
+ selected.synch(true, element);
}
return result;
}
Modified: trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/ExportElementToRemoteAction.java
===================================================================
--- trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/ExportElementToRemoteAction.java 2008-02-20 18:45:27 UTC (rev 1144)
+++ trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/ExportElementToRemoteAction.java 2008-02-20 18:46:01 UTC (rev 1145)
@@ -20,13 +20,13 @@
import fr.cemagref.simexplorer.is.entities.EntityHelper;
import fr.cemagref.simexplorer.is.entities.data.LoggableElement;
+import fr.cemagref.simexplorer.is.ui.swing.model.DataEntityModel;
import fr.cemagref.simexplorer.is.ui.swing.model.SynchronizeTabModel;
-import fr.cemagref.simexplorer.is.ui.swing.model.DataEntityModel;
import java.awt.event.ActionEvent;
/**
- * Action pour exporter une application
+ * Action pour exporter un élément vers la base distante
*
* @author chemit
*/
@@ -56,7 +56,7 @@
boolean result;
if (result = EntityHelper.Action.EXPORT.accept(element)) {
selected = new DataEntityModel();
- selected.synch(false,element);
+ selected.synch(false, element);
}
return result;
}
Modified: trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/GoLastPageAction.java
===================================================================
--- trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/GoLastPageAction.java 2008-02-20 18:45:27 UTC (rev 1144)
+++ trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/GoLastPageAction.java 2008-02-20 18:46:01 UTC (rev 1145)
@@ -18,8 +18,8 @@
* ##% */
package fr.cemagref.simexplorer.is.ui.swing.actions;
-import fr.cemagref.simexplorer.is.ui.swing.SimExplorerTab;
import fr.cemagref.simexplorer.is.ui.swing.model.ListTabModel;
+import fr.cemagref.simexplorer.is.ui.swing.ui.SimExplorerTab;
import java.awt.event.ActionEvent;
Modified: trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/GoNextPageAction.java
===================================================================
--- trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/GoNextPageAction.java 2008-02-20 18:45:27 UTC (rev 1144)
+++ trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/GoNextPageAction.java 2008-02-20 18:46:01 UTC (rev 1145)
@@ -19,7 +19,7 @@
package fr.cemagref.simexplorer.is.ui.swing.actions;
import fr.cemagref.simexplorer.is.ui.swing.model.ListTabModel;
-import fr.cemagref.simexplorer.is.ui.swing.SimExplorerTab;
+import fr.cemagref.simexplorer.is.ui.swing.ui.SimExplorerTab;
import java.awt.event.ActionEvent;
@@ -48,14 +48,14 @@
@Override
protected boolean beforeAction(ActionEvent e) throws Exception {
SimExplorerTab myTab = findTab(e);
- if (myTab==null) {
+ if (myTab == null) {
return false;
}
ListTabModel model = (ListTabModel) myTab.getModel();
Integer oldPage = model.getPagination().getCurrentPage();
boolean b = oldPage < model.getPagination().getNbPages();
if (b) {
- newPage = oldPage+1;
+ newPage = oldPage + 1;
}
return b;
}
Modified: trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/GoPreviousPageAction.java
===================================================================
--- trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/GoPreviousPageAction.java 2008-02-20 18:45:27 UTC (rev 1144)
+++ trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/GoPreviousPageAction.java 2008-02-20 18:46:01 UTC (rev 1145)
@@ -19,7 +19,7 @@
package fr.cemagref.simexplorer.is.ui.swing.actions;
import fr.cemagref.simexplorer.is.ui.swing.model.ListTabModel;
-import fr.cemagref.simexplorer.is.ui.swing.SimExplorerTab;
+import fr.cemagref.simexplorer.is.ui.swing.ui.SimExplorerTab;
import java.awt.event.ActionEvent;
@@ -48,7 +48,7 @@
@Override
protected boolean beforeAction(ActionEvent e) throws Exception {
SimExplorerTab myTab = findTab(e);
- if (myTab==null) {
+ if (myTab == null) {
return false;
}
ListTabModel model = (ListTabModel) myTab.getModel();
Modified: trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/HelpAction.java
===================================================================
--- trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/HelpAction.java 2008-02-20 18:45:27 UTC (rev 1144)
+++ trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/HelpAction.java 2008-02-20 18:46:01 UTC (rev 1145)
@@ -18,8 +18,8 @@
* ##% */
package fr.cemagref.simexplorer.is.ui.swing.actions;
+import fr.cemagref.simexplorer.is.exceptions.SimExplorerRuntimeException;
import fr.cemagref.simexplorer.is.ui.swing.actions.util.SimExplorerAbstractAction;
-import fr.cemagref.simexplorer.is.exceptions.SimExplorerRuntimeException;
import java.awt.event.ActionEvent;
@@ -48,6 +48,6 @@
@Override
protected void doAction(ActionEvent e) throws Exception {
super.doAction(e);
- throw new SimExplorerRuntimeException(this+" is not implemented yet!");
+ throw new SimExplorerRuntimeException(this + " is not implemented yet!");
}
}
\ No newline at end of file
Modified: trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/ImportElementAction.java
===================================================================
--- trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/ImportElementAction.java 2008-02-20 18:45:27 UTC (rev 1144)
+++ trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/ImportElementAction.java 2008-02-20 18:46:01 UTC (rev 1145)
@@ -18,8 +18,8 @@
* ##% */
package fr.cemagref.simexplorer.is.ui.swing.actions;
-import fr.cemagref.simexplorer.is.ui.StorageServiceHelper;
-import fr.cemagref.simexplorer.is.ui.swing.ImportDialog;
+import fr.cemagref.simexplorer.is.ui.swing.ui.ImportDialog;
+import fr.cemagref.simexplorer.is.ui.swing.StorageServiceHelper;
import fr.cemagref.simexplorer.is.ui.swing.actions.util.SimExplorerAbstractTabAction;
import fr.cemagref.simexplorer.is.ui.swing.model.ListTabModel;
import static org.codelutin.i18n.I18n._;
@@ -97,7 +97,7 @@
}
@Override
- public String getI18nToolTipText() {
+ public String getI18nToolTipText() {
return getI18nToolTipText(remote);
}
Modified: trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/QuitAction.java
===================================================================
--- trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/QuitAction.java 2008-02-20 18:45:27 UTC (rev 1144)
+++ trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/QuitAction.java 2008-02-20 18:46:01 UTC (rev 1145)
@@ -18,6 +18,7 @@
* ##% */
package fr.cemagref.simexplorer.is.ui.swing.actions;
+import fr.cemagref.simexplorer.is.ui.swing.SimExplorer;
import fr.cemagref.simexplorer.is.ui.swing.actions.util.SimExplorerAbstractAction;
/**
@@ -46,6 +47,6 @@
protected void doAction(java.awt.event.ActionEvent e) throws Exception {
//TODO Fermer tous les tabs
//TODO se deconnecter,...
- getMainUI().dispose();
+ SimExplorer.dispose(false);
}
}
Modified: trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/ResetSearchAction.java
===================================================================
--- trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/ResetSearchAction.java 2008-02-20 18:45:27 UTC (rev 1144)
+++ trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/ResetSearchAction.java 2008-02-20 18:46:01 UTC (rev 1145)
@@ -18,11 +18,11 @@
* ##% */
package fr.cemagref.simexplorer.is.ui.swing.actions;
-import fr.cemagref.simexplorer.is.ui.swing.JListTab;
+import fr.cemagref.simexplorer.is.entities.metadata.MetaData;
+import fr.cemagref.simexplorer.is.ui.swing.ui.JListTab;
import fr.cemagref.simexplorer.is.ui.swing.actions.util.SimExplorerAbstractTabAction;
import fr.cemagref.simexplorer.is.ui.swing.model.ListTabModel;
import fr.cemagref.simexplorer.is.ui.swing.model.ListTableModel;
-import fr.cemagref.simexplorer.is.entities.metadata.MetaData;
import java.awt.event.ActionEvent;
@@ -75,19 +75,17 @@
model.setQuery(null);
// reset selected item
model.synch(model.isRemote(), (MetaData) null);
- log.info("sync "+model.getSelectedItem());
- // pagination a vide
- model.setPagination(null);
+ log.info("sync " + model.getSelectedItem());
// update model
- model.updateTabModel(getContext(), (ListTableModel) ((JListTab) getUI()).getTable().getModel());
+ model.updateTabModel(getContext(), (ListTableModel) ((JListTab) getUI()).getTable().getModel(), true);
}
@Override
public void updateUI() {
super.updateUI();
// refresh ui
- getTab().updateUI();
+ getTab().updateUI(getContext(),getMainUI());
}
@Override
Modified: trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/SearchAction.java
===================================================================
--- trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/SearchAction.java 2008-02-20 18:45:27 UTC (rev 1144)
+++ trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/SearchAction.java 2008-02-20 18:46:01 UTC (rev 1145)
@@ -18,11 +18,11 @@
* ##% */
package fr.cemagref.simexplorer.is.ui.swing.actions;
-import fr.cemagref.simexplorer.is.ui.swing.JListTab;
+import fr.cemagref.simexplorer.is.entities.metadata.MetaData;
+import fr.cemagref.simexplorer.is.ui.swing.ui.JListTab;
import fr.cemagref.simexplorer.is.ui.swing.actions.util.SimExplorerAbstractTabAction;
import fr.cemagref.simexplorer.is.ui.swing.model.ListTabModel;
import fr.cemagref.simexplorer.is.ui.swing.model.ListTableModel;
-import fr.cemagref.simexplorer.is.entities.metadata.MetaData;
import javax.swing.JTextField;
import java.awt.event.ActionEvent;
@@ -68,17 +68,14 @@
model.synch(model.isRemote(), (MetaData) null);
model.setSelectedIndex(-1);
- // pagination a vide
- model.setPagination(null);
-
// update model
- model.updateTabModel(getContext(), (ListTableModel) ((JListTab) getUI()).getTable().getModel());
+ model.updateTabModel(getContext(), (ListTableModel) ((JListTab) getUI()).getTable().getModel(), true);
}
@Override
public void updateUI() {
// refresh tab ui
- getTab().updateUI();
+ getTab().updateUI(getContext(),getMainUI());
}
@Override
Modified: trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/ShowDetailTabAction.java
===================================================================
--- trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/ShowDetailTabAction.java 2008-02-20 18:45:27 UTC (rev 1144)
+++ trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/ShowDetailTabAction.java 2008-02-20 18:46:01 UTC (rev 1145)
@@ -21,15 +21,15 @@
import fr.cemagref.simexplorer.is.entities.data.LoggableElement;
import fr.cemagref.simexplorer.is.entities.metadata.MetaData;
import fr.cemagref.simexplorer.is.entities.metadata.Version;
-import fr.cemagref.simexplorer.is.ui.StorageServiceHelper;
-import fr.cemagref.simexplorer.is.ui.swing.DetailTabRefreshHelper;
-import fr.cemagref.simexplorer.is.ui.swing.EntityTreeNodeHelper;
-import fr.cemagref.simexplorer.is.ui.swing.JDetailTab;
-import fr.cemagref.simexplorer.is.ui.swing.SimExplorerTab;
+import fr.cemagref.simexplorer.is.ui.swing.ui.JDetailTab;
+import fr.cemagref.simexplorer.is.ui.swing.StorageServiceHelper;
import fr.cemagref.simexplorer.is.ui.swing.actions.util.ShowTabAbstractAction;
import fr.cemagref.simexplorer.is.ui.swing.model.DataEntityModel;
import fr.cemagref.simexplorer.is.ui.swing.model.DetailTabModel;
import fr.cemagref.simexplorer.is.ui.swing.model.EntityTreeNode;
+import fr.cemagref.simexplorer.is.ui.swing.ui.DetailTabRefreshHelper;
+import fr.cemagref.simexplorer.is.ui.swing.ui.EntityTreeNodeHelper;
+import fr.cemagref.simexplorer.is.ui.swing.ui.SimExplorerTab;
import javax.swing.DefaultComboBoxModel;
import javax.swing.event.ListSelectionEvent;
@@ -153,7 +153,7 @@
model.resetSelectedVersion();
// update history list
- LoggableElement element = node == null ? null : node.getLoggableElement();
+ LoggableElement element = node == null ? null : node.getLoggableElement();
boolean history = element != null;
Version selectedVersion;
Integer selectedAttachment;
@@ -213,7 +213,7 @@
attachmentListener.setEnabled(wasEnable2);
// update actions on toolbar
EntityTreeNode node = EntityTreeNodeHelper.getSelectedNode(ui.getNavigationTree());
- DetailTabRefreshHelper.refreshDetailActions(ui, model, node);
+ DetailTabRefreshHelper.refreshDetailActions(getContext(), ui, model, node);
EntityTreeNode rootNode = EntityTreeNodeHelper.getRootNode(ui.getNavigationTree());
if (model.getDetail() != null && !node.equals(rootNode)) {
@@ -239,7 +239,7 @@
JDetailTab ui = getTabUI();
DetailTabModel model = getTabModel();
- MetaData metas;
+ MetaData metas;
Object selectedItem = ui.getDetailVersions().getSelectedItem();
if (selectedItem == null) {
throw new NullPointerException("can not have a selectedItem null");
@@ -303,7 +303,7 @@
ui.getDetailAttachments().setSelectedIndex(0);
// update actions on toolbar
EntityTreeNode node = EntityTreeNodeHelper.getSelectedNodeOrRootNode(ui.getNavigationTree());
- DetailTabRefreshHelper.refreshDetailActions(ui, model, node);
+ DetailTabRefreshHelper.refreshDetailActions(getContext(), ui, model, node);
}
public boolean isEnabled() {
Modified: trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/ShowLocalTabAction.java
===================================================================
--- trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/ShowLocalTabAction.java 2008-02-20 18:45:27 UTC (rev 1144)
+++ trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/ShowLocalTabAction.java 2008-02-20 18:46:01 UTC (rev 1145)
@@ -38,6 +38,6 @@
private static final long serialVersionUID = 7009836674867908237L;
public ShowLocalTabAction(String name) {
- super(name,false);
+ super(name, false);
}
}
\ No newline at end of file
Modified: trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/ShowRemoteTabAction.java
===================================================================
--- trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/ShowRemoteTabAction.java 2008-02-20 18:45:27 UTC (rev 1144)
+++ trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/ShowRemoteTabAction.java 2008-02-20 18:46:01 UTC (rev 1145)
@@ -38,6 +38,6 @@
private static final long serialVersionUID = -5791049785753596347L;
public ShowRemoteTabAction(String name) {
- super(name,true);
+ super(name, true);
}
}
\ No newline at end of file
Modified: trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/ShowSynchronizeTabAction.java
===================================================================
--- trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/ShowSynchronizeTabAction.java 2008-02-20 18:45:27 UTC (rev 1144)
+++ trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/ShowSynchronizeTabAction.java 2008-02-20 18:46:01 UTC (rev 1145)
@@ -19,18 +19,17 @@
package fr.cemagref.simexplorer.is.ui.swing.actions;
import fr.cemagref.simexplorer.is.entities.data.LoggableElement;
-import fr.cemagref.simexplorer.is.ui.swing.JSynchronizeTab;
-import fr.cemagref.simexplorer.is.ui.swing.SimExplorerTab;
-import fr.cemagref.simexplorer.is.ui.swing.SynchronizeTabRefreshHelper;
-import fr.cemagref.simexplorer.is.ui.swing.EntityTreeNodeHelper;
+import fr.cemagref.simexplorer.is.ui.swing.ui.JSynchronizeTab;
import fr.cemagref.simexplorer.is.ui.swing.actions.util.ShowTabAbstractAction;
import fr.cemagref.simexplorer.is.ui.swing.model.DataEntityModel;
import fr.cemagref.simexplorer.is.ui.swing.model.EntityTreeNode;
import fr.cemagref.simexplorer.is.ui.swing.model.SynchronizeTabModel;
+import fr.cemagref.simexplorer.is.ui.swing.ui.EntityTreeNodeHelper;
+import fr.cemagref.simexplorer.is.ui.swing.ui.SimExplorerTab;
+import fr.cemagref.simexplorer.is.ui.swing.ui.SynchronizeTabRefreshHelper;
import javax.swing.event.TreeSelectionEvent;
import javax.swing.event.TreeSelectionListener;
-import javax.swing.tree.TreePath;
import java.awt.event.ActionEvent;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
@@ -57,14 +56,14 @@
/** le listener sur la navigation dans l'arbre local */
protected TreeSelectionListener navigationLocalListener;
+ protected TreeSelectionListener navigationActionsLocalListener;
/** le listener sur la navigation dans l'arbre distant */
protected TreeSelectionListener navigationRemoteListener;
+ protected TreeSelectionListener navigationActionsRemoteListener;
public ShowSynchronizeTabAction(String name) {
super(name);
- navigationLocalListener = new NavigationSelectionListener(false);
- navigationRemoteListener = new NavigationSelectionListener(true);
}
@Override
@@ -86,18 +85,60 @@
}
protected void initFirstUsage(JSynchronizeTab ui, SynchronizeTabModel model) {
+ navigationLocalListener = new NavigationSelectionListener(false);
+ navigationRemoteListener = new NavigationSelectionListener(true);
+
+ navigationActionsLocalListener = new NavigationActionsSelectionListener(ui, false);
+ navigationActionsRemoteListener = new NavigationActionsSelectionListener(ui, true);
// add a listener on navigation tree
ui.getTree(false).addTreeSelectionListener(navigationLocalListener);
+ ui.getTree(false).addTreeSelectionListener(navigationActionsLocalListener);
ui.getTree(true).addTreeSelectionListener(navigationRemoteListener);
+ ui.getTree(true).addTreeSelectionListener(navigationActionsRemoteListener);
}
@Override
+ public void disposeUI() {
+ super.disposeUI();
+ JSynchronizeTab ui = getTabUI();
+ if (navigationActionsLocalListener!=null) {
+ ui.getTree(false).removeTreeSelectionListener(navigationLocalListener);
+ ui.getTree(false).removeTreeSelectionListener(navigationActionsLocalListener);
+ ui.getTree(true).removeTreeSelectionListener(navigationRemoteListener);
+ ui.getTree(true).removeTreeSelectionListener(navigationActionsRemoteListener);
+ }
+ }
+
+ @Override
protected void clear() {
super.clear();
selected = null;
}
/**
+ * Listen on selection of node in a tree, and refresh navigation actions.
+ *
+ * @author chemit
+ */
+ protected class NavigationActionsSelectionListener implements TreeSelectionListener {
+
+ protected final boolean remote;
+ protected JSynchronizeTab ui;
+
+ public NavigationActionsSelectionListener(JSynchronizeTab ui, boolean remote) {
+ this.remote = remote;
+ this.ui = ui;
+ }
+
+ public void valueChanged(TreeSelectionEvent e) {
+ // get EntityTreeNode
+ EntityTreeNode node = EntityTreeNodeHelper.getSelectedNode(e);
+ // refresh tree actions
+ EntityTreeNodeHelper.refreshTreeActions(ui.getCollapseButton(remote), ui.getExpandButton(remote), node);
+ }
+ }
+
+ /**
* The listener of the selection in a navigation tree.
*
* @author chemit
@@ -115,21 +156,10 @@
public void valueChanged(TreeSelectionEvent e) {
SynchronizeTabModel model = getTabModel();
- TreePath path = e.getNewLeadSelectionPath();
- EntityTreeNode node = null;
- if (path != null) {
- node = (EntityTreeNode) path.getLastPathComponent();
- }
- // on rafraichit toujours ici les actions de l'arbre qui sont
- // indépendantes du model et dépendent juste dunoeud sélectionné
- EntityTreeNodeHelper.refreshTreeActions(getTabUI().getCollapseButton(remote), getTabUI().getExpandButton(remote), node);
-
- Object o = node == null ? null : node.getUserObject();
+ EntityTreeNode node = EntityTreeNodeHelper.getSelectedNode(e);
- // update history list
- LoggableElement element = (LoggableElement) (o == null || !(o instanceof LoggableElement) ? null : o);
+ LoggableElement element = node.getLoggableElement();
- // le node est acceptable uniquement si c'est un loggableElement
model.setSelectedNode(element, remote);
}
@@ -142,7 +172,7 @@
*/
public void propertyChange(PropertyChangeEvent evt) {
log.info(evt.getPropertyName() + " old:" + evt.getOldValue() + ", new:" + evt.getNewValue());
- SynchronizeTabRefreshHelper.refreshExportElement(getTabUI(), getTabModel(), remote);
+ SynchronizeTabRefreshHelper.refreshExportElement(getContext(),getTabUI(), getTabModel(), remote);
}
}
Modified: trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/UnconnectAction.java
===================================================================
--- trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/UnconnectAction.java 2008-02-20 18:45:27 UTC (rev 1144)
+++ trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/UnconnectAction.java 2008-02-20 18:46:01 UTC (rev 1145)
@@ -18,18 +18,18 @@
* ##% */
package fr.cemagref.simexplorer.is.ui.swing.actions;
-import fr.cemagref.simexplorer.is.ui.swing.DetailTabRefreshHelper;
-import fr.cemagref.simexplorer.is.ui.swing.JDetailTab;
-import fr.cemagref.simexplorer.is.ui.swing.JListTab;
-import fr.cemagref.simexplorer.is.ui.swing.ListTabRefreshHelper;
-import fr.cemagref.simexplorer.is.ui.swing.SimExplorerMainUI;
-import fr.cemagref.simexplorer.is.ui.swing.SimExplorerTab;
+import fr.cemagref.simexplorer.is.ui.swing.ui.JDetailTab;
+import fr.cemagref.simexplorer.is.ui.swing.ui.JListTab;
import fr.cemagref.simexplorer.is.ui.swing.SimExplorerActionManager;
import fr.cemagref.simexplorer.is.ui.swing.actions.util.SimExplorerAbstractAction;
import fr.cemagref.simexplorer.is.ui.swing.model.DetailTabModel;
+import fr.cemagref.simexplorer.is.ui.swing.model.EntityTreeNode;
import fr.cemagref.simexplorer.is.ui.swing.model.HistoryModel;
import fr.cemagref.simexplorer.is.ui.swing.model.ListTabModel;
-import fr.cemagref.simexplorer.is.ui.swing.model.EntityTreeNode;
+import fr.cemagref.simexplorer.is.ui.swing.ui.DetailTabRefreshHelper;
+import fr.cemagref.simexplorer.is.ui.swing.ui.ListTabRefreshHelper;
+import fr.cemagref.simexplorer.is.ui.swing.ui.SimExplorerMainUI;
+import fr.cemagref.simexplorer.is.ui.swing.ui.SimExplorerTab;
import javax.swing.JTabbedPane;
import java.awt.event.ActionEvent;
@@ -73,7 +73,7 @@
//DetailTabModel model = (DetailTabModel) SimExplorerTab.detail.getModel();
// remove all remote entries from history
- SimExplorerActionManager.fireAction("historyUnconnect",e.getSource());
+ SimExplorerActionManager.fireAction("historyUnconnect", e.getSource());
}
@@ -103,11 +103,11 @@
if (SimExplorerTab.remote.isTabVisible(container)) {
// close tab
- SimExplorerTab.remote.closeTab(container);
+ SimExplorerTab.remote.closeTab(getMainUI(), container);
}
if (SimExplorerTab.synchronize.isTabVisible(container)) {
// close tab
- SimExplorerTab.synchronize.closeTab(container);
+ SimExplorerTab.synchronize.closeTab(getMainUI(), container);
}
/*if (SimExplorerTab.detail.isTabVisible(container) && history != null) {
if (history.isEmpty()) {
@@ -125,12 +125,12 @@
}*/
if (SimExplorerTab.detail.isTabVisible(container)) {
- DetailTabRefreshHelper.refreshSynchroniseAction(tabUI, model);
- DetailTabRefreshHelper.refreshExportAction(tabUI, model);
+ DetailTabRefreshHelper.refreshSynchroniseAction(getContext(), tabUI, model);
+ DetailTabRefreshHelper.refreshExportAction(getContext(),tabUI, model);
}
if (SimExplorerTab.local.isTabVisible(container)) {
- ListTabRefreshHelper.refreshListTablePopupMenu((JListTab) SimExplorerTab.local.getUI(), (ListTabModel) SimExplorerTab.local.getModel());
+ ListTabRefreshHelper.refreshListTablePopupMenu(getContext(), (JListTab) SimExplorerTab.local.getUI(), (ListTabModel) SimExplorerTab.local.getModel());
}
// }
//});
Modified: trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/history/HistoryAbstractAction.java
===================================================================
--- trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/history/HistoryAbstractAction.java 2008-02-20 18:45:27 UTC (rev 1144)
+++ trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/history/HistoryAbstractAction.java 2008-02-20 18:46:01 UTC (rev 1145)
@@ -18,13 +18,13 @@
package fr.cemagref.simexplorer.is.ui.swing.actions.history;
import fr.cemagref.simexplorer.is.entities.metadata.MetaData;
-import fr.cemagref.simexplorer.is.ui.swing.DetailTabRefreshHelper;
-import fr.cemagref.simexplorer.is.ui.swing.JDetailTab;
-import fr.cemagref.simexplorer.is.ui.swing.SimExplorerTab;
+import fr.cemagref.simexplorer.is.ui.swing.ui.JDetailTab;
import fr.cemagref.simexplorer.is.ui.swing.actions.util.SimExplorerAbstractTabAction;
import fr.cemagref.simexplorer.is.ui.swing.model.DetailTabModel;
import fr.cemagref.simexplorer.is.ui.swing.model.EntityTreeNode;
import fr.cemagref.simexplorer.is.ui.swing.model.HistoryModel;
+import fr.cemagref.simexplorer.is.ui.swing.ui.DetailTabRefreshHelper;
+import fr.cemagref.simexplorer.is.ui.swing.ui.SimExplorerTab;
import java.awt.event.ActionEvent;
@@ -92,7 +92,7 @@
DetailTabRefreshHelper.updateDetailNavigationTree((JDetailTab) getUI(), history);
} else if (getTab().isTabVisible(getTabContainer())) {
// close tab, no more history
- getTab().closeTab(getTabContainer());
+ getTab().closeTab(getMainUI(), getTabContainer());
}
}
Modified: trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/history/HistoryDeleteAction.java
===================================================================
--- trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/history/HistoryDeleteAction.java 2008-02-20 18:45:27 UTC (rev 1144)
+++ trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/history/HistoryDeleteAction.java 2008-02-20 18:46:01 UTC (rev 1145)
@@ -19,7 +19,6 @@
package fr.cemagref.simexplorer.is.ui.swing.actions.history;
import fr.cemagref.simexplorer.is.entities.data.LoggableElement;
-import fr.cemagref.simexplorer.is.ui.swing.actions.history.HistoryAbstractAction;
import fr.cemagref.simexplorer.is.ui.swing.model.DataEntityModel;
import fr.cemagref.simexplorer.is.ui.swing.model.EntityTreeNode;
import fr.cemagref.simexplorer.is.ui.swing.model.HistoryModel;
Modified: trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/history/HistoryNextAction.java
===================================================================
--- trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/history/HistoryNextAction.java 2008-02-20 18:45:27 UTC (rev 1144)
+++ trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/history/HistoryNextAction.java 2008-02-20 18:46:01 UTC (rev 1145)
@@ -18,7 +18,6 @@
* ##% */
package fr.cemagref.simexplorer.is.ui.swing.actions.history;
-import fr.cemagref.simexplorer.is.ui.swing.actions.history.HistoryAbstractAction;
import fr.cemagref.simexplorer.is.ui.swing.model.EntityTreeNode;
import fr.cemagref.simexplorer.is.ui.swing.model.HistoryModel;
Modified: trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/history/HistoryPreviousAction.java
===================================================================
--- trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/history/HistoryPreviousAction.java 2008-02-20 18:45:27 UTC (rev 1144)
+++ trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/history/HistoryPreviousAction.java 2008-02-20 18:46:01 UTC (rev 1145)
@@ -18,7 +18,6 @@
* ##% */
package fr.cemagref.simexplorer.is.ui.swing.actions.history;
-import fr.cemagref.simexplorer.is.ui.swing.actions.history.HistoryAbstractAction;
import fr.cemagref.simexplorer.is.ui.swing.model.EntityTreeNode;
import fr.cemagref.simexplorer.is.ui.swing.model.HistoryModel;
Modified: trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/history/HistoryUnconnectAction.java
===================================================================
--- trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/history/HistoryUnconnectAction.java 2008-02-20 18:45:27 UTC (rev 1144)
+++ trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/history/HistoryUnconnectAction.java 2008-02-20 18:46:01 UTC (rev 1145)
@@ -18,7 +18,6 @@
* ##% */
package fr.cemagref.simexplorer.is.ui.swing.actions.history;
-import fr.cemagref.simexplorer.is.ui.swing.actions.history.HistoryAbstractAction;
import fr.cemagref.simexplorer.is.ui.swing.model.EntityTreeNode;
import fr.cemagref.simexplorer.is.ui.swing.model.HistoryModel;
Modified: trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/util/ChangeI18nAbstractAction.java
===================================================================
--- trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/util/ChangeI18nAbstractAction.java 2008-02-20 18:45:27 UTC (rev 1144)
+++ trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/util/ChangeI18nAbstractAction.java 2008-02-20 18:46:01 UTC (rev 1145)
@@ -18,7 +18,7 @@
* ##% */
package fr.cemagref.simexplorer.is.ui.swing.actions.util;
-import fr.cemagref.simexplorer.is.ui.SimExplorer;
+import fr.cemagref.simexplorer.is.ui.swing.SimExplorer;
import org.apache.commons.beanutils.Converter;
import org.codelutin.i18n.CountryEnum;
import org.codelutin.i18n.I18n;
@@ -62,22 +62,19 @@
}
@Override
- public void doAction(java.awt.event.ActionEvent e) {
+ public void doAction(ActionEvent e) {
//TODO Should ask confirm from user since it will close ui, and re instanciate ui
-
- getMainUI().getQuit().getAction().actionPerformed(new ActionEvent(this, ActionEvent.ACTION_FIRST, "cancel"));
+ //getMainUI().getQuit().getAction().actionPerformed(new ActionEvent(this, ActionEvent.ACTION_FIRST, "cancel"));
getContext().getConfig().setI18n(language, country);
// on doit initialiser la nouvelle locale avant de decharger les ui
// au cas ou un appel à une ui surviendrait et dans quel cas la locale
// serait toujours sur l'ancienne valeur ...
getContext().getConfig().initI18n();
// save config
- SimExplorer.getContext().saveSafely();
- // dispose all ui
- SimExplorer.disposeUI();
- // reload main ui
- SimExplorer.launch();
+ getContext().saveSafely();
+ // dispose then reload main ui
+ SimExplorer.dispose(true);
}
public boolean equalsLocale(LanguageEnum lang, CountryEnum countr) {
Modified: trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/util/ShowListTabAbstractAction.java
===================================================================
--- trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/util/ShowListTabAbstractAction.java 2008-02-20 18:45:27 UTC (rev 1144)
+++ trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/util/ShowListTabAbstractAction.java 2008-02-20 18:46:01 UTC (rev 1145)
@@ -20,14 +20,15 @@
import fr.cemagref.simexplorer.is.entities.metadata.MetaData;
import fr.cemagref.simexplorer.is.exceptions.SimExplorerRuntimeException;
-import fr.cemagref.simexplorer.is.ui.swing.JListTab;
-import fr.cemagref.simexplorer.is.ui.swing.ListTabRefreshHelper;
+import fr.cemagref.simexplorer.is.ui.swing.ui.JListTab;
import fr.cemagref.simexplorer.is.ui.swing.SimExplorerActionManager;
import fr.cemagref.simexplorer.is.ui.swing.actions.ImportElementAction;
import fr.cemagref.simexplorer.is.ui.swing.model.DataEntityModel;
import fr.cemagref.simexplorer.is.ui.swing.model.ListTabModel;
import fr.cemagref.simexplorer.is.ui.swing.model.ListTableModel;
+import fr.cemagref.simexplorer.is.ui.swing.ui.ListTabRefreshHelper;
import jaxx.runtime.swing.JAXXTab;
+import static org.codelutin.i18n.I18n._;
import javax.swing.AbstractButton;
import javax.swing.JTabbedPane;
@@ -41,8 +42,6 @@
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
-import static org.codelutin.i18n.I18n._;
-
/** @author chemit */
public class ShowListTabAbstractAction extends ShowTabAbstractAction<JListTab, ListTabModel> {
private static final long serialVersionUID = 3813479850648257169L;
@@ -138,7 +137,7 @@
entityModel = model.getSelectedItem();
log.info(entityModel);
- ListTabRefreshHelper.refreshListTablePopupMenu(ui, model);
+ ListTabRefreshHelper.refreshListTablePopupMenu(getContext(), ui, model);
}
}
@@ -174,26 +173,26 @@
}
@Override
- public void mousePressed(MouseEvent e) {
+ public void mousePressed(MouseEvent e) {
super.mousePressed(e);
initPopup(e);
}
@Override
- public void mouseReleased(MouseEvent e) {
+ public void mouseReleased(MouseEvent e) {
super.mouseReleased(e);
initPopup(e);
}
@Override
- public void mouseClicked(MouseEvent e) {
+ public void mouseClicked(MouseEvent e) {
if (e.getClickCount() == 2) {
try {
// synchronization du meta selectionne
synchSelected(ui, getRowAtPoint(ui, e.getPoint()), ui.getTable().getSelectionModel(), model);
// lancement de l'action d'affichage de l'onglet de detail
//ActionEvent e1 = new ActionEvent(e.getSource(), ActionEvent.ACTION_FIRST, "showTab_detail");
- SimExplorerActionManager.fireAction("showTab_detail", e.getSource(),(AbstractButton) null);
+ SimExplorerActionManager.fireAction("showTab_detail", e.getSource(), (AbstractButton) null);
} catch (Exception e1) {
throw new SimExplorerRuntimeException(e1);
}
Modified: trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/util/ShowTabAbstractAction.java
===================================================================
--- trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/util/ShowTabAbstractAction.java 2008-02-20 18:45:27 UTC (rev 1144)
+++ trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/util/ShowTabAbstractAction.java 2008-02-20 18:46:01 UTC (rev 1145)
@@ -73,7 +73,7 @@
protected void updateUI(U ui, M model) {
// refresh ui
- getTab().updateUI(ui, model);
+ getTab().updateUI(getContext(),getMainUI(), ui, model);
}
@Override
Modified: trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/util/SimExplorerAbstractAction.java
===================================================================
--- trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/util/SimExplorerAbstractAction.java 2008-02-20 18:45:27 UTC (rev 1144)
+++ trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/util/SimExplorerAbstractAction.java 2008-02-20 18:46:01 UTC (rev 1145)
@@ -18,9 +18,10 @@
* ##% */
package fr.cemagref.simexplorer.is.ui.swing.actions.util;
-import fr.cemagref.simexplorer.is.ui.SimExplorer;
-import fr.cemagref.simexplorer.is.ui.SimExplorerContext;
-import fr.cemagref.simexplorer.is.ui.swing.SimExplorerMainUI;
+import fr.cemagref.simexplorer.is.ui.swing.SimExplorer;
+import fr.cemagref.simexplorer.is.ui.swing.SimExplorerContext;
+import fr.cemagref.simexplorer.is.ui.swing.ui.SimExplorerMainUI;
+import fr.cemagref.simexplorer.is.ui.swing.ui.util.ErrorDialog;
import jaxx.runtime.JAXXObject;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -61,7 +62,7 @@
updateUI();
}
} catch (Exception e1) {
- SimExplorer.showError(e1);
+ showError(e1);
} finally {
this.e = null;
// always clear action after use : actions are staless
@@ -69,6 +70,10 @@
}
}
+ protected void showError(Exception e) {
+ ErrorDialog.showError(e);
+ }
+
protected SimExplorerAbstractAction(String name) {
super(name);
log.debug("> " + this);
@@ -79,7 +84,7 @@
}
protected SimExplorerMainUI getMainUI() {
- return SimExplorer.getUI();
+ return SimExplorerMainUI.getUI();
}
protected String getActionName() {
Modified: trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/util/SimExplorerAbstractTabAction.java
===================================================================
--- trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/util/SimExplorerAbstractTabAction.java 2008-02-20 18:45:27 UTC (rev 1144)
+++ trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/util/SimExplorerAbstractTabAction.java 2008-02-20 18:46:01 UTC (rev 1145)
@@ -18,12 +18,12 @@
* ##% */
package fr.cemagref.simexplorer.is.ui.swing.actions.util;
-import fr.cemagref.simexplorer.is.ui.swing.SimExplorerTab;
-import fr.cemagref.simexplorer.is.ui.swing.JDetailTab;
-import fr.cemagref.simexplorer.is.ui.swing.JSynchronizeTab;
+import fr.cemagref.simexplorer.is.exceptions.SimExplorerRuntimeException;
+import fr.cemagref.simexplorer.is.ui.swing.ui.JDetailTab;
+import fr.cemagref.simexplorer.is.ui.swing.ui.JSynchronizeTab;
import fr.cemagref.simexplorer.is.ui.swing.model.DataEntityModel;
import fr.cemagref.simexplorer.is.ui.swing.model.SimExplorerTabModel;
-import fr.cemagref.simexplorer.is.exceptions.SimExplorerRuntimeException;
+import fr.cemagref.simexplorer.is.ui.swing.ui.SimExplorerTab;
import jaxx.runtime.JAXXObject;
import jaxx.runtime.swing.JAXXTab;
import org.apache.commons.beanutils.Converter;
Modified: trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/model/DataEntityModel.java
===================================================================
--- trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/model/DataEntityModel.java 2008-02-20 18:45:27 UTC (rev 1144)
+++ trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/model/DataEntityModel.java 2008-02-20 18:46:01 UTC (rev 1145)
@@ -23,8 +23,8 @@
import fr.cemagref.simexplorer.is.entities.data.LoggableElement;
import fr.cemagref.simexplorer.is.entities.metadata.MetaData;
import fr.cemagref.simexplorer.is.entities.metadata.Version;
-import fr.cemagref.simexplorer.is.ui.SimExplorerContext;
-import fr.cemagref.simexplorer.is.ui.StorageServiceHelper;
+import fr.cemagref.simexplorer.is.ui.swing.SimExplorerContext;
+import fr.cemagref.simexplorer.is.ui.swing.StorageServiceHelper;
/**
* Le model d'un meta sélectionné dans un onglet
@@ -90,7 +90,7 @@
// acquire it
le = StorageServiceHelper.getElement(context, isRemote(), uuid, version.toString());
- if (le != null) {
+ if (le != null) {
meta = le.getMetaData();
}
return le;
@@ -225,7 +225,7 @@
@Override
public String toString() {
String s = super.toString();
- return s.substring(s.lastIndexOf('.')+1) + "<remote:" + remote + ", uuid:" + uuid +
+ return s.substring(s.lastIndexOf('.') + 1) + "<remote:" + remote + ", uuid:" + uuid +
", version:" + version + ", result:" + isResult() + ", type:" +
type + ">";
}
Modified: trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/model/DetailTabModel.java
===================================================================
--- trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/model/DetailTabModel.java 2008-02-20 18:45:27 UTC (rev 1144)
+++ trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/model/DetailTabModel.java 2008-02-20 18:46:01 UTC (rev 1145)
@@ -34,6 +34,7 @@
*/
public class DetailTabModel extends SimExplorerTabModel {
+ public static final String ROOT_NODE_PROPERTY_CHANGED = "rootNodePropertyChanged";
public static final String SELECTED_NODE_PROPERTY_CHANGED = "selectedNodePropertyChanged";
public static final String SELECTED_VERSION_INDEX_PROPERTY_CHANGED = "selectedVersionIndexPropertyChanged";
public static final String SELECTED_ATTACHMENT_INDEX_PROPERTY_CHANGED = "selectedAttachmentIndexPropertyChanged";
@@ -167,7 +168,7 @@
public void setDetail(MetaData detail) {
this.detail = detail;
- synch(isRemote(),detail);
+ synch(isRemote(), detail);
}
public void reset() {
Modified: trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/model/EntityTreeNode.java
===================================================================
--- trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/model/EntityTreeNode.java 2008-02-20 18:45:27 UTC (rev 1144)
+++ trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/model/EntityTreeNode.java 2008-02-20 18:46:01 UTC (rev 1145)
@@ -62,7 +62,7 @@
public Object get() {
LoggableElement le = getLoggableElement();
- if (le!=null) {
+ if (le != null) {
return le;
}
if (isResult()) {
@@ -70,7 +70,7 @@
}
return null;
}
-
+
public LoggableElement getLoggableElement() {
Object userObject = getUserObject();
if (userObject instanceof LoggableElement) {
Modified: trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/model/ListTabModel.java
===================================================================
--- trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/model/ListTabModel.java 2008-02-20 18:45:27 UTC (rev 1144)
+++ trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/model/ListTabModel.java 2008-02-20 18:46:01 UTC (rev 1145)
@@ -19,8 +19,8 @@
package fr.cemagref.simexplorer.is.ui.swing.model;
import fr.cemagref.simexplorer.is.entities.metadata.MetaData;
-import fr.cemagref.simexplorer.is.ui.SimExplorerContext;
-import fr.cemagref.simexplorer.is.ui.StorageServiceHelper;
+import fr.cemagref.simexplorer.is.ui.swing.SimExplorerContext;
+import fr.cemagref.simexplorer.is.ui.swing.StorageServiceHelper;
/**
* Le model pour un Tab contenant une liste d'application
@@ -90,7 +90,7 @@
@Override
public String toString() {
String s = super.toString();
- return s.substring(s.lastIndexOf(".") + 1) + "<size: " + size() + ",selectedItem:"+selectedItem+">";
+ return s.substring(s.lastIndexOf(".") + 1) + "<size: " + size() + ",selectedItem:" + selectedItem + ">";
}
public void setSelectedIndex(int selectedIndex) {
@@ -116,21 +116,27 @@
synch(remote, null, null);
// first query, build model
- updateTabModel(context, tableModel);
+ updateTabModel(context, tableModel, true);
}
- public void updateTabModel(SimExplorerContext context, ListTableModel tableModel) {
+ public void updateTabModel(SimExplorerContext context, ListTableModel tableModel, boolean deletePagination) {
// init pagination
- PaginationModel paginationModel;
- paginationModel = pagination == null ? initPagination(context) : pagination;
+ if (deletePagination) {
+ setPagination(null);
+ }
+ if (pagination == null) {
+ initPagination(context);
+ }
+ PaginationModel model = pagination;
+
// init query model
QueryModel queryModel;
queryModel = getQuery();
// obtain datas from service
- MetaData[] data = StorageServiceHelper.getData(context, remote, queryModel.isOnlyLatest(), queryModel.getQuery(), (int) paginationModel.getFirstIndex(), paginationModel.getWidth(), queryModel.getDateOrder());
+ MetaData[] data = StorageServiceHelper.getData(context, remote, queryModel.isOnlyLatest(), queryModel.getQuery(), (int) model.getFirstIndex(), model.getWidth(), queryModel.getDateOrder());
// save in model
setList(data);
@@ -145,15 +151,15 @@
long size = StorageServiceHelper.getCount(context, remote, query, queryModel.isOnlyLatest());
// init pagination
- PaginationModel paginationModel = getPagination();
- paginationModel.setFirstIndex(0);
- paginationModel.setSize(size);
+ PaginationModel model = getPagination();
+ model.setFirstIndex(0);
+ model.setSize(size);
// utilisation sizor par défaut
- paginationModel.setWidth(remote ? context.getConfig().getRemoteSizor() : context.getConfig().getLocalSizor());
+ model.setWidth(remote ? context.getConfig().getRemoteSizor() : context.getConfig().getLocalSizor());
// save pagination in model
- setPagination(paginationModel);
- return paginationModel;
+ setPagination(model);
+ return model;
}
private void checkSize(int index) {
Modified: trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/model/ListTableModel.java
===================================================================
--- trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/model/ListTableModel.java 2008-02-20 18:45:27 UTC (rev 1144)
+++ trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/model/ListTableModel.java 2008-02-20 18:46:01 UTC (rev 1145)
@@ -18,8 +18,8 @@
* ##% */
package fr.cemagref.simexplorer.is.ui.swing.model;
+import fr.cemagref.simexplorer.is.entities.EntityHelper;
import fr.cemagref.simexplorer.is.entities.metadata.MetaData;
-import fr.cemagref.simexplorer.is.entities.EntityHelper;
import static org.codelutin.i18n.I18n._;
import static org.codelutin.i18n.I18n.n_;
@@ -79,7 +79,7 @@
MetaData current = data[rowIndex];
if (current != null) {
try {
- if (columnIndex==1) {
+ if (columnIndex == 1) {
// use I18n
result = EntityHelper.Type.getLibelle(current);
} else {
Modified: trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/model/PaginationModel.java
===================================================================
--- trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/model/PaginationModel.java 2008-02-20 18:45:27 UTC (rev 1144)
+++ trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/model/PaginationModel.java 2008-02-20 18:46:01 UTC (rev 1145)
@@ -69,8 +69,8 @@
}
public int getNbPages() {
- int nbPages = (int) (size / width);
- if ((size%width!=0) || (nbPages == 0 && size > 0)) {
+ int nbPages = (int) (size / width);
+ if ((size % width != 0) || (nbPages == 0 && size > 0)) {
nbPages++;
}
return nbPages;
Modified: trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/model/QueryModel.java
===================================================================
--- trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/model/QueryModel.java 2008-02-20 18:45:27 UTC (rev 1144)
+++ trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/model/QueryModel.java 2008-02-20 18:46:01 UTC (rev 1145)
@@ -41,7 +41,7 @@
public boolean hasQuery() {
return query != null && !query.isEmpty();
}
-
+
public int getDateOrder() {
return dateOrder;
}
Modified: trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/model/SimExplorerTabModel.java
===================================================================
--- trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/model/SimExplorerTabModel.java 2008-02-20 18:45:27 UTC (rev 1144)
+++ trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/model/SimExplorerTabModel.java 2008-02-20 18:46:01 UTC (rev 1145)
@@ -20,7 +20,7 @@
import fr.cemagref.simexplorer.is.entities.data.LoggableElement;
import fr.cemagref.simexplorer.is.entities.metadata.MetaData;
import fr.cemagref.simexplorer.is.entities.metadata.Version;
-import fr.cemagref.simexplorer.is.ui.swing.SimExplorerTab;
+import fr.cemagref.simexplorer.is.ui.swing.ui.SimExplorerTab;
import jaxx.runtime.builder.TabModel;
import java.beans.PropertyChangeListener;
Modified: trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/model/SynchronizeTabModel.java
===================================================================
--- trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/model/SynchronizeTabModel.java 2008-02-20 18:45:27 UTC (rev 1144)
+++ trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/model/SynchronizeTabModel.java 2008-02-20 18:46:01 UTC (rev 1145)
@@ -20,8 +20,8 @@
import fr.cemagref.simexplorer.is.entities.data.LoggableElement;
import fr.cemagref.simexplorer.is.entities.metadata.Version;
-import fr.cemagref.simexplorer.is.ui.SimExplorerContext;
-import fr.cemagref.simexplorer.is.ui.StorageServiceHelper;
+import fr.cemagref.simexplorer.is.ui.swing.SimExplorerContext;
+import fr.cemagref.simexplorer.is.ui.swing.StorageServiceHelper;
/**
* Le model pour un Tab contenant 2 arbres de navigation de LE
@@ -30,17 +30,24 @@
*/
public class SynchronizeTabModel extends SimExplorerTabModel {
- public static final String ROOT_LOCAL_NODE_PROPERTY_CHANGED = "rootLocalNodePropertyChanged";
+ /** la clef de l'évènement après la modification du root de l'arbre local */
+ public static final String LOCAL_ROOT_NODE_PROPERTY_CHANGED = "rootLocalNodePropertyChanged";
- public static final String ROOT_REMOTE_NODE_PROPERTY_CHANGED = "rootRemoteNodePropertyChanged";
+ /** la clef de l'évènement après la modification du root de l'arbre distant */
+ public static final String REMOTE_ROOT_NODE_PROPERTY_CHANGED = "rootRemoteNodePropertyChanged";
- public static final String SELECTED_LOCAL_NODE_PROPERTY_CHANGED = "selectedLocalNodePropertyChanged";
+ /** la clef de l'évènement après la modification du noeud sélectionné dans l'arbre local */
+ public static final String LOCAL_SELECTED_NODE_PROPERTY_CHANGED = "selectedLocalNodePropertyChanged";
- public static final String SELECTED_REMOTE_NODE_PROPERTY_CHANGED = "selectedRemoteNodePropertyChanged";
+ /** la clef de l'évènement après la modification du noeud sélectionné dans l'arbre distant */
+ public static final String REMOTE_SELECTED_NODE_PROPERTY_CHANGED = "selectedRemoteNodePropertyChanged";
private static final long serialVersionUID = -3623331875470531459L;
- /** la racine de l'arbre de nivation local. */
+ /** l'element source de la synchronisation */
+ protected DataEntityModel source;
+
+ /** la racine de l'arbre de navigation local. */
protected LoggableElement localRootNode;
/** la racine de l'abre de navigation distant. */
@@ -69,13 +76,21 @@
}
public String getRootProperty(boolean remote) {
- return remote ? ROOT_REMOTE_NODE_PROPERTY_CHANGED : ROOT_LOCAL_NODE_PROPERTY_CHANGED;
+ return remote ? REMOTE_ROOT_NODE_PROPERTY_CHANGED : LOCAL_ROOT_NODE_PROPERTY_CHANGED;
}
public String getSelectedProperty(boolean remote) {
- return remote ? SELECTED_REMOTE_NODE_PROPERTY_CHANGED : SELECTED_LOCAL_NODE_PROPERTY_CHANGED;
+ return remote ? REMOTE_SELECTED_NODE_PROPERTY_CHANGED : LOCAL_SELECTED_NODE_PROPERTY_CHANGED;
}
+ public DataEntityModel getSource() {
+ return source;
+ }
+
+ public void setSource(DataEntityModel source) {
+ this.source = source;
+ }
+
public void setRootNode(LoggableElement source, boolean remote) {
String property = getRootProperty(remote);
LoggableElement oldRootNode = getRootNode(remote);
@@ -101,8 +116,11 @@
public void updateTabModel(SimExplorerContext context, DataEntityModel selected) {
// on nettoye le model avant tout
+
reset();
+ setSource(selected);
+
if (selected == null) {
// rien de plus à faire
return;
1
0
r1144 - trunk/simexplorer-is/simexplorer-is-swing/src/test/fr/cemagref/simexplorer/is/ui/swing
by tchemit@users.labs.libre-entreprise.org 20 Feb '08
by tchemit@users.labs.libre-entreprise.org 20 Feb '08
20 Feb '08
Author: tchemit
Date: 2008-02-20 18:45:27 +0000 (Wed, 20 Feb 2008)
New Revision: 1144
Removed:
trunk/simexplorer-is/simexplorer-is-swing/src/test/fr/cemagref/simexplorer/is/ui/swing/SimExplorerUIRefreshHelperTest.java
Log:
move ui to ui package
Deleted: trunk/simexplorer-is/simexplorer-is-swing/src/test/fr/cemagref/simexplorer/is/ui/swing/SimExplorerUIRefreshHelperTest.java
===================================================================
--- trunk/simexplorer-is/simexplorer-is-swing/src/test/fr/cemagref/simexplorer/is/ui/swing/SimExplorerUIRefreshHelperTest.java 2008-02-20 18:45:16 UTC (rev 1143)
+++ trunk/simexplorer-is/simexplorer-is-swing/src/test/fr/cemagref/simexplorer/is/ui/swing/SimExplorerUIRefreshHelperTest.java 2008-02-20 18:45:27 UTC (rev 1144)
@@ -1,77 +0,0 @@
-package fr.cemagref.simexplorer.is.ui.swing;
-
-import junit.framework.TestCase;
-
-/**
- * SimExplorerUIRefreshHelper Tester.
- *
- * @author chemit
- * @version 1.0
- * @since <pre>02/08/2008</pre>
- */
-public class SimExplorerUIRefreshHelperTest extends TestCase {
- int max = 14;
- public SimExplorerUIRefreshHelperTest(String name) {
- super(name);
- }
-
- public void testComputeRowLimitCases() throws Exception {
- for (int i = 0; i < max+1; i++) {
- assertComputeRow(0, i, DetailTabRefreshHelper.computeRows(0, i));
- }
- for (int i = 0; i < max+1; i++) {
- assertComputeRow(i, 0, DetailTabRefreshHelper.computeRows(i, 0));
- }
- assertComputeRow(0, max, DetailTabRefreshHelper.computeRows(0, max+1));
- assertComputeRow(max, 0, DetailTabRefreshHelper.computeRows(max+1, 0));
- }
-
-
- public void testComputeRowDescriptor() throws Exception {
- for (int i = 1; i < max-1; i++) {
- testComputeRowDescriptor(i);
- }
- }
-
- public void testComputeRowAttachment() throws Exception {
- for (int i = 1; i < max-1; i++) {
- testComputeRowAttachment(i);
- }
- }
-
- public void testComputeRowAttachment(int nb) throws Exception {
- int pivot = max - nb;
- for (int i = 0; i < pivot + 1; i++) {
- assertComputeRow(i, nb, DetailTabRefreshHelper.computeRows(i, nb));
- }
- for (int i = pivot + 1; i < max+1; i++) {
- if (nb + i > max) {
- int[] res = DetailTabRefreshHelper.computeRows(i, nb);
- assertEquals(max, res[0] + res[1]);
- } else {
- assertComputeRow(pivot, nb, DetailTabRefreshHelper.computeRows(i, nb));
- }
- }
- }
-
- public void testComputeRowDescriptor(int nb) throws Exception {
- int pivot = max - nb;
- for (int i = 0; i < pivot + 1; i++) {
- assertComputeRow(nb, i, DetailTabRefreshHelper.computeRows(nb, i));
- }
- for (int i = pivot + 1; i < max+1; i++) {
- if (nb + i > max) {
- int[] res = DetailTabRefreshHelper.computeRows(nb, i);
- assertEquals(max, res[0] + res[1]);
- } else {
- assertComputeRow(nb, pivot, DetailTabRefreshHelper.computeRows(nb, i));
- }
- }
- }
-
- public void assertComputeRow(int expectedOne, int expectedTwo, int[] result) {
- assertEquals(expectedOne, result[0]);
- assertEquals(expectedTwo, result[1]);
- }
-
-}
1
0
r1143 - in trunk/simexplorer-is/simexplorer-is-swing/src: java/fr/cemagref/simexplorer/is/ui/swing java/fr/cemagref/simexplorer/is/ui/swing/ui test/fr/cemagref/simexplorer/is/ui/swing test/fr/cemagref/simexplorer/is/ui/swing/ui
by tchemit@users.labs.libre-entreprise.org 20 Feb '08
by tchemit@users.labs.libre-entreprise.org 20 Feb '08
20 Feb '08
Author: tchemit
Date: 2008-02-20 18:45:16 +0000 (Wed, 20 Feb 2008)
New Revision: 1143
Added:
trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/ui/
trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/ui/DetailTabRefreshHelper.java
trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/ui/EntityTreeNodeHelper.java
trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/ui/ListTabRefreshHelper.java
trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/ui/MainUIRefreshHelper.java
trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/ui/SimExplorerMainUI.java
trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/ui/SimExplorerTab.java
trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/ui/SimExplorerTabFactory.java
trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/ui/SynchronizeTabRefreshHelper.java
trunk/simexplorer-is/simexplorer-is-swing/src/test/fr/cemagref/simexplorer/is/ui/swing/ui/
trunk/simexplorer-is/simexplorer-is-swing/src/test/fr/cemagref/simexplorer/is/ui/swing/ui/SimExplorerUIRefreshHelperTest.java
Removed:
trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/DetailTabRefreshHelper.java
trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/EntityTreeNodeHelper.java
trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/ListTabRefreshHelper.java
trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/MainUIRefreshHelper.java
trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/SimExplorerMainUI.java
trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/SimExplorerTab.java
trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/SimExplorerTabFactory.java
trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/SynchronizeTabRefreshHelper.java
Log:
move ui to ui package
Deleted: trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/DetailTabRefreshHelper.java
===================================================================
--- trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/DetailTabRefreshHelper.java 2008-02-20 18:43:44 UTC (rev 1142)
+++ trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/DetailTabRefreshHelper.java 2008-02-20 18:45:16 UTC (rev 1143)
@@ -1,294 +0,0 @@
-/*
-* ##% Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008 Code Lutin,
-* Tony Chemit, Gabriel Landais
-*
-* 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 fr.cemagref.simexplorer.is.ui.swing;
-
-import fr.cemagref.simexplorer.is.entities.EntityHelper;
-import fr.cemagref.simexplorer.is.entities.attachment.Attachment;
-import fr.cemagref.simexplorer.is.entities.data.LoggableElement;
-import fr.cemagref.simexplorer.is.entities.metadata.MetaData;
-import fr.cemagref.simexplorer.is.entities.metadata.Version;
-import fr.cemagref.simexplorer.is.ui.SimExplorer;
-import fr.cemagref.simexplorer.is.ui.swing.model.DetailTabModel;
-import fr.cemagref.simexplorer.is.ui.swing.model.DetailTableModel;
-import fr.cemagref.simexplorer.is.ui.swing.model.EntityTreeNode;
-import fr.cemagref.simexplorer.is.ui.swing.model.HistoryModel;
-import static org.codelutin.i18n.I18n._;
-
-import javax.swing.DefaultComboBoxModel;
-import javax.swing.DefaultListModel;
-import javax.swing.JList;
-import javax.swing.JTable;
-import javax.swing.tree.DefaultTreeModel;
-import java.awt.Dimension;
-import java.awt.Rectangle;
-import java.text.SimpleDateFormat;
-import java.util.List;
-
-/**
- * Cette classe contient les méthodes utiles et réutilisables pour rafraichir
- * l'onglet de detail.
- * <p/>
- * Les méthodes utilisent les données stockées dans les modèles pour rafraichir
- * les uis concernées.
- * <p/>
- * Note : <b>Dans toutes ces méthodes, NOS modèles ne doivent en aucun cas être modifiés</b>
- * <p/>
- * Par contre les modèles des ui peuvent être modifiés (par exemple modèle d'arbre, de liste)
- * mais uniquement à partir de nos modèles.
- *
- * @author chemit
- */
-public class DetailTabRefreshHelper {
-
- public static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy.MM.dd HH:mm:ss.SSS");
-
- public static void refreshDetailTab(JDetailTab ui, DetailTabModel model) {
- EntityTreeNode root = EntityTreeNodeHelper.build(model.getRootNode(), model.isRemote());
- EntityTreeNode current = model.getHistory().getCurrent();
- //FIXME : if object has different version, it says that this is same!!!
- if (current == null || !root.getUserObject().equals(current.getUserObject())) {
- model.getHistory().add(root);
- }
- DetailTabRefreshHelper.updateDetailNavigationTree(ui, model.getHistory());
- }
-
- /**
- * Rafraichit les actions d'un node dans l'arbre de navigation
- *
- * @param ui l'onglet de détail
- * @param model le model de d'onglet detail
- * @param node le node sélectionné dans l'arbre de navigation
- */
- public static void refreshDetailActions(JDetailTab ui, DetailTabModel model, EntityTreeNode node) {
- // refresh synchronize action button
- refreshSynchroniseAction(ui, model);
- // refresh download LoggableElement button
- refreshDownloadElementAction(ui, model, node);
- // refresh delete button
- refreshDeleteAction(ui, model);
- // refresh export button
- refreshExportAction(ui, model);
- // refresh download Attachment button
- refreshDownloadAttachmentAction(ui, model);
- }
-
- public static void refreshTreeDetailActions(JDetailTab ui, EntityTreeNode node) {
- EntityTreeNodeHelper.refreshTreeActions(ui.getCollapseAllDetail(), ui.getExpandAllDetail(), node);
- }
-
- public static void refreshDownloadElementAction(JDetailTab ui, DetailTabModel model, EntityTreeNode node) {
- MetaData detail = model.getDetail();
- boolean enabled = EntityHelper.Action.DOWNLOAD.accept(node);
- MainUIRefreshHelper.UpdateButton(ui.getDownloadElement(), enabled, enabled ? detail == null ? node.getUserObject() : detail.getName() + " [" + model.getSelectedVersion() + "]" : null);
- }
-
- protected static void refreshDeleteAction(JDetailTab ui, DetailTabModel model) {
- MetaData detail = model.getDetail();
- boolean enabled = EntityHelper.Action.DELETE.accept(detail);
- MainUIRefreshHelper.UpdateButton(ui.getDeleteElement(), enabled, enabled ? detail.getName() + " [" + model.getSelectedVersion() + "]" : null);
- }
-
- public static void refreshDownloadAttachmentAction(JDetailTab ui, DetailTabModel model) {
- Attachment attachment = model.getSelectedAttachment();
- boolean enabled = model.getDetail() != null && attachment != null;
- MainUIRefreshHelper.UpdateButton(ui.getDownloadAttachment(), enabled, enabled ? attachment : null);
- }
-
- public static void refreshDetailToTreeAction(JDetailTab ui, DetailTabModel model) {
- MetaData detail = model.getDetail();
- EntityTreeNode rootNode = model.getHistory().getCurrent();
- LoggableElement rootElement = (LoggableElement) rootNode.getUserObject();
- MetaData data = rootElement.getMetaData();
- Version version = model.getSelectedVersion();
- if (version == null) {
- // la version peut être null, ce qui veut dire que l'on vient d'un changement
- // de node dans l'arbre de navigation et donc la version est celle du detai
- version = detail.getVersion();
- }
- boolean enabled = !(detail.getName().equals(data.getName()) && data.getVersion().equals(version));
-
- MainUIRefreshHelper.UpdateButton(ui.getDetailToTree(), enabled, enabled ? detail.getName() + " [" + version + "]" : null);
- }
-
- public static void refreshSynchroniseAction(JDetailTab ui, DetailTabModel model) {
- MetaData detail = model.getDetail();
- boolean enabled = detail != null && SimExplorer.getContext().isConnected();
- MainUIRefreshHelper.UpdateButton(ui.getShowTab_synchronize(), enabled, enabled ? detail.getName() + " [" + model.getSelectedVersion() + "]" : null);
- }
-
- public static void refreshExportAction(JDetailTab ui, DetailTabModel model) {
- LoggableElement sNode = model.getSelectedNode();
- MainUIRefreshHelper.refreshExportElement(ui.getExportElement(),
- model.isRemote(),
- sNode);
- }
-
- public static void resetHistory(JDetailTab ui, DetailTabModel model, DefaultComboBoxModel historyModel) {
- historyModel.removeAllElements();
- LoggableElement selectedNode = model.getSelectedNode();
- Version[] versions = model.getVersions();
- boolean nodetail = versions == null || selectedNode == null;
- if (nodetail) {
- resetDetailPanel(ui);
- } else {
- ui.getDetailHeaderFromLocal().setVisible(!model.isRemote());
- ui.getDetailHeaderFromRemote().setVisible(model.isRemote());
- for (Version version : versions) {
- historyModel.addElement(version);
- }
- boolean enabled = ui.getDetailVersions().getItemCount() > 1;
- ui.getDetailVersions().setEnabled(enabled);
- String text;
- text = !enabled ? null : _("simexplorer.action.changeVersion.tooltip");
- ui.getDetailVersions().setToolTipText(text);
- }
- // can not synchronize to tree
- MainUIRefreshHelper.UpdateButton(ui.getDetailToTree(), false);
- }
-
- public static void resetDetailPanel(final JDetailTab ui) {
- ui.getDetailVersions().setVisible(false);
- ui.getDetailHeader().setText(_("simexplorer.node.nodetail"));
- ui.getDetailAttachmentsHeader().setText(_("simexplorer.node.noattachments"));
- JList listAttchments = ui.getDetailAttachments();
- listAttchments.clearSelection();
- DefaultListModel listModel = (DefaultListModel) listAttchments.getModel();
- listModel.setSize(0);
- listModel.trimToSize();
- ui.getDetail().setVisible(false);
- ((DetailTableModel) ui.getDetailTable().getModel()).setData(null);
- }
-
- public static void updateDetailNavigationTree(JDetailTab ui, HistoryModel<EntityTreeNode> model) {
- // push it in tree model
- ((DefaultTreeModel) ui.getNavigationTree().getModel()).setRoot(model.getCurrent());
- // by default select the root node
- if (ui.getNavigationTree().getModel().getRoot() != null) {
- ui.getNavigationTree().setSelectionRow(0);
- }
- boolean enabled;
- enabled = model.size() > 1 && model.hasPrevious();
- MainUIRefreshHelper.UpdateButton(ui.getHistoryPrevious(), enabled, !enabled ? null : model.getPrevious());
- enabled = model.size() > 1 && model.hasNext();
- MainUIRefreshHelper.UpdateButton(ui.getHistoryNext(), enabled, !enabled ? null : model.getNext());
- }
-
- public static void updateDetailPanel(Integer index, final JDetailTab ui, DetailTabModel model, LoggableElement selectedNode) {
- MetaData detail = model.getDetail();
- ui.getDetailVersions().setVisible(true);
- if (ui.getDetailVersions().getItemCount() > 0) {
- ui.getDetailVersions().setSelectedIndex(index);
- }
- ui.getDetailHeader().setText(selectedNode.getMetaData().getName());
- ui.getDetailDescriptorsHeader().setText(_("simexplorer.node.descriptors", detail.getDescriptors().size()));
- ui.getDetailType().setText(EntityHelper.Type.getLibelle(detail));
- String s = detail.getDescription();
- String tooltip = s;
- if (s.length() > 32) {
- s = s.substring(0, 32) + "...";
- }
- ui.getDetailDescription().setText(s);
- if (!s.equals(tooltip)) {
- ui.getDetailDescription().setToolTipText(tooltip);
- }
- ui.getDetailCreationDate().setText(DATE_FORMAT.format(detail.getCreationDate()));
- ui.getDetail().setVisible(true);
- JTable table = ui.getDetailTable();
- ((DetailTableModel) table.getModel()).setData(detail);
- int nbDescriptorRows = table.getRowCount();
-
- List<Attachment> attachments = detail.getAttachments();
- JList listAttachments = ui.getDetailAttachments();
- DefaultListModel listModel = (DefaultListModel) listAttachments.getModel();
- listModel.setSize(0);
- listModel.trimToSize();
- int nbAttachmentRows;
- if (attachments.isEmpty()) {
- ui.getDetailAttachmentsHeader().setText(_("simexplorer.node.noattachments"));
- ui.getScrollAttachments().setVisible(false);
- nbAttachmentRows = 0;
- } else {
- ui.getDetailAttachmentsHeader().setText(EntityHelper.Type.Attachment.getLibelles() + " (" + attachments.size() + ")");
- for (Attachment attachment : attachments) {
- listModel.addElement(attachment);
- }
- listAttachments.setSelectedIndex(0);
- nbAttachmentRows = listModel.getSize();
- ui.getScrollAttachments().setVisible(true);
- }
-
- int[] rows = computeRows(nbDescriptorRows, nbAttachmentRows);
-
- Dimension dimOneRow = table.getUI().getPreferredSize(table.getTableHeader());
-
- ui.getScrollTable().setPreferredSize(new Dimension((int) dimOneRow.getWidth(), 2 + ((rows[0] + 1) * (4 + table.getFont().getSize()))));
- //ui.getScrollTable().setPreferredSize(new Dimension((int) table.getSize().getWidth(), 2 + (nbDescriptorRows * (4 + table.getFont().getSize()))));
- if (nbAttachmentRows > 0) {
- Rectangle rect = listAttachments.getUI().getCellBounds(listAttachments, 0, 0);
- ui.getScrollAttachments().setPreferredSize(new Dimension((int) rect.getWidth() - 4, (int) (3 + rows[1] * rect.getHeight())));
- }
-
- table.invalidate();
- listAttachments.invalidate();
- ui.getScrollPane().invalidate();
- ui.repaint();
- }
-
- protected static int[] computeRows(int nbDescriptorRows, int nbAttachmentRows) {
- int[] result = new int[2];
- int max = 14;
- int maxOne = max / 2;
- if (nbDescriptorRows == 0) {
- result[0] = 0;
- result[1] = nbAttachmentRows > max ? max : nbAttachmentRows;
- return result;
- }
- if (nbAttachmentRows == 0) {
- result[0] = nbDescriptorRows > max ? max : nbDescriptorRows;
- result[1] = 0;
- return result;
- }
- if (nbAttachmentRows < maxOne + 1 && nbDescriptorRows < maxOne + 1) {
- result[0] = nbDescriptorRows;
- result[1] = nbAttachmentRows;
- return result;
- }
- if (nbDescriptorRows > maxOne && nbAttachmentRows > maxOne) {
- result[0] = result[1] = maxOne;
- return result;
- }
- if (nbDescriptorRows < maxOne + 1) {
- result[0] = nbDescriptorRows;
- int i = max - nbDescriptorRows;
- result[1] = nbAttachmentRows < i ? nbAttachmentRows : i;
- return result;
- }
- if (nbAttachmentRows < maxOne + 1) {
- int i = max - nbAttachmentRows;
- result[0] = nbDescriptorRows < i ? nbDescriptorRows : i;
- result[1] = nbAttachmentRows;
- return result;
- }
- throw new IllegalStateException("can not come her :)");
- }
-
- protected DetailTabRefreshHelper() {
- // do not instanciate me please
- }
-}
\ No newline at end of file
Deleted: trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/EntityTreeNodeHelper.java
===================================================================
--- trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/EntityTreeNodeHelper.java 2008-02-20 18:43:44 UTC (rev 1142)
+++ trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/EntityTreeNodeHelper.java 2008-02-20 18:45:16 UTC (rev 1143)
@@ -1,308 +0,0 @@
-/*
-* ##% Copyright (C) 2007, 2008 Code Lutin,
-* Tony Chemit, Gabriel Landais
-*
-* 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 fr.cemagref.simexplorer.is.ui.swing;
-
-import static fr.cemagref.simexplorer.is.entities.EntityHelper.Type.Code;
-import static fr.cemagref.simexplorer.is.entities.EntityHelper.Type.Component;
-import static fr.cemagref.simexplorer.is.entities.EntityHelper.Type.Constant;
-import static fr.cemagref.simexplorer.is.entities.EntityHelper.Type.ConstantValue;
-import static fr.cemagref.simexplorer.is.entities.EntityHelper.Type.ExplorationData;
-import static fr.cemagref.simexplorer.is.entities.EntityHelper.Type.Library;
-import static fr.cemagref.simexplorer.is.entities.EntityHelper.Type.Structure;
-import fr.cemagref.simexplorer.is.entities.EntityVisitable;
-import fr.cemagref.simexplorer.is.entities.SimpleEntityVisitor;
-import fr.cemagref.simexplorer.is.entities.data.Code;
-import fr.cemagref.simexplorer.is.entities.data.Component;
-import fr.cemagref.simexplorer.is.entities.data.Constant;
-import fr.cemagref.simexplorer.is.entities.data.ConstantValue;
-import fr.cemagref.simexplorer.is.entities.data.ExplorationApplication;
-import fr.cemagref.simexplorer.is.entities.data.ExplorationData;
-import fr.cemagref.simexplorer.is.entities.data.Library;
-import fr.cemagref.simexplorer.is.entities.data.LoggableElement;
-import fr.cemagref.simexplorer.is.entities.data.Result;
-import fr.cemagref.simexplorer.is.entities.data.Structure;
-import fr.cemagref.simexplorer.is.entities.metadata.MetaData;
-import fr.cemagref.simexplorer.is.ui.swing.model.EntityTreeNode;
-
-import javax.swing.AbstractButton;
-import javax.swing.JTree;
-import javax.swing.tree.TreePath;
-import java.util.Collection;
-
-/**
- * La classe responsable de la création des arbres de {@link fr.cemagref.simexplorer.is.ui.swing.model.EntityTreeNode}
- * à partir de {@link LoggableElement} .
- * <p/>
- * La classe possède une instance cachée par thread qui délègue la construction
- * del'arbre de navigation à un visiteur de {@link LoggableElement}.
- * <p/>
- *
- * @author chemit
- */
-public class EntityTreeNodeHelper {
-
- /** L'instance cachée de builder par Thread. */
- protected static final ThreadLocal<EntityVisitorBuilder> builder =
- new ThreadLocal<EntityVisitorBuilder>() {
- @Override
- protected EntityVisitorBuilder initialValue() {
- return new EntityVisitorBuilder();
- }
- };
-
- /**
- * Construit un arbre de navigation à partir d'un {@link LoggableElement}.
- *
- * @param v la donnée à visiter
- * @param remote flag pour indiquer si on travaille sur des données locales
- * ou en remote.
- * @return le noeud parent de l'arbre de nivation construit.
- */
- public static EntityTreeNode build(LoggableElement v, boolean remote) {
- EntityVisitorBuilder instance;
- synchronized (instance = EntityTreeNodeHelper.builder.get()) {
- EntityTreeNode result;
- // walk
- result = instance.visit(v, remote);
- return result;
- }
- }
-
- public static EntityTreeNode getSelectedNodeOrRootNode(JTree tree) {
- EntityTreeNode node = getSelectedNode(tree);
- if (node == null) {
- return getRootNode(tree);
- }
- return node;
- }
-
- public static EntityTreeNode getSelectedNode(JTree tree) {
- TreePath path = tree.getSelectionPath();
- EntityTreeNode node = null;
- if (path != null) {
- Object o = path.getLastPathComponent();
- if (o != null && !(o instanceof EntityTreeNode)) {
- return null;
- }
- node = (EntityTreeNode) o;
- }
- return node;
- }
-
- public static EntityTreeNode getRootNode(JTree tree) {
- EntityTreeNode node;
- // take the root node
- Object root = tree.getModel().getRoot();
- if (root == null || !(root instanceof EntityTreeNode)) {
- return null;
- }
- node = (EntityTreeNode) root;
- return node;
- }
-
- public static void refreshTreeActions(AbstractButton collapseButton, AbstractButton expandButton, EntityTreeNode node) {
- boolean enabled = node != null && !node.isLeaf() && node.getChildCount() > 0;
- Object o = enabled?node.getUserObject():null;
- MainUIRefreshHelper.UpdateButton(collapseButton, enabled, o );
- MainUIRefreshHelper.UpdateButton(expandButton, enabled, o);
- }
-
- protected EntityTreeNodeHelper() {
- // no instance
- }
-
- /**
- * Implantation de {@link SimpleEntityVisitor} pour construire l'arbre
- * de navigation d'un {@link LoggableElement}.
- * <p/>
- * Cette classe est stateless, tous ces états internes doivent être nettoyé
- * après une visite, en utilisant la méthode {@link #reset()}.
- * <p/>
- */
- public static class EntityVisitorBuilder extends SimpleEntityVisitor {
-
- /**
- * le noeud parent de tous les autres.
- * <p/>
- * Ce noeud est positionné par la méthode
- * {@link #markRootNode(EntityTreeNode)}.
- */
- protected EntityTreeNode rootNode;
-
- /**
- * flag qui indique si on travaille sur des objet locaux ou distants.
- * <p/>
- * Cette information est conservé dans les nodes pour permettre de gérer
- * de manière transparent des objet locaux ou distants.
- */
- protected Boolean remote;
-
- /** les nodes internes utilisés pendant la visite. */
- protected EntityTreeNode explorationApplication,
- component,
- explorationData,
- components,
- explorationDatas,
- libraries,
- constants,
- strutures,
- codes,
- constantValues;
-
- public EntityTreeNode visit(EntityVisitable v, boolean remote) {
- reset();
- try {
- this.remote = remote;
- super.visit(v);
- EntityTreeNode result;
- result = this.rootNode;
- return result;
- } finally {
- reset();
- }
- }
-
- @Override
- public void visitMetaData(MetaData v) {
- // do not visit meta data (for the moment we dont need thoses
- // informations in navigation tree), but it could be interresting
- // for example to display attchments here ?
- }
-
- @Override
- public void visitExplorationApplication(ExplorationApplication v) {
- markRootNode(explorationApplication = new EntityTreeNode(null, v, remote, true));
- super.visitExplorationApplication(v);
- }
-
- @Override
- public void visitComponent(Component v) {
- markRootNode(component = new EntityTreeNode(components, v, remote, true));
- super.visitComponent(v);
- }
-
- @Override
- public void visitExplorationData(ExplorationData v) {
- markRootNode(explorationData = new EntityTreeNode(explorationDatas, v, remote, true));
- super.visitExplorationData(v);
- }
-
- @Override
- public void visitCodes(Collection<Code> vs) {
- codes = new EntityTreeNode(component, Code.getLibelles(), remote, true);
- super.visitCodes(vs);
- }
-
- @Override
- public void visitComponents(Collection<Component> vs) {
- components = new EntityTreeNode(explorationApplication, Component.getLibelles(), remote, true);
- super.visitComponents(vs);
- }
-
- @Override
- public void visitConstants(Collection<Constant> vs) {
- constants = new EntityTreeNode(component, Constant.getLibelles(), remote, true);
- super.visitConstants(vs);
- }
-
- @Override
- public void visitConstantValues(Collection<ConstantValue> vs) {
- constantValues = new EntityTreeNode(explorationData, ConstantValue.getLibelles(), remote, true);
- super.visitConstantValues(vs);
- }
-
- @Override
- public void visitExplorationDatas(Collection<ExplorationData> vs) {
- explorationDatas = new EntityTreeNode(explorationApplication, ExplorationData.getLibelles(), remote, true);
- super.visitExplorationDatas(vs);
- }
-
- @Override
- public void visitLibraries(Collection<Library> vs) {
- libraries = new EntityTreeNode(component, Library.getLibelles(), remote, true);
- super.visitLibraries(vs);
- }
-
- @Override
- public void visitStructures(Collection<Structure> vs) {
- strutures = new EntityTreeNode(component, Structure.getLibelles(), remote, true);
- super.visitStructures(vs);
- }
-
- @Override
- public void visitConstant(Constant v) {
- markRootNode(new EntityTreeNode(constants, v, remote, false));
- }
-
- @Override
- public void visitLibrary(Library v) {
- markRootNode(new EntityTreeNode(libraries, v, remote, false));
- }
-
- @Override
- public void visitResult(Result v) {
- if (v != null) {
- markRootNode(new EntityTreeNode(explorationData, v, remote, false));
- }
- }
-
- @Override
- public void visitCode(Code v) {
- new EntityTreeNode(codes, v, remote, false);
- }
-
- @Override
- public void visitConstantValue(ConstantValue v) {
- new EntityTreeNode(
- new EntityTreeNode(constantValues, v.getConstant().getName(), remote, true),
- v.getValue(), remote, false);
- }
-
- @Override
- public void visitStructure(Structure v) {
- new EntityTreeNode(strutures, v, remote, false);
- }
-
- /**
- * Tente de marquerle node donné comme noeud ancêtre de tous les autres.
- * <p/>
- * Le positionnement n'a lieu que si on a pas encore de rootNode.
- *
- * @param node le node a positionner comme rootNode (si nessecaire)
- */
- protected void markRootNode(EntityTreeNode node) {
- if (rootNode == null) {
- rootNode = node;
- }
- }
-
- /**
- * La méthode pour réinitialiser les états interne de la classe.
- * <p/>
- * Cette méthode doit être appeler après chaque visite, afin d'assurer
- * la propriété stateless de la classe.
- */
- protected void reset() {
- remote = null;
- rootNode = explorationApplication = explorationDatas = explorationData
- = components = component = constants = codes = libraries
- = constantValues = null;
- }
- }
-}
Deleted: trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/ListTabRefreshHelper.java
===================================================================
--- trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/ListTabRefreshHelper.java 2008-02-20 18:43:44 UTC (rev 1142)
+++ trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/ListTabRefreshHelper.java 2008-02-20 18:45:16 UTC (rev 1143)
@@ -1,176 +0,0 @@
-/*
-* ##% Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008 Code Lutin,
-* Tony Chemit, Gabriel Landais
-*
-* 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 fr.cemagref.simexplorer.is.ui.swing;
-
-import fr.cemagref.simexplorer.is.entities.EntityHelper;
-import fr.cemagref.simexplorer.is.entities.metadata.MetaData;
-import fr.cemagref.simexplorer.is.ui.SimExplorer;
-import fr.cemagref.simexplorer.is.ui.swing.model.DataEntityModel;
-import fr.cemagref.simexplorer.is.ui.swing.model.ListTabModel;
-import fr.cemagref.simexplorer.is.ui.swing.model.PaginationModel;
-
-import javax.swing.JComboBox;
-import javax.swing.SwingUtilities;
-import javax.swing.ListSelectionModel;
-
-/**
- * Cette classe contient les méthodes utiles et réutilisables pour rafraichir
- * les onglets de liste.
- * <p/>
- * Les méthodes utilisent les données stockées dans les modèles pour rafraichir
- * les uis concernées.
- * <p/>
- * Note : <b>Dans toutes ces méthodes, NOS modèles ne doivent en aucun cas être modifiés</b>
- * <p/>
- * Par contre les modèles des ui peuvent être modifiés (par exemple modèle d'arbre, de liste)
- * mais uniquement à partir de nos modèles.
- *
- * @author chemit
- */
-public class ListTabRefreshHelper {
-
- /**
- * Rafraichit un onglet de type liste à partir de son modèle.
- *
- * @param ui l'onglet de liste à utiliser
- * @param model le modèle de liste à utiliser
- */
- public static void refreshListTabUI(final JListTab ui, final ListTabModel model) {
-
- SwingUtilities.invokeLater(new Runnable() {
- public void run() {
-
- // refresh search text
- ui.getSearchText().setText(model.getQuery().getQuery());
-
- // refresh search actions
- refreshSearchActions(ui, model);
-
- // refresh pagination actions
- refreshPagination(ui, model.getPagination());
-
-
- ListSelectionModel selectionModel = ui.getTable().getSelectionModel();
- if (!model.isEmpty() && selectionModel.isSelectionEmpty()) {
- // always select the first row (to init selectedItem)
- selectionModel.setSelectionInterval(0, 0);
- } else {
- selectionModel.clearSelection();
- }
-
- // table data model may have changed, must revalidate
- ui.getTable().invalidate();
-
- // repaint the frame
- SimExplorer.getUI().repaint();
- }
- });
- }
-
- public static void refreshListTablePopupMenu(final JListTab ui, final ListTabModel model) {
- DataEntityModel item = model.getSelectedItem();
- ui.getTablePopupMenu().setEnabled(item != null);
- int index = model.getSelectedIndex();
- if (item == null || index==-1) {
- return;
- }
- MetaData data = model.get(index);
-
- String text = data.getName() + " [" + data.getVersion() + "]";
-
- MainUIRefreshHelper.UpdateButton(ui.getDownloadElement(), EntityHelper.Action.DOWNLOAD.accept(data), text);
-
- MainUIRefreshHelper.UpdateButton(ui.getDeleteElement(), EntityHelper.Action.DELETE.accept(data), text);
-
- boolean isConnected = SimExplorer.getContext().isConnected();
- boolean enabled = isConnected && EntityHelper.Action.EXPORT.accept(data);
-
- MainUIRefreshHelper.refreshExportElement(ui.getExportElement(),enabled, model.isRemote(),data.getName(),data.getVersion().toString());
-
- MainUIRefreshHelper.UpdateButton(ui.getShowTab_detail(), true, text);
- MainUIRefreshHelper.UpdateButton(ui.getShowTab_synchronize(), isConnected, text);
- }
-
- /**
- * Rafraichit les actions de recherche d'un onglet de type liste.
- *
- * @param ui l'onglet de liste à utiliser
- * @param model le modèle de liste à utiliser
- */
- public static void refreshSearchActions(JListTab ui, ListTabModel model) {
- String text = ui.getSearchText().getText();
- boolean hasQuery = model.getQuery().hasQuery();
- ui.getSearch().setEnabled(hasQuery || !text.isEmpty());
- ui.getResetSearch().setEnabled(hasQuery || !text.isEmpty());
- }
-
- public static void refreshPagination(JListTab ui, PaginationModel pagination) {
-
- // refresh changePage combobox
- refreshChangePageCombo(ui, pagination);
-
- // refresh changeSizor combo
- refreshChangeSizorCombo(ui, pagination);
-
- int page = pagination.getCurrentPage();
- boolean notLast = page + 1 < pagination.getNbPages();
- ui.getGoNextPage().setEnabled(notLast);
- ui.getGoLastPage().setEnabled(notLast);
- boolean notFirstPage = !(pagination.getSize() < 2 || page<1);
- ui.getGoFirstPage().setEnabled(notFirstPage);
- ui.getGoPreviousPage().setEnabled(notFirstPage);
- }
-
- public static void refreshChangeSizorCombo(JListTab ui, PaginationModel pagination) {
- JComboBox combo = ui.getChangeSizor();
- String s = pagination.getWidth() + "";
- if (!s.equals(String.valueOf(combo.getSelectedItem()))) {
- combo.setEnabled(false);
- combo.setSelectedItem(s);
- combo.setEnabled(true);
- }
- }
-
- public static void refreshChangePageCombo(JListTab ui, PaginationModel pagination) {
- JComboBox combo = ui.getGoPage();
- long size = pagination.getNbPages();
- combo.setEnabled(false);
- //System.out.println("page old size : " + combo.getItemCount() + " new size : " + size);
- if (size < combo.getItemCount()) {
- while (size < combo.getItemCount()) {
- combo.removeItemAt(combo.getItemCount() - 1);
- }
- } else {
- while (size > combo.getItemCount()) {
- combo.addItem(combo.getItemCount());
- }
- }
- //System.out.println("new page size : " + combo.getItemCount());
- if (combo.getItemCount()>0) {
- combo.setSelectedIndex(pagination.getCurrentPage());
- }
- boolean b = combo.getItemCount() > 1;
- combo.setEnabled(b);
- ui.getCurrentPage().setEnabled(b);
- }
-
- protected ListTabRefreshHelper() {
- // do not instanciate me please
- }
-}
\ No newline at end of file
Deleted: trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/MainUIRefreshHelper.java
===================================================================
--- trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/MainUIRefreshHelper.java 2008-02-20 18:43:44 UTC (rev 1142)
+++ trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/MainUIRefreshHelper.java 2008-02-20 18:45:16 UTC (rev 1143)
@@ -1,160 +0,0 @@
-/*
-* ##% Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008 Code Lutin,
-* Tony Chemit, Gabriel Landais
-*
-* 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 fr.cemagref.simexplorer.is.ui.swing;
-
-import fr.cemagref.simexplorer.is.entities.EntityHelper;
-import fr.cemagref.simexplorer.is.entities.data.LoggableElement;
-import fr.cemagref.simexplorer.is.ui.swing.actions.ExportElementAction;
-import fr.cemagref.simexplorer.is.ui.swing.actions.util.SimExplorerAbstractAction;
-import static org.codelutin.i18n.I18n._;
-
-import javax.swing.AbstractButton;
-
-/**
- * Cette classe contient les méthodes utiles et réutilisables pour rafraichit
- * les ui.
- * <p/>
- * Les méthodes utilisent les données stockées dans les modèles pour rafraichir
- * les uis concernées.
- * <p/>
- * Note : <b>Dans toutes ces méthodes, NOS modèles ne doivent en aucun cas être modifiés</b>
- * <p/>
- * Par contre les modèles des ui peuvent être modifiés (par exemple modèle d'arbre, de liste)
- * mais uniquement à partir de nos modèles.
- *
- * @author chemit
- */
-public class MainUIRefreshHelper {
-
-
- public static void refreshExportElement(AbstractButton button, boolean remote, LoggableElement sNode) {
- boolean enabled = EntityHelper.Action.EXPORT.accept(sNode);
- refreshExportElement(button, enabled, remote, enabled ? sNode.getMetaData().getName() : null, enabled ? sNode.getMetaData().getVersion().toString() : null);
- }
-
- public static void refreshExportElement(AbstractButton button, boolean enabled, boolean remote, String name, String version) {
- button.setEnabled(enabled);
- String t = null;
- if (enabled) {
- ExportElementAction action = (ExportElementAction) button.getAction();
- t = _(action.getI18nToolTipText(remote), name, version);
- }
- button.setToolTipText(t);
- }
-
- protected static void UpdateButton(AbstractButton button, boolean enabled, Object... params) {
- button.setEnabled(enabled);
- if (!enabled) {
- button.setToolTipText(null);
- } else {
-
- }
- SimExplorerAbstractAction action = (SimExplorerAbstractAction) button.getAction();
- String t = _(action.getI18nToolTipText(), params);
- button.setToolTipText(t);
- }
-
-
- protected MainUIRefreshHelper() {
- // do not instanciate me please
- }
-
-}
-
-/**
- * Rafraichit les uis après un changement de status de connexion de l'utilisateur.
- * <p/>
- * Si l'utilisateur est déconnecté, alors toutes les ui et actions liées au
- * mode remote sont fermées et les actions correspondantes sont rendues
- * inaccessibles.
- *
- * @param ui l'ui principale
- * @param isConnected flag pour indique si l'utiliseur est connecté
- * @param history l'historique de l'onglet de detail
- */
-/* public static void refreshConnnectState(SimExplorerMainUI ui, final boolean isConnected, HistoryModel<EntityTreeNode> history) {
-
- //SwingUtilities.invokeLater(new Runnable() {
- // public void run() {
- ui.getConnect().setEnabled(!isConnected);
- ui.getUnconnect().setEnabled(isConnected);
- ui.getShowTab_remote().setEnabled(isConnected);
- ui.getToggleTab_remote().setEnabled(isConnected);
-
- JTabbedPane container = ui.getContent();
- DetailTabModel model = (DetailTabModel) SimExplorerTab.detail.getModel();
- JDetailTab tabUI = (JDetailTab) SimExplorerTab.detail.getUI();
- if (!isConnected) {
- // close all connected ui
-
- if (SimExplorerTab.remote.isTabVisible(container)) {
- // close tab
- SimExplorerTab.remote.closeTab(container);
- }
- if (SimExplorerTab.synchronize.isTabVisible(container)) {
- // close tab
- SimExplorerTab.synchronize.closeTab(container);
- }
- if (SimExplorerTab.detail.isTabVisible(container) && history != null) {
- if (history.isEmpty()) {
- // close tab, no more history
- SimExplorerTab.detail.closeTab(container);
- } else {
- // select current history element
- EntityTreeNode node = history.getCurrent();
- model.synch(node);
- //model.setRemote(node.isRemote());
- //model.setRootNode((LoggableElement) node.getUserObject());
- DetailTabRefreshHelper.updateDetailNavigationTree(tabUI, model.getHistory());
- }
- }
- }
- if (SimExplorerTab.detail.isTabVisible(container)) {
- DetailTabRefreshHelper.refreshSynchroniseAction(tabUI, model);
- DetailTabRefreshHelper.refreshExportAction(tabUI, model);
- }
-
- if (SimExplorerTab.local.isTabVisible(container)) {
- ListTabRefreshHelper.refreshListTablePopupMenu((JListTab) SimExplorerTab.local.getUI(), (ListTabModel) SimExplorerTab.local.getModel());
- }
- // }
- //});
-}*/
-
-/**
- * Rafraichit les actions i18n dans le menu en fonction de la locale
- * actuellement utilisée.
- *
- * @param ui l'ui principale
- */
-/*public static void refreshI18nActions(SimExplorerMainUI ui) {
- LanguageEnum language = SimExplorer.getContext().getConfig().getUserLanguage();
- CountryEnum country = SimExplorer.getContext().getConfig().getUserCountry();
- String[] actions = SimExplorerActionManager.getFactory().getActionNames();
- for (String actionName : actions) {
- Matcher matcher = ChangeI18nAbstractAction.PATTERN_NAME.matcher(actionName);
- if (!matcher.matches()) {
- continue;
- }
- AbstractButton button = (AbstractButton) ui.getObjectById(actionName);
- ChangeI18nAbstractAction action = (ChangeI18nAbstractAction) button.getAction();
- boolean enable = !action.equalsLocale(language, country);
- button.setEnabled(enable);
- }
-}*/
\ No newline at end of file
Deleted: trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/SimExplorerMainUI.java
===================================================================
--- trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/SimExplorerMainUI.java 2008-02-20 18:43:44 UTC (rev 1142)
+++ trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/SimExplorerMainUI.java 2008-02-20 18:45:16 UTC (rev 1143)
@@ -1,91 +0,0 @@
-/*
-* ##% Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008 Code Lutin,
-* Tony Chemit, Gabriel Landais
-*
-* 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 fr.cemagref.simexplorer.is.ui.swing;
-
-import fr.cemagref.simexplorer.is.ui.SimExplorer;
-import fr.cemagref.simexplorer.is.ui.swing.actions.util.ChangeI18nAbstractAction;
-import org.codelutin.i18n.CountryEnum;
-import org.codelutin.i18n.LanguageEnum;
-
-import javax.swing.AbstractButton;
-import javax.swing.JComponent;
-import javax.swing.KeyStroke;
-import javax.swing.SwingUtilities;
-import java.awt.event.InputEvent;
-import java.awt.event.KeyEvent;
-import java.util.regex.Matcher;
-
-/**
- * L'ui principale de l'application
- *
- * @author chemit
- */
-public class SimExplorerMainUI extends SimExplorerUI {
-
- public SimExplorerMainUI() {
- super();
-
- // chargement dans l'ui des actions
- SimExplorerActionManager.loadActions(this, null);
-
- // add Ctrl-W to close current tab
- getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_W, InputEvent.CTRL_MASK), "closeTab");
- getRootPane().getActionMap().put("closeTab", SimExplorerActionManager.newAction("closeTab"));
- // override Ctrl-F4 close application
- getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_F4, InputEvent.CTRL_MASK), "quit");
- getRootPane().getActionMap().put("quit", SimExplorerActionManager.newAction("quit"));
-
- // repaint i18n actions
- refreshI18nActions();
- }
-
- public void setStatus(final String msg) {
-
- Runnable runnable = new Runnable() {
- public void run() {
- //TODO il faut enlever le synchronize dans statusBar
- //getStatusBar().setStatus(msg);
- //System.out.println(msg);
- }
- };
- SwingUtilities.invokeLater(runnable);
- }
-
- /**
- * Rafraichit les actions i18n dans le menu en fonction de la locale
- * actuellement utilisée.
- */
- public void refreshI18nActions() {
-
- LanguageEnum language = SimExplorer.getContext().getConfig().getUserLanguage();
- CountryEnum country = SimExplorer.getContext().getConfig().getUserCountry();
- String[] actions = SimExplorerActionManager.getFactory().getActionNames();
- for (String actionName : actions) {
- Matcher matcher = ChangeI18nAbstractAction.PATTERN_NAME.matcher(actionName);
- if (!matcher.matches()) {
- continue;
- }
- AbstractButton button = (AbstractButton) getObjectById(actionName);
- ChangeI18nAbstractAction action = (ChangeI18nAbstractAction) button.getAction();
- boolean enable = !action.equalsLocale(language, country);
- button.setEnabled(enable);
- }
- }
-
-}
Deleted: trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/SimExplorerTab.java
===================================================================
--- trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/SimExplorerTab.java 2008-02-20 18:43:44 UTC (rev 1142)
+++ trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/SimExplorerTab.java 2008-02-20 18:45:16 UTC (rev 1143)
@@ -1,165 +0,0 @@
-/*
-* ##% Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008 Code Lutin,
-* Tony Chemit
-*
-* This program is free software; you can redistribute it and/or
-* modify it under the terms of the GNU General Public License
-* as published by the Free Software Foundation; either version 2
-* of the License, or (at your option) any later version.
-*
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with this program; if not, write to the Free Software
-* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-* ##% */
-package fr.cemagref.simexplorer.is.ui.swing;
-
-import fr.cemagref.simexplorer.is.ui.swing.model.DetailTabModel;
-import fr.cemagref.simexplorer.is.ui.swing.model.ListTabModel;
-import fr.cemagref.simexplorer.is.ui.swing.model.SimExplorerTabModel;
-import fr.cemagref.simexplorer.is.ui.swing.model.SynchronizeTabModel;
-import jaxx.runtime.builder.TabContentConfig;
-import jaxx.runtime.swing.JAXXTab;
-
-import javax.swing.JTabbedPane;
-import javax.swing.JPopupMenu;
-import java.awt.Component;
-
-/**
- * La défintion des onglets utilisés dans l'application
- *
- * @author tony
- */
-
-public enum SimExplorerTab {
-
- @TabContentConfig(
- impl = JDetailTab.class,
- model = DetailTabModel.class,
- parentImpl = JTabbedPane.class,
- name = "simexplorer.tab.detail",
- shortDescription = "simexplorer.tab.detail.tooltip"
- )detail {
- public <U extends JAXXTab, M extends SimExplorerTabModel> void updateUI(U ui, M model) {
- DetailTabRefreshHelper.refreshDetailTab((JDetailTab) ui, (DetailTabModel) model);
- }},
-
- @TabContentConfig(
- impl = JListTab.class,
- parentImpl = JTabbedPane.class,
- model = ListTabModel.class,
- useToogle = true,
- name = "simexplorer.tab.local",
- shortDescription = "simexplorer.tab.local.tooltip"
- )local {
- public <U extends JAXXTab, M extends SimExplorerTabModel> void updateUI(U ui, M model) {
- ListTabRefreshHelper.refreshListTabUI((JListTab) ui, (ListTabModel) model);
- }},
-
- @TabContentConfig(
- impl = JListTab.class,
- parentImpl = JTabbedPane.class,
- model = ListTabModel.class,
- useToogle = true,
- name = "simexplorer.tab.remote",
- shortDescription = "simexplorer.tab.remote.tooltip"
- )remote {
- public <U extends JAXXTab, M extends SimExplorerTabModel> void updateUI(U ui, M model) {
- ListTabRefreshHelper.refreshListTabUI((JListTab) ui, (ListTabModel) model);
- }},
-
- @TabContentConfig(
- impl = JSynchronizeTab.class,
- parentImpl = JTabbedPane.class,
- model = SynchronizeTabModel.class,
- useToogle = false,
- name = "simexplorer.tab.synchronize",
- shortDescription = "simexplorer.tab.synchronize.tooltip"
- )synchronize {
- public <U extends JAXXTab, M extends SimExplorerTabModel> void updateUI(U ui, M model) {
- SynchronizeTabRefreshHelper.refreshSynchronizeTab((JSynchronizeTab) ui, (SynchronizeTabModel) model);
- }
- };
-
- /** l'usine de tabs */
- private static SimExplorerTabFactory factory;
-
- public static SimExplorerTabFactory getFactory() {
- if (factory == null) {
- factory = new SimExplorerTabFactory();
- }
- return factory;
- }
-
- /**
- * recherche d'un onglet contenant un component.
- *
- * @param c le component dont on cherche l'onglet
- * @return l'onglet parent du component, ou null si pas de tab trouvé
- */
- public static SimExplorerTab findTab(Component c) {
- Component parent = c.getParent();
- while (parent != null) {
- if (parent instanceof JPopupMenu) {
- parent = ((JPopupMenu)parent).getInvoker();
- }
- if (parent instanceof JAXXTab) {
- // find a JAXXTab
- for (SimExplorerTab tab : values()) {
- if (parent.equals(tab.getUI())) {
- // find the correct tab
- return tab;
- }
- }
- break;
- }
- parent = parent.getParent();
- }
- return null;
- }
-
- public abstract <U extends JAXXTab, M extends SimExplorerTabModel> void updateUI(U ui, M model);
-
- public JAXXTab getUI() {
- return getFactory().getUI(name());
- }
-
- public SimExplorerTabModel getModel() {
- return getFactory().getModel(name());
- }
-
- public boolean isTabVisible(JTabbedPane container) {
- JAXXTab ui = getUI();
- return ui != null && getFactory().getTabIndex(container, ui) > -1;
- }
-
- public boolean isTabSelected(JTabbedPane container) {
- return isTabVisible(container) && getFactory().getTabIndex(container, getUI()) == container.getSelectedIndex();
- }
-
- public int getTabIndex(JTabbedPane container) {
- JAXXTab ui = getUI();
- return ui == null ? -1 : getFactory().getTabIndex(container, ui);
- }
-
- public void showTab(final JTabbedPane container) {
- getFactory().showTab(container, name());
- }
-
- public void closeTab(JTabbedPane container) {
- getFactory().closeTab(container, name());
- getModel().setSelectedItem(null);
- }
-
- public void updateUI() {
- updateUI(getUI(), getModel());
- }
-
- public void removePropertyChangeListeners() {
- getModel().removePropertyChangeListeners();
- }
-}
Deleted: trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/SimExplorerTabFactory.java
===================================================================
--- trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/SimExplorerTabFactory.java 2008-02-20 18:43:44 UTC (rev 1142)
+++ trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/SimExplorerTabFactory.java 2008-02-20 18:45:16 UTC (rev 1143)
@@ -1,137 +0,0 @@
-/*
-* ##% Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008 Code Lutin,
-* Tony Chemit, Gabriel Landais
-*
-* 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 fr.cemagref.simexplorer.is.ui.swing;
-
-import fr.cemagref.simexplorer.is.exceptions.SimExplorerRuntimeException;
-import fr.cemagref.simexplorer.is.ui.SimExplorer;
-import fr.cemagref.simexplorer.is.ui.swing.model.SimExplorerTabModel;
-import fr.cemagref.simexplorer.is.ui.swing.util.MyTabHeader;
-import jaxx.runtime.JAXXObject;
-import jaxx.runtime.builder.TabContentConfig;
-import jaxx.runtime.builder.TabFactory;
-import jaxx.runtime.swing.JAXXTab;
-import static org.codelutin.i18n.I18n._;
-
-import javax.swing.AbstractButton;
-import javax.swing.JComponent;
-import javax.swing.JTabbedPane;
-import java.awt.Component;
-import java.awt.event.MouseAdapter;
-import java.awt.event.MouseEvent;
-import java.lang.reflect.Field;
-import java.util.Map;
-import java.util.TreeMap;
-
-/**
- * L'implatantion pour SimExplorer de la factory de Tab
- *
- * @author chemit
- * @see TabFactory
- */
-public class SimExplorerTabFactory extends TabFactory {
-
- protected Map<String, TabContentConfig> initFactory() {
- Map<String, TabContentConfig> result = new TreeMap<String, TabContentConfig>();
- for (SimExplorerTab tab : SimExplorerTab.values()) {
- try {
- String tabName = tab.name();
- Field field = tab.getClass().getField(tabName);
- result.put(tabName, field.getAnnotation(TabContentConfig.class));
- } catch (NoSuchFieldException e) {
- throw new SimExplorerRuntimeException(e);
- }
- }
- return result;
- }
-
- protected void initTab(JAXXTab tab, String tabName, TabContentConfig config) {
- SimExplorerActionManager.loadActions((JAXXObject) tab, getTab(tabName));
- }
-
- protected SimExplorerTab getTab(String tabName) {
- return SimExplorerTab.valueOf(tabName);
- }
-
- @Override
- public SimExplorerTabModel getModel(String tabName) {
- return (SimExplorerTabModel) super.getModel(tabName);
- }
-
- @Override
- protected JComponent addTabHeader(final JTabbedPane container,
- String tabName,
- TabContentConfig tab,
- final JAXXTab comp) {
-
- final MyTabHeader panel = new MyTabHeader();
-
- // add a dynamic reference to tab close button to enable
- // dynamic action instanciation
- //TODO add the ActionManager mecanism ?
- String actionName = panel.getCloseTab().getName() + "_" + tabName;
-
- panel.get$objectMap().put(actionName, panel.getCloseTab());
-
- // chargement dans l'ui des actions
- SimExplorerActionManager.loadActions(panel, getTab(tabName));
-
- panel.setToolTipText(_(tab.shortDescription()));
- panel.getLabel().setText(_(tab.name()));
-
- panel.addMouseListener(new MouseAdapter() {
- @Override
- public void mouseClicked(MouseEvent e) {
- Component compOld = container.getSelectedComponent();
- if (!comp.equals(compOld)) {
- //TODO should use the showTab_XXX action
- container.setSelectedComponent(comp);
- }
- }
- });
- return panel;
- }
-
- @Override
- public void showTab(final JTabbedPane container, String tabName) {
-
- super.showTab(container, tabName);
-
- switchToggleButton(tabName, true);
- }
-
- @Override
- public void closeTab(JTabbedPane container, String tabName) {
-
- super.closeTab(container, tabName);
-
- switchToggleButton(tabName, false);
- }
-
- protected void switchToggleButton(String tabName, boolean b) {
-
- TabContentConfig tab = getConfig(tabName);
-
- if (tab.useToogle()) {
- AbstractButton buton;
- buton = (AbstractButton) SimExplorer.getUI().getObjectById("toggleTab_" + tabName);
- buton.setSelected(b);
- }
- }
-
-}
Deleted: trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/SynchronizeTabRefreshHelper.java
===================================================================
--- trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/SynchronizeTabRefreshHelper.java 2008-02-20 18:43:44 UTC (rev 1142)
+++ trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/SynchronizeTabRefreshHelper.java 2008-02-20 18:45:16 UTC (rev 1143)
@@ -1,109 +0,0 @@
-/*
-* ##% Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008 Code Lutin,
-* Tony Chemit, Gabriel Landais
-*
-* 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 fr.cemagref.simexplorer.is.ui.swing;
-
-import fr.cemagref.simexplorer.is.entities.data.LoggableElement;
-import fr.cemagref.simexplorer.is.ui.swing.model.SynchronizeTabModel;
-
-import javax.swing.JTabbedPane;
-import javax.swing.JTree;
-import javax.swing.tree.DefaultTreeModel;
-import javax.swing.tree.TreeNode;
-
-/**
- * Cette classe contient les méthodes utiles et réutilisables pour rafraichir
- * les onglets de liste.
- * <p/>
- * Les méthodes utilisent les données stockées dans les modèles pour rafraichir
- * les uis concernées.
- * <p/>
- * Note : <b>Dans toutes ces méthodes, NOS modèles ne doivent en aucun cas être modifiés</b>
- * <p/>
- * Par contre les modèles des ui peuvent être modifiés (par exemple modèle d'arbre, de liste)
- * mais uniquement à partir de nos modèles.
- *
- * @author chemit
- */
-public class SynchronizeTabRefreshHelper {
-
- protected static void refreshSynchronizeTab(JSynchronizeTab ui, SynchronizeTabModel model) {
-
- EntityTreeNodeHelper.refreshTreeActions(ui.getCollapseButton(false), ui.getExpandButton(false), null);
- EntityTreeNodeHelper.refreshTreeActions(ui.getCollapseButton(true), ui.getExpandButton(true), null);
-
- refreshExportElement(ui, model, true);
- refreshExportElement(ui, model, false);
-
- refreshRootNode(ui, model, false);
- refreshRootNode(ui, model, true);
- }
-
- public static void updateTree(JTabbedPane container, LoggableElement oldLocalRoot, LoggableElement oldRemoteRoot) {
-
- SimExplorerTab tab = SimExplorerTab.synchronize;
-
- SynchronizeTabModel model = (SynchronizeTabModel) tab.getModel();
- if (model.getRootNode(false) == null && model.getRootNode(true) == null) {
- // on doit supprimer la vue
- tab.closeTab(container);
- }
-
- JSynchronizeTab ui = (JSynchronizeTab) tab.getUI();
-
- if (model.getRootNode(false) != oldLocalRoot) {
- // rebuild node ?
- refreshRootNode(ui, model, false);
- }
-
- if (model.getRootNode(true) != oldRemoteRoot) {
- // rebuild node ?
- refreshRootNode(ui, model, true);
- }
- }
-
- protected static void refreshRootNode(JSynchronizeTab ui, SynchronizeTabModel model, boolean remote) {
-
- LoggableElement element;
- TreeNode root = null;
-
- element = model.getRootNode(remote);
- if (element != null) {
- root = EntityTreeNodeHelper.build(element, remote);
- }
-
- JTree tree = ui.getTree(remote);
-
- ((DefaultTreeModel) tree.getModel()).setRoot(root);
-
- if (root == null) {
- tree.getSelectionModel().clearSelection();
- } else {
- tree.setSelectionRow(0);
- }
- }
-
- public static void refreshExportElement(JSynchronizeTab ui, SynchronizeTabModel model, boolean remote) {
- LoggableElement sNode = model.getSelectedNode(remote);
- MainUIRefreshHelper.refreshExportElement(ui.getExportButton(remote), remote, sNode);
- }
-
- protected SynchronizeTabRefreshHelper() {
- // do not instanciate me please
- }
-}
\ No newline at end of file
Copied: trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/ui/DetailTabRefreshHelper.java (from rev 1132, trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/DetailTabRefreshHelper.java)
===================================================================
--- trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/ui/DetailTabRefreshHelper.java (rev 0)
+++ trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/ui/DetailTabRefreshHelper.java 2008-02-20 18:45:16 UTC (rev 1143)
@@ -0,0 +1,294 @@
+/*
+* ##% Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008 Code Lutin,
+* Tony Chemit, Gabriel Landais
+*
+* 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 fr.cemagref.simexplorer.is.ui.swing.ui;
+
+import fr.cemagref.simexplorer.is.entities.EntityHelper;
+import fr.cemagref.simexplorer.is.entities.attachment.Attachment;
+import fr.cemagref.simexplorer.is.entities.data.LoggableElement;
+import fr.cemagref.simexplorer.is.entities.metadata.MetaData;
+import fr.cemagref.simexplorer.is.entities.metadata.Version;
+import fr.cemagref.simexplorer.is.ui.swing.ui.JDetailTab;
+import fr.cemagref.simexplorer.is.ui.swing.SimExplorerContext;
+import fr.cemagref.simexplorer.is.ui.swing.model.DetailTabModel;
+import fr.cemagref.simexplorer.is.ui.swing.model.DetailTableModel;
+import fr.cemagref.simexplorer.is.ui.swing.model.EntityTreeNode;
+import fr.cemagref.simexplorer.is.ui.swing.model.HistoryModel;
+import static org.codelutin.i18n.I18n._;
+
+import javax.swing.DefaultComboBoxModel;
+import javax.swing.DefaultListModel;
+import javax.swing.JList;
+import javax.swing.JTable;
+import javax.swing.tree.DefaultTreeModel;
+import java.awt.Dimension;
+import java.awt.Rectangle;
+import java.text.SimpleDateFormat;
+import java.util.List;
+
+/**
+ * Cette classe contient les méthodes utiles et réutilisables pour rafraichir
+ * l'onglet de detail.
+ * <p/>
+ * Les méthodes utilisent les données stockées dans les modèles pour rafraichir
+ * les uis concernées.
+ * <p/>
+ * Note : <b>Dans toutes ces méthodes, NOS modèles ne doivent en aucun cas être modifiés</b>
+ * <p/>
+ * Par contre les modèles des ui peuvent être modifiés (par exemple modèle d'arbre, de liste)
+ * mais uniquement à partir de nos modèles.
+ *
+ * @author chemit
+ */
+public class DetailTabRefreshHelper {
+
+ public static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy.MM.dd HH:mm:ss.SSS");
+
+ public static void refreshDetailTab(JDetailTab ui, DetailTabModel model) {
+ EntityTreeNode root = EntityTreeNodeHelper.build(model.getRootNode(), model.isRemote());
+ EntityTreeNode current = model.getHistory().getCurrent();
+ //FIXME : if object has different version, it says that this is same!!!
+ if (current == null || !root.getUserObject().equals(current.getUserObject())) {
+ model.getHistory().add(root);
+ }
+ DetailTabRefreshHelper.updateDetailNavigationTree(ui, model.getHistory());
+ }
+
+ /**
+ * Rafraichit les actions d'un node dans l'arbre de navigation
+ *
+ * @param context
+ * @param ui l'onglet de détail
+ * @param model le model de d'onglet detail
+ * @param node le node sélectionné dans l'arbre de navigation
+ */
+ public static void refreshDetailActions(SimExplorerContext context, JDetailTab ui, DetailTabModel model, EntityTreeNode node) {
+ // refresh synchronize action button
+ refreshSynchroniseAction(context, ui, model);
+ // refresh download LoggableElement button
+ refreshDownloadElementAction(ui, model, node);
+ // refresh delete button
+ refreshDeleteAction(ui, model);
+ // refresh export button
+ refreshExportAction(context,ui, model);
+ // refresh download Attachment button
+ refreshDownloadAttachmentAction(ui, model);
+ }
+
+ public static void refreshTreeDetailActions(JDetailTab ui, EntityTreeNode node) {
+ EntityTreeNodeHelper.refreshTreeActions(ui.getCollapseAllDetail(), ui.getExpandAllDetail(), node);
+ }
+
+ public static void refreshDownloadElementAction(JDetailTab ui, DetailTabModel model, EntityTreeNode node) {
+ MetaData detail = model.getDetail();
+ boolean enabled = EntityHelper.Action.DOWNLOAD.accept(node);
+ MainUIRefreshHelper.UpdateButton(ui.getDownloadElement(), enabled, enabled ? detail == null ? node.getUserObject() : detail.getName() + " [" + model.getSelectedVersion() + "]" : null);
+ }
+
+ protected static void refreshDeleteAction(JDetailTab ui, DetailTabModel model) {
+ MetaData detail = model.getDetail();
+ boolean enabled = EntityHelper.Action.DELETE.accept(detail);
+ MainUIRefreshHelper.UpdateButton(ui.getDeleteElement(), enabled, enabled ? detail.getName() + " [" + model.getSelectedVersion() + "]" : null);
+ }
+
+ public static void refreshDownloadAttachmentAction(JDetailTab ui, DetailTabModel model) {
+ Attachment attachment = model.getSelectedAttachment();
+ boolean enabled = model.getDetail() != null && attachment != null;
+ MainUIRefreshHelper.UpdateButton(ui.getDownloadAttachment(), enabled, enabled ? attachment : null);
+ }
+
+ public static void refreshDetailToTreeAction(JDetailTab ui, DetailTabModel model) {
+ MetaData detail = model.getDetail();
+ EntityTreeNode rootNode = model.getHistory().getCurrent();
+ LoggableElement rootElement = (LoggableElement) rootNode.getUserObject();
+ MetaData data = rootElement.getMetaData();
+ Version version = model.getSelectedVersion();
+ if (version == null) {
+ // la version peut être null, ce qui veut dire que l'on vient d'un changement
+ // de node dans l'arbre de navigation et donc la version est celle du detai
+ version = detail.getVersion();
+ }
+ boolean enabled = !(detail.getName().equals(data.getName()) && data.getVersion().equals(version));
+
+ MainUIRefreshHelper.UpdateButton(ui.getDetailToTree(), enabled, enabled ? detail.getName() + " [" + version + "]" : null);
+ }
+
+ public static void refreshSynchroniseAction(SimExplorerContext context, JDetailTab ui, DetailTabModel model) {
+ MetaData detail = model.getDetail();
+ boolean enabled = detail != null && context.isConnected();
+ MainUIRefreshHelper.UpdateButton(ui.getShowTab_synchronize(), enabled, enabled ? detail.getName() + " [" + model.getSelectedVersion() + "]" : null);
+ }
+
+ public static void refreshExportAction(SimExplorerContext context, JDetailTab ui, DetailTabModel model) {
+ LoggableElement sNode = model.getSelectedNode();
+ MainUIRefreshHelper.refreshExportElement(context,ui.getExportElement(),model.isRemote(),sNode);
+ }
+
+ public static void resetHistory(JDetailTab ui, DetailTabModel model, DefaultComboBoxModel historyModel) {
+ historyModel.removeAllElements();
+ LoggableElement selectedNode = model.getSelectedNode();
+ Version[] versions = model.getVersions();
+ boolean nodetail = versions == null || selectedNode == null;
+ if (nodetail) {
+ resetDetailPanel(ui);
+ } else {
+ ui.getDetailHeaderFromLocal().setVisible(!model.isRemote());
+ ui.getDetailHeaderFromRemote().setVisible(model.isRemote());
+ for (Version version : versions) {
+ historyModel.addElement(version);
+ }
+ boolean enabled = ui.getDetailVersions().getItemCount() > 1;
+ ui.getDetailVersions().setEnabled(enabled);
+ String text;
+ text = !enabled ? null : _("simexplorer.action.changeVersion.tooltip");
+ ui.getDetailVersions().setToolTipText(text);
+ }
+ // can not synchronize to tree
+ MainUIRefreshHelper.UpdateButton(ui.getDetailToTree(), false);
+ }
+
+ public static void resetDetailPanel(final JDetailTab ui) {
+ ui.getDetailVersions().setVisible(false);
+ ui.getDetailHeader().setText(_("simexplorer.node.nodetail"));
+ ui.getDetailAttachmentsHeader().setText(_("simexplorer.node.noattachments"));
+ JList listAttchments = ui.getDetailAttachments();
+ listAttchments.clearSelection();
+ DefaultListModel listModel = (DefaultListModel) listAttchments.getModel();
+ listModel.setSize(0);
+ listModel.trimToSize();
+ ui.getDetail().setVisible(false);
+ ((DetailTableModel) ui.getDetailTable().getModel()).setData(null);
+ }
+
+ public static void updateDetailNavigationTree(JDetailTab ui, HistoryModel<EntityTreeNode> model) {
+ // push it in tree model
+ ((DefaultTreeModel) ui.getNavigationTree().getModel()).setRoot(model.getCurrent());
+ // by default select the root node
+ if (ui.getNavigationTree().getModel().getRoot() != null) {
+ ui.getNavigationTree().setSelectionRow(0);
+ }
+ boolean enabled;
+ enabled = model.size() > 1 && model.hasPrevious();
+ MainUIRefreshHelper.UpdateButton(ui.getHistoryPrevious(), enabled, !enabled ? null : model.getPrevious());
+ enabled = model.size() > 1 && model.hasNext();
+ MainUIRefreshHelper.UpdateButton(ui.getHistoryNext(), enabled, !enabled ? null : model.getNext());
+ }
+
+ public static void updateDetailPanel(Integer index, final JDetailTab ui, DetailTabModel model, LoggableElement selectedNode) {
+ MetaData detail = model.getDetail();
+ ui.getDetailVersions().setVisible(true);
+ if (ui.getDetailVersions().getItemCount() > 0) {
+ ui.getDetailVersions().setSelectedIndex(index);
+ }
+ ui.getDetailHeader().setText(selectedNode.getMetaData().getName());
+ ui.getDetailDescriptorsHeader().setText(_("simexplorer.node.descriptors", detail.getDescriptors().size()));
+ ui.getDetailType().setText(EntityHelper.Type.getLibelle(detail));
+ String s = detail.getDescription();
+ String tooltip = s;
+ if (s.length() > 32) {
+ s = s.substring(0, 32) + "...";
+ }
+ ui.getDetailDescription().setText(s);
+ if (!s.equals(tooltip)) {
+ ui.getDetailDescription().setToolTipText(tooltip);
+ }
+ ui.getDetailCreationDate().setText(DATE_FORMAT.format(detail.getCreationDate()));
+ ui.getDetail().setVisible(true);
+ JTable table = ui.getDetailTable();
+ ((DetailTableModel) table.getModel()).setData(detail);
+ int nbDescriptorRows = table.getRowCount();
+
+ List<Attachment> attachments = detail.getAttachments();
+ JList listAttachments = ui.getDetailAttachments();
+ DefaultListModel listModel = (DefaultListModel) listAttachments.getModel();
+ listModel.setSize(0);
+ listModel.trimToSize();
+ int nbAttachmentRows;
+ if (attachments.isEmpty()) {
+ ui.getDetailAttachmentsHeader().setText(_("simexplorer.node.noattachments"));
+ ui.getScrollAttachments().setVisible(false);
+ nbAttachmentRows = 0;
+ } else {
+ ui.getDetailAttachmentsHeader().setText(EntityHelper.Type.Attachment.getLibelles() + " (" + attachments.size() + ")");
+ for (Attachment attachment : attachments) {
+ listModel.addElement(attachment);
+ }
+ listAttachments.setSelectedIndex(0);
+ nbAttachmentRows = listModel.getSize();
+ ui.getScrollAttachments().setVisible(true);
+ }
+
+ int[] rows = computeRows(nbDescriptorRows, nbAttachmentRows);
+
+ Dimension dimOneRow = table.getUI().getPreferredSize(table.getTableHeader());
+
+ ui.getScrollTable().setPreferredSize(new Dimension((int) dimOneRow.getWidth(), 2 + ((rows[0] + 1) * (4 + table.getFont().getSize()))));
+ //ui.getScrollTable().setPreferredSize(new Dimension((int) table.getSize().getWidth(), 2 + (nbDescriptorRows * (4 + table.getFont().getSize()))));
+ if (nbAttachmentRows > 0) {
+ Rectangle rect = listAttachments.getUI().getCellBounds(listAttachments, 0, 0);
+ ui.getScrollAttachments().setPreferredSize(new Dimension((int) rect.getWidth() - 4, (int) (3 + rows[1] * rect.getHeight())));
+ }
+
+ table.invalidate();
+ listAttachments.invalidate();
+ ui.getScrollPane().invalidate();
+ ui.repaint();
+ }
+
+ protected static int[] computeRows(int nbDescriptorRows, int nbAttachmentRows) {
+ int[] result = new int[2];
+ int max = 14;
+ int maxOne = max / 2;
+ if (nbDescriptorRows == 0) {
+ result[0] = 0;
+ result[1] = nbAttachmentRows > max ? max : nbAttachmentRows;
+ return result;
+ }
+ if (nbAttachmentRows == 0) {
+ result[0] = nbDescriptorRows > max ? max : nbDescriptorRows;
+ result[1] = 0;
+ return result;
+ }
+ if (nbAttachmentRows < maxOne + 1 && nbDescriptorRows < maxOne + 1) {
+ result[0] = nbDescriptorRows;
+ result[1] = nbAttachmentRows;
+ return result;
+ }
+ if (nbDescriptorRows > maxOne && nbAttachmentRows > maxOne) {
+ result[0] = result[1] = maxOne;
+ return result;
+ }
+ if (nbDescriptorRows < maxOne + 1) {
+ result[0] = nbDescriptorRows;
+ int i = max - nbDescriptorRows;
+ result[1] = nbAttachmentRows < i ? nbAttachmentRows : i;
+ return result;
+ }
+ if (nbAttachmentRows < maxOne + 1) {
+ int i = max - nbAttachmentRows;
+ result[0] = nbDescriptorRows < i ? nbDescriptorRows : i;
+ result[1] = nbAttachmentRows;
+ return result;
+ }
+ throw new IllegalStateException("can not come her :)");
+ }
+
+ protected DetailTabRefreshHelper() {
+ // do not instanciate me please
+ }
+}
\ No newline at end of file
Copied: trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/ui/EntityTreeNodeHelper.java (from rev 1132, trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/EntityTreeNodeHelper.java)
===================================================================
--- trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/ui/EntityTreeNodeHelper.java (rev 0)
+++ trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/ui/EntityTreeNodeHelper.java 2008-02-20 18:45:16 UTC (rev 1143)
@@ -0,0 +1,321 @@
+/*
+* ##% Copyright (C) 2007, 2008 Code Lutin,
+* Tony Chemit, Gabriel Landais
+*
+* 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 fr.cemagref.simexplorer.is.ui.swing.ui;
+
+import static fr.cemagref.simexplorer.is.entities.EntityHelper.Type.Code;
+import static fr.cemagref.simexplorer.is.entities.EntityHelper.Type.Component;
+import static fr.cemagref.simexplorer.is.entities.EntityHelper.Type.Constant;
+import static fr.cemagref.simexplorer.is.entities.EntityHelper.Type.ConstantValue;
+import static fr.cemagref.simexplorer.is.entities.EntityHelper.Type.ExplorationData;
+import static fr.cemagref.simexplorer.is.entities.EntityHelper.Type.Library;
+import static fr.cemagref.simexplorer.is.entities.EntityHelper.Type.Structure;
+import fr.cemagref.simexplorer.is.entities.EntityVisitable;
+import fr.cemagref.simexplorer.is.entities.SimpleEntityVisitor;
+import fr.cemagref.simexplorer.is.entities.data.Code;
+import fr.cemagref.simexplorer.is.entities.data.Component;
+import fr.cemagref.simexplorer.is.entities.data.Constant;
+import fr.cemagref.simexplorer.is.entities.data.ConstantValue;
+import fr.cemagref.simexplorer.is.entities.data.ExplorationApplication;
+import fr.cemagref.simexplorer.is.entities.data.ExplorationData;
+import fr.cemagref.simexplorer.is.entities.data.Library;
+import fr.cemagref.simexplorer.is.entities.data.LoggableElement;
+import fr.cemagref.simexplorer.is.entities.data.Result;
+import fr.cemagref.simexplorer.is.entities.data.Structure;
+import fr.cemagref.simexplorer.is.entities.metadata.MetaData;
+import fr.cemagref.simexplorer.is.ui.swing.model.EntityTreeNode;
+
+import javax.swing.AbstractButton;
+import javax.swing.JTree;
+import javax.swing.event.TreeSelectionEvent;
+import javax.swing.tree.TreePath;
+import java.util.Collection;
+
+/**
+ * La classe responsable de la création des arbres de {@link fr.cemagref.simexplorer.is.ui.swing.model.EntityTreeNode}
+ * à partir de {@link LoggableElement} .
+ * <p/>
+ * La classe possède une instance cachée par thread qui délègue la construction
+ * del'arbre de navigation à un visiteur de {@link LoggableElement}.
+ * <p/>
+ *
+ * @author chemit
+ */
+public class EntityTreeNodeHelper {
+
+ /** L'instance cachée de builder par Thread. */
+ protected static final ThreadLocal<EntityVisitorBuilder> builder =
+ new ThreadLocal<EntityVisitorBuilder>() {
+ @Override
+ protected EntityVisitorBuilder initialValue() {
+ return new EntityVisitorBuilder();
+ }
+ };
+
+ /**
+ * Construit un arbre de navigation à partir d'un {@link LoggableElement}.
+ *
+ * @param v la donnée à visiter
+ * @param remote flag pour indiquer si on travaille sur des données locales
+ * ou en remote.
+ * @return le noeud parent de l'arbre de nivation construit.
+ */
+ public static EntityTreeNode build(LoggableElement v, boolean remote) {
+ EntityVisitorBuilder instance;
+ synchronized (instance = EntityTreeNodeHelper.builder.get()) {
+ EntityTreeNode result;
+ // walk
+ result = instance.visit(v, remote);
+ return result;
+ }
+ }
+
+ public static EntityTreeNode getSelectedNode(TreeSelectionEvent e) {
+ TreePath path = e.getNewLeadSelectionPath();
+ EntityTreeNode node = null;
+ if (path != null) {
+ Object o = path.getLastPathComponent();
+ if (o instanceof EntityTreeNode) {
+ node = (EntityTreeNode) o;
+ }
+ }
+ return node;
+ }
+
+ public static EntityTreeNode getSelectedNodeOrRootNode(JTree tree) {
+ EntityTreeNode node = getSelectedNode(tree);
+ if (node == null) {
+ return getRootNode(tree);
+ }
+ return node;
+ }
+
+ public static EntityTreeNode getSelectedNode(JTree tree) {
+ TreePath path = tree.getSelectionPath();
+ EntityTreeNode node = null;
+ if (path != null) {
+ Object o = path.getLastPathComponent();
+ if (o != null && !(o instanceof EntityTreeNode)) {
+ return null;
+ }
+ node = (EntityTreeNode) o;
+ }
+ return node;
+ }
+
+ public static EntityTreeNode getRootNode(JTree tree) {
+ EntityTreeNode node;
+ // take the root node
+ Object root = tree.getModel().getRoot();
+ if (root == null || !(root instanceof EntityTreeNode)) {
+ return null;
+ }
+ node = (EntityTreeNode) root;
+ return node;
+ }
+
+ public static void refreshTreeActions(AbstractButton collapseButton, AbstractButton expandButton, EntityTreeNode node) {
+ boolean enabled = node != null && !node.isLeaf() && node.getChildCount() > 0;
+ Object o = enabled ? node.getUserObject() : null;
+ MainUIRefreshHelper.UpdateButton(collapseButton, enabled, o);
+ MainUIRefreshHelper.UpdateButton(expandButton, enabled, o);
+ }
+
+ protected EntityTreeNodeHelper() {
+ // no instance
+ }
+
+ /**
+ * Implantation de {@link SimpleEntityVisitor} pour construire l'arbre
+ * de navigation d'un {@link LoggableElement}.
+ * <p/>
+ * Cette classe est stateless, tous ces états internes doivent être nettoyé
+ * après une visite, en utilisant la méthode {@link #reset()}.
+ * <p/>
+ */
+ public static class EntityVisitorBuilder extends SimpleEntityVisitor {
+
+ /**
+ * le noeud parent de tous les autres.
+ * <p/>
+ * Ce noeud est positionné par la méthode
+ * {@link #markRootNode(EntityTreeNode)}.
+ */
+ protected EntityTreeNode rootNode;
+
+ /**
+ * flag qui indique si on travaille sur des objet locaux ou distants.
+ * <p/>
+ * Cette information est conservé dans les nodes pour permettre de gérer
+ * de manière transparent des objet locaux ou distants.
+ */
+ protected Boolean remote;
+
+ /** les nodes internes utilisés pendant la visite. */
+ protected EntityTreeNode explorationApplication,
+ component,
+ explorationData,
+ components,
+ explorationDatas,
+ libraries,
+ constants,
+ strutures,
+ codes,
+ constantValues;
+
+ public EntityTreeNode visit(EntityVisitable v, boolean remote) {
+ reset();
+ try {
+ this.remote = remote;
+ super.visit(v);
+ EntityTreeNode result;
+ result = this.rootNode;
+ return result;
+ } finally {
+ reset();
+ }
+ }
+
+ @Override
+ public void visitMetaData(MetaData v) {
+ // do not visit meta data (for the moment we dont need thoses
+ // informations in navigation tree), but it could be interresting
+ // for example to display attchments here ?
+ }
+
+ @Override
+ public void visitExplorationApplication(ExplorationApplication v) {
+ markRootNode(explorationApplication = new EntityTreeNode(null, v, remote, true));
+ super.visitExplorationApplication(v);
+ }
+
+ @Override
+ public void visitComponent(Component v) {
+ markRootNode(component = new EntityTreeNode(components, v, remote, true));
+ super.visitComponent(v);
+ }
+
+ @Override
+ public void visitExplorationData(ExplorationData v) {
+ markRootNode(explorationData = new EntityTreeNode(explorationDatas, v, remote, true));
+ super.visitExplorationData(v);
+ }
+
+ @Override
+ public void visitCodes(Collection<Code> vs) {
+ codes = new EntityTreeNode(component, Code.getLibelles(), remote, true);
+ super.visitCodes(vs);
+ }
+
+ @Override
+ public void visitComponents(Collection<Component> vs) {
+ components = new EntityTreeNode(explorationApplication, Component.getLibelles(), remote, true);
+ super.visitComponents(vs);
+ }
+
+ @Override
+ public void visitConstants(Collection<Constant> vs) {
+ constants = new EntityTreeNode(component, Constant.getLibelles(), remote, true);
+ super.visitConstants(vs);
+ }
+
+ @Override
+ public void visitConstantValues(Collection<ConstantValue> vs) {
+ constantValues = new EntityTreeNode(explorationData, ConstantValue.getLibelles(), remote, true);
+ super.visitConstantValues(vs);
+ }
+
+ @Override
+ public void visitExplorationDatas(Collection<ExplorationData> vs) {
+ explorationDatas = new EntityTreeNode(explorationApplication, ExplorationData.getLibelles(), remote, true);
+ super.visitExplorationDatas(vs);
+ }
+
+ @Override
+ public void visitLibraries(Collection<Library> vs) {
+ libraries = new EntityTreeNode(component, Library.getLibelles(), remote, true);
+ super.visitLibraries(vs);
+ }
+
+ @Override
+ public void visitStructures(Collection<Structure> vs) {
+ strutures = new EntityTreeNode(component, Structure.getLibelles(), remote, true);
+ super.visitStructures(vs);
+ }
+
+ @Override
+ public void visitConstant(Constant v) {
+ markRootNode(new EntityTreeNode(constants, v, remote, false));
+ }
+
+ @Override
+ public void visitLibrary(Library v) {
+ markRootNode(new EntityTreeNode(libraries, v, remote, false));
+ }
+
+ @Override
+ public void visitResult(Result v) {
+ if (v != null) {
+ markRootNode(new EntityTreeNode(explorationData, v, remote, false));
+ }
+ }
+
+ @Override
+ public void visitCode(Code v) {
+ new EntityTreeNode(codes, v, remote, false);
+ }
+
+ @Override
+ public void visitConstantValue(ConstantValue v) {
+ new EntityTreeNode(
+ new EntityTreeNode(constantValues, v.getConstant().getName(), remote, true),
+ v.getValue(), remote, false);
+ }
+
+ @Override
+ public void visitStructure(Structure v) {
+ new EntityTreeNode(strutures, v, remote, false);
+ }
+
+ /**
+ * Tente de marquerle node donné comme noeud ancêtre de tous les autres.
+ * <p/>
+ * Le positionnement n'a lieu que si on a pas encore de rootNode.
+ *
+ * @param node le node a positionner comme rootNode (si nessecaire)
+ */
+ protected void markRootNode(EntityTreeNode node) {
+ if (rootNode == null) {
+ rootNode = node;
+ }
+ }
+
+ /**
+ * La méthode pour réinitialiser les états interne de la classe.
+ * <p/>
+ * Cette méthode doit être appeler après chaque visite, afin d'assurer
+ * la propriété stateless de la classe.
+ */
+ protected void reset() {
+ remote = null;
+ rootNode = explorationApplication = explorationDatas = explorationData
+ = components = component = constants = codes = libraries
+ = constantValues = null;
+ }
+ }
+}
Copied: trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/ui/ListTabRefreshHelper.java (from rev 1132, trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/ListTabRefreshHelper.java)
===================================================================
--- trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/ui/ListTabRefreshHelper.java (rev 0)
+++ trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/ui/ListTabRefreshHelper.java 2008-02-20 18:45:16 UTC (rev 1143)
@@ -0,0 +1,172 @@
+/*
+* ##% Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008 Code Lutin,
+* Tony Chemit, Gabriel Landais
+*
+* 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 fr.cemagref.simexplorer.is.ui.swing.ui;
+
+import fr.cemagref.simexplorer.is.entities.EntityHelper;
+import fr.cemagref.simexplorer.is.entities.metadata.MetaData;
+import fr.cemagref.simexplorer.is.ui.swing.ui.JListTab;
+import fr.cemagref.simexplorer.is.ui.swing.SimExplorerContext;
+import fr.cemagref.simexplorer.is.ui.swing.model.DataEntityModel;
+import fr.cemagref.simexplorer.is.ui.swing.model.ListTabModel;
+import fr.cemagref.simexplorer.is.ui.swing.model.PaginationModel;
+
+import javax.swing.JComboBox;
+import javax.swing.ListSelectionModel;
+import javax.swing.SwingUtilities;
+
+/**
+ * Cette classe contient les méthodes utiles et réutilisables pour rafraichir
+ * les onglets de liste.
+ * <p/>
+ * Les méthodes utilisent les données stockées dans les modèles pour rafraichir
+ * les uis concernées.
+ * <p/>
+ * Note : <b>Dans toutes ces méthodes, NOS modèles ne doivent en aucun cas être modifiés</b>
+ * <p/>
+ * Par contre les modèles des ui peuvent être modifiés (par exemple modèle d'arbre, de liste)
+ * mais uniquement à partir de nos modèles.
+ *
+ * @author chemit
+ */
+public class ListTabRefreshHelper {
+
+ /**
+ * Rafraichit un onglet de type liste à partir de son modèle.
+ *
+ * @param mainUi main ui
+ * @param ui l'onglet de liste à utiliser
+ * @param model le modèle de liste à utiliser
+ */
+ public static void refreshListTabUI(final SimExplorerMainUI mainUi, final JListTab ui, final ListTabModel model) {
+
+ SwingUtilities.invokeLater(new Runnable() {
+ public void run() {
+
+ // refresh search text
+ ui.getSearchText().setText(model.getQuery().getQuery());
+
+ // refresh search actions
+ refreshSearchActions(ui, model);
+
+ // refresh pagination actions
+ refreshPagination(ui, model.getPagination());
+
+
+ ListSelectionModel selectionModel = ui.getTable().getSelectionModel();
+ if (!model.isEmpty() && selectionModel.isSelectionEmpty()) {
+ // always select the first row (to init selectedItem)
+ selectionModel.setSelectionInterval(0, 0);
+ } else {
+ selectionModel.clearSelection();
+ }
+
+ // table data model may have changed, must revalidate
+ ui.getTable().invalidate();
+
+ // repaint the frame
+ mainUi.repaint();
+ }
+ });
+ }
+
+ public static void refreshListTablePopupMenu(SimExplorerContext context, final JListTab ui, final ListTabModel model) {
+ DataEntityModel item = model.getSelectedItem();
+ ui.getTablePopupMenu().setEnabled(item != null);
+ int index = model.getSelectedIndex();
+ if (item == null || index == -1) {
+ return;
+ }
+ MetaData data = model.get(index);
+
+ String text = data.getName() + " [" + data.getVersion() + "]";
+
+ MainUIRefreshHelper.UpdateButton(ui.getDownloadElement(), EntityHelper.Action.DOWNLOAD.accept(data), text);
+ MainUIRefreshHelper.UpdateButton(ui.getDeleteElement(), EntityHelper.Action.DELETE.accept(data), text);
+ MainUIRefreshHelper.refreshExportElement(context,ui.getExportElement(), model.isRemote(), data);
+ MainUIRefreshHelper.UpdateButton(ui.getShowTab_detail(), true, text);
+ MainUIRefreshHelper.UpdateButton(ui.getShowTab_synchronize(), context.isConnected(), text);
+ }
+
+ /**
+ * Rafraichit les actions de recherche d'un onglet de type liste.
+ *
+ * @param ui l'onglet de liste à utiliser
+ * @param model le modèle de liste à utiliser
+ */
+ public static void refreshSearchActions(JListTab ui, ListTabModel model) {
+ String text = ui.getSearchText().getText();
+ boolean hasQuery = model.getQuery().hasQuery();
+ ui.getSearch().setEnabled(hasQuery || !text.isEmpty());
+ ui.getResetSearch().setEnabled(hasQuery || !text.isEmpty());
+ }
+
+ public static void refreshPagination(JListTab ui, PaginationModel pagination) {
+
+ // refresh changePage combobox
+ refreshChangePageCombo(ui, pagination);
+
+ // refresh changeSizor combo
+ refreshChangeSizorCombo(ui, pagination);
+
+ int page = pagination.getCurrentPage();
+ boolean notLast = page + 1 < pagination.getNbPages();
+ ui.getGoNextPage().setEnabled(notLast);
+ ui.getGoLastPage().setEnabled(notLast);
+ boolean notFirstPage = !(pagination.getSize() < 2 || page < 1);
+ ui.getGoFirstPage().setEnabled(notFirstPage);
+ ui.getGoPreviousPage().setEnabled(notFirstPage);
+ }
+
+ public static void refreshChangeSizorCombo(JListTab ui, PaginationModel pagination) {
+ JComboBox combo = ui.getChangeSizor();
+ String s = pagination.getWidth() + "";
+ if (!s.equals(String.valueOf(combo.getSelectedItem()))) {
+ combo.setEnabled(false);
+ combo.setSelectedItem(s);
+ combo.setEnabled(true);
+ }
+ }
+
+ public static void refreshChangePageCombo(JListTab ui, PaginationModel pagination) {
+ JComboBox combo = ui.getGoPage();
+ long size = pagination.getNbPages();
+ combo.setEnabled(false);
+ //System.out.println("page old size : " + combo.getItemCount() + " new size : " + size);
+ if (size < combo.getItemCount()) {
+ while (size < combo.getItemCount()) {
+ combo.removeItemAt(combo.getItemCount() - 1);
+ }
+ } else {
+ while (size > combo.getItemCount()) {
+ combo.addItem(combo.getItemCount());
+ }
+ }
+ //System.out.println("new page size : " + combo.getItemCount());
+ if (combo.getItemCount() > 0) {
+ combo.setSelectedIndex(pagination.getCurrentPage());
+ }
+ boolean b = combo.getItemCount() > 1;
+ combo.setEnabled(b);
+ ui.getCurrentPage().setEnabled(b);
+ }
+
+ protected ListTabRefreshHelper() {
+ // do not instanciate me please
+ }
+}
\ No newline at end of file
Copied: trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/ui/MainUIRefreshHelper.java (from rev 1132, trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/MainUIRefreshHelper.java)
===================================================================
--- trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/ui/MainUIRefreshHelper.java (rev 0)
+++ trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/ui/MainUIRefreshHelper.java 2008-02-20 18:45:16 UTC (rev 1143)
@@ -0,0 +1,163 @@
+/*
+* ##% Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008 Code Lutin,
+* Tony Chemit, Gabriel Landais
+*
+* 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 fr.cemagref.simexplorer.is.ui.swing.ui;
+
+import fr.cemagref.simexplorer.is.entities.EntityHelper;
+import fr.cemagref.simexplorer.is.entities.metadata.MetaData;
+import fr.cemagref.simexplorer.is.entities.data.LoggableElement;
+import fr.cemagref.simexplorer.is.ui.swing.actions.ExportElementAction;
+import fr.cemagref.simexplorer.is.ui.swing.actions.util.SimExplorerAbstractAction;
+import fr.cemagref.simexplorer.is.ui.swing.SimExplorerContext;
+import static org.codelutin.i18n.I18n._;
+
+import javax.swing.AbstractButton;
+
+/**
+ * Cette classe contient les méthodes utiles et réutilisables pour rafraichit
+ * les ui.
+ * <p/>
+ * Les méthodes utilisent les données stockées dans les modèles pour rafraichir
+ * les uis concernées.
+ * <p/>
+ * Note : <b>Dans toutes ces méthodes, NOS modèles ne doivent en aucun cas être modifiés</b>
+ * <p/>
+ * Par contre les modèles des ui peuvent être modifiés (par exemple modèle d'arbre, de liste)
+ * mais uniquement à partir de nos modèles.
+ *
+ * @author chemit
+ */
+public class MainUIRefreshHelper {
+
+
+ public static void refreshExportElement(SimExplorerContext context, AbstractButton button, boolean remote, LoggableElement sNode) {
+ boolean enabled = EntityHelper.Action.EXPORT.accept(sNode) && context.isConnected();
+ refreshExportElement(context,button, remote, enabled ? sNode.getMetaData(): null);
+ }
+
+ public static void refreshExportElement(SimExplorerContext context, AbstractButton button, boolean remote, MetaData data) {
+ boolean enabled = EntityHelper.Action.EXPORT.accept(data) && context.isConnected();
+ button.setEnabled(enabled);
+ String t = null;
+ if (enabled) {
+ ExportElementAction action = (ExportElementAction) button.getAction();
+ t = _(action.getI18nToolTipText(remote), data.getName(), data.getVersion().toString());
+ }
+ button.setToolTipText(t);
+ }
+
+ protected static void UpdateButton(AbstractButton button, boolean enabled, Object... params) {
+ button.setEnabled(enabled);
+ if (!enabled) {
+ button.setToolTipText(null);
+ } else {
+
+ }
+ SimExplorerAbstractAction action = (SimExplorerAbstractAction) button.getAction();
+ String t = _(action.getI18nToolTipText(), params);
+ button.setToolTipText(t);
+ }
+
+
+ protected MainUIRefreshHelper() {
+ // do not instanciate me please
+ }
+
+}
+
+/**
+ * Rafraichit les uis après un changement de status de connexion de l'utilisateur.
+ * <p/>
+ * Si l'utilisateur est déconnecté, alors toutes les ui et actions liées au
+ * mode remote sont fermées et les actions correspondantes sont rendues
+ * inaccessibles.
+ *
+ * @param ui l'ui principale
+ * @param isConnected flag pour indique si l'utiliseur est connecté
+ * @param history l'historique de l'onglet de detail
+ */
+/* public static void refreshConnnectState(SimExplorerMainUI ui, final boolean isConnected, HistoryModel<EntityTreeNode> history) {
+
+ //SwingUtilities.invokeLater(new Runnable() {
+ // public void run() {
+ ui.getConnect().setEnabled(!isConnected);
+ ui.getUnconnect().setEnabled(isConnected);
+ ui.getShowTab_remote().setEnabled(isConnected);
+ ui.getToggleTab_remote().setEnabled(isConnected);
+
+ JTabbedPane container = ui.getContent();
+ DetailTabModel model = (DetailTabModel) SimExplorerTab.detail.getModel();
+ JDetailTab tabUI = (JDetailTab) SimExplorerTab.detail.getUI();
+ if (!isConnected) {
+ // close all connected ui
+
+ if (SimExplorerTab.remote.isTabVisible(container)) {
+ // close tab
+ SimExplorerTab.remote.closeTab(container);
+ }
+ if (SimExplorerTab.synchronize.isTabVisible(container)) {
+ // close tab
+ SimExplorerTab.synchronize.closeTab(container);
+ }
+ if (SimExplorerTab.detail.isTabVisible(container) && history != null) {
+ if (history.isEmpty()) {
+ // close tab, no more history
+ SimExplorerTab.detail.closeTab(container);
+ } else {
+ // select current history element
+ EntityTreeNode node = history.getCurrent();
+ model.synch(node);
+ //model.setRemote(node.isRemote());
+ //model.setRootNode((LoggableElement) node.getUserObject());
+ DetailTabRefreshHelper.updateDetailNavigationTree(tabUI, model.getHistory());
+ }
+ }
+ }
+ if (SimExplorerTab.detail.isTabVisible(container)) {
+ DetailTabRefreshHelper.refreshSynchroniseAction(tabUI, model);
+ DetailTabRefreshHelper.refreshExportAction(tabUI, model);
+ }
+
+ if (SimExplorerTab.local.isTabVisible(container)) {
+ ListTabRefreshHelper.refreshListTablePopupMenu((JListTab) SimExplorerTab.local.getUI(), (ListTabModel) SimExplorerTab.local.getModel());
+ }
+ // }
+ //});
+}*/
+
+/**
+ * Rafraichit les actions i18n dans le menu en fonction de la locale
+ * actuellement utilisée.
+ *
+ * @param ui l'ui principale
+ */
+/*public static void refreshI18nActions(SimExplorerMainUI ui) {
+ LanguageEnum language = SimExplorer.getContext().getConfig().getUserLanguage();
+ CountryEnum country = SimExplorer.getContext().getConfig().getUserCountry();
+ String[] actions = SimExplorerActionManager.getFactory().getActionNames();
+ for (String actionName : actions) {
+ Matcher matcher = ChangeI18nAbstractAction.PATTERN_NAME.matcher(actionName);
+ if (!matcher.matches()) {
+ continue;
+ }
+ AbstractButton button = (AbstractButton) ui.getObjectById(actionName);
+ ChangeI18nAbstractAction action = (ChangeI18nAbstractAction) button.getAction();
+ boolean enable = !action.equalsLocale(language, country);
+ button.setEnabled(enable);
+ }
+}*/
\ No newline at end of file
Copied: trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/ui/SimExplorerMainUI.java (from rev 1132, trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/SimExplorerMainUI.java)
===================================================================
--- trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/ui/SimExplorerMainUI.java (rev 0)
+++ trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/ui/SimExplorerMainUI.java 2008-02-20 18:45:16 UTC (rev 1143)
@@ -0,0 +1,115 @@
+/*
+* ##% Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008 Code Lutin,
+* Tony Chemit, Gabriel Landais
+*
+* 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 fr.cemagref.simexplorer.is.ui.swing.ui;
+
+import fr.cemagref.simexplorer.is.ui.swing.SimExplorer;
+import fr.cemagref.simexplorer.is.ui.swing.SimExplorerActionManager;
+import fr.cemagref.simexplorer.is.ui.swing.SimExplorerContext;
+import fr.cemagref.simexplorer.is.ui.swing.ui.SimExplorerUI;
+import fr.cemagref.simexplorer.is.ui.swing.actions.util.ChangeI18nAbstractAction;
+import org.codelutin.i18n.CountryEnum;
+import org.codelutin.i18n.LanguageEnum;
+
+import javax.swing.AbstractButton;
+import javax.swing.JComponent;
+import javax.swing.KeyStroke;
+import javax.swing.SwingUtilities;
+import java.awt.event.InputEvent;
+import java.awt.event.KeyEvent;
+import java.util.regex.Matcher;
+
+/**
+ * L'ui principale de l'application
+ *
+ * @author chemit
+ */
+public class SimExplorerMainUI extends SimExplorerUI {
+ /* begin raw body code */
+ /** l'ui principale de l'application */
+ public static SimExplorerMainUI ui;
+
+ public static SimExplorerMainUI getUI() {
+ SimExplorer.checkInitContext();
+ if (ui == null) {
+ ui = new SimExplorerMainUI();
+ }
+ return ui;
+ }
+
+ public void disposeUI() {
+ super.dispose();
+ ui = null;
+ }
+
+ protected SimExplorerMainUI() {
+ super();
+ finalizeInit(SimExplorer.getContext());
+ }
+
+ public void finalizeInit(SimExplorerContext context) {
+
+ // chargement dans l'ui des actions
+ SimExplorerActionManager.loadActions(this, null);
+
+ // add Ctrl-W to close current tab
+ getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_W, InputEvent.CTRL_MASK), "closeTab");
+ getRootPane().getActionMap().put("closeTab", SimExplorerActionManager.newAction("closeTab"));
+ // override Ctrl-F4 close application
+ getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_F4, InputEvent.CTRL_MASK), "quit");
+ getRootPane().getActionMap().put("quit", SimExplorerActionManager.newAction("quit"));
+
+ // repaint i18n actions
+ refreshI18nActions(context);
+ }
+
+ public void setStatus(final String msg) {
+
+ Runnable runnable = new Runnable() {
+ public void run() {
+ //TODO il faut enlever le synchronize dans statusBar
+ //getStatusBar().setStatus(msg);
+ //System.out.println(msg);
+ }
+ };
+ SwingUtilities.invokeLater(runnable);
+ }
+
+ /**
+ * Rafraichit les actions i18n dans le menu en fonction de la locale
+ * actuellement utilisée.
+ *
+ * @param context application context
+ */
+ public void refreshI18nActions(SimExplorerContext context) {
+
+ LanguageEnum language = context.getConfig().getUserLanguage();
+ CountryEnum country = context.getConfig().getUserCountry();
+ String[] actions = SimExplorerActionManager.getFactory().getActionNames();
+ for (String actionName : actions) {
+ Matcher matcher = ChangeI18nAbstractAction.PATTERN_NAME.matcher(actionName);
+ if (!matcher.matches()) {
+ continue;
+ }
+ AbstractButton button = (AbstractButton) getObjectById(actionName);
+ ChangeI18nAbstractAction action = (ChangeI18nAbstractAction) button.getAction();
+ boolean enable = !action.equalsLocale(language, country);
+ button.setEnabled(enable);
+ }
+ }
+}
Copied: trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/ui/SimExplorerTab.java (from rev 1132, trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/SimExplorerTab.java)
===================================================================
--- trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/ui/SimExplorerTab.java (rev 0)
+++ trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/ui/SimExplorerTab.java 2008-02-20 18:45:16 UTC (rev 1143)
@@ -0,0 +1,189 @@
+/*
+* ##% Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008 Code Lutin,
+* Tony Chemit
+*
+* This program is free software; you can redistribute it and/or
+* modify it under the terms of the GNU General Public License
+* as published by the Free Software Foundation; either version 2
+* of the License, or (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with this program; if not, write to the Free Software
+* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+* ##% */
+package fr.cemagref.simexplorer.is.ui.swing.ui;
+
+import fr.cemagref.simexplorer.is.ui.swing.ui.JDetailTab;
+import fr.cemagref.simexplorer.is.ui.swing.ui.JListTab;
+import fr.cemagref.simexplorer.is.ui.swing.ui.JSynchronizeTab;
+import fr.cemagref.simexplorer.is.ui.swing.SimExplorerContext;
+import fr.cemagref.simexplorer.is.ui.swing.model.DetailTabModel;
+import fr.cemagref.simexplorer.is.ui.swing.model.ListTabModel;
+import fr.cemagref.simexplorer.is.ui.swing.model.SimExplorerTabModel;
+import fr.cemagref.simexplorer.is.ui.swing.model.SynchronizeTabModel;
+import jaxx.runtime.builder.TabContentConfig;
+import jaxx.runtime.swing.JAXXTab;
+
+import javax.swing.JPopupMenu;
+import javax.swing.JTabbedPane;
+import java.awt.Component;
+
+/**
+ * La défintion des onglets utilisés dans l'application
+ *
+ * @author tony
+ */
+
+public enum SimExplorerTab {
+
+ @TabContentConfig(
+ impl = JDetailTab.class,
+ model = DetailTabModel.class,
+ parentImpl = JTabbedPane.class,
+ name = "simexplorer.tab.detail",
+ shortDescription = "simexplorer.tab.detail.tooltip"
+ )detail {
+ public <U extends JAXXTab, M extends SimExplorerTabModel> void updateUI(SimExplorerContext context, SimExplorerMainUI mainUi, U ui, M model) {
+ DetailTabRefreshHelper.refreshDetailTab((JDetailTab) ui, (DetailTabModel) model);
+ }},
+
+ @TabContentConfig(
+ impl = JListTab.class,
+ parentImpl = JTabbedPane.class,
+ model = ListTabModel.class,
+ useToogle = true,
+ name = "simexplorer.tab.local",
+ shortDescription = "simexplorer.tab.local.tooltip"
+ )local {
+ public <U extends JAXXTab, M extends SimExplorerTabModel> void updateUI(SimExplorerContext context, SimExplorerMainUI mainUi, U ui, M model) {
+ ListTabRefreshHelper.refreshListTabUI(mainUi, (JListTab) ui, (ListTabModel) model);
+ }},
+
+ @TabContentConfig(
+ impl = JListTab.class,
+ parentImpl = JTabbedPane.class,
+ model = ListTabModel.class,
+ useToogle = true,
+ name = "simexplorer.tab.remote",
+ shortDescription = "simexplorer.tab.remote.tooltip"
+ )remote {
+ public <U extends JAXXTab, M extends SimExplorerTabModel> void updateUI(SimExplorerContext context, SimExplorerMainUI mainUi, U ui, M model) {
+ ListTabRefreshHelper.refreshListTabUI(mainUi, (JListTab) ui, (ListTabModel) model);
+ }},
+
+ @TabContentConfig(
+ impl = JSynchronizeTab.class,
+ parentImpl = JTabbedPane.class,
+ model = SynchronizeTabModel.class,
+ useToogle = false,
+ name = "simexplorer.tab.synchronize",
+ shortDescription = "simexplorer.tab.synchronize.tooltip"
+ )synchronize {
+ public <U extends JAXXTab, M extends SimExplorerTabModel> void updateUI(SimExplorerContext context, SimExplorerMainUI mainUi, U ui, M model) {
+ SynchronizeTabRefreshHelper.refreshSynchronizeTab(context,(JSynchronizeTab) ui, (SynchronizeTabModel) model);
+ }
+ };
+
+ /** l'usine de tabs */
+ private static SimExplorerTabFactory factory;
+
+ public static SimExplorerTabFactory getFactory() {
+ if (factory == null) {
+ factory = new SimExplorerTabFactory();
+ }
+ return factory;
+ }
+
+ /**
+ * recherche d'un onglet contenant un component.
+ *
+ * @param c le component dont on cherche l'onglet
+ * @return l'onglet parent du component, ou null si pas de tab trouvé
+ */
+ public static SimExplorerTab findTab(Component c) {
+ Component parent = c.getParent();
+ while (parent != null) {
+ if (parent instanceof JPopupMenu) {
+ parent = ((JPopupMenu) parent).getInvoker();
+ }
+ if (parent instanceof JAXXTab) {
+ // find a JAXXTab
+ for (SimExplorerTab tab : values()) {
+ if (parent.equals(tab.getUI())) {
+ // find the correct tab
+ return tab;
+ }
+ }
+ break;
+ }
+ parent = parent.getParent();
+ }
+ return null;
+ }
+
+ public static SimExplorerTab getListTab(boolean remote) {
+ return remote ? SimExplorerTab.remote : SimExplorerTab.local;
+ }
+
+ public static JListTab getListUI(boolean remote) {
+ return (JListTab) getListTab(remote).getUI();
+ }
+
+ public static ListTabModel getListModel(boolean remote) {
+ return (ListTabModel) getListTab(remote).getModel();
+ }
+
+ public static void dispose() {
+ SimExplorerTab.getFactory().resetCache();
+ // remove listeners on detail tab model
+ for (SimExplorerTab tab : SimExplorerTab.values()) {
+ tab.removePropertyChangeListeners();
+ }
+ }
+
+ public abstract <U extends JAXXTab, M extends SimExplorerTabModel> void updateUI(SimExplorerContext context, SimExplorerMainUI mainUi, U ui, M model);
+
+ public JAXXTab getUI() {
+ return getFactory().getUI(name());
+ }
+
+ public SimExplorerTabModel getModel() {
+ return getFactory().getModel(name());
+ }
+
+ public boolean isTabVisible(JTabbedPane container) {
+ JAXXTab ui = getUI();
+ return ui != null && getFactory().getTabIndex(container, ui) > -1;
+ }
+
+ public boolean isTabSelected(JTabbedPane container) {
+ return isTabVisible(container) && getFactory().getTabIndex(container, getUI()) == container.getSelectedIndex();
+ }
+
+ public int getTabIndex(JTabbedPane container) {
+ JAXXTab ui = getUI();
+ return ui == null ? -1 : getFactory().getTabIndex(container, ui);
+ }
+
+ public void showTab(final JTabbedPane container) {
+ getFactory().showTab(container, name());
+ }
+
+ public void closeTab(SimExplorerMainUI mainUi, JTabbedPane container) {
+ getFactory().closeTab(mainUi, container, name());
+ getModel().setSelectedItem(null);
+ }
+
+ public void updateUI(SimExplorerContext context, SimExplorerMainUI mainUI) {
+ updateUI(context,mainUI, getUI(), getModel());
+ }
+
+ public void removePropertyChangeListeners() {
+ getModel().removePropertyChangeListeners();
+ }
+}
Copied: trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/ui/SimExplorerTabFactory.java (from rev 1132, trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/SimExplorerTabFactory.java)
===================================================================
--- trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/ui/SimExplorerTabFactory.java (rev 0)
+++ trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/ui/SimExplorerTabFactory.java 2008-02-20 18:45:16 UTC (rev 1143)
@@ -0,0 +1,130 @@
+/*
+* ##% Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008 Code Lutin,
+* Tony Chemit, Gabriel Landais
+*
+* 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 fr.cemagref.simexplorer.is.ui.swing.ui;
+
+import fr.cemagref.simexplorer.is.exceptions.SimExplorerRuntimeException;
+import fr.cemagref.simexplorer.is.ui.swing.SimExplorerActionManager;
+import fr.cemagref.simexplorer.is.ui.swing.model.SimExplorerTabModel;
+import fr.cemagref.simexplorer.is.ui.swing.ui.util.MyTabHeader;
+import jaxx.runtime.JAXXObject;
+import jaxx.runtime.builder.TabContentConfig;
+import jaxx.runtime.builder.TabFactory;
+import jaxx.runtime.swing.JAXXTab;
+import static org.codelutin.i18n.I18n._;
+
+import javax.swing.AbstractButton;
+import javax.swing.JComponent;
+import javax.swing.JTabbedPane;
+import java.awt.Component;
+import java.awt.event.MouseAdapter;
+import java.awt.event.MouseEvent;
+import java.lang.reflect.Field;
+import java.util.Map;
+import java.util.TreeMap;
+
+/**
+ * L'implatantion pour SimExplorer de la factory de Tab
+ *
+ * @author chemit
+ * @see TabFactory
+ */
+public class SimExplorerTabFactory extends TabFactory {
+
+ protected Map<String, TabContentConfig> initFactory() {
+ Map<String, TabContentConfig> result = new TreeMap<String, TabContentConfig>();
+ for (SimExplorerTab tab : SimExplorerTab.values()) {
+ try {
+ String tabName = tab.name();
+ Field field = tab.getClass().getField(tabName);
+ result.put(tabName, field.getAnnotation(TabContentConfig.class));
+ } catch (NoSuchFieldException e) {
+ throw new SimExplorerRuntimeException(e);
+ }
+ }
+ return result;
+ }
+
+ protected void initTab(JAXXTab tab, String tabName, TabContentConfig config) {
+ SimExplorerActionManager.loadActions((JAXXObject) tab, getTab(tabName));
+ }
+
+ protected SimExplorerTab getTab(String tabName) {
+ return SimExplorerTab.valueOf(tabName);
+ }
+
+ @Override
+ public SimExplorerTabModel getModel(String tabName) {
+ return (SimExplorerTabModel) super.getModel(tabName);
+ }
+
+ @Override
+ protected JComponent addTabHeader(final JTabbedPane container,
+ String tabName,
+ TabContentConfig tab,
+ final JAXXTab comp) {
+
+ final MyTabHeader panel = new MyTabHeader();
+
+ // add a dynamic reference to tab close button to enable
+ // dynamic action instanciation
+ //TODO add the ActionManager mecanism ?
+ String actionName = panel.getCloseTab().getName() + "_" + tabName;
+
+ panel.get$objectMap().put(actionName, panel.getCloseTab());
+
+ // chargement dans l'ui des actions
+ SimExplorerActionManager.loadActions(panel, getTab(tabName));
+
+ panel.setToolTipText(_(tab.shortDescription()));
+ panel.getLabel().setText(_(tab.name()));
+
+ panel.addMouseListener(new MouseAdapter() {
+ @Override
+ public void mouseClicked(MouseEvent e) {
+ Component compOld = container.getSelectedComponent();
+ if (!comp.equals(compOld)) {
+ //TODO should use the showTab_XXX action
+ container.setSelectedComponent(comp);
+ }
+ }
+ });
+ return panel;
+ }
+
+
+ public void showTab(SimExplorerMainUI mainUI, JTabbedPane container, String tabName) {
+ super.showTab(container, tabName);
+ switchToggleButton(mainUI, tabName, true);
+ }
+
+ public void closeTab(SimExplorerMainUI mainUi, JTabbedPane container, String tabName) {
+ super.closeTab(container, tabName);
+ switchToggleButton(mainUi, tabName, false);
+ }
+
+ protected void switchToggleButton(SimExplorerMainUI mainUi, String tabName, boolean b) {
+ TabContentConfig tab = getConfig(tabName);
+ if (tab.useToogle()) {
+ AbstractButton buton;
+ buton = (AbstractButton) mainUi.getObjectById("toggleTab_" + tabName);
+ buton.setSelected(b);
+ }
+ }
+
+}
Copied: trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/ui/SynchronizeTabRefreshHelper.java (from rev 1135, trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/SynchronizeTabRefreshHelper.java)
===================================================================
--- trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/ui/SynchronizeTabRefreshHelper.java (rev 0)
+++ trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/ui/SynchronizeTabRefreshHelper.java 2008-02-20 18:45:16 UTC (rev 1143)
@@ -0,0 +1,111 @@
+/*
+* ##% Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008 Code Lutin,
+* Tony Chemit, Gabriel Landais
+*
+* 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 fr.cemagref.simexplorer.is.ui.swing.ui;
+
+import fr.cemagref.simexplorer.is.entities.data.LoggableElement;
+import fr.cemagref.simexplorer.is.ui.swing.ui.JSynchronizeTab;
+import fr.cemagref.simexplorer.is.ui.swing.SimExplorerContext;
+import fr.cemagref.simexplorer.is.ui.swing.model.SynchronizeTabModel;
+
+import javax.swing.JTabbedPane;
+import javax.swing.JTree;
+import javax.swing.tree.DefaultTreeModel;
+import javax.swing.tree.TreeNode;
+
+/**
+ * Cette classe contient les méthodes utiles et réutilisables pour rafraichir
+ * les onglets de liste.
+ * <p/>
+ * Les méthodes utilisent les données stockées dans les modèles pour rafraichir
+ * les uis concernées.
+ * <p/>
+ * Note : <b>Dans toutes ces méthodes, NOS modèles ne doivent en aucun cas être modifiés</b>
+ * <p/>
+ * Par contre les modèles des ui peuvent être modifiés (par exemple modèle d'arbre, de liste)
+ * mais uniquement à partir de nos modèles.
+ *
+ * @author chemit
+ */
+public class SynchronizeTabRefreshHelper {
+
+ protected static void refreshSynchronizeTab(SimExplorerContext context, JSynchronizeTab ui, SynchronizeTabModel model) {
+
+ EntityTreeNodeHelper.refreshTreeActions(ui.getCollapseButton(false), ui.getExpandButton(false), null);
+ EntityTreeNodeHelper.refreshTreeActions(ui.getCollapseButton(true), ui.getExpandButton(true), null);
+
+ refreshExportElement(context, ui, model, true);
+ refreshExportElement(context, ui, model, false);
+
+ refreshRootNode(ui, model, false);
+ refreshRootNode(ui, model, true);
+ }
+
+ public static void updateTree(SimExplorerMainUI mainUi, JTabbedPane container, LoggableElement oldLocalRoot, LoggableElement oldRemoteRoot) {
+
+ SimExplorerTab tab = SimExplorerTab.synchronize;
+
+ SynchronizeTabModel model = (SynchronizeTabModel) tab.getModel();
+ if (model.getRootNode(false) == null && model.getRootNode(true) == null) {
+ // on doit supprimer la vue
+ tab.closeTab(mainUi, container);
+ }
+
+ JSynchronizeTab ui = (JSynchronizeTab) tab.getUI();
+
+ if (model.getRootNode(false) != oldLocalRoot) {
+ // rebuild node ?
+ refreshRootNode(ui, model, false);
+ }
+
+ if (model.getRootNode(true) != oldRemoteRoot) {
+ // rebuild node ?
+ refreshRootNode(ui, model, true);
+ }
+ }
+
+ protected static void refreshRootNode(JSynchronizeTab ui, SynchronizeTabModel model, boolean remote) {
+
+ LoggableElement element;
+ TreeNode root = null;
+
+ element = model.getRootNode(remote);
+ if (element != null) {
+ root = EntityTreeNodeHelper.build(element, remote);
+ }
+
+ JTree tree = ui.getTree(remote);
+
+ ((DefaultTreeModel) tree.getModel()).setRoot(root);
+
+ if (root == null) {
+ tree.getSelectionModel().clearSelection();
+ } else {
+ tree.setSelectionRow(0);
+ }
+ }
+
+ public static void refreshExportElement(SimExplorerContext context, JSynchronizeTab ui, SynchronizeTabModel model, boolean remote) {
+ LoggableElement sNode = model.getSelectedNode(remote);
+ MainUIRefreshHelper.refreshExportElement(context, ui.getExportButton(remote), remote, sNode);
+ }
+
+ protected SynchronizeTabRefreshHelper() {
+ // do not instanciate me please
+ }
+}
\ No newline at end of file
Added: trunk/simexplorer-is/simexplorer-is-swing/src/test/fr/cemagref/simexplorer/is/ui/swing/ui/SimExplorerUIRefreshHelperTest.java
===================================================================
--- trunk/simexplorer-is/simexplorer-is-swing/src/test/fr/cemagref/simexplorer/is/ui/swing/ui/SimExplorerUIRefreshHelperTest.java (rev 0)
+++ trunk/simexplorer-is/simexplorer-is-swing/src/test/fr/cemagref/simexplorer/is/ui/swing/ui/SimExplorerUIRefreshHelperTest.java 2008-02-20 18:45:16 UTC (rev 1143)
@@ -0,0 +1,78 @@
+package fr.cemagref.simexplorer.is.ui.swing.ui;
+
+import junit.framework.TestCase;
+import fr.cemagref.simexplorer.is.ui.swing.ui.DetailTabRefreshHelper;
+
+/**
+ * SimExplorerUIRefreshHelper Tester.
+ *
+ * @author chemit
+ * @version 1.0
+ * @since <pre>02/08/2008</pre>
+ */
+public class SimExplorerUIRefreshHelperTest extends TestCase {
+ int max = 14;
+ public SimExplorerUIRefreshHelperTest(String name) {
+ super(name);
+ }
+
+ public void testComputeRowLimitCases() throws Exception {
+ for (int i = 0; i < max+1; i++) {
+ assertComputeRow(0, i, DetailTabRefreshHelper.computeRows(0, i));
+ }
+ for (int i = 0; i < max+1; i++) {
+ assertComputeRow(i, 0, DetailTabRefreshHelper.computeRows(i, 0));
+ }
+ assertComputeRow(0, max, DetailTabRefreshHelper.computeRows(0, max+1));
+ assertComputeRow(max, 0, DetailTabRefreshHelper.computeRows(max+1, 0));
+ }
+
+
+ public void testComputeRowDescriptor() throws Exception {
+ for (int i = 1; i < max-1; i++) {
+ testComputeRowDescriptor(i);
+ }
+ }
+
+ public void testComputeRowAttachment() throws Exception {
+ for (int i = 1; i < max-1; i++) {
+ testComputeRowAttachment(i);
+ }
+ }
+
+ public void testComputeRowAttachment(int nb) throws Exception {
+ int pivot = max - nb;
+ for (int i = 0; i < pivot + 1; i++) {
+ assertComputeRow(i, nb, DetailTabRefreshHelper.computeRows(i, nb));
+ }
+ for (int i = pivot + 1; i < max+1; i++) {
+ if (nb + i > max) {
+ int[] res = DetailTabRefreshHelper.computeRows(i, nb);
+ assertEquals(max, res[0] + res[1]);
+ } else {
+ assertComputeRow(pivot, nb, DetailTabRefreshHelper.computeRows(i, nb));
+ }
+ }
+ }
+
+ public void testComputeRowDescriptor(int nb) throws Exception {
+ int pivot = max - nb;
+ for (int i = 0; i < pivot + 1; i++) {
+ assertComputeRow(nb, i, DetailTabRefreshHelper.computeRows(nb, i));
+ }
+ for (int i = pivot + 1; i < max+1; i++) {
+ if (nb + i > max) {
+ int[] res = DetailTabRefreshHelper.computeRows(nb, i);
+ assertEquals(max, res[0] + res[1]);
+ } else {
+ assertComputeRow(nb, pivot, DetailTabRefreshHelper.computeRows(nb, i));
+ }
+ }
+ }
+
+ public void assertComputeRow(int expectedOne, int expectedTwo, int[] result) {
+ assertEquals(expectedOne, result[0]);
+ assertEquals(expectedTwo, result[1]);
+ }
+
+}
1
0
r1142 - in trunk/simexplorer-is/simexplorer-is-swing/src/uimodel/fr/cemagref/simexplorer/is/ui/swing: ui ui/util util
by tchemit@users.labs.libre-entreprise.org 20 Feb '08
by tchemit@users.labs.libre-entreprise.org 20 Feb '08
20 Feb '08
Author: tchemit
Date: 2008-02-20 18:43:44 +0000 (Wed, 20 Feb 2008)
New Revision: 1142
Added:
trunk/simexplorer-is/simexplorer-is-swing/src/uimodel/fr/cemagref/simexplorer/is/ui/swing/ui/util/
trunk/simexplorer-is/simexplorer-is-swing/src/uimodel/fr/cemagref/simexplorer/is/ui/swing/ui/util/ErrorDialog.jaxx
Removed:
trunk/simexplorer-is/simexplorer-is-swing/src/uimodel/fr/cemagref/simexplorer/is/ui/swing/ui/util/ErrorDialog.jaxx
trunk/simexplorer-is/simexplorer-is-swing/src/uimodel/fr/cemagref/simexplorer/is/ui/swing/util/ChooseFile.jaxx
trunk/simexplorer-is/simexplorer-is-swing/src/uimodel/fr/cemagref/simexplorer/is/ui/swing/util/ChooseFilePanel.jaxx
trunk/simexplorer-is/simexplorer-is-swing/src/uimodel/fr/cemagref/simexplorer/is/ui/swing/util/ErrorDialog.jaxx
trunk/simexplorer-is/simexplorer-is-swing/src/uimodel/fr/cemagref/simexplorer/is/ui/swing/util/MyTabHeader.jaxx
Log:
move ui to ui package
Copied: trunk/simexplorer-is/simexplorer-is-swing/src/uimodel/fr/cemagref/simexplorer/is/ui/swing/ui/util (from rev 1132, trunk/simexplorer-is/simexplorer-is-swing/src/uimodel/fr/cemagref/simexplorer/is/ui/swing/util)
Deleted: trunk/simexplorer-is/simexplorer-is-swing/src/uimodel/fr/cemagref/simexplorer/is/ui/swing/ui/util/ErrorDialog.jaxx
===================================================================
--- trunk/simexplorer-is/simexplorer-is-swing/src/uimodel/fr/cemagref/simexplorer/is/ui/swing/util/ErrorDialog.jaxx 2008-02-19 21:13:55 UTC (rev 1132)
+++ trunk/simexplorer-is/simexplorer-is-swing/src/uimodel/fr/cemagref/simexplorer/is/ui/swing/ui/util/ErrorDialog.jaxx 2008-02-20 18:43:44 UTC (rev 1142)
@@ -1,34 +0,0 @@
-<JDialog title='simexplorer.error.dialog.title'>
- <script>
- JRootPane rootPane = getRootPane();
- rootPane.setDefaultButton(close);
- rootPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("ESCAPE"), "close");
- rootPane.getActionMap().put("close", close.getAction());
- </script>
- <Table>
- <row fill='both'>
- <cell>
- <JPanel>
- <JLabel text='simexplorer.error.dialog.message'/>
- </JPanel>
- </cell>
- </row>
- <row fill='both'>
- <cell>
- <JLabel id='errorMessage' />
- </cell>
- </row>
- <row fill='both' weightx='1' weighty='1'>
- <cell>
- <JScrollPane width='600' height='200'>
- <JTextArea id='errorStack' editable='false' font-size='9'/>
- </JScrollPane>
- </cell>
- </row>
- <row fill='horizontal'>
- <cell>
- <JButton id='close' text='simexplorer.common.close' onActionPerformed='dispose()'/>
- </cell>
- </row>
- </Table>
-</JDialog>
Copied: trunk/simexplorer-is/simexplorer-is-swing/src/uimodel/fr/cemagref/simexplorer/is/ui/swing/ui/util/ErrorDialog.jaxx (from rev 1140, trunk/simexplorer-is/simexplorer-is-swing/src/uimodel/fr/cemagref/simexplorer/is/ui/swing/util/ErrorDialog.jaxx)
===================================================================
--- trunk/simexplorer-is/simexplorer-is-swing/src/uimodel/fr/cemagref/simexplorer/is/ui/swing/ui/util/ErrorDialog.jaxx (rev 0)
+++ trunk/simexplorer-is/simexplorer-is-swing/src/uimodel/fr/cemagref/simexplorer/is/ui/swing/ui/util/ErrorDialog.jaxx 2008-02-20 18:43:44 UTC (rev 1142)
@@ -0,0 +1,53 @@
+<JDialog title='simexplorer.error.dialog.title'>
+ <script>
+
+/** le dialogue pour afficher les erreurs */
+protected static ErrorDialog instance;
+
+public static void showError(Exception e) {
+ if (instance == null) {
+ instance = new ErrorDialog();
+ }
+ instance.getErrorMessage().setText(e.getMessage());
+ StringWriter w = new StringWriter();
+ e.printStackTrace(new PrintWriter(w));
+ instance.getErrorStack().setText(w.toString());
+ instance.getErrorStack().setCaretPosition(0);
+ instance.pack();
+ instance.setVisible(true);
+}
+public static void disposeUI() {
+ instance=null;
+}
+JRootPane rootPane = getRootPane();
+rootPane.setDefaultButton(close);
+rootPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("ESCAPE"), "close");
+rootPane.getActionMap().put("close", close.getAction());
+ </script>
+ <Table>
+ <row fill='both'>
+ <cell>
+ <JPanel>
+ <JLabel text='simexplorer.error.dialog.message'/>
+ </JPanel>
+ </cell>
+ </row>
+ <row fill='both'>
+ <cell>
+ <JLabel id='errorMessage' />
+ </cell>
+ </row>
+ <row fill='both' weightx='1' weighty='1'>
+ <cell>
+ <JScrollPane width='600' height='200'>
+ <JTextArea id='errorStack' editable='false' font-size='9'/>
+ </JScrollPane>
+ </cell>
+ </row>
+ <row fill='horizontal'>
+ <cell>
+ <JButton id='close' text='simexplorer.common.close' onActionPerformed='dispose()'/>
+ </cell>
+ </row>
+ </Table>
+</JDialog>
Deleted: trunk/simexplorer-is/simexplorer-is-swing/src/uimodel/fr/cemagref/simexplorer/is/ui/swing/util/ChooseFile.jaxx
===================================================================
--- trunk/simexplorer-is/simexplorer-is-swing/src/uimodel/fr/cemagref/simexplorer/is/ui/swing/util/ChooseFile.jaxx 2008-02-20 18:42:52 UTC (rev 1141)
+++ trunk/simexplorer-is/simexplorer-is-swing/src/uimodel/fr/cemagref/simexplorer/is/ui/swing/util/ChooseFile.jaxx 2008-02-20 18:43:44 UTC (rev 1142)
@@ -1,37 +0,0 @@
-<JDialog title='simexplorer.error.dialog.title'>
- <script>
- JRootPane rootPane = getRootPane();
- rootPane.setDefaultButton(cancel);
- rootPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("ESCAPE"), "cancel");
- rootPane.getActionMap().put("cancel", cancel.getAction());
-
- protected void doOk() {
- // TODO implements it
- }
-
- protected void doCancel() {
- dispose();
- }
-
- </script>
- <Table>
- <row fill='both' weightx="1">
- <cell>
- <fr.cemagref.simexplorer.is.ui.swing.util.ChooseFilePanel />
- </cell>
- </row>
- <row fill='both' weightx='1' weighty='1'>
- <cell>
- <JPanel id='content' visible='false'/>
- </cell>
- </row>
- <row fill='horizontal'>
- <cell>
- <JPanel layout='{new GridLayout(1, 0, 6, 6)}'>
- <JButton id='ok' text='simexplorer.common.ok' onActionPerformed='doOk()'/>
- <JButton id='cancel' text='simexplorer.common.cancel' onActionPerformed='doCancel()'/>
- </JPanel>
- </cell>
- </row>
- </Table>
-</JDialog>
Deleted: trunk/simexplorer-is/simexplorer-is-swing/src/uimodel/fr/cemagref/simexplorer/is/ui/swing/util/ChooseFilePanel.jaxx
===================================================================
--- trunk/simexplorer-is/simexplorer-is-swing/src/uimodel/fr/cemagref/simexplorer/is/ui/swing/util/ChooseFilePanel.jaxx 2008-02-20 18:42:52 UTC (rev 1141)
+++ trunk/simexplorer-is/simexplorer-is-swing/src/uimodel/fr/cemagref/simexplorer/is/ui/swing/util/ChooseFilePanel.jaxx 2008-02-20 18:43:44 UTC (rev 1142)
@@ -1,36 +0,0 @@
-<Table>
- <script>
-protected void chooseDir() {
- String dir= org.codelutin.util.FileUtil.getDirectory();
- if (dir!=null) {
- directory.setText(dir);
- }
-}
- </script>
- <row fill='both'>
- <cell>
- <JPanel>
- <JLabel id='message'/>
- </JPanel>
- </cell>
- </row>
- <row fill='both'>
- <cell>
- <JTextField id='directory'/>
- </cell>
- <cell>
- <JButton id='chooseDirectory'
- icon='{createImageIcon("action/fileChooser.png")}'
- onActionPerformed='chooseDir()'/>
- </cell>
- </row>
-
- <row fill='both'>
- <cell>
- <JLabel id='fileLabel' labelFor='{file}'/>
- </cell>
- <cell weightx='1'>
- <JTextField id='file'/>
- </cell>
- </row>
-</Table>
Deleted: trunk/simexplorer-is/simexplorer-is-swing/src/uimodel/fr/cemagref/simexplorer/is/ui/swing/util/ErrorDialog.jaxx
===================================================================
--- trunk/simexplorer-is/simexplorer-is-swing/src/uimodel/fr/cemagref/simexplorer/is/ui/swing/util/ErrorDialog.jaxx 2008-02-20 18:42:52 UTC (rev 1141)
+++ trunk/simexplorer-is/simexplorer-is-swing/src/uimodel/fr/cemagref/simexplorer/is/ui/swing/util/ErrorDialog.jaxx 2008-02-20 18:43:44 UTC (rev 1142)
@@ -1,53 +0,0 @@
-<JDialog title='simexplorer.error.dialog.title'>
- <script>
-
-/** le dialogue pour afficher les erreurs */
-protected static ErrorDialog instance;
-
-public static void showError(Exception e) {
- if (instance == null) {
- instance = new ErrorDialog();
- }
- instance.getErrorMessage().setText(e.getMessage());
- StringWriter w = new StringWriter();
- e.printStackTrace(new PrintWriter(w));
- instance.getErrorStack().setText(w.toString());
- instance.getErrorStack().setCaretPosition(0);
- instance.pack();
- instance.setVisible(true);
-}
-public static void disposeUI() {
- instance=null;
-}
-JRootPane rootPane = getRootPane();
-rootPane.setDefaultButton(close);
-rootPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("ESCAPE"), "close");
-rootPane.getActionMap().put("close", close.getAction());
- </script>
- <Table>
- <row fill='both'>
- <cell>
- <JPanel>
- <JLabel text='simexplorer.error.dialog.message'/>
- </JPanel>
- </cell>
- </row>
- <row fill='both'>
- <cell>
- <JLabel id='errorMessage' />
- </cell>
- </row>
- <row fill='both' weightx='1' weighty='1'>
- <cell>
- <JScrollPane width='600' height='200'>
- <JTextArea id='errorStack' editable='false' font-size='9'/>
- </JScrollPane>
- </cell>
- </row>
- <row fill='horizontal'>
- <cell>
- <JButton id='close' text='simexplorer.common.close' onActionPerformed='dispose()'/>
- </cell>
- </row>
- </Table>
-</JDialog>
Deleted: trunk/simexplorer-is/simexplorer-is-swing/src/uimodel/fr/cemagref/simexplorer/is/ui/swing/util/MyTabHeader.jaxx
===================================================================
--- trunk/simexplorer-is/simexplorer-is-swing/src/uimodel/fr/cemagref/simexplorer/is/ui/swing/util/MyTabHeader.jaxx 2008-02-20 18:42:52 UTC (rev 1141)
+++ trunk/simexplorer-is/simexplorer-is-swing/src/uimodel/fr/cemagref/simexplorer/is/ui/swing/util/MyTabHeader.jaxx 2008-02-20 18:43:44 UTC (rev 1142)
@@ -1,18 +0,0 @@
-<Table insets='0,0,0,0' opaque='false'>
- <row fill='both'>
- <cell anchor='west' weightx="1" insets='0,0,0,0'>
- <JLabel id='label' opaque='false' font-size='12'
- verticalAlignment='center' verticalTextPosition='0'/>
- </cell>
- <cell anchor='east' insets='2,15,0,0' weighty='1'>
- <JButton id='closeTab' preferredSize='{new Dimension(18,18)}'
- verticalAlignment='0'
- verticalTextPosition='0'
- opaque='true'
- borderPainted='true'
- focusPainted='false'
- enabled='false'
- horizontalTextPosition='0'/>
- </cell>
- </row>
-</Table>
1
0
r1141 - in trunk/simexplorer-is/simexplorer-is-swing/src/uimodel/fr/cemagref/simexplorer/is/ui/swing: . ui
by tchemit@users.labs.libre-entreprise.org 20 Feb '08
by tchemit@users.labs.libre-entreprise.org 20 Feb '08
20 Feb '08
Author: tchemit
Date: 2008-02-20 18:42:52 +0000 (Wed, 20 Feb 2008)
New Revision: 1141
Added:
trunk/simexplorer-is/simexplorer-is-swing/src/uimodel/fr/cemagref/simexplorer/is/ui/swing/ui/
trunk/simexplorer-is/simexplorer-is-swing/src/uimodel/fr/cemagref/simexplorer/is/ui/swing/ui/ImportDialog.jaxx
trunk/simexplorer-is/simexplorer-is-swing/src/uimodel/fr/cemagref/simexplorer/is/ui/swing/ui/JDetailTab.jaxx
trunk/simexplorer-is/simexplorer-is-swing/src/uimodel/fr/cemagref/simexplorer/is/ui/swing/ui/JListTab.jaxx
trunk/simexplorer-is/simexplorer-is-swing/src/uimodel/fr/cemagref/simexplorer/is/ui/swing/ui/JSynchronizeTab.jaxx
trunk/simexplorer-is/simexplorer-is-swing/src/uimodel/fr/cemagref/simexplorer/is/ui/swing/ui/LoginUI.jaxx
trunk/simexplorer-is/simexplorer-is-swing/src/uimodel/fr/cemagref/simexplorer/is/ui/swing/ui/SimExplorerUI.jaxx
trunk/simexplorer-is/simexplorer-is-swing/src/uimodel/fr/cemagref/simexplorer/is/ui/swing/ui/common.css
Removed:
trunk/simexplorer-is/simexplorer-is-swing/src/uimodel/fr/cemagref/simexplorer/is/ui/swing/ImportDialog.jaxx
trunk/simexplorer-is/simexplorer-is-swing/src/uimodel/fr/cemagref/simexplorer/is/ui/swing/JDetailTab.jaxx
trunk/simexplorer-is/simexplorer-is-swing/src/uimodel/fr/cemagref/simexplorer/is/ui/swing/JListTab.jaxx
trunk/simexplorer-is/simexplorer-is-swing/src/uimodel/fr/cemagref/simexplorer/is/ui/swing/JSynchronizeTab.jaxx
trunk/simexplorer-is/simexplorer-is-swing/src/uimodel/fr/cemagref/simexplorer/is/ui/swing/LoginUI.jaxx
trunk/simexplorer-is/simexplorer-is-swing/src/uimodel/fr/cemagref/simexplorer/is/ui/swing/SimExplorerUI.jaxx
trunk/simexplorer-is/simexplorer-is-swing/src/uimodel/fr/cemagref/simexplorer/is/ui/swing/common.css
Log:
move ui to ui package
Deleted: trunk/simexplorer-is/simexplorer-is-swing/src/uimodel/fr/cemagref/simexplorer/is/ui/swing/ImportDialog.jaxx
===================================================================
--- trunk/simexplorer-is/simexplorer-is-swing/src/uimodel/fr/cemagref/simexplorer/is/ui/swing/ImportDialog.jaxx 2008-02-20 18:42:03 UTC (rev 1140)
+++ trunk/simexplorer-is/simexplorer-is-swing/src/uimodel/fr/cemagref/simexplorer/is/ui/swing/ImportDialog.jaxx 2008-02-20 18:42:52 UTC (rev 1141)
@@ -1,82 +0,0 @@
-<JDialog>
- <script>
-AbstractAction cancelAction = new AbstractAction(_("simexplorer.common.cancel")){
- private static final long serialVersionUID = -4585698788717305452L;
-
- public void actionPerformed(ActionEvent e) {
- filePath.setText(null);
- dispose();
- }
-};
-
-public java.io.File getFile() {
- setVisible(true);
- if (filePath.getText().equals("")) {
- return null;
- }
- java.io.File f= new java.io.File(filePath.getText());
- filePath.setText(null);
- return f;
-}
-
-private java.util.Map<String, String[]> filters;
-
-protected void chooseDir() {
- String type = (String) getTypeImport().getSelectedValue();
- String[] filter = this.filters.get(type);
- File dir= org.codelutin.util.FileUtil.getFile(filter==null?null:filter);
- if (dir!=null) {
- filePath.setText(dir.toString());
- }
-}
-protected void check() {
- String t = filePath.getText();
- java.io.File f = new File(t);
- ok.setEnabled(!t.equals("") && f.exists() && f.isFile());
-}
-
-public ImportDialog(JFrame frame,java.util.Map<String,String[]> filters) {
- super(frame,true);
- JRootPane rootPane = getRootPane();
- rootPane.setDefaultButton(ok);
- rootPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("ESCAPE"),"cancel");
- rootPane.getActionMap().put("cancel", cancelAction);
- this.filters = filters;
-}
- </script>
- <Table>
- <row fill='vertical'>
- <cell anchor='west' fill='horizontal' weightx="2">
- <JLabel text='simexplorer.choose.import.label'/>
- </cell>
- <cell anchor='west'>
- <VBox>
- <JRadioButton id='selected' text='simexplorer.entities.applicationExploration' value='ApplicationExploration' buttonGroup='typeImport' onActionPerformed='filePath.setText(null)'/>
- <JRadioButton text='simexplorer.entities.library' value='Library' buttonGroup='typeImport' onActionPerformed='filePath.setText(null)'/>
- </VBox>
- </cell>
- </row>
- <row>
- <cell columns='2' weightx='1' fill='horizontal'>
- <Table>
- <row fill="both">
- <cell weightx='1' fill='both' insets='0,0,0,0'>
- <JTextField id='filePath' onCaretUpdate='check()' margin='0,0,0,0'/>
- </cell>
- <cell anchor='east' insets='0,2,0,0'>
- <JButton id='chooseDirectory' icon='{createImageIcon("fileChooser.png")}' onActionPerformed='chooseDir()' margin='0,0,0,0'/>
- </cell>
- </row>
- </Table>
- </cell>
- </row>
- <row fill='horizontal'>
- <cell columns='2'>
- <JPanel layout='{new GridLayout(1, 0, 2, 2)}'>
- <JButton id='ok' text='simexplorer.action.importElement' enabled='false' onActionPerformed='dispose();'/>
- <JButton id='cancel' text='simexplorer.common.cancel' action='{cancelAction}'/>
- </JPanel>
- </cell>
- </row>
- </Table>
-</JDialog>
Deleted: trunk/simexplorer-is/simexplorer-is-swing/src/uimodel/fr/cemagref/simexplorer/is/ui/swing/JDetailTab.jaxx
===================================================================
--- trunk/simexplorer-is/simexplorer-is-swing/src/uimodel/fr/cemagref/simexplorer/is/ui/swing/JDetailTab.jaxx 2008-02-20 18:42:03 UTC (rev 1140)
+++ trunk/simexplorer-is/simexplorer-is-swing/src/uimodel/fr/cemagref/simexplorer/is/ui/swing/JDetailTab.jaxx 2008-02-20 18:42:52 UTC (rev 1141)
@@ -1,140 +0,0 @@
-<JAXXTab>
- <style source="common.css"/>
- <row>
- <cell>
- <!--TODO imposer une taille minimum -->
- <Table id='toolbarNavigation' styleClass='border' insets='0,0,0,0'>
- <row>
- <cell anchor='west' insets='0,2,0,0' weightx="1" fill='horizontal' >
- <JLabel id='detailHeaderFromLocal' opaque='false' visible='false'
- text='simexplorer.node.navigation.local'
- icon='{createImageIcon("action/local.png")}'/>
- </cell>
- <cell anchor='west' insets='0,2,0,0' weightx="1" fill='horizontal' >
- <JLabel id='detailHeaderFromRemote' opaque='false'
- text='simexplorer.node.navigation.remote'
- visible='false' icon='{createImageIcon("action/remote.png")}'/>
- </cell>
- <cell anchor="east" insets='0,0,0,0'>
- <JToolBar>
- <JButton id='historyPrevious'/>
- <JButton id='historyNext'/>
- <JButton id='collapseAllDetail'/>
- <JButton id='expandAllDetail'/>
- </JToolBar>
- </cell>
- </row>
- </Table>
- </cell>
- </row>
- <row>
- <cell>
- <Table id='toolbarDetail' styleClass='border' background='{Color.WHITE}' insets='0,0,0,0'>
- <row>
- <cell anchor='west' fill="vertical">
- <JToolBar>
- <JButton id='detailToTree'/>
- </JToolBar>
- </cell>
- <cell weightx="1" fill='horizontal'>
- <JPanel opaque='false' >
- <JLabel id='detailHeader' opaque='false' />
- </JPanel>
- </cell>
- <cell anchor="east">
- <JToolBar>
- <JComboBox id='detailVersions' model='{new DefaultComboBoxModel()}'/>
- <JButton id='showTab_synchronize'/>
- <JButton id='exportElement'/>
- <JButton id='downloadElement'/>
- <JButton id='deleteElement'/>
- </JToolBar>
- </cell>
- </row>
- </Table>
- </cell>
- </row>
- <row fill="both" weightx="1" weighty="1">
- <cell columns="2">
- <JSplitPane id='splitOne' orientation="horizontal" resizeWeight="0.45" oneTouchExpandable='true'>
- <JScrollPane columnHeaderView='{toolbarNavigation}'>
- <JTree id="navigationTree" model='{new javax.swing.tree.DefaultTreeModel(null)}' styleClass='smallSize'/>
- </JScrollPane>
- <JScrollPane id="scrollPane" columnHeaderView='{toolbarDetail}' border='{null}' horizontalScrollBarPolicy='horizontal_scrollbar_never' verticalScrollBarPolicy='vertical_scrollbar_never'>
- <Table id='detail' insets='2,2,2,1'>
- <row fill='vertical'>
- <cell anchor='west'>
- <JLabel text='simexplorer.common.type'/>
- </cell>
- <cell weightx="1" anchor='west'>
- <JLabel id='detailType'/>
- </cell>
- </row>
- <row fill='vertical'>
- <cell anchor='west'>
- <JLabel text='simexplorer.common.description'/>
- </cell>
- <cell fill='horizontal' weightx="2" anchor='west'>
- <JLabel id='detailDescription'/>
- </cell>
- </row>
- <row fill='vertical'>
- <cell anchor='west'>
- <JLabel text='simexplorer.common.creationDate'/>
- </cell>
- <cell anchor='west'>
- <JLabel id='detailCreationDate'/>
- </cell>
- </row>
- <row>
- <cell fill='horizontal' columns="2" insets='3,0,0,1'>
- <JPanel styleClass='border'>
- <JLabel id='detailDescriptorsHeader'/>
- </JPanel>
- </cell>
- </row>
- <row>
- <cell fill='horizontal' columns="2" insets='0,0,0,0'>
- <JScrollPane id='scrollTable' border='{null}' horizontalScrollBarPolicy='horizontal_scrollbar_as_needed' verticalScrollBarPolicy='vertical_scrollbar_as_needed'>
- <JTable id="detailTable" border='{null}' model='{new fr.cemagref.simexplorer.is.ui.swing.model.DetailTableModel()}' focusable='false' enabled='false' />
- </JScrollPane>
- </cell>
- </row>
- <row>
- <cell fill="horizontal" columns="2" insets='3,0,0,1' >
- <Table id='toolbarAttachment' styleClass='border' insets='0,0,0,0'>
- <row fill='both'>
- <cell weightx="1" fill='horizontal'>
- <JPanel opaque='false'>
- <JLabel id='detailAttachmentsHeader'/>
- </JPanel>
- </cell>
- <cell fill='horizontal' anchor="east">
- <JToolBar>
- <JButton id='downloadAttachment'/>
- </JToolBar>
- </cell>
- </row>
- </Table>
- </cell>
- </row>
- <row>
- <cell fill='horizontal' columns="2" insets='0,0,0,0'>
- <JScrollPane id='scrollAttachments' horizontalScrollBarPolicy='horizontal_scrollbar_as_needed' verticalScrollBarPolicy='vertical_scrollbar_as_needed'>
- <JList id="detailAttachments" model='{new DefaultListModel()}' selectionMode='0'/>
- </JScrollPane>
- </cell>
- </row>
- <row weighty="1" weightx="2">
- <cell fill='both'>
- <JPanel>
- <JLabel text=''/>
- </JPanel>
- </cell>
- </row>
- </Table>
- </JScrollPane>
- </JSplitPane>
- </cell>
- </row>
-</JAXXTab>
Deleted: trunk/simexplorer-is/simexplorer-is-swing/src/uimodel/fr/cemagref/simexplorer/is/ui/swing/JListTab.jaxx
===================================================================
--- trunk/simexplorer-is/simexplorer-is-swing/src/uimodel/fr/cemagref/simexplorer/is/ui/swing/JListTab.jaxx 2008-02-20 18:42:03 UTC (rev 1140)
+++ trunk/simexplorer-is/simexplorer-is-swing/src/uimodel/fr/cemagref/simexplorer/is/ui/swing/JListTab.jaxx 2008-02-20 18:42:52 UTC (rev 1141)
@@ -1,53 +0,0 @@
-<JAXXTab>
- <style source="common.css"/>
- <!-- la barre des actions de la liste -->
- <row>
- <cell fill='horizontal' insets='0,0,0,0'>
- <JPopupMenu id="tablePopupMenu" invoker='{table}' enabled='false'>
- <JMenuItem id='showTab_detail'/>
- <JMenuItem id='showTab_synchronize'/>
- <JMenuItem id='exportElement'/>
- <JMenuItem id='downloadElement'/>
- <JMenuItem id='deleteElement'/>
- </JPopupMenu>
- <JToolBar>
- <JButton id='importElement'/>
- <JButton id='resetSearch'/>
- <JTextField id='searchText' toolTipText='simexplorer.action.searchText.tooltip'/>
- <JButton id='search'/>
- <JButton id='advancedSearch'/>
- <JComboBox id='changeSizor' enabled='false' opaque='false' preferredSize='{new Dimension(50,5)}'>
- <item value='5'/>
- <item value='10'/>
- <item value='20'/>
- <item value='50'/>
- <item value='100'/>
- <item value='200'/>
- <item value='500'/>
- </JComboBox>
- </JToolBar>
- </cell>
- </row>
- <row fill='both' weightx='1' weighty='1'>
- <cell insets='0,0,0,0'>
- <JScrollPane>
- <JTable id='table' model='{new fr.cemagref.simexplorer.is.ui.swing.model.ListTableModel()}'/>
- </JScrollPane>
- </cell>
- </row>
- <!-- la barre de pagination de la liste -->
- <row>
- <cell anchor='center' insets='0,0,0,0'>
- <JToolBar>
- <JButton id='goFirstPage' enabled='{false}'/>
- <JButton id='goPreviousPage' enabled='{false}'/>
- <JPanel layout='{new GridLayout(0, 2, 0, 0)}'>
- <JLabel id='currentPage' text='simexplorer.action.currentPage' labelFor="{goPage}" font-size='9'/>
- <JComboBox id='goPage' enabled='false' font-size='9' opaque='false' preferredSize='{new Dimension(50,5)}'/>
- </JPanel>
- <JButton id='goNextPage'/>
- <JButton id='goLastPage'/>
- </JToolBar>
- </cell>
- </row>
-</JAXXTab>
Deleted: trunk/simexplorer-is/simexplorer-is-swing/src/uimodel/fr/cemagref/simexplorer/is/ui/swing/JSynchronizeTab.jaxx
===================================================================
--- trunk/simexplorer-is/simexplorer-is-swing/src/uimodel/fr/cemagref/simexplorer/is/ui/swing/JSynchronizeTab.jaxx 2008-02-20 18:42:03 UTC (rev 1140)
+++ trunk/simexplorer-is/simexplorer-is-swing/src/uimodel/fr/cemagref/simexplorer/is/ui/swing/JSynchronizeTab.jaxx 2008-02-20 18:42:52 UTC (rev 1141)
@@ -1,87 +0,0 @@
-<JAXXTab insets='0,0,0,0'>
- <style source="common.css"/>
- <script>
-public JTree getTree(boolean remote) {
- return remote ? treeRemote : treeLocal;
-}
-public AbstractButton getExpandButton(boolean remote) {
- return remote ? expandAllRemote : expandAllLocal;
-}
-public AbstractButton getCollapseButton(boolean remote) {
- return remote ? collapseAllRemote : collapseAllLocal;
-}
-public AbstractButton getExportButton(boolean remote) {
- return remote ? exportElementToLocal : exportElementToRemote;
-}
- </script>
- <row>
- <cell>
- <Table id='toolbarNavigationLocal' styleClass='border' insets='0,0,0,0'>
- <row>
- <cell insets='0,5,0,0' weightx="1" fill='horizontal'>
- <JLabel id='navigationHeaderLocal' icon='{createImageIcon("action/local.png")}' text='simexplorer.node.navigation.local'/>
- </cell>
- <cell anchor="east">
- <JToolBar>
- <JButton id='collapseAllLocal'/>
- <JButton id='expandAllLocal'/>
- </JToolBar>
- </cell>
- </row>
- </Table>
- </cell>
- </row>
- <row>
- <cell>
- <Table id='toolbarNavigationRemote' styleClass='border' insets='0,0,0,0'>
- <row>
- <cell insets='0,5,0,0' weightx="1" fill='horizontal'>
- <JLabel id='navigationHeaderRemote' icon='{createImageIcon("action/remote.png")}' text='simexplorer.node.navigation.remote'/>
- </cell>
- <cell anchor="east">
- <JToolBar>
- <JButton id='collapseAllRemote'/>
- <JButton id='expandAllRemote'/>
- </JToolBar>
- </cell>
- </row>
- </Table>
- </cell>
- </row>
- <row fill="both">
- <cell weightx="1" weighty="1">
- <JScrollPane columnHeaderView='{toolbarNavigationLocal}' horizontalScrollBarPolicy='horizontal_scrollbar_always' verticalScrollBarPolicy='vertical_scrollbar_always'>
- <JTree id='treeLocal' model='{new javax.swing.tree.DefaultTreeModel(null)}'/>
- </JScrollPane>
- </cell>
- <cell fill='vertical'>
- <Table>
- <row fill='both' weightx="1" weighty="1">
- <cell>
- <JPanel/>
- </cell>
- </row>
- <row>
- <cell>
- <JPanel>
- <JToolBar orientation='{JToolBar.VERTICAL}'>
- <JButton id='exportElementToRemote'/>
- <JButton id='exportElementToLocal'/>
- </JToolBar>
- </JPanel>
- </cell>
- </row>
- <row fill='both' weightx="1" weighty="1">
- <cell>
- <JPanel/>
- </cell>
- </row>
- </Table>
- </cell>
- <cell weightx="1" weighty="1">
- <JScrollPane columnHeaderView='{toolbarNavigationRemote}' horizontalScrollBarPolicy='horizontal_scrollbar_always' verticalScrollBarPolicy='vertical_scrollbar_always'>
- <JTree id='treeRemote' model='{new javax.swing.tree.DefaultTreeModel(null)}'/>
- </JScrollPane>
- </cell>
- </row>
-</JAXXTab>
Deleted: trunk/simexplorer-is/simexplorer-is-swing/src/uimodel/fr/cemagref/simexplorer/is/ui/swing/LoginUI.jaxx
===================================================================
--- trunk/simexplorer-is/simexplorer-is-swing/src/uimodel/fr/cemagref/simexplorer/is/ui/swing/LoginUI.jaxx 2008-02-20 18:42:03 UTC (rev 1140)
+++ trunk/simexplorer-is/simexplorer-is-swing/src/uimodel/fr/cemagref/simexplorer/is/ui/swing/LoginUI.jaxx 2008-02-20 18:42:52 UTC (rev 1141)
@@ -1,86 +0,0 @@
-<JDialog title='simexplorer.login.title' modal='true'>
- <script>
- public static abstract class LoginUIHandler {
-
- boolean cancel;
-
- LoginUI ui;
-
- protected abstract boolean connect(String login, char[] password);
-
- protected abstract boolean failedToConnect();
-
- public abstract void doConnect();
-
- public abstract void doCancel();
-
- protected void setUi(LoginUI ui) {
- this.ui = ui;
- }
-
- public void setCancel(boolean cancel) {
- this.cancel = cancel;
- }
-
- public boolean isCancel() {
- return cancel;
- }
- }
-
- protected LoginUIHandler handler;
-
- public boolean launch(String login) {
- if (login != null) {
- this.getLogin().setText(login);
- }
- setVisible(true);
- return !handler.cancel;
- }
-
- public LoginUI(JFrame instance, LoginUIHandler handler) {
- super(instance);
- this.handler = handler;
- this.handler.setUi(this);
- // block close operation
- setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
- }
-
- protected void doConnect() {
- handler.doConnect();
- if (handler.isCancel()) {
- doCancel();
- }
- }
-
- protected void doCancel() {
- handler.doCancel();
- dispose();
- }
- </script>
- <Table>
- <row fill='horizontal'>
- <cell>
- <JLabel text='simexplorer.common.login' labelFor='{login}'/>
- </cell>
- <cell>
- <JTextField id='login' onKeyReleased='ok.setEnabled(login.getText().trim().length()>0 && password.getPassword().length>0)'/>
- </cell>
- </row>
- <row fill='horizontal'>
- <cell>
- <JLabel text='simexplorer.common.passphrase' labelFor='{password}'/>
- </cell>
- <cell>
- <JPasswordField id='password' onKeyReleased='ok.setEnabled(login.getText().trim().length()>0 && password.getPassword().length>0)'/>
- </cell>
- </row>
- <row fill='horizontal'>
- <cell columns="2">
- <JPanel layout='{new GridLayout(0, 2, 2, 2)}'>
- <JButton id='ok' text='simexplorer.common.apply' onActionPerformed="doConnect()" enabled='false'/>
- <JButton text='simexplorer.common.cancel' onActionPerformed="doCancel()"/>
- </JPanel>
- </cell>
- </row>
- </Table>
-</JDialog>
Deleted: trunk/simexplorer-is/simexplorer-is-swing/src/uimodel/fr/cemagref/simexplorer/is/ui/swing/SimExplorerUI.jaxx
===================================================================
--- trunk/simexplorer-is/simexplorer-is-swing/src/uimodel/fr/cemagref/simexplorer/is/ui/swing/SimExplorerUI.jaxx 2008-02-20 18:42:03 UTC (rev 1140)
+++ trunk/simexplorer-is/simexplorer-is-swing/src/uimodel/fr/cemagref/simexplorer/is/ui/swing/SimExplorerUI.jaxx 2008-02-20 18:42:52 UTC (rev 1141)
@@ -1,63 +0,0 @@
-<JFrame name="mainFrame" title='simexplorer.main.ui.title'
- defaultCloseOperation='DISPOSE_ON_CLOSE' width='700' height='520'>
- <style source="/common.css"/>
- <script>
-public Action getConnectAction(boolean isConnected) {
- if (isConnected) {
- return getConnect().getAction();
- } else {
- return getUnconnect().getAction();
- }
-}
- </script><JMenuBar>
- <!-- menu principal -->
- <JMenu text='simexplorer.main.menu' mnemonic="{'M'}">
- <JMenuItem id="connect"/>
- <JMenuItem id="unconnect"/>
- <JSeparator/>
- <JMenuItem id="showTab_local" mnemonic="{'l'}"/>
- <JMenuItem id="showTab_remote"/>
- <JSeparator/>
- <JMenuItem id="quit"/>
- </JMenu>
- <!-- menu config -->
- <JMenu text='simexplorer.config.menu' mnemonic="{'C'}">
- <JMenu text='simexplorer.config.i18n.menu' mnemonic="{'L'}"
- icon='{createImageIcon("action/translate.png")}'>
- <JMenuItem id="i18n_fr_FR"/>
- <JMenuItem id="i18n_en_GB"/>
- </JMenu>
- <JMenuItem id="config"/>
- <JMenuItem id="resetPassword"/>
- </JMenu>
- <!-- menu aide -->
- <JMenu text='simexplorer.help.menu' mnemonic="{'e'}">
- <JMenuItem id="help"/>
- <JMenuItem id="site"/>
- <JMenuItem id="about"/>
- </JMenu>
- </JMenuBar>
- <Table insets='0,0,0,0'>
- <!-- la barre des actions générales -->
- <row>
- <cell fill="horizontal">
- <JToolBar borderPainted='true'>
- <jaxx.runtime.swing.JAXXToggleButton id='toggleTab_local'/>
- <jaxx.runtime.swing.JAXXToggleButton id='toggleTab_remote'/>
- </JToolBar>
- </cell>
- </row>
- <!-- le panel principal à surcharger selon le context -->
- <row fill="both" weightx="1" weighty="1">
- <cell>
- <JTabbedPane id="content"/>
- </cell>
- </row>
- <!-- la barre de status -->
- <row>
- <cell fill="both">
- <org.codelutin.widget.StatusBar id='statusBar'/>
- </cell>
- </row>
- </Table>
-</JFrame>
Deleted: trunk/simexplorer-is/simexplorer-is-swing/src/uimodel/fr/cemagref/simexplorer/is/ui/swing/common.css
===================================================================
--- trunk/simexplorer-is/simexplorer-is-swing/src/uimodel/fr/cemagref/simexplorer/is/ui/swing/common.css 2008-02-20 18:42:03 UTC (rev 1140)
+++ trunk/simexplorer-is/simexplorer-is-swing/src/uimodel/fr/cemagref/simexplorer/is/ui/swing/common.css 2008-02-20 18:42:52 UTC (rev 1141)
@@ -1,40 +0,0 @@
-JToolBar {
- floatable:false;
- focusable:false;
- opaque:false;
- margin:0;
- borderPainted:false;
-}
-
-JButton {
- opaque:false;
- borderPainted:false;
- enabled:false;
- margin:0;
-}
-
-JAXXToggleButton {
- enabled:false;
- focusPainted:false;
-}
-
-JMenuItem {
- enabled:false;
-}
-
-JMenu {
- enabled:true;
-}
-
-JComboBox{
- font-size:9;
-}
-
-.smallSize {
- font-size:9;
-}
-.border {
- border:{javax.swing.border.LineBorder.createBlackLineBorder()};
- height:22;
-}
-
Copied: trunk/simexplorer-is/simexplorer-is-swing/src/uimodel/fr/cemagref/simexplorer/is/ui/swing/ui/ImportDialog.jaxx (from rev 1132, trunk/simexplorer-is/simexplorer-is-swing/src/uimodel/fr/cemagref/simexplorer/is/ui/swing/ImportDialog.jaxx)
===================================================================
--- trunk/simexplorer-is/simexplorer-is-swing/src/uimodel/fr/cemagref/simexplorer/is/ui/swing/ui/ImportDialog.jaxx (rev 0)
+++ trunk/simexplorer-is/simexplorer-is-swing/src/uimodel/fr/cemagref/simexplorer/is/ui/swing/ui/ImportDialog.jaxx 2008-02-20 18:42:52 UTC (rev 1141)
@@ -0,0 +1,82 @@
+<JDialog>
+ <script>
+AbstractAction cancelAction = new AbstractAction(_("simexplorer.common.cancel")){
+ private static final long serialVersionUID = -4585698788717305452L;
+
+ public void actionPerformed(ActionEvent e) {
+ filePath.setText(null);
+ dispose();
+ }
+};
+
+public java.io.File getFile() {
+ setVisible(true);
+ if (filePath.getText().equals("")) {
+ return null;
+ }
+ java.io.File f= new java.io.File(filePath.getText());
+ filePath.setText(null);
+ return f;
+}
+
+private java.util.Map<String, String[]> filters;
+
+protected void chooseDir() {
+ String type = (String) getTypeImport().getSelectedValue();
+ String[] filter = this.filters.get(type);
+ File dir= org.codelutin.util.FileUtil.getFile(filter==null?null:filter);
+ if (dir!=null) {
+ filePath.setText(dir.toString());
+ }
+}
+protected void check() {
+ String t = filePath.getText();
+ java.io.File f = new File(t);
+ ok.setEnabled(!t.equals("") && f.exists() && f.isFile());
+}
+
+public ImportDialog(JFrame frame,java.util.Map<String,String[]> filters) {
+ super(frame,true);
+ JRootPane rootPane = getRootPane();
+ rootPane.setDefaultButton(ok);
+ rootPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("ESCAPE"),"cancel");
+ rootPane.getActionMap().put("cancel", cancelAction);
+ this.filters = filters;
+}
+ </script>
+ <Table>
+ <row fill='vertical'>
+ <cell anchor='west' fill='horizontal' weightx="2">
+ <JLabel text='simexplorer.choose.import.label'/>
+ </cell>
+ <cell anchor='west'>
+ <VBox>
+ <JRadioButton id='selected' text='simexplorer.entities.applicationExploration' value='ApplicationExploration' buttonGroup='typeImport' onActionPerformed='filePath.setText(null)'/>
+ <JRadioButton text='simexplorer.entities.library' value='Library' buttonGroup='typeImport' onActionPerformed='filePath.setText(null)'/>
+ </VBox>
+ </cell>
+ </row>
+ <row>
+ <cell columns='2' weightx='1' fill='horizontal'>
+ <Table>
+ <row fill="both">
+ <cell weightx='1' fill='both' insets='0,0,0,0'>
+ <JTextField id='filePath' onCaretUpdate='check()' margin='0,0,0,0'/>
+ </cell>
+ <cell anchor='east' insets='0,2,0,0'>
+ <JButton id='chooseDirectory' icon='{createImageIcon("fileChooser.png")}' onActionPerformed='chooseDir()' margin='0,0,0,0'/>
+ </cell>
+ </row>
+ </Table>
+ </cell>
+ </row>
+ <row fill='horizontal'>
+ <cell columns='2'>
+ <JPanel layout='{new GridLayout(1, 0, 2, 2)}'>
+ <JButton id='ok' text='simexplorer.action.importElement' enabled='false' onActionPerformed='dispose();'/>
+ <JButton id='cancel' text='simexplorer.common.cancel' action='{cancelAction}'/>
+ </JPanel>
+ </cell>
+ </row>
+ </Table>
+</JDialog>
Copied: trunk/simexplorer-is/simexplorer-is-swing/src/uimodel/fr/cemagref/simexplorer/is/ui/swing/ui/JDetailTab.jaxx (from rev 1132, trunk/simexplorer-is/simexplorer-is-swing/src/uimodel/fr/cemagref/simexplorer/is/ui/swing/JDetailTab.jaxx)
===================================================================
--- trunk/simexplorer-is/simexplorer-is-swing/src/uimodel/fr/cemagref/simexplorer/is/ui/swing/ui/JDetailTab.jaxx (rev 0)
+++ trunk/simexplorer-is/simexplorer-is-swing/src/uimodel/fr/cemagref/simexplorer/is/ui/swing/ui/JDetailTab.jaxx 2008-02-20 18:42:52 UTC (rev 1141)
@@ -0,0 +1,140 @@
+<JAXXTab>
+ <style source="common.css"/>
+ <row>
+ <cell>
+ <!--TODO imposer une taille minimum -->
+ <Table id='toolbarNavigation' styleClass='border' insets='0,0,0,0'>
+ <row>
+ <cell anchor='west' insets='0,2,0,0' weightx="1" fill='horizontal' >
+ <JLabel id='detailHeaderFromLocal' opaque='false' visible='false'
+ text='simexplorer.node.navigation.local'
+ icon='{createImageIcon("action/local.png")}'/>
+ </cell>
+ <cell anchor='west' insets='0,2,0,0' weightx="1" fill='horizontal' >
+ <JLabel id='detailHeaderFromRemote' opaque='false'
+ text='simexplorer.node.navigation.remote'
+ visible='false' icon='{createImageIcon("action/remote.png")}'/>
+ </cell>
+ <cell anchor="east" insets='0,0,0,0'>
+ <JToolBar>
+ <JButton id='historyPrevious'/>
+ <JButton id='historyNext'/>
+ <JButton id='collapseAllDetail'/>
+ <JButton id='expandAllDetail'/>
+ </JToolBar>
+ </cell>
+ </row>
+ </Table>
+ </cell>
+ </row>
+ <row>
+ <cell>
+ <Table id='toolbarDetail' styleClass='border' background='{Color.WHITE}' insets='0,0,0,0'>
+ <row>
+ <cell anchor='west' fill="vertical">
+ <JToolBar>
+ <JButton id='detailToTree'/>
+ </JToolBar>
+ </cell>
+ <cell weightx="1" fill='horizontal'>
+ <JPanel opaque='false' >
+ <JLabel id='detailHeader' opaque='false' />
+ </JPanel>
+ </cell>
+ <cell anchor="east">
+ <JToolBar>
+ <JComboBox id='detailVersions' model='{new DefaultComboBoxModel()}'/>
+ <JButton id='showTab_synchronize'/>
+ <JButton id='exportElement'/>
+ <JButton id='downloadElement'/>
+ <JButton id='deleteElement'/>
+ </JToolBar>
+ </cell>
+ </row>
+ </Table>
+ </cell>
+ </row>
+ <row fill="both" weightx="1" weighty="1">
+ <cell columns="2">
+ <JSplitPane id='splitOne' orientation="horizontal" resizeWeight="0.45" oneTouchExpandable='true'>
+ <JScrollPane columnHeaderView='{toolbarNavigation}'>
+ <JTree id="navigationTree" model='{new javax.swing.tree.DefaultTreeModel(null)}' styleClass='smallSize'/>
+ </JScrollPane>
+ <JScrollPane id="scrollPane" columnHeaderView='{toolbarDetail}' border='{null}' horizontalScrollBarPolicy='horizontal_scrollbar_never' verticalScrollBarPolicy='vertical_scrollbar_never'>
+ <Table id='detail' insets='2,2,2,1'>
+ <row fill='vertical'>
+ <cell anchor='west'>
+ <JLabel text='simexplorer.common.type'/>
+ </cell>
+ <cell weightx="1" anchor='west'>
+ <JLabel id='detailType'/>
+ </cell>
+ </row>
+ <row fill='vertical'>
+ <cell anchor='west'>
+ <JLabel text='simexplorer.common.description'/>
+ </cell>
+ <cell fill='horizontal' weightx="2" anchor='west'>
+ <JLabel id='detailDescription'/>
+ </cell>
+ </row>
+ <row fill='vertical'>
+ <cell anchor='west'>
+ <JLabel text='simexplorer.common.creationDate'/>
+ </cell>
+ <cell anchor='west'>
+ <JLabel id='detailCreationDate'/>
+ </cell>
+ </row>
+ <row>
+ <cell fill='horizontal' columns="2" insets='3,0,0,1'>
+ <JPanel styleClass='border'>
+ <JLabel id='detailDescriptorsHeader'/>
+ </JPanel>
+ </cell>
+ </row>
+ <row>
+ <cell fill='horizontal' columns="2" insets='0,0,0,0'>
+ <JScrollPane id='scrollTable' border='{null}' horizontalScrollBarPolicy='horizontal_scrollbar_as_needed' verticalScrollBarPolicy='vertical_scrollbar_as_needed'>
+ <JTable id="detailTable" border='{null}' model='{new fr.cemagref.simexplorer.is.ui.swing.model.DetailTableModel()}' focusable='false' enabled='false' />
+ </JScrollPane>
+ </cell>
+ </row>
+ <row>
+ <cell fill="horizontal" columns="2" insets='3,0,0,1' >
+ <Table id='toolbarAttachment' styleClass='border' insets='0,0,0,0'>
+ <row fill='both'>
+ <cell weightx="1" fill='horizontal'>
+ <JPanel opaque='false'>
+ <JLabel id='detailAttachmentsHeader'/>
+ </JPanel>
+ </cell>
+ <cell fill='horizontal' anchor="east">
+ <JToolBar>
+ <JButton id='downloadAttachment'/>
+ </JToolBar>
+ </cell>
+ </row>
+ </Table>
+ </cell>
+ </row>
+ <row>
+ <cell fill='horizontal' columns="2" insets='0,0,0,0'>
+ <JScrollPane id='scrollAttachments' horizontalScrollBarPolicy='horizontal_scrollbar_as_needed' verticalScrollBarPolicy='vertical_scrollbar_as_needed'>
+ <JList id="detailAttachments" model='{new DefaultListModel()}' selectionMode='0'/>
+ </JScrollPane>
+ </cell>
+ </row>
+ <row weighty="1" weightx="2">
+ <cell fill='both'>
+ <JPanel>
+ <JLabel text=''/>
+ </JPanel>
+ </cell>
+ </row>
+ </Table>
+ </JScrollPane>
+ </JSplitPane>
+ </cell>
+ </row>
+</JAXXTab>
Copied: trunk/simexplorer-is/simexplorer-is-swing/src/uimodel/fr/cemagref/simexplorer/is/ui/swing/ui/JListTab.jaxx (from rev 1132, trunk/simexplorer-is/simexplorer-is-swing/src/uimodel/fr/cemagref/simexplorer/is/ui/swing/JListTab.jaxx)
===================================================================
--- trunk/simexplorer-is/simexplorer-is-swing/src/uimodel/fr/cemagref/simexplorer/is/ui/swing/ui/JListTab.jaxx (rev 0)
+++ trunk/simexplorer-is/simexplorer-is-swing/src/uimodel/fr/cemagref/simexplorer/is/ui/swing/ui/JListTab.jaxx 2008-02-20 18:42:52 UTC (rev 1141)
@@ -0,0 +1,53 @@
+<JAXXTab>
+ <style source="common.css"/>
+ <!-- la barre des actions de la liste -->
+ <row>
+ <cell fill='horizontal' insets='0,0,0,0'>
+ <JPopupMenu id="tablePopupMenu" invoker='{table}' enabled='false'>
+ <JMenuItem id='showTab_detail'/>
+ <JMenuItem id='showTab_synchronize'/>
+ <JMenuItem id='exportElement'/>
+ <JMenuItem id='downloadElement'/>
+ <JMenuItem id='deleteElement'/>
+ </JPopupMenu>
+ <JToolBar>
+ <JButton id='importElement'/>
+ <JButton id='resetSearch'/>
+ <JTextField id='searchText' toolTipText='simexplorer.action.searchText.tooltip'/>
+ <JButton id='search'/>
+ <JButton id='advancedSearch'/>
+ <JComboBox id='changeSizor' enabled='false' opaque='false' preferredSize='{new Dimension(50,5)}'>
+ <item value='5'/>
+ <item value='10'/>
+ <item value='20'/>
+ <item value='50'/>
+ <item value='100'/>
+ <item value='200'/>
+ <item value='500'/>
+ </JComboBox>
+ </JToolBar>
+ </cell>
+ </row>
+ <row fill='both' weightx='1' weighty='1'>
+ <cell insets='0,0,0,0'>
+ <JScrollPane>
+ <JTable id='table' model='{new fr.cemagref.simexplorer.is.ui.swing.model.ListTableModel()}'/>
+ </JScrollPane>
+ </cell>
+ </row>
+ <!-- la barre de pagination de la liste -->
+ <row>
+ <cell anchor='center' insets='0,0,0,0'>
+ <JToolBar>
+ <JButton id='goFirstPage' enabled='{false}'/>
+ <JButton id='goPreviousPage' enabled='{false}'/>
+ <JPanel layout='{new GridLayout(0, 2, 0, 0)}'>
+ <JLabel id='currentPage' text='simexplorer.action.currentPage' labelFor="{goPage}" font-size='9'/>
+ <JComboBox id='goPage' enabled='false' font-size='9' opaque='false' preferredSize='{new Dimension(50,5)}'/>
+ </JPanel>
+ <JButton id='goNextPage'/>
+ <JButton id='goLastPage'/>
+ </JToolBar>
+ </cell>
+ </row>
+</JAXXTab>
Copied: trunk/simexplorer-is/simexplorer-is-swing/src/uimodel/fr/cemagref/simexplorer/is/ui/swing/ui/JSynchronizeTab.jaxx (from rev 1134, trunk/simexplorer-is/simexplorer-is-swing/src/uimodel/fr/cemagref/simexplorer/is/ui/swing/JSynchronizeTab.jaxx)
===================================================================
--- trunk/simexplorer-is/simexplorer-is-swing/src/uimodel/fr/cemagref/simexplorer/is/ui/swing/ui/JSynchronizeTab.jaxx (rev 0)
+++ trunk/simexplorer-is/simexplorer-is-swing/src/uimodel/fr/cemagref/simexplorer/is/ui/swing/ui/JSynchronizeTab.jaxx 2008-02-20 18:42:52 UTC (rev 1141)
@@ -0,0 +1,87 @@
+<JAXXTab insets='0,0,0,0'>
+ <style source="common.css"/>
+ <script>
+public JTree getTree(boolean remote) {
+ return remote ? treeRemote : treeLocal;
+}
+public AbstractButton getExpandButton(boolean remote) {
+ return remote ? expandAllRemote : expandAllLocal;
+}
+public AbstractButton getCollapseButton(boolean remote) {
+ return remote ? collapseAllRemote : collapseAllLocal;
+}
+public AbstractButton getExportButton(boolean remote) {
+ return remote ? exportElementToLocal : exportElementToRemote;
+}
+ </script>
+ <row>
+ <cell>
+ <Table id='toolbarNavigationLocal' styleClass='border' insets='0,0,0,0'>
+ <row>
+ <cell insets='0,5,0,0' weightx="1" fill='horizontal'>
+ <JLabel id='navigationHeaderLocal' icon='{createImageIcon("action/local.png")}' text='simexplorer.node.navigation.local'/>
+ </cell>
+ <cell anchor="east">
+ <JToolBar>
+ <JButton id='collapseAllLocal'/>
+ <JButton id='expandAllLocal'/>
+ </JToolBar>
+ </cell>
+ </row>
+ </Table>
+ </cell>
+ </row>
+ <row>
+ <cell>
+ <Table id='toolbarNavigationRemote' styleClass='border' insets='0,0,0,0'>
+ <row>
+ <cell insets='0,5,0,0' weightx="1" fill='horizontal'>
+ <JLabel id='navigationHeaderRemote' icon='{createImageIcon("action/remote.png")}' text='simexplorer.node.navigation.remote'/>
+ </cell>
+ <cell anchor="east">
+ <JToolBar>
+ <JButton id='collapseAllRemote'/>
+ <JButton id='expandAllRemote'/>
+ </JToolBar>
+ </cell>
+ </row>
+ </Table>
+ </cell>
+ </row>
+ <row fill="both">
+ <cell weightx="1" weighty="1">
+ <JScrollPane columnHeaderView='{toolbarNavigationLocal}' horizontalScrollBarPolicy='horizontal_scrollbar_always' verticalScrollBarPolicy='vertical_scrollbar_always'>
+ <JTree id='treeLocal' model='{new javax.swing.tree.DefaultTreeModel(null)}'/>
+ </JScrollPane>
+ </cell>
+ <cell fill='vertical'>
+ <Table>
+ <row fill='both' weightx="1" weighty="1">
+ <cell>
+ <JPanel/>
+ </cell>
+ </row>
+ <row>
+ <cell>
+ <JPanel>
+ <JToolBar orientation='{JToolBar.VERTICAL}'>
+ <JButton id='exportElementToRemote'/>
+ <JButton id='exportElementToLocal'/>
+ </JToolBar>
+ </JPanel>
+ </cell>
+ </row>
+ <row fill='both' weightx="1" weighty="1">
+ <cell>
+ <JPanel/>
+ </cell>
+ </row>
+ </Table>
+ </cell>
+ <cell weightx="1" weighty="1">
+ <JScrollPane columnHeaderView='{toolbarNavigationRemote}' horizontalScrollBarPolicy='horizontal_scrollbar_always' verticalScrollBarPolicy='vertical_scrollbar_always'>
+ <JTree id='treeRemote' model='{new javax.swing.tree.DefaultTreeModel(null)}'/>
+ </JScrollPane>
+ </cell>
+ </row>
+</JAXXTab>
Copied: trunk/simexplorer-is/simexplorer-is-swing/src/uimodel/fr/cemagref/simexplorer/is/ui/swing/ui/LoginUI.jaxx (from rev 1132, trunk/simexplorer-is/simexplorer-is-swing/src/uimodel/fr/cemagref/simexplorer/is/ui/swing/LoginUI.jaxx)
===================================================================
--- trunk/simexplorer-is/simexplorer-is-swing/src/uimodel/fr/cemagref/simexplorer/is/ui/swing/ui/LoginUI.jaxx (rev 0)
+++ trunk/simexplorer-is/simexplorer-is-swing/src/uimodel/fr/cemagref/simexplorer/is/ui/swing/ui/LoginUI.jaxx 2008-02-20 18:42:52 UTC (rev 1141)
@@ -0,0 +1,86 @@
+<JDialog title='simexplorer.login.title' modal='true'>
+ <script>
+ public static abstract class LoginUIHandler {
+
+ boolean cancel;
+
+ LoginUI ui;
+
+ protected abstract boolean connect(String login, char[] password);
+
+ protected abstract boolean failedToConnect();
+
+ public abstract void doConnect();
+
+ public abstract void doCancel();
+
+ protected void setUi(LoginUI ui) {
+ this.ui = ui;
+ }
+
+ public void setCancel(boolean cancel) {
+ this.cancel = cancel;
+ }
+
+ public boolean isCancel() {
+ return cancel;
+ }
+ }
+
+ protected LoginUIHandler handler;
+
+ public boolean launch(String login) {
+ if (login != null) {
+ this.getLogin().setText(login);
+ }
+ setVisible(true);
+ return !handler.cancel;
+ }
+
+ public LoginUI(JFrame instance, LoginUIHandler handler) {
+ super(instance);
+ this.handler = handler;
+ this.handler.setUi(this);
+ // block close operation
+ setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
+ }
+
+ protected void doConnect() {
+ handler.doConnect();
+ if (handler.isCancel()) {
+ doCancel();
+ }
+ }
+
+ protected void doCancel() {
+ handler.doCancel();
+ dispose();
+ }
+ </script>
+ <Table>
+ <row fill='horizontal'>
+ <cell>
+ <JLabel text='simexplorer.common.login' labelFor='{login}'/>
+ </cell>
+ <cell>
+ <JTextField id='login' onKeyReleased='ok.setEnabled(login.getText().trim().length()>0 && password.getPassword().length>0)'/>
+ </cell>
+ </row>
+ <row fill='horizontal'>
+ <cell>
+ <JLabel text='simexplorer.common.passphrase' labelFor='{password}'/>
+ </cell>
+ <cell>
+ <JPasswordField id='password' onKeyReleased='ok.setEnabled(login.getText().trim().length()>0 && password.getPassword().length>0)'/>
+ </cell>
+ </row>
+ <row fill='horizontal'>
+ <cell columns="2">
+ <JPanel layout='{new GridLayout(0, 2, 2, 2)}'>
+ <JButton id='ok' text='simexplorer.common.apply' onActionPerformed="doConnect()" enabled='false'/>
+ <JButton text='simexplorer.common.cancel' onActionPerformed="doCancel()"/>
+ </JPanel>
+ </cell>
+ </row>
+ </Table>
+</JDialog>
Copied: trunk/simexplorer-is/simexplorer-is-swing/src/uimodel/fr/cemagref/simexplorer/is/ui/swing/ui/SimExplorerUI.jaxx (from rev 1140, trunk/simexplorer-is/simexplorer-is-swing/src/uimodel/fr/cemagref/simexplorer/is/ui/swing/SimExplorerUI.jaxx)
===================================================================
--- trunk/simexplorer-is/simexplorer-is-swing/src/uimodel/fr/cemagref/simexplorer/is/ui/swing/ui/SimExplorerUI.jaxx (rev 0)
+++ trunk/simexplorer-is/simexplorer-is-swing/src/uimodel/fr/cemagref/simexplorer/is/ui/swing/ui/SimExplorerUI.jaxx 2008-02-20 18:42:52 UTC (rev 1141)
@@ -0,0 +1,63 @@
+<JFrame name="mainFrame" title='simexplorer.main.ui.title'
+ defaultCloseOperation='DISPOSE_ON_CLOSE' width='700' height='520'>
+ <style source="/common.css"/>
+ <script>
+public Action getConnectAction(boolean isConnected) {
+ if (isConnected) {
+ return getConnect().getAction();
+ } else {
+ return getUnconnect().getAction();
+ }
+}
+ </script><JMenuBar>
+ <!-- menu principal -->
+ <JMenu text='simexplorer.main.menu' mnemonic="{'M'}">
+ <JMenuItem id="connect"/>
+ <JMenuItem id="unconnect"/>
+ <JSeparator/>
+ <JMenuItem id="showTab_local" mnemonic="{'l'}"/>
+ <JMenuItem id="showTab_remote"/>
+ <JSeparator/>
+ <JMenuItem id="quit"/>
+ </JMenu>
+ <!-- menu config -->
+ <JMenu text='simexplorer.config.menu' mnemonic="{'C'}">
+ <JMenu text='simexplorer.config.i18n.menu' mnemonic="{'L'}"
+ icon='{createImageIcon("action/translate.png")}'>
+ <JMenuItem id="i18n_fr_FR"/>
+ <JMenuItem id="i18n_en_GB"/>
+ </JMenu>
+ <JMenuItem id="config"/>
+ <JMenuItem id="resetPassword"/>
+ </JMenu>
+ <!-- menu aide -->
+ <JMenu text='simexplorer.help.menu' mnemonic="{'e'}">
+ <JMenuItem id="help"/>
+ <JMenuItem id="site"/>
+ <JMenuItem id="about"/>
+ </JMenu>
+ </JMenuBar>
+ <Table insets='0,0,0,0'>
+ <!-- la barre des actions générales -->
+ <row>
+ <cell fill="horizontal">
+ <JToolBar borderPainted='true'>
+ <jaxx.runtime.swing.JAXXToggleButton id='toggleTab_local'/>
+ <jaxx.runtime.swing.JAXXToggleButton id='toggleTab_remote'/>
+ </JToolBar>
+ </cell>
+ </row>
+ <!-- le panel principal à surcharger selon le context -->
+ <row fill="both" weightx="1" weighty="1">
+ <cell>
+ <JTabbedPane id="content"/>
+ </cell>
+ </row>
+ <!-- la barre de status -->
+ <row>
+ <cell fill="both">
+ <org.codelutin.widget.StatusBar id='statusBar'/>
+ </cell>
+ </row>
+ </Table>
+</JFrame>
Copied: trunk/simexplorer-is/simexplorer-is-swing/src/uimodel/fr/cemagref/simexplorer/is/ui/swing/ui/common.css (from rev 1132, trunk/simexplorer-is/simexplorer-is-swing/src/uimodel/fr/cemagref/simexplorer/is/ui/swing/common.css)
===================================================================
--- trunk/simexplorer-is/simexplorer-is-swing/src/uimodel/fr/cemagref/simexplorer/is/ui/swing/ui/common.css (rev 0)
+++ trunk/simexplorer-is/simexplorer-is-swing/src/uimodel/fr/cemagref/simexplorer/is/ui/swing/ui/common.css 2008-02-20 18:42:52 UTC (rev 1141)
@@ -0,0 +1,40 @@
+JToolBar {
+ floatable:false;
+ focusable:false;
+ opaque:false;
+ margin:0;
+ borderPainted:false;
+}
+
+JButton {
+ opaque:false;
+ borderPainted:false;
+ enabled:false;
+ margin:0;
+}
+
+JAXXToggleButton {
+ enabled:false;
+ focusPainted:false;
+}
+
+JMenuItem {
+ enabled:false;
+}
+
+JMenu {
+ enabled:true;
+}
+
+JComboBox{
+ font-size:9;
+}
+
+.smallSize {
+ font-size:9;
+}
+.border {
+ border:{javax.swing.border.LineBorder.createBlackLineBorder()};
+ height:22;
+}
+
1
0
r1140 - in trunk/simexplorer-is/simexplorer-is-swing/src/uimodel/fr/cemagref/simexplorer/is/ui/swing: . util
by tchemit@users.labs.libre-entreprise.org 20 Feb '08
by tchemit@users.labs.libre-entreprise.org 20 Feb '08
20 Feb '08
Author: tchemit
Date: 2008-02-20 18:42:03 +0000 (Wed, 20 Feb 2008)
New Revision: 1140
Modified:
trunk/simexplorer-is/simexplorer-is-swing/src/uimodel/fr/cemagref/simexplorer/is/ui/swing/SimExplorerUI.jaxx
trunk/simexplorer-is/simexplorer-is-swing/src/uimodel/fr/cemagref/simexplorer/is/ui/swing/util/ErrorDialog.jaxx
Log:
add simple usefull methods
Modified: trunk/simexplorer-is/simexplorer-is-swing/src/uimodel/fr/cemagref/simexplorer/is/ui/swing/SimExplorerUI.jaxx
===================================================================
--- trunk/simexplorer-is/simexplorer-is-swing/src/uimodel/fr/cemagref/simexplorer/is/ui/swing/SimExplorerUI.jaxx 2008-02-20 14:50:20 UTC (rev 1139)
+++ trunk/simexplorer-is/simexplorer-is-swing/src/uimodel/fr/cemagref/simexplorer/is/ui/swing/SimExplorerUI.jaxx 2008-02-20 18:42:03 UTC (rev 1140)
@@ -1,7 +1,15 @@
<JFrame name="mainFrame" title='simexplorer.main.ui.title'
defaultCloseOperation='DISPOSE_ON_CLOSE' width='700' height='520'>
<style source="/common.css"/>
- <JMenuBar>
+ <script>
+public Action getConnectAction(boolean isConnected) {
+ if (isConnected) {
+ return getConnect().getAction();
+ } else {
+ return getUnconnect().getAction();
+ }
+}
+ </script><JMenuBar>
<!-- menu principal -->
<JMenu text='simexplorer.main.menu' mnemonic="{'M'}">
<JMenuItem id="connect"/>
Modified: trunk/simexplorer-is/simexplorer-is-swing/src/uimodel/fr/cemagref/simexplorer/is/ui/swing/util/ErrorDialog.jaxx
===================================================================
--- trunk/simexplorer-is/simexplorer-is-swing/src/uimodel/fr/cemagref/simexplorer/is/ui/swing/util/ErrorDialog.jaxx 2008-02-20 14:50:20 UTC (rev 1139)
+++ trunk/simexplorer-is/simexplorer-is-swing/src/uimodel/fr/cemagref/simexplorer/is/ui/swing/util/ErrorDialog.jaxx 2008-02-20 18:42:03 UTC (rev 1140)
@@ -1,9 +1,28 @@
<JDialog title='simexplorer.error.dialog.title'>
<script>
- JRootPane rootPane = getRootPane();
- rootPane.setDefaultButton(close);
- rootPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("ESCAPE"), "close");
- rootPane.getActionMap().put("close", close.getAction());
+
+/** le dialogue pour afficher les erreurs */
+protected static ErrorDialog instance;
+
+public static void showError(Exception e) {
+ if (instance == null) {
+ instance = new ErrorDialog();
+ }
+ instance.getErrorMessage().setText(e.getMessage());
+ StringWriter w = new StringWriter();
+ e.printStackTrace(new PrintWriter(w));
+ instance.getErrorStack().setText(w.toString());
+ instance.getErrorStack().setCaretPosition(0);
+ instance.pack();
+ instance.setVisible(true);
+}
+public static void disposeUI() {
+ instance=null;
+}
+JRootPane rootPane = getRootPane();
+rootPane.setDefaultButton(close);
+rootPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("ESCAPE"), "close");
+rootPane.getActionMap().put("close", close.getAction());
</script>
<Table>
<row fill='both'>
1
0
r1139 - trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions
by tchemit@users.labs.libre-entreprise.org 20 Feb '08
by tchemit@users.labs.libre-entreprise.org 20 Feb '08
20 Feb '08
Author: tchemit
Date: 2008-02-20 14:50:20 +0000 (Wed, 20 Feb 2008)
New Revision: 1139
Modified:
trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/DeleteElementAction.java
Log:
refactoring
Modified: trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/DeleteElementAction.java
===================================================================
--- trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/DeleteElementAction.java 2008-02-20 14:37:27 UTC (rev 1138)
+++ trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/DeleteElementAction.java 2008-02-20 14:50:20 UTC (rev 1139)
@@ -21,7 +21,6 @@
import fr.cemagref.simexplorer.is.entities.data.LoggableElement;
import fr.cemagref.simexplorer.is.ui.StorageServiceHelper;
import fr.cemagref.simexplorer.is.ui.swing.JListTab;
-import fr.cemagref.simexplorer.is.ui.swing.JSynchronizeTab;
import fr.cemagref.simexplorer.is.ui.swing.SimExplorerActionManager;
import fr.cemagref.simexplorer.is.ui.swing.SimExplorerTab;
import fr.cemagref.simexplorer.is.ui.swing.SynchronizeTabRefreshHelper;
@@ -100,14 +99,15 @@
@Override
public void updateUI() {
- // on doit invalider les données apres un export
updateListTab();
// update detail model (delegue a l'action d'historique)
- // update synchronize model
- updateSynchronizeTab();
+ if (SimExplorerTab.synchronize.isTabVisible(getTabContainer())) {
+ updateSynchronizeTab();
+ }
+
}
protected void updateListTab() {
@@ -131,49 +131,20 @@
}
protected void updateSynchronizeTab() {
- SimExplorerTab tab;
- tab = SimExplorerTab.synchronize;
- if (!tab.isTabVisible(getTabContainer())) {
- // nothing to do
- return;
- }
- JSynchronizeTab ui = (JSynchronizeTab) tab.getUI();
+ SimExplorerTab tab = SimExplorerTab.synchronize;
+
SynchronizeTabModel model = (SynchronizeTabModel) tab.getModel();
-
- LoggableElement oldSource = model.getSource();
- LoggableElement oldDestination = model.getDestination();
+
+ LoggableElement oldLocalRoot = model.getRootNode(false);
+ LoggableElement oldRemoteRoot = model.getRootNode(true);
+
LoggableElement item;
- boolean modelIsRemote = model.isRemote();
- if (selected.isRemote()) {
- // selected is remote
- item = modelIsRemote ? model.getSource() : model.getDestination();
- if (item != null && item.getMetaData().getUuid() != null && item.getMetaData().getUuid().equals(selected.getUuid())) {
- if (modelIsRemote) {
- model.setSource(null);
- } else {
- model.setDestination(null);
- }
- }
- } else {
- // selected is local
- item = modelIsRemote ? model.getDestination() : model.getSource();
- if (item != null && item.getMetaData().getUuid() != null && item.getMetaData().getUuid().equals(selected.getUuid())) {
- if (modelIsRemote) {
- model.setDestination(null);
- } else {
- model.setSource(null);
- }
- }
+ boolean modelIsRemote = selected.isRemote();
+ item = model.getRootNode(modelIsRemote);
+ if (item != null && item.getMetaData().getUuid() != null && item.getMetaData().getUuid().equals(selected.getUuid())) {
+ model.setRootNode(null, modelIsRemote);
}
- if (model.getSource() == null && model.getDestination() == null) {
- // on doit supprimer la vue
- tab.closeTab(getTabContainer());
- }
-
- if (model.getSource() != oldSource || model.getDestination() != oldDestination) {
- // rebuild node ?
- SynchronizeTabRefreshHelper.refreshRootNodes(ui, model);
- }
+ SynchronizeTabRefreshHelper.updateTree(getTabContainer(), oldLocalRoot, oldRemoteRoot);
}
@Override
1
0
r1138 - in trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions: . util
by tchemit@users.labs.libre-entreprise.org 20 Feb '08
by tchemit@users.labs.libre-entreprise.org 20 Feb '08
20 Feb '08
Author: tchemit
Date: 2008-02-20 14:37:27 +0000 (Wed, 20 Feb 2008)
New Revision: 1138
Modified:
trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/CollapseAllAction.java
trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/ExpandAllAction.java
trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/util/SimExplorerAbstractTabAction.java
Log:
refactoring
Modified: trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/CollapseAllAction.java
===================================================================
--- trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/CollapseAllAction.java 2008-02-20 13:51:45 UTC (rev 1137)
+++ trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/CollapseAllAction.java 2008-02-20 14:37:27 UTC (rev 1138)
@@ -19,8 +19,6 @@
package fr.cemagref.simexplorer.is.ui.swing.actions;
import fr.cemagref.simexplorer.is.ui.swing.EntityTreeNodeHelper;
-import fr.cemagref.simexplorer.is.ui.swing.JDetailTab;
-import fr.cemagref.simexplorer.is.ui.swing.JSynchronizeTab;
import fr.cemagref.simexplorer.is.ui.swing.actions.util.SimExplorerAbstractTabAction;
import fr.cemagref.simexplorer.is.ui.swing.model.EntityTreeNode;
@@ -61,26 +59,10 @@
if (!super.beforeAction(e)) {
return false;
}
- String actionName = getActionName();
- // on retrouve l'arbre concerné à partir du nom de l'action
- if ("collapseAllDetail".equals(actionName)) {
- JDetailTab ui = (JDetailTab) getUI();
- tree = ui.getNavigationTree();
- } else if ("collapseAllLocal".equals(actionName)) {
- JSynchronizeTab ui = (JSynchronizeTab) getUI();
- tree = ui.getTree(false);
- } else if ("collapseAllRemote".equals(actionName)) {
- JSynchronizeTab ui = (JSynchronizeTab) getUI();
- tree = ui.getTree(true);
- }
- if (tree == null) {
- // arbre non trouvé (cela devrait souleve une exception !)
- return false;
- }
- node = EntityTreeNodeHelper.getSelectedNodeOrRootNode(tree);
- boolean result;
- result = !(node == null || node.isLeaf());
- return result;
+
+ tree = getTreeForAction("collapseAll", getActionName());
+ node = EntityTreeNodeHelper.getSelectedNodeOrRootNode(tree);
+ return !(node == null || node.isLeaf());
}
@Override
@@ -90,7 +72,6 @@
@Override
public void updateUI() {
- super.updateUI();
tree.invalidate();
getMainUI().repaint();
}
Modified: trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/ExpandAllAction.java
===================================================================
--- trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/ExpandAllAction.java 2008-02-20 13:51:45 UTC (rev 1137)
+++ trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/ExpandAllAction.java 2008-02-20 14:37:27 UTC (rev 1138)
@@ -19,8 +19,6 @@
package fr.cemagref.simexplorer.is.ui.swing.actions;
import fr.cemagref.simexplorer.is.ui.swing.EntityTreeNodeHelper;
-import fr.cemagref.simexplorer.is.ui.swing.JDetailTab;
-import fr.cemagref.simexplorer.is.ui.swing.JSynchronizeTab;
import fr.cemagref.simexplorer.is.ui.swing.actions.util.SimExplorerAbstractTabAction;
import fr.cemagref.simexplorer.is.ui.swing.model.EntityTreeNode;
@@ -62,27 +60,9 @@
if (!super.beforeAction(e)) {
return false;
}
- String actionName = getActionName();
- // on retrouve l'arbre concerné à partir du nom de l'action
- if ("expandAllDetail".equals(actionName)) {
- JDetailTab ui = (JDetailTab) getUI();
- tree = ui.getNavigationTree();
- } else if ("expandAllLocal".equals(actionName)) {
- JSynchronizeTab ui = (JSynchronizeTab) getUI();
- tree = ui.getTree(false);
- } else if ("expandAllRemote".equals(actionName)) {
- JSynchronizeTab ui = (JSynchronizeTab) getUI();
- tree = ui.getTree(true);
- }
- if (tree == null) {
- // arbre non trouvé (cela devrait souleve une exception !)
- return false;
- }
-
- node = EntityTreeNodeHelper.getSelectedNodeOrRootNode(tree);
- boolean result;
- result = !(node == null || node.isLeaf());
- return result;
+ tree = getTreeForAction("expandAll", getActionName());
+ node = EntityTreeNodeHelper.getSelectedNodeOrRootNode(tree);
+ return !(node == null || node.isLeaf());
}
@Override
@@ -92,7 +72,6 @@
@Override
public void updateUI() {
- super.updateUI();
tree.invalidate();
getMainUI().repaint();
}
Modified: trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/util/SimExplorerAbstractTabAction.java
===================================================================
--- trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/util/SimExplorerAbstractTabAction.java 2008-02-20 13:51:45 UTC (rev 1137)
+++ trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/util/SimExplorerAbstractTabAction.java 2008-02-20 14:37:27 UTC (rev 1138)
@@ -19,8 +19,11 @@
package fr.cemagref.simexplorer.is.ui.swing.actions.util;
import fr.cemagref.simexplorer.is.ui.swing.SimExplorerTab;
+import fr.cemagref.simexplorer.is.ui.swing.JDetailTab;
+import fr.cemagref.simexplorer.is.ui.swing.JSynchronizeTab;
import fr.cemagref.simexplorer.is.ui.swing.model.DataEntityModel;
import fr.cemagref.simexplorer.is.ui.swing.model.SimExplorerTabModel;
+import fr.cemagref.simexplorer.is.exceptions.SimExplorerRuntimeException;
import jaxx.runtime.JAXXObject;
import jaxx.runtime.swing.JAXXTab;
import org.apache.commons.beanutils.Converter;
@@ -29,6 +32,7 @@
import javax.swing.JComponent;
import javax.swing.JTabbedPane;
+import javax.swing.JTree;
import java.awt.Component;
import java.awt.event.ActionEvent;
import java.util.regex.Matcher;
@@ -153,4 +157,23 @@
}
return entityModel;
}
+
+ protected JTree getTreeForAction(String actionPrefix, String actionName) {
+ JTree tree = null;
+ // on retrouve l'arbre concerné à partir du nom de l'action
+ if ((actionPrefix + "Detail").equals(actionName)) {
+ JDetailTab ui = (JDetailTab) getUI();
+ tree = ui.getNavigationTree();
+ } else if ((actionPrefix + "Local").equals(actionName)) {
+ JSynchronizeTab ui = (JSynchronizeTab) getUI();
+ tree = ui.getTree(false);
+ } else if ((actionPrefix + "Remote").equals(actionName)) {
+ JSynchronizeTab ui = (JSynchronizeTab) getUI();
+ tree = ui.getTree(true);
+ }
+ if (tree == null) {
+ throw new SimExplorerRuntimeException("could not find a tree for command " + actionName);
+ }
+ return tree;
+ }
}
1
0
r1137 - trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions
by tchemit@users.labs.libre-entreprise.org 20 Feb '08
by tchemit@users.labs.libre-entreprise.org 20 Feb '08
20 Feb '08
Author: tchemit
Date: 2008-02-20 13:51:45 +0000 (Wed, 20 Feb 2008)
New Revision: 1137
Modified:
trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/ShowSynchronizeTabAction.java
Log:
un seul listener g?\195?\169n?\195?\169rique d'?\195?\169coute sur l'arbre de navigation
Modified: trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/ShowSynchronizeTabAction.java
===================================================================
--- trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/ShowSynchronizeTabAction.java 2008-02-20 13:51:09 UTC (rev 1136)
+++ trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/ShowSynchronizeTabAction.java 2008-02-20 13:51:45 UTC (rev 1137)
@@ -19,11 +19,10 @@
package fr.cemagref.simexplorer.is.ui.swing.actions;
import fr.cemagref.simexplorer.is.entities.data.LoggableElement;
-import fr.cemagref.simexplorer.is.entities.metadata.Version;
-import fr.cemagref.simexplorer.is.ui.StorageServiceHelper;
import fr.cemagref.simexplorer.is.ui.swing.JSynchronizeTab;
import fr.cemagref.simexplorer.is.ui.swing.SimExplorerTab;
import fr.cemagref.simexplorer.is.ui.swing.SynchronizeTabRefreshHelper;
+import fr.cemagref.simexplorer.is.ui.swing.EntityTreeNodeHelper;
import fr.cemagref.simexplorer.is.ui.swing.actions.util.ShowTabAbstractAction;
import fr.cemagref.simexplorer.is.ui.swing.model.DataEntityModel;
import fr.cemagref.simexplorer.is.ui.swing.model.EntityTreeNode;
@@ -64,8 +63,8 @@
public ShowSynchronizeTabAction(String name) {
super(name);
- navigationLocalListener = new NavigationLocalSelectionListener();
- navigationRemoteListener = new NavigationRemoteSelectionListener();
+ navigationLocalListener = new NavigationSelectionListener(false);
+ navigationRemoteListener = new NavigationSelectionListener(true);
}
@Override
@@ -79,55 +78,17 @@
return false;
}
+ SynchronizeTabModel model = (SynchronizeTabModel) SimExplorerTab.synchronize.getModel();
+
// init synchronize tab model
- initTabModel();
-
+ model.updateTabModel(getContext(), selected);
return true;
}
- protected void initTabModel() {
-
- boolean remote = selected.isRemote();
- String uuid = selected.getUuid();
-
- // preparation du model de l'onglet
- SynchronizeTabModel model = (SynchronizeTabModel) SimExplorerTab.synchronize.getModel();
-
- // on nettoye le model avant tout
- model.reset();
-
- // l'élément selectionné est bien la source
- model.setSelectedItem(selected);
-
- DataEntityModel save = model.getSelectedItem();
- LoggableElement source = save.getLe(getContext());
-
- model.setSelectedItem(null);
- // recuperation des versions de l'element destination
- Version[] versions = StorageServiceHelper.getVersions(getContext(), !remote, uuid);
- Version requiredVersion = null;
- if (versions.length != 0) {
- // on prend la dernière version disponible dans la base (i.e
- // la première de la liste des versions :))
- requiredVersion = versions[0];
- }
-
- model.synch(!remote, uuid, requiredVersion);
-
- LoggableElement destination = model.getSelectedItem().getLe(getContext());
-
- // sauvegarde de la source
- model.setSource(source);
- // sauvegarde de la destination
- model.setDestination(destination);
-
- model.setSelectedItem(save);
- }
-
protected void initFirstUsage(JSynchronizeTab ui, SynchronizeTabModel model) {
// add a listener on navigation tree
- ui.getContentTreeLocal().addTreeSelectionListener(navigationLocalListener);
- ui.getContentTreeRemote().addTreeSelectionListener(navigationRemoteListener);
+ ui.getTree(false).addTreeSelectionListener(navigationLocalListener);
+ ui.getTree(true).addTreeSelectionListener(navigationRemoteListener);
}
@Override
@@ -137,61 +98,20 @@
}
/**
- * The listener of the selection in local navigation tree.
+ * The listener of the selection in a navigation tree.
*
* @author chemit
*/
- protected class NavigationLocalSelectionListener implements TreeSelectionListener, PropertyChangeListener {
+ protected class NavigationSelectionListener implements TreeSelectionListener, PropertyChangeListener {
- public NavigationLocalSelectionListener() {
- getTabModel().addPropertyChangeListener(SynchronizeTabModel.SELECTED_LOCAL_NODE_PROPERTY_CHANGED, this);
- }
+ protected boolean remote;
- public void valueChanged(TreeSelectionEvent e) {
+ public NavigationSelectionListener(boolean remote) {
+ this.remote = remote;
SynchronizeTabModel model = getTabModel();
-
- TreePath path = e.getNewLeadSelectionPath();
- EntityTreeNode node = null;
- if (path != null) {
- node = (EntityTreeNode) path.getLastPathComponent();
- }
- // on rafraichit toujours ici les actions de l'arbre qui sont
- // indépendantes du model et dépendent juste dunoeud sélectionné
- SynchronizeTabRefreshHelper.refreshTreeLocalActions(getTabUI(), node);
-
- Object o = node == null ? null : node.getUserObject();
-
- // update history list
- LoggableElement element = (LoggableElement) (o == null || !(o instanceof LoggableElement) ? null : o);
-
- // le node est acceptable uniquement si c'est un loggableElement
- model.setLocalSelectedNode(element);
+ getTabModel().addPropertyChangeListener(model.getSelectedProperty(remote), this);
}
- /**
- * Notify a modification in the model.
- * <p/>
- * This method will update ui.
- *
- * @param evt event coming from DetailTabModel
- */
- public void propertyChange(PropertyChangeEvent evt) {
- log.debug(evt.getPropertyName() + " old:" + evt.getOldValue() + ", new:" + evt.getNewValue());
- SynchronizeTabRefreshHelper.refreshExportElement(getTabUI(), getTabModel(),false);
- }
- }
-
- /**
- * The listener of the selection in local navigation tree.
- *
- * @author chemit
- */
- protected class NavigationRemoteSelectionListener implements TreeSelectionListener, PropertyChangeListener {
-
- public NavigationRemoteSelectionListener() {
- getTabModel().addPropertyChangeListener(SynchronizeTabModel.SELECTED_REMOTE_NODE_PROPERTY_CHANGED, this);
- }
-
public void valueChanged(TreeSelectionEvent e) {
SynchronizeTabModel model = getTabModel();
@@ -201,16 +121,16 @@
node = (EntityTreeNode) path.getLastPathComponent();
}
// on rafraichit toujours ici les actions de l'arbre qui sont
- // indépendantes du model et dépendent juste dunoeud sélectionné
- SynchronizeTabRefreshHelper.refreshTreeRemoteActions(getTabUI(), node);
-
+ // indépendantes du model et dépendent juste dunoeud sélectionné
+ EntityTreeNodeHelper.refreshTreeActions(getTabUI().getCollapseButton(remote), getTabUI().getExpandButton(remote), node);
+
Object o = node == null ? null : node.getUserObject();
// update history list
LoggableElement element = (LoggableElement) (o == null || !(o instanceof LoggableElement) ? null : o);
// le node est acceptable uniquement si c'est un loggableElement
- model.setRemoteSelectedNode(element);
+ model.setSelectedNode(element, remote);
}
/**
@@ -221,9 +141,10 @@
* @param evt event coming from DetailTabModel
*/
public void propertyChange(PropertyChangeEvent evt) {
- log.debug(evt.getPropertyName() + " old:" + evt.getOldValue() + ", new:" + evt.getNewValue());
- SynchronizeTabRefreshHelper.refreshExportElement(getTabUI(), getTabModel(),true);
+ log.info(evt.getPropertyName() + " old:" + evt.getOldValue() + ", new:" + evt.getNewValue());
+ SynchronizeTabRefreshHelper.refreshExportElement(getTabUI(), getTabModel(), remote);
}
}
+
}
1
0
r1136 - trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions
by tchemit@users.labs.libre-entreprise.org 20 Feb '08
by tchemit@users.labs.libre-entreprise.org 20 Feb '08
20 Feb '08
Author: tchemit
Date: 2008-02-20 13:51:09 +0000 (Wed, 20 Feb 2008)
New Revision: 1136
Modified:
trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/CollapseAllAction.java
trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/ExpandAllAction.java
Log:
refactoring model d'onglet de synchronisation
Modified: trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/CollapseAllAction.java
===================================================================
--- trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/CollapseAllAction.java 2008-02-20 13:50:41 UTC (rev 1135)
+++ trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/CollapseAllAction.java 2008-02-20 13:51:09 UTC (rev 1136)
@@ -68,10 +68,10 @@
tree = ui.getNavigationTree();
} else if ("collapseAllLocal".equals(actionName)) {
JSynchronizeTab ui = (JSynchronizeTab) getUI();
- tree = ui.getContentTreeLocal();
+ tree = ui.getTree(false);
} else if ("collapseAllRemote".equals(actionName)) {
JSynchronizeTab ui = (JSynchronizeTab) getUI();
- tree = ui.getContentTreeRemote();
+ tree = ui.getTree(true);
}
if (tree == null) {
// arbre non trouvé (cela devrait souleve une exception !)
Modified: trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/ExpandAllAction.java
===================================================================
--- trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/ExpandAllAction.java 2008-02-20 13:50:41 UTC (rev 1135)
+++ trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/ExpandAllAction.java 2008-02-20 13:51:09 UTC (rev 1136)
@@ -69,10 +69,10 @@
tree = ui.getNavigationTree();
} else if ("expandAllLocal".equals(actionName)) {
JSynchronizeTab ui = (JSynchronizeTab) getUI();
- tree = ui.getContentTreeLocal();
+ tree = ui.getTree(false);
} else if ("expandAllRemote".equals(actionName)) {
JSynchronizeTab ui = (JSynchronizeTab) getUI();
- tree = ui.getContentTreeRemote();
+ tree = ui.getTree(true);
}
if (tree == null) {
// arbre non trouvé (cela devrait souleve une exception !)
1
0