) me=
thod.invoke(null, new Object[] { isisContext });
+
+ TopiaEntity entity =3D 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 =3D=3D 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.getMes=
sage());
+ }
+ return selected;
+ }
+ =20
+ /**
+ * 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 !=3D null) {
+ selected =3D 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.getMes=
sage());
+ }
+ return null;
+ }
+
+ /**
+ * Delete one entity and commit the change, try to selected intelligently
+ * other node in tree.
+ *
+ * Refresh all ui component where name match "input<entity type witho=
ut
+ * 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 =3D "";
+ try {
+ =20
+ boolean doDelete =3D true;
+ List allWillBeRemoved =3D selected.getCompo=
site();
+ if (allWillBeRemoved.size() > 0) {
+ String text =3D _(
+ "isisfish.message.delete.object",
+ selected.toString());
+ for (TopiaEntity e : allWillBeRemoved) {
+ text +=3D ClassUtils.getShortClassName(e=
.getClass()) + " - "
+ + e.toString() + "\n";
+ }
+ int resp =3D JOptionPane.showConfirmDialog(null,=
text,
+ _("isisfish.message.delete.entit=
ies"), JOptionPane.YES_NO_OPTION);
+ doDelete =3D resp =3D=3D JOptionPane.YES_OPTION;
+ } else {
+ String text =3D _("isisfish.message.confirm.dele=
te.object", selected.toString());
+ int resp =3D JOptionPane.showConfirmDialog(null,=
text,
+ _("isisfish.message.delete.entit=
y"), JOptionPane.YES_NO_OPTION);
+ doDelete =3D resp =3D=3D JOptionPane.YES_OPTION;
+ }
+
+ if (doDelete) {
+// uiContext.setData("RegionModified", Boolean.FA=
LSE);
+// uiContext.setData("InDeletion", Boolean.TRUE);
+ selected.delete();
+ isisContext.commitTransaction();
+ msg =3D _("isisfish.message.remove.finished");
+ } else {
+ msg =3D _("isisfish.message.remove.canceled");
+ }
+ } catch (Exception eee) {
+ log.error("Can't remove entity: " + selected, eee);
+ // return new OutputView("Error.xml", "error", eee.getMes=
sage());
+ }
+// 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 conte=
nt) {
+ try {
+ String name =3D showInputDialog("");
+ if ("".equals(name)) {
+// return new OutputView("Error.xml", "error",_("=
isisfish.error.invalid.equation.name"));
+ }
+ if (name !=3D null) {
+ FormuleStorage storage =3D FormuleStorage.createForm=
ule(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.getMes=
sage());
+ }
+ return null;
+ }
+ public Object openEditor(String category, String name,
+ Class javaInterface, String content, Editor editor) {
+ log.debug("openEditor");
+ try {
+ EquationEditorPaneUI pane =3D new EquationEditorPaneUI();
+ pane.setEquation(category, name, javaInterface, content);
+ pane.setVisible(true);
+ if (pane.isOk() && editor !=3D 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 !=3D null) {
return fisheryRegion.getName();
@@ -215,6 +445,10 @@
protected FisheryRegion getFisheryRegion() {
return fisheryRegion;
}
+ =20
+ protected TopiaEntity getSelected(){
+ return selected;
+ }
=20
protected Cell getCell() {
return cell;
@@ -255,4 +489,41 @@
protected Strategy getStrategy() {
return strategy;
}
+ =20
+// InputGear
+ =20
+ public Object addSelectivity(Population pop, String equation) {
+ try {
+ =20
+ SelectivityDAO dao =3D IsisFishDAOHelper.getSelectivityDAO(isisC=
ontext);
+ Selectivity selectivity =3D dao.create();
+ =20
+ selectivity.setGear(gear);
+ selectivity.setPopulation(pop);
+ selectivity.getEquation().setContent(equation);
+ selectivity.update();
+ =20
+ gear.addPopulationSelectivity(selectivity);
+ gear.update();
+ =20
+ } catch (Exception eee) {
+ log.error("Can't add selectivity", eee);
+// return new OutputView("Error.xml", "error", eee.getMessage());
+ }
+ return null;
+ }
+ =20
+ public Object removeSelectivity(Selectivity selectivity){
+ log.debug("removeTargetSpecies called: " + selectivity);
+ try {
+ if (gear !=3D null && selectivity !=3D 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
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputUI.jaxx 2=
008-10-28 11:34:42 UTC (rev 1578)
+++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputUI.jaxx 2=
008-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;
=20
tree.addTreeSelectionListener(new TreeSelectionListener() {
@Override
public void valueChanged(TreeSelectionEvent e) {
DefaultMutableTreeNode node =3D (DefaultMutableTreeNode) tree.ge=
tLastSelectedPathComponent();
+ String name =3D null;
if (node !=3D null) {
GenericCell selectedValue =3D (GenericCell) node.getUserObje=
ct();
if (selectedValue.getType() !=3D null) {
- ((CardLayout) inputPane.getLayout()).show(inputPane, sel=
ectedValue.getType().getSimpleName());
- if (selectedValue.getClass() !=3D null) {
- getContextValue(InputAction.class).setValue(selected=
Value.getValue(),selectedValue.getType());
- if (selectedValue.getType() =3D=3D Zone.class){
- zoneUI.refresh();
- } else if (selectedValue.getType() =3D=3D Cell.class=
){
- cellUI.refresh();
- } else if (selectedValue.getType() =3D=3D Port.class=
){
- portUI.refresh();
- } else if (selectedValue.getType() =3D=3D Species.cl=
ass){
- speciesUI.refresh();
- } else if (selectedValue.getType() =3D=3D Gear.class=
){
- gearUI.refresh();
- } else if (selectedValue.getType() =3D=3D Metier.cla=
ss){
- metierUI.refresh();
- } else if (selectedValue.getType() =3D=3D TripType.c=
lass){
- tripTypeUI.refresh();
- } else if (selectedValue.getType() =3D=3D VesselType=
.class){
- vesselTypeUI.refresh();
- } else if (selectedValue.getType() =3D=3D SetOfVesse=
ls.class){
- setOfVesselsUI.refresh();
- } else if (selectedValue.getType() =3D=3D Strategy.c=
lass){
- strategyUI.refresh();
- }
- }
+ name =3D selectedValue.getType().getSimpleName();
+ getContextValue(InputAction.class).setValue(selectedValu=
e.getValue(),selectedValue.getType());
+ refreshAll(selectedValue);
}
else {
- ((CardLayout) inputPane.getLayout()).show(inputPane, "no=
ne");
+ name =3D "none";
}
+ ((CardLayout) inputPane.getLayout()).show(inputPane, name);
}
}
});
+ protected void refreshAll(GenericCell selectedValue){
+ if (selectedValue.getType() =3D=3D Zone.class){
+ zoneUI.refresh();
+ } else if (selectedValue.getType() =3D=3D Cell.class){
+ cellUI.refresh();
+ } else if (selectedValue.getType() =3D=3D Port.class){
+ portUI.refresh();
+ } else if (selectedValue.getType() =3D=3D Species.class){
+ speciesUI.refresh();
+ } else if (selectedValue.getType() =3D=3D Gear.class){
+ gearUI.refresh();
+ } else if (selectedValue.getType() =3D=3D Metier.class){
+ metierUI.refresh();
+ } else if (selectedValue.getType() =3D=3D TripType.class){
+ tripTypeUI.refresh();
+ } else if (selectedValue.getType() =3D=3D VesselType.class){
+ vesselTypeUI.refresh();
+ } else if (selectedValue.getType() =3D=3D SetOfVessels.class){
+ setOfVesselsUI.refresh();
+ } else if (selectedValue.getType() =3D=3D 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 =3D null;
+ if (topia !=3D null){
+ if (type =3D=3D Zone.class){
+ name =3D ((Zone) topia).getName();
+ } else if (type =3D=3D Cell.class){
+ name =3D ((Cell) topia).getName();
+ } else if (type =3D=3D Port.class){
+ name =3D ((Port) topia).getName();
+ } else if (type =3D=3D Species.class){
+ name =3D ((Species) topia).getName();
+ } else if (type =3D=3D Gear.class){
+ name =3D ((Gear) topia).getName();
+ } else if (type =3D=3D Metier.class){
+ name =3D ((Metier) topia).getName();
+ } else if (type =3D=3D TripType.class){
+ name =3D ((TripType) topia).getName();
+ } else if (type =3D=3D VesselType.class){
+ name =3D ((VesselType) topia).getName();
+ } else if (type =3D=3D SetOfVessels.class){
+ name =3D ((SetOfVessels) topia).getName();
+ } else if (type =3D=3D Strategy.class){
+ name =3D ((Strategy) topia).getName();
+ }
+ }
+ DefaultMutableTreeNode element =3D null;
+ element =3D findNode((DefaultMutableTreeNode) tree.getModel().getRoo=
t(), type, name);
+ TreeNode[] path =3D element.getPath();
+ if (log.isDebugEnabled()) {
+ log.debug("chemin du prochain noeud selectionn=C3=A9e: " + Array=
s.toString(path));
+ }
+ TreePath newSelectionPath =3D new TreePath(path);
+ tree.setSelectionPath(newSelectionPath);
+ }
+ protected DefaultMutableTreeNode findNode(DefaultMutableTreeNode root, C=
lass type, String name){
+ DefaultMutableTreeNode result =3D null;
+ for (Enumeration e =3D root.children(); e.hasMoreElements();){
+ DefaultMutableTreeNode node =3D (DefaultMutableTreeNode)e.nextEl=
ement();
+ GenericCell g =3D (GenericCell)node.getUserObject();
+ if (type =3D=3D g.getType()){
+ result =3D node;
+ if (name !=3D null){
+ for (e =3D result.children(); e.hasMoreElements();){
+ node =3D (DefaultMutableTreeNode)e.nextElement();
+ g =3D (GenericCell)node.getUserObject();
+ if (name.equals(g.getName())){
+ result =3D node;
+ break;
+ }
+ }
+ }
+ }
+ }
+ return result;
+ }
protected void setInfoText(String s){
WelcomePanelUI root =3D getParentContainer(WelcomePanelUI.class);
root.setInfoText(s);
Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/MetierSe=
asonInfoSpeciesUI.jaxx
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/MetierSeasonIn=
foSpeciesUI.jaxx 2008-10-28 11:34:42 UTC (rev 1578)
+++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/MetierSeasonIn=
foSpeciesUI.jaxx 2008-10-30 17:47:57 UTC (rev 1579)
@@ -32,6 +32,14 @@
-->
=20
+
Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/MetierSe=
asonInfoZoneUI.jaxx
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/MetierSeasonIn=
foZoneUI.jaxx 2008-10-28 11:34:42 UTC (rev 1578)
+++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/MetierSeasonIn=
foZoneUI.jaxx 2008-10-30 17:47:57 UTC (rev 1579)
@@ -32,6 +32,14 @@
-->
=20
+
@@ -55,6 +63,7 @@
+
=20
=20
+
@@ -40,7 +119,7 @@
|
-
+
-
|
@@ -95,14 +173,14 @@
|
-
+
|
-
+
|
-
+
-
-
-
-
+
+
+
-
-
+
\ No newline at end of file
Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/PortUI.j=
axx
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/PortUI.jaxx 20=
08-10-28 11:34:42 UTC (rev 1578)
+++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/PortUI.jaxx 20=
08-10-30 17:47:57 UTC (rev 1579)
@@ -37,11 +37,106 @@
+-->
@@ -56,11 +151,7 @@
|
-
-
+
|
@@ -72,13 +163,7 @@
|
-
-
+
|
@@ -91,68 +176,34 @@
|
-
|
|
-
-
+
|
-
-
+
|
|
-
-
+
|
-
-
+
|
-
-
-
+
|
|
-
-
+
|
Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/Selectiv=
ityUI.jaxx
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- 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 @@
*/
-->
+
@@ -51,7 +176,7 @@
-
+
@@ -72,7 +197,7 @@
|
-
+
@@ -87,10 +212,7 @@
|
-
+
|
@@ -102,7 +224,7 @@
|
-
+
|
- =20
+
@@ -53,7 +138,7 @@
=20
|
-
+
|
-
+
Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/ZoneUI.j=
axx
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/ZoneUI.jaxx 20=
08-10-28 11:34:42 UTC (rev 1578)
+++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/ZoneUI.jaxx 20=
08-10-30 17:47:57 UTC (rev 1579)
@@ -39,30 +39,156 @@
@@ -78,105 +204,57 @@
|
-
-
+
|
|
-
-
|
|
-
-
-
+
|
|
-
|
|
-
+
|
|
-
-
+
|
-
-
+
|
|
-
|
-
|
|
-
-
-
+
|
|
-
-
+
|
Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/result/ResultU=
I.jaxx
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- 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 @@
| | | | | | |