r1579 - in isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui: . input result simulator
Author: sletellier Date: 2008-10-30 17:47:57 +0000 (Thu, 30 Oct 2008) New Revision: 1579 Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/Common.java isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/CellUI.jaxx isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/GearTabUI.jaxx isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/GearUI.jaxx isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputAction.java isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputUI.jaxx isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/MetierSeasonInfoSpeciesUI.jaxx isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/MetierSeasonInfoZoneUI.jaxx isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/MetierTabUI.jaxx isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/MetierUI.jaxx isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/PortUI.jaxx isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/SelectivityUI.jaxx isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/SpeciesUI.jaxx isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/ZoneUI.jaxx isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/result/ResultUI.jaxx isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/ParamsUI.jaxx Log: InputUI in progress Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/Common.java =================================================================== --- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/Common.java 2008-10-28 11:34:42 UTC (rev 1578) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/Common.java 2008-10-30 17:47:57 UTC (rev 1579) @@ -85,5 +85,6 @@ Logger.getLogger(Common.class.getName()).log(Level.SEVERE, null, ex); } return null; - } + } + } Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/CellUI.jaxx =================================================================== --- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/CellUI.jaxx 2008-10-28 11:34:42 UTC (rev 1578) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/CellUI.jaxx 2008-10-30 17:47:57 UTC (rev 1579) @@ -36,11 +36,91 @@ +--> <Table> <script><![CDATA[ + import fr.ifremer.isisfish.entities.Cell; + import com.bbn.openmap.gui.OMToolSet; + import fr.ifremer.isisfish.map.IsisMapBean; + import fr.ifremer.isisfish.map.OpenMapToolPanel; + import org.codelutin.topia.persistence.TopiaEntity; + import fr.ifremer.isisfish.entities.Zone; + import fr.ifremer.isisfish.ui.WelcomePanelUI; + + protected IsisMapBean cellMap = new IsisMapBean(); + protected OpenMapToolPanel toolMap = new OpenMapToolPanel(); + protected OMToolSet toolSet = new OMToolSet(); + protected boolean changed = false; + public CellUI (InputAction action){ setContextValue(action); } protected void refresh() { - } + Cell cell = getContextValue(InputAction.class).getCell(); + if (cell != null){ + DefaultComboBoxModel fieldCellModel = new DefaultComboBoxModel(); + java.util.List<Cell> cells = getContextValue(InputAction.class).getFisheryRegion().getCell(); + for (Cell c : cells){ + fieldCellModel.addElement(c); + } + fieldCell.setModel(fieldCellModel); + + fieldCellName.setText(cell.getName()); + fieldCellLatitude.setText(cell.getLatitude()+""); + fieldCellLongitude.setText(cell.getLongitude()+""); + fieldCellLand.setSelected(cell.getLand()); + fieldCellComment.setText(getContextValue(InputAction.class).getCell().getComment()); + + cellMap.setFisheryRegion(getContextValue(InputAction.class).getFisheryRegion()); + toolSet.setupListeners(cellMap); + toolMap.add((Component)toolSet); + cellMapPanel.add(toolMap, BorderLayout.NORTH); + cellMapPanel.add(cellMap, BorderLayout.CENTER); + cellMap.setSelectedCells(cell); + } + } + protected void save(){ + TopiaEntity topia = getContextValue(InputAction.class).save("Cell"); + getParentContainer(InputUI.class).setTreeSelection(topia, Cell.class); + setInfoText(_("isisfish.message.save.finished")); + refresh(); + valueChanged(false); + } + protected void cancel(){ + getContextValue(InputAction.class).cancel("Cell"); + setInfoText(_("isisfish.message.cancel.finished")); + valueChanged(false); + refresh(); + } + protected void goToZone(){ + getParentContainer(InputUI.class).setTreeSelection(null, Zone.class); + } + protected void valueChanged(boolean b){ + changed=b; + save.setEnabled(b); + cancel.setEnabled(b); + } + protected void setInfoText(String txt){ + WelcomePanelUI root = getParentContainer(WelcomePanelUI.class); + root.setInfoText(txt); + } + protected void fieldCellChanged(){ + Cell c = (Cell)fieldCell.getSelectedItem(); + getContextValue(InputAction.class).setValue(c, Cell.class); + getParentContainer(InputUI.class).setTreeSelection(c, Cell.class); + refresh(); + } + protected void nameChanged(){ + getContextValue(InputAction.class).getCell().setName(fieldCellName.getText()); + valueChanged(true); + refresh(); + } + protected void cellLandChanged(){ + getContextValue(InputAction.class).getCell().setLand(fieldCellLand.isSelected()); + valueChanged(true); + refresh(); + } + protected void commentChanged(){ + getContextValue(InputAction.class).getCell().setComment(fieldCellComment.getText()); + valueChanged(true); + } ]]> </script> <row> @@ -50,13 +130,7 @@ <Table> <row> <cell fill='horizontal' columns='2' weightx='1.0'> - <!-- Widget --> - <JComboBox id="fieldCell"/> -<!-- Fixme : ComboBoxModel -origin="$Cell" renderer="name" -actionCommand='UIHelper.setTreeSelection($tree, $treeModel, $fieldCell/selectedItem)' -<ComboBoxModel origin="$FisheryRegion/cell"/> ---> + <JComboBox id="fieldCell" onActionPerformed='fieldCellChanged()'/> </cell> </row> <row> @@ -64,24 +138,15 @@ <JLabel text="isisfish.cell.name"/> </cell> <cell fill='horizontal' weightx='1.0'> - <JTextField id="fieldCellName"/> -<!-- Fixme : DocumentEvents -origin="$Cell/name" - <DocumentEvents onModified="Update($fieldCellName/text)"/> ---> + <JTextField id="fieldCellName" onActionPerformed='nameChanged()'/> </cell> </row> <row> <cell> - - <JLabel text="isisfish.cell.latitude"/> </cell> <cell fill='horizontal' weightx='1.0'> <JTextField id="fieldCellLatitude" editable="false"/> -<!-- -origin="$Cell/latitude" ---> </cell> </row> <row> @@ -89,83 +154,45 @@ <JLabel text="isisfish.cell.longitude"/> </cell> <cell fill='horizontal' weightx='1.0'> - <JTextField id="fieldCellLongitude" editable="false"/> -<!-- -origin="$Cell/longitude" ---> + <JTextField id="fieldCellLongitude" editable="false"/> </cell> </row> <row> <cell> - - <JLabel text="isisfish.cell.land"/> </cell> <cell fill='horizontal' weightx='1.0'> - <JCheckBox id="fieldCellLand"/> -<!-- Fixme : ItemEvents -origin="$Cell/land" -<ItemEvents onStateChanged="Update($fieldCellLand/selected)"/> ---> + <JCheckBox id="fieldCellLand" onActionPerformed='cellLandChanged()'/> </cell> </row> <row> <cell columns='2' fill='horizontal'> - <JLabel text="isisfish.cell.comments"/> + <JLabel text="isisfish.cell.comments" onFocusLost='commentChanged()'/> </cell> </row> <row> <cell columns='2' fill='both' weighty='1.0' weightx='1.0'> <JScrollPane> - <JTextArea id="fieldCellComment"> -<!-- -origin="$Cell/comment" -<DocumentEvents onModified="Update($fieldCellComment/text)"/> ---> - </JTextArea> + <JTextArea id="fieldCellComment" onKeyPressed='commentChanged()'/> </JScrollPane> </cell> </row> <row> <cell fill='horizontal' weightx='0.5'> - <JButton text="isisfish.common.save"/> -<!-- -origin="$EntityModified" -actionCommand='input.Input.save("Cell", $Cell);refreshView($inputCell)' ---> + <JButton id='save' text="isisfish.common.save" enabled='false' onActionPerformed='save()'/> </cell> <cell fill='horizontal' weightx='0.5'> - <JButton text="isisfish.common.cancel"/> -<!-- -origin="$EntityModified" -actionCommand='input.Input.cancel("Cell", $Cell);refreshView($inputCell)' ---> + <JButton id='cancel' text="isisfish.common.cancel" enabled='false' onActionPerformed='cancel()'/> </cell> </row> </Table> - <JPanel id="cellMapPanel" layout='{new BorderLayout()}'/> -<!-- - <OpenMapToolPanel constraints='"BorderLayout.NORTH"' id="cellMapTool"> - <OpenMapToolSet id="cellMapToolSet" origin="$cellMap"/> - </OpenMapToolPanel> - <OpenMap constraints='"BorderLayout.CENTER"' id="cellMap" - origin="$FisheryRegion" selected="$Cell" selectionMode="1"> - <OpenMapEvents id="cellMapEvents" mouseMode="Select" - onMouseClicked="UIHelper.setTreeSelection($cellMap/selectedCells[1])"/> - </OpenMap> ---> </JSplitPane> - </cell> </row> <row> <cell fill='horizontal' weightx='1.0'> - <JButton text="isisfish.input.continueZones"/> -<!-- - actionCommand="UIHelper.setTreeSelection('Zones')" ---> - + <JButton text="isisfish.input.continueZones" onActionPerformed='goToZone()'/> </cell> </row> </Table> \ No newline at end of file Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/GearTabUI.jaxx =================================================================== --- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/GearTabUI.jaxx 2008-10-28 11:34:42 UTC (rev 1578) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/GearTabUI.jaxx 2008-10-30 17:47:57 UTC (rev 1579) @@ -31,6 +31,95 @@ */ --> <Table> + <script><![CDATA[ + import fr.ifremer.isisfish.entities.Gear; + import fr.ifremer.isisfish.ui.WelcomePanelUI; + import org.codelutin.topia.persistence.TopiaEntity; + import org.codelutin.topia.TopiaException; + + protected boolean changed = false; + public GearTabUI (InputAction action){ + setContextValue(action); + } + protected void refresh() { + Gear gear = getContextValue(InputAction.class).getGear(); + if (gear != null){ + fieldGearName.setText(gear.getName()); + fieldGearEffortUnit.setText(gear.getEffortUnit()); + fieldGearStandardisationFactor.setText(gear.getStandardisationFactor() + ""); + fieldGearParamName.setText(gear.getParameterName()); + DefaultComboBoxModel model = new DefaultComboBoxModel(fr.ifremer.isisfish.types.RangeOfValues.getPossibleTypes()); + fieldGearParamType.setModel(model); + fieldGearParamPossibleValue.setText(gear.getPossibleValue().getValues()); + fieldGearComment.setText(gear.getComment()); + } + } + protected void create(){ + TopiaEntity topia = getContextValue(InputAction.class).create("Gear"); + + getParentContainer(InputUI.class).setTreeModel(); + getParentContainer(InputUI.class).setTreeSelection(topia, Gear.class); + + setInfoText(_("isisfish.message.creation.finished")); + } + protected void save(){ + TopiaEntity topia = getContextValue(InputAction.class).save("Gear"); + getParentContainer(InputUI.class).setTreeSelection(topia, Gear.class); + setInfoText(_("isisfish.message.save.finished")); + refresh(); + valueChanged(false); + } + protected void cancel(){ + getContextValue(InputAction.class).cancel("Gear"); + setInfoText(_("isisfish.message.cancel.finished")); + valueChanged(false); + refresh(); + } + protected void remove(){ + setInfoText(getContextValue(InputAction.class).remove()); + valueChanged(false); + refresh(); + } + protected void setInfoText(String txt){ + WelcomePanelUI root = getParentContainer(WelcomePanelUI.class); + root.setInfoText(txt); + } + protected void valueChanged(boolean b){ + changed=b; + create.setEnabled(b); + save.setEnabled(b); + } + protected void nameChanged(){ + getContextValue(InputAction.class).getGear().setName(fieldGearName.getText()); + valueChanged(true); + } + protected void effortUnitChanged(){ + getContextValue(InputAction.class).getGear().setEffortUnit(fieldGearEffortUnit.getText()); + valueChanged(true); + } + protected void standardisationFactorChanged(){ + getContextValue(InputAction.class).getGear().setStandardisationFactor(Double.parseDouble(fieldGearStandardisationFactor.getText())); + valueChanged(true); + } + protected void paramNameChanged(){ + getContextValue(InputAction.class).getGear().setParameterName(fieldGearParamName.getSelectedText()); + valueChanged(true); + } + protected void paramTypeChanged(){ +// TODO +// getContextValue(InputAction.class).getGear().setParameterName(fieldGearParamName.getSelectedText()); +// valueChanged(true); + } + protected void paramPossibleValueChanged(){ + getContextValue(InputAction.class).getGear().setStandardisationFactor(Double.parseDouble(fieldGearParamPossibleValue.getText())); + valueChanged(true); + } + protected void commentChanged(){ + getContextValue(InputAction.class).getGear().setComment(fieldGearComment.getText()); + valueChanged(true); + } + ]]> + </script> <row> <cell fill='both' weightx='1.0' weighty='1.0'> <Table> @@ -39,7 +128,7 @@ <JLabel text="isisfish.gear.name"/> </cell> <cell columns="2" fill='horizontal' weightx='1.0'> - <JTextField id="fieldGearName"/> + <JTextField id="fieldGearName" onKeyTyped='nameChanged()'/> <!-- Fixme : DocumentEvents origin="$Gear/name" <DocumentEvents onModified="Update($fieldGearName/text)"/> @@ -51,7 +140,7 @@ <JLabel text="isisfish.gear.effortUnit"/> </cell> <cell columns="2" fill='horizontal' weightx='1.0'> - <JTextField id="fieldGearEffortUnit"/> + <JTextField id="fieldGearEffortUnit" onKeyTyped='effortUnitChanged()'/> <!-- Fixme : DocumentEvents origin="$Gear/effortUnit" <DocumentEvents onModified="Update($fieldGearEffortUnit/text)"/> @@ -63,7 +152,7 @@ <JLabel text="isisfish.gear.standardisationFactor"/> </cell> <cell columns="2" fill='horizontal' weightx='1.0'> - <JTextField id="fieldGearStandardisationFactor"/> + <JTextField id="fieldGearStandardisationFactor" onKeyTyped='standardisationFactorChanged()'/> <!-- Fixme : DocumentEvents origin="$Gear/standardisationFactor" <DocumentEvents onModified="Update($fieldGearStandardisationFactor/text)"/> @@ -75,7 +164,7 @@ <JLabel text="isisfish.gear.technicalParameter"/> </cell> <cell columns="2" fill='horizontal' weightx='1.0'> - <JTextField id="fieldGearParamName"/> + <JTextField id="fieldGearParamName" onKeyTyped='paramNameChanged()'/> <!-- Fixme : DocumentEvents origin="$Gear/parameterName"> <DocumentEvents onModified="Update($fieldGearParamName/text)"/> @@ -87,7 +176,7 @@ <JLabel text="isisfish.gear.rangeValues"/> </cell> <cell fill='horizontal' weightx='0.5'> - <JComboBox id="fieldGearParamType"/> + <JComboBox id="fieldGearParamType" onActionPerformed='paramTypeChanged()'/> <!-- Fixme : ComboBoxModel firstNull="true" origin="$Gear/possibleValue/type" @@ -96,7 +185,7 @@ --> </cell> <cell fill='horizontal' weightx='0.5'> - <JTextField id="fieldGearParamPossibleValue"/> + <JTextField id="fieldGearParamPossibleValue" onKeyTyped='paramPossibleValueChanged()'/> <!-- Fixme : DocumentEvents origin="$Gear/possibleValue/values" <DocumentEvents onModified="Update(concat($fieldGearParamType/selectedItem, '[', $fieldGearParamPossibleValue/text, ']'), $Gear/possibleValue)"/> @@ -109,7 +198,7 @@ </cell> <cell columns="2" fill='both' weightx='1.0' weighty='1.0'> <JScrollPane> - <JTextArea id="fieldGearComment"> + <JTextArea id="fieldGearComment" onKeyTyped='commentChanged()'> <!-- Fixme : DocumentEvents origin="$Gear/comment" <DocumentEvents onModified="Update($fieldGearComment/text)"/> @@ -126,14 +215,14 @@ <Table> <row> <cell fill='horizontal' weightx='0.5'> - <JButton text="isisfish.common.new"/> + <JButton id="create" text="isisfish.common.new" onActionPerformed='create()'/> <!-- origin="$FisheryRegion" actionCommand='input.Input.create("Gear")' --> </cell> <cell fill='horizontal' weightx='0.5'> - <JButton text="isisfish.common.save"/> + <JButton id="save" text="isisfish.common.save" onActionPerformed='save()'/> <!-- origin="$EntityModified" actionCommand='input.Input.save("Gear", $Gear);refreshView($inputGear)' @@ -142,14 +231,14 @@ </row> <row> <cell fill='horizontal' weightx='0.5'> - <JButton text="isisfish.common.cancel"/> + <JButton id='cancel' text="isisfish.common.cancel" onActionPerformed='cancel()'/> <!-- origin="$EntityModified" actionCommand='input.Input.cancel("Gear", $Gear);refreshView($inputGear)' --> </cell> <cell fill='horizontal' weightx='0.5'> - <JButton text="isisfish.common.remove"/> + <JButton id='remove' text="isisfish.common.remove" onActionPerformed='remove()'/> <!-- origin="$Gear" actionCommand="input.Input.remove($Gear)" Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/GearUI.jaxx =================================================================== --- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/GearUI.jaxx 2008-10-28 11:34:42 UTC (rev 1578) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/GearUI.jaxx 2008-10-30 17:47:57 UTC (rev 1579) @@ -37,24 +37,21 @@ +--> <JPanel layout='{new BorderLayout()}'> <script><![CDATA[ + import fr.ifremer.isisfish.entities.Metier; public GearUI (InputAction action){ setContextValue(action); } protected void refresh() { - } + gearTabUI.refresh(); + selectivityUI.refresh(); + } + protected void goToMetier(){ + getParentContainer(InputUI.class).setTreeSelection(null, Metier.class); + } ]]></script> <JTabbedPane constraints='BorderLayout.CENTER' id="GearTab" name="Gear"> - <tab title='{_("isisfish.gear.title")}'><GearTabUI/></tab> - <tab title='{_("isisfish.selectivity.title")}'><SelectivityUI/></tab> -<!-- - name="isisfish.gear.title" - name="isisfish.selectivity.title" - <xpanel xml="input/Gear.xml" id="inputGear"/> - <xpanel xml="input/Selectivity.xml" id="inputSelectivity"/> ---> + <tab title='{_("isisfish.gear.title")}'><GearTabUI id="gearTabUI" constructorParams='getContextValue(InputAction.class)'/></tab> + <tab title='{_("isisfish.selectivity.title")}'><SelectivityUI id="selectivityUI" constructorParams='getContextValue(InputAction.class)'/></tab> </JTabbedPane> - <JButton constraints='BorderLayout.SOUTH' text="isisfish.input.continueMetiers"/> -<!-- - actionCommand="UIHelper.setTreeSelection('Metiers')" ---> + <JButton constraints='BorderLayout.SOUTH' text="isisfish.input.continueMetiers" onActionPerformed='goToMetier()'/> </JPanel> 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-10-28 11:34:42 UTC (rev 1578) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputAction.java 2008-10-30 17:47:57 UTC (rev 1579) @@ -34,6 +34,9 @@ * and open the template in the editor. */ +import fr.ifremer.isisfish.IsisFishDAOHelper; +import fr.ifremer.isisfish.datastore.FormuleStorage; +import fr.ifremer.isisfish.datastore.StorageException; import java.util.List; import fr.ifremer.isisfish.datastore.RegionStorage; @@ -41,20 +44,31 @@ import fr.ifremer.isisfish.entities.FisheryRegion; import fr.ifremer.isisfish.entities.Gear; import fr.ifremer.isisfish.entities.Metier; +import fr.ifremer.isisfish.entities.Population; import fr.ifremer.isisfish.entities.Port; +import fr.ifremer.isisfish.entities.Selectivity; +import fr.ifremer.isisfish.entities.SelectivityDAO; import fr.ifremer.isisfish.entities.SetOfVessels; import fr.ifremer.isisfish.entities.Species; import fr.ifremer.isisfish.entities.Strategy; import fr.ifremer.isisfish.entities.TripType; import fr.ifremer.isisfish.entities.VesselType; import fr.ifremer.isisfish.entities.Zone; +import java.lang.reflect.Method; import java.util.ArrayList; +import java.util.logging.Level; +import java.util.logging.Logger; import javax.swing.JOptionPane; +import org.apache.commons.beanutils.MethodUtils; +import org.apache.commons.lang.ClassUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.codelutin.topia.TopiaContext; +import org.codelutin.topia.persistence.TopiaDAO; import org.codelutin.topia.persistence.TopiaEntity; +import org.codelutin.widget.editor.Editor; import static org.codelutin.i18n.I18nf._; +import static javax.swing.JOptionPane.showInputDialog; /** * @@ -84,28 +98,33 @@ } public void setValue(Object value, Class type) { - if (type == Zone.class){ - zone = (Zone) value; - } else if (type == Cell.class){ - cell = (Cell) value; - } else if (type == Port.class){ - port = (Port) value; - } else if (type == Species.class){ - species = (Species) value; - } else if (type == Gear.class){ - gear = (Gear) value; - } else if (type == Metier.class){ - metier = (Metier) value; - } else if (type == TripType.class){ - tripType = (TripType) value; - } else if (type == VesselType.class){ - vesselType = (VesselType) value; - } else if (type == SetOfVessels.class){ - setOfVessels = (SetOfVessels) value; - } else if (type == Strategy.class){ - strategy = (Strategy) value; - } + if (type == Zone.class) { + zone = (Zone) value; + } else if (type == Cell.class) { + cell = (Cell) value; + } else if (type == Port.class) { + port = (Port) value; + } else if (type == Species.class) { + species = (Species) value; + } else if (type == Gear.class) { + gear = (Gear) value; + } else if (type == Metier.class) { + metier = (Metier) value; + } else if (type == TripType.class) { + tripType = (TripType) value; + } else if (type == VesselType.class) { + vesselType = (VesselType) value; + } else if (type == SetOfVessels.class) { + setOfVessels = (SetOfVessels) value; + } else if (type == Strategy.class) { + strategy = (Strategy) value; + } + selected = (TopiaEntity) value; + selectedType = type; } + public TopiaContext getIsisContext(){ + return isisContext; + } /** * load region. @@ -204,7 +223,218 @@ // return result; } + /** + * Permet de creer simplement un nouvelle objet portant un nom par defaut. + * Le nouvel element est automatiquement selectionné dans l'arbre + * + * @param frame + * @param isisContext + * (auto) Le Topia context a utiliser + * @param tree + * (auto) l'arbre ou il faudra selectionner le nouvel element + * @param jmodel + * (auto) le model de l'arbre + * @param type + * le type de l'entite a creer, le type est compose seulement du + * nom de l'entite et pas du package. + * @return null ou un fenetre d'erreur + */ + @SuppressWarnings("unchecked") + public TopiaEntity create(String type) { + log.debug("create called for " + type); + try { + String name = type + "_new"; + Method method = MethodUtils.getAccessibleMethod( + IsisFishDAOHelper.class, "get" + type + "DAO", + TopiaContext.class); + TopiaDAO<TopiaEntity> dao = (TopiaDAO<TopiaEntity>) method.invoke(null, new Object[] { isisContext }); + + TopiaEntity entity = dao.create("name", name); + entity.update(); + isisContext.commitTransaction(); + return entity; + + } catch (Exception eee) { + log.error("Can't create entity", eee); +// return new OutputView("Error.xml", "error", eee.getMessage()); + } + return null; + } + + /** + * Save entity passed in argument, and commit + * + * @param frame + * @param idToRefresh + * id to refresh after commit + * @param entity + * entity to save + * @return if ok return null else OutView error + */ + public TopiaEntity save(String idToRefresh) { + log.debug("save called"); + try { + if (selected == null) { + log.warn("Try to save null entity"); + return null; + } + // on est pas en autoUpdate donc il faut faire le update avant le + // commit + selected.update(); + + selected.getTopiaContext().commitTransaction(); + } catch (Exception eee) { + log.error("Can't save region", eee); + // return new OutputView("Error.xml", "error", eee.getMessage()); + } + return selected; + } + + /** + * Cancel all modification on entity (rollback), and force reload it and + * refresh all ui component that name match 'type'Tab + * + * @param uiContext + * @param frame + * @param isisContext + * @param type + * entity type (Zone, Gear, Population, ...), prefix of user + * interface Tab to refresh after rollback and reload + * @param entity + * entity to refresh + * @return if ok return null else OutView error + */ + public Object cancel(String type) { + log.debug("cancel called"); + try { + isisContext.rollbackTransaction(); + + // reload the object + if (selected != null) { + selected = isisContext.findByTopiaId(selected.getTopiaId()); + } +// uiContext.setData(type, entity); + +// frame.refreshView(type + "Tab"); + + } catch (Exception eee) { + log.error("Can't cancel modification in region", eee); +// return new OutputView("Error.xml", "error", eee.getMessage()); + } + return null; + } + + /** + * Delete one entity and commit the change, try to selected intelligently + * other node in tree. + * <p> + * Refresh all ui component where name match "input<entity type without + * package >.*" + * + * @param uiContext + * @param frame + * @param isisContext + * @param fisheryRegion + * @param tree + * tree where we want to select other node + * @param jmodel + * tree model + * @param entity + * entuty to remove + * @return if ok return null else OutView error + */ + public String remove() { + log.debug("remove called"); + String msg = ""; + try { + + boolean doDelete = true; + List<TopiaEntity> allWillBeRemoved = selected.getComposite(); + if (allWillBeRemoved.size() > 0) { + String text = _( + "isisfish.message.delete.object", + selected.toString()); + for (TopiaEntity e : allWillBeRemoved) { + text += ClassUtils.getShortClassName(e.getClass()) + " - " + + e.toString() + "\n"; + } + int resp = JOptionPane.showConfirmDialog(null, text, + _("isisfish.message.delete.entities"), JOptionPane.YES_NO_OPTION); + doDelete = resp == JOptionPane.YES_OPTION; + } else { + String text = _("isisfish.message.confirm.delete.object", selected.toString()); + int resp = JOptionPane.showConfirmDialog(null, text, + _("isisfish.message.delete.entity"), JOptionPane.YES_NO_OPTION); + doDelete = resp == JOptionPane.YES_OPTION; + } + + if (doDelete) { +// uiContext.setData("RegionModified", Boolean.FALSE); +// uiContext.setData("InDeletion", Boolean.TRUE); + selected.delete(); + isisContext.commitTransaction(); + msg = _("isisfish.message.remove.finished"); + } else { + msg = _("isisfish.message.remove.canceled"); + } + } catch (Exception eee) { + log.error("Can't remove entity: " + selected, eee); + // return new OutputView("Error.xml", "error", eee.getMessage()); + } +// finally { + // uiContext.removeData("InDeletion"); +// } + return msg; + } + + /** + * Save an Equation as model, to reuse it for other equation + * + * @param uiContext + * @param frame + * @param isisfish + * @param category + * categoy for this equation + * @param isisfish + * equation to put in models + * @param language + * @return if ok return null else OutputView error message + */ + public Object saveAsModel(String category, String language, String content) { + try { + String name = showInputDialog(""); + if ("".equals(name)) { +// return new OutputView("Error.xml", "error",_("isisfish.error.invalid.equation.name")); + } + if (name != null) { + FormuleStorage storage = FormuleStorage.createFormule(category, name, language); + storage.setContent(content); + } + + } catch (Exception eee) { + log.error("Can't save equation as model", eee); +// return new OutputView("Error.xml", "error", eee.getMessage()); + } + return null; + } + public Object openEditor(String category, String name, + Class javaInterface, String content, Editor editor) { + log.debug("openEditor"); + try { + EquationEditorPaneUI pane = new EquationEditorPaneUI(); + pane.setEquation(category, name, javaInterface, content); + pane.setVisible(true); + if (pane.isOk() && editor != null) { + editor.setText(pane.getEditor().getText()); + } + pane.dispose(); + } catch (Exception eee) { + log.error("Can't open editor", eee); +// return new OutputView("Error.xml", "error", eee.getMessage()); + } + return null; + } protected String getFisheryRegionName() { if (fisheryRegion != null) { return fisheryRegion.getName(); @@ -215,6 +445,10 @@ protected FisheryRegion getFisheryRegion() { return fisheryRegion; } + + protected TopiaEntity getSelected(){ + return selected; + } protected Cell getCell() { return cell; @@ -255,4 +489,41 @@ protected Strategy getStrategy() { return strategy; } + +// InputGear + + public Object addSelectivity(Population pop, String equation) { + try { + + SelectivityDAO dao = IsisFishDAOHelper.getSelectivityDAO(isisContext); + Selectivity selectivity = dao.create(); + + selectivity.setGear(gear); + selectivity.setPopulation(pop); + selectivity.getEquation().setContent(equation); + selectivity.update(); + + gear.addPopulationSelectivity(selectivity); + gear.update(); + + } catch (Exception eee) { + log.error("Can't add selectivity", eee); +// return new OutputView("Error.xml", "error", eee.getMessage()); + } + return null; + } + + public Object removeSelectivity(Selectivity selectivity){ + log.debug("removeTargetSpecies called: " + selectivity); + try { + if (gear != null && selectivity != null) { + gear.removePopulationSelectivity(selectivity); + } + }catch(Exception eee){ + log.error("Can't remove TargetSpecies", eee); +// return new OutputView("Error.xml", "error", eee.getMessage()); + } + return null; + } + } Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputUI.jaxx =================================================================== --- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputUI.jaxx 2008-10-28 11:34:42 UTC (rev 1578) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputUI.jaxx 2008-10-30 17:47:57 UTC (rev 1579) @@ -52,48 +52,53 @@ import fr.ifremer.isisfish.entities.TripType; import fr.ifremer.isisfish.entities.VesselType; import fr.ifremer.isisfish.entities.Zone; - - //setContextValue(new InputAction()); + import javax.swing.tree.TreeNode; + import javax.swing.tree.TreePath; + import org.codelutin.topia.persistence.TopiaEntity; + import org.codelutin.topia.TopiaException; tree.addTreeSelectionListener(new TreeSelectionListener() { @Override public void valueChanged(TreeSelectionEvent e) { DefaultMutableTreeNode node = (DefaultMutableTreeNode) tree.getLastSelectedPathComponent(); + String name = null; if (node != null) { GenericCell selectedValue = (GenericCell) node.getUserObject(); if (selectedValue.getType() != null) { - ((CardLayout) inputPane.getLayout()).show(inputPane, selectedValue.getType().getSimpleName()); - if (selectedValue.getClass() != null) { - getContextValue(InputAction.class).setValue(selectedValue.getValue(),selectedValue.getType()); - if (selectedValue.getType() == Zone.class){ - zoneUI.refresh(); - } else if (selectedValue.getType() == Cell.class){ - cellUI.refresh(); - } else if (selectedValue.getType() == Port.class){ - portUI.refresh(); - } else if (selectedValue.getType() == Species.class){ - speciesUI.refresh(); - } else if (selectedValue.getType() == Gear.class){ - gearUI.refresh(); - } else if (selectedValue.getType() == Metier.class){ - metierUI.refresh(); - } else if (selectedValue.getType() == TripType.class){ - tripTypeUI.refresh(); - } else if (selectedValue.getType() == VesselType.class){ - vesselTypeUI.refresh(); - } else if (selectedValue.getType() == SetOfVessels.class){ - setOfVesselsUI.refresh(); - } else if (selectedValue.getType() == Strategy.class){ - strategyUI.refresh(); - } - } + name = selectedValue.getType().getSimpleName(); + getContextValue(InputAction.class).setValue(selectedValue.getValue(),selectedValue.getType()); + refreshAll(selectedValue); } else { - ((CardLayout) inputPane.getLayout()).show(inputPane, "none"); + name = "none"; } + ((CardLayout) inputPane.getLayout()).show(inputPane, name); } } }); + protected void refreshAll(GenericCell selectedValue){ + if (selectedValue.getType() == Zone.class){ + zoneUI.refresh(); + } else if (selectedValue.getType() == Cell.class){ + cellUI.refresh(); + } else if (selectedValue.getType() == Port.class){ + portUI.refresh(); + } else if (selectedValue.getType() == Species.class){ + speciesUI.refresh(); + } else if (selectedValue.getType() == Gear.class){ + gearUI.refresh(); + } else if (selectedValue.getType() == Metier.class){ + metierUI.refresh(); + } else if (selectedValue.getType() == TripType.class){ + tripTypeUI.refresh(); + } else if (selectedValue.getType() == VesselType.class){ + vesselTypeUI.refresh(); + } else if (selectedValue.getType() == SetOfVessels.class){ + setOfVesselsUI.refresh(); + } else if (selectedValue.getType() == Strategy.class){ + strategyUI.refresh(); + } + } public InputUI (InputAction action){ setContextValue(action); } @@ -161,6 +166,61 @@ node.add(childNode); } } + protected void setTreeSelection(TopiaEntity topia, Class type){ + String name = null; + if (topia != null){ + if (type == Zone.class){ + name = ((Zone) topia).getName(); + } else if (type == Cell.class){ + name = ((Cell) topia).getName(); + } else if (type == Port.class){ + name = ((Port) topia).getName(); + } else if (type == Species.class){ + name = ((Species) topia).getName(); + } else if (type == Gear.class){ + name = ((Gear) topia).getName(); + } else if (type == Metier.class){ + name = ((Metier) topia).getName(); + } else if (type == TripType.class){ + name = ((TripType) topia).getName(); + } else if (type == VesselType.class){ + name = ((VesselType) topia).getName(); + } else if (type == SetOfVessels.class){ + name = ((SetOfVessels) topia).getName(); + } else if (type == Strategy.class){ + name = ((Strategy) topia).getName(); + } + } + DefaultMutableTreeNode element = null; + element = findNode((DefaultMutableTreeNode) tree.getModel().getRoot(), type, name); + TreeNode[] path = element.getPath(); + if (log.isDebugEnabled()) { + log.debug("chemin du prochain noeud selectionnée: " + Arrays.toString(path)); + } + TreePath newSelectionPath = new TreePath(path); + tree.setSelectionPath(newSelectionPath); + } + protected DefaultMutableTreeNode findNode(DefaultMutableTreeNode root, Class type, String name){ + DefaultMutableTreeNode result = null; + for (Enumeration e = root.children(); e.hasMoreElements();){ + DefaultMutableTreeNode node = (DefaultMutableTreeNode)e.nextElement(); + GenericCell g = (GenericCell)node.getUserObject(); + if (type == g.getType()){ + result = node; + if (name != null){ + for (e = result.children(); e.hasMoreElements();){ + node = (DefaultMutableTreeNode)e.nextElement(); + g = (GenericCell)node.getUserObject(); + if (name.equals(g.getName())){ + result = node; + break; + } + } + } + } + } + return result; + } protected void setInfoText(String s){ WelcomePanelUI root = getParentContainer(WelcomePanelUI.class); root.setInfoText(s); Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/MetierSeasonInfoSpeciesUI.jaxx =================================================================== --- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/MetierSeasonInfoSpeciesUI.jaxx 2008-10-28 11:34:42 UTC (rev 1578) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/MetierSeasonInfoSpeciesUI.jaxx 2008-10-30 17:47:57 UTC (rev 1579) @@ -32,6 +32,14 @@ --> <Table> + <script><![CDATA[ + public MetierSeasonInfoSpeciesUI (InputAction action){ + setContextValue(action); + } + protected void refresh() { + + } + ]]></script> <row> <cell fill='both' weightx='1.0' weighty='0.5'> <Table> Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/MetierSeasonInfoZoneUI.jaxx =================================================================== --- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/MetierSeasonInfoZoneUI.jaxx 2008-10-28 11:34:42 UTC (rev 1578) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/MetierSeasonInfoZoneUI.jaxx 2008-10-30 17:47:57 UTC (rev 1579) @@ -32,6 +32,14 @@ --> <Table> + <script><![CDATA[ + public MetierSeasonInfoZoneUI (InputAction action){ + setContextValue(action); + } + protected void refresh() { + + } + ]]></script> <row> <cell fill='both' weightx='1.0' weighty='1.0'> <Table> @@ -55,6 +63,7 @@ </cell> <cell fill='horizontal' weightx='1.0'> <JPanel/> + <!--fr.ifremer.isisfish.ui.widget.IntervalPanel id="displayMetierSeason"/--> <!-- Fixme : SeasonIntervalPanel <SeasonIntervalPanel constraints='"displayMetierSeason"' id="displayMetierSeason" Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/MetierTabUI.jaxx =================================================================== --- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/MetierTabUI.jaxx 2008-10-28 11:34:42 UTC (rev 1578) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/MetierTabUI.jaxx 2008-10-30 17:47:57 UTC (rev 1579) @@ -32,6 +32,85 @@ --> <Table> + <script><![CDATA[ + + import fr.ifremer.isisfish.entities.Gear; + import fr.ifremer.isisfish.entities.TripType; + import fr.ifremer.isisfish.entities.Metier; + import fr.ifremer.isisfish.ui.WelcomePanelUI; + import org.codelutin.topia.persistence.TopiaEntity; + import org.codelutin.topia.TopiaException; + import java.util.logging.Level; + import java.util.logging.Logger; + + protected boolean changed = false; + public MetierTabUI (InputAction action){ + setContextValue(action); + } + protected void refresh() { + try { + Metier metier = getContextValue(InputAction.class).getMetier(); + if (metier != null){ + fieldMetierName.setText(metier.getName()); + DefaultComboBoxModel model = new DefaultComboBoxModel(getContextValue(InputAction.class).getFisheryRegion().getGear().toArray()); + fieldMetierGear.setModel(model); + fieldMetierParam.setText(metier.getGearParameterValue()); + fieldMetierComment.setText(metier.getComment()); + } + } catch (Exception ex) { + Logger.getLogger(MetierTabUI.class.getName()).log(Level.SEVERE, null, ex); + } + } + protected void nameChanged(){ + getContextValue(InputAction.class).getMetier().setName(fieldMetierName.getText()); + valueChanged(true); + } + protected void gearChanged(){ + getContextValue(InputAction.class).getMetier().setGear((Gear)fieldMetierGear.getSelectedItem()); + valueChanged(true); + } + protected void paramChanged(){ + getContextValue(InputAction.class).getMetier().setGearParameterValue(fieldMetierParam.getText()); + valueChanged(true); + } + protected void commentChanged(){ + getContextValue(InputAction.class).getMetier().setComment(fieldMetierComment.getText()); + valueChanged(true); + } + protected void create(){ + TopiaEntity topia = getContextValue(InputAction.class).create("Metier"); + getParentContainer(InputUI.class).setTreeModel(); + getParentContainer(InputUI.class).setTreeSelection(topia, Metier.class); + setInfoText(_("isisfish.message.creation.finished")); + } + protected void save(){ + TopiaEntity topia = getContextValue(InputAction.class).save("Metier"); + getParentContainer(InputUI.class).setTreeSelection(topia, Metier.class); + setInfoText(_("isisfish.message.save.finished")); + refresh(); + valueChanged(false); + } + protected void cancel(){ + getContextValue(InputAction.class).cancel("Metier"); + setInfoText(_("isisfish.message.cancel.finished")); + valueChanged(false); + refresh(); + } + protected void remove(){ + setInfoText(getContextValue(InputAction.class).remove()); + valueChanged(false); + refresh(); + } + protected void setInfoText(String txt){ + WelcomePanelUI root = getParentContainer(WelcomePanelUI.class); + root.setInfoText(txt); + } + protected void valueChanged(boolean b){ + changed=b; + create.setEnabled(b); + save.setEnabled(b); + } + ]]></script> <row> <cell fill='both' weightx='1.0' weighty='1.0'> <Table> @@ -40,7 +119,7 @@ <JLabel text="isisfish.metier.name"/> </cell> <cell fill='horizontal' weightx='1.0'> - <JTextField id="fieldMetierName"/> + <JTextField id="fieldMetierName" onKeyTyped='nameChanged()'/> <!-- Fixme : DocumentEvents origin="$Metier/name" <DocumentEvents onModified="Update($fieldMetierName/text)"/> @@ -52,7 +131,7 @@ <JLabel text="isisfish.common.gear"/> </cell> <cell fill='horizontal' weightx='1.0'> - <JComboBox id="fieldMetierGear"/> + <JComboBox id="fieldMetierGear" onActionPerformed='gearChanged()'/> <!-- Fixme : ComboBoxModel origin="$Metier/gear" renderer="name" firstNull="true" actionCommand="update($fieldMetierGear/selectedItem, $Metier/gear)" @@ -65,7 +144,7 @@ <JLabel text="isisfish.metier.rangeValues"/> </cell> <cell fill='horizontal' weightx='1.0'> - <JTextField id="fieldMetierParam"/> + <JTextField id="fieldMetierParam" onKeyTyped='paramChanged()'/> <!-- Fixme : DocumentEvents origin="$Metier/gearParameterValue" <DocumentEvents onModified="Update($fieldMetierParam/text)"/> @@ -78,12 +157,11 @@ </cell> <cell fill='both' weightx='1.0' weighty='1.0'> <JScrollPane minimumSize='{new Dimension(0,0)}' preferredSize='{new Dimension(0,0)}'> - <JTextArea id="fieldMetierComment"> + <JTextArea id="fieldMetierComment" onKeyTyped='commentChanged()'/> <!-- Fixme : DocumentEvents origin="$Metier/comment" <DocumentEvents onModified="Update($fieldMetierComment/text)"/> --> - </JTextArea> </JScrollPane> </cell> </row> @@ -95,14 +173,14 @@ <Table> <row> <cell fill='horizontal' weightx='0.5'> - <JButton text="isisfish.common.new"/> + <JButton id="create" text="isisfish.common.new" onActionPerformed='create()'/> <!-- origin="$FisheryRegion" actionCommand='input.Input.create("Metier")' --> </cell> <cell fill='horizontal' weightx='0.5'> - <JButton text="isisfish.common.save"/> + <JButton id="save" text="isisfish.common.save" onActionPerformed='save()'/> <!-- origin="$EntityModified" actionCommand='input.Input.save("Metier", $Metier);refreshView($inputMetier)' @@ -111,14 +189,14 @@ </row> <row> <cell fill='horizontal' weightx='0.5'> - <JButton text="isisfish.common.cancel"/> + <JButton id="cancel" text="isisfish.common.cancel" onActionPerformed='cancel()'/> <!-- origin="$EntityModified" actionCommand='input.Input.cancel("Metier", $Metier);refreshView($inputMetier)' --> </cell> <cell fill='horizontal' weightx='0.5'> - <JButton text="isisfish.common.remove"/> + <JButton id="remove" text="isisfish.common.remove" onActionPerformed='remove()'/> <!-- origin="$Metier" actionCommand="input.Input.remove($Metier)" @@ -128,5 +206,4 @@ </Table> </cell> </row> -</Table> - +</Table> \ No newline at end of file Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/MetierUI.jaxx =================================================================== --- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/MetierUI.jaxx 2008-10-28 11:34:42 UTC (rev 1578) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/MetierUI.jaxx 2008-10-30 17:47:57 UTC (rev 1579) @@ -36,20 +36,23 @@ +--> <JPanel layout='{new BorderLayout()}'> <script><![CDATA[ + import fr.ifremer.isisfish.entities.TripType; public MetierUI (InputAction action){ setContextValue(action); } protected void refresh() { - } + metierTabUI.refresh(); + metierSeasonSpeciesUI.refresh(); + metierSeasonInfoUI.refresh(); + } + protected void goToTripType(){ + getParentContainer(InputUI.class).setTreeSelection(null, TripType.class); + } ]]></script> <JTabbedPane id="MetierTab" name="Metier" constraints='BorderLayout.CENTER'> - <tab title='{_("isisfish.metier.title")}'><MetierTabUI/></tab> - <tab title='{_("isisfish.metierSeasonInfoZone.title")}'><MetierSeasonInfoZoneUI/></tab> - <tab title='{_("isisfish.metierSeasonInfoSpecies.title")}'><MetierSeasonInfoSpeciesUI/></tab> - + <tab title='{_("isisfish.metier.title")}'><MetierTabUI id="metierTabUI" constructorParams='getContextValue(InputAction.class)'/></tab> + <tab title='{_("isisfish.metierSeasonInfoZone.title")}'><MetierSeasonInfoZoneUI id="metierSeasonInfoUI" constructorParams='getContextValue(InputAction.class)'/></tab> + <tab title='{_("isisfish.metierSeasonInfoSpecies.title")}'><MetierSeasonInfoSpeciesUI id="metierSeasonSpeciesUI" constructorParams='getContextValue(InputAction.class)'/></tab> </JTabbedPane> - <JButton constraints='BorderLayout.SOUTH' text="isisfish.input.continueTripTypes"/> -<!-- - actionCommand="UIHelper.setTreeSelection('TripTypes')" ---> + <JButton constraints='BorderLayout.SOUTH' text="isisfish.input.continueTripTypes" onActionPerformed='goToTripType()'/> </JPanel> \ No newline at end of file Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/PortUI.jaxx =================================================================== --- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/PortUI.jaxx 2008-10-28 11:34:42 UTC (rev 1578) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/PortUI.jaxx 2008-10-30 17:47:57 UTC (rev 1579) @@ -37,11 +37,106 @@ +--> <Table> <script><![CDATA[ + + import fr.ifremer.isisfish.entities.Species; + import fr.ifremer.isisfish.entities.Port; + import fr.ifremer.isisfish.entities.Cell; + import fr.ifremer.isisfish.map.IsisMapBean; + import fr.ifremer.isisfish.map.OpenMapToolPanel; + import com.bbn.openmap.gui.OMToolSet; + import fr.ifremer.isisfish.ui.WelcomePanelUI; + import org.codelutin.topia.persistence.TopiaEntity; + import org.codelutin.topia.TopiaException; + + protected IsisMapBean portMap = new IsisMapBean(); + protected OpenMapToolPanel toolMap = new OpenMapToolPanel(); + protected OMToolSet toolSet = new OMToolSet(); + protected boolean changed = false; public PortUI (InputAction action){ setContextValue(action); } protected void refresh() { - } + Port port = getContextValue(InputAction.class).getPort(); + if (port != null){ + + fieldPortName.setText(port.getName()); + + DefaultListModel portCellModel = new DefaultListModel(); + java.util.List<Cell> cells = getContextValue(InputAction.class).getFisheryRegion().getCell(); + for (Cell c : cells){ + portCellModel.addElement(c); + } + portCell.setModel(portCellModel); + portCell.setSelectedValue(port.getCell()); + + fieldPortComment.setText(getContextValue(InputAction.class).getPort().getComment()); + + portMap.setFisheryRegion(getContextValue(InputAction.class).getFisheryRegion()); + toolSet.setupListeners(portMap); + toolMap.add((Component)toolSet); + portMapPanel.add(toolMap, BorderLayout.NORTH); + portMapPanel.add(portMap, BorderLayout.CENTER); + refreshMap(); + } + } + protected void refreshMap(){ + java.util.List<Cell> cells = new ArrayList<Cell>(); + cells.add((Cell)portCell.getSelectedValue()); + portMap.setSelectedCells(cells); + portMap.setSelectedCells(cells); + } + protected void create(){ + TopiaEntity topia = getContextValue(InputAction.class).create("Port"); + + getParentContainer(InputUI.class).setTreeModel(); + getParentContainer(InputUI.class).setTreeSelection(topia, Port.class); + + setInfoText(_("isisfish.message.creation.finished")); + } + protected void save(){ + TopiaEntity topia = getContextValue(InputAction.class).save("Port"); + getParentContainer(InputUI.class).setTreeSelection(topia, Port.class); + setInfoText(_("isisfish.message.save.finished")); + refresh(); + valueChanged(false); + } + protected void cancel(){ + getContextValue(InputAction.class).cancel("Port"); + setInfoText(_("isisfish.message.cancel.finished")); + valueChanged(false); + refresh(); + } + protected void remove(){ + setInfoText(getContextValue(InputAction.class).remove()); + valueChanged(false); + refresh(); + } + protected void goToSpecies(){ + getParentContainer(InputUI.class).setTreeSelection(null, Species.class); + } + protected void setInfoText(String txt){ + WelcomePanelUI root = getParentContainer(WelcomePanelUI.class); + root.setInfoText(txt); + } + protected void valueChanged(boolean b){ + changed=b; + create.setEnabled(b); + save.setEnabled(b); + } + protected void nameChanged(){ + getContextValue(InputAction.class).getPort().setName(fieldPortName.getText()); + valueChanged(true); + refresh(); + } + protected void portCellChanged(){ + getContextValue(InputAction.class).getPort().setCell((Cell)portCell.getSelectedValue()); + valueChanged(true); + refresh(); + } + protected void commentChanged(){ + getContextValue(InputAction.class).getPort().setComment(fieldPortComment.getText()); + valueChanged(true); + } ]]> </script> <row> @@ -56,11 +151,7 @@ </row> <row> <cell columns='2' fill='horizontal' weightx='1.0' > - <JTextField id="fieldPortName"/> -<!-- Fixme : DocumentEvents -origin="$Port/name" - <DocumentEvents onModified="Update($fieldPortName/text)"/> ---> + <JTextField id="fieldPortName" onActionPerformed='nameChanged()'/> </cell> </row> <row> @@ -72,13 +163,7 @@ <row> <cell columns='2' fill='both' weighty='0.7' weightx='1.0'> <JScrollPane> - <JList id="portCell"/> -<!-- Fixme : ListModel -SelectionMode="0" renderer="name" - origin="getCell($Port)" - <ListModel origin="$FisheryRegion/cell"/> - <ListSelectionEvents onValueChanged="Update($portCell/selectedValue, $Port/cell, refreshView($portMap))"/> ---> + <JList id="portCell" selectionMode="0" onMouseClicked='portCellChanged()'/> </JScrollPane> </cell> </row> @@ -91,68 +176,34 @@ <row> <cell columns='2' fill='both' weighty='0.3' weightx='1.0' > <JScrollPane> - <JTextArea id="fieldPortComment"/> -<!-- Fixme : DocumentEvents - origin="$Port/comment" -<DocumentEvents onModified="Update($fieldPortComment/text)"/> ---> + <JTextArea id="fieldPortComment" onKeyPressed='commentChanged()'/> </JScrollPane> </cell> </row> <row> <cell fill='horizontal' weightx='0.5'> - <JButton text="isisfish.common.save"/> -<!-- - origin="$EntityModified" - actionCommand='input.Input.save("Port", $Port);refreshView($inputPort)' ---> + <JButton id='save' text="isisfish.common.save" onActionPerformed='save()'/> </cell> <cell fill='horizontal' weightx='0.5'> - <JButton text="isisfish.common.cancel"/> -<!-- - origin="$EntityModified" - actionCommand='input.Input.cancel("Port", $Port);refreshView($inputPort)' ---> + <JButton id='cancel' text="isisfish.common.cancel" onActionPerformed='cancel()'/> </cell> </row> <row> <cell fill='horizontal' weightx='0.5'> - <JButton text="isisfish.common.new"/> -<!-- -origin="$FisheryRegion" - actionCommand='input.Input.create("Port")' ---> + <JButton id='create' text="isisfish.common.new" onActionPerformed='create()'/> </cell> <cell fill='horizontal' weightx='0.5'> - <JButton text="isisfish.common.remove"/> -<!-- - origin="$Port" - actionCommand="input.Input.remove($Port)" ---> + <JButton id='remove' text="isisfish.common.remove" onActionPerformed='remove()'/> </cell> </row> </Table> - <JPanel id="portMapPanel" layout='{new BorderLayout()}'> - <!-- Fixme : OpenMapToolPanel, OpenMap - <OpenMapToolPanel constraints='"BorderLayout.NORTH"' id="portMapTool"> - <OpenMapToolSet id="portMapToolSet" origin="$portMap"/> - </OpenMapToolPanel> - <OpenMap id="portMap" origin="$FisheryRegion" selected="$Port/cell" - selectionMode="1"> - <OpenMapEvents id="portMapEvents" mouseMode="Select" - onMouseClicked="Update($portMap/selectedCells[1], $Port/cell, refreshView($portCell))"/> - </OpenMap> - --> - </JPanel> + <JPanel id="portMapPanel" layout='{new BorderLayout()}'/> </JSplitPane> </cell> </row> <row> <cell fill='horizontal' weightx='1.0'> - <JButton text="isisfish.input.continueSpecies"/> -<!-- - actionCommand="UIHelper.setTreeSelection('Species')" ---> + <JButton text="isisfish.input.continueSpecies" onActionPerformed='goToSpecies()'/> </cell> </row> </Table> Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/SelectivityUI.jaxx =================================================================== --- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/SelectivityUI.jaxx 2008-10-28 11:34:42 UTC (rev 1578) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/SelectivityUI.jaxx 2008-10-30 17:47:57 UTC (rev 1579) @@ -31,6 +31,131 @@ */ --> <Table> + <script> + <![CDATA[ + + import fr.ifremer.isisfish.entities.Population; + import fr.ifremer.isisfish.entities.Gear; + import fr.ifremer.isisfish.entities.Species; + import fr.ifremer.isisfish.entities.Formule; + import fr.ifremer.isisfish.ui.WelcomePanelUI; + import fr.ifremer.isisfish.ui.widget.editor.EquationTableEditor; + import javax.swing.table.DefaultTableModel; + import fr.ifremer.isisfish.entities.Selectivity; + import fr.ifremer.isisfish.entities.Equation; + import java.util.logging.Level; + import java.util.logging.Logger; + import org.codelutin.topia.persistence.TopiaEntity; + import fr.ifremer.isisfish.ui.widget.editor.GenericCell; + + boolean changed = false; + public SelectivityUI (InputAction action){ + setContextValue(action); + } + public void refresh(){ + if (getContextValue(InputAction.class).getSelected() != null){ + fieldSelectivityPopulation.setModel(getSelectivityPopulationModel()); + } + fieldSelectivityEquation.setModel(getSelectivityEquationModel()); + setSelectivityTableModel(); + try { + fieldSelectivityScript.open(org.codelutin.util.FileUtil.getTempFile("", ".java")); + } catch (IOException ex) { + Logger.getLogger(SelectivityUI.class.getName()).log(Level.SEVERE, null, ex); + } + } + protected void setSelectivityTableModel(){ + DefaultTableModel model = new DefaultTableModel(){ + @Override + public boolean isCellEditable(int row, int column) { + boolean result = false; + if (column > 0){ + result =true; + } + return result; + } + }; + Collection<Selectivity> selectivity = getContextValue(InputAction.class).getGear().getPopulationSelectivity(); + java.util.List<Population> populations = new ArrayList<Population>(); + java.util.List<Equation> equations = new ArrayList<Equation>(); + for (Selectivity s : selectivity){ + populations.add(s.getPopulation()); + equations.add(s.getEquation()); + } + model.addColumn("Population", populations.toArray()); + model.addColumn("Equation", equations.toArray()); + + selectivityTable.setModel(model); + EquationTableEditor cellEditor = new EquationTableEditor(); + selectivityTable.getColumnModel().getColumn(1).setCellEditor(cellEditor); + } + protected DefaultComboBoxModel getSelectivityPopulationModel(){ + java.util.List<Species> species = getContextValue(InputAction.class).getFisheryRegion().getSpecies(); + DefaultComboBoxModel selectivityPopulationModel = new DefaultComboBoxModel(); + selectivityPopulationModel.addElement(new GenericCell(" ", null, null)); + for (Species s : species){ + for (Population p : s.getPopulation()){ + selectivityPopulationModel.addElement(new GenericCell(p.getName(), p, Population.class)); + } + } + return selectivityPopulationModel; + } + protected DefaultComboBoxModel getSelectivityEquationModel(){ + java.util.List<Formule> formules = fr.ifremer.isisfish.datastore.FormuleStorage.getFormules(getContextValue(InputAction.class).getIsisContext(), "Selectivity"); + DefaultComboBoxModel selectivityEquationModel = new DefaultComboBoxModel(); + selectivityEquationModel.addElement(new GenericCell(" ", null, null)); + for (Formule f : formules){ + GenericCell g = new GenericCell(f.getName(), f, Formule.class); + selectivityEquationModel.addElement(g); + } + return selectivityEquationModel; + } + protected void saveAsModel(){ + getContextValue(InputAction.class).saveAsModel("Selectivity", "Java", fieldSelectivityScript.getText()); + setInfoText(_("isisfish.message.saveModel.finished")); + } + protected void setInfoText(String txt){ + WelcomePanelUI root = getParentContainer(WelcomePanelUI.class); + root.setInfoText(txt); + } + protected void openEditor(){ + getContextValue(InputAction.class).openEditor("Selectivity", "new", fr.ifremer.isisfish.equation.SelectivityEquation.class, fieldSelectivityScript.getText(), fieldSelectivityScript); + } + protected void add(){ + getContextValue(InputAction.class).addSelectivity((Population) ((GenericCell) fieldSelectivityPopulation.getSelectedItem()).getValue(), fieldSelectivityScript.getText()); + valueChanged(true); + refresh(); + } + protected void remove(){ + getContextValue(InputAction.class).removeSelectivity((Selectivity) getContextValue(InputAction.class).getGear().getPopulationSelectivity((Population) selectivityTable.getValueAt(selectivityTable.getSelectedRow(), 0))); + refresh(); + } + protected void save(){ + TopiaEntity topia = getContextValue(InputAction.class).save("Gear"); + getParentContainer(InputUI.class).setTreeSelection(topia, Gear.class); + setInfoText(_("isisfish.message.save.finished")); + refresh(); + valueChanged(false); + } + protected void cancel(){ + getContextValue(InputAction.class).cancel("Gear"); + setInfoText(_("isisfish.message.cancel.finished")); + valueChanged(false); + refresh(); + } + protected void valueChanged(boolean b){ + changed=b; + cancel.setEnabled(b); + save.setEnabled(b); + } + protected void equationChanged(){ + GenericCell g = (GenericCell)fieldSelectivityEquation.getSelectedItem(); + if (g.getValue() != null){ + fieldSelectivityScript.setText(((Formule)(g).getValue()).getContent()); + } + } + ]]> + </script> <row> <cell fill='both' weightx='1.0' weighty='1.0'> <Table> @@ -51,7 +176,7 @@ <JLabel text="isisfish.selectivity.equation"/> </cell> <cell fill='horizontal' weightx='1.0'> - <JComboBox id="fieldSelectivityEquation"/> + <JComboBox id="fieldSelectivityEquation" onActionPerformed='equationChanged()'/> <!-- Fixme : ComboBoxModel renderer="name" firstNull="true" actionCommand="update($fieldSelectivityEquation/selectedItem/content, $fieldSelectivityScript/text)" @@ -64,7 +189,7 @@ <Table> <row> <cell fill='horizontal'> - <JButton text="isisfish.common.saveModel"/> + <JButton id='saveModel' text="isisfish.common.saveModel" onActionPerformed='saveAsModel()'/> <!-- actionCommand='input.Input.saveAsModel("Selectivity", "Java", $fieldSelectivityScript/text);refreshView($fieldSelectivityEquation)' --> @@ -72,7 +197,7 @@ </row> <row> <cell fill='horizontal'> - <JButton text="isisfish.common.openEditor"/> + <JButton id='openEditor' text="isisfish.common.openEditor" onActionPerformed='openEditor()'/> <!-- actionCommand='input.Input.openEditor("Selectivity","new","fr.ifremer.isisfish.equation.SelectivityEquation",$fieldSelectivityScript/text,$fieldSelectivityScript)' --> @@ -87,10 +212,7 @@ </cell> <cell fill='both' weightx='1.0' weighty='1.0'> <JScrollPane> -<!-- Fixme : editor - <editor id="fieldSelectivityScript" askIfNotSaved="false" origin="org.codelutin.util.FileUtil.getTempFile('', '.java')"> - </editor> ---> + <org.codelutin.widget.editor.Editor id='fieldSelectivityScript' askIfNotSaved="false"/> </JScrollPane> </cell> </row> @@ -102,7 +224,7 @@ <Table> <row> <cell columns='2' fill='horizontal' weightx='1.0'> - <JButton id="buttonAddSelectivity" text="isisfish.common.add"/> + <JButton id="buttonAddSelectivity" text="isisfish.common.add" onActionPerformed='add()'/> <!-- origin="$Gear" actionCommand="input.InputGear.addSelectivity($Gear, $fieldSelectivityPopulation/selectedItem, $fieldSelectivityScript/text)" @@ -127,7 +249,7 @@ </row> <row> <cell columns='2' fill='horizontal' weightx='1.0'> - <JButton id="buttonSelectivityRemove" text="isisfish.common.remove"/> + <JButton id="buttonSelectivityRemove" text="isisfish.common.remove" onActionPerformed='remove()'/> <!-- origin="$Gear/populationSelectivity" actionCommand="input.InputGear.removeSelectivity($Gear, getPopulationSelectivity($Gear)[$selectivityTable/selectedRow + 1])" @@ -136,14 +258,14 @@ </row> <row> <cell fill='horizontal' weightx='1.0'> - <JButton text="isisfish.common.save"/> + <JButton id='save' text="isisfish.common.save" onActionPerformed='save()' enabled='false'/> <!-- origin="$EntityModified" actionCommand='input.Input.save("Gear", $Gear);refreshView($inputSelectivity)' --> </cell> <cell fill='horizontal' weightx='1.0'> - <JButton text="isisfish.common.cancel"/> + <JButton id='cancel' text="isisfish.common.cancel" onActionPerformed='cancel()' enabled='false'/> <!-- origin="$EntityModified" actionCommand='input.Input.cancel("Gear", $Gear);refreshView($inputSelectivity)' Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/SpeciesUI.jaxx =================================================================== --- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/SpeciesUI.jaxx 2008-10-28 11:34:42 UTC (rev 1578) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/SpeciesUI.jaxx 2008-10-30 17:47:57 UTC (rev 1579) @@ -37,11 +37,96 @@ +--> <Table> <script><![CDATA[ + import fr.ifremer.isisfish.entities.Gear; + import fr.ifremer.isisfish.entities.Species; + import fr.ifremer.isisfish.ui.WelcomePanelUI; + import org.codelutin.topia.persistence.TopiaEntity; + import org.codelutin.topia.TopiaException; + + protected boolean changed = false; public SpeciesUI (InputAction action){ setContextValue(action); } protected void refresh() { - } + Species s = getContextValue(InputAction.class).getSpecies(); + if (s != null){ + fieldSpeciesName.setText(s.getName()); + fieldSpeciesScientificName.setText(s.getScientificName()); + fieldSpeciesCodeRubbin.setText(s.getCodeRubbin()); + fieldSpeciesCEE.setText(s.getCodeCEE() + ""); + fieldSpeciesDynamicAge.setSelected(s.getAgeGroupType()); + fieldSpeciesDynamicLength.setSelected(!s.getAgeGroupType()); + fieldSpeciesComment.setText(s.getComment()); + } + } + protected void create(){ + TopiaEntity topia = getContextValue(InputAction.class).create("Species"); + + getParentContainer(InputUI.class).setTreeModel(); + getParentContainer(InputUI.class).setTreeSelection(topia, Species.class); + + setInfoText(_("isisfish.message.creation.finished")); + } + protected void save(){ + TopiaEntity topia = getContextValue(InputAction.class).save("Species"); + getParentContainer(InputUI.class).setTreeSelection(topia, Species.class); + setInfoText(_("isisfish.message.save.finished")); + refresh(); + valueChanged(false); + } + protected void cancel(){ + getContextValue(InputAction.class).cancel("Species"); + setInfoText(_("isisfish.message.cancel.finished")); + valueChanged(false); + refresh(); + } + protected void remove(){ + setInfoText(getContextValue(InputAction.class).remove()); + valueChanged(false); + refresh(); + } + protected void goToGear(){ + getParentContainer(InputUI.class).setTreeSelection(null, Gear.class); + } + protected void valueChanged(boolean b){ + changed=b; + create.setEnabled(b); + save.setEnabled(b); + } + protected void setInfoText(String txt){ + WelcomePanelUI root = getParentContainer(WelcomePanelUI.class); + root.setInfoText(txt); + } + protected void commentChanged(){ + getContextValue(InputAction.class).getSpecies().setComment(fieldSpeciesComment.getText()); + valueChanged(true); + refresh(); + } + protected void dynamicAgeChanged(){ + getContextValue(InputAction.class).getSpecies().setAgeGroupType(fieldSpeciesDynamicAge.isSelected()); + valueChanged(true); + refresh(); + } + protected void CEEChanged(){ + getContextValue(InputAction.class).getSpecies().setCodeCEE(Integer.parseInt(fieldSpeciesCEE.getText())); + valueChanged(true); + refresh(); + } + protected void codeChanged(){ + getContextValue(InputAction.class).getSpecies().setCodeRubbin(fieldSpeciesCodeRubbin.getText()); + valueChanged(true); + refresh(); + } + protected void scientificNameChanged(){ + getContextValue(InputAction.class).getSpecies().setScientificName(fieldSpeciesScientificName.getText()); + valueChanged(true); + refresh(); + } + protected void nameChanged(){ + getContextValue(InputAction.class).getSpecies().setName(fieldSpeciesName.getText()); + valueChanged(true); + refresh(); + } ]]> </script> <row> @@ -53,7 +138,7 @@ </cell> <cell fill='horizontal' columns='2' weightx='1.0'> - <JTextField id="fieldSpeciesName"/> + <JTextField id="fieldSpeciesName" onKeyTyped='nameChanged()'/> <!-- Fixme : DocumentEvents origin="$Species/name" <DocumentEvents onModified="Update($fieldSpeciesName/text)"/> @@ -66,7 +151,7 @@ </cell> <cell fill='horizontal' columns='2' weightx='1.0'> - <JTextField id="fieldSpeciesScientificName"/> + <JTextField id="fieldSpeciesScientificName" onKeyTyped='scientificNameChanged()'/> <!-- Fixme : DocumentEvents origin="$Species/scientificName" <DocumentEvents onModified="Update($fieldSpeciesScientificName/text)"/> @@ -80,7 +165,7 @@ </cell> <cell fill='horizontal' columns='2' weightx='1.0'> - <JTextField id="fieldSpeciesCodeRubbin"/> + <JTextField id="fieldSpeciesCodeRubbin" onKeyTyped='codeChanged()'/> <!-- Fixme : DocumentEvents origin="$Species/codeRubbin" <DocumentEvents onModified="Update($fieldSpeciesCodeRubbin/text)"/> @@ -93,7 +178,7 @@ </cell> <cell fill='horizontal' columns='2' weightx='1.0'> - <JTextField id="fieldSpeciesCEE"/> + <JTextField id="fieldSpeciesCEE" onKeyTyped='CEEChanged()'/> <!-- origin="$Species/codeCEE" <DocumentEvents onModified="Update($fieldSpeciesCEE/text)"/> @@ -107,7 +192,7 @@ </cell> <cell fill='horizontal' weightx='0.5'> - <JRadioButton id="fieldSpeciesDynamicAge" text="isisfish.species.age" buttonGroup="structuredGroup"/> + <JRadioButton id="fieldSpeciesDynamicAge" text="isisfish.species.age" buttonGroup="structuredGroup" onItemStateChanged='dynamicAgeChanged()'/> <!-- origin="$Species/ageGroupType" actionCommand="Update($fieldSpeciesDynamicAge/selected)" @@ -137,7 +222,7 @@ </cell> <cell fill='both' columns='2' weightx='1.0' weighty='1.0'> <JScrollPane> - <JTextArea id="fieldSpeciesComment"/> + <JTextArea id="fieldSpeciesComment" onKeyTyped='commentChanged()'/> <!-- Fixme : DocumentEvents origin="$Species/comment" <DocumentEvents onModified="Update($fieldSpeciesComment/text)"/> @@ -156,7 +241,7 @@ <cell fill='horizontal' weightx='0.5'> - <JButton text="isisfish.common.save"/> + <JButton id='save' text="isisfish.common.save" onActionPerformed='save()'/> <!-- origin="$EntityModified" actionCommand='input.Input.save("Species", $Species);refreshView($inputSpecies)' @@ -165,7 +250,7 @@ </cell> <cell fill='horizontal' weightx='0.5'> - <JButton text="isisfish.common.cancel"/> + <JButton id='cancel' text="isisfish.common.cancel" onActionPerformed='cancel()'/> <!-- origin="$EntityModified" actionCommand='input.Input.cancel("Species", $Species);refreshView($inputSpecies)' @@ -174,14 +259,14 @@ </row> <row> <cell fill='horizontal' weightx='0.5'> - <JButton text="isisfish.common.new"/> + <JButton id='create' text="isisfish.common.new" onActionPerformed='create()'/> <!-- origin="$FisheryRegion" actionCommand='input.Input.create("Species")' --> </cell> <cell fill='horizontal' weightx='0.5'> - <JButton text="isisfish.common.remove"/> + <JButton id='remove' text="isisfish.common.remove" onActionPerformed='remove()'/> <!-- origin="$Species" actionCommand="input.Input.remove($Species)" @@ -190,7 +275,7 @@ </row> <row> <cell columns='2' fill='horizontal' weightx='1.0'> - <JButton text="isisfish.input.continuePopulations"/> + <JButton text="isisfish.input.continuePopulations" onActionPerformed='goToGear()'/> <!-- actionCommand="UIHelper.setTreeSelectionFirstChild($Species)" --> Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/ZoneUI.jaxx =================================================================== --- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/ZoneUI.jaxx 2008-10-28 11:34:42 UTC (rev 1578) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/ZoneUI.jaxx 2008-10-30 17:47:57 UTC (rev 1579) @@ -39,30 +39,156 @@ <script><![CDATA[ import fr.ifremer.isisfish.entities.Cell; import fr.ifremer.isisfish.entities.Zone; + import fr.ifremer.isisfish.entities.Port; + import fr.ifremer.isisfish.map.IsisMapBean; + import fr.ifremer.isisfish.map.OpenMapToolPanel; + import com.bbn.openmap.gui.OMToolSet; + import fr.ifremer.isisfish.ui.WelcomePanelUI; + import org.codelutin.topia.persistence.TopiaEntity; + import org.codelutin.topia.TopiaException; + import java.util.logging.Level; + import java.util.logging.Logger; + + protected IsisMapBean zoneMap = new IsisMapBean(); + protected OpenMapToolPanel toolMap = new OpenMapToolPanel(); + protected OMToolSet toolSet = new OMToolSet(); + protected boolean changed = false; public ZoneUI (InputAction action){ setContextValue(action); + this.addFocusListener(new FocusListener() { + + @Override + public void focusGained(FocusEvent e) { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void focusLost(FocusEvent e) { + System.out.println(changed); + if (changed){ + if (!askAndSave()){ + getParentContainer(InputUI.class).setTreeSelection(getContextValue(InputAction.class).getSelected(), Zone.class); + } + } + } + }); } + protected boolean askAndSave(){ + boolean result = true; + try { + int choice = JOptionPane.showConfirmDialog(null, _("isisfish.message.page.modified")); + switch (choice) { + case JOptionPane.YES_OPTION: + getContextValue(InputAction.class).getIsisContext().commitTransaction(); + result = true; + break; + case JOptionPane.NO_OPTION: + getContextValue(InputAction.class).getIsisContext().rollbackTransaction(); + result = true; + break; + case JOptionPane.CANCEL_OPTION: + result = false; + break; + }; + } catch (TopiaException ex) { + Logger.getLogger(InputUI.class.getName()).log(Level.SEVERE, null, ex); + } + return result; + } protected void refresh() { Zone z = getContextValue(InputAction.class).getZone(); - System.out.println("refresh" + z); if (z != null){ + //DefaultComboBoxModel model = new DefaultComboBoxModel(getContextValue(InputAction.class).getFisheryRegion().getCell().toArray()); + //zoneCells.setModel(model); + DefaultListModel zoneCellsModel = new DefaultListModel(); + java.util.List<Cell> cells = getContextValue(InputAction.class).getFisheryRegion().getCell(); + for (Cell c : cells){ + zoneCellsModel.addElement(c); + } + zoneCells.setModel(zoneCellsModel); + java.util.List<Cell> cellsSelected = z.getCell(); + int[] indexs = new int[zoneCellsModel.size()]; + int i = 0; + for (Cell c : cellsSelected){ + indexs[i] = zoneCellsModel.indexOf(c); + i++; + } + zoneCells.setSelectedIndices(indexs); + fieldZoneName.setText(z.getName()); - DefaultListModel model = new DefaultListModel(); - for (Cell c : getContextValue(InputAction.class).getZone().getCell()){ - model.addElement(c); - } - zoneCells.setModel(model); fieldZoneComment.setText(getContextValue(InputAction.class).getZone().getComment()); + + zoneMap.setFisheryRegion(getContextValue(InputAction.class).getFisheryRegion()); + toolSet.setupListeners(zoneMap); + toolMap.add((Component)toolSet); + zoneMapPanel.add(toolMap, BorderLayout.NORTH); + zoneMapPanel.add(zoneMap, BorderLayout.CENTER); + refreshMap(); } - } + } + protected void refreshMap(){ + java.util.List<Cell> cells = new ArrayList<Cell>(); + for (Object o : zoneCells.getSelectedValues()){ + cells.add((Cell) o ); + } + zoneMap.setSelectedCells(cells); + } protected void create(){ + TopiaEntity topia = getContextValue(InputAction.class).create("Zone"); + + getParentContainer(InputUI.class).setTreeModel(); + getParentContainer(InputUI.class).setTreeSelection(topia, Zone.class); + + setInfoText(_("isisfish.message.creation.finished")); } protected void save(){ + TopiaEntity topia = getContextValue(InputAction.class).save("Zone"); + getParentContainer(InputUI.class).setTreeSelection(topia, Zone.class); + setInfoText(_("isisfish.message.save.finished")); + refresh(); + valueChanged(false); } protected void cancel(){ + getContextValue(InputAction.class).cancel("Zone"); + setInfoText(_("isisfish.message.cancel.finished")); + valueChanged(false); + refresh(); } protected void remove(){ + setInfoText(getContextValue(InputAction.class).remove()); + valueChanged(false); + refresh(); } + protected void goToPort(){ + getParentContainer(InputUI.class).setTreeSelection(null, Port.class); + } + protected void setInfoText(String txt){ + WelcomePanelUI root = getParentContainer(WelcomePanelUI.class); + root.setInfoText(txt); + } + protected void commentChange(){ + getContextValue(InputAction.class).getZone().setComment(fieldZoneComment.getText()); + valueChanged(true); + } + protected void zoneCellsChange(){ + java.util.List<Cell> cells = new ArrayList<Cell>(); + for (Object o : zoneCells.getSelectedValues()){ + cells.add((Cell) o); + } + getContextValue(InputAction.class).getZone().setCell(cells); + valueChanged(true); + refresh(); + } + protected void nameChange(){ + getContextValue(InputAction.class).getZone().setName(fieldZoneName.getText()); + valueChanged(true); + refresh(); + } + protected void valueChanged(boolean b){ + changed=b; + create.setEnabled(b); + save.setEnabled(b); + } ]]> </script> <row> @@ -78,105 +204,57 @@ </row> <row> <cell columns='2' fill='horizontal' weightx='1.0'> - <JTextField id="fieldZoneName"/> -<!-- Fixme : DocumentEvents - origin="$Zone/name" - <DocumentEvents onModified="Update($fieldZoneName/text)"/> ---> + <JTextField id="fieldZoneName" onFocusLost='nameChange()'/> </cell> </row> <row> <cell columns='2' fill='horizontal' weightx='1.0'> <JLabel text="isisfish.zone.cells"/> - - </cell> </row> <row> <cell columns='2' fill='both' weighty='0.7' weightx='1.0'> <JScrollPane> - <JList id="zoneCells"> -<!-- Fixme : ListModel - origin="getCell($Zone)" iterate="true" renderer="name" - <ListModel origin="$FisheryRegion/cell"/> - <ListSelectionEvents onValueChanged="Update($zoneCells/selectedValues, $Zone/cell, refreshView($zoneMap))"/> ---> - </JList> + <JList id="zoneCells" onMouseClicked='refreshMap()' onFocusLost='zoneCellsChange()'/> </JScrollPane> </cell> </row> <row> <cell columns='2' fill='horizontal' weightx='1.0'> <JLabel text="isisfish.zone.comments"/> - </cell> </row> <row> <cell columns='2' fill='both' weighty='0.3' weightx='1.0'> <JScrollPane> - <JTextArea id="fieldZoneComment"> -<!-- Fixme : DocumentEvents - origin="$Zone/comment" - <DocumentEvents onModified="Update($fieldZoneComment/text)"/> ---> - </JTextArea> + <JTextArea id="fieldZoneComment" onFocusLost='commentChange()'/> </JScrollPane> </cell> </row> <row> <cell fill='horizontal' weightx='0.5'> - <JButton text="isisfish.common.new" onActionPerformed='create()'/> -<!-- - origin="$FisheryRegion" - actionCommand='input.Input.create("Zone")' ---> + <JButton id='create' text="isisfish.common.new" enabled='false' onActionPerformed='create()'/> </cell> <cell fill='horizontal' weightx='0.5'> - <JButton text="isisfish.common.save" onActionPerformed='save()'/> -<!-- - origin="$EntityModified" - actionCommand='input.Input.save("Zone", $Zone);refreshView($inputZone)' ---> + <JButton id='save' text="isisfish.common.save" enabled='false' onActionPerformed='save()'/> </cell> </row> <row> <cell fill='horizontal' weightx='0.5'> <JButton text="isisfish.common.cancel" onActionPerformed='cancel()'/> -<!-- - origin="$EntityModified" - actionCommand='input.Input.cancel("Zone", $Zone);refreshView($inputZone)' ---> </cell> <cell fill='horizontal' weightx='0.5'> <JButton text="isisfish.common.remove" onActionPerformed='remove()'/> -<!-- -origin="$Zone" - actionCommand="input.Input.remove($Zone)" ---> </cell> </row> </Table> - <JPanel id="zoneMapPanel" layout='{new BorderLayout()}'> -<!-- Fixme : OpenMapToolPanel, OpenMap - <OpenMapToolPanel constraints='"BorderLayout.NORTH"' id="zoneMapTool"> - <OpenMapToolSet id="zoneMapToolSet" origin="$zoneMap"/> - </OpenMapToolPanel> - <OpenMap id="zoneMap" origin="$FisheryRegion" selected="$Zone/cell" - selectionMode="2"> - <OpenMapEvents id="zoneMapEvents" mouseMode="Select" - onMouseClicked="Update($zoneMap/selectedCells, $Zone/cell, refreshView($zoneCells))"/> - </OpenMap> ---> - </JPanel> + <JPanel id="zoneMapPanel" layout='{new BorderLayout()}'/> </JSplitPane> </cell> </row> <row> <cell fill='horizontal' weightx='1.0'> - <JButton text="isisfish.input.continuePorts" onActionPerformed='create()'/> -<!-- - actionCommand="UIHelper.setTreeSelection('Ports')" ---> + <JButton text="isisfish.input.continuePorts" onActionPerformed='goToPort()'/> </cell> </row> </Table> Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/result/ResultUI.jaxx =================================================================== --- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/result/ResultUI.jaxx 2008-10-28 11:34:42 UTC (rev 1578) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/result/ResultUI.jaxx 2008-10-30 17:47:57 UTC (rev 1579) @@ -39,6 +39,7 @@ <cell fill="horizontal"> <JComboBox id='selSimulation' editable='true' toolTipText='isisfish.result.simulation'/> <!-- + model='{new DefaultComboBoxModel(Common.getOldSimulationItem())}' addItemListener(new ItemListener(){ public void itemStateChanged(ItemEvent e){ on_simulation_selection_notify_event(e); @@ -50,6 +51,7 @@ <cell fill="horizontal" weightx="0.2"> <JButton id='filterSimulationButton' text='isisfish.filter' toolTipText='isisfish.filter.simulation'/> <!-- + onActionPerformed='filter()' result.addMouseListener(new MouseAdapter(){ public void mouseClicked(MouseEvent e){ on_filterSimulationLogButton_clicked(); @@ -60,6 +62,7 @@ <cell fill="horizontal" weightx="0.2"> <JButton id='openWindowButton' text='isisfish.result.new.window' toolTipText='isisfish.result.openWindowButton'/> <!-- + onActionPerformed='open()' result.addMouseListener(new MouseAdapter(){ public void mouseClicked(MouseEvent e){ on_openWindowButton_clicked(); @@ -70,6 +73,7 @@ <cell fill="horizontal" weightx="0.2"> <JButton id="supprimerSimulationButton" text='isisfish.result.remove.simulation' toolTipText='isisfish.result.removeSimulationButton'/> <!-- + onActionPerformed='open()' result.addMouseListener(new MouseAdapter(){ public void mouseClicked(MouseEvent e){ on_supprimerSimulationButton_clicked(); Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/ParamsUI.jaxx =================================================================== --- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/ParamsUI.jaxx 2008-10-28 11:34:42 UTC (rev 1578) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/ParamsUI.jaxx 2008-10-30 17:47:57 UTC (rev 1579) @@ -300,7 +300,7 @@ <row> <cell columns="4" fill="both" weightx="1.0" weighty="0.3"> <JScrollPane minimumSize='{new Dimension(0,0)}' preferredSize='{new Dimension(0,0)}'> - <JTextArea id="fieldSimulParamsDesc" text='{getContextValue(SimulAction.class).getSimulationParameter().getDescription()}' onFocusLost='saveDescription()'/> + <JTextArea id="fieldSimulParamsDesc" text='{getContextValue(SimulAction.class).getSimulationParameter().getDescription()}' onKeyPressed='saveDescription()'/> </JScrollPane> </cell> </row> @@ -332,7 +332,7 @@ <row> <cell fill="both" weightx="1.0" weighty="1.0"> <JScrollPane minimumSize='{new Dimension(0,0)}' preferredSize='{new Dimension(0,0)}'> - <JList id="listSimulParamsStrategies" selectionMode="2" onFocusLost='strategySelected()'/> + <JList id="listSimulParamsStrategies" selectionMode="2" onMouseClicked='strategySelected()'/> </JScrollPane> </cell> </row> @@ -370,7 +370,7 @@ <row> <cell fill="both" weightx="1.0" weighty="1.0"> <JScrollPane minimumSize='{new Dimension(0,0)}' preferredSize='{new Dimension(0,0)}'> - <JList id="listSimulParamsMesuresList" selectionMode="0" model='{new DefaultComboBoxModel(getContextValue(SimulAction.class).getRules().toArray())}' onValueChanged='setRulesButton()'/> + <JList id="listSimulParamsMesuresList" selectionMode="0" model='{new DefaultComboBoxModel(getContextValue(SimulAction.class).getRules().toArray())}' onMouseClicked='setRulesButton()'/> </JScrollPane> </cell> </row>
participants (1)
-
sletellier@users.labs.libre-entreprise.org