Author: tchemit Date: 2008-01-22 01:57:50 +0000 (Tue, 22 Jan 2008) New Revision: 360 Modified: trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/action/SimExplorerAbstractTabAction.java Log: action de base revisit?\195?\169e (reste ?\195?\160 ajouter la gestion de s?\195?\169curit?\195?\169 sur action) 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 01:57:11 UTC (rev 359) +++ trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/action/SimExplorerAbstractTabAction.java 2008-01-22 01:57:50 UTC (rev 360) @@ -18,14 +18,16 @@ * ##% */ package fr.cemagref.simexplorer.is.ui.swing.action; -import fr.cemagref.simexplorer.is.ui.swing.SimExplorerTabManager; +import fr.cemagref.simexplorer.is.ui.swing.SimExplorerActionManager; +import fr.cemagref.simexplorer.is.ui.swing.SimExplorerTab; +import jaxx.runtime.builder.TabModel; +import jaxx.runtime.JAXXObject; import org.apache.commons.beanutils.Converter; import org.codelutin.i18n.I18n; import org.codelutin.util.ConverterUtil; +import javax.swing.JComponent; import javax.swing.JTabbedPane; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -36,53 +38,54 @@ */ public abstract class SimExplorerAbstractTabAction extends SimExplorerAbstractAction implements ActionParameter { - protected SimExplorerTabManager.Tab tab; + protected SimExplorerTab tab; + protected String param; - protected String methodName; - - protected Method method; - private static final long serialVersionUID = 5285229914266682509L; - protected String param; - protected SimExplorerAbstractTabAction(String name, String prefixPatternName) { super(name); - methodName = prefixPatternName; - Pattern patternName = Pattern.compile(prefixPatternName + "_(\\w+)"); - Matcher matcher = patternName.matcher(name); - if (!matcher.matches()) { - throw new IllegalArgumentException(I18n._("{0} should have a name like this {1}, but was {2}", getClass().getName(), patternName, name)); - } - param = matcher.group(1); - Converter convertorLanguage = ConverterUtil.getConverter(SimExplorerTabManager.Tab.class); - tab = (SimExplorerTabManager.Tab) convertorLanguage.convert(SimExplorerTabManager.Tab.class, param); - } + if (prefixPatternName != null) { + Pattern patternName = Pattern.compile(prefixPatternName + "_(\\w+)"); + Matcher matcher = patternName.matcher(name); + if (!matcher.matches()) { + throw new IllegalArgumentException(I18n._("{0} should have a name like this {1}, but was {2}", getClass().getName(), patternName, name)); + } - @Override - public void actionPerformed(java.awt.event.ActionEvent e) { - super.actionPerformed(e); - try { - getMethod().invoke(null, getMainUI().getContent(), tab); - } catch (IllegalAccessException e1) { - throw new RuntimeException(e1); - } catch (InvocationTargetException e1) { - throw new RuntimeException(e1); - } - } + param = prefixPatternName; - protected Method getMethod() { - if (method == null) { - try { - method = SimExplorerTabManager.class.getMethod(methodName, JTabbedPane.class, SimExplorerTabManager.Tab.class); - } catch (NoSuchMethodException e) { - throw new RuntimeException("could not found method '" + methodName + "' on " + SimExplorerTabManager.class); - } + Converter convertorLanguage = ConverterUtil.getConverter(SimExplorerTab.class); + tab = (SimExplorerTab) convertorLanguage.convert(SimExplorerTab.class, matcher.group(1)); + } else { + param = name; + tab = SimExplorerActionManager.getLoadingTab(); } - return method; + log.info(">>> " + this); } public String getParam() { return param; } + + public JTabbedPane getTabContainer() { + return getMainUI().getContent(); + } + + public JAXXObject getTab() { + return tab.getUI(); + } + + public TabModel getModel() { + return tab.getModel(); + } + + protected JComponent getUIObject(String name) { + return getUIObject(name, getTab()); + } + + @Override + public String toString() { + String s = super.toString(); + return s.substring(s.lastIndexOf(".") + 1) + "<tab: " + tab + ", param: " + param + ">"; + } }
participants (1)
-
tchemit@users.labs.libre-entreprise.org