r1643 - in isis-fish/trunk: . src/main/java/fr/ifremer/isisfish/ui/input src/main/resources src/main/resources/i18n
Author: tchemit Date: 2008-12-02 20:57:45 +0000 (Tue, 02 Dec 2008) New Revision: 1643 Modified: isis-fish/trunk/pom.xml isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputAction.java isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputNavigationTreeSelectionAdapter.java isis-fish/trunk/src/main/resources/i18n/isis-fish-en_GB.properties isis-fish/trunk/src/main/resources/i18n/isis-fish-fr_FR.properties isis-fish/trunk/src/main/resources/log4j.properties Log: l'arbe fonctionne :) Modified: isis-fish/trunk/pom.xml =================================================================== --- isis-fish/trunk/pom.xml 2008-12-02 17:03:51 UTC (rev 1642) +++ isis-fish/trunk/pom.xml 2008-12-02 20:57:45 UTC (rev 1643) @@ -382,26 +382,22 @@ <dependency> <groupId>org.codelutin</groupId> <artifactId>lutinwidget</artifactId> - <version>${lutinwidget.version}</version> - <scope>runtime</scope> + <version>${lutinwidget.version}</version> </dependency> <dependency> <groupId>org.codelutin.topia</groupId> <artifactId>topia-persistence</artifactId> <version>${topia.version}</version> - <scope>runtime</scope> </dependency> <dependency> <groupId>jfreechart</groupId> <artifactId>jfreechart</artifactId> <version>0.9.3</version> - <scope>runtime</scope> </dependency> <dependency> <groupId>org.codelutin</groupId> <artifactId>lutinmatrix</artifactId> <version>1.1</version> - <scope>runtime</scope> </dependency> </dependencies> </plugin> Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputAction.java =================================================================== --- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputAction.java 2008-12-02 17:03:51 UTC (rev 1642) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputAction.java 2008-12-02 20:57:45 UTC (rev 1643) @@ -115,6 +115,7 @@ protected Strategy strategy; public InputAction() { + log.info("new instance"); } protected void showMsgBox(String txt){ if (txt != null){ @@ -133,7 +134,11 @@ vesselType = null; setOfVessels = null; strategy = null; - System.out.println(value.getClass().getName()); + selected=null; + if (!(value instanceof TopiaEntity)) { + // this is not a TopiaEntity value, so quit + return; + } switch (IsisFishEntityEnum.valueOf(value.getClass())){ case Zone: zone = (Zone) value; @@ -459,7 +464,6 @@ * if this method return false, nothing is do * * @return false if user want cancel action, true otherwize - * @throws TopiaException */ protected boolean askForSave() { boolean result = true; @@ -627,10 +631,10 @@ * Save an Equation as model, to reuse it for other equation * * @param category - * categoy for this equation - * @param isisfish + * category for this equation + * @param language * equation to put in models - * @param language + * @param content content ? * @return if ok return null else OutputView error message */ public Object saveAsModel(String category, String language, String content) { Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputNavigationTreeSelectionAdapter.java =================================================================== --- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputNavigationTreeSelectionAdapter.java 2008-12-02 17:03:51 UTC (rev 1642) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputNavigationTreeSelectionAdapter.java 2008-12-02 20:57:45 UTC (rev 1643) @@ -5,40 +5,38 @@ package fr.ifremer.isisfish.ui.input; -import java.awt.Component; -import java.lang.reflect.Method; -import javax.swing.JPanel; -import javax.swing.event.TreeSelectionEvent; import jaxx.runtime.swing.CardLayout2; import jaxx.runtime.swing.JAXXTree; import jaxx.runtime.swing.navigation.NavigationTreeModel; import jaxx.runtime.swing.navigation.NavigationTreeModel.NavigationTreeNode; -import jaxx.runtime.swing.navigation.NavigationTreeSelectionAdapter; import jaxx.runtime.swing.navigation.NavigationTreeSelectionAdapterWithCardLayout; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -/** - * - * @author letellier - */ +import javax.swing.JPanel; +import javax.swing.event.TreeSelectionEvent; +import java.awt.Component; +import java.lang.reflect.Method; + +/** @author letellier */ public class InputNavigationTreeSelectionAdapter extends NavigationTreeSelectionAdapterWithCardLayout { /** to use log facility, just put in your code: log.info(\"...\"); */ static private final Log log = LogFactory.getLog(InputNavigationTreeSelectionAdapter.class); - public InputNavigationTreeSelectionAdapter (InputUI context, boolean register) { - super(InputUI.class, null, context); + public InputNavigationTreeSelectionAdapter(InputUI context, boolean register) { + super(InputUI.class, null, context, Strategy.PER_UI_TYPE); if (context.getNavigation() == null) { throw new IllegalArgumentException("could not have a null 'navigation' in ui " + context); } -// Util.checkJAXXContextEntry(context, ContextHelper.NAVIGATION_MODEL_ENTRY_DEF); + if (register) { // register in tree this listener context.getNavigation().addTreeSelectionListener(this); } } + @Override protected JPanel getContentContainer() { return ((InputUI) context).getInputPane(); @@ -58,6 +56,7 @@ protected void goBackToPreviousNode(TreeSelectionEvent event, Exception e) { if (e != null) { // ErrorDialogUI.showError(e); + e.printStackTrace(); } // go back to previous node returnToPreviousNode(getNavigationTree(), event); @@ -69,92 +68,26 @@ } @Override - public void valueChanged(TreeSelectionEvent event) { - if (event.getOldLeadSelectionPath() != null && event.getOldLeadSelectionPath().equals(event.getPath())) { - // do not treate this if no path changed - return; - } - + protected void openUI(Component newUI, NavigationTreeNode node) throws Exception { + super.openUI(newUI, node); + // apply refresh method (should a contract for all this ui with a method refresh...) try { - - NavigationTreeNode node = prepareNode(event); - - String path = node.getContextPath(); - - if (log.isTraceEnabled()) { - log.trace(path); - } - - Component newUI = getNewUI(path); - Component component = getCurrentUI(); - - if (newUI != null && newUI.equals(component)) { - // call back from goto back to previous node, do nothing - return; - } - - if (!closeUI(event, component)) { - // previous ui was not closed, so reselect the previous node in navigation - goBackToPreviousNode(event, null); - // and quit - return; - } - - // now, we are free to open the ui associated with the selected node in navigation - - // before all, attach bean in context associated with the selected node in naivgation tree - Object data = getNavigationTreeModel().getJAXXContextValue(context, path); - - if (log.isDebugEnabled()) { - log.debug("find data for contextPath <" + path + "> : " + (data == null ? null : data.getClass())); - } - - context.removeContextValue(Object.class,NAVIGATION_SELECTED_BEAN); - InputUI inputUI = ((InputUI)context); - InputAction action = inputUI.getContextValue(InputAction.class); - if (data != null) { - action.setValue(data); - // context.setContextValue(data, NAVIGATION_SELECTED_BEAN); - //todo should we not use this to avoid conflict in context ? - // context.setContextValue(data); - } - - - if (newUI == null) { - // instanciate a new ui associated with the selected node - newUI = createUI(node); - - } - - ((jaxx.runtime.JAXXObject)newUI).setContextValue(action); - // save in context current node context path - context.setContextValue(node.getContextPath(), NAVIGATION_CONTEXT_PATH); - - // save in context current node - context.setContextValue(node, NAVIGATION_SELECTED_NODE); - - // really open the ui associated with the selected node - openUI(newUI, node); - - } catch (Exception e) { - // remove data from context - System.out.println(e.getMessage()); - // if any error, go back to previvous node - goBackToPreviousNode(event, e); + Method m = newUI.getClass().getDeclaredMethod("refresh"); + m.setAccessible(true); + m.invoke(newUI); + } catch (NoSuchMethodException e) { + // ok do nothing } } @Override - protected void openUI(Component newUI, NavigationTreeNode node) throws Exception { - CardLayout2 layout = getContentLayout(); - JPanel container = getContentContainer(); - // switch layout - layout.show(container, node.getContextPath()); - log.info(((jaxx.runtime.JAXXObject)newUI).getContextValue(InputAction.class)); - Method m = newUI.getClass().getMethod("refresh"); - m.invoke(newUI); - + protected void addSelectedBeanInContext(NavigationTreeNode node, Object data) { + if (log.isDebugEnabled()) { + log.debug("find data for contextPath <" + node.getContextPath() + "> : " + (data == null ? null : data.getClass())); + } + InputAction action = context.getContextValue(InputAction.class); + if (data != null) { + action.setValue(data); + } } - - } Modified: isis-fish/trunk/src/main/resources/i18n/isis-fish-en_GB.properties =================================================================== --- isis-fish/trunk/src/main/resources/i18n/isis-fish-en_GB.properties 2008-12-02 17:03:51 UTC (rev 1642) +++ isis-fish/trunk/src/main/resources/i18n/isis-fish-en_GB.properties 2008-12-02 20:57:45 UTC (rev 1643) @@ -857,6 +857,9 @@ isisfish.simpleResult.table=defaultToolTip-fr.ifremer.isisfish.map.SimpleResultatMapBean.table12 isisfish.simulation.log.console.title=Log console for simulation '%1$s' isisfish.simulation.log.showConsole=display log console for simulation %1$s +isisfish.simulation.menu.import= +isisfish.simulation.menu.save= +isisfish.simulation.menu.simulation= isisfish.simulation.name=Simulation name isisfish.simulation.title=Simulation launcher isisfish.simulator.launcher.inprocess=in current process Modified: isis-fish/trunk/src/main/resources/i18n/isis-fish-fr_FR.properties =================================================================== --- isis-fish/trunk/src/main/resources/i18n/isis-fish-fr_FR.properties 2008-12-02 17:03:51 UTC (rev 1642) +++ isis-fish/trunk/src/main/resources/i18n/isis-fish-fr_FR.properties 2008-12-02 20:57:45 UTC (rev 1643) @@ -857,6 +857,9 @@ isisfish.simpleResult.table=defaultToolTip-fr.ifremer.isisfish.map.SimpleResultatMapBean.table12 isisfish.simulation.log.console.title=Console de log simulation '%1$s' isisfish.simulation.log.showConsole=affichage de la console de log pour la simulation %1$s +isisfish.simulation.menu.import= +isisfish.simulation.menu.save= +isisfish.simulation.menu.simulation= isisfish.simulation.name=Nom de la simulation isisfish.simulation.title=Lanceur de simulation isisfish.simulator.launcher.inprocess=dans le m\u00EAme processus Modified: isis-fish/trunk/src/main/resources/log4j.properties =================================================================== --- isis-fish/trunk/src/main/resources/log4j.properties 2008-12-02 17:03:51 UTC (rev 1642) +++ isis-fish/trunk/src/main/resources/log4j.properties 2008-12-02 20:57:45 UTC (rev 1643) @@ -14,3 +14,4 @@ log4j.logger.rules=INFO log4j.logger.scripts=INFO log4j.logger.simulators=INFO +log4j.logger.fr.ifremer.isisfish.ui.input.InputNavigationTreeSelectionAdapter=DEBUG
participants (1)
-
tchemit@users.labs.libre-entreprise.org