Author: tchemit Date: 2008-02-02 17:01:43 +0000 (Sat, 02 Feb 2008) New Revision: 600 Added: trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/action/tab/ShowListTabAbstractAction.java Log: introduction d'une action de base d'ouverture de tab pour une liste Added: 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 (rev 0) +++ trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/action/tab/ShowListTabAbstractAction.java 2008-02-02 17:01:43 UTC (rev 600) @@ -0,0 +1,85 @@ +/* +* ##% 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.ui.swing.tab.JApplicationListTab; +import fr.cemagref.simexplorer.is.ui.swing.model.ListTabModel; +import fr.cemagref.simexplorer.is.ui.swing.model.JApplicationTableModel; +import fr.cemagref.simexplorer.is.ui.swing.action.ShowTabAbstractAction; +import fr.cemagref.simexplorer.is.entities.metadata.MetaData; + +import javax.swing.JTabbedPane; +import java.awt.event.ActionEvent; +import java.awt.event.KeyAdapter; +import java.awt.event.KeyEvent; +import java.awt.Component; + +import jaxx.runtime.JAXXObject; + +/** @author chemit */ +public class ShowListTabAbstractAction extends ShowTabAbstractAction<JApplicationListTab, ListTabModel> { + private static final long serialVersionUID = 3813479850648257169L; + + public ShowListTabAbstractAction(String name) { + super(name); + } + + @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; + } + + // mark it, after action will push table model + firstTime = ui == null; + + ListTabModel model = (ListTabModel) getModel(); + + MetaData[] data = model.getList(); + + if (data == null) { + // first coming here, init model + model.initTabModel(false, getContext()); + } + return true; + } + + protected void initFirstUsage(final JApplicationListTab ui, final ListTabModel model) { + // push model into tableModel + JApplicationTableModel modelTab = (JApplicationTableModel) ui.getTable().getModel(); + modelTab.setData(model.getList()); + // add search actions listeners + ui.getSearchText().addKeyListener(new KeyAdapter() { + @Override + public void keyReleased(KeyEvent e) { + getMainUI().refreshSearchActions(ui, model); + } + }); + } + + protected void initUI(JApplicationListTab ui, ListTabModel model) { + getMainUI().refreshListTabUI(model, ui); + } +}
participants (1)
-
tchemit@users.labs.libre-entreprise.org