r654 - in trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing: action/tab actions/util
Author: tchemit Date: 2008-02-04 18:59:16 +0000 (Mon, 04 Feb 2008) New Revision: 654 Added: trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/util/ShowListTabAbstractAction.java Removed: trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/action/tab/ShowListTabAbstractAction.java Log: normalisation nom paquetage Deleted: trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/action/tab/ShowListTabAbstractAction.java =================================================================== --- trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/action/tab/ShowListTabAbstractAction.java 2008-02-04 18:58:07 UTC (rev 653) +++ trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/action/tab/ShowListTabAbstractAction.java 2008-02-04 18:59:16 UTC (rev 654) @@ -1,134 +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.action.tab; - -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.SimExplorerRuntimeException; -import fr.cemagref.simexplorer.is.ui.StorageServiceHelper; -import fr.cemagref.simexplorer.is.ui.swing.SimExplorerActionManager; -import fr.cemagref.simexplorer.is.ui.swing.SimExplorerTab; -import fr.cemagref.simexplorer.is.ui.swing.SimExplorerUIRefreshHelper; -import fr.cemagref.simexplorer.is.ui.swing.action.ShowTabAbstractAction; -import fr.cemagref.simexplorer.is.ui.swing.model.DetailTabModel; -import fr.cemagref.simexplorer.is.ui.swing.model.JApplicationTableModel; -import fr.cemagref.simexplorer.is.ui.swing.model.ListTabModel; -import fr.cemagref.simexplorer.is.ui.swing.tab.JApplicationListTab; -import jaxx.runtime.JAXXObject; - -import javax.swing.AbstractAction; -import javax.swing.AbstractButton; -import javax.swing.JTabbedPane; -import java.awt.Component; -import java.awt.event.ActionEvent; -import java.awt.event.KeyAdapter; -import java.awt.event.KeyEvent; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; - -/** @author chemit */ -public class ShowListTabAbstractAction extends ShowTabAbstractAction<JApplicationListTab, ListTabModel> { - private static final long serialVersionUID = 3813479850648257169L; - - /** flag pour indiquer si la liste est locale ou remote */ - protected boolean remote; - - public ShowListTabAbstractAction(String name, boolean remote) { - super(name); - this.remote = remote; - } - - @Override - protected boolean beforeAction(ActionEvent e) throws Exception { - super.beforeAction(e); - JTabbedPane tabbedPane = getTabContainer(); - JAXXObject ui = getUI(); - - if (getTab().isTabVisible(tabbedPane)) { - // tab is already visible, just select it - tabbedPane.setSelectedComponent((Component) ui); - return false; - } - - ListTabModel model = (ListTabModel) getModel(); - - MetaData[] data = model.getList(); - - if (data == null) { - // first coming here, init model - model.initTabModel(remote, getContext()); - } - return true; - } - - protected void initFirstUsage(final JApplicationListTab ui, final ListTabModel model) { - // add a show detail action when double click on a row of the table - ui.getTable().addMouseListener(new MouseAdapter() { - - /** l'action d'affichage de l'onglet de détail */ - AbstractAction detailAction = SimExplorerActionManager.newAction("showTab_detail", (AbstractButton) null); - - @Override - public void mouseClicked(MouseEvent e) { - if (e.getClickCount() == 2) { - // récupération du metadata à afficher - MetaData data = model.get(ui.getTable().getSelectedRow()); - // récupération de l'uuid à afficher - String uuid = data.getUuid(); - // récupération de la version à afficher - Version version = data.getVersion(); - try { - // chargement de l'élément à partir du service - LoggableElement element = StorageServiceHelper.getElement(getContext(), remote, uuid, version.toString()); - // préparation du modèle de détail - DetailTabModel detailModel = (DetailTabModel) SimExplorerTab.detail.getModel(); - // on supprime les anciennes données du modèle - detailModel.reset(); - // positionnement du type de détail (local ou remote) - detailModel.setRemote(remote); - // positionnement du rootNode du modèle - detailModel.setRootNode(element); - log.info("prepare detail - uuid:" + uuid + ", version:" + version + " (remote ?" + remote + ")"); - // lancement de l'action d'affichage du tab - detailAction.actionPerformed(new ActionEvent(e.getSource(), ActionEvent.ACTION_FIRST, "showTab_detail")); - } catch (Exception e1) { - throw new SimExplorerRuntimeException(e1); - } - } - } - }); - // add search actions listeners - - ui.getSearchText().addKeyListener(new KeyAdapter() { - @Override - public void keyReleased(KeyEvent e) { - SimExplorerUIRefreshHelper.refreshSearchActions(ui, model); - } - }); - //TODO Est-ce vraiment le bon endroit pour faire ça ? - // push model into tableModel - JApplicationTableModel modelTab = (JApplicationTableModel) ui.getTable().getModel(); - modelTab.setData(model.getList()); - } - - protected void initUI(JApplicationListTab ui, ListTabModel model) { - SimExplorerUIRefreshHelper.refreshListTabUI(ui, model); - } -} Copied: trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/util/ShowListTabAbstractAction.java (from rev 649, trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/action/tab/ShowListTabAbstractAction.java) =================================================================== --- trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/util/ShowListTabAbstractAction.java (rev 0) +++ trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/util/ShowListTabAbstractAction.java 2008-02-04 18:59:16 UTC (rev 654) @@ -0,0 +1,134 @@ +/* +* ##% 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.actions.util; + +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.SimExplorerRuntimeException; +import fr.cemagref.simexplorer.is.ui.StorageServiceHelper; +import fr.cemagref.simexplorer.is.ui.swing.SimExplorerActionManager; +import fr.cemagref.simexplorer.is.ui.swing.SimExplorerTab; +import fr.cemagref.simexplorer.is.ui.swing.SimExplorerUIRefreshHelper; +import fr.cemagref.simexplorer.is.ui.swing.actions.util.ShowTabAbstractAction; +import fr.cemagref.simexplorer.is.ui.swing.model.DetailTabModel; +import fr.cemagref.simexplorer.is.ui.swing.model.JApplicationTableModel; +import fr.cemagref.simexplorer.is.ui.swing.model.ListTabModel; +import fr.cemagref.simexplorer.is.ui.swing.tab.JApplicationListTab; +import jaxx.runtime.JAXXObject; + +import javax.swing.AbstractAction; +import javax.swing.AbstractButton; +import javax.swing.JTabbedPane; +import java.awt.Component; +import java.awt.event.ActionEvent; +import java.awt.event.KeyAdapter; +import java.awt.event.KeyEvent; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; + +/** @author chemit */ +public class ShowListTabAbstractAction extends ShowTabAbstractAction<JApplicationListTab, ListTabModel> { + private static final long serialVersionUID = 3813479850648257169L; + + /** flag pour indiquer si la liste est locale ou remote */ + protected boolean remote; + + public ShowListTabAbstractAction(String name, boolean remote) { + super(name); + this.remote = remote; + } + + @Override + protected boolean beforeAction(ActionEvent e) throws Exception { + super.beforeAction(e); + JTabbedPane tabbedPane = getTabContainer(); + JAXXObject ui = getUI(); + + if (getTab().isTabVisible(tabbedPane)) { + // tab is already visible, just select it + tabbedPane.setSelectedComponent((Component) ui); + return false; + } + + ListTabModel model = (ListTabModel) getModel(); + + MetaData[] data = model.getList(); + + if (data == null) { + // first coming here, init model + model.initTabModel(remote, getContext()); + } + return true; + } + + protected void initFirstUsage(final JApplicationListTab ui, final ListTabModel model) { + // add a show detail action when double click on a row of the table + ui.getTable().addMouseListener(new MouseAdapter() { + + /** l'action d'affichage de l'onglet de détail */ + AbstractAction detailAction = SimExplorerActionManager.newAction("showTab_detail", (AbstractButton) null); + + @Override + public void mouseClicked(MouseEvent e) { + if (e.getClickCount() == 2) { + // récupération du metadata à afficher + MetaData data = model.get(ui.getTable().getSelectedRow()); + // récupération de l'uuid à afficher + String uuid = data.getUuid(); + // récupération de la version à afficher + Version version = data.getVersion(); + try { + // chargement de l'élément à partir du service + LoggableElement element = StorageServiceHelper.getElement(getContext(), remote, uuid, version.toString()); + // préparation du modèle de détail + DetailTabModel detailModel = (DetailTabModel) SimExplorerTab.detail.getModel(); + // on supprime les anciennes données du modèle + detailModel.reset(); + // positionnement du type de détail (local ou remote) + detailModel.setRemote(remote); + // positionnement du rootNode du modèle + detailModel.setRootNode(element); + log.info("prepare detail - uuid:" + uuid + ", version:" + version + " (remote ?" + remote + ")"); + // lancement de l'action d'affichage du tab + detailAction.actionPerformed(new ActionEvent(e.getSource(), ActionEvent.ACTION_FIRST, "showTab_detail")); + } catch (Exception e1) { + throw new SimExplorerRuntimeException(e1); + } + } + } + }); + // add search actions listeners + + ui.getSearchText().addKeyListener(new KeyAdapter() { + @Override + public void keyReleased(KeyEvent e) { + SimExplorerUIRefreshHelper.refreshSearchActions(ui, model); + } + }); + //TODO Est-ce vraiment le bon endroit pour faire ça ? + // push model into tableModel + JApplicationTableModel modelTab = (JApplicationTableModel) ui.getTable().getModel(); + modelTab.setData(model.getList()); + } + + protected void initUI(JApplicationListTab ui, ListTabModel model) { + SimExplorerUIRefreshHelper.refreshListTabUI(ui, model); + } +}
participants (1)
-
tchemit@users.labs.libre-entreprise.org