Author: tchemit Date: 2008-01-22 06:01:30 +0000 (Tue, 22 Jan 2008) New Revision: 381 Modified: trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/action/ShowTabAbstractAction.java trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/action/SimExplorerAbstractAction.java trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/action/SimExplorerAbstractTabAction.java Log: utilisation accesseur getTab() plutot que la r?\195?\169f?\195?\169rence tab + ajout m?\195?\169thode pour r?\195?\169cup?\195?\169rer le tab quand l'action n'est pas sp?\195?\169cifique ?\195?\160 un tab ainsi on peut maintenant utiliser une m?\195?\170me action sur plusieurs tab, le tab utilis?\195?\169 sera celui dans lequel se trouve la source de l'?\195?\169v?\195?\168nement :) Modified: trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/action/ShowTabAbstractAction.java =================================================================== --- trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/action/ShowTabAbstractAction.java 2008-01-22 05:59:18 UTC (rev 380) +++ trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/action/ShowTabAbstractAction.java 2008-01-22 06:01:30 UTC (rev 381) @@ -35,6 +35,6 @@ @Override protected void doAction(ActionEvent e) throws Exception { - tab.showTab(getTabContainer()); + getTab().showTab(getTabContainer()); } } Modified: trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/action/SimExplorerAbstractAction.java =================================================================== --- trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/action/SimExplorerAbstractAction.java 2008-01-22 05:59:18 UTC (rev 380) +++ trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/action/SimExplorerAbstractAction.java 2008-01-22 06:01:30 UTC (rev 381) @@ -42,12 +42,12 @@ public void actionPerformed(java.awt.event.ActionEvent e) { - log.info("------------------------------------------------------------"); - log.info("action : " + this); + log.info("------------------------------------------------------------"); log.info("event : " + e); log.info("source : " + e.getSource()); try { boolean accepted = beforeAction(e); + log.info("action : " + this); log.info("doAction : (" + accepted + ") : " + getActionName()); if (accepted) { doAction(e); Modified: trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/action/SimExplorerAbstractTabAction.java =================================================================== --- trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/action/SimExplorerAbstractTabAction.java 2008-01-22 05:59:18 UTC (rev 380) +++ trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/action/SimExplorerAbstractTabAction.java 2008-01-22 06:01:30 UTC (rev 381) @@ -18,7 +18,6 @@ * ##% */ package fr.cemagref.simexplorer.is.ui.swing.action; -import fr.cemagref.simexplorer.is.ui.swing.SimExplorerActionManager; import fr.cemagref.simexplorer.is.ui.swing.SimExplorerTab; import jaxx.runtime.JAXXObject; import jaxx.runtime.builder.TabModel; @@ -28,6 +27,7 @@ import javax.swing.JComponent; import javax.swing.JTabbedPane; +import java.awt.Component; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -38,7 +38,7 @@ */ public abstract class SimExplorerAbstractTabAction extends SimExplorerAbstractAction implements ActionParameter { - protected SimExplorerTab tab; + private SimExplorerTab tab; protected String param; private static final long serialVersionUID = 5285229914266682509L; @@ -58,7 +58,6 @@ tab = (SimExplorerTab) convertorLanguage.convert(SimExplorerTab.class, matcher.group(1)); } else { param = name; - tab = SimExplorerActionManager.getLoadingTab(); } log.info(">>> " + this); } @@ -71,16 +70,28 @@ return getMainUI().getContent(); } - public JAXXObject getTab() { - return tab.getUI(); + public SimExplorerTab getTab() { + if (tab == null) { + Component comp = getTabContainer().getSelectedComponent(); + for (SimExplorerTab explorerTab : SimExplorerTab.values()) { + if (comp.equals(explorerTab.getUI())) { + tab = explorerTab; + break; + } + } + if (tab==null) { + throw new IllegalStateException("could not found tab to match for action " + this); + } + } + return tab; } - public TabModel getModel() { - return tab.getModel(); + public JAXXObject getUI() { + return getTab().getUI(); } - protected JComponent getUIObject(String name) { - return getUIObject(name, getTab()); + public TabModel getModel() { + return getTab().getModel(); } @Override @@ -88,4 +99,12 @@ String s = super.toString(); return s.substring(s.lastIndexOf(".") + 1) + "<tab: " + tab + ", param: " + param + ">"; } + + protected JComponent getUIObject(String name) { + return getUIObject(name, getUI()); + } + + protected void setTab(SimExplorerTab tab) { + this.tab = tab; + } }
participants (1)
-
tchemit@users.labs.libre-entreprise.org