Author: echatellier Date: 2012-02-14 17:48:29 +0100 (Tue, 14 Feb 2012) New Revision: 3604 Url: http://forge.codelutin.com/repositories/revision/isis-fish/3604 Log: Debut de l'impl?\195?\169mentation et de l'interface de gestion des variables habitats Added: branches/4.1/src/main/java/fr/ifremer/isisfish/datastore/migration/MigrationV40V41.java branches/4.1/src/main/java/fr/ifremer/isisfish/entities/VariableImpl.java branches/4.1/src/main/java/fr/ifremer/isisfish/ui/input/ZoneBasicsUI.jaxx branches/4.1/src/main/java/fr/ifremer/isisfish/ui/input/variable/ branches/4.1/src/main/java/fr/ifremer/isisfish/ui/input/variable/EntityVariableHandler.java branches/4.1/src/main/java/fr/ifremer/isisfish/ui/input/variable/EntityVariableUI.jaxx branches/4.1/src/main/java/fr/ifremer/isisfish/ui/input/variable/VariableListRenderer.java branches/4.1/src/main/java/fr/ifremer/isisfish/ui/input/variable/VariableTypeComboModel.java Modified: branches/4.1/src/main/java/fr/ifremer/isisfish/datastore/migration/DatabaseMigrationClass.java branches/4.1/src/main/java/fr/ifremer/isisfish/ui/input/ZoneUI.jaxx branches/4.1/src/main/java/fr/ifremer/isisfish/ui/input/model/TopiaEntityListModel.java branches/4.1/src/main/resources/i18n/isis-fish_en_GB.properties branches/4.1/src/main/resources/i18n/isis-fish_fr_FR.properties branches/4.1/src/main/xmi/isis-fish.zargo Modified: branches/4.1/src/main/java/fr/ifremer/isisfish/datastore/migration/DatabaseMigrationClass.java =================================================================== --- branches/4.1/src/main/java/fr/ifremer/isisfish/datastore/migration/DatabaseMigrationClass.java 2012-02-13 14:55:15 UTC (rev 3603) +++ branches/4.1/src/main/java/fr/ifremer/isisfish/datastore/migration/DatabaseMigrationClass.java 2012-02-14 16:48:29 UTC (rev 3604) @@ -5,7 +5,7 @@ * $Id$ * $HeadURL$ * %% - * Copyright (C) 2011 Ifremer, Codelutin, Chatellier Eric + * Copyright (C) 2011 - 2012 Ifremer, Codelutin, Chatellier Eric * %% * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as @@ -50,6 +50,7 @@ protected static final Version VERSION_32 = new Version("3.2"); protected static final Version VERSION_33 = new Version("3.3"); protected static final Version VERSION_40 = new Version("4.0"); + protected static final Version VERSION_41 = new Version("4.1"); public DatabaseMigrationClass() { super(new MigrationResolver()); @@ -65,12 +66,12 @@ if (version.equals(VERSION_32)) { result = MigrationV0V32.class; - } - else if (version.equals(VERSION_33)) { + } else if (version.equals(VERSION_33)) { result = MigrationV32V33.class; - } - else if (version.equals(VERSION_40)) { + } else if (version.equals(VERSION_40)) { result = MigrationV33V40.class; + } else if (version.equals(VERSION_41)) { + result = MigrationV40V41.class; } return result; } @@ -82,7 +83,7 @@ */ @Override public Version[] getAvailableVersions() { - Version[] result = new Version[] { VERSION_32, VERSION_33, VERSION_40 }; + Version[] result = new Version[] { VERSION_32, VERSION_33, VERSION_40, VERSION_41 }; return result; } Added: branches/4.1/src/main/java/fr/ifremer/isisfish/datastore/migration/MigrationV40V41.java =================================================================== --- branches/4.1/src/main/java/fr/ifremer/isisfish/datastore/migration/MigrationV40V41.java (rev 0) +++ branches/4.1/src/main/java/fr/ifremer/isisfish/datastore/migration/MigrationV40V41.java 2012-02-14 16:48:29 UTC (rev 3604) @@ -0,0 +1,81 @@ +/* + * #%L + * + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2012 Ifremer, Codelutin, Chatellier Eric + * %% + * 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, see + * <http://www.gnu.org/licenses/gpl-2.0.html>. + * #L% + */ + +package fr.ifremer.isisfish.datastore.migration; + +import java.util.List; + +import org.nuiton.topia.TopiaException; +import org.nuiton.topia.framework.TopiaContextImplementor; +import org.nuiton.topia.migration.TopiaMigrationCallbackByClass; +import org.nuiton.topia.migration.TopiaMigrationCallbackByClass.MigrationCallBackForVersion; +import org.nuiton.util.Version; + +/** + * Migration between version 3.3 and 4.0. + * + * @author chatellier + * @version $Revision$ + * + * Last update : $Date$ + * By : $Author$ + */ +public class MigrationV40V41 extends MigrationCallBackForVersion { + + /** + * Constructor. + * + * @param version version + * @param callback callback + */ + public MigrationV40V41(Version version, TopiaMigrationCallbackByClass callback) { + super(version, callback); + } + + /* + * @see org.nuiton.topia.migration.TopiaMigrationCallbackByClass.MigrationCallBackForVersion#prepareMigrationScript(org.nuiton.topia.framework.TopiaContextImplementor, java.util.List, boolean, boolean) + */ + @Override + protected void prepareMigrationScript(TopiaContextImplementor tx, + List<String> queries, boolean showSql, boolean showProgression) + throws TopiaException { + + queries.add("CREATE TABLE VARIABLE( " + + "TOPIAID VARCHAR(255) NOT NULL, " + + "TOPIAVERSION BIGINT NOT NULL, " + + "TOPIACREATEDATE DATE, " + + "ENTITYID VARCHAR(255), " + + "NAME LONGVARCHAR, " + + "TYPE LONGVARCHAR, " + + "DOUBLEVALUE DOUBLE, " + + "MATRIXVALUE_NAME VARCHAR(255), " + + "MATRIXVALUE_DIM VARCHAR(255), " + + "MATRIXVALUE_DIMNAMES LONGVARCHAR, " + + "MATRIXVALUE_SEMANTICS LONGVARCHAR," + + "MATRIXVALUE_DATA LONGVARCHAR, " + + "EQUATIONVALUE VARCHAR(255)) "); + + } +} Property changes on: branches/4.1/src/main/java/fr/ifremer/isisfish/datastore/migration/MigrationV40V41.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: branches/4.1/src/main/java/fr/ifremer/isisfish/entities/VariableImpl.java =================================================================== --- branches/4.1/src/main/java/fr/ifremer/isisfish/entities/VariableImpl.java (rev 0) +++ branches/4.1/src/main/java/fr/ifremer/isisfish/entities/VariableImpl.java 2012-02-14 16:48:29 UTC (rev 3604) @@ -0,0 +1,55 @@ +/* + * #%L + * IsisFish + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2012 Ifremer, Code Lutin, Chatellier Eric + * %% + * 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, see + * <http://www.gnu.org/licenses/gpl-2.0.html>. + * #L% + */ + +package fr.ifremer.isisfish.entities; + +import org.nuiton.math.matrix.MatrixND; + +public class VariableImpl extends VariableAbstract { + + private static final long serialVersionUID = 3978428224373810278L; + + @Override + public void setDoubleValue(double doubleValue) { + super.setDoubleValue(doubleValue); + super.setMatrixValue(null); + super.setEquationValue(null); + } + + @Override + public void setEquationValue(Equation equationValue) { + super.setEquationValue(equationValue); + super.setDoubleValue(0); + super.setMatrixValue(null); + } + + @Override + public void setMatrixValue(MatrixND matrixValue) { + super.setMatrixValue(matrixValue); + super.setDoubleValue(0); + super.setEquationValue(null); + } + +} //VariableImpl Property changes on: branches/4.1/src/main/java/fr/ifremer/isisfish/entities/VariableImpl.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Copied: branches/4.1/src/main/java/fr/ifremer/isisfish/ui/input/ZoneBasicsUI.jaxx (from rev 3601, branches/4.1/src/main/java/fr/ifremer/isisfish/ui/input/ZoneUI.jaxx) =================================================================== --- branches/4.1/src/main/java/fr/ifremer/isisfish/ui/input/ZoneBasicsUI.jaxx (rev 0) +++ branches/4.1/src/main/java/fr/ifremer/isisfish/ui/input/ZoneBasicsUI.jaxx 2012-02-14 16:48:29 UTC (rev 3604) @@ -0,0 +1,206 @@ +<!-- + #%L + IsisFish + + $Id$ + $HeadURL$ + %% + Copyright (C) 2009 - 2012 Ifremer, Code Lutin, Chatellier Eric + %% + 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, see + <http://www.gnu.org/licenses/gpl-2.0.html>. + #L% + --> +<fr.ifremer.isisfish.ui.input.InputContentUI superGenericType='Zone'> + + <!-- bean property --> + <fr.ifremer.isisfish.entities.Zone id='bean' javaBean='null'/> + + <import> + static org.nuiton.i18n.I18n.n_ + javax.swing.event.ListSelectionEvent + fr.ifremer.isisfish.entities.Cell + fr.ifremer.isisfish.entities.Zone + fr.ifremer.isisfish.map.CellSelectionLayer + fr.ifremer.isisfish.map.CopyMapToClipboardListener + fr.ifremer.isisfish.ui.input.model.TopiaEntityListModel + com.bbn.openmap.event.SelectMouseMode + com.bbn.openmap.gui.Tool + com.bbn.openmap.gui.OMToolSet + java.beans.PropertyChangeEvent + java.beans.PropertyChangeListener + java.awt.event.MouseEvent + java.util.ArrayList + </import> + + <BeanValidator id='validator' + bean='{getBean()}' beanClass='fr.ifremer.isisfish.entities.Zone' + uiClass="jaxx.runtime.validator.swing.ui.ImageValidationUI"> + <field name="name" component="fieldZoneName" /> + <field name="cell" component="spZoneCells" /> + </BeanValidator> + + <script><![CDATA[ +protected OMToolSet toolSet = new OMToolSet(); + +protected void $afterCompleteSetup() { + + toolSet.setupListeners(zoneMap); + toolMap.add((Tool)toolSet); + + // add copy to clipboard support + zoneMap.addMapMouseListener(new CopyMapToClipboardListener(zoneMap)); + new OpenMapEvents(zoneMap, new SelectMouseMode(false), CellSelectionLayer.MULT_SELECTION) { + @Override + public boolean mouseClicked(MouseEvent e) { + boolean result = false; + if (getBean() != null) { // impossible de desactiver la carte :( + getBean().setCell(zoneMap.getSelectedCells()); + setZoneCells(); + } + return result; + } + }; + + addPropertyChangeListener(PROPERTY_BEAN, new PropertyChangeListener() { + public void propertyChange(PropertyChangeEvent evt) { + if (evt.getNewValue() == null) { + fieldZoneName.setText(""); + fieldZoneComment.setText(""); + zoneMap.setSelectedCells(); + } + if (evt.getNewValue() != null) { + setZoneCells(); + } + } + }); +} + +protected void setZoneCells() { + if (getBean() != null) { + List<Cell> cells = getFisheryRegion().getCell(); + TopiaEntityListModel model = new TopiaEntityListModel(cells); + zoneCells.setModel(model); + if (getBean().getCell() != null) { + for (Cell selectedCell : getBean().getCell()) { + int index = cells.indexOf(selectedCell); + zoneCells.addSelectionInterval(index, index); + } + } + } +} + +protected void zoneCellsChange(ListSelectionEvent event) { + // sans ca, ca boucle (modification depuis la carte) + if (event.getValueIsAdjusting()) { + // pas a faie dans le cas d'une AS + if (isActive()) { + java.util.List<Cell> cells = new ArrayList<Cell>(); + for (Object o : zoneCells.getSelectedValues()) { + cells.add((Cell) o); + } + getBean().setCell(cells); + } + } +} +]]> + </script> + <JPanel id='body'> + <JSplitPane oneTouchExpandable="true" dividerLocation="200" orientation="horizontal"> + <Table> + <row> + <cell columns='2' fill='horizontal' weightx='1.0'> + <JLabel enabled='{isActive()}' text="isisfish.zone.name"/> + </cell> + </row> + <row> + <cell columns='2' fill='horizontal' weightx='1.0'> + <JTextField id="fieldZoneName" + text='{jaxx.runtime.SwingUtil.getStringValue(getBean().getName())}' + enabled='{isActive()}' decorator='boxed' + onKeyReleased='getBean().setName(fieldZoneName.getText())'/> + </cell> + </row> + <row> + <cell columns='2' fill='horizontal' weightx='1.0'> + <JLabel enabled='{isActive()}' text="isisfish.zone.cells"/> + </cell> + </row> + <row> + <cell columns='2' fill='both' weighty='0.7' weightx='1.0'> + <JScrollPane id="spZoneCells"> + <JList id="zoneCells" enabled='{isActive()}' + onValueChanged='zoneCellsChange(event)' decorator='boxed'/> + </JScrollPane> + </cell> + </row> + <row> + <cell columns='2' fill='horizontal' weightx='1.0'> + <JLabel enabled='{isActive()}' text="isisfish.zone.comments"/> + </cell> + </row> + <row> + <cell columns='2' fill='both' weighty='0.3' weightx='1.0'> + <JScrollPane> + <JTextArea id="fieldZoneComment" + text='{jaxx.runtime.SwingUtil.getStringValue(getBean().getComment())}' + enabled='{isActive()}' + decorator='boxed' + onKeyReleased='getBean().setComment(fieldZoneComment.getText())'/> + </JScrollPane> + </cell> + </row> + <row> + <cell fill='horizontal' weightx='0.5'> + <JButton id='save' decorator='boxed' + text="isisfish.common.save" + enabled="{validator.isValid() && validator.isChanged()}" + onActionPerformed="getSaveVerifier().save();validator.setChanged(false);"/> + </cell> + <cell fill='horizontal' weightx='0.5'> + <JButton id='cancel' decorator='boxed' + text="isisfish.common.cancel" + enabled="{validator.isChanged()}" + onActionPerformed="getSaveVerifier().cancel()"/> + </cell> + </row> + <row> + <cell fill='horizontal' weightx='0.5'> + <JButton id='create' decorator='boxed' + text="isisfish.common.new" + enabled="{!validator.isChanged()}" + onActionPerformed="getSaveVerifier().create(Zone.class)"/> + </cell> + <cell fill='horizontal' weightx='0.5'> + <JButton id='delete' decorator='boxed' + text="isisfish.common.remove" + enabled="{!validator.isChanged() && getBean() != null}" + onActionPerformed="getSaveVerifier().delete()"/> + </cell> + </row> + </Table> + <JPanel id='map' layout='{new BorderLayout()}'> + <com.bbn.openmap.gui.ToolPanel id='toolMap' + javaBean='new com.bbn.openmap.gui.ToolPanel()' + decorator='boxed' constraints='BorderLayout.NORTH'/> + <fr.ifremer.isisfish.map.IsisMapBean id='zoneMap' + javaBean='new fr.ifremer.isisfish.map.IsisMapBean()' + selectionMode="{fr.ifremer.isisfish.map.CellSelectionLayer.MULT_SELECTION}" + fisheryRegion='{getFisheryRegion()}' selectedCells='{getBean()==null?null:bean.getCell()}' + decorator='boxed' constraints='BorderLayout.CENTER'/> + <!-- FIXME echatellier 20110429 : binding --> + </JPanel> + </JSplitPane> + </JPanel> +</fr.ifremer.isisfish.ui.input.InputContentUI> Modified: branches/4.1/src/main/java/fr/ifremer/isisfish/ui/input/ZoneUI.jaxx =================================================================== --- branches/4.1/src/main/java/fr/ifremer/isisfish/ui/input/ZoneUI.jaxx 2012-02-13 14:55:15 UTC (rev 3603) +++ branches/4.1/src/main/java/fr/ifremer/isisfish/ui/input/ZoneUI.jaxx 2012-02-14 16:48:29 UTC (rev 3604) @@ -5,7 +5,7 @@ $Id$ $HeadURL$ %% - Copyright (C) 2009 - 2010 Ifremer, Code Lutin + Copyright (C) 2012 Ifremer, Code Lutin, Chatellier Eric %% This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as @@ -22,187 +22,50 @@ <http://www.gnu.org/licenses/gpl-2.0.html>. #L% --> -<fr.ifremer.isisfish.ui.input.InputContentUI superGenericType='Zone'> +<fr.ifremer.isisfish.ui.input.InputContentUI superGenericType='fr.ifremer.isisfish.entities.Zone'> - <!-- bean property --> <fr.ifremer.isisfish.entities.Zone id='bean' javaBean='null'/> <import> static org.nuiton.i18n.I18n.n_ - javax.swing.event.ListSelectionEvent - fr.ifremer.isisfish.entities.Cell - fr.ifremer.isisfish.entities.Zone - fr.ifremer.isisfish.map.CellSelectionLayer - fr.ifremer.isisfish.map.CopyMapToClipboardListener - fr.ifremer.isisfish.ui.input.model.TopiaEntityListModel - com.bbn.openmap.event.SelectMouseMode - com.bbn.openmap.gui.Tool - com.bbn.openmap.gui.OMToolSet - java.beans.PropertyChangeEvent - java.beans.PropertyChangeListener - java.awt.event.MouseEvent - java.util.ArrayList + java.beans.PropertyChangeEvent; + java.beans.PropertyChangeListener; </import> - - <BeanValidator id='validator' - bean='{getBean()}' beanClass='fr.ifremer.isisfish.entities.Zone' - uiClass="jaxx.runtime.validator.swing.ui.ImageValidationUI"> - <field name="name" component="fieldZoneName" /> - <field name="cell" component="spZoneCells" /> - </BeanValidator> - <script><![CDATA[ -protected OMToolSet toolSet = new OMToolSet(); protected void $afterCompleteSetup() { setButtonTitle(_("isisfish.input.continuePorts")); setNextPath(n_("isisfish.input.tree.ports")); - toolSet.setupListeners(zoneMap); - toolMap.add((Tool)toolSet); - - // add copy to clipboard support - zoneMap.addMapMouseListener(new CopyMapToClipboardListener(zoneMap)); - new OpenMapEvents(zoneMap, new SelectMouseMode(false), CellSelectionLayer.MULT_SELECTION) { - @Override - public boolean mouseClicked(MouseEvent e) { - boolean result = false; - if (getBean() != null) { // impossible de desactiver la carte :( - getBean().setCell(zoneMap.getSelectedCells()); - setZoneCells(); - } - return result; - } - }; - - addPropertyChangeListener(PROPERTY_BEAN, new PropertyChangeListener() { - public void propertyChange(PropertyChangeEvent evt) { - if (evt.getNewValue() == null) { - fieldZoneName.setText(""); - fieldZoneComment.setText(""); - zoneMap.setSelectedCells(); - } - if (evt.getNewValue() != null) { - setZoneCells(); - } - } - }); + // install change listener + // (depends on sensitivity can't be done on constructor) + installChangeListener(zoneTab); } -protected void setZoneCells() { - if (getBean() != null) { - List<Cell> cells = getFisheryRegion().getCell(); - TopiaEntityListModel model = new TopiaEntityListModel(cells); - zoneCells.setModel(model); - if (getBean().getCell() != null) { - for (Cell selectedCell : getBean().getCell()) { - int index = cells.indexOf(selectedCell); - zoneCells.addSelectionInterval(index, index); - } - } - } +@Override +public void setLayer(boolean active) { + super.setLayer(active); + zoneBasicsUI.setLayer(active); + variablesUI.setLayer(active); } -protected void zoneCellsChange(ListSelectionEvent event) { - // sans ca, ca boucle (modification depuis la carte) - if (event.getValueIsAdjusting()) { - // pas a faie dans le cas d'une AS - if (isActive()) { - java.util.List<Cell> cells = new ArrayList<Cell>(); - for (Object o : zoneCells.getSelectedValues()) { - cells.add((Cell) o); - } - getBean().setCell(cells); - } - } +@Override +public void resetChangeModel() { + zoneBasicsUI.resetChangeModel(); + variablesUI.resetChangeModel(); } -]]> - </script> - <JPanel id='body'> - <JSplitPane oneTouchExpandable="true" dividerLocation="200" orientation="horizontal"> - <Table> - <row> - <cell columns='2' fill='horizontal' weightx='1.0'> - <JLabel enabled='{isActive()}' text="isisfish.zone.name"/> - </cell> - </row> - <row> - <cell columns='2' fill='horizontal' weightx='1.0'> - <JTextField id="fieldZoneName" - text='{jaxx.runtime.SwingUtil.getStringValue(getBean().getName())}' - enabled='{isActive()}' decorator='boxed' - onKeyReleased='getBean().setName(fieldZoneName.getText())'/> - </cell> - </row> - <row> - <cell columns='2' fill='horizontal' weightx='1.0'> - <JLabel enabled='{isActive()}' text="isisfish.zone.cells"/> - </cell> - </row> - <row> - <cell columns='2' fill='both' weighty='0.7' weightx='1.0'> - <JScrollPane id="spZoneCells"> - <JList id="zoneCells" enabled='{isActive()}' - onValueChanged='zoneCellsChange(event)' decorator='boxed'/> - </JScrollPane> - </cell> - </row> - <row> - <cell columns='2' fill='horizontal' weightx='1.0'> - <JLabel enabled='{isActive()}' text="isisfish.zone.comments"/> - </cell> - </row> - <row> - <cell columns='2' fill='both' weighty='0.3' weightx='1.0'> - <JScrollPane> - <JTextArea id="fieldZoneComment" - text='{jaxx.runtime.SwingUtil.getStringValue(getBean().getComment())}' - enabled='{isActive()}' - decorator='boxed' - onKeyReleased='getBean().setComment(fieldZoneComment.getText())'/> - </JScrollPane> - </cell> - </row> - <row> - <cell fill='horizontal' weightx='0.5'> - <JButton id='save' decorator='boxed' - text="isisfish.common.save" - enabled="{validator.isValid() && validator.isChanged()}" - onActionPerformed="getSaveVerifier().save();validator.setChanged(false);"/> - </cell> - <cell fill='horizontal' weightx='0.5'> - <JButton id='cancel' decorator='boxed' - text="isisfish.common.cancel" - enabled="{validator.isChanged()}" - onActionPerformed="getSaveVerifier().cancel()"/> - </cell> - </row> - <row> - <cell fill='horizontal' weightx='0.5'> - <JButton id='create' decorator='boxed' - text="isisfish.common.new" - enabled="{!validator.isChanged()}" - onActionPerformed="getSaveVerifier().create(Zone.class)"/> - </cell> - <cell fill='horizontal' weightx='0.5'> - <JButton id='delete' decorator='boxed' - text="isisfish.common.remove" - enabled="{!validator.isChanged() && getBean() != null}" - onActionPerformed="getSaveVerifier().delete()"/> - </cell> - </row> - </Table> - <JPanel id='map' layout='{new BorderLayout()}'> - <com.bbn.openmap.gui.ToolPanel id='toolMap' - javaBean='new com.bbn.openmap.gui.ToolPanel()' - decorator='boxed' constraints='BorderLayout.NORTH'/> - <fr.ifremer.isisfish.map.IsisMapBean id='zoneMap' - javaBean='new fr.ifremer.isisfish.map.IsisMapBean()' - selectionMode="{fr.ifremer.isisfish.map.CellSelectionLayer.MULT_SELECTION}" - fisheryRegion='{getFisheryRegion()}' selectedCells='{getBean()==null?null:bean.getCell()}' - decorator='boxed' constraints='BorderLayout.CENTER'/> - <!-- FIXME echatellier 20110429 : binding --> - </JPanel> - </JSplitPane> + ]]></script> + <JPanel id="body"> + <JTabbedPane constraints='BorderLayout.CENTER' id="zoneTab"> + <tab title='isisfish.gear.title'> + <ZoneBasicsUI id="zoneBasicsUI" bean="{getBean()}" active="{isActive()}" + sensitivity="{isSensitivity()}" constructorParams='this' /> + </tab> + <tab title='isisfish.variables.tabtitle'> + <fr.ifremer.isisfish.ui.input.variable.EntityVariableUI id="variablesUI" + bean="{getBean()}" active="{isActive()}" + sensitivity="{isSensitivity()}" constructorParams='this'/> + </tab> + </JTabbedPane> </JPanel> -</fr.ifremer.isisfish.ui.input.InputContentUI> +</fr.ifremer.isisfish.ui.input.InputContentUI> \ No newline at end of file Modified: branches/4.1/src/main/java/fr/ifremer/isisfish/ui/input/model/TopiaEntityListModel.java =================================================================== --- branches/4.1/src/main/java/fr/ifremer/isisfish/ui/input/model/TopiaEntityListModel.java 2012-02-13 14:55:15 UTC (rev 3603) +++ branches/4.1/src/main/java/fr/ifremer/isisfish/ui/input/model/TopiaEntityListModel.java 2012-02-14 16:48:29 UTC (rev 3604) @@ -50,15 +50,30 @@ /** Zones list */ protected List<? extends TopiaEntity> entities; + public TopiaEntityListModel() { + + } + /** * Constructor with entities list. * * @param entities entities list */ public TopiaEntityListModel(List<? extends TopiaEntity> entities) { + this(); this.entities = entities; } + /** + * Update model entities list. + * + * @param entities entities + */ + public void setEntities(List<? extends TopiaEntity> entities) { + this.entities = entities; + fireContentsChanged(this, 0, entities == null ? 0 : entities.size() - 1); + } + /* * @see javax.swing.ListModel#getElementAt(int) */ Added: branches/4.1/src/main/java/fr/ifremer/isisfish/ui/input/variable/EntityVariableHandler.java =================================================================== --- branches/4.1/src/main/java/fr/ifremer/isisfish/ui/input/variable/EntityVariableHandler.java (rev 0) +++ branches/4.1/src/main/java/fr/ifremer/isisfish/ui/input/variable/EntityVariableHandler.java 2012-02-14 16:48:29 UTC (rev 3604) @@ -0,0 +1,162 @@ +/* + * #%L + * + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2012 Ifremer, Codelutin, Chatellier Eric + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation, either version 3 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 Lesser Public License for more details. + * + * You should have received a copy of the GNU General Lesser Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/lgpl-3.0.html>. + * #L% + */ + +package fr.ifremer.isisfish.ui.input.variable; + +import static org.nuiton.i18n.I18n._; + +import java.awt.CardLayout; +import java.util.List; + +import javax.swing.JList; + +import org.nuiton.topia.TopiaContext; +import org.nuiton.topia.TopiaException; +import org.nuiton.topia.persistence.TopiaEntity; + +import fr.ifremer.isisfish.IsisFishDAOHelper; +import fr.ifremer.isisfish.IsisFishRuntimeException; +import fr.ifremer.isisfish.entities.Equation; +import fr.ifremer.isisfish.entities.EquationImpl; +import fr.ifremer.isisfish.entities.Variable; +import fr.ifremer.isisfish.entities.VariableDAO; +import fr.ifremer.isisfish.ui.input.model.TopiaEntityListModel; + +/** + * Handler for generic variable ui. + * + * @author chatellier + * @version $Revision$ + * + * Last update : $Date$ + * By : $Author$ + */ +public class EntityVariableHandler { + + /** + * Init view with currently entity variables. + * + * @param view view + */ + public void initView(EntityVariableUI view) { + + List<Variable> variables = null; + TopiaEntityListModel model = (TopiaEntityListModel)view.getVariablesList().getModel(); + TopiaEntity bean = view.getBean(); + if (bean != null) { + try { + TopiaContext context = view.getTopiaContext(); + VariableDAO dao = IsisFishDAOHelper.getVariableDAO(context); + variables = dao.findAllByEntityId(bean.getTopiaId()); + } catch (TopiaException ex) { + throw new IsisFishRuntimeException("Can't init view", ex); + } + } + + model.setEntities(variables); + } + + /** + * Add new variable into list. + * + * @param view view + */ + public void addNewVariable(EntityVariableUI view) { + try { + TopiaContext context = view.getTopiaContext(); + VariableDAO dao = IsisFishDAOHelper.getVariableDAO(context); + + Variable variable = dao.create("name", _("isisfish.variables.defaultname"), + "type", "double"); + + TopiaEntityListModel model = (TopiaEntityListModel)view.getVariablesList().getModel(); + List<Variable> variables = (List<Variable>)model.getElements(); + variables.add(variable); + model.setEntities(variables); + } catch (TopiaException ex) { + throw new IsisFishRuntimeException("Can't add variable", ex); + } + } + + /** + * Display selected variable for edition. + * + * @param view view + */ + public void showSelectedVariable(EntityVariableUI view) { + + JList variableList = view.getVariablesList(); + Variable variable = (Variable)variableList.getSelectedValue(); + if (variable != null) { + view.getVariableNameField().setText(variable.getName()); + view.getVariableTypeCombo().setSelectedItem(variable.getType()); + } + + } + + /** + * Display card layout part associated with selected type. + * + * @param view view + */ + public void showSelectedType(EntityVariableUI view) { + CardLayout cardLayout = view.getVariableTypeLayout(); + String type = (String)view.getVariableTypeCombo().getSelectedItem(); + if ("double".equals(type)) { + cardLayout.show(view.getVariableTypePanel(), "doubletype"); + } else if ("matrix".equals(type)) { + cardLayout.show(view.getVariableTypePanel(), "matrixtype"); + } else if ("equation".equals(type)) { + cardLayout.show(view.getVariableTypePanel(), "equationtype"); + } + } + + /** + * Save current edited variable. + * + * @param view view + */ + public void saveVariable(EntityVariableUI view) { + JList variableList = view.getVariablesList(); + Variable variable = (Variable)variableList.getSelectedValue(); + variable.setName(view.getVariableNameField().getText().trim()); + + String type = (String)view.getVariableTypeCombo().getSelectedItem(); + variable.setType((String)view.getVariableTypeCombo().getSelectedItem()); + + if ("double".equals(type)) { + variable.setDoubleValue(0); + } else if ("matrix".equals(type)) { + variable.setMatrixValue(view.getMatrixPanel().getMatrix()); + } else if ("equation".equals(type)) { + Equation eq = variable.getEquationValue(); + if (eq == null) { + eq = new EquationImpl(); + } + eq.setContent(view.getVariableDoubleValue().getText()); + variable.setEquationValue(eq); + } + } +} Property changes on: branches/4.1/src/main/java/fr/ifremer/isisfish/ui/input/variable/EntityVariableHandler.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: branches/4.1/src/main/java/fr/ifremer/isisfish/ui/input/variable/EntityVariableUI.jaxx =================================================================== --- branches/4.1/src/main/java/fr/ifremer/isisfish/ui/input/variable/EntityVariableUI.jaxx (rev 0) +++ branches/4.1/src/main/java/fr/ifremer/isisfish/ui/input/variable/EntityVariableUI.jaxx 2012-02-14 16:48:29 UTC (rev 3604) @@ -0,0 +1,135 @@ +<!-- + #%L + IsisFish + + $Id$ + $HeadURL$ + %% + Copyright (C) 2012 Ifremer, Code Lutin, Chatellier Eric + %% + 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, see + <http://www.gnu.org/licenses/gpl-2.0.html>. + #L% + --> +<fr.ifremer.isisfish.ui.input.InputContentUI superGenericType='org.nuiton.topia.persistence.TopiaEntityContextable'> + + <EntityVariableHandler id="varHandler" /> + + <!-- bean property --> + <org.nuiton.topia.persistence.TopiaEntityContextable id='bean' javaBean='null'/> + + <script><![CDATA[ + protected void $afterCompleteSetup() { + addPropertyChangeListener(PROPERTY_BEAN, new java.beans.PropertyChangeListener() { + public void propertyChange(java.beans.PropertyChangeEvent evt) { + varHandler.initView(EntityVariableUI.this); + } + }); + } + ]]></script> + + <Table> + <row> + <cell fill="both" weightx='1.0' weighty='1.0'> + <Table border='{BorderFactory.createTitledBorder(_("isisfish.variables.variableslist"))}'> + <row> + <cell fill="both" weightx='1.0' weighty='1.0'> + <JScrollPane> + <JList id="variablesList" cellRenderer="{new VariableListRenderer()}" + model="{new fr.ifremer.isisfish.ui.input.model.TopiaEntityListModel()}" + onValueChanged="getVarHandler().showSelectedVariable(this)"/> + </JScrollPane> + </cell> + </row> + <row> + <cell fill="horizontal"> + <JButton text="isisfish.variables.addvariable" onActionPerformed="getVarHandler().addNewVariable(this)" /> + </cell> + </row> + </Table> + </cell> + <cell fill="both" weightx='3.0' weighty='1.0' rows="2"> + <Table border='{BorderFactory.createTitledBorder(_("isisfish.variables.variabledetail"))}'> + <row> + <cell fill="horizontal"> + <JLabel text="isisfish.variables.variablename" /> + </cell> + <cell fill="horizontal" weightx='1.0'> + <JTextField id="variableNameField" /> + </cell> + </row> + <row> + <cell fill="horizontal"> + <JLabel text="isisfish.variables.variabletype" /> + </cell> + <cell fill="horizontal" weightx='1.0'> + <JComboBox id="variableTypeCombo" model="{new VariableTypeComboModel()}" + onActionPerformed="getVarHandler().showSelectedType(this)"/> + </cell> + </row> + <row> + <cell columns="2" fill="both" weightx='1.0' weighty='1.0'> + <CardLayout id="variableTypeLayout" /> + + <JPanel id="variableTypePanel" layout="{variableTypeLayout}"> + <!-- double --> + <Table constraints='"doubletype"'> + <row> + <cell fill="horizontal" anchor="northeast" weighty='1.0'> + <JLabel text="isisfish.variables.double.value" /> + </cell> + <cell fill="horizontal" weightx='1.0' anchor="northeast" weighty='1.0'> + <JTextField id="variableDoubleValue" /> + </cell> + </row> + </Table> + + <!-- matrix --> + <Table constraints='"matrixtype"'> + <row> + <cell fill="horizontal"> + <JLabel text="isisfish.variables.matrix.value" /> + </cell> + </row> + <row> + <cell fill="both" weightx='1.0' weighty='1.0'> + <org.nuiton.math.matrix.gui.MatrixPanelEditor id="matrixPanel" /> + </cell> + </row> + </Table> + + <!-- equation --> + <Table constraints='"equationtype"'> + <row> + <cell fill="both" weightx='1.0' weighty='1.0'> + <fr.ifremer.isisfish.ui.input.InputOneEquationUI id="variableEquationValue" /> + </cell> + </row> + </Table> + </JPanel> + </cell> + </row> + <row> + <cell anchor="west"> + <JButton text="isisfish.variables.deletevariable" /> + </cell> + <cell anchor="east" weightx='1.0'> + <JButton text="isisfish.variables.savevariable" /> + </cell> + </row> + </Table> + </cell> + </row> + </Table> +</fr.ifremer.isisfish.ui.input.InputContentUI> \ No newline at end of file Added: branches/4.1/src/main/java/fr/ifremer/isisfish/ui/input/variable/VariableListRenderer.java =================================================================== --- branches/4.1/src/main/java/fr/ifremer/isisfish/ui/input/variable/VariableListRenderer.java (rev 0) +++ branches/4.1/src/main/java/fr/ifremer/isisfish/ui/input/variable/VariableListRenderer.java 2012-02-14 16:48:29 UTC (rev 3604) @@ -0,0 +1,69 @@ +/* + * #%L + * IsisFish + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Ifremer, CodeLutin + * %% + * 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, see + * <http://www.gnu.org/licenses/gpl-2.0.html>. + * #L% + */ + +package fr.ifremer.isisfish.ui.input.variable; + +import java.awt.Component; + +import javax.swing.DefaultListCellRenderer; +import javax.swing.JLabel; +import javax.swing.JList; + +import fr.ifremer.isisfish.entities.Variable; + +/** + * Renderer pour liste des trip types. + * + * @author chatellier + * @version $Revision$ + * + * Last update : $Date$ + * By : $Author$ + */ +public class VariableListRenderer extends DefaultListCellRenderer { + + /** serialVersionUID. */ + private static final long serialVersionUID = 1113492654780402245L; + + /* + * @see javax.swing.ListCellRenderer#getListCellRendererComponent(javax.swing.JList, java.lang.Object, int, boolean, boolean) + */ + @Override + public Component getListCellRendererComponent(JList list, Object value, + int index, boolean isSelected, boolean cellHasFocus) { + + // this must be used to have alternated highlight rows and default + // selection color + JLabel c = (JLabel) super.getListCellRendererComponent(list, value, + index, isSelected, cellHasFocus); + + Variable variable = (Variable) value; + if (variable != null) { + c.setText(variable.getName()); + } + + return c; + } +} Property changes on: branches/4.1/src/main/java/fr/ifremer/isisfish/ui/input/variable/VariableListRenderer.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: branches/4.1/src/main/java/fr/ifremer/isisfish/ui/input/variable/VariableTypeComboModel.java =================================================================== --- branches/4.1/src/main/java/fr/ifremer/isisfish/ui/input/variable/VariableTypeComboModel.java (rev 0) +++ branches/4.1/src/main/java/fr/ifremer/isisfish/ui/input/variable/VariableTypeComboModel.java 2012-02-14 16:48:29 UTC (rev 3604) @@ -0,0 +1,80 @@ +/* + * #%L + * IsisFish + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2012 Ifremer, CodeLutin, Chatellier Eric + * %% + * 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, see + * <http://www.gnu.org/licenses/gpl-2.0.html>. + * #L% + */ + +package fr.ifremer.isisfish.ui.input.variable; + +import java.util.ArrayList; +import java.util.List; + +import javax.swing.DefaultComboBoxModel; + +/** + * Modele pour la liste des type possible de variable. + * + * @author chatellier + * @version $Revision$ + * + * Last update : $Date$ + * By : $Author$ + */ +public class VariableTypeComboModel extends DefaultComboBoxModel { + + /** serialVersionUID. */ + private static final long serialVersionUID = 6171850179969290032L; + + /** Values list */ + protected List<String> variableTypes; + + /** + * Empty constructor. + */ + public VariableTypeComboModel() { + variableTypes = new ArrayList<String>(); + variableTypes.add("double"); + variableTypes.add("equation"); + variableTypes.add("matrix"); + } + + /* + * @see javax.swing.ListModel#getElementAt(int) + */ + @Override + public Object getElementAt(int index) { + return variableTypes.get(index); + } + + /* + * @see javax.swing.ListModel#getSize() + */ + @Override + public int getSize() { + int size = 0; + + if (variableTypes != null) { + size = variableTypes.size(); + } + return size; + } +} Property changes on: branches/4.1/src/main/java/fr/ifremer/isisfish/ui/input/variable/VariableTypeComboModel.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Modified: branches/4.1/src/main/resources/i18n/isis-fish_en_GB.properties =================================================================== --- branches/4.1/src/main/resources/i18n/isis-fish_en_GB.properties 2012-02-13 14:55:15 UTC (rev 3603) +++ branches/4.1/src/main/resources/i18n/isis-fish_en_GB.properties 2012-02-14 16:48:29 UTC (rev 3604) @@ -64,7 +64,7 @@ destination\ already\ exists\ %s\ use\ 'force'\ argument\ to\ force\ overwrite= destination\ already\ exists\ %s\ use\ \\'force\\'\ argument\ to\ force\ overwrite= filter\ loaded\ in\ %1$s\ ms\ \:\ found\ %2$s\ lines.=filter loaded in %1$s ms \: found %2$s lines. -isisfish.about.abouthtmltext=<html><b>ISIS-Fish (%s)</b><br /><br />Copyright IFREMER-MAERHA 2000-2011.<br /><br /><a href\="http\://www.isis-fish.org">http\://www.isis-fish.org</a><br /><br />Please, report any bug you can found.<html> +isisfish.about.abouthtmltext=<html><b>ISIS-Fish (%s)</b><br /><br />Copyright IFREMER-MAERHA 2000-2012.<br /><br /><a href\="http\://www.isis-fish.org">http\://www.isis-fish.org</a><br /><br />Please, report any bug you can found.<html> isisfish.about.licensetext=You can modify and redistribute the program under the conditions of the GNU General Public License (version 2 or later). A copy of the GPL is in the file "LICENSE.txt" provided with ISIS-Fish. All rights reserved. No guarantees are provided for use of this program. isisfish.about.title=About ISIS-Fish... isisfish.advancedParameters.title=Advanced parameters @@ -967,6 +967,18 @@ isisfish.tripType.name=Name isisfish.ui.script.communityvcs=Community VCS isisfish.ui.script.officialvcs=Official VCS +isisfish.variables.addvariable=Add +isisfish.variables.defaultname=VarName +isisfish.variables.deletevariable=Delete +isisfish.variables.double.value=Real value \: +isisfish.variables.equation.value=Equation \: +isisfish.variables.matrix.value=Matrix \: +isisfish.variables.savevariable=Save +isisfish.variables.tabtitle=Variables +isisfish.variables.variabledetail=Variable details +isisfish.variables.variablename=Variable name \: +isisfish.variables.variableslist=Variables +isisfish.variables.variabletype=Variable type isisfish.vcs.ask.passphrase=Enter your pass phrase (if your private key have one). isisfish.vcs.ask.passphrase.title=Ask your pass phrase isisfish.vcs.commit=vcs.commit Modified: branches/4.1/src/main/resources/i18n/isis-fish_fr_FR.properties =================================================================== --- branches/4.1/src/main/resources/i18n/isis-fish_fr_FR.properties 2012-02-13 14:55:15 UTC (rev 3603) +++ branches/4.1/src/main/resources/i18n/isis-fish_fr_FR.properties 2012-02-14 16:48:29 UTC (rev 3604) @@ -64,7 +64,7 @@ destination\ already\ exists\ %s\ use\ 'force'\ argument\ to\ force\ overwrite= destination\ already\ exists\ %s\ use\ \\'force\\'\ argument\ to\ force\ overwrite= filter\ loaded\ in\ %1$s\ ms\ \:\ found\ %2$s\ lines.=filter loaded in %1$s ms \: found %2$s lines. -isisfish.about.abouthtmltext=<html><b>ISIS-Fish (%s)</b><br /><br />Copyright IFREMER-MAERHA 2000-2011.<br /><br /><a href\="http\://www.isis-fish.org">http\://www.isis-fish.org</a><br /><br />Merci de rapporter les bugs.<html> +isisfish.about.abouthtmltext=<html><b>ISIS-Fish (%s)</b><br /><br />Copyright IFREMER-MAERHA 2000-2012.<br /><br /><a href\="http\://www.isis-fish.org">http\://www.isis-fish.org</a><br /><br />Merci de rapporter les bugs.<html> isisfish.about.licensetext=Vous pouvez modifier et redistribuer ce programme sous les conditions énoncées par la licence GNU GPL (version 2 ou ultérieure). Une copie de la licence GPL est dans le fichier « LICENSE.txt » fourni avec ISIS-Fish. Tous droits réservés. Aucune garantie n'est fournie pour l'utilisation de ce programme. isisfish.about.title=À propos de ISIS-Fish... isisfish.advancedParameters.title=Paramètres avancés @@ -967,6 +967,18 @@ isisfish.tripType.name=Nom isisfish.ui.script.communityvcs=VCS Communauté isisfish.ui.script.officialvcs=VCS Officiel +isisfish.variables.addvariable=Ajouter +isisfish.variables.defaultname=VarName +isisfish.variables.deletevariable=Supprimer +isisfish.variables.double.value=Valeur réelle \: +isisfish.variables.equation.value=Equation +isisfish.variables.matrix.value=Matrice +isisfish.variables.savevariable=Sauver +isisfish.variables.tabtitle=Variables +isisfish.variables.variabledetail=Détail +isisfish.variables.variablename=Nom de la variable \: +isisfish.variables.variableslist=Variables +isisfish.variables.variabletype=Type \: isisfish.vcs.ask.passphrase=Entrez votre passphrase (si votre clef ssh en contient une). isisfish.vcs.ask.passphrase.title=Demande de passe phrase isisfish.vcs.commit=Message de sauvegarde Modified: branches/4.1/src/main/xmi/isis-fish.zargo =================================================================== (Binary files differ)