Isis-fish-commits
Threads by month
- ----- 2026 -----
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
May 2015
- 1 participants
- 28 discussions
r4230 - in trunk/src/main/java/fr/ifremer/isisfish/ui: . input input/equation input/fisheryregion input/gear input/metier input/observation input/population input/setofvessels sensitivity sensitivity/wizard simulator
by echatellier@users.forge.codelutin.com 20 May '15
by echatellier@users.forge.codelutin.com 20 May '15
20 May '15
Author: echatellier
Date: 2015-05-20 13:37:54 +0000 (Wed, 20 May 2015)
New Revision: 4230
Url: http://forge.codelutin.com/projects/isis-fish/repository/revisions/4230
Log:
Remove InputAction and move related code to handlers
Removed:
trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputAction.java
Modified:
trunk/src/main/java/fr/ifremer/isisfish/ui/WelcomeHandler.java
trunk/src/main/java/fr/ifremer/isisfish/ui/WelcomeTabUI.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputContentUI.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/input/equation/InputOneEquationHandler.java
trunk/src/main/java/fr/ifremer/isisfish/ui/input/fisheryregion/FisheryRegionHandler.java
trunk/src/main/java/fr/ifremer/isisfish/ui/input/gear/SelectivityHandler.java
trunk/src/main/java/fr/ifremer/isisfish/ui/input/metier/MetierSeasonInfoSpeciesHandler.java
trunk/src/main/java/fr/ifremer/isisfish/ui/input/metier/MetierSeasonInfoZoneHandler.java
trunk/src/main/java/fr/ifremer/isisfish/ui/input/observation/ObservationHandler.java
trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationBasicsHandler.java
trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationEmigrationHandler.java
trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationImmigrationHandler.java
trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationMigrationHandler.java
trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationRecruitmentHandler.java
trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationRecruitmentUI.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationSeasonsHandler.java
trunk/src/main/java/fr/ifremer/isisfish/ui/input/setofvessels/EffortDescriptionHandler.java
trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/SensitivityTabUI.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/SensitivityUI.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/wizard/SensitivityWizardHandler.java
trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/OptimizationHandler.java
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/WelcomeHandler.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/WelcomeHandler.java 2015-05-20 13:11:09 UTC (rev 4229)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/WelcomeHandler.java 2015-05-20 13:37:54 UTC (rev 4230)
@@ -53,7 +53,6 @@
import fr.ifremer.isisfish.ui.config.RConfigHandler;
import fr.ifremer.isisfish.ui.config.RConfigUI;
import fr.ifremer.isisfish.ui.config.SSHLauncherConfigUI;
-import fr.ifremer.isisfish.ui.input.InputAction;
import fr.ifremer.isisfish.ui.input.InputSaveVerifier;
import fr.ifremer.isisfish.ui.input.InputUI;
import fr.ifremer.isisfish.ui.queue.QueueUI;
@@ -153,7 +152,7 @@
* @param welcomeUI
*/
public void newInputFrame(WelcomeUI welcomeUI) {
- openFrame(welcomeUI, new InputUI(new JAXXInitialContext().add(verifier).add(new InputAction()).add(new InputSaveVerifier()).add(this)), t("isisfish.input.title"));
+ openFrame(welcomeUI, new InputUI(new JAXXInitialContext().add(verifier).add(new InputSaveVerifier()).add(this)), t("isisfish.input.title"));
}
/**
@@ -169,7 +168,7 @@
* @param welcomeUI
*/
public void newSensitivityFrame(WelcomeUI welcomeUI) {
- openFrame(welcomeUI, new SensitivityUI(new JAXXInitialContext().add(new InputAction()).add(new SensitivitySaveVerifier()).add(new SimulAction()).add(this)), t("isisfish.sensitivity.title"));
+ openFrame(welcomeUI, new SensitivityUI(new JAXXInitialContext().add(new SensitivitySaveVerifier()).add(new SimulAction()).add(this)), t("isisfish.sensitivity.title"));
}
/**
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/WelcomeTabUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/WelcomeTabUI.jaxx 2015-05-20 13:11:09 UTC (rev 4229)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/WelcomeTabUI.jaxx 2015-05-20 13:37:54 UTC (rev 4230)
@@ -26,7 +26,6 @@
<import>
fr.ifremer.isisfish.ui.simulator.SimulAction
jaxx.runtime.context.JAXXInitialContext
- fr.ifremer.isisfish.ui.input.InputAction
fr.ifremer.isisfish.ui.input.InputSaveVerifier
fr.ifremer.isisfish.ui.sensitivity.SensitivitySaveVerifier
fr.ifremer.isisfish.ui.sensitivity.SensitivityInputHandler
@@ -48,7 +47,7 @@
<JTabbedPane id="simulTabs" tabPlacement='{JTabbedPane.LEFT}' constraints="BorderLayout.CENTER">
<tab title=' ' icon='{new ImageIcon(getClass().getResource("/images/book.gif"))}'>
<fr.ifremer.isisfish.ui.input.InputUI id='inputUI'
- constructorParams='new JAXXInitialContext().add(getContextValue(WelcomeSaveVerifier.class)).add(new InputAction()).add(new InputSaveVerifier())' />
+ constructorParams='new JAXXInitialContext().add(getContextValue(WelcomeSaveVerifier.class)).add(new InputSaveVerifier())' />
</tab>
<tab title=' ' icon='{new ImageIcon(getClass().getResource("/images/simulation.gif"))}'>
<fr.ifremer.isisfish.ui.simulator.SimulUI id='simulUI'
@@ -56,7 +55,7 @@
</tab>
<tab title=' ' icon='{new ImageIcon(getClass().getResource("/images/sensitivities.gif"))}'>
<fr.ifremer.isisfish.ui.sensitivity.SensitivityUI id="sensitivityUI"
- constructorParams='new JAXXInitialContext().add(new InputAction()).add(new SensitivitySaveVerifier()).add(new SimulAction()).add(new SensitivityInputHandler()).add(this)' />
+ constructorParams='new JAXXInitialContext().add(new SensitivitySaveVerifier()).add(new SimulAction()).add(new SensitivityInputHandler()).add(this)' />
</tab>
<tab title=' ' icon='{new ImageIcon(getClass().getResource("/images/calc.gif"))}'>
<fr.ifremer.isisfish.ui.result.ResultUI />
Deleted: trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputAction.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputAction.java 2015-05-20 13:11:09 UTC (rev 4229)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputAction.java 2015-05-20 13:37:54 UTC (rev 4230)
@@ -1,1011 +0,0 @@
-/*
- * #%L
- * IsisFish
- *
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2005 - 2014 Ifremer, Code Lutin, Cedric Pineau, Benjamin Poussin, Chatellier Eric
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-
-package fr.ifremer.isisfish.ui.input;
-
-import static org.nuiton.i18n.I18n.t;
-
-import java.awt.geom.Point2D;
-import java.io.File;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-import javax.swing.JOptionPane;
-
-import org.apache.commons.io.FileUtils;
-import org.apache.commons.lang3.StringUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.nuiton.math.matrix.MatrixFactory;
-import org.nuiton.math.matrix.MatrixND;
-import org.nuiton.topia.TopiaContext;
-import org.nuiton.topia.TopiaException;
-import org.nuiton.util.FileUtil;
-import org.nuiton.widget.SwingUtil;
-import org.nuiton.widget.editor.Editor;
-
-import fr.ifremer.isisfish.IsisFishDAOHelper;
-import fr.ifremer.isisfish.IsisFishRuntimeException;
-import fr.ifremer.isisfish.datastore.FormuleStorage;
-import fr.ifremer.isisfish.datastore.RegionStorage;
-import fr.ifremer.isisfish.entities.Cell;
-import fr.ifremer.isisfish.entities.CellDAO;
-import fr.ifremer.isisfish.entities.EffortDescription;
-import fr.ifremer.isisfish.entities.EffortDescriptionDAO;
-import fr.ifremer.isisfish.entities.FisheryRegion;
-import fr.ifremer.isisfish.entities.Formule;
-import fr.ifremer.isisfish.entities.Gear;
-import fr.ifremer.isisfish.entities.Metier;
-import fr.ifremer.isisfish.entities.MetierSeasonInfo;
-import fr.ifremer.isisfish.entities.MetierSeasonInfoDAO;
-import fr.ifremer.isisfish.entities.Observation;
-import fr.ifremer.isisfish.entities.Population;
-import fr.ifremer.isisfish.entities.PopulationDAO;
-import fr.ifremer.isisfish.entities.PopulationGroup;
-import fr.ifremer.isisfish.entities.PopulationSeasonInfo;
-import fr.ifremer.isisfish.entities.PopulationSeasonInfoDAO;
-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.TargetSpecies;
-import fr.ifremer.isisfish.entities.TargetSpeciesDAO;
-import fr.ifremer.isisfish.entities.Zone;
-import fr.ifremer.isisfish.types.Month;
-import fr.ifremer.isisfish.ui.input.check.CheckRegion;
-import fr.ifremer.isisfish.ui.input.check.CheckResult;
-import fr.ifremer.isisfish.ui.input.check.CheckResultFrame;
-import fr.ifremer.isisfish.ui.input.equation.EquationEditorPaneUI;
-import fr.ifremer.isisfish.ui.input.equation.InputOneEquationUI;
-import fr.ifremer.isisfish.ui.util.ErrorHelper;
-import fr.ifremer.isisfish.util.CellPointcomparator;
-
-/**
- * All code used in input UI.
- *
- * Created: 1 aout 2005 18:37:25 CEST
- *
- * @author Benjamin POUSSIN <poussin(a)codelutin.com>
- * @version $Revision$
- *
- * Last update: $Date$
- * by : $Author$
- *
- * @deprecated since 4.4.0.0, move code to dedicated handlers
- */
-@Deprecated
-public class InputAction {
-
- /** Class logger. */
- private static Log log = LogFactory.getLog(InputAction.class);
-
- /*
- * Permet de creer simplement un nouvelle objet portant un nom par defaut.
- * Le nouvel element est automatiquement selectionné dans 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
- *
- public TopiaEntity create(TopiaContext isisContext, String type) {
- if (log.isTraceEnabled()) {
- log.trace("create called for " + type);
- }
- try {
- //TODO use the IsisFishEntityEnum for this purpose :
- //TopiaDAO<TopiaEntity> dao = IsisFishEntityEnum.getEntry(type).getDAO(isisContext);
- String name = type + "_new";
-
- Method method = MethodUtils.getAccessibleMethod(
- IsisFishDAOHelper.class, "get" + type + "DAO",
- TopiaContext.class);
- TopiaDAO<TopiaEntity> dao = (TopiaDAO<TopiaEntity>) method.invoke(
- null, isisContext);
-
- TopiaEntity entity = dao.create("name", name);
- entity.update();
- isisContext.commitTransaction();
- return entity;
-
- } catch (Exception eee) {
- if (log.isErrorEnabled()) {
- log.error("Can't create entity", eee);
- }
- ErrorHelper.showErrorDialog(t("isisfish.error.region.new"), eee);
- }
- return null;
- }*/
-
- /*
- * Save entity passed in argument, and commit
- *
- * @param selected entity to save
- * @return the saved entity
- *
- public TopiaEntity save(TopiaEntity selected) {
- if (log.isTraceEnabled()) {
- log.trace("save called");
- }
- try {
- if (selected == null) {
- if (log.isWarnEnabled()) {
- 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) {
- if (log.isErrorEnabled()) {
- log.error("Can't save region", eee);
- }
- ErrorHelper.showErrorDialog(t("isisfish.error.input.save"), eee);
- }
- return selected;
- }*/
-
- /*
- * Cancel all modification on entity (rollback), and force reload it and
- * refresh all ui component that name match 'type'Tab
- *
- * @return the roolbacked entity
- *
- public TopiaEntity cancel(TopiaEntity selected) {
- if (log.isTraceEnabled()) {
- log.trace("cancel called");
- }
- try {
- TopiaContext isisContext = selected.getTopiaContext();
- isisContext.rollbackTransaction();
-
- // reload the object
- // can't be null here, or allready null before !!!
- //if (selected != null) {
- // FIXME don't modify parameters
- selected = isisContext.findByTopiaId(selected.getTopiaId());
- //}
- } catch (Exception eee) {
- if (log.isErrorEnabled()) {
- log.error("Can't cancel modification in region", eee);
- }
- ErrorHelper.showErrorDialog(t("isisfish.error.region.cancel"), eee);
- }
- return selected;
- }*/
-
- /*
- * 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 >.*"
- *
- * @return if ok return null else OutView error
- *
- public String remove(TopiaEntity selected) {
- if (log.isTraceEnabled()) {
- log.trace("remove called");
- }
- String msg = "";
- try {
- boolean doDelete;
- List<TopiaEntity> allWillBeRemoved = selected.getComposite();
- if (allWillBeRemoved.size() > 0) {
- String text = t("isisfish.message.delete.object", selected
- .toString());
- for (TopiaEntity e : allWillBeRemoved) {
- text += ClassUtils.getShortClassName(e.getClass()) + " - "
- + e.toString() + "\n";
- }
- int resp = JOptionPane.showConfirmDialog(null, text,
- t("isisfish.message.delete.entities"),
- JOptionPane.YES_NO_OPTION);
- doDelete = resp == JOptionPane.YES_OPTION;
- } else {
- String text = t("isisfish.message.confirm.delete.object",
- selected.toString());
- int resp = JOptionPane.showConfirmDialog(null, text,
- t("isisfish.message.delete.entity"),
- JOptionPane.YES_NO_OPTION);
- doDelete = resp == JOptionPane.YES_OPTION;
- }
-
- if (doDelete) {
- selected.delete();
- selected.getTopiaContext().commitTransaction();
- msg = t("isisfish.message.remove.finished");
- } else {
- msg = t("isisfish.message.remove.canceled");
- }
- } catch (Exception eee) {
- if (log.isErrorEnabled()) {
- log.error("Can't remove entity: " + selected, eee);
- }
- showMsgBox(eee);
- }
- return msg;
- }*/
-
- /*
- * Save an Equation as model, to reuse it for other equation
- *
- * @param eq equation to put in models
- * @return if ok return null else OutputView error message
- *
- public Object saveEquationAsModel(Equation eq) {
- try {
- if (eq != null) {
- String name = showInputDialog("");
- //if ("".equals(name)) {
- // showMsgBox("Error " +t("isisfish.error.invalid.equation.name"));
- //}
- if (name != null) {
- FormuleStorage storage = FormuleStorage.createFormule(eq
- .getCategory(), name, eq.getLanguage());
- storage.setContent(eq.getContent());
- }
- }
- } catch (Exception eee) {
- if (log.isErrorEnabled()) {
- log.error("Can't save equation as model", eee);
- }
- showMsgBox(eee);
- }
- return null;
- }*/
-
- /**
- * Save an Equation as model, to reuse it for other equation
- *
- * @param category category for this equation
- * @param language equation to put in models
- * @param content content ?
- * @return if ok return null else OutputView error message
- */
- public Object saveAsModel(String category, String language, String content) {
- try {
- String name = JOptionPane
- .showInputDialog(t("isisfish.message.saveModel.dialog"));
- /*if ("".equals(name)) {
- showMsgBox("Error " +t("isisfish.error.invalid.equation.name"));
- }*/
- if (name != null) {
- FormuleStorage storage = FormuleStorage.createFormule(category,
- name, language);
- storage.setContent(content);
- }
-
- } catch (Exception eee) {
- if (log.isErrorEnabled()) {
- log.error("Can't save equation as model", eee);
- }
- ErrorHelper.showErrorDialog(t("isisfish.error.equation.savemodel"),
- eee);
- }
- return null;
- }
-
- public Object openEditor(InputOneEquationUI ui, String category, String name, Class<?> javaInterface,
- String content, Editor editor) {
- if (log.isTraceEnabled()) {
- log.trace("openEditor");
- }
- try {
- EquationEditorPaneUI pane = new EquationEditorPaneUI(ui);
- pane.getHandler().setEquation(category, name, javaInterface, content);
- pane.setLocationRelativeTo(ui);
- pane.setVisible(true); // blocking call
- if (pane.isResultOk() && editor != null) {
- editor.setText(pane.getEditor().getText());
- }
- pane.dispose();
- } catch (Exception eee) {
- if (log.isErrorEnabled()) {
- log.error("Can't open editor", eee);
- }
- ErrorHelper.showErrorDialog(
- t("isisfish.error.equation.openeditor"), eee);
- }
- return null;
- }
-
- public List<Formule> getFormules(TopiaContext isisContext, String name) {
- return FormuleStorage.getFormules(isisContext, name);
- }
-
- // InputGear
-
- public Object addSelectivity(Population pop, String equation, Gear gear) {
- try {
-
- SelectivityDAO dao = IsisFishDAOHelper.getSelectivityDAO(pop
- .getTopiaContext());
- Selectivity selectivity = dao.create();
-
- selectivity.setGear(gear);
- selectivity.setPopulation(pop);
- selectivity.getEquation().setContent(equation);
- selectivity.update();
-
- gear.addPopulationSelectivity(selectivity);
- gear.update();
-
- } catch (Exception eee) {
- if (log.isErrorEnabled()) {
- log.error("Can't add selectivity", eee);
- }
- ErrorHelper.showErrorDialog(t("isisfish.error.input.addentity",
- "Selectivity"), eee);
- }
- return null;
- }
-
- public Object removeSelectivity(Gear gear, Selectivity selectivity) {
- if (log.isTraceEnabled()) {
- log.trace("removeSelectivity called: " + selectivity);
- }
- try {
- if (gear != null && selectivity != null) {
- gear.removePopulationSelectivity(selectivity);
- }
- } catch (Exception eee) {
- if (log.isErrorEnabled()) {
- log.error("Can't remove TargetSpecies", eee);
- }
- ErrorHelper.showErrorDialog(t("isisfish.error.input.removeentity",
- "Selectivity"), eee);
- }
- return null;
- }
-
- // InputMetier
-
- /*public Object createSeasonInfo(Metier metier) {
- if (log.isTraceEnabled()) {
- log.trace("createSeasonInfo called");
- }
- try {
- MetierSeasonInfoDAO metierSeasonInfoPS = IsisFishDAOHelper
- .getMetierSeasonInfoDAO(metier.getTopiaContext());
- MetierSeasonInfo metierSeasonInfo = metierSeasonInfoPS.create();
- metierSeasonInfo.setFirstMonth(Month.MONTH[0]);
- metierSeasonInfo.setLastMonth(Month.MONTH[3]);
- metier.addMetierSeasonInfo(metierSeasonInfo);
- metierSeasonInfo.update();
- metier.update();
- // isisContext.commitTransaction();
-
- } catch (Exception eee) {
- if (log.isErrorEnabled()) {
- log.error("Can't create MetierSeasonInfo", eee);
- }
- ErrorHelper.showErrorDialog(t("isisfish.error.input.addentity", "SeasonInfo"), eee);
- }
- return null;
- }*/
-
- /*public Object removeSeasonInfo(Metier metier, MetierSeasonInfo info) {
- if (log.isTraceEnabled()) {
- log.trace("removeSeasonInfo called");
- }
- try {
- metier.removeMetierSeasonInfo(info);
- metier.update();
- metier.getTopiaContext().commitTransaction();
- } catch (Exception eee) {
- if (log.isErrorEnabled()) {
- log.error("Can't create MetierSeasonInfo", eee);
- }
- ErrorHelper.showErrorDialog(t("isisfish.error.input.removeentity", "SeasonInfo"), eee);
- }
- return null;
- }*/
-
- public Object addTargetSpecies(Metier metier, MetierSeasonInfo m,
- Species species, String targetFactorEquationContent,
- boolean primaryCatch) {
- if (log.isDebugEnabled()) {
- log.debug("addTargetSpecies called: " + metier + " " + species
- + " " + primaryCatch + " " + targetFactorEquationContent);
- }
- try {
- // build targetFactorEquation name
- String targetFactorEquationName = metier.getName() + "-"
- + species.getName() + "(" + m.getFirstMonth() + "-"
- + m.getLastMonth() + ")";
-
- TargetSpeciesDAO dao = IsisFishDAOHelper.getTargetSpeciesDAO(metier
- .getTopiaContext());
- TargetSpecies targetSpecies = dao.create();
-
- targetSpecies.setSpecies(species);
- targetSpecies.getTargetFactorEquation().setName(
- targetFactorEquationName);
- targetSpecies.getTargetFactorEquation().setContent(
- targetFactorEquationContent);
- targetSpecies.setPrimaryCatch(primaryCatch);
- m.addSpeciesTargetSpecies(targetSpecies);
- } catch (Exception eee) {
- if (log.isErrorEnabled()) {
- log.error("Can't add TargetSpecies", eee);
- }
- ErrorHelper.showErrorDialog(t("isisfish.error.input.addentity",
- "TargetSpecies"), eee);
- }
- return null;
- }
-
- public Object removeTargetSpecies(MetierSeasonInfo m,
- TargetSpecies targetSpecies) {
- if (log.isDebugEnabled()) {
- log.debug("removeTargetSpecies called: " + targetSpecies);
- }
- try {
- if (targetSpecies != null) {
- m.removeSpeciesTargetSpecies(targetSpecies);
- }
- } catch (Exception eee) {
- if (log.isErrorEnabled()) {
- log.error("Can't remove TargetSpecies", eee);
- }
- ErrorHelper.showErrorDialog(t("isisfish.error.input.removeentity",
- "TargetSpecies"), eee);
- }
- return null;
- }
-
- // SetOfVessels
-
- public void addEffortDescription(SetOfVessels setOfVessels, Metier metier) {
- if (log.isDebugEnabled()) {
- log.debug("addEffortDescription called: " + setOfVessels
- + " metier: " + metier);
- }
- try {
- EffortDescriptionDAO effortDescriptionPS = IsisFishDAOHelper
- .getEffortDescriptionDAO(metier.getTopiaContext());
- EffortDescription effortDescription = effortDescriptionPS.create();
- // EC20090715 : c'est la classe d'association
- // qui en étant sauvee, sauve les relations en base
- // il faut bien faire les set des deux cotes
- effortDescription.setSetOfVessels(setOfVessels);
- effortDescription.setPossibleMetiers(metier);
- effortDescription.update();
- setOfVessels.addPossibleMetiers(effortDescription);
- setOfVessels.update();
- } catch (Exception eee) {
- if (log.isErrorEnabled()) {
- log.error("Can't create EffortDescription", eee);
- }
- ErrorHelper.showErrorDialog(t("isisfish.error.input.addentity",
- "EffortDescription"), eee);
- }
- }
-
- public Object removeEffortDescription(SetOfVessels sov,
- EffortDescription effort) {
- if (log.isTraceEnabled()) {
- log.trace("removeEffortDescription called");
- }
- try {
- sov.removePossibleMetiers(effort);
- // EC-20091112 : commit() twice cause hibernate error:
- // Found two representations of same collection:
- //sov.getTopiaContext().commitTransaction();
- } catch (Exception eee) {
- if (log.isErrorEnabled()) {
- log.error("Can't remove entity: " + effort, eee);
- }
- ErrorHelper.showErrorDialog(t("isisfish.error.input.removeentity",
- "EffortDescription"), eee);
- }
- return null;
- }
-
- public Population createPopulation(TopiaContext context, Species species) {
- Population pop = null;
- if (log.isTraceEnabled()) {
- log.trace("createPopulation called");
- }
- try {
- String name = "Population_new";
-
- PopulationDAO dao = IsisFishDAOHelper.getPopulationDAO(context);
- pop = dao.create();
- pop.setName(name);
-
- species.addPopulation(pop);
- pop.setSpecies(species);
- species.update();
- pop.update();
- } catch (TopiaException eee) {
- throw new IsisFishRuntimeException(t("isisfish.error.input.addentity", "Population"), eee);
- }
- return pop;
- }
-
- public PopulationSeasonInfo createPopulationSeasonInfo(Population pop) {
- if (log.isDebugEnabled()) {
- log.debug("createSeasonInfo called");
- }
- PopulationSeasonInfo seasonInfo = null;
- try {
- PopulationSeasonInfoDAO dao = IsisFishDAOHelper
- .getPopulationSeasonInfoDAO(pop.getTopiaContext());
- seasonInfo = dao.create();
- seasonInfo.setFirstMonth(Month.MONTH[0]);
- seasonInfo.setLastMonth(Month.MONTH[3]);
- pop.addPopulationSeasonInfo(seasonInfo);
- seasonInfo.setPopulation(pop);
-
- // EC-20090710 ajout du code d'initailisation
- // d'un populationseasoninfo
- // il a du se perdre au changement d'interface
- // swiat>jaxx
- // moved to entity
- //MatrixND matrix = ((PopulationSeasonInfoImpl) seasonInfo)
- // .createNoSpacializedChangeGroupMatrix();
- //seasonInfo.setLengthChangeMatrix(matrix);
-
- seasonInfo.update();
- pop.update();
- // isisContext.commitTransaction();
- } catch (Exception eee) {
- if (log.isErrorEnabled()) {
- log.error("Can't create PopulationSeasonInfo", eee);
- }
- ErrorHelper.showErrorDialog(t("isisfish.error.input.removeentity",
- "PopulationSeasonInfo"), eee);
- }
- return seasonInfo;
- }
-
- public void removePopulationSeasonInfo(Population pop,
- PopulationSeasonInfo populationSeasonInfo) {
- if (log.isDebugEnabled()) {
- log.debug("removePopulationSeasonInfo called");
- }
- try {
- pop.removePopulationSeasonInfo(populationSeasonInfo);
- pop.update();
- //pop.getTopiaContext().commitTransaction();
- } catch (Exception eee) {
- if (log.isErrorEnabled()) {
- log.error("Can't remove PopulationSeasonInfo", eee);
- }
- ErrorHelper.showErrorDialog(t("isisfish.error.input.removeentity",
- "PopulationSeasonInfo"), eee);
- }
- }
-
- public MetierSeasonInfo createMetierSeasonInfo(Metier metier) {
- MetierSeasonInfo metierSeasonInfo = null;
- if (log.isDebugEnabled()) {
- log.debug("createMetierSeasonInfo called");
- }
- try {
- MetierSeasonInfoDAO metierSeasonInfoPS = IsisFishDAOHelper
- .getMetierSeasonInfoDAO(metier.getTopiaContext());
- metierSeasonInfo = metierSeasonInfoPS.create();
- metierSeasonInfo.setFirstMonth(Month.MONTH[0]);
- metierSeasonInfo.setLastMonth(Month.MONTH[3]);
- metier.addMetierSeasonInfo(metierSeasonInfo);
- metierSeasonInfo.update();
- metier.update();
-
- } catch (TopiaException eee) {
- throw new IsisFishRuntimeException("Can't create MetierSeasonInfo", eee);
- }
- return metierSeasonInfo;
- }
-
- public void removeMetierSeasonInfo(Metier metier, MetierSeasonInfo info) {
- if (log.isDebugEnabled()) {
- log.debug("removeMetierSeasonInfo called");
- }
- try {
- metier.removeMetierSeasonInfo(info);
- metier.update();
-
- // EC-20091112 : commit() twice cause hibernate error:
- // Found two representations of same collection:
- //metier.getTopiaContext().commitTransaction();
-
- } catch (Exception eee) {
- if (log.isErrorEnabled()) {
- log.error("Can't remove MetierSeasonInfo", eee);
- }
- ErrorHelper.showErrorDialog(t("isisfish.error.input.addentity",
- "MetierSeasonInfo"), eee);
- }
- }
-
- public void createRecruitmentDistribution(Population pop) {
- if (log.isTraceEnabled()) {
- log.trace("createRecruitmentDistributionon called: " + pop);
- }
- try {
- String val = JOptionPane
- .showInputDialog(t("isisfish.message.recruitment.number.month"));
- int num = -1;
- if (val != null && !"".equals(val)) {
- try {
- num = Integer.parseInt(val);
- } catch (RuntimeException eee) {
- if (log.isWarnEnabled()) {
- log.warn("Can't parse val: " + val, eee);
- }
- }
- }
-
- if (num > 0) {
- List<String> sem = new ArrayList<String>(num);
- for (int i = 0; i < num; i++) {
- sem.add(t("isisfish.common.month", i));
- }
- MatrixND newMat = MatrixFactory.getInstance().create(
- new List[] { sem });
-
- MatrixND mat = pop.getRecruitmentDistribution();
- if (mat != null) {
- newMat.paste(mat);
- }
- pop.setRecruitmentDistribution(newMat);
- pop.update();
- }
- } catch (Exception eee) {
- if (log.isErrorEnabled()) {
- log.error("Can't remove RecruitmentDistribution", eee);
- }
- ErrorHelper.showErrorDialog(t("isisfish.error.input.removeentity",
- "RecruitmentDistribution"), eee);
- }
- }
-
- public void createObservationValueMatrix(Observation observation) {
- try {
- String val = JOptionPane.showInputDialog(t("isisfish.message.observation.value.dimensions"));
-
- if (StringUtils.isNotBlank(val)) {
- String[] values = val.trim().split("(,|;|\\*|x|\\s)");
-
- List<Integer> dims = new ArrayList<Integer>();
- for (String value : values) {
- if (!value.isEmpty() && StringUtils.isNumeric(value)) {
- dims.add(Integer.valueOf(value));
- }
- }
-
- int[] dim = new int[dims.size()];
- for (int i = 0; i < dims.size(); i++) {
- dim[i] = dims.get(i).intValue();
- }
- MatrixND newMat = MatrixFactory.getInstance().create(dim);
-
- MatrixND mat = observation.getValue();
- if (mat != null) {
- newMat.paste(mat);
- }
- observation.setValue(newMat);
- observation.update();
- }
- } catch (Exception eee) {
- if (log.isErrorEnabled()) {
- log.error("Can't remove RecruitmentDistribution", eee);
- }
- ErrorHelper.showErrorDialog(t("isisfish.error.input.removeentity",
- "RecruitmentDistribution"), eee);
- }
- }
-
- // Migration
-
- public Object addMigration(PopulationSeasonInfo info,
- PopulationGroup group, Zone departure, Zone arrival, double coeff) {
- if (log.isTraceEnabled()) {
- log.trace("addMigration called");
- }
- try {
- MatrixND mat = info.getMigrationMatrix().copy();
- mat.setValue(group, departure, arrival, coeff);
- info.setMigrationMatrix(mat);
-
- } catch (Exception eee) {
- if (log.isErrorEnabled()) {
- log.error("Can't add migration", eee);
- }
- ErrorHelper.showErrorDialog(t("isisfish.error.input.addentity",
- "Migration"), eee);
- }
- return null;
- }
-
- public Object addEmigration(PopulationSeasonInfo info,
- PopulationGroup group, Zone departure, double coeff) {
- if (log.isTraceEnabled()) {
- log.trace("addEmigration called");
- }
- try {
- MatrixND mat = info.getEmigrationMatrix().copy();
- mat.setValue(group, departure, coeff);
- info.setEmigrationMatrix(mat);
-
- } catch (Exception eee) {
- if (log.isErrorEnabled()) {
- log.error("Can't add emigration", eee);
- }
- ErrorHelper.showErrorDialog(t("isisfish.error.input.addentity",
- "Emigration"), eee);
- }
- return null;
- }
-
- public Object addImmigration(PopulationSeasonInfo info,
- PopulationGroup group, Zone arrival, double coeff) {
- if (log.isTraceEnabled()) {
- log.trace("addImmigration called");
- }
- try {
- MatrixND mat = info.getImmigrationMatrix().copy();
- mat.setValue(group, arrival, coeff);
- info.setImmigrationMatrix(mat);
-
- } catch (Exception eee) {
- if (log.isErrorEnabled()) {
- log.error("Can't add immigration", eee);
- }
- ErrorHelper.showErrorDialog(t("isisfish.error.input.addentity",
- "Immigration"), eee);
- }
- return null;
- }
-
- /**
- * Add new map in region.
- *
- * Since isis-fsih 3.3.0.0, this method supports a multiple file format :
- * - http://openmap.bbn.com/cgi-bin/faqw.py?req=all#9.1
- *
- * @param fisheryRegion fishery region
- */
- public void addMap(FisheryRegion fisheryRegion) {
- if (log.isTraceEnabled()) {
- log.trace("AddMap called");
- }
-
- // Openmap suported fileformat
- String[] fileFormats = {
- // ESRI (http://www.esri.com) Shapefiles
- ".*\\.shp", "ESRI Shapefiles (.shp)",
-
- // NIMA (http://www.nima.mil)
- ".*\\.dcw", "Digital Chart of the World (.dcw)",
- ".*\\.vpf", "Vector Product Format (.vpf)",
- ".*\\.vmap", "Vector Map (.vmap)",
- ".*\\.cadrg", "Compressed ARC Digitized Raster Graphics (.cadrg)",
- ".*\\.cib", "Controlled Image Base (.cib)",
- ".*\\.rpf", "Raster Product Format (.rpf)",
- // seams to be a special format with multiples files
- //".*\\.dt[0-2]+", "Digital Terrain Elevation Data (levels 0, 1, 2) (.dt0, .dt0, .dt2)",
-
- // MapInfo (http://www.mapinfo.com) files (.mif)
- ".*\\.mif", "MapInfo (.mif)",
-
- // ArcInfo (.e00) files.
- ".*\\.e00", "ArcInfo (.e00)"
- };
-
- File inputMap = FileUtil.getFile(fileFormats);
- try {
- if (inputMap != null) {
-
- // copy inputMapFormat to region map directory
- // since isis-fsih-3.3.0.0, we store maps with extension
- String filename = inputMap.getName();
-
- RegionStorage regionStorage = RegionStorage.getRegion(fisheryRegion.getName());
- File destDir = regionStorage.getMapRepository();
-
- // copy map file
- File destMap = new File(destDir, filename);
- FileUtils.copyFile(inputMap, destMap);
-
- List<String> maps = fisheryRegion.getMapFileList();
- maps.add(filename);
- fisheryRegion.setMapFileList(maps);
- }
- } catch (Exception eee) {
- if (log.isErrorEnabled()) {
- log.error("Can't copy map file for : " + inputMap, eee);
- }
- ErrorHelper.showErrorDialog(t("isisfish.error.region.addmap"), eee);
- }
- }
-
- /**
- * Remove map in a region.
- *
- * @param fisheryRegion fishery region
- * @param selectedMaps la liste de map a retirer
- */
- public void removeMap(FisheryRegion fisheryRegion, List<String> selectedMaps) {
- if (log.isTraceEnabled()) {
- log.trace("removeMap called");
- }
-
- try {
- List<String> maps = fisheryRegion.getMapFileList();
-
- RegionStorage regionStorage = RegionStorage.getRegion(fisheryRegion.getName());
- File mapDir = regionStorage.getMapRepository();
-
- for (String mapName : selectedMaps) {
- maps.remove(mapName);
- // remove on disk too, if possible
- File mapFile = new File(mapDir, mapName);
- mapFile.delete();
- if (log.isDebugEnabled()) {
- log.debug("Removing map file : " + mapFile);
- }
-
- // special case, for some format, an index is created
- if (mapName.endsWith(".shp")) {
- String indexName = mapName.replaceAll("\\.shp$", ".ssx");
- File indexFile = new File(mapDir, indexName);
- indexFile.delete();
- if (log.isDebugEnabled()) {
- log.debug("Removing index file : " + indexFile);
- }
- }
- }
-
- fisheryRegion.setMapFileList(maps);
-
- } catch (Exception eee) {
- if (log.isErrorEnabled()) {
- log.error("Can't remove map", eee);
- }
- ErrorHelper.showErrorDialog(t("isisfish.error.region.removemap"),
- eee);
- }
- }
-
- /*
- * Affiche une boite de dialogue demandant a l'utilisateur de rentrer
- * un nom de fichier, et met ce nom dans la textField.
- * Passe le saveButton en enabled pour marque que la region a ete modifié
- *
- * @param cellFile file of cells
- *
- public void loadCellFile(String cellFile) {
- if (log.isWarnEnabled()) {
- log.warn("loadCell called but not implemented");
- }
- // FIXME todo loadCellFile
- }*/
-
- public void saveFisheryRegion(FisheryRegion fisheryRegion) {
- if (log.isTraceEnabled()) {
- log.trace("save called");
- }
- try {
- TopiaContext isisContext = fisheryRegion.getTopiaContext();
-
- // frame.setInfoText(t("isisfish.message.checking.cell"));
- int latNumber = (int) Math
- .round((fisheryRegion.getMaxLatitude() - fisheryRegion
- .getMinLatitude())
- / fisheryRegion.getCellLengthLatitude());
- int lonNumber = (int) Math
- .round((fisheryRegion.getMaxLongitude() - fisheryRegion
- .getMinLongitude())
- / fisheryRegion.getCellLengthLongitude());
-
- // frame.setProgressMin(0);
- // frame.setProgressMax(latNumber * lonNumber);
- int progresscpt = 0;
-
- // il faut peut-etre creer ou supprimer des mailles
- CellPointcomparator cellPointcomparator = new CellPointcomparator();
- CellDAO cellPS = IsisFishDAOHelper.getCellDAO(isisContext);
- List<Cell> cells = cellPS.findAll();
- Collections.sort(cells, cellPointcomparator);
- Point2D.Float point = new Point2D.Float();
-
- for (float lati = fisheryRegion.getMinLatitude(); lati < fisheryRegion
- .getMaxLatitude(); lati += fisheryRegion
- .getCellLengthLatitude()) {
- lati = Math.round(lati * 1000f);
- lati = lati / 1000.0f;
- for (float longi = fisheryRegion.getMinLongitude(); longi < fisheryRegion
- .getMaxLongitude(); longi += fisheryRegion
- .getCellLengthLongitude()) {
- longi = Math.round(longi * 1000f) / 1000.0f;
- point.setLocation(lati, longi);
- int position = Collections.binarySearch(cells, point,
- cellPointcomparator);
- if (position >= 0) {
- // deja existant on l'enleve de la liste, et on ne cree rien
- cells.remove(position);
- } else {
- // n'existe pas on la cree
- Cell cell = cellPS.create();
- cell.setName("La" + lati + "Lo" + longi);
- cell.setLatitude(lati);
- cell.setLongitude(longi);
- cell.setLand(false);
- cell.update();
- }
- // frame.setProgressValue(++progresscpt);
- }
- }
-
- // on est pas en autoUpdate donc il faut faire le update avant le commit
- fisheryRegion.update();
-
- // toutes les mailles restantes dans la liste sont des mailles en trop
- // on les supprimes
-
- progresscpt = 0;
- for (Cell cell : cells) {
- // FIXME il faudrait aussi rechercher les objets dependants
- // des mailles que l'on va supprimer et demander confirmation
- // a l'utilisateur qu'il souhaite reellement supprimer tous
- // ces objets. Si ce n'est pas le cas, on sort tout de suite
- // avant le commit
- cellPS.delete(cell);
- }
- isisContext.commitTransaction();
- } catch (Exception eee) {
- if (log.isErrorEnabled()) {
- log.error(t("isisfish.error.region.save"), eee);
- }
- ErrorHelper.showErrorDialog(t("isisfish.error.region.save"), eee);
- }
- }
-
- public void checkFisheryRegion(FisheryRegion fisheryRegion) {
- try {
- if (log.isTraceEnabled()) {
- log.trace("check called: ");
- }
- CheckResult result = new CheckResult();
- CheckRegion.check(fisheryRegion, result);
- CheckResultFrame dialog = new CheckResultFrame();
- dialog.setCheckResult(result);
- SwingUtil.center(dialog);
- dialog.setVisible(true);
- } catch (Exception eee) {
- if (log.isErrorEnabled()) {
- log.error(t("isisfish.error.region.check"), eee);
- }
- ErrorHelper.showErrorDialog(t("isisfish.error.region.check"), eee);
- }
- }
-}
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputContentUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputContentUI.jaxx 2015-05-20 13:11:09 UTC (rev 4229)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputContentUI.jaxx 2015-05-20 13:37:54 UTC (rev 4230)
@@ -99,9 +99,6 @@
}
-public InputAction getAction() {
- return getContextValue(InputAction.class);
-}
public InputSaveVerifier getSaveVerifier() {
return getContextValue(InputSaveVerifier.class);
}
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/equation/InputOneEquationHandler.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/equation/InputOneEquationHandler.java 2015-05-20 13:11:09 UTC (rev 4229)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/equation/InputOneEquationHandler.java 2015-05-20 13:37:54 UTC (rev 4230)
@@ -33,6 +33,7 @@
import java.util.List;
import javax.swing.DefaultComboBoxModel;
+import javax.swing.JOptionPane;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
@@ -41,12 +42,14 @@
import org.apache.commons.logging.LogFactory;
import org.nuiton.topia.TopiaContext;
import org.nuiton.util.FileUtil;
+import org.nuiton.widget.editor.Editor;
+import fr.ifremer.isisfish.datastore.FormuleStorage;
import fr.ifremer.isisfish.entities.Equation;
import fr.ifremer.isisfish.entities.Formule;
-import fr.ifremer.isisfish.ui.input.InputAction;
import fr.ifremer.isisfish.ui.input.InputContentHandler;
import fr.ifremer.isisfish.ui.models.common.GenericComboModel;
+import fr.ifremer.isisfish.ui.util.ErrorHelper;
/**
* Equation handler.
@@ -187,7 +190,7 @@
TopiaContext isisContext = ((org.nuiton.topia.persistence.TopiaEntityAbstract)inputContentUI.getBean()).getTopiaContext();
List<Formule> formules = null;
if (inputContentUI.formuleCategory != null) {
- formules = inputContentUI.getAction().getFormules(isisContext, inputContentUI.formuleCategory);
+ formules = FormuleStorage.getFormules(isisContext, inputContentUI.formuleCategory);
GenericComboModel<Formule> formulesModel = new GenericComboModel<>(formules);
inputContentUI.formuleComboBox.setModel(formulesModel);
// fix default selection
@@ -197,24 +200,76 @@
}
protected void saveModel() {
- inputContentUI.getContextValue(InputAction.class).saveAsModel(inputContentUI.formuleCategory, "Java", inputContentUI.editor.getText());
+ saveAsModel(inputContentUI.formuleCategory, "Java", inputContentUI.editor.getText());
setComboModel();
inputContentUI.setInfoText(t("isisfish.message.saveModel.finished"));
}
+
+ /**
+ * Save an Equation as model, to reuse it for other equation
+ *
+ * @param category category for this equation
+ * @param language equation to put in models
+ * @param content content ?
+ */
+ protected void saveAsModel(String category, String language, String content) {
+ try {
+ String name = JOptionPane
+ .showInputDialog(t("isisfish.message.saveModel.dialog"));
+ /*if ("".equals(name)) {
+ showMsgBox("Error " +t("isisfish.error.invalid.equation.name"));
+ }*/
+ if (name != null) {
+ FormuleStorage storage = FormuleStorage.createFormule(category,
+ name, language);
+ storage.setContent(content);
+ }
+ } catch (Exception eee) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't save equation as model", eee);
+ }
+ ErrorHelper.showErrorDialog(t("isisfish.error.equation.savemodel"),
+ eee);
+ }
+ }
+
/**
* Open external editor, with equation documentation.
*/
protected void openEditor() {
Formule e = (Formule)inputContentUI.formuleComboBox.getSelectedItem();
if (e != null) {
- inputContentUI.getContextValue(InputAction.class).openEditor(inputContentUI, e.getCategory(),
+ openEditor(inputContentUI, e.getCategory(),
e.getName(), inputContentUI.clazz, e.getContent(), inputContentUI.editor);
} else {
- inputContentUI.getContextValue(InputAction.class).openEditor(inputContentUI, inputContentUI.formuleCategory,
+ openEditor(inputContentUI, inputContentUI.formuleCategory,
"new", inputContentUI.clazz, inputContentUI.editor.getText(), inputContentUI.editor);
}
}
+
+ public void openEditor(InputOneEquationUI ui, String category, String name, Class<?> javaInterface,
+ String content, Editor editor) {
+ if (log.isTraceEnabled()) {
+ log.trace("openEditor");
+ }
+ try {
+ EquationEditorPaneUI pane = new EquationEditorPaneUI(ui);
+ pane.getHandler().setEquation(category, name, javaInterface, content);
+ pane.setLocationRelativeTo(ui);
+ pane.setVisible(true); // blocking call
+ if (pane.isResultOk() && editor != null) {
+ editor.setText(pane.getEditor().getText());
+ }
+ pane.dispose();
+ } catch (Exception eee) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't open editor", eee);
+ }
+ ErrorHelper.showErrorDialog(
+ t("isisfish.error.equation.openeditor"), eee);
+ }
+ }
protected void setEditorText() {
if (inputContentUI.getFormule() != null) {
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/fisheryregion/FisheryRegionHandler.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/fisheryregion/FisheryRegionHandler.java 2015-05-20 13:11:09 UTC (rev 4229)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/fisheryregion/FisheryRegionHandler.java 2015-05-20 13:37:54 UTC (rev 4230)
@@ -26,19 +26,34 @@
import static org.nuiton.i18n.I18n.n;
import static org.nuiton.i18n.I18n.t;
+import java.awt.geom.Point2D;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
+import java.io.File;
+import java.util.Collections;
import java.util.List;
import javax.swing.DefaultListModel;
+import org.apache.commons.io.FileUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.nuiton.topia.TopiaContext;
+import org.nuiton.util.FileUtil;
+import org.nuiton.widget.SwingUtil;
+import fr.ifremer.isisfish.IsisFishDAOHelper;
+import fr.ifremer.isisfish.datastore.RegionStorage;
+import fr.ifremer.isisfish.entities.Cell;
+import fr.ifremer.isisfish.entities.CellDAO;
import fr.ifremer.isisfish.entities.FisheryRegion;
-import fr.ifremer.isisfish.ui.input.InputAction;
import fr.ifremer.isisfish.ui.input.InputContentHandler;
import fr.ifremer.isisfish.ui.input.InputUI;
+import fr.ifremer.isisfish.ui.input.check.CheckRegion;
+import fr.ifremer.isisfish.ui.input.check.CheckResult;
+import fr.ifremer.isisfish.ui.input.check.CheckResultFrame;
+import fr.ifremer.isisfish.ui.util.ErrorHelper;
+import fr.ifremer.isisfish.util.CellPointcomparator;
/**
* FisheryRegion handler.
@@ -84,10 +99,6 @@
inputContentUI.setBean(region);
}
- protected InputAction getInputAction() {
- return inputContentUI.getContextValue(InputAction.class);
- }
-
protected void setFieldMapfilesModel(FisheryRegion region) {
DefaultListModel<String> model = new DefaultListModel<>();
List<String> mapList = region.getMapFileList();
@@ -102,23 +113,152 @@
}
protected void addMap() {
- getInputAction().addMap(inputContentUI.getBean());
+ addMap(inputContentUI.getBean());
setFieldMapfilesModel(inputContentUI.getBean());
}
protected void delMap() {
- getInputAction().removeMap(inputContentUI.getBean(), inputContentUI.fieldMapfiles.getSelectedValuesList());
+ removeMap(inputContentUI.getBean(), inputContentUI.fieldMapfiles.getSelectedValuesList());
setFieldMapfilesModel(inputContentUI.getBean());
}
+
+ /**
+ * Add new map in region.
+ *
+ * Since isis-fsih 3.3.0.0, this method supports a multiple file format :
+ * - http://openmap.bbn.com/cgi-bin/faqw.py?req=all#9.1
+ *
+ * @param fisheryRegion fishery region
+ */
+ public void addMap(FisheryRegion fisheryRegion) {
+ if (log.isTraceEnabled()) {
+ log.trace("AddMap called");
+ }
+ // Openmap suported fileformat
+ String[] fileFormats = {
+ // ESRI (http://www.esri.com) Shapefiles
+ ".*\\.shp", "ESRI Shapefiles (.shp)",
+
+ // NIMA (http://www.nima.mil)
+ ".*\\.dcw", "Digital Chart of the World (.dcw)",
+ ".*\\.vpf", "Vector Product Format (.vpf)",
+ ".*\\.vmap", "Vector Map (.vmap)",
+ ".*\\.cadrg", "Compressed ARC Digitized Raster Graphics (.cadrg)",
+ ".*\\.cib", "Controlled Image Base (.cib)",
+ ".*\\.rpf", "Raster Product Format (.rpf)",
+ // seams to be a special format with multiples files
+ //".*\\.dt[0-2]+", "Digital Terrain Elevation Data (levels 0, 1, 2) (.dt0, .dt0, .dt2)",
+
+ // MapInfo (http://www.mapinfo.com) files (.mif)
+ ".*\\.mif", "MapInfo (.mif)",
+
+ // ArcInfo (.e00) files.
+ ".*\\.e00", "ArcInfo (.e00)"
+ };
+
+ File inputMap = FileUtil.getFile(fileFormats);
+ try {
+ if (inputMap != null) {
+
+ // copy inputMapFormat to region map directory
+ // since isis-fsih-3.3.0.0, we store maps with extension
+ String filename = inputMap.getName();
+
+ RegionStorage regionStorage = RegionStorage.getRegion(fisheryRegion.getName());
+ File destDir = regionStorage.getMapRepository();
+
+ // copy map file
+ File destMap = new File(destDir, filename);
+ FileUtils.copyFile(inputMap, destMap);
+
+ List<String> maps = fisheryRegion.getMapFileList();
+ maps.add(filename);
+ fisheryRegion.setMapFileList(maps);
+ }
+ } catch (Exception eee) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't copy map file for : " + inputMap, eee);
+ }
+ ErrorHelper.showErrorDialog(t("isisfish.error.region.addmap"), eee);
+ }
+ }
+
+ /**
+ * Remove map in a region.
+ *
+ * @param fisheryRegion fishery region
+ * @param selectedMaps la liste de map a retirer
+ */
+ public void removeMap(FisheryRegion fisheryRegion, List<String> selectedMaps) {
+ if (log.isTraceEnabled()) {
+ log.trace("removeMap called");
+ }
+
+ try {
+ List<String> maps = fisheryRegion.getMapFileList();
+
+ RegionStorage regionStorage = RegionStorage.getRegion(fisheryRegion.getName());
+ File mapDir = regionStorage.getMapRepository();
+
+ for (String mapName : selectedMaps) {
+ maps.remove(mapName);
+ // remove on disk too, if possible
+ File mapFile = new File(mapDir, mapName);
+ mapFile.delete();
+ if (log.isDebugEnabled()) {
+ log.debug("Removing map file : " + mapFile);
+ }
+
+ // special case, for some format, an index is created
+ if (mapName.endsWith(".shp")) {
+ String indexName = mapName.replaceAll("\\.shp$", ".ssx");
+ File indexFile = new File(mapDir, indexName);
+ indexFile.delete();
+ if (log.isDebugEnabled()) {
+ log.debug("Removing index file : " + indexFile);
+ }
+ }
+ }
+
+ fisheryRegion.setMapFileList(maps);
+
+ } catch (Exception eee) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't remove map", eee);
+ }
+ ErrorHelper.showErrorDialog(t("isisfish.error.region.removemap"),
+ eee);
+ }
+ }
+
/*protected void cellFile() {
getInputAction().loadCellFile(fieldCellFile.getText());
}*/
protected void check() {
- inputContentUI.getContextValue(InputAction.class).checkFisheryRegion(inputContentUI.getBean());
+ checkFisheryRegion(inputContentUI.getBean());
inputContentUI.setInfoText(t("isisfish.message.check.finished"));
}
+
+ public void checkFisheryRegion(FisheryRegion fisheryRegion) {
+ try {
+ if (log.isTraceEnabled()) {
+ log.trace("check called: ");
+ }
+ CheckResult result = new CheckResult();
+ CheckRegion.check(fisheryRegion, result);
+ CheckResultFrame dialog = new CheckResultFrame();
+ dialog.setCheckResult(result);
+ SwingUtil.center(dialog);
+ dialog.setVisible(true);
+ } catch (Exception eee) {
+ if (log.isErrorEnabled()) {
+ log.error(t("isisfish.error.region.check"), eee);
+ }
+ ErrorHelper.showErrorDialog(t("isisfish.error.region.check"), eee);
+ }
+ }
protected void save() {
inputContentUI.setInfoText(t("isisfish.message.checking.cell"));
@@ -128,7 +268,7 @@
inputContentUI.getSaveVerifier().reset();
// save generating cells
- getInputAction().saveFisheryRegion(inputContentUI.getBean());
+ saveFisheryRegion(inputContentUI.getBean());
// reload tree
InputUI inputUI = inputContentUI.getParentContainer(InputUI.class);
@@ -136,4 +276,84 @@
inputContentUI.setInfoText(t("isisfish.message.save.finished"));
}
+
+ public void saveFisheryRegion(FisheryRegion fisheryRegion) {
+ if (log.isTraceEnabled()) {
+ log.trace("save called");
+ }
+ try {
+ TopiaContext isisContext = fisheryRegion.getTopiaContext();
+
+ // frame.setInfoText(t("isisfish.message.checking.cell"));
+ int latNumber = (int) Math
+ .round((fisheryRegion.getMaxLatitude() - fisheryRegion
+ .getMinLatitude())
+ / fisheryRegion.getCellLengthLatitude());
+ int lonNumber = (int) Math
+ .round((fisheryRegion.getMaxLongitude() - fisheryRegion
+ .getMinLongitude())
+ / fisheryRegion.getCellLengthLongitude());
+
+ // frame.setProgressMin(0);
+ // frame.setProgressMax(latNumber * lonNumber);
+ int progresscpt = 0;
+
+ // il faut peut-etre creer ou supprimer des mailles
+ CellPointcomparator cellPointcomparator = new CellPointcomparator();
+ CellDAO cellPS = IsisFishDAOHelper.getCellDAO(isisContext);
+ List<Cell> cells = cellPS.findAll();
+ Collections.sort(cells, cellPointcomparator);
+ Point2D.Float point = new Point2D.Float();
+
+ for (float lati = fisheryRegion.getMinLatitude(); lati < fisheryRegion
+ .getMaxLatitude(); lati += fisheryRegion
+ .getCellLengthLatitude()) {
+ lati = Math.round(lati * 1000f);
+ lati = lati / 1000.0f;
+ for (float longi = fisheryRegion.getMinLongitude(); longi < fisheryRegion
+ .getMaxLongitude(); longi += fisheryRegion
+ .getCellLengthLongitude()) {
+ longi = Math.round(longi * 1000f) / 1000.0f;
+ point.setLocation(lati, longi);
+ int position = Collections.binarySearch(cells, point,
+ cellPointcomparator);
+ if (position >= 0) {
+ // deja existant on l'enleve de la liste, et on ne cree rien
+ cells.remove(position);
+ } else {
+ // n'existe pas on la cree
+ Cell cell = cellPS.create();
+ cell.setName("La" + lati + "Lo" + longi);
+ cell.setLatitude(lati);
+ cell.setLongitude(longi);
+ cell.setLand(false);
+ cell.update();
+ }
+ // frame.setProgressValue(++progresscpt);
+ }
+ }
+
+ // on est pas en autoUpdate donc il faut faire le update avant le commit
+ fisheryRegion.update();
+
+ // toutes les mailles restantes dans la liste sont des mailles en trop
+ // on les supprimes
+
+ progresscpt = 0;
+ for (Cell cell : cells) {
+ // FIXME il faudrait aussi rechercher les objets dependants
+ // des mailles que l'on va supprimer et demander confirmation
+ // a l'utilisateur qu'il souhaite reellement supprimer tous
+ // ces objets. Si ce n'est pas le cas, on sort tout de suite
+ // avant le commit
+ cellPS.delete(cell);
+ }
+ isisContext.commitTransaction();
+ } catch (Exception eee) {
+ if (log.isErrorEnabled()) {
+ log.error(t("isisfish.error.region.save"), eee);
+ }
+ ErrorHelper.showErrorDialog(t("isisfish.error.region.save"), eee);
+ }
+ }
}
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/gear/SelectivityHandler.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/gear/SelectivityHandler.java 2015-05-20 13:11:09 UTC (rev 4229)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/gear/SelectivityHandler.java 2015-05-20 13:37:54 UTC (rev 4230)
@@ -23,6 +23,8 @@
package fr.ifremer.isisfish.ui.input.gear;
+import static org.nuiton.i18n.I18n.t;
+
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.util.ArrayList;
@@ -31,12 +33,16 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import fr.ifremer.isisfish.IsisFishDAOHelper;
import fr.ifremer.isisfish.entities.Equation;
+import fr.ifremer.isisfish.entities.Gear;
import fr.ifremer.isisfish.entities.Population;
import fr.ifremer.isisfish.entities.Selectivity;
+import fr.ifremer.isisfish.entities.SelectivityDAO;
import fr.ifremer.isisfish.entities.Species;
import fr.ifremer.isisfish.ui.input.InputContentHandler;
import fr.ifremer.isisfish.ui.models.common.GenericComboModel;
+import fr.ifremer.isisfish.ui.util.ErrorHelper;
import fr.ifremer.isisfish.ui.widget.editor.EquationTableEditor;
/**
@@ -108,7 +114,7 @@
}
protected void addSelectivity() {
- inputContentUI.getAction().addSelectivity(inputContentUI.getPopulation(),
+ addSelectivity(inputContentUI.getPopulation(),
inputContentUI.selectivityEquation.getEditor().getText(), inputContentUI.getBean());
setSelectivityTableModel();
}
@@ -116,12 +122,53 @@
protected void removeSelectivity() {
GearPopulationSelectivityModel model = (GearPopulationSelectivityModel)inputContentUI.selectivityTable.getModel();
Selectivity selectedSelectivity = model.getSelectivities().get(inputContentUI.selectivityTable.getSelectedRow());
- inputContentUI.getAction().removeSelectivity(inputContentUI.getBean(), selectedSelectivity);
+ removeSelectivity(inputContentUI.getBean(), selectedSelectivity);
inputContentUI.getSaveVerifier().removeCurrentEntity(selectedSelectivity.getTopiaId());
setSelectivityTableModel();
inputContentUI.removeSelectivityButton.setEnabled(false);
}
+
+ protected void addSelectivity(Population pop, String equation, Gear gear) {
+ try {
+ SelectivityDAO dao = IsisFishDAOHelper.getSelectivityDAO(pop
+ .getTopiaContext());
+ Selectivity selectivity = dao.create();
+
+ selectivity.setGear(gear);
+ selectivity.setPopulation(pop);
+ selectivity.getEquation().setContent(equation);
+ selectivity.update();
+
+ gear.addPopulationSelectivity(selectivity);
+ gear.update();
+
+ } catch (Exception eee) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't add selectivity", eee);
+ }
+ ErrorHelper.showErrorDialog(t("isisfish.error.input.addentity",
+ "Selectivity"), eee);
+ }
+ }
+
+ protected void removeSelectivity(Gear gear, Selectivity selectivity) {
+ if (log.isTraceEnabled()) {
+ log.trace("removeSelectivity called: " + selectivity);
+ }
+ try {
+ if (gear != null && selectivity != null) {
+ gear.removePopulationSelectivity(selectivity);
+ }
+ } catch (Exception eee) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't remove TargetSpecies", eee);
+ }
+ ErrorHelper.showErrorDialog(t("isisfish.error.input.removeentity",
+ "Selectivity"), eee);
+ }
+ }
+
protected GenericComboModel<Population> getSelectivityPopulationModel() {
List<Species> species = inputContentUI.getFisheryRegion().getSpecies();
List<Population> populations = new ArrayList<>();
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/metier/MetierSeasonInfoSpeciesHandler.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/metier/MetierSeasonInfoSpeciesHandler.java 2015-05-20 13:11:09 UTC (rev 4229)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/metier/MetierSeasonInfoSpeciesHandler.java 2015-05-20 13:37:54 UTC (rev 4230)
@@ -23,18 +23,26 @@
package fr.ifremer.isisfish.ui.input.metier;
+import static org.nuiton.i18n.I18n.t;
+
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.util.ArrayList;
import java.util.List;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import fr.ifremer.isisfish.IsisFishDAOHelper;
import fr.ifremer.isisfish.entities.Equation;
+import fr.ifremer.isisfish.entities.Metier;
import fr.ifremer.isisfish.entities.MetierSeasonInfo;
import fr.ifremer.isisfish.entities.Species;
import fr.ifremer.isisfish.entities.TargetSpecies;
-import fr.ifremer.isisfish.ui.input.InputAction;
+import fr.ifremer.isisfish.entities.TargetSpeciesDAO;
import fr.ifremer.isisfish.ui.input.InputContentHandler;
import fr.ifremer.isisfish.ui.models.common.GenericComboModel;
+import fr.ifremer.isisfish.ui.util.ErrorHelper;
import fr.ifremer.isisfish.ui.widget.editor.EquationTableEditor;
/**
@@ -42,6 +50,9 @@
*/
public class MetierSeasonInfoSpeciesHandler extends InputContentHandler<MetierSeasonInfoSpeciesUI> {
+ /** Class logger. */
+ private static final Log log = LogFactory.getLog(MetierSeasonInfoSpeciesHandler.class);
+
protected void init(final MetierSeasonInfoSpeciesUI inputContentUI) {
super.init(inputContentUI);
@@ -118,7 +129,7 @@
if (selectedSpecies != null) {
// il n'y en a pas a la creation de la base
//Formule selectedFormule = (Formule)targetFactor.getFormuleComboBox().getSelectedItem();
- inputContentUI.getContextValue(InputAction.class).addTargetSpecies(
+ addTargetSpecies(
inputContentUI.getBean(),
inputContentUI.getMetierSeasonInfo(),
selectedSpecies,
@@ -135,9 +146,60 @@
Object o = targetSpecies[inputContentUI.tableTargetSpecies.getSelectedRow()];
if (o != null) {
TargetSpecies ts = (TargetSpecies)o;
- inputContentUI.getAction().removeTargetSpecies(inputContentUI.getMetierSeasonInfo(), ts);
+ removeTargetSpecies(inputContentUI.getMetierSeasonInfo(), ts);
inputContentUI.getSaveVerifier().removeCurrentEntity(ts.getTopiaId());
setTableTargetSpeciesModel();
}
}
+
+ public void addTargetSpecies(Metier metier, MetierSeasonInfo m,
+ Species species, String targetFactorEquationContent,
+ boolean primaryCatch) {
+ if (log.isDebugEnabled()) {
+ log.debug("addTargetSpecies called: " + metier + " " + species
+ + " " + primaryCatch + " " + targetFactorEquationContent);
+ }
+ try {
+ // build targetFactorEquation name
+ String targetFactorEquationName = metier.getName() + "-"
+ + species.getName() + "(" + m.getFirstMonth() + "-"
+ + m.getLastMonth() + ")";
+
+ TargetSpeciesDAO dao = IsisFishDAOHelper.getTargetSpeciesDAO(metier
+ .getTopiaContext());
+ TargetSpecies targetSpecies = dao.create();
+
+ targetSpecies.setSpecies(species);
+ targetSpecies.getTargetFactorEquation().setName(
+ targetFactorEquationName);
+ targetSpecies.getTargetFactorEquation().setContent(
+ targetFactorEquationContent);
+ targetSpecies.setPrimaryCatch(primaryCatch);
+ m.addSpeciesTargetSpecies(targetSpecies);
+ } catch (Exception eee) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't add TargetSpecies", eee);
+ }
+ ErrorHelper.showErrorDialog(t("isisfish.error.input.addentity",
+ "TargetSpecies"), eee);
+ }
+ }
+
+ public void removeTargetSpecies(MetierSeasonInfo m,
+ TargetSpecies targetSpecies) {
+ if (log.isDebugEnabled()) {
+ log.debug("removeTargetSpecies called: " + targetSpecies);
+ }
+ try {
+ if (targetSpecies != null) {
+ m.removeSpeciesTargetSpecies(targetSpecies);
+ }
+ } catch (Exception eee) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't remove TargetSpecies", eee);
+ }
+ ErrorHelper.showErrorDialog(t("isisfish.error.input.removeentity",
+ "TargetSpecies"), eee);
+ }
+ }
}
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/metier/MetierSeasonInfoZoneHandler.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/metier/MetierSeasonInfoZoneHandler.java 2015-05-20 13:11:09 UTC (rev 4229)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/metier/MetierSeasonInfoZoneHandler.java 2015-05-20 13:37:54 UTC (rev 4230)
@@ -23,6 +23,8 @@
package fr.ifremer.isisfish.ui.input.metier;
+import static org.nuiton.i18n.I18n.t;
+
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.util.ArrayList;
@@ -32,14 +34,19 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.nuiton.topia.TopiaException;
+import fr.ifremer.isisfish.IsisFishDAOHelper;
+import fr.ifremer.isisfish.IsisFishRuntimeException;
+import fr.ifremer.isisfish.entities.Metier;
import fr.ifremer.isisfish.entities.MetierSeasonInfo;
+import fr.ifremer.isisfish.entities.MetierSeasonInfoDAO;
import fr.ifremer.isisfish.entities.Zone;
import fr.ifremer.isisfish.types.Month;
-import fr.ifremer.isisfish.ui.input.InputAction;
import fr.ifremer.isisfish.ui.input.InputContentHandler;
import fr.ifremer.isisfish.ui.models.common.GenericComboModel;
import fr.ifremer.isisfish.ui.models.common.GenericListModel;
+import fr.ifremer.isisfish.ui.util.ErrorHelper;
import fr.ifremer.isisfish.ui.widget.Interval;
/**
@@ -96,17 +103,59 @@
}
protected void create() {
- MetierSeasonInfo newMSI = inputContentUI.getContextValue(InputAction.class).createMetierSeasonInfo(inputContentUI.getBean());
+ MetierSeasonInfo newMSI = createMetierSeasonInfo(inputContentUI.getBean());
inputContentUI.setMetierSeasonInfo(newMSI);
setMetierSeasonInfoCombo();
}
protected void delete() {
- inputContentUI.getContextValue(InputAction.class).removeMetierSeasonInfo(inputContentUI.getBean(), inputContentUI.getMetierSeasonInfo());
+ removeMetierSeasonInfo(inputContentUI.getBean(), inputContentUI.getMetierSeasonInfo());
inputContentUI.setMetierSeasonInfo(null);
setMetierSeasonInfoCombo();
}
+ public MetierSeasonInfo createMetierSeasonInfo(Metier metier) {
+ MetierSeasonInfo metierSeasonInfo = null;
+ if (log.isDebugEnabled()) {
+ log.debug("createMetierSeasonInfo called");
+ }
+ try {
+ MetierSeasonInfoDAO metierSeasonInfoPS = IsisFishDAOHelper
+ .getMetierSeasonInfoDAO(metier.getTopiaContext());
+ metierSeasonInfo = metierSeasonInfoPS.create();
+ metierSeasonInfo.setFirstMonth(Month.MONTH[0]);
+ metierSeasonInfo.setLastMonth(Month.MONTH[3]);
+ metier.addMetierSeasonInfo(metierSeasonInfo);
+ metierSeasonInfo.update();
+ metier.update();
+
+ } catch (TopiaException eee) {
+ throw new IsisFishRuntimeException("Can't create MetierSeasonInfo", eee);
+ }
+ return metierSeasonInfo;
+ }
+
+ public void removeMetierSeasonInfo(Metier metier, MetierSeasonInfo info) {
+ if (log.isDebugEnabled()) {
+ log.debug("removeMetierSeasonInfo called");
+ }
+ try {
+ metier.removeMetierSeasonInfo(info);
+ metier.update();
+
+ // EC-20091112 : commit() twice cause hibernate error:
+ // Found two representations of same collection:
+ //metier.getTopiaContext().commitTransaction();
+
+ } catch (Exception eee) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't remove MetierSeasonInfo", eee);
+ }
+ ErrorHelper.showErrorDialog(t("isisfish.error.input.addentity",
+ "MetierSeasonInfo"), eee);
+ }
+ }
+
public void refresh() {
inputContentUI.setMetierSeasonInfo(null);
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/observation/ObservationHandler.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/observation/ObservationHandler.java 2015-05-20 13:11:09 UTC (rev 4229)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/observation/ObservationHandler.java 2015-05-20 13:37:54 UTC (rev 4230)
@@ -23,19 +23,35 @@
package fr.ifremer.isisfish.ui.input.observation;
+import static org.nuiton.i18n.I18n.t;
+
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
+import java.util.ArrayList;
+import java.util.List;
+import javax.swing.JOptionPane;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.nuiton.math.matrix.MatrixFactory;
import org.nuiton.math.matrix.MatrixND;
import org.nuiton.math.matrix.gui.MatrixPanelEvent;
+import fr.ifremer.isisfish.entities.Observation;
import fr.ifremer.isisfish.ui.input.InputContentHandler;
+import fr.ifremer.isisfish.ui.input.metier.MetierSeasonInfoSpeciesHandler;
+import fr.ifremer.isisfish.ui.util.ErrorHelper;
/**
* Observation handler.
*/
public class ObservationHandler extends InputContentHandler<ObservationUI> {
+ /** Class logger. */
+ private static final Log log = LogFactory.getLog(ObservationHandler.class);
+
protected void init(final ObservationUI inputContentUI) {
super.init(inputContentUI);
@@ -61,10 +77,46 @@
}
protected void createObservationValueMatrix() {
- inputContentUI.getAction().createObservationValueMatrix(inputContentUI.getBean());
+ createObservationValueMatrix(inputContentUI.getBean());
setObservationValueMatrix();
}
+
+ public void createObservationValueMatrix(Observation observation) {
+ try {
+ String val = JOptionPane.showInputDialog(t("isisfish.message.observation.value.dimensions"));
+ if (StringUtils.isNotBlank(val)) {
+ String[] values = val.trim().split("(,|;|\\*|x|\\s)");
+
+ List<Integer> dims = new ArrayList<Integer>();
+ for (String value : values) {
+ if (!value.isEmpty() && StringUtils.isNumeric(value)) {
+ dims.add(Integer.valueOf(value));
+ }
+ }
+
+ int[] dim = new int[dims.size()];
+ for (int i = 0; i < dims.size(); i++) {
+ dim[i] = dims.get(i).intValue();
+ }
+ MatrixND newMat = MatrixFactory.getInstance().create(dim);
+
+ MatrixND mat = observation.getValue();
+ if (mat != null) {
+ newMat.paste(mat);
+ }
+ observation.setValue(newMat);
+ observation.update();
+ }
+ } catch (Exception eee) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't remove RecruitmentDistribution", eee);
+ }
+ ErrorHelper.showErrorDialog(t("isisfish.error.input.removeentity",
+ "RecruitmentDistribution"), eee);
+ }
+ }
+
protected void observationValueMatrixChanged(MatrixPanelEvent event) {
MatrixND mat = inputContentUI.fieldObservationValue.getMatrix();
if (inputContentUI.getBean() != null && mat != null) {
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationBasicsHandler.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationBasicsHandler.java 2015-05-20 13:11:09 UTC (rev 4229)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationBasicsHandler.java 2015-05-20 13:37:54 UTC (rev 4230)
@@ -34,10 +34,17 @@
import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.nuiton.topia.TopiaContext;
+import org.nuiton.topia.TopiaException;
+
+import fr.ifremer.isisfish.IsisFishDAOHelper;
+import fr.ifremer.isisfish.IsisFishRuntimeException;
import fr.ifremer.isisfish.entities.Population;
+import fr.ifremer.isisfish.entities.PopulationDAO;
import fr.ifremer.isisfish.entities.PopulationGroup;
import fr.ifremer.isisfish.entities.Species;
-import fr.ifremer.isisfish.ui.input.InputAction;
import fr.ifremer.isisfish.ui.input.InputContentHandler;
import fr.ifremer.isisfish.ui.input.InputUI;
import jaxx.runtime.JAXXUtil;
@@ -47,6 +54,9 @@
*/
public class PopulationBasicsHandler extends InputContentHandler<PopulationBasicsUI> {
+ /** Class logger. */
+ private static final Log log = LogFactory.getLog(PopulationBasicsHandler.class);
+
protected void init(final PopulationBasicsUI inputContentUI) {
super.init(inputContentUI);
@@ -130,8 +140,30 @@
InputUI inputUI = inputContentUI.getContextValue(InputUI.class, JAXXUtil.PARENT);
Species species = inputUI.getHandler().findSpecies(inputUI);
// create node and select it
- Population population = inputContentUI.getContextValue(InputAction.class).createPopulation(inputContentUI.getTopiaContext(), species);
+ Population population = createPopulation(inputContentUI.getTopiaContext(), species);
inputUI.getHandler().insertTreeNode(inputUI, Population.class, population);
inputContentUI.setInfoText(t("isisfish.message.creation.finished"));
}
+
+ protected Population createPopulation(TopiaContext context, Species species) {
+ Population pop = null;
+ if (log.isTraceEnabled()) {
+ log.trace("createPopulation called");
+ }
+ try {
+ String name = "Population_new";
+
+ PopulationDAO dao = IsisFishDAOHelper.getPopulationDAO(context);
+ pop = dao.create();
+ pop.setName(name);
+
+ species.addPopulation(pop);
+ pop.setSpecies(species);
+ species.update();
+ pop.update();
+ } catch (TopiaException eee) {
+ throw new IsisFishRuntimeException(t("isisfish.error.input.addentity", "Population"), eee);
+ }
+ return pop;
+ }
}
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationEmigrationHandler.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationEmigrationHandler.java 2015-05-20 13:11:09 UTC (rev 4229)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationEmigrationHandler.java 2015-05-20 13:37:54 UTC (rev 4230)
@@ -23,24 +23,31 @@
package fr.ifremer.isisfish.ui.input.population;
+import static org.nuiton.i18n.I18n.t;
+
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.nuiton.math.matrix.MatrixND;
import org.nuiton.math.matrix.gui.MatrixPanelEvent;
import fr.ifremer.isisfish.entities.PopulationGroup;
import fr.ifremer.isisfish.entities.PopulationSeasonInfo;
import fr.ifremer.isisfish.entities.Zone;
-import fr.ifremer.isisfish.ui.input.InputAction;
import fr.ifremer.isisfish.ui.input.InputContentHandler;
import fr.ifremer.isisfish.ui.models.common.GenericComboModel;
+import fr.ifremer.isisfish.ui.util.ErrorHelper;
/**
* Population handler.
*/
public class PopulationMigrationEmigrationHandler extends InputContentHandler<PopulationMigrationEmigrationUI> {
+ /** Class logger. */
+ private static final Log log = LogFactory.getLog(PopulationMigrationEmigrationHandler.class);
+
protected void init(final PopulationMigrationEmigrationUI inputContentUI) {
super.init(inputContentUI);
@@ -94,13 +101,33 @@
}
protected void add() {
- inputContentUI.getContextValue(InputAction.class).addEmigration(inputContentUI.getPopInfo(),
+ addEmigration(inputContentUI.getPopInfo(),
(PopulationGroup)inputContentUI.fieldPopulationMigrationEmigrationGroupChooser.getSelectedItem(),
(Zone)inputContentUI.fieldPopulationMigrationEmigrationDepartureZoneChooser.getSelectedItem(),
Double.parseDouble(inputContentUI.fieldPopulationMigrationEmigrationCoefficient.getText()));
inputContentUI.populationMigrationEmigrationTable.setMatrix(inputContentUI.getPopInfo().getEmigrationMatrix().clone());
}
+
+ public Object addEmigration(PopulationSeasonInfo info,
+ PopulationGroup group, Zone departure, double coeff) {
+ if (log.isTraceEnabled()) {
+ log.trace("addEmigration called");
+ }
+ try {
+ MatrixND mat = info.getEmigrationMatrix().copy();
+ mat.setValue(group, departure, coeff);
+ info.setEmigrationMatrix(mat);
+ } catch (Exception eee) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't add emigration", eee);
+ }
+ ErrorHelper.showErrorDialog(t("isisfish.error.input.addentity",
+ "Emigration"), eee);
+ }
+ return null;
+ }
+
protected void remove() {
int row = inputContentUI.populationMigrationEmigrationTable.getTable().getSelectedRow();
if (row != -1) {
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationImmigrationHandler.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationImmigrationHandler.java 2015-05-20 13:11:09 UTC (rev 4229)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationImmigrationHandler.java 2015-05-20 13:37:54 UTC (rev 4230)
@@ -23,24 +23,31 @@
package fr.ifremer.isisfish.ui.input.population;
+import static org.nuiton.i18n.I18n.t;
+
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.nuiton.math.matrix.MatrixND;
import org.nuiton.math.matrix.gui.MatrixPanelEvent;
import fr.ifremer.isisfish.entities.PopulationGroup;
import fr.ifremer.isisfish.entities.PopulationSeasonInfo;
import fr.ifremer.isisfish.entities.Zone;
-import fr.ifremer.isisfish.ui.input.InputAction;
import fr.ifremer.isisfish.ui.input.InputContentHandler;
import fr.ifremer.isisfish.ui.models.common.GenericComboModel;
+import fr.ifremer.isisfish.ui.util.ErrorHelper;
/**
* Population handler.
*/
public class PopulationMigrationImmigrationHandler extends InputContentHandler<PopulationMigrationImmigrationUI> {
+ /** Class logger. */
+ private static final Log log = LogFactory.getLog(PopulationMigrationImmigrationHandler.class);
+
protected void init(final PopulationMigrationImmigrationUI inputContentUI) {
super.init(inputContentUI);
@@ -93,13 +100,33 @@
}
protected void add() {
- inputContentUI.getContextValue(InputAction.class).addImmigration(inputContentUI.getPopInfo(),
+ addImmigration(inputContentUI.getPopInfo(),
(PopulationGroup)inputContentUI.fieldPopulationMigrationImmigrationGroupChooser.getSelectedItem(),
(Zone)inputContentUI.fieldPopulationMigrationImmigrationArrivalZoneChooser.getSelectedItem(),
Double.parseDouble(inputContentUI.fieldPopulationMigrationImmigrationCoefficient.getText()));
inputContentUI.populationMigrationImmigrationTable.setMatrix(inputContentUI.getPopInfo().getImmigrationMatrix().clone());
}
+
+ public Object addImmigration(PopulationSeasonInfo info,
+ PopulationGroup group, Zone arrival, double coeff) {
+ if (log.isTraceEnabled()) {
+ log.trace("addImmigration called");
+ }
+ try {
+ MatrixND mat = info.getImmigrationMatrix().copy();
+ mat.setValue(group, arrival, coeff);
+ info.setImmigrationMatrix(mat);
+ } catch (Exception eee) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't add immigration", eee);
+ }
+ ErrorHelper.showErrorDialog(t("isisfish.error.input.addentity",
+ "Immigration"), eee);
+ }
+ return null;
+ }
+
protected void remove() {
int row = inputContentUI.populationMigrationImmigrationTable.getTable().getSelectedRow();
if (row != -1) {
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationMigrationHandler.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationMigrationHandler.java 2015-05-20 13:11:09 UTC (rev 4229)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationMigrationHandler.java 2015-05-20 13:37:54 UTC (rev 4230)
@@ -23,9 +23,13 @@
package fr.ifremer.isisfish.ui.input.population;
+import static org.nuiton.i18n.I18n.t;
+
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.nuiton.math.matrix.MatrixND;
import org.nuiton.math.matrix.gui.MatrixPanelEvent;
@@ -34,12 +38,16 @@
import fr.ifremer.isisfish.entities.Zone;
import fr.ifremer.isisfish.ui.input.InputContentHandler;
import fr.ifremer.isisfish.ui.models.common.GenericComboModel;
+import fr.ifremer.isisfish.ui.util.ErrorHelper;
/**
* Population handler.
*/
public class PopulationMigrationMigrationHandler extends InputContentHandler<PopulationMigrationMigrationUI> {
+ /** Class logger. */
+ private static final Log log = LogFactory.getLog(PopulationMigrationMigrationHandler.class);
+
protected void init(final PopulationMigrationMigrationUI inputContentUI) {
super.init(inputContentUI);
@@ -102,13 +110,33 @@
}
protected void add() {
- inputContentUI.getAction().addMigration(inputContentUI.getPopInfo(), (PopulationGroup)inputContentUI.fieldPopulationMigrationMigrationGroupChooser.getSelectedItem(),
+ addMigration(inputContentUI.getPopInfo(), (PopulationGroup)inputContentUI.fieldPopulationMigrationMigrationGroupChooser.getSelectedItem(),
(Zone)inputContentUI.fieldPopulationMigrationMigrationDepartureZoneChooser.getSelectedItem(),
(Zone)inputContentUI.fieldPopulationMigrationMigrationArrivalZoneChooser.getSelectedItem(),
Double.parseDouble(inputContentUI.fieldPopulationMigrationMigrationCoefficient.getText()));
inputContentUI.populationMigrationMigrationTable.setMatrix(inputContentUI.getPopInfo().getMigrationMatrix().clone());
}
+
+ public Object addMigration(PopulationSeasonInfo info,
+ PopulationGroup group, Zone departure, Zone arrival, double coeff) {
+ if (log.isTraceEnabled()) {
+ log.trace("addMigration called");
+ }
+ try {
+ MatrixND mat = info.getMigrationMatrix().copy();
+ mat.setValue(group, departure, arrival, coeff);
+ info.setMigrationMatrix(mat);
+ } catch (Exception eee) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't add migration", eee);
+ }
+ ErrorHelper.showErrorDialog(t("isisfish.error.input.addentity",
+ "Migration"), eee);
+ }
+ return null;
+ }
+
protected void remove() {
int row = inputContentUI.populationMigrationMigrationTable.getTable().getSelectedRow();
if (row != -1) {
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationRecruitmentHandler.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationRecruitmentHandler.java 2015-05-20 13:11:09 UTC (rev 4229)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationRecruitmentHandler.java 2015-05-20 13:37:54 UTC (rev 4230)
@@ -23,18 +23,33 @@
package fr.ifremer.isisfish.ui.input.population;
+import static org.nuiton.i18n.I18n.t;
+
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
+import java.util.ArrayList;
+import java.util.List;
+import javax.swing.JOptionPane;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.nuiton.math.matrix.MatrixFactory;
+import org.nuiton.math.matrix.MatrixND;
import org.nuiton.math.matrix.gui.MatrixPanelEvent;
+import fr.ifremer.isisfish.entities.Population;
import fr.ifremer.isisfish.ui.input.InputContentHandler;
+import fr.ifremer.isisfish.ui.util.ErrorHelper;
/**
* Population handler.
*/
public class PopulationRecruitmentHandler extends InputContentHandler<PopulationRecruitmentUI> {
+ /** Class logger. */
+ private static final Log log = LogFactory.getLog(PopulationRecruitmentHandler.class);
+
protected void init(final PopulationRecruitmentUI inputContentUI) {
super.init(inputContentUI);
@@ -58,4 +73,46 @@
}
}
}
+
+ public void createRecruitmentDistribution(Population pop) {
+ if (log.isTraceEnabled()) {
+ log.trace("createRecruitmentDistributionon called: " + pop);
+ }
+ try {
+ String val = JOptionPane
+ .showInputDialog(t("isisfish.message.recruitment.number.month"));
+ int num = -1;
+ if (val != null && !"".equals(val)) {
+ try {
+ num = Integer.parseInt(val);
+ } catch (RuntimeException eee) {
+ if (log.isWarnEnabled()) {
+ log.warn("Can't parse val: " + val, eee);
+ }
+ }
+ }
+
+ if (num > 0) {
+ List<String> sem = new ArrayList<String>(num);
+ for (int i = 0; i < num; i++) {
+ sem.add(t("isisfish.common.month", i));
+ }
+ MatrixND newMat = MatrixFactory.getInstance().create(
+ new List[] { sem });
+
+ MatrixND mat = pop.getRecruitmentDistribution();
+ if (mat != null) {
+ newMat.paste(mat);
+ }
+ pop.setRecruitmentDistribution(newMat);
+ pop.update();
+ }
+ } catch (Exception eee) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't remove RecruitmentDistribution", eee);
+ }
+ ErrorHelper.showErrorDialog(t("isisfish.error.input.removeentity",
+ "RecruitmentDistribution"), eee);
+ }
+ }
}
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationRecruitmentUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationRecruitmentUI.jaxx 2015-05-20 13:11:09 UTC (rev 4229)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationRecruitmentUI.jaxx 2015-05-20 13:37:54 UTC (rev 4230)
@@ -80,7 +80,7 @@
</cell>
<cell>
<JButton icon="table.png" toolTipText="isisfish.common.newMatrix"
- onActionPerformed="getAction().createRecruitmentDistribution(getBean())"
+ onActionPerformed="handler.createRecruitmentDistribution(getBean())"
enabled='{isActive()}' decorator='boxed' />
</cell>
</row>
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationSeasonsHandler.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationSeasonsHandler.java 2015-05-20 13:11:09 UTC (rev 4229)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationSeasonsHandler.java 2015-05-20 13:37:54 UTC (rev 4230)
@@ -23,6 +23,8 @@
package fr.ifremer.isisfish.ui.input.population;
+import static org.nuiton.i18n.I18n.t;
+
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
@@ -31,11 +33,14 @@
import org.nuiton.math.matrix.MatrixND;
import org.nuiton.math.matrix.gui.MatrixPanelEvent;
+import fr.ifremer.isisfish.IsisFishDAOHelper;
+import fr.ifremer.isisfish.entities.Population;
import fr.ifremer.isisfish.entities.PopulationSeasonInfo;
+import fr.ifremer.isisfish.entities.PopulationSeasonInfoDAO;
import fr.ifremer.isisfish.types.Month;
-import fr.ifremer.isisfish.ui.input.InputAction;
import fr.ifremer.isisfish.ui.input.InputContentHandler;
import fr.ifremer.isisfish.ui.models.common.GenericComboModel;
+import fr.ifremer.isisfish.ui.util.ErrorHelper;
import fr.ifremer.isisfish.ui.widget.Interval;
/**
@@ -91,17 +96,71 @@
}
protected void create() {
- PopulationSeasonInfo seasonNew = inputContentUI.getContextValue(InputAction.class).createPopulationSeasonInfo(inputContentUI.getBean());
+ PopulationSeasonInfo seasonNew = createPopulationSeasonInfo(inputContentUI.getBean());
inputContentUI.setPopulationSeasonInfo(seasonNew);
setPopulationSeasonInfoCombo();
}
protected void delete() {
- inputContentUI.getContextValue(InputAction.class).removePopulationSeasonInfo(inputContentUI.getBean(), inputContentUI.getPopulationSeasonInfo());
+ removePopulationSeasonInfo(inputContentUI.getBean(), inputContentUI.getPopulationSeasonInfo());
inputContentUI.setPopulationSeasonInfo(null);
setPopulationSeasonInfoCombo();
}
+
+ protected PopulationSeasonInfo createPopulationSeasonInfo(Population pop) {
+ if (log.isDebugEnabled()) {
+ log.debug("createSeasonInfo called");
+ }
+ PopulationSeasonInfo seasonInfo = null;
+ try {
+ PopulationSeasonInfoDAO dao = IsisFishDAOHelper
+ .getPopulationSeasonInfoDAO(pop.getTopiaContext());
+ seasonInfo = dao.create();
+ seasonInfo.setFirstMonth(Month.MONTH[0]);
+ seasonInfo.setLastMonth(Month.MONTH[3]);
+ pop.addPopulationSeasonInfo(seasonInfo);
+ seasonInfo.setPopulation(pop);
+ // EC-20090710 ajout du code d'initailisation
+ // d'un populationseasoninfo
+ // il a du se perdre au changement d'interface
+ // swiat>jaxx
+ // moved to entity
+ //MatrixND matrix = ((PopulationSeasonInfoImpl) seasonInfo)
+ // .createNoSpacializedChangeGroupMatrix();
+ //seasonInfo.setLengthChangeMatrix(matrix);
+
+ seasonInfo.update();
+ pop.update();
+ // isisContext.commitTransaction();
+ } catch (Exception eee) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't create PopulationSeasonInfo", eee);
+ }
+ ErrorHelper.showErrorDialog(t("isisfish.error.input.removeentity",
+ "PopulationSeasonInfo"), eee);
+ }
+ return seasonInfo;
+ }
+
+ protected void removePopulationSeasonInfo(Population pop,
+ PopulationSeasonInfo populationSeasonInfo) {
+ if (log.isDebugEnabled()) {
+ log.debug("removePopulationSeasonInfo called");
+ }
+ try {
+ pop.removePopulationSeasonInfo(populationSeasonInfo);
+ pop.update();
+ //pop.getTopiaContext().commitTransaction();
+ } catch (Exception eee) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't remove PopulationSeasonInfo", eee);
+ }
+ ErrorHelper.showErrorDialog(t("isisfish.error.input.removeentity",
+ "PopulationSeasonInfo"), eee);
+ }
+ }
+
protected void save() {
inputContentUI.getSaveVerifier().save();
setPopulationSeasonInfoCombo();
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/setofvessels/EffortDescriptionHandler.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/setofvessels/EffortDescriptionHandler.java 2015-05-20 13:11:09 UTC (rev 4229)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/setofvessels/EffortDescriptionHandler.java 2015-05-20 13:37:54 UTC (rev 4230)
@@ -23,22 +23,33 @@
package fr.ifremer.isisfish.ui.input.setofvessels;
+import static org.nuiton.i18n.I18n.t;
+
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.util.ArrayList;
import java.util.List;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import fr.ifremer.isisfish.IsisFishDAOHelper;
import fr.ifremer.isisfish.entities.EffortDescription;
+import fr.ifremer.isisfish.entities.EffortDescriptionDAO;
import fr.ifremer.isisfish.entities.Metier;
-import fr.ifremer.isisfish.ui.input.InputAction;
+import fr.ifremer.isisfish.entities.SetOfVessels;
import fr.ifremer.isisfish.ui.input.InputContentHandler;
import fr.ifremer.isisfish.ui.models.common.GenericListModel;
+import fr.ifremer.isisfish.ui.util.ErrorHelper;
/**
* set of vessels handler.
*/
public class EffortDescriptionHandler extends InputContentHandler<EffortDescriptionUI> {
+ /** Class logger. */
+ private static final Log log = LogFactory.getLog(EffortDescriptionHandler.class);
+
protected void init(final EffortDescriptionUI inputContentUI) {
super.init(inputContentUI);
@@ -56,14 +67,6 @@
});
}
- /**
- * Get input action from context.
- */
- @Deprecated
- protected InputAction getInputAction() {
- return inputContentUI.getContextValue(InputAction.class);
- }
-
protected void onFieldEffortDescriptionMetierListValueChanged() {
// active le bouton seulement si l'interface est active
// dans le cas de sensitivity par exemple
@@ -92,15 +95,61 @@
protected void addEffortDescriptions() {
List<Metier> selectedValues = inputContentUI.fieldEffortDescriptionMetierList.getSelectedValuesList();
for (Metier selectedMetier : selectedValues) {
- getInputAction().addEffortDescription(inputContentUI.getBean(), selectedMetier);
+ addEffortDescription(inputContentUI.getBean(), selectedMetier);
}
setEffortDescriptionEffortDescriptionList();
}
+
protected void removeEffortDescriptions() {
List<EffortDescription> selectedValues = inputContentUI.fieldEffortDescriptionEffortDescriptionList.getSelectedValuesList();
for (EffortDescription selectedEffortDescription : selectedValues) {
- getInputAction().removeEffortDescription(inputContentUI.getBean(), selectedEffortDescription);
+ removeEffortDescription(inputContentUI.getBean(), selectedEffortDescription);
}
setEffortDescriptionEffortDescriptionList();
}
+
+ public void addEffortDescription(SetOfVessels setOfVessels, Metier metier) {
+ if (log.isDebugEnabled()) {
+ log.debug("addEffortDescription called: " + setOfVessels
+ + " metier: " + metier);
+ }
+ try {
+ EffortDescriptionDAO effortDescriptionPS = IsisFishDAOHelper
+ .getEffortDescriptionDAO(metier.getTopiaContext());
+ EffortDescription effortDescription = effortDescriptionPS.create();
+ // EC20090715 : c'est la classe d'association
+ // qui en étant sauvee, sauve les relations en base
+ // il faut bien faire les set des deux cotes
+ effortDescription.setSetOfVessels(setOfVessels);
+ effortDescription.setPossibleMetiers(metier);
+ effortDescription.update();
+ setOfVessels.addPossibleMetiers(effortDescription);
+ setOfVessels.update();
+ } catch (Exception eee) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't create EffortDescription", eee);
+ }
+ ErrorHelper.showErrorDialog(t("isisfish.error.input.addentity",
+ "EffortDescription"), eee);
+ }
+ }
+
+ public void removeEffortDescription(SetOfVessels sov,
+ EffortDescription effort) {
+ if (log.isTraceEnabled()) {
+ log.trace("removeEffortDescription called");
+ }
+ try {
+ sov.removePossibleMetiers(effort);
+ // EC-20091112 : commit() twice cause hibernate error:
+ // Found two representations of same collection:
+ //sov.getTopiaContext().commitTransaction();
+ } catch (Exception eee) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't remove entity: " + effort, eee);
+ }
+ ErrorHelper.showErrorDialog(t("isisfish.error.input.removeentity",
+ "EffortDescription"), eee);
+ }
+ }
}
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/SensitivityTabUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/SensitivityTabUI.jaxx 2015-05-20 13:11:09 UTC (rev 4229)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/SensitivityTabUI.jaxx 2015-05-20 13:37:54 UTC (rev 4230)
@@ -27,7 +27,6 @@
javax.swing.tree.DefaultTreeModel
fr.ifremer.isisfish.datastore.RegionStorage
fr.ifremer.isisfish.ui.WelcomePanelUI
- fr.ifremer.isisfish.ui.input.InputAction
fr.ifremer.isisfish.ui.input.InputSaveVerifier
fr.ifremer.isisfish.ui.simulator.SimulAction
fr.ifremer.isisfish.simulator.sensitivity.FactorGroup
@@ -43,10 +42,6 @@
<fr.ifremer.isisfish.entities.FisheryRegion id='fisheryRegion' javaBean='null'/>
<script><![CDATA[
-protected InputAction getInputAction() {
- return getContextValue(InputAction.class);
-}
-
protected SimulAction getSimulAction() {
return getContextValue(SimulAction.class);
}
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/SensitivityUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/SensitivityUI.jaxx 2015-05-20 13:11:09 UTC (rev 4229)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/SensitivityUI.jaxx 2015-05-20 13:37:54 UTC (rev 4230)
@@ -25,7 +25,6 @@
<fr.ifremer.isisfish.ui.SimulationUI>
<import>
- fr.ifremer.isisfish.ui.input.InputAction
fr.ifremer.isisfish.ui.sensitivity.SensitivitySaveVerifier
jaxx.runtime.context.JAXXInitialContext
jaxx.runtime.JAXXContext
@@ -79,11 +78,11 @@
<JTabbedPane id="bodyTabbedPane">
<tab title='isisfish.params.title'>
<fr.ifremer.isisfish.ui.simulator.ParamsUI id='paramsUI' sensitivity='true' regionStorage="{getRegionStorage()}"
- constructorParams='new JAXXInitialContext().add(new InputAction()).add(new SensitivitySaveVerifier()).add("SimulationUI", this).add(this)' />
+ constructorParams='new JAXXInitialContext().add(new SensitivitySaveVerifier()).add("SimulationUI", this).add(this)' />
</tab>
<tab title='isisfish.sensitivity.title' enabled="false">
<fr.ifremer.isisfish.ui.sensitivity.SensitivityTabUI id="sensitivityTabUI"
- constructorParams='new JAXXInitialContext().add(new InputAction()).add(new SensitivitySaveVerifier()).add("SimulationUI", this).add(this)' />
+ constructorParams='new JAXXInitialContext().add(new SensitivitySaveVerifier()).add("SimulationUI", this).add(this)' />
</tab>
<tab title='isisfish.sensitivityChooser.title' enabled="false">
<SensitivityChooserUI id="sensitivityChooserUI" constructorParams='this'/>
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/wizard/SensitivityWizardHandler.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/wizard/SensitivityWizardHandler.java 2015-05-20 13:11:09 UTC (rev 4229)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/wizard/SensitivityWizardHandler.java 2015-05-20 13:37:54 UTC (rev 4230)
@@ -72,7 +72,6 @@
import fr.ifremer.isisfish.types.TimeStep;
import fr.ifremer.isisfish.types.TimeUnit;
import fr.ifremer.isisfish.ui.SimulationUI;
-import fr.ifremer.isisfish.ui.input.InputAction;
import fr.ifremer.isisfish.ui.input.equation.InputOneEquationUI;
import fr.ifremer.isisfish.ui.simulator.RuleChooser;
import fr.ifremer.isisfish.ui.simulator.SimulAction;
@@ -364,7 +363,7 @@
result = new ContinuousDistributionPanel(min);
} else if (value instanceof Equation) {
Equation equation = (Equation)value;
- EquationContinuousPanelUI ui = new EquationContinuousPanelUI(new JAXXInitialContext().add(new InputAction()));
+ EquationContinuousPanelUI ui = new EquationContinuousPanelUI();
ui.setSelectedEquation(equation);
ui.setText(t("isisfish.common.equation")); // can't get real name
ui.setFormuleCategory(equation.getCategory());
@@ -575,7 +574,7 @@
result = new ContinuousDistributionPanel(min);
} else if (value instanceof Equation) {
Equation equation = (Equation)value;
- EquationContinuousPanelUI ui = new EquationContinuousPanelUI(new JAXXInitialContext().add(new InputAction()));
+ EquationContinuousPanelUI ui = new EquationContinuousPanelUI();
ui.setSelectedEquation(equation);
ui.setText(t("isisfish.common.equation")); // can't get real name
ui.setFormuleCategory(equation.getCategory());
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/OptimizationHandler.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/OptimizationHandler.java 2015-05-20 13:11:09 UTC (rev 4229)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/OptimizationHandler.java 2015-05-20 13:37:54 UTC (rev 4230)
@@ -52,7 +52,6 @@
import fr.ifremer.isisfish.simulator.sensitivity.Factor;
import fr.ifremer.isisfish.simulator.sensitivity.FactorGroup;
import fr.ifremer.isisfish.ui.SimulationUI;
-import fr.ifremer.isisfish.ui.input.InputAction;
import fr.ifremer.isisfish.ui.models.common.GenericComboModel;
import fr.ifremer.isisfish.ui.models.common.ScriptParametersTableCellEditor;
import fr.ifremer.isisfish.ui.models.common.ScriptParametersTableCellRenderer;
@@ -182,7 +181,6 @@
// init new sensitivity tav ui hierarchy
final SensitivityTabUI sensitivityTabUI = new SensitivityTabUI(view);
- sensitivityTabUI.setContextValue(new InputAction());
sensitivityTabUI.setContextValue(new SensitivitySaveVerifier()); // prevent NPE
sensitivityTabUI.setContextValue(view.getParentContainer(SimulationUI.class), "SimulationUI"); // prevent NPE
1
0
r4229 - trunk/src/main/java/fr/ifremer/isisfish/ui/queue
by echatellier@users.forge.codelutin.com 20 May '15
by echatellier@users.forge.codelutin.com 20 May '15
20 May '15
Author: echatellier
Date: 2015-05-20 13:11:09 +0000 (Wed, 20 May 2015)
New Revision: 4229
Url: http://forge.codelutin.com/projects/isis-fish/repository/revisions/4229
Log:
Move script code to dedicated handler (queue)
Added:
trunk/src/main/java/fr/ifremer/isisfish/ui/queue/QueueHandler.java
Removed:
trunk/src/main/java/fr/ifremer/isisfish/ui/queue/QueueAction.java
Modified:
trunk/src/main/java/fr/ifremer/isisfish/ui/queue/PauseButtonModel.java
trunk/src/main/java/fr/ifremer/isisfish/ui/queue/QueueUI.jaxx
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/queue/PauseButtonModel.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/queue/PauseButtonModel.java 2015-05-20 12:58:46 UTC (rev 4228)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/queue/PauseButtonModel.java 2015-05-20 13:11:09 UTC (rev 4229)
@@ -4,7 +4,7 @@
* #%L
* IsisFish
* %%
- * Copyright (C) 2014 Ifremer, Codelutin, Benjamin Poussin
+ * Copyright (C) 2014 - 2015 Ifremer, Codelutin, Benjamin Poussin
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
@@ -22,7 +22,6 @@
* #L%
*/
-
import fr.ifremer.isisfish.simulator.launcher.SimulationExecutor;
import fr.ifremer.isisfish.simulator.launcher.SimulationService;
import java.awt.event.ItemEvent;
@@ -89,5 +88,4 @@
}
}
-
}
Deleted: trunk/src/main/java/fr/ifremer/isisfish/ui/queue/QueueAction.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/queue/QueueAction.java 2015-05-20 12:58:46 UTC (rev 4228)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/queue/QueueAction.java 2015-05-20 13:11:09 UTC (rev 4229)
@@ -1,146 +0,0 @@
-/*
- * #%L
- * IsisFish
- *
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2009 - 2010 Ifremer, Code Lutin
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-
-package fr.ifremer.isisfish.ui.queue;
-
-import static org.nuiton.i18n.I18n.t;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import fr.ifremer.isisfish.logging.SimulationLoggerUtil;
-import fr.ifremer.isisfish.simulator.launcher.SimulationJob;
-import fr.ifremer.isisfish.simulator.launcher.SimulationService;
-import fr.ifremer.isisfish.ui.util.ErrorHelper;
-
-/**
- * Common action for all queue ui.
- *
- * @author chatellier
- * @version $Revision$
- *
- * Last update : $Date$
- * By : $Author$
- */
-public class QueueAction {
-
- /** Log. */
- private static Log log = LogFactory.getLog(QueueAction.class);
-
- /** queue ui to manage. */
- protected QueueUI queueUI;
-
- /**
- * Queue action.
- *
- * @param queueUI queue ui to manage
- */
- public QueueAction(QueueUI queueUI) {
- this.queueUI = queueUI;
- }
-
- /**
- * Update ui buttons.
- */
- public void updateActions() {
- queueUI.setCanStop(!queueUI.getSelectionModelQueueTable().isSelectionEmpty());
- queueUI.setCanShowLog(!queueUI.getSelectionModelQueueTableDone().isSelectionEmpty());
- queueUI.setCanClear(queueUI.getQueueTableDone().getModel().getRowCount()>0);
- queueUI.setCanRestart(!queueUI.getSelectionModelQueueTableDone().isSelectionEmpty());
- }
-
- /**
- * Stop simulation associated with table selected rows.
- */
- protected void stopSimulation() {
- int[] selectedRows = queueUI.getQueueTable().getSelectedRows();
- SimulationJob[] jobsToStop = new SimulationJob[selectedRows.length];
- int index = 0;
-
- // to do in two pass, because each stopped simulation
- // change selected rows
- for (int selectedRow : selectedRows) {
- jobsToStop[index++] = queueUI.getNewSimulationModel().getJob(selectedRow);
- }
- for (SimulationJob jobToStop : jobsToStop) {
- jobToStop.stop();
- if (log.isInfoEnabled()) {
- log.info(t("User stop simulation %s", jobToStop.getItem().getControl()
- .getId()));
- }
- }
- }
-
- /**
- * Restart simulation.
- */
- protected void restartSimulation() {
- int[] selectedRows = queueUI.getQueueTableDone().getSelectedRows();
- SimulationJob[] jobsToRestart = new SimulationJob[selectedRows.length];
- int index = 0;
-
- // to do in two pass, because each simulation
- // change selected rows
- for (int selectedRow : selectedRows) {
- jobsToRestart[index++] = queueUI.getDoneSimulationModel().getJob(selectedRow);
- }
- for (SimulationJob jobToRestart : jobsToRestart) {
-
- jobToRestart.restart();
- jobToRestart.getItem().getControl().setText(t("isisfish.simulation.restarting"));
- if (log.isInfoEnabled()) {
- log.info(t("User restart simulation %s", jobToRestart.getItem().getControl()
- .getId()));
- }
- }
- }
-
- /**
- * View log of selected done jobs.
- */
- protected void viewLog() {
- if (queueUI.getQueueTableDone().getSelectedRow() >= 0) {
- SimulationJob selectedJob = queueUI.getDoneSimulationModel().getJob(queueUI.getQueueTableDone().getSelectedRow());
-
- String id = selectedJob.getItem().getControl().getId();
- try {
- SimulationLoggerUtil.showSimulationLogConsole(queueUI, id);
- } catch (Exception eee) {
- if (log.isErrorEnabled()) {
- log.error(t("Can't open log for %s", id), eee);
- }
- ErrorHelper.showErrorDialog(t("Can't open log for %s", id), eee);
- }
- }
- }
-
- /**
- * Remove all done jobs.
- */
- protected void clearDoneJobs() {
- SimulationService ss = SimulationService.getService();
- ss.clearJobDone();
- }
-}
Copied: trunk/src/main/java/fr/ifremer/isisfish/ui/queue/QueueHandler.java (from rev 4226, trunk/src/main/java/fr/ifremer/isisfish/ui/queue/QueueAction.java)
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/queue/QueueHandler.java (rev 0)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/queue/QueueHandler.java 2015-05-20 13:11:09 UTC (rev 4229)
@@ -0,0 +1,151 @@
+/*
+ * #%L
+ * IsisFish
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2009 - 2010 Ifremer, Code Lutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+package fr.ifremer.isisfish.ui.queue;
+
+import static org.nuiton.i18n.I18n.t;
+
+import javax.swing.JProgressBar;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import fr.ifremer.isisfish.logging.SimulationLoggerUtil;
+import fr.ifremer.isisfish.simulator.launcher.SimulationJob;
+import fr.ifremer.isisfish.simulator.launcher.SimulationService;
+import fr.ifremer.isisfish.ui.util.ErrorHelper;
+
+/**
+ * Common action for all queue ui.
+ *
+ * @author chatellier
+ * @version $Revision$
+ *
+ * Last update : $Date$
+ * By : $Author$
+ */
+public class QueueHandler {
+
+ /** Log. */
+ private static Log log = LogFactory.getLog(QueueHandler.class);
+
+ /** queue ui to manage. */
+ protected QueueUI queueUI;
+
+ /**
+ * Queue action.
+ *
+ * @param queueUI queue ui to manage
+ */
+ public void init(QueueUI queueUI) {
+ this.queueUI = queueUI;
+
+ queueUI.queueTable.setDefaultRenderer(JProgressBar.class, new ComponentTableCellRenderer());
+ queueUI.queueTableDone.setDefaultRenderer(JProgressBar.class, new ComponentTableCellRenderer());
+ }
+
+ /**
+ * Update ui buttons.
+ */
+ public void updateActions() {
+ queueUI.setCanStop(!queueUI.getSelectionModelQueueTable().isSelectionEmpty());
+ queueUI.setCanShowLog(!queueUI.getSelectionModelQueueTableDone().isSelectionEmpty());
+ queueUI.setCanClear(queueUI.getQueueTableDone().getModel().getRowCount()>0);
+ queueUI.setCanRestart(!queueUI.getSelectionModelQueueTableDone().isSelectionEmpty());
+ }
+
+ /**
+ * Stop simulation associated with table selected rows.
+ */
+ protected void stopSimulation() {
+ int[] selectedRows = queueUI.getQueueTable().getSelectedRows();
+ SimulationJob[] jobsToStop = new SimulationJob[selectedRows.length];
+ int index = 0;
+
+ // to do in two pass, because each stopped simulation
+ // change selected rows
+ for (int selectedRow : selectedRows) {
+ jobsToStop[index++] = queueUI.getNewSimulationModel().getJob(selectedRow);
+ }
+ for (SimulationJob jobToStop : jobsToStop) {
+ jobToStop.stop();
+ if (log.isInfoEnabled()) {
+ log.info(t("User stop simulation %s", jobToStop.getItem().getControl()
+ .getId()));
+ }
+ }
+ }
+
+ /**
+ * Restart simulation.
+ */
+ protected void restartSimulation() {
+ int[] selectedRows = queueUI.getQueueTableDone().getSelectedRows();
+ SimulationJob[] jobsToRestart = new SimulationJob[selectedRows.length];
+ int index = 0;
+
+ // to do in two pass, because each simulation
+ // change selected rows
+ for (int selectedRow : selectedRows) {
+ jobsToRestart[index++] = queueUI.getDoneSimulationModel().getJob(selectedRow);
+ }
+ for (SimulationJob jobToRestart : jobsToRestart) {
+
+ jobToRestart.restart();
+ jobToRestart.getItem().getControl().setText(t("isisfish.simulation.restarting"));
+ if (log.isInfoEnabled()) {
+ log.info(t("User restart simulation %s", jobToRestart.getItem().getControl()
+ .getId()));
+ }
+ }
+ }
+
+ /**
+ * View log of selected done jobs.
+ */
+ protected void viewLog() {
+ if (queueUI.getQueueTableDone().getSelectedRow() >= 0) {
+ SimulationJob selectedJob = queueUI.getDoneSimulationModel().getJob(queueUI.getQueueTableDone().getSelectedRow());
+
+ String id = selectedJob.getItem().getControl().getId();
+ try {
+ SimulationLoggerUtil.showSimulationLogConsole(queueUI, id);
+ } catch (Exception eee) {
+ if (log.isErrorEnabled()) {
+ log.error(t("Can't open log for %s", id), eee);
+ }
+ ErrorHelper.showErrorDialog(t("Can't open log for %s", id), eee);
+ }
+ }
+ }
+
+ /**
+ * Remove all done jobs.
+ */
+ protected void clearDoneJobs() {
+ SimulationService ss = SimulationService.getService();
+ ss.clearJobDone();
+ }
+}
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/queue/QueueUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/queue/QueueUI.jaxx 2015-05-20 12:58:46 UTC (rev 4228)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/queue/QueueUI.jaxx 2015-05-20 13:11:09 UTC (rev 4229)
@@ -23,44 +23,42 @@
#L%
-->
<Table>
- <import>
- fr.ifremer.isisfish.simulator.launcher.SimulationServiceTableModel;
- fr.ifremer.isisfish.simulator.launcher.SimulationService;
- javax.swing.JProgressBar;
- javax.swing.ListSelectionModel;
- </import>
-
- <script><![CDATA[
- queueTable.setDefaultRenderer(JProgressBar.class, new ComponentTableCellRenderer());
- queueTableDone.setDefaultRenderer(JProgressBar.class, new ComponentTableCellRenderer());
- ]]>
- </script>
+ <import>
+ fr.ifremer.isisfish.simulator.launcher.SimulationService
+ fr.ifremer.isisfish.simulator.launcher.SimulationServiceTableModel
+ </import>
+ <script><![CDATA[
+ protected void $afterCompleteSetup() {
+ handler.init(this);
+ }
+ ]]></script>
+
<Boolean id='canStop' javaBean='false'/>
<Boolean id='canShowLog' javaBean='false'/>
<Boolean id='canClear' javaBean='false'/>
<Boolean id='canRestart' javaBean='false'/>
- <QueueAction id="queueAction" javaBean='new QueueAction(this)'/>
+ <QueueHandler id="handler" />
<SimulationServiceTableModel id="newSimulationModel" javaBean='new SimulationServiceTableModel(SimulationService.getService(), true)'/>
<SimulationServiceTableModel id="doneSimulationModel" javaBean='new SimulationServiceTableModel(SimulationService.getService(), false)'
- onTableChanged='queueAction.updateActions()' />
+ onTableChanged='handler.updateActions()' />
<PauseButtonModel id="autoLaunchButtonModel" javaBean='new PauseButtonModel(SimulationService.getService())'/>
- <DefaultListSelectionModel id="selectionModelQueueTable" onValueChanged='queueAction.updateActions()'/>
- <DefaultListSelectionModel id="selectionModelQueueTableDone" onValueChanged='queueAction.updateActions()'/>
+ <DefaultListSelectionModel id="selectionModelQueueTable" onValueChanged='handler.updateActions()'/>
+ <DefaultListSelectionModel id="selectionModelQueueTableDone" onValueChanged='handler.updateActions()'/>
<row>
<cell columns="5" fill="both" weightx="1.0" weighty="0.5">
<JSplitPane oneTouchExpandable="true" orientation="VERTICAL" resizeWeight="0.5">
<JScrollPane>
<JTable id="queueTable" model='{newSimulationModel}'
- selectionMode="{ListSelectionModel.MULTIPLE_INTERVAL_SELECTION}"
+ selectionMode="{javax.swing.ListSelectionModel.MULTIPLE_INTERVAL_SELECTION}"
selectionModel="{selectionModelQueueTable}"/>
</JScrollPane>
<JScrollPane>
<JTable id="queueTableDone" model='{doneSimulationModel}'
- selectionMode="{ListSelectionModel.SINGLE_SELECTION}"
+ selectionMode="{javax.swing.ListSelectionModel.SINGLE_SELECTION}"
selectionModel="{selectionModelQueueTableDone}" />
</JScrollPane>
</JSplitPane>
@@ -71,16 +69,16 @@
<JToggleButton id="autoLaunchButton" text="isisfish.queue.simulationLaunch" model="{autoLaunchButtonModel}"/>
</cell>
<cell fill="horizontal" weightx="0.3">
- <JButton id="stopSimuButton" text="isisfish.queue.stopSimulation" onActionPerformed='queueAction.stopSimulation()' enabled='{isCanStop()}' />
+ <JButton id="stopSimuButton" text="isisfish.queue.stopSimulation" onActionPerformed='handler.stopSimulation()' enabled='{isCanStop()}' />
</cell>
<cell fill="horizontal" weightx="0.3">
- <JButton id="restartSimulationButton" text="isisfish.queue.restartSimulation" onActionPerformed='queueAction.restartSimulation()' enabled='{isCanRestart()}' />
+ <JButton id="restartSimulationButton" text="isisfish.queue.restartSimulation" onActionPerformed='handler.restartSimulation()' enabled='{isCanRestart()}' />
</cell>
<cell fill="horizontal" weightx="0.3">
- <JButton id="showLogButton" text="isisfish.queue.showLog" onActionPerformed='queueAction.viewLog()' enabled='{isCanShowLog()}' />
+ <JButton id="showLogButton" text="isisfish.queue.showLog" onActionPerformed='handler.viewLog()' enabled='{isCanShowLog()}' />
</cell>
<cell fill="horizontal" weightx="0.3">
- <JButton id="clearDoneJobsButton" text="isisfish.queue.clearDone" onActionPerformed='queueAction.clearDoneJobs()' enabled='{isCanClear()}' />
+ <JButton id="clearDoneJobsButton" text="isisfish.queue.clearDone" onActionPerformed='handler.clearDoneJobs()' enabled='{isCanClear()}' />
</cell>
</row>
</Table>
1
0
r4228 - in trunk/src/main/java/fr/ifremer/isisfish: datastore/migration ui/input ui/input/equation ui/input/gear ui/input/metier ui/input/population ui/input/setofvessels ui/input/strategy ui/input/variable ui/sensitivity ui/sensitivity/wizard ui/widget/editor
by echatellier@users.forge.codelutin.com 20 May '15
by echatellier@users.forge.codelutin.com 20 May '15
20 May '15
Author: echatellier
Date: 2015-05-20 12:58:46 +0000 (Wed, 20 May 2015)
New Revision: 4228
Url: http://forge.codelutin.com/projects/isis-fish/repository/revisions/4228
Log:
Move script code to dedicated handler (equation)
Added:
trunk/src/main/java/fr/ifremer/isisfish/ui/input/equation/
trunk/src/main/java/fr/ifremer/isisfish/ui/input/equation/EquationEditorPaneHandler.java
trunk/src/main/java/fr/ifremer/isisfish/ui/input/equation/EquationEditorPaneUI.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/input/equation/FormuleComboRenderer.java
trunk/src/main/java/fr/ifremer/isisfish/ui/input/equation/InputOneEquationHandler.java
trunk/src/main/java/fr/ifremer/isisfish/ui/input/equation/InputOneEquationUI.jaxx
Removed:
trunk/src/main/java/fr/ifremer/isisfish/ui/input/EquationEditorPaneUI.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/input/FormuleComboRenderer.java
trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputOneEquationUI.jaxx
Modified:
trunk/src/main/java/fr/ifremer/isisfish/datastore/migration/MigrationV33V40.java
trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputAction.java
trunk/src/main/java/fr/ifremer/isisfish/ui/input/gear/SelectivityUI.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/input/metier/MetierSeasonInfoSpeciesUI.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationBasicsUI.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationCapturabilityUI.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationEquationUI.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationEquationUI.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationPriceUI.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationRecruitmentUI.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/input/setofvessels/SetOfVesselsBasicsUI.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/input/strategy/StrategyTabUI.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/input/variable/EntityVariableUI.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/SensitivityInputHandler.java
trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/wizard/EquationContinuousPanelUI.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/wizard/SensitivityWizardHandler.java
trunk/src/main/java/fr/ifremer/isisfish/ui/widget/editor/EquationTableEditor.java
Modified: trunk/src/main/java/fr/ifremer/isisfish/datastore/migration/MigrationV33V40.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/datastore/migration/MigrationV33V40.java 2015-05-20 12:09:09 UTC (rev 4227)
+++ trunk/src/main/java/fr/ifremer/isisfish/datastore/migration/MigrationV33V40.java 2015-05-20 12:58:46 UTC (rev 4228)
@@ -43,7 +43,7 @@
import fr.ifremer.isisfish.entities.Equation;
import fr.ifremer.isisfish.entities.Population;
import fr.ifremer.isisfish.entities.PopulationImpl;
-import fr.ifremer.isisfish.ui.input.EquationEditorPaneUI;
+import fr.ifremer.isisfish.ui.input.equation.EquationEditorPaneUI;
import fr.ifremer.isisfish.util.EvaluatorHelper;
/**
@@ -159,7 +159,7 @@
frame.setTitle(t("isisfish.message.import.equation.convert"));
try {
- frame.setEquation(equation.getCategory(), equation.getName(),
+ frame.getHandler().setEquation(equation.getCategory(), equation.getName(),
equation.getJavaInterface(), content);
} catch (Exception ex) {
if (log.isErrorEnabled()) {
Deleted: trunk/src/main/java/fr/ifremer/isisfish/ui/input/EquationEditorPaneUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/EquationEditorPaneUI.jaxx 2015-05-20 12:09:09 UTC (rev 4227)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/EquationEditorPaneUI.jaxx 2015-05-20 12:58:46 UTC (rev 4228)
@@ -1,141 +0,0 @@
-<!--
- #%L
- IsisFish
-
- $Id$
- $HeadURL$
- %%
- Copyright (C) 2009 - 2011 Ifremer, Code Lutin, Chatellier Eric
- %%
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as
- published by the Free Software Foundation, either version 3 of the
- License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public
- License along with this program. If not, see
- <http://www.gnu.org/licenses/gpl-3.0.html>.
- #L%
- -->
-<JDialog id="EquationEditorPane" modal="true" title="isisfish.equation.editor.title"
- width="400" height="400" layout="{new BorderLayout()}"
- modalityType="{Dialog.ModalityType.APPLICATION_MODAL}">
-
- <Boolean id="resultOk" javaBean="false" />
-
- <import>
- fr.ifremer.isisfish.util.CompileHelper;
- fr.ifremer.isisfish.util.EvaluatorHelper;
- org.nuiton.util.FileUtil;
- javax.swing.text.html.HTMLEditorKit;
- javax.swing.text.html.HTMLDocument;
- javax.swing.event.HyperlinkListener;
- javax.swing.text.html.HTMLFrameHyperlinkEvent;
- javax.swing.event.HyperlinkEvent;
- java.io.PrintWriter;
- java.io.StringWriter;
- java.awt.Color
- java.awt.Desktop
- </import>
-
- <script><![CDATA[
-Class javaInterface = null;
-
-protected void $afterCompleteSetup() {
- split.setDividerLocation(0.8);
-}
-
-public void setEquation(String category, String name, Class javaInterface, String content) throws Exception {
- this.javaInterface = javaInterface;
- getDoc().setText(CompileHelper.extractDoc(category, name, javaInterface));
- getEditor().open(FileUtil.getTempFile(content, ".java"));
-}
-
-public void docEditorHyperlinkUpdate(HyperlinkEvent e) {
- if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
- if (e instanceof HTMLFrameHyperlinkEvent) {
- ((HTMLDocument)doc.getDocument()).processHTMLFrameHyperlinkEvent(
- (HTMLFrameHyperlinkEvent)e);
- } else {
- try {
- if (Desktop.isDesktopSupported() && Desktop.getDesktop().isSupported(Desktop.Action.BROWSE)) {
- Desktop.getDesktop().browse(e.getURL().toURI());
- } else {
- doc.setPage(e.getURL());
- }
- } catch (Exception ex) {
- if (log.isErrorEnabled()) {
- log.error("Error for : " + e.getURL(), ex);
- }
- }
- }
- }
-}
-
-public void check() {
- try {
- String content = editor.getText();
-
- StringWriter result = new StringWriter();
- PrintWriter out = new PrintWriter(result);
- int compileResult = 0;
- try {
- compileResult = EvaluatorHelper.check(javaInterface, content, out);
- } catch (Exception eee) {
- compileResult = -1;
- }
-
- out.flush();
- if (compileResult != 0) {
- checkWindow.setText(result.toString());
- checkWindow.setBackground(Color.RED);
- } else {
- checkWindow.setText("Compilation Ok");
- checkWindow.setBackground(Color.WHITE);
- }
-
- } catch(Exception e){
- log.error("Can't check script", e);
- }
-}
-
- ]]></script>
-
- <Table constraints="BorderLayout.CENTER">
- <row>
- <cell columns='3' weighty="1" fill='both'>
- <JScrollPane>
- <JEditorPane id="doc" editable="false" editorKit="{new HTMLEditorKit()}"
- onHyperlinkUpdate="docEditorHyperlinkUpdate(event)" />
- </JScrollPane>
- </cell>
- </row>
- <row columns='3' weightx="1" weighty="5" fill='both'>
- <cell>
- <JSplitPane id='split' orientation='vertical'
- oneTouchExpandable='true' resizeWeight='0.8'>
- <org.nuiton.widget.editor.Editor id="editor" askIfNotSaved="false" />
- <JScrollPane>
- <JTextArea id="checkWindow" editable="false" />
- </JScrollPane>
- </JSplitPane>
- </cell>
- </row>
- <row fill='horizontal'>
- <cell>
- <JButton text='isisfish.common.check' onActionPerformed='check()' />
- </cell>
- <cell weightx="1" fill="none" anchor="east">
- <JButton id='okButton' text='isisfish.common.ok' onActionPerformed='setResultOk(true); setVisible(false)' />
- </cell>
- <cell anchor="east">
- <JButton id='cancelButton' text='isisfish.common.cancel' onActionPerformed='setVisible(false)' />
- </cell>
- </row>
- </Table>
-</JDialog>
Deleted: trunk/src/main/java/fr/ifremer/isisfish/ui/input/FormuleComboRenderer.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/FormuleComboRenderer.java 2015-05-20 12:09:09 UTC (rev 4227)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/FormuleComboRenderer.java 2015-05-20 12:58:46 UTC (rev 4228)
@@ -1,69 +0,0 @@
-/*
- * #%L
- * IsisFish
- *
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2009 - 2010 Ifremer, CodeLutin
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-
-package fr.ifremer.isisfish.ui.input;
-
-import java.awt.Component;
-
-import javax.swing.DefaultListCellRenderer;
-import javax.swing.JLabel;
-import javax.swing.JList;
-
-import fr.ifremer.isisfish.entities.Formule;
-
-/**
- * Renderer pour la combo des {@link Formule}.
- *
- * @author chatellier
- * @version $Revision$
- *
- * Last update : $Date$
- * By : $Author$
- */
-public class FormuleComboRenderer extends DefaultListCellRenderer {
-
- /** serialVersionUID. */
- private static final long serialVersionUID = -8277883340386163087L;
-
- /*
- * @see javax.swing.ListCellRenderer#getListCellRendererComponent(javax.swing.JList, java.lang.Object, int, boolean, boolean)
- */
- @Override
- public Component getListCellRendererComponent(JList<?> list, Object value,
- int index, boolean isSelected, boolean cellHasFocus) {
-
- // this must be used to have alterned highlight rows and default
- // selection color
- JLabel c = (JLabel) super.getListCellRendererComponent(list, value,
- index, isSelected, cellHasFocus);
-
- // there is no default selection
- if (value != null) {
- Formule formule = (Formule) value;
- c.setText(formule.getName());
- }
- return c;
- }
-}
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputAction.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputAction.java 2015-05-20 12:09:09 UTC (rev 4227)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputAction.java 2015-05-20 12:58:46 UTC (rev 4228)
@@ -78,6 +78,8 @@
import fr.ifremer.isisfish.ui.input.check.CheckRegion;
import fr.ifremer.isisfish.ui.input.check.CheckResult;
import fr.ifremer.isisfish.ui.input.check.CheckResultFrame;
+import fr.ifremer.isisfish.ui.input.equation.EquationEditorPaneUI;
+import fr.ifremer.isisfish.ui.input.equation.InputOneEquationUI;
import fr.ifremer.isisfish.ui.util.ErrorHelper;
import fr.ifremer.isisfish.util.CellPointcomparator;
@@ -91,7 +93,10 @@
*
* Last update: $Date$
* by : $Author$
+ *
+ * @deprecated since 4.4.0.0, move code to dedicated handlers
*/
+@Deprecated
public class InputAction {
/** Class logger. */
@@ -313,7 +318,7 @@
}
try {
EquationEditorPaneUI pane = new EquationEditorPaneUI(ui);
- pane.setEquation(category, name, javaInterface, content);
+ pane.getHandler().setEquation(category, name, javaInterface, content);
pane.setLocationRelativeTo(ui);
pane.setVisible(true); // blocking call
if (pane.isResultOk() && editor != null) {
@@ -330,7 +335,7 @@
return null;
}
- protected List<Formule> getFormules(TopiaContext isisContext, String name) {
+ public List<Formule> getFormules(TopiaContext isisContext, String name) {
return FormuleStorage.getFormules(isisContext, name);
}
Deleted: trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputOneEquationUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputOneEquationUI.jaxx 2015-05-20 12:09:09 UTC (rev 4227)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputOneEquationUI.jaxx 2015-05-20 12:58:46 UTC (rev 4228)
@@ -1,271 +0,0 @@
-<!--
- #%L
- IsisFish
-
- $Id$
- $HeadURL$
- %%
- Copyright (C) 2009 - 2015 Ifremer, Code Lutin, Chatellier Eric
- %%
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as
- published by the Free Software Foundation, either version 3 of the
- License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public
- License along with this program. If not, see
- <http://www.gnu.org/licenses/gpl-3.0.html>.
- #L%
- -->
-<fr.ifremer.isisfish.ui.input.InputContentUI superGenericType='org.nuiton.topia.persistence.TopiaEntityContextable'>
-
- <!-- Equation name (just for display purpose, not mandatory) -->
- <String id='text' javaBean='null'/>
- <!-- Bean containing equation -->
- <org.nuiton.topia.persistence.TopiaEntityContextable id='bean' javaBean='null'/>
- <!-- Bean property used to access equation -->
- <String id='beanProperty' javaBean='null'/>
- <!-- Used to get documentation in opened editor (not mandatory) -->
- <Class id='clazz' javaBean='null'/>
-
- <!-- Bean property -->
- <fr.ifremer.isisfish.entities.Formule id='formule' javaBean='null'/>
- <!-- Equation name used to auto select formule in combo box -->
- <String id='formuleCategory' javaBean='null'/>
- <!-- Selected equation -->
- <fr.ifremer.isisfish.entities.Equation id='selectedEquation' javaBean='null'/>
-
- <Boolean id="autoSaveModification" javaBean="true" />
-
- <import>
- static org.nuiton.i18n.I18n.t
- java.lang.reflect.Method;
- java.io.File;
- fr.ifremer.isisfish.entities.Formule;
- fr.ifremer.isisfish.entities.Equation;
- fr.ifremer.isisfish.ui.models.common.GenericComboModel;
- org.apache.commons.lang3.StringUtils;
- org.nuiton.topia.TopiaContext;
- javax.swing.event.DocumentListener;
- javax.swing.event.DocumentEvent
- java.beans.PropertyChangeEvent;
- java.beans.PropertyChangeListener;
- java.io.IOException
- javax.swing.DefaultComboBoxModel
- </import>
- <script><![CDATA[
-
-protected DocumentListener listener = null;
-
-protected void $afterCompleteSetup() {
- addPropertyChangeListener(PROPERTY_BEAN, new PropertyChangeListener() {
- public void propertyChange(PropertyChangeEvent evt) {
- if (evt.getNewValue() == null) {
- formuleComboBox.setModel(new DefaultComboBoxModel());
- try {
- File nullFile = org.nuiton.util.FileUtil.getTempFile("", ".java");
- editor.open(nullFile);
- editor.setEnabled(false); // editor is replaced at each launch
- } catch (IOException e) {
- if (log.isErrorEnabled()) {
- log.error("Error on property change", e);
- }
- }
- }
- if (evt.getNewValue() != null) {
- // chatellier 20090526 : force refresh in bean change ?
- refresh();
- }
- }
- });
-
- if (listener == null) {
- listener = new DocumentListener() {
- @Override
- public void insertUpdate(DocumentEvent e) {
- setEquation();
- }
- @Override
- public void removeUpdate(DocumentEvent e) {
- setEquation();
- }
- @Override
- public void changedUpdate(DocumentEvent e) {
- }
- };
- }
- setComboModel();
-}
-
-/**
- * Get equation on entity.
- */
-protected Equation getEquation() {
- Equation result = null;
- try {
- // can be null in some uis
- // content is managed by caller, can do anythings here
- if (bean != null && beanProperty != null) {
- String localBeanProperty = StringUtils.capitalize(beanProperty);
- Method m = bean.getClass().getMethod("get" + localBeanProperty);
- result = (Equation)m.invoke(bean);
- }
- } catch (Exception e) {
- if (log.isErrorEnabled()) {
- log.error("Can't get equation", e);
- }
- }
- return result;
-}
-
-/**
- * Call setXXXContent on topia entity (convention).
- */
-protected void setEquation() {
- try {
- // can be null in some uis
- // content is managed by caller, can do anythings here
- if (bean != null && beanProperty != null) {
- if (log.isDebugEnabled()) {
- log.debug("Saving equation content (" + bean.getClass().getSimpleName() +
- "#" + beanProperty + ")");
- }
- String localBeanProperty = StringUtils.capitalize(beanProperty);
- Method m = bean.getClass().getMethod("set" + localBeanProperty + "Content", String.class);
- m.invoke(bean, editor.getText());
- }
- else {
- if (log.isDebugEnabled()) {
- log.debug("No bean property defined, skipping content saving");
- }
- }
- } catch (Exception e) {
- if (log.isErrorEnabled()) {
- log.error("Can't set equation content", e);
- }
- }
-}
-
-public void refresh() {
-
- // TODO binding don't work
- if (getText() == null) {
- setText(t("isisfish.common.equation"));
- }
-
- editor.getCurrentEditor().removeDocumentListener(listener);
- try {
- File equationContentFile = org.nuiton.util.FileUtil.getTempFile("", ".java");
- editor.open(equationContentFile);
- editor.setEnabled(isActive());
- } catch (IOException ex) {
- if (log.isErrorEnabled()) {
- log.error("Can't refresh editor", ex);
- }
- }
- if (formuleCategory != null) {
- // chatellier 20090526 (change to get combo selected on this equation)
- selectedEquation = getEquation();
- setComboModel();
- setFormule((Formule)formuleComboBox.getSelectedItem());
- setEditorText();
- }
-
- // utilisee lors de l'edition des equations dans l'interface de sensibilité
- // le contenu de l'equation ne doit pas automatiquement
- // etre sauvé dans l'entité (pas de sens pour un facteur discret de type equation)
- if (autoSaveModification) {
- editor.getCurrentEditor().addDocumentListener(listener);
- }
-}
-
-protected void setComboModel() {
- if (getBean() != null){
- TopiaContext isisContext = ((org.nuiton.topia.persistence.TopiaEntityAbstract)getBean()).getTopiaContext();
- java.util.List<Formule> formules = null;
- if (formuleCategory != null) {
- formules = getAction().getFormules(isisContext, formuleCategory);
- GenericComboModel formulesModel = new GenericComboModel(formules);
- formuleComboBox.setModel(formulesModel);
- // fix default selection
- formuleComboBox.setSelectedItem(selectedEquation);
- }
- }
-}
-protected void saveModel() {
- getContextValue(InputAction.class).saveAsModel(formuleCategory, "Java", editor.getText());
- setComboModel();
- setInfoText(t("isisfish.message.saveModel.finished"));
-}
-
-/**
- * Open external editor, with equation documentation.
- */
-protected void openEditor() {
- Formule e = (Formule)formuleComboBox.getSelectedItem();
- if (e != null) {
- getContextValue(InputAction.class).openEditor(this, e.getCategory(), e.getName(), clazz, e.getContent(), editor);
- }
- else {
- getContextValue(InputAction.class).openEditor(this, formuleCategory, "new", clazz, editor.getText(), editor);
- }
-}
-protected void setEditorText() {
- if (getFormule() != null) {
- editor.setText(getFormule().getContent());
- }
- else {
- try {
- File nullFile = org.nuiton.util.FileUtil.getTempFile("", ".java");
- editor.open(nullFile);
- } catch (IOException e) {
- if (log.isErrorEnabled()) {
- log.error("Open editor", e);
- }
- }
- }
-}
-
-/**
- * New formule selected, replace content.
- */
-protected void formuleChanged() {
- Formule selectedFormule = (Formule)formuleComboBox.getSelectedItem();
- setFormule(selectedFormule);
- setEditorText();
-}
- ]]>
- </script>
- <JPanel id="body">
- <Table insets="0">
- <row>
- <cell fill='horizontal' anchor='east'>
- <JLabel text='{getText()}' enabled='{isActive()}'/>
- </cell>
- <cell fill='horizontal'>
- <JComboBox id="formuleComboBox" onActionPerformed='formuleChanged()' enabled='{isActive()}'
- genericType="fr.ifremer.isisfish.entities.Formule"
- renderer="{new FormuleComboRenderer()}" />
- </cell>
- </row>
- <row>
- <cell fill='horizontal' anchor='north'>
- <JButton text="isisfish.common.saveModel" onActionPerformed='saveModel()' enabled='{isActive() && formuleCategory != null}'/>
- </cell>
- <cell fill='both' weightx='1.0' weighty='1.0' rows="2">
- <org.nuiton.widget.editor.Editor id='editor' askIfNotSaved="false" enabled='{isActive()}'/>
- </cell>
- </row>
- <row>
- <cell fill='horizontal' anchor='north' weighty='1.0'>
- <JButton text="isisfish.common.openEditor" onActionPerformed='openEditor()' enabled='{isActive() && clazz != null && formuleCategory != null}'/>
- </cell>
- </row>
- </Table>
- </JPanel>
-</fr.ifremer.isisfish.ui.input.InputContentUI>
Added: trunk/src/main/java/fr/ifremer/isisfish/ui/input/equation/EquationEditorPaneHandler.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/equation/EquationEditorPaneHandler.java (rev 0)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/equation/EquationEditorPaneHandler.java 2015-05-20 12:58:46 UTC (rev 4228)
@@ -0,0 +1,113 @@
+/*
+ * #%L
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2015 Ifremer, Codelutin, Chatellier Eric
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+package fr.ifremer.isisfish.ui.input.equation;
+
+import java.awt.Color;
+import java.awt.Desktop;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+
+import javax.swing.event.HyperlinkEvent;
+import javax.swing.text.html.HTMLDocument;
+import javax.swing.text.html.HTMLFrameHyperlinkEvent;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.nuiton.util.FileUtil;
+
+import fr.ifremer.isisfish.util.CompileHelper;
+import fr.ifremer.isisfish.util.EvaluatorHelper;
+
+/**
+ * Equation editor handler.
+ */
+public class EquationEditorPaneHandler {
+
+ /** Class logger. */
+ private static final Log log = LogFactory.getLog(EquationEditorPaneHandler.class);
+
+ protected EquationEditorPaneUI equationUI;
+
+ protected Class javaInterface = null;
+
+ protected void init(final EquationEditorPaneUI equationUI) {
+ this.equationUI = equationUI;
+
+ equationUI.split.setDividerLocation(0.8);
+ }
+
+ public void setEquation(String category, String name, Class javaInterface, String content) throws Exception {
+ this.javaInterface = javaInterface;
+ equationUI.getDoc().setText(CompileHelper.extractDoc(category, name, javaInterface));
+ equationUI.getEditor().open(FileUtil.getTempFile(content, ".java"));
+ }
+
+ public void docEditorHyperlinkUpdate(HyperlinkEvent e) {
+ if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
+ if (e instanceof HTMLFrameHyperlinkEvent) {
+ ((HTMLDocument)equationUI.doc.getDocument()).processHTMLFrameHyperlinkEvent(
+ (HTMLFrameHyperlinkEvent)e);
+ } else {
+ try {
+ if (Desktop.isDesktopSupported() && Desktop.getDesktop().isSupported(Desktop.Action.BROWSE)) {
+ Desktop.getDesktop().browse(e.getURL().toURI());
+ } else {
+ equationUI.doc.setPage(e.getURL());
+ }
+ } catch (Exception ex) {
+ if (log.isErrorEnabled()) {
+ log.error("Error for : " + e.getURL(), ex);
+ }
+ }
+ }
+ }
+ }
+
+ public void check() {
+ try {
+ String content = equationUI.editor.getText();
+
+ StringWriter result = new StringWriter();
+ PrintWriter out = new PrintWriter(result);
+ int compileResult = 0;
+ try {
+ compileResult = EvaluatorHelper.check(javaInterface, content, out);
+ } catch (Exception eee) {
+ compileResult = -1;
+ }
+
+ out.flush();
+ if (compileResult != 0) {
+ equationUI.checkWindow.setText(result.toString());
+ equationUI.checkWindow.setBackground(Color.RED);
+ } else {
+ equationUI.checkWindow.setText("Compilation Ok");
+ equationUI.checkWindow.setBackground(Color.WHITE);
+ }
+
+ } catch(Exception e){
+ log.error("Can't check script", e);
+ }
+ }
+}
Property changes on: trunk/src/main/java/fr/ifremer/isisfish/ui/input/equation/EquationEditorPaneHandler.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Copied: trunk/src/main/java/fr/ifremer/isisfish/ui/input/equation/EquationEditorPaneUI.jaxx (from rev 4226, trunk/src/main/java/fr/ifremer/isisfish/ui/input/EquationEditorPaneUI.jaxx)
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/equation/EquationEditorPaneUI.jaxx (rev 0)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/equation/EquationEditorPaneUI.jaxx 2015-05-20 12:58:46 UTC (rev 4228)
@@ -0,0 +1,71 @@
+<!--
+ #%L
+ IsisFish
+
+ $Id$
+ $HeadURL$
+ %%
+ Copyright (C) 2009 - 2015 Ifremer, Code Lutin, Chatellier Eric
+ %%
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as
+ published by the Free Software Foundation, either version 3 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public
+ License along with this program. If not, see
+ <http://www.gnu.org/licenses/gpl-3.0.html>.
+ #L%
+ -->
+<JDialog id="EquationEditorPane" modal="true" title="isisfish.equation.editor.title"
+ width="400" height="400" layout="{new BorderLayout()}"
+ modalityType="{Dialog.ModalityType.APPLICATION_MODAL}">
+
+ <Boolean id="resultOk" javaBean="false" />
+
+ <EquationEditorPaneHandler id="handler" />
+
+ <script><![CDATA[
+ protected void $afterCompleteSetup() {
+ handler.init(this);
+ }
+ ]]></script>
+
+ <Table constraints="BorderLayout.CENTER">
+ <row>
+ <cell columns='3' weighty="1" fill='both'>
+ <JScrollPane>
+ <JEditorPane id="doc" editable="false" editorKit="{new javax.swing.text.html.HTMLEditorKit()}"
+ onHyperlinkUpdate="handler.docEditorHyperlinkUpdate(event)" />
+ </JScrollPane>
+ </cell>
+ </row>
+ <row columns='3' weightx="1" weighty="5" fill='both'>
+ <cell>
+ <JSplitPane id='split' orientation='vertical'
+ oneTouchExpandable='true' resizeWeight='0.8'>
+ <org.nuiton.widget.editor.Editor id="editor" askIfNotSaved="false" />
+ <JScrollPane>
+ <JTextArea id="checkWindow" editable="false" />
+ </JScrollPane>
+ </JSplitPane>
+ </cell>
+ </row>
+ <row fill='horizontal'>
+ <cell>
+ <JButton text='isisfish.common.check' onActionPerformed='handler.check()' />
+ </cell>
+ <cell weightx="1" fill="none" anchor="east">
+ <JButton id='okButton' text='isisfish.common.ok' onActionPerformed='setResultOk(true); setVisible(false)' />
+ </cell>
+ <cell anchor="east">
+ <JButton id='cancelButton' text='isisfish.common.cancel' onActionPerformed='setVisible(false)' />
+ </cell>
+ </row>
+ </Table>
+</JDialog>
Copied: trunk/src/main/java/fr/ifremer/isisfish/ui/input/equation/FormuleComboRenderer.java (from rev 4227, trunk/src/main/java/fr/ifremer/isisfish/ui/input/FormuleComboRenderer.java)
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/equation/FormuleComboRenderer.java (rev 0)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/equation/FormuleComboRenderer.java 2015-05-20 12:58:46 UTC (rev 4228)
@@ -0,0 +1,69 @@
+/*
+ * #%L
+ * IsisFish
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2009 - 2010 Ifremer, CodeLutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+package fr.ifremer.isisfish.ui.input.equation;
+
+import java.awt.Component;
+
+import javax.swing.DefaultListCellRenderer;
+import javax.swing.JLabel;
+import javax.swing.JList;
+
+import fr.ifremer.isisfish.entities.Formule;
+
+/**
+ * Renderer pour la combo des {@link Formule}.
+ *
+ * @author chatellier
+ * @version $Revision$
+ *
+ * Last update : $Date$
+ * By : $Author$
+ */
+public class FormuleComboRenderer extends DefaultListCellRenderer {
+
+ /** serialVersionUID. */
+ private static final long serialVersionUID = -8277883340386163087L;
+
+ /*
+ * @see javax.swing.ListCellRenderer#getListCellRendererComponent(javax.swing.JList, java.lang.Object, int, boolean, boolean)
+ */
+ @Override
+ public Component getListCellRendererComponent(JList<?> list, Object value,
+ int index, boolean isSelected, boolean cellHasFocus) {
+
+ // this must be used to have alterned highlight rows and default
+ // selection color
+ JLabel c = (JLabel) super.getListCellRendererComponent(list, value,
+ index, isSelected, cellHasFocus);
+
+ // there is no default selection
+ if (value != null) {
+ Formule formule = (Formule) value;
+ c.setText(formule.getName());
+ }
+ return c;
+ }
+}
Added: trunk/src/main/java/fr/ifremer/isisfish/ui/input/equation/InputOneEquationHandler.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/equation/InputOneEquationHandler.java (rev 0)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/equation/InputOneEquationHandler.java 2015-05-20 12:58:46 UTC (rev 4228)
@@ -0,0 +1,242 @@
+/*
+ * #%L
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2015 Ifremer, Codelutin, Chatellier Eric
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+package fr.ifremer.isisfish.ui.input.equation;
+
+import static org.nuiton.i18n.I18n.t;
+
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.io.File;
+import java.io.IOException;
+import java.lang.reflect.Method;
+import java.util.List;
+
+import javax.swing.DefaultComboBoxModel;
+import javax.swing.event.DocumentEvent;
+import javax.swing.event.DocumentListener;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.nuiton.topia.TopiaContext;
+import org.nuiton.util.FileUtil;
+
+import fr.ifremer.isisfish.entities.Equation;
+import fr.ifremer.isisfish.entities.Formule;
+import fr.ifremer.isisfish.ui.input.InputAction;
+import fr.ifremer.isisfish.ui.input.InputContentHandler;
+import fr.ifremer.isisfish.ui.models.common.GenericComboModel;
+
+/**
+ * Equation handler.
+ */
+public class InputOneEquationHandler extends InputContentHandler<InputOneEquationUI> {
+
+ /** Class logger. */
+ private static final Log log = LogFactory.getLog(InputOneEquationHandler.class);
+
+ protected DocumentListener listener = null;
+
+ protected void init(final InputOneEquationUI inputContentUI) {
+ super.init(inputContentUI);
+
+ inputContentUI.addPropertyChangeListener(InputOneEquationUI.PROPERTY_BEAN, new PropertyChangeListener() {
+ public void propertyChange(PropertyChangeEvent evt) {
+ if (evt.getNewValue() == null) {
+ inputContentUI.formuleComboBox.setModel(new DefaultComboBoxModel<Formule>());
+ try {
+ File nullFile = org.nuiton.util.FileUtil.getTempFile("", ".java");
+ inputContentUI.editor.open(nullFile);
+ inputContentUI.editor.setEnabled(false); // editor is replaced at each launch
+ } catch (IOException e) {
+ if (log.isErrorEnabled()) {
+ log.error("Error on property change", e);
+ }
+ }
+ }
+ if (evt.getNewValue() != null) {
+ // chatellier 20090526 : force refresh in bean change ?
+ refresh();
+ }
+ }
+ });
+
+ if (listener == null) {
+ listener = new DocumentListener() {
+ @Override
+ public void insertUpdate(DocumentEvent e) {
+ setEquation();
+ }
+ @Override
+ public void removeUpdate(DocumentEvent e) {
+ setEquation();
+ }
+ @Override
+ public void changedUpdate(DocumentEvent e) {
+ }
+ };
+ }
+ setComboModel();
+ }
+
+ /**
+ * Get equation on entity.
+ */
+ protected Equation getEquation() {
+ Equation result = null;
+ try {
+ // can be null in some uis
+ // content is managed by caller, can do anythings here
+ if (inputContentUI.bean != null && inputContentUI.beanProperty != null) {
+ String localBeanProperty = StringUtils.capitalize(inputContentUI.beanProperty);
+ Method m = inputContentUI.bean.getClass().getMethod("get" + localBeanProperty);
+ result = (Equation)m.invoke(inputContentUI.bean);
+ }
+ } catch (Exception e) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't get equation", e);
+ }
+ }
+ return result;
+ }
+
+ /**
+ * Call setXXXContent on topia entity (convention).
+ */
+ protected void setEquation() {
+ try {
+ // can be null in some uis
+ // content is managed by caller, can do anythings here
+ if (inputContentUI.bean != null && inputContentUI.beanProperty != null) {
+ if (log.isDebugEnabled()) {
+ log.debug("Saving equation content (" + inputContentUI.bean.getClass().getSimpleName() +
+ "#" + inputContentUI.beanProperty + ")");
+ }
+ String localBeanProperty = StringUtils.capitalize(inputContentUI.beanProperty);
+ Method m = inputContentUI.bean.getClass().getMethod("set" + localBeanProperty + "Content", String.class);
+ m.invoke(inputContentUI.bean, inputContentUI.editor.getText());
+ }
+ else {
+ if (log.isDebugEnabled()) {
+ log.debug("No bean property defined, skipping content saving");
+ }
+ }
+ } catch (Exception e) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't set equation content", e);
+ }
+ }
+ }
+
+ public void refresh() {
+
+ // TODO binding don't work
+ if (inputContentUI.getText() == null) {
+ inputContentUI.setText(t("isisfish.common.equation"));
+ }
+
+ inputContentUI.editor.getCurrentEditor().removeDocumentListener(listener);
+ try {
+ File equationContentFile = FileUtil.getTempFile("", ".java");
+ inputContentUI.editor.open(equationContentFile);
+ inputContentUI.editor.setEnabled(inputContentUI.isActive());
+ } catch (IOException ex) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't refresh editor", ex);
+ }
+ }
+ if (inputContentUI.formuleCategory != null) {
+ // chatellier 20090526 (change to get combo selected on this equation)
+ inputContentUI.selectedEquation = getEquation();
+ setComboModel();
+ inputContentUI.setFormule((Formule)inputContentUI.formuleComboBox.getSelectedItem());
+ setEditorText();
+ }
+
+ // utilisee lors de l'edition des equations dans l'interface de sensibilité
+ // le contenu de l'equation ne doit pas automatiquement
+ // etre sauvé dans l'entité (pas de sens pour un facteur discret de type equation)
+ if (inputContentUI.autoSaveModification) {
+ inputContentUI.editor.getCurrentEditor().addDocumentListener(listener);
+ }
+ }
+
+ protected void setComboModel() {
+ if (inputContentUI.getBean() != null){
+ TopiaContext isisContext = ((org.nuiton.topia.persistence.TopiaEntityAbstract)inputContentUI.getBean()).getTopiaContext();
+ List<Formule> formules = null;
+ if (inputContentUI.formuleCategory != null) {
+ formules = inputContentUI.getAction().getFormules(isisContext, inputContentUI.formuleCategory);
+ GenericComboModel<Formule> formulesModel = new GenericComboModel<>(formules);
+ inputContentUI.formuleComboBox.setModel(formulesModel);
+ // fix default selection
+ inputContentUI.formuleComboBox.setSelectedItem(inputContentUI.selectedEquation);
+ }
+ }
+ }
+
+ protected void saveModel() {
+ inputContentUI.getContextValue(InputAction.class).saveAsModel(inputContentUI.formuleCategory, "Java", inputContentUI.editor.getText());
+ setComboModel();
+ inputContentUI.setInfoText(t("isisfish.message.saveModel.finished"));
+ }
+
+ /**
+ * Open external editor, with equation documentation.
+ */
+ protected void openEditor() {
+ Formule e = (Formule)inputContentUI.formuleComboBox.getSelectedItem();
+ if (e != null) {
+ inputContentUI.getContextValue(InputAction.class).openEditor(inputContentUI, e.getCategory(),
+ e.getName(), inputContentUI.clazz, e.getContent(), inputContentUI.editor);
+ } else {
+ inputContentUI.getContextValue(InputAction.class).openEditor(inputContentUI, inputContentUI.formuleCategory,
+ "new", inputContentUI.clazz, inputContentUI.editor.getText(), inputContentUI.editor);
+ }
+ }
+
+ protected void setEditorText() {
+ if (inputContentUI.getFormule() != null) {
+ inputContentUI.editor.setText(inputContentUI.getFormule().getContent());
+ } else {
+ try {
+ File nullFile = org.nuiton.util.FileUtil.getTempFile("", ".java");
+ inputContentUI.editor.open(nullFile);
+ } catch (IOException e) {
+ if (log.isErrorEnabled()) {
+ log.error("Open editor", e);
+ }
+ }
+ }
+ }
+
+ /**
+ * New formule selected, replace content.
+ */
+ protected void formuleChanged() {
+ Formule selectedFormule = (Formule)inputContentUI.formuleComboBox.getSelectedItem();
+ inputContentUI.setFormule(selectedFormule);
+ setEditorText();
+ }
+}
Property changes on: trunk/src/main/java/fr/ifremer/isisfish/ui/input/equation/InputOneEquationHandler.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Copied: trunk/src/main/java/fr/ifremer/isisfish/ui/input/equation/InputOneEquationUI.jaxx (from rev 4227, trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputOneEquationUI.jaxx)
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/equation/InputOneEquationUI.jaxx (rev 0)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/equation/InputOneEquationUI.jaxx 2015-05-20 12:58:46 UTC (rev 4228)
@@ -0,0 +1,81 @@
+<!--
+ #%L
+ IsisFish
+
+ $Id$
+ $HeadURL$
+ %%
+ Copyright (C) 2009 - 2015 Ifremer, Code Lutin, Chatellier Eric
+ %%
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as
+ published by the Free Software Foundation, either version 3 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public
+ License along with this program. If not, see
+ <http://www.gnu.org/licenses/gpl-3.0.html>.
+ #L%
+ -->
+<fr.ifremer.isisfish.ui.input.InputContentUI superGenericType='org.nuiton.topia.persistence.TopiaEntityContextable'>
+
+ <!-- Equation name (just for display purpose, not mandatory) -->
+ <String id='text' javaBean='null'/>
+ <!-- Bean containing equation -->
+ <org.nuiton.topia.persistence.TopiaEntityContextable id='bean' javaBean='null'/>
+ <!-- Bean property used to access equation -->
+ <String id='beanProperty' javaBean='null'/>
+ <!-- Used to get documentation in opened editor (not mandatory) -->
+ <Class id='clazz' javaBean='null'/>
+
+ <!-- Bean property -->
+ <fr.ifremer.isisfish.entities.Formule id='formule' javaBean='null'/>
+ <!-- Equation name used to auto select formule in combo box -->
+ <String id='formuleCategory' javaBean='null'/>
+ <!-- Selected equation -->
+ <fr.ifremer.isisfish.entities.Equation id='selectedEquation' javaBean='null'/>
+
+ <Boolean id="autoSaveModification" javaBean="true" />
+
+ <InputOneEquationHandler id="handler" />
+
+ <script><![CDATA[
+ protected void $afterCompleteSetup() {
+ handler.init(this);
+ }
+ ]]></script>
+
+ <JPanel id="body">
+ <Table insets="0">
+ <row>
+ <cell fill='horizontal' anchor='east'>
+ <JLabel text='{getText()}' enabled='{isActive()}'/>
+ </cell>
+ <cell fill='horizontal'>
+ <JComboBox id="formuleComboBox" onActionPerformed='handler.formuleChanged()' enabled='{isActive()}'
+ genericType="fr.ifremer.isisfish.entities.Formule"
+ renderer="{new FormuleComboRenderer()}" />
+ </cell>
+ </row>
+ <row>
+ <cell fill='horizontal' anchor='north'>
+ <JButton text="isisfish.common.saveModel" onActionPerformed='handler.saveModel()' enabled='{isActive() && formuleCategory != null}'/>
+ </cell>
+ <cell fill='both' weightx='1.0' weighty='1.0' rows="2">
+ <org.nuiton.widget.editor.Editor id='editor' askIfNotSaved="false" enabled='{isActive()}'/>
+ </cell>
+ </row>
+ <row>
+ <cell fill='horizontal' anchor='north' weighty='1.0'>
+ <JButton text="isisfish.common.openEditor" onActionPerformed='handler.openEditor()'
+ enabled='{isActive() && clazz != null && formuleCategory != null}'/>
+ </cell>
+ </row>
+ </Table>
+ </JPanel>
+</fr.ifremer.isisfish.ui.input.InputContentUI>
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/gear/SelectivityUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/gear/SelectivityUI.jaxx 2015-05-20 12:09:09 UTC (rev 4227)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/gear/SelectivityUI.jaxx 2015-05-20 12:58:46 UTC (rev 4228)
@@ -67,7 +67,7 @@
</row>
<row>
<cell columns='2' fill='both' weightx='1.0' weighty='1.0' insets="0">
- <fr.ifremer.isisfish.ui.input.InputOneEquationUI id='selectivityEquation' constructorParams='this'
+ <fr.ifremer.isisfish.ui.input.equation.InputOneEquationUI id='selectivityEquation' constructorParams='this'
text='isisfish.selectivity.equation'
bean='{getBean()}' formuleCategory='Selectivity' active='{getPopulation() != null}'
clazz='{fr.ifremer.isisfish.equation.SelectivityEquation.class}'
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/metier/MetierSeasonInfoSpeciesUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/metier/MetierSeasonInfoSpeciesUI.jaxx 2015-05-20 12:09:09 UTC (rev 4227)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/metier/MetierSeasonInfoSpeciesUI.jaxx 2015-05-20 12:58:46 UTC (rev 4228)
@@ -85,7 +85,7 @@
</row>
<row>
<cell columns='2' fill='both' weightx='1.0' weighty='1.0'>
- <fr.ifremer.isisfish.ui.input.InputOneEquationUI id='targetFactor' constructorParams='this'
+ <fr.ifremer.isisfish.ui.input.equation.InputOneEquationUI id='targetFactor' constructorParams='this'
active='{isActive() && getMetierSeasonInfo() != null}'
text='isisfish.metierSeasonInfoSpecies.targetFactor'
bean='{getMetierSeasonInfo()}' formuleCategory='TargetFactor'
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationBasicsUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationBasicsUI.jaxx 2015-05-20 12:09:09 UTC (rev 4227)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationBasicsUI.jaxx 2015-05-20 12:58:46 UTC (rev 4228)
@@ -122,7 +122,7 @@
</row>
<row>
<cell columns='4' fill='both' weightx='1.0' weighty='1.0'>
- <fr.ifremer.isisfish.ui.input.InputOneEquationUI id='growthEquation' constructorParams='this'
+ <fr.ifremer.isisfish.ui.input.equation.InputOneEquationUI id='growthEquation' constructorParams='this'
text='isisfish.populationBasics.growth' active='{isActive()}'
bean='{getBean()}' beanProperty='growth' formuleCategory='Growth'
clazz='{fr.ifremer.isisfish.equation.PopulationGrowth.class}'
@@ -131,7 +131,7 @@
</row>
<row>
<cell columns='4' fill='both' weightx='1.0' weighty='1.0'>
- <fr.ifremer.isisfish.ui.input.InputOneEquationUI id='growthReverseEquation' constructorParams='this'
+ <fr.ifremer.isisfish.ui.input.equation.InputOneEquationUI id='growthReverseEquation' constructorParams='this'
text='isisfish.populationBasics.growthReverse' active='{isActive()}'
bean='{getBean()}' formuleCategory='GrowthReverse' beanProperty='GrowthReverse'
clazz='{fr.ifremer.isisfish.equation.PopulationGrowthReverse.class}'
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationCapturabilityUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationCapturabilityUI.jaxx 2015-05-20 12:09:09 UTC (rev 4227)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationCapturabilityUI.jaxx 2015-05-20 12:58:46 UTC (rev 4228)
@@ -63,7 +63,7 @@
enabled='{isActive()}' decorator='boxed' _sensitivityBean='{Population.class}' _sensitivityMethod='"Capturability"'
onMatrixChanged="handler.populationCapturabilityMatrixChanged(event)"
constraints='"fieldUseMatrix"' />
- <fr.ifremer.isisfish.ui.input.InputOneEquationUI id='capturabilityEquation' constructorParams='this'
+ <fr.ifremer.isisfish.ui.input.equation.InputOneEquationUI id='capturabilityEquation' constructorParams='this'
text='isisfish.common.capturability' active='{isActive()}'
bean='{getBean()}' formuleCategory='Capturability' beanProperty='CapturabilityEquation'
clazz='{fr.ifremer.isisfish.equation.PopulationCapturabilityEquation.class}'
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationEquationUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationEquationUI.jaxx 2015-05-20 12:09:09 UTC (rev 4227)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationEquationUI.jaxx 2015-05-20 12:58:46 UTC (rev 4228)
@@ -44,7 +44,7 @@
<Table>
<row>
<cell columns='2' fill='both' weightx='0.5' weighty='0.3'>
- <fr.ifremer.isisfish.ui.input.InputOneEquationUI id='naturalDeathRate' constructorParams='this'
+ <fr.ifremer.isisfish.ui.input.equation.InputOneEquationUI id='naturalDeathRate' constructorParams='this'
text='isisfish.populationEquation.naturalDeathRate' active="{isActive()}"
bean='{getBean()}' formuleCategory='NaturalDeathRate' beanProperty='NaturalDeathRate'
clazz='{fr.ifremer.isisfish.equation.PopulationNaturalDeathRate.class}'
@@ -53,7 +53,7 @@
</row>
<row>
<cell columns='2' fill='both' weightx='1.0' weighty='0.3'>
- <fr.ifremer.isisfish.ui.input.InputOneEquationUI id='meanWeight' constructorParams='this'
+ <fr.ifremer.isisfish.ui.input.equation.InputOneEquationUI id='meanWeight' constructorParams='this'
text='isisfish.populationEquation.meanWeight' active="{isActive()}"
bean='{getBean()}' formuleCategory='MeanWeight' beanProperty='MeanWeight'
clazz='{fr.ifremer.isisfish.equation.PopulationMeanWeight.class}'
@@ -62,7 +62,7 @@
</row>
<row>
<cell columns='2' fill='both' weightx='1.0' weighty='0.3'>
- <fr.ifremer.isisfish.ui.input.InputOneEquationUI id='maturityOgive' constructorParams='this'
+ <fr.ifremer.isisfish.ui.input.equation.InputOneEquationUI id='maturityOgive' constructorParams='this'
text='isisfish.populationEquation.MaturityOgive' active="{isActive()}"
bean='{getBean()}' formuleCategory='MaturityOgive' beanProperty='MaturityOgiveEquation'
clazz='{fr.ifremer.isisfish.equation.PopulationMaturityOgiveEquation.class}'
@@ -71,7 +71,7 @@
</row>
<row>
<cell columns='2' fill='both' weightx='1.0' weighty='0.3'>
- <fr.ifremer.isisfish.ui.input.InputOneEquationUI id='reproductionRate' constructorParams='this'
+ <fr.ifremer.isisfish.ui.input.equation.InputOneEquationUI id='reproductionRate' constructorParams='this'
text='isisfish.populationEquation.reproductionRate' active="{isActive()}"
bean='{getBean()}' formuleCategory='ReproductionRate' beanProperty='ReproductionRateEquation'
clazz='{fr.ifremer.isisfish.equation.PopulationReproductionRateEquation.class}'
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationEquationUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationEquationUI.jaxx 2015-05-20 12:09:09 UTC (rev 4227)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationEquationUI.jaxx 2015-05-20 12:58:46 UTC (rev 4228)
@@ -47,7 +47,7 @@
<Table>
<row>
<cell fill='both' weightx='1.0' weighty='1.0'>
- <fr.ifremer.isisfish.ui.input.InputOneEquationUI id='migrationEquation' constructorParams='this'
+ <fr.ifremer.isisfish.ui.input.equation.InputOneEquationUI id='migrationEquation' constructorParams='this'
text='isisfish.common.migration' active='{isActive()}'
bean='{getPopInfo()}' formuleCategory='Migration' beanProperty='MigrationEquation'
clazz='{fr.ifremer.isisfish.equation.MigrationEquation.class}'
@@ -56,7 +56,7 @@
</row>
<row>
<cell fill='both' weightx='1.0' weighty='1.0'>
- <fr.ifremer.isisfish.ui.input.InputOneEquationUI id='emigrationEquation' constructorParams='this'
+ <fr.ifremer.isisfish.ui.input.equation.InputOneEquationUI id='emigrationEquation' constructorParams='this'
text='isisfish.common.emigration' active='{isActive()}'
bean='{getPopInfo()}' formuleCategory='Emigration' beanProperty='EmigrationEquation'
clazz='{fr.ifremer.isisfish.equation.EmigrationEquation.class}'
@@ -65,7 +65,7 @@
</row>
<row>
<cell fill='both' weightx='1.0' weighty='1.0'>
- <fr.ifremer.isisfish.ui.input.InputOneEquationUI id='immigrationEquation' constructorParams='this'
+ <fr.ifremer.isisfish.ui.input.equation.InputOneEquationUI id='immigrationEquation' constructorParams='this'
text='isisfish.common.immigration' active='{isActive()}'
bean='{getPopInfo()}' formuleCategory='Immigration' beanProperty='ImmigrationEquation'
clazz='{fr.ifremer.isisfish.equation.ImmigrationEquation.class}'
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationPriceUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationPriceUI.jaxx 2015-05-20 12:09:09 UTC (rev 4227)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationPriceUI.jaxx 2015-05-20 12:58:46 UTC (rev 4228)
@@ -44,7 +44,7 @@
<Table>
<row>
<cell columns='2' fill='both' weightx='1.0' weighty='0.3'>
- <fr.ifremer.isisfish.ui.input.InputOneEquationUI id='price' constructorParams='this'
+ <fr.ifremer.isisfish.ui.input.equation.InputOneEquationUI id='price' constructorParams='this'
text='isisfish.populationEquation.price' active="{isActive()}"
bean='{getBean()}' formuleCategory='Price' beanProperty='Price'
clazz='{fr.ifremer.isisfish.equation.PopulationPrice.class}'
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationRecruitmentUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationRecruitmentUI.jaxx 2015-05-20 12:09:09 UTC (rev 4227)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationRecruitmentUI.jaxx 2015-05-20 12:58:46 UTC (rev 4228)
@@ -47,7 +47,7 @@
<Table>
<row>
<cell columns='3' fill='both' weightx='1.0' weighty='1'>
- <fr.ifremer.isisfish.ui.input.InputOneEquationUI id='reproductionEquation' constructorParams='this'
+ <fr.ifremer.isisfish.ui.input.equation.InputOneEquationUI id='reproductionEquation' constructorParams='this'
active="{isActive()}" text='isisfish.populationEquation.reproductionEquation'
bean='{getBean()}' formuleCategory='Reproduction' beanProperty='ReproductionEquation'
clazz='{fr.ifremer.isisfish.equation.PopulationReproductionEquation.class}'
@@ -86,7 +86,7 @@
</row>
<row>
<cell columns='3' fill='both' weightx='1.0' weighty='1'>
- <fr.ifremer.isisfish.ui.input.InputOneEquationUI id='recruitmentEquation' constructorParams='this'
+ <fr.ifremer.isisfish.ui.input.equation.InputOneEquationUI id='recruitmentEquation' constructorParams='this'
active="{isActive()}" text='isisfish.populationEquation.recruitmentEquation'
bean='{getBean()}' formuleCategory='Recruitment' beanProperty='RecruitmentEquation'
clazz='{fr.ifremer.isisfish.equation.PopulationRecruitmentEquation.class}'
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/setofvessels/SetOfVesselsBasicsUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/setofvessels/SetOfVesselsBasicsUI.jaxx 2015-05-20 12:09:09 UTC (rev 4227)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/setofvessels/SetOfVesselsBasicsUI.jaxx 2015-05-20 12:58:46 UTC (rev 4228)
@@ -104,7 +104,7 @@
</row>
<row>
<cell columns='2' fill='both' weightx='1.0' weighty='0.3'>
- <fr.ifremer.isisfish.ui.input.InputOneEquationUI id='technicalEfficiency' constructorParams='this'
+ <fr.ifremer.isisfish.ui.input.equation.InputOneEquationUI id='technicalEfficiency' constructorParams='this'
text='isisfish.setOfVessels.technicalEfficiency' active='{isActive()}'
bean='{getBean()}' formuleCategory='TechnicalEfficiency' beanProperty='TechnicalEfficiencyEquation'
clazz='{fr.ifremer.isisfish.equation.SoVTechnicalEfficiencyEquation.class}'
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/strategy/StrategyTabUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/strategy/StrategyTabUI.jaxx 2015-05-20 12:09:09 UTC (rev 4227)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/strategy/StrategyTabUI.jaxx 2015-05-20 12:58:46 UTC (rev 4228)
@@ -92,7 +92,7 @@
</row>
<row>
<cell columns="2" fill='both' weightx='1.0' weighty='0.5'>
- <fr.ifremer.isisfish.ui.input.InputOneEquationUI id="strategyInactivity" constructorParams='this'
+ <fr.ifremer.isisfish.ui.input.equation.InputOneEquationUI id="strategyInactivity" constructorParams='this'
text='isisfish.strategy.inactivity'
active="{isActive() && getBean() != null && bean.isInactivityEquationUsed()}"
bean='{getBean()}' formuleCategory='Inactivity' beanProperty='InactivityEquation'
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/variable/EntityVariableUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/variable/EntityVariableUI.jaxx 2015-05-20 12:09:09 UTC (rev 4227)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/variable/EntityVariableUI.jaxx 2015-05-20 12:58:46 UTC (rev 4228)
@@ -141,7 +141,7 @@
<Table constraints='"equationtype"' insets="0">
<row>
<cell fill="both" weightx='1.0' weighty='1.0'>
- <fr.ifremer.isisfish.ui.input.InputOneEquationUI id="variableEquationValue"
+ <fr.ifremer.isisfish.ui.input.equation.InputOneEquationUI id="variableEquationValue"
constructorParams='this'
active='{isActive() && getVariable() != null}'
text='isisfish.common.equation' formuleCategory='Variable'
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/SensitivityInputHandler.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/SensitivityInputHandler.java 2015-05-20 12:09:09 UTC (rev 4227)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/SensitivityInputHandler.java 2015-05-20 12:58:46 UTC (rev 4228)
@@ -63,7 +63,7 @@
import fr.ifremer.isisfish.types.TimeStep;
import fr.ifremer.isisfish.ui.input.InputContentUI;
import fr.ifremer.isisfish.ui.input.InputHandler;
-import fr.ifremer.isisfish.ui.input.InputOneEquationUI;
+import fr.ifremer.isisfish.ui.input.equation.InputOneEquationUI;
import fr.ifremer.isisfish.ui.input.tree.FisheryDataProvider;
import fr.ifremer.isisfish.ui.input.tree.FisheryTreeHelper;
import fr.ifremer.isisfish.ui.input.tree.FisheryTreeNode;
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/wizard/EquationContinuousPanelUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/wizard/EquationContinuousPanelUI.jaxx 2015-05-20 12:09:09 UTC (rev 4227)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/wizard/EquationContinuousPanelUI.jaxx 2015-05-20 12:58:46 UTC (rev 4228)
@@ -191,7 +191,7 @@
</row>
<row>
<cell fill='both' columns='2' weightx='1' weighty='1'>
- <fr.ifremer.isisfish.ui.input.InputOneEquationUI id='editor' constructorParams='this'
+ <fr.ifremer.isisfish.ui.input.equation.InputOneEquationUI id='editor' constructorParams='this'
autoSaveModification="false" formule='{getFormule()}' text='{getText()}'
bean='{getBean()}' clazz='{getClazz()}' beanProperty='{getBeanProperty()}'
formuleCategory='{getFormuleCategory()}' selectedEquation='{getSelectedEquation()}'
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/wizard/SensitivityWizardHandler.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/wizard/SensitivityWizardHandler.java 2015-05-20 12:09:09 UTC (rev 4227)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/wizard/SensitivityWizardHandler.java 2015-05-20 12:58:46 UTC (rev 4228)
@@ -73,7 +73,7 @@
import fr.ifremer.isisfish.types.TimeUnit;
import fr.ifremer.isisfish.ui.SimulationUI;
import fr.ifremer.isisfish.ui.input.InputAction;
-import fr.ifremer.isisfish.ui.input.InputOneEquationUI;
+import fr.ifremer.isisfish.ui.input.equation.InputOneEquationUI;
import fr.ifremer.isisfish.ui.simulator.RuleChooser;
import fr.ifremer.isisfish.ui.simulator.SimulAction;
import fr.ifremer.isisfish.ui.widget.editor.MonthComponent;
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/widget/editor/EquationTableEditor.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/widget/editor/EquationTableEditor.java 2015-05-20 12:09:09 UTC (rev 4227)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/widget/editor/EquationTableEditor.java 2015-05-20 12:58:46 UTC (rev 4228)
@@ -44,7 +44,7 @@
import fr.ifremer.isisfish.IsisFishRuntimeException;
import fr.ifremer.isisfish.entities.Equation;
-import fr.ifremer.isisfish.ui.input.EquationEditorPaneUI;
+import fr.ifremer.isisfish.ui.input.equation.EquationEditorPaneUI;
/**
* Equation table cell editor.
@@ -102,7 +102,7 @@
this.setText(equation.getName());
try {
- getFrame().setEquation(equation.getCategory(), equation.getName(),
+ getFrame().getHandler().setEquation(equation.getCategory(), equation.getName(),
equation.getJavaInterface(), equation.getContent());
} catch (Exception eee) {
throw new IsisFishRuntimeException(
1
0
20 May '15
Author: echatellier
Date: 2015-05-20 12:09:09 +0000 (Wed, 20 May 2015)
New Revision: 4227
Url: http://forge.codelutin.com/projects/isis-fish/repository/revisions/4227
Log:
Move script code to dedicated handler
Added:
trunk/src/main/java/fr/ifremer/isisfish/ui/input/FormuleComboRenderer.java
trunk/src/main/java/fr/ifremer/isisfish/ui/input/gear/GearHandler.java
trunk/src/main/java/fr/ifremer/isisfish/ui/input/gear/GearTabHandler.java
trunk/src/main/java/fr/ifremer/isisfish/ui/input/gear/RangeOfValuesHandler.java
trunk/src/main/java/fr/ifremer/isisfish/ui/input/gear/SelectivityHandler.java
trunk/src/main/java/fr/ifremer/isisfish/ui/input/metier/MetierHandler.java
trunk/src/main/java/fr/ifremer/isisfish/ui/input/metier/MetierSeasonInfoComboRenderer.java
trunk/src/main/java/fr/ifremer/isisfish/ui/input/metier/MetierSeasonInfoSpeciesHandler.java
trunk/src/main/java/fr/ifremer/isisfish/ui/input/metier/MetierSeasonInfoZoneHandler.java
trunk/src/main/java/fr/ifremer/isisfish/ui/input/metier/MetierTabHandler.java
trunk/src/main/java/fr/ifremer/isisfish/ui/input/observation/ObservationHandler.java
trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationBasicsHandler.java
trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationCapturabilityHandler.java
trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationEquationHandler.java
trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationGroupHandler.java
trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationHandler.java
trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationEmigrationHandler.java
trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationEquationHandler.java
trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationHandler.java
trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationImmigrationHandler.java
trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationMigrationHandler.java
trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationPriceHandler.java
trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationRecruitmentHandler.java
trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationSeasonInfoComboRenderer.java
trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationSeasonSpacializedHandler.java
trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationSeasonsHandler.java
trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationZonesEditorHandler.java
trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationZonesHandler.java
trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/WizardGroupCreationHandler.java
trunk/src/main/java/fr/ifremer/isisfish/ui/input/port/PortHandler.java
trunk/src/main/java/fr/ifremer/isisfish/ui/input/setofvessels/EffortDescriptionHandler.java
trunk/src/main/java/fr/ifremer/isisfish/ui/input/setofvessels/EffortDescriptionListRenderer.java
trunk/src/main/java/fr/ifremer/isisfish/ui/input/setofvessels/EffortDescriptionParametersHandler.java
trunk/src/main/java/fr/ifremer/isisfish/ui/input/setofvessels/MetierListRenderer.java
trunk/src/main/java/fr/ifremer/isisfish/ui/input/setofvessels/SetOfVesselsBasicsHandler.java
trunk/src/main/java/fr/ifremer/isisfish/ui/input/setofvessels/SetOfVesselsHandler.java
trunk/src/main/java/fr/ifremer/isisfish/ui/input/species/SpeciesHandler.java
trunk/src/main/java/fr/ifremer/isisfish/ui/input/species/SpeciesStructuredHandler.java
trunk/src/main/java/fr/ifremer/isisfish/ui/input/strategy/StrategyHandler.java
trunk/src/main/java/fr/ifremer/isisfish/ui/input/strategy/StrategyMonthInfoHandler.java
trunk/src/main/java/fr/ifremer/isisfish/ui/input/strategy/StrategyOneMonthInfoHandler.java
trunk/src/main/java/fr/ifremer/isisfish/ui/input/strategy/StrategyTabHandler.java
trunk/src/main/java/fr/ifremer/isisfish/ui/input/triptype/TripTypeHandler.java
trunk/src/main/java/fr/ifremer/isisfish/ui/input/triptype/TripTypeListRenderer.java
trunk/src/main/java/fr/ifremer/isisfish/ui/input/vesseltype/VesselTypeHandler.java
trunk/src/main/java/fr/ifremer/isisfish/ui/input/zone/ZoneBasicsHandler.java
trunk/src/main/java/fr/ifremer/isisfish/ui/models/common/EnumComboModel.java
Removed:
trunk/src/main/java/fr/ifremer/isisfish/ui/input/renderer/
Modified:
trunk/src/main/java/fr/ifremer/isisfish/ui/SaveVerifier.java
trunk/src/main/java/fr/ifremer/isisfish/ui/WelcomeSaveVerifier.java
trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputContentHandler.java
trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputOneEquationUI.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputTabbedPaneListener.java
trunk/src/main/java/fr/ifremer/isisfish/ui/input/cell/CellHandler.java
trunk/src/main/java/fr/ifremer/isisfish/ui/input/check/CheckResult.java
trunk/src/main/java/fr/ifremer/isisfish/ui/input/gear/GearTabUI.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/input/gear/GearUI.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/input/gear/RangeOfValuesUI.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/input/gear/SelectivityUI.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/input/metier/MetierSeasonInfoSpeciesUI.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/input/metier/MetierSeasonInfoZoneUI.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/input/metier/MetierTabUI.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/input/metier/MetierUI.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/input/observation/ObservationUI.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationBasicsUI.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationCapturabilityUI.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationEquationUI.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationGroupUI.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationEmigrationUI.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationEquationUI.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationImmigrationUI.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationMigrationUI.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationUI.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationPriceUI.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationRecruitmentUI.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationSeasonSpacializedUI.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationSeasonsUI.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationUI.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationZonesEditorUI.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationZonesUI.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/WizardGroupCreationUI.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/input/port/PortUI.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/input/setofvessels/EffortDescriptionParametersUI.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/input/setofvessels/EffortDescriptionUI.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/input/setofvessels/SetOfVesselsBasicsUI.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/input/setofvessels/SetOfVesselsUI.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/input/species/SpeciesStructuredUI.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/input/species/SpeciesUI.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/input/strategy/StrategyMonthInfoUI.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/input/strategy/StrategyOneMonthInfoUI.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/input/strategy/StrategyTabUI.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/input/strategy/StrategyUI.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/input/tree/FisheryTreeSelectionModel.java
trunk/src/main/java/fr/ifremer/isisfish/ui/input/triptype/TripTypeUI.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/input/variable/EntityVariableHandler.java
trunk/src/main/java/fr/ifremer/isisfish/ui/input/variable/EntityVariableUI.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/input/vesseltype/VesselTypeUI.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/input/zone/ZoneBasicsUI.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/input/zone/ZoneHandler.java
trunk/src/main/java/fr/ifremer/isisfish/ui/input/zone/ZoneUI.jaxx
trunk/src/main/resources/i18n/isis-fish_en_GB.properties
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/SaveVerifier.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/SaveVerifier.java 2015-05-18 09:52:01 UTC (rev 4226)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/SaveVerifier.java 2015-05-20 12:09:09 UTC (rev 4227)
@@ -5,7 +5,7 @@
* $Id$
* $HeadURL$
* %%
- * Copyright (C) 2009 - 2011 Ifremer, Code Lutin, Chatellier Eric
+ * Copyright (C) 2009 - 2015 Ifremer, Code Lutin, Chatellier Eric
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
@@ -25,6 +25,8 @@
package fr.ifremer.isisfish.ui;
+import javax.swing.JOptionPane;
+
/**
* Isis interface modification verifier.
*
@@ -38,16 +40,18 @@
* by : $Author$
*/
public interface SaveVerifier {
-
+
+ public static final int YES_OPTION = JOptionPane.YES_OPTION;
+ public static final int NO_OPTION = JOptionPane.NO_OPTION;
+ public static final int CANCEL_OPTION = JOptionPane.CANCEL_OPTION;
+
/**
* Tell verifier to check for unsaved modification.
*
- * Then return user choice ({@link javax.swing.JOptionPane} type).
- *
- * @return user JOptionPane response
- * @see javax.swing.JOptionPane#YES_OPTION
- * @see javax.swing.JOptionPane#NO_OPTION
- * @see javax.swing.JOptionPane#CANCEL_OPTION
+ * @return user int response
+ * @see #YES_OPTION
+ * @see #NO_OPTION
+ * @see #CANCEL_OPTION
*/
public int checkEdit();
}
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/WelcomeSaveVerifier.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/WelcomeSaveVerifier.java 2015-05-18 09:52:01 UTC (rev 4226)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/WelcomeSaveVerifier.java 2015-05-20 12:09:09 UTC (rev 4227)
@@ -5,7 +5,7 @@
* $Id$
* $HeadURL$
* %%
- * Copyright (C) 2009 - 2010 Ifremer, Code Lutin
+ * Copyright (C) 2009 - 2015 Ifremer, Code Lutin
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
@@ -28,8 +28,6 @@
import java.util.ArrayList;
import java.util.List;
-import javax.swing.JOptionPane;
-
/**
* WelcomeSaveVerifier.
*
@@ -66,7 +64,7 @@
// return false, if at least one verifier
// return cancel option
- if (reponse == JOptionPane.CANCEL_OPTION) {
+ if (reponse == SaveVerifier.CANCEL_OPTION) {
canExit = false;
}
}
Copied: trunk/src/main/java/fr/ifremer/isisfish/ui/input/FormuleComboRenderer.java (from rev 4226, trunk/src/main/java/fr/ifremer/isisfish/ui/input/renderer/FormuleComboRenderer.java)
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/FormuleComboRenderer.java (rev 0)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/FormuleComboRenderer.java 2015-05-20 12:09:09 UTC (rev 4227)
@@ -0,0 +1,69 @@
+/*
+ * #%L
+ * IsisFish
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2009 - 2010 Ifremer, CodeLutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+package fr.ifremer.isisfish.ui.input;
+
+import java.awt.Component;
+
+import javax.swing.DefaultListCellRenderer;
+import javax.swing.JLabel;
+import javax.swing.JList;
+
+import fr.ifremer.isisfish.entities.Formule;
+
+/**
+ * Renderer pour la combo des {@link Formule}.
+ *
+ * @author chatellier
+ * @version $Revision$
+ *
+ * Last update : $Date$
+ * By : $Author$
+ */
+public class FormuleComboRenderer extends DefaultListCellRenderer {
+
+ /** serialVersionUID. */
+ private static final long serialVersionUID = -8277883340386163087L;
+
+ /*
+ * @see javax.swing.ListCellRenderer#getListCellRendererComponent(javax.swing.JList, java.lang.Object, int, boolean, boolean)
+ */
+ @Override
+ public Component getListCellRendererComponent(JList<?> list, Object value,
+ int index, boolean isSelected, boolean cellHasFocus) {
+
+ // this must be used to have alterned highlight rows and default
+ // selection color
+ JLabel c = (JLabel) super.getListCellRendererComponent(list, value,
+ index, isSelected, cellHasFocus);
+
+ // there is no default selection
+ if (value != null) {
+ Formule formule = (Formule) value;
+ c.setText(formule.getName());
+ }
+ return c;
+ }
+}
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputContentHandler.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputContentHandler.java 2015-05-18 09:52:01 UTC (rev 4226)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputContentHandler.java 2015-05-20 12:09:09 UTC (rev 4227)
@@ -48,7 +48,7 @@
protected void init(final T inputContentUI) {
this.inputContentUI = inputContentUI;
}
-
+
/**
* Action appelée lors du clic sur un layer (sensitivity).
*
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputOneEquationUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputOneEquationUI.jaxx 2015-05-18 09:52:01 UTC (rev 4226)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputOneEquationUI.jaxx 2015-05-20 12:09:09 UTC (rev 4227)
@@ -242,41 +242,30 @@
]]>
</script>
<JPanel id="body">
- <Table>
+ <Table insets="0">
<row>
<cell fill='horizontal' anchor='east'>
<JLabel text='{getText()}' enabled='{isActive()}'/>
</cell>
- <cell fill='horizontal' weightx='1.0'>
+ <cell fill='horizontal'>
<JComboBox id="formuleComboBox" onActionPerformed='formuleChanged()' enabled='{isActive()}'
genericType="fr.ifremer.isisfish.entities.Formule"
- renderer="{new fr.ifremer.isisfish.ui.input.renderer.FormuleComboRenderer()}" />
+ renderer="{new FormuleComboRenderer()}" />
</cell>
</row>
<row>
- <cell fill='both' weighty='1.0'>
- <Table>
- <row>
- <cell fill='horizontal'>
- <JButton text="isisfish.common.saveModel" onActionPerformed='saveModel()' enabled='{isActive() && formuleCategory != null}'/>
- </cell>
- </row>
- <row>
- <cell fill='horizontal'>
- <JButton text="isisfish.common.openEditor" onActionPerformed='openEditor()' enabled='{isActive() && clazz != null && formuleCategory != null}'/>
- </cell>
- </row>
- <row>
- <cell fill='horizontal' weighty='1.0'>
- <JPanel/>
- </cell>
- </row>
- </Table>
+ <cell fill='horizontal' anchor='north'>
+ <JButton text="isisfish.common.saveModel" onActionPerformed='saveModel()' enabled='{isActive() && formuleCategory != null}'/>
</cell>
- <cell fill='both' weightx='1.0' weighty='1.0'>
+ <cell fill='both' weightx='1.0' weighty='1.0' rows="2">
<org.nuiton.widget.editor.Editor id='editor' askIfNotSaved="false" enabled='{isActive()}'/>
</cell>
</row>
+ <row>
+ <cell fill='horizontal' anchor='north' weighty='1.0'>
+ <JButton text="isisfish.common.openEditor" onActionPerformed='openEditor()' enabled='{isActive() && clazz != null && formuleCategory != null}'/>
+ </cell>
+ </row>
</Table>
</JPanel>
</fr.ifremer.isisfish.ui.input.InputContentUI>
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputTabbedPaneListener.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputTabbedPaneListener.java 2015-05-18 09:52:01 UTC (rev 4226)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputTabbedPaneListener.java 2015-05-20 12:09:09 UTC (rev 4227)
@@ -25,7 +25,6 @@
package fr.ifremer.isisfish.ui.input;
-import javax.swing.JOptionPane;
import javax.swing.JTabbedPane;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
@@ -114,7 +113,7 @@
int response = saveVerifier.checkEdit();
- if (response == JOptionPane.CANCEL_OPTION) {
+ if (response == SaveVerifier.CANCEL_OPTION) {
exit = false;
}
return exit;
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/cell/CellHandler.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/cell/CellHandler.java 2015-05-18 09:52:01 UTC (rev 4226)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/cell/CellHandler.java 2015-05-20 12:09:09 UTC (rev 4227)
@@ -31,9 +31,6 @@
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
import com.bbn.openmap.event.SelectMouseMode;
import fr.ifremer.isisfish.entities.Cell;
@@ -49,9 +46,6 @@
*/
public class CellHandler extends InputContentHandler<CellUI> {
- /** Class logger. */
- private static final Log log = LogFactory.getLog(CellHandler.class);
-
protected boolean init;
protected void init(final CellUI cellUI) {
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/check/CheckResult.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/check/CheckResult.java 2015-05-18 09:52:01 UTC (rev 4226)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/check/CheckResult.java 2015-05-20 12:09:09 UTC (rev 4227)
@@ -5,7 +5,7 @@
* $Id$
* $HeadURL$
* %%
- * Copyright (C) 2002 - 2011 Ifremer, CodeLutin, Chatellier Eric
+ * Copyright (C) 2002 - 2015 Ifremer, CodeLutin, Chatellier Eric
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
@@ -48,9 +48,9 @@
protected Set<Object> order = new LinkedHashSet<Object>();
- protected Map<Object, List<String>> info = new HashMap<Object, List<String>>();
- protected Map<Object, List<String>> warning = new HashMap<Object, List<String>>();
- protected Map<Object, List<String>> error = new HashMap<Object, List<String>>();
+ protected Map<Object, List<String>> info = new HashMap<>();
+ protected Map<Object, List<String>> warning = new HashMap<>();
+ protected Map<Object, List<String>> error = new HashMap<>();
public StringBuffer getInfo() {
StringBuffer result = new StringBuffer();
@@ -187,7 +187,7 @@
order.add(o);
List<String> list = info.get(o);
if (list == null) {
- info.put(o, list = new LinkedList<String>());
+ info.put(o, list = new LinkedList<>());
}
list.add(message);
}
@@ -202,7 +202,7 @@
order.add(o);
List<String> list = warning.get(o);
if (list == null) {
- warning.put(o, list = new LinkedList<String>());
+ warning.put(o, list = new LinkedList<>());
}
list.add(message);
}
@@ -217,7 +217,7 @@
order.add(o);
List<String> list = error.get(o);
if (list == null) {
- error.put(o, list = new LinkedList<String>());
+ error.put(o, list = new LinkedList<>());
}
list.add(message);
}
Added: trunk/src/main/java/fr/ifremer/isisfish/ui/input/gear/GearHandler.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/gear/GearHandler.java (rev 0)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/gear/GearHandler.java 2015-05-20 12:09:09 UTC (rev 4227)
@@ -0,0 +1,60 @@
+/*
+ * #%L
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2015 Ifremer, Codelutin, Chatellier Eric
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+package fr.ifremer.isisfish.ui.input.gear;
+
+import static org.nuiton.i18n.I18n.n;
+import static org.nuiton.i18n.I18n.t;
+
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+
+import fr.ifremer.isisfish.ui.input.InputContentHandler;
+
+/**
+ * Gear handler.
+ */
+public class GearHandler extends InputContentHandler<GearUI> {
+
+ protected void init(final GearUI gearUI) {
+ super.init(gearUI);
+
+ gearUI.setButtonTitle(t("isisfish.input.continueMetiers"));
+ gearUI.setNextPath(n("isisfish.input.tree.metiers"));
+
+ gearUI.addPropertyChangeListener(GearUI.PROPERTY_BEAN, new PropertyChangeListener() {
+ public void propertyChange(PropertyChangeEvent evt) {
+ if (evt.getNewValue() == null) {
+
+ }
+ if (evt.getNewValue() != null) {
+ //getVerifier().addCurrentPanel(gearTabUI, selectivityUI);
+ }
+ }
+ });
+
+ // install change listener
+ // (depends on sensitivity can't be done on constructor)
+ gearUI.installChangeListener(gearUI.gearTab);
+ }
+}
Property changes on: trunk/src/main/java/fr/ifremer/isisfish/ui/input/gear/GearHandler.java
___________________________________________________________________
Added: svn:eol-style
+ native
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: trunk/src/main/java/fr/ifremer/isisfish/ui/input/gear/GearTabHandler.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/gear/GearTabHandler.java (rev 0)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/gear/GearTabHandler.java 2015-05-20 12:09:09 UTC (rev 4227)
@@ -0,0 +1,54 @@
+/*
+ * #%L
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2015 Ifremer, Codelutin, Chatellier Eric
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+package fr.ifremer.isisfish.ui.input.gear;
+
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+
+import fr.ifremer.isisfish.ui.input.InputContentHandler;
+
+/**
+ * Gear tab handler.
+ */
+public class GearTabHandler extends InputContentHandler<GearTabUI> {
+
+ protected void init(final GearTabUI gearTabUI) {
+ super.init(gearTabUI);
+
+ gearTabUI.addPropertyChangeListener(GearTabUI.PROPERTY_BEAN, new PropertyChangeListener() {
+ public void propertyChange(PropertyChangeEvent evt) {
+ if (evt.getNewValue() == null) {
+ gearTabUI.fieldGearName.setText("");
+ gearTabUI.fieldGearEffortUnit.setText("");
+ gearTabUI.fieldGearStandardisationFactor.setText("");
+ gearTabUI.fieldGearParamName.setText("");
+ gearTabUI.fieldGearComment.setText("");
+ }
+ if (evt.getNewValue() != null) {
+
+ }
+ }
+ });
+ }
+}
Property changes on: trunk/src/main/java/fr/ifremer/isisfish/ui/input/gear/GearTabHandler.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/gear/GearTabUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/gear/GearTabUI.jaxx 2015-05-18 09:52:01 UTC (rev 4226)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/gear/GearTabUI.jaxx 2015-05-20 12:09:09 UTC (rev 4227)
@@ -5,7 +5,7 @@
$Id$
$HeadURL$
%%
- Copyright (C) 2009 - 2011 Ifremer, Code Lutin, Chatellier Eric
+ Copyright (C) 2009 - 2015 Ifremer, Code Lutin, Chatellier Eric
%%
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as
@@ -27,11 +27,7 @@
<!-- bean property -->
<fr.ifremer.isisfish.entities.Gear id='bean' javaBean='null'/>
- <import>
- fr.ifremer.isisfish.entities.Gear;
- java.beans.PropertyChangeEvent;
- java.beans.PropertyChangeListener;
- </import>
+ <GearTabHandler id="handler" />
<BeanValidator id='validator' context="gear"
bean='{getBean()}' beanClass='fr.ifremer.isisfish.entities.Gear'
@@ -41,40 +37,11 @@
</BeanValidator>
<script><![CDATA[
-
-protected void $afterCompleteSetup() {
- addPropertyChangeListener(PROPERTY_BEAN, new PropertyChangeListener() {
- public void propertyChange(PropertyChangeEvent evt) {
- if (evt.getNewValue() == null) {
- fieldGearName.setText("");
- fieldGearEffortUnit.setText("");
- fieldGearStandardisationFactor.setText("");
- fieldGearParamName.setText("");
- fieldGearComment.setText("");
- }
- if (evt.getNewValue() != null) {
-
- }
- }
- });
-}
-
-/*public void refresh() {
- Gear gear = getSaveVerifier().getEntity(Gear.class);
-
- // add null before, for second to be considered as a changed event
- // otherwize, setBean has no effect
- setBean(null);
- setBean(gear);
-
- getVerifier().addCurrentPanel(rangeOfValues);
-
- // chatellier commented since number editor is not working
- //if (getBean() != null) {
- // fieldGearStandardisationFactor.init();
- //}
-}*/
+ protected void $afterCompleteSetup() {
+ handler.init(this);
+ }
]]></script>
+
<JPanel id="body">
<Table>
<row>
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/gear/GearUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/gear/GearUI.jaxx 2015-05-18 09:52:01 UTC (rev 4226)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/gear/GearUI.jaxx 2015-05-20 12:09:09 UTC (rev 4227)
@@ -26,50 +26,25 @@
<fr.ifremer.isisfish.entities.Gear id='bean' javaBean='null'/>
- <import>
- static org.nuiton.i18n.I18n.t
- static org.nuiton.i18n.I18n.n
- java.beans.PropertyChangeEvent;
- java.beans.PropertyChangeListener;
- </import>
+ <GearHandler id="handler" />
+
<script><![CDATA[
+ protected void $afterCompleteSetup() {
+ handler.init(this);
+ }
-protected void $afterCompleteSetup() {
- setButtonTitle(t("isisfish.input.continueMetiers"));
- setNextPath(n("isisfish.input.tree.metiers"));
+ @Override
+ public void setLayer(boolean active) {
+ super.setLayer(active);
+ gearTabUI.setLayer(active);
+ selectivityUI.setLayer(active);
+ }
- addPropertyChangeListener(PROPERTY_BEAN, new PropertyChangeListener() {
- public void propertyChange(PropertyChangeEvent evt) {
- if (evt.getNewValue() == null) {
-
- }
- if (evt.getNewValue() != null) {
- //getVerifier().addCurrentPanel(gearTabUI, selectivityUI);
- }
- }
- });
-
- // install change listener
- // (depends on sensitivity can't be done on constructor)
- installChangeListener(gearTab);
-}
-
-/*public void refresh() {
- //getVerifier().addCurrentPanel(gearTabUI, selectivityUI);
-}*/
-
-@Override
-public void setLayer(boolean active) {
- super.setLayer(active);
- gearTabUI.setLayer(active);
- selectivityUI.setLayer(active);
-}
-
-@Override
-public void resetChangeModel() {
- gearTabUI.resetChangeModel();
- selectivityUI.resetChangeModel();
-}
+ @Override
+ public void resetChangeModel() {
+ gearTabUI.resetChangeModel();
+ selectivityUI.resetChangeModel();
+ }
]]></script>
<JPanel id="body">
<JTabbedPane constraints='BorderLayout.CENTER' id="gearTab">
Added: trunk/src/main/java/fr/ifremer/isisfish/ui/input/gear/RangeOfValuesHandler.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/gear/RangeOfValuesHandler.java (rev 0)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/gear/RangeOfValuesHandler.java 2015-05-20 12:09:09 UTC (rev 4227)
@@ -0,0 +1,86 @@
+/*
+ * #%L
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2015 Ifremer, Codelutin, Chatellier Eric
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+package fr.ifremer.isisfish.ui.input.gear;
+
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import fr.ifremer.isisfish.types.RangeOfValues;
+import fr.ifremer.isisfish.ui.input.InputContentHandler;
+import fr.ifremer.isisfish.ui.models.common.GenericComboModel;
+
+/**
+ * RangeOfValues handler.
+ */
+public class RangeOfValuesHandler extends InputContentHandler<RangeOfValuesUI> {
+
+ /** Class logger. */
+ private static final Log log = LogFactory.getLog(RangeOfValuesHandler.class);
+
+ protected boolean init;
+
+ protected void init(final RangeOfValuesUI inputContentUI) {
+ super.init(inputContentUI);
+
+ inputContentUI.addPropertyChangeListener(RangeOfValuesUI.PROPERTY_BEAN, new PropertyChangeListener() {
+ public void propertyChange(PropertyChangeEvent evt) {
+
+ GenericComboModel<String> gearParamTypeModel = new GenericComboModel<>();
+ if (evt.getNewValue() == null) {
+ inputContentUI.fieldGearParamPossibleValue.setText("");
+ inputContentUI.fieldGearParamType.setSelectedItem(null);
+ inputContentUI.fieldGearParamType.setModel(gearParamTypeModel);
+ }
+ if (evt.getNewValue() != null) {
+ init = true;
+
+ List<String> values = new ArrayList<String>();
+ for (String value : RangeOfValues.getPossibleTypes()) {
+ values.add(value);
+ }
+ gearParamTypeModel.setElementList(values);
+
+ inputContentUI.fieldGearParamType.setModel(gearParamTypeModel);
+ if (inputContentUI.getBean().getPossibleValue() != null) {
+ inputContentUI.fieldGearParamType.setSelectedItem(inputContentUI.getBean().getPossibleValue().getType());
+ }
+
+ init = false;
+ }
+ }
+ });
+ }
+
+ protected void gearParamChanged() {
+ if (inputContentUI.fieldGearParamType.getSelectedItem() != null && !init) {
+ inputContentUI.getBean().setPossibleValue(new RangeOfValues(inputContentUI.fieldGearParamType.getSelectedItem().toString()
+ .concat("[" + inputContentUI.fieldGearParamPossibleValue.getText() + "]")));
+ }
+ }
+}
Property changes on: trunk/src/main/java/fr/ifremer/isisfish/ui/input/gear/RangeOfValuesHandler.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/gear/RangeOfValuesUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/gear/RangeOfValuesUI.jaxx 2015-05-18 09:52:01 UTC (rev 4226)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/gear/RangeOfValuesUI.jaxx 2015-05-20 12:09:09 UTC (rev 4227)
@@ -27,55 +27,12 @@
<!-- bean property -->
<fr.ifremer.isisfish.entities.Gear id='bean' javaBean='null'/>
- <import>
- fr.ifremer.isisfish.types.RangeOfValues
- fr.ifremer.isisfish.entities.Gear
- java.beans.PropertyChangeEvent;
- java.beans.PropertyChangeListener
- java.util.List
- java.util.ArrayList
- fr.ifremer.isisfish.ui.models.common.GenericComboModel
- </import>
+ <RangeOfValuesHandler id="handler" />
<script><![CDATA[
-
-boolean init = false;
-
-protected void $afterCompleteSetup() {
- addPropertyChangeListener(PROPERTY_BEAN, new PropertyChangeListener() {
- public void propertyChange(PropertyChangeEvent evt) {
-
- GenericComboModel<String> gearParamTypeModel = new GenericComboModel<>();
- if (evt.getNewValue() == null) {
- fieldGearParamPossibleValue.setText("");
- fieldGearParamType.setSelectedItem(null);
- fieldGearParamType.setModel(gearParamTypeModel);
- }
- if (evt.getNewValue() != null) {
- init = true;
-
- List<String> values = new ArrayList<String>();
- for (String value : RangeOfValues.getPossibleTypes()) {
- values.add(value);
- }
- gearParamTypeModel.setElementList(values);
-
- fieldGearParamType.setModel(gearParamTypeModel);
- if (getBean().getPossibleValue() != null) {
- fieldGearParamType.setSelectedItem(getBean().getPossibleValue().getType());
- }
-
- init = false;
- }
- }
- });
-}
-
-protected void gearParamChanged() {
- if (fieldGearParamType.getSelectedItem() != null && !init) {
- getBean().setPossibleValue(new RangeOfValues(fieldGearParamType.getSelectedItem().toString().concat("[" + fieldGearParamPossibleValue.getText() + "]")));
+ protected void $afterCompleteSetup() {
+ handler.init(this);
}
-}
]]></script>
<JPanel id='body'>
<Table>
@@ -83,11 +40,11 @@
<cell fill='horizontal' weightx='0.5'>
<JComboBox id="fieldGearParamType"
genericType="String"
- onItemStateChanged='gearParamChanged()' enabled='{isActive()}'/>
+ onItemStateChanged='handler.gearParamChanged()' enabled='{isActive()}'/>
</cell>
<cell fill='horizontal' weightx='0.5'>
<JTextField id="fieldGearParamPossibleValue" text='{getBean().getPossibleValue() == null ? "" : getBean().getPossibleValue().getValues()}'
- onKeyReleased='gearParamChanged()' enabled='{isActive()}'/>
+ onKeyReleased='handler.gearParamChanged()' enabled='{isActive()}'/>
</cell>
</row>
</Table>
Added: trunk/src/main/java/fr/ifremer/isisfish/ui/input/gear/SelectivityHandler.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/gear/SelectivityHandler.java (rev 0)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/gear/SelectivityHandler.java 2015-05-20 12:09:09 UTC (rev 4227)
@@ -0,0 +1,142 @@
+/*
+ * #%L
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2015 Ifremer, Codelutin, Chatellier Eric
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+package fr.ifremer.isisfish.ui.input.gear;
+
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import fr.ifremer.isisfish.entities.Equation;
+import fr.ifremer.isisfish.entities.Population;
+import fr.ifremer.isisfish.entities.Selectivity;
+import fr.ifremer.isisfish.entities.Species;
+import fr.ifremer.isisfish.ui.input.InputContentHandler;
+import fr.ifremer.isisfish.ui.models.common.GenericComboModel;
+import fr.ifremer.isisfish.ui.widget.editor.EquationTableEditor;
+
+/**
+ * Selectivity handler.
+ */
+public class SelectivityHandler extends InputContentHandler<SelectivityUI> {
+
+ /** Class logger. */
+ private static final Log log = LogFactory.getLog(SelectivityHandler.class);
+
+ protected void init(final SelectivityUI selectivityUI) {
+ super.init(selectivityUI);
+
+ selectivityUI.addPropertyChangeListener(SelectivityUI.PROPERTY_BEAN, new PropertyChangeListener() {
+ public void propertyChange(PropertyChangeEvent evt) {
+ if (evt.getNewValue() == null) {
+ selectivityUI.setPopulation(null);
+ selectivityUI.selectivityTable.setModel(new GearPopulationSelectivityModel());
+ }
+ if (evt.getNewValue() != null) {
+ refresh();
+ }
+ }
+ });
+ }
+
+ public void refresh() {
+
+ //Gear gear = (Gear)inputContentUI.getSaveVerifier().getEntity(Gear.class);
+
+ // add null before, for second to be considered as a changed event
+ // otherwize, setBean has no effect
+ //setBean(null);
+ //setBean(gear);
+
+ if (inputContentUI.getBean() != null) {
+ setSelectivityTableModel();
+ inputContentUI.fieldSelectivityPopulation.setModel(getSelectivityPopulationModel());
+ }
+ }
+
+ protected void setSelectivityTableModel() {
+
+ List<Selectivity> selectivitiesList = new ArrayList<Selectivity>();
+
+ // set model even if no selectivity
+ // to clear data
+ if (inputContentUI.getBean().getPopulationSelectivity() != null) {
+ // move collection to list
+ // and add all entity to verifier
+ for (Selectivity oneSelectivity : inputContentUI.getBean().getPopulationSelectivity()) {
+ inputContentUI.getSaveVerifier().addCurrentEntity(oneSelectivity);
+ selectivitiesList.add(oneSelectivity);
+
+ // hack to enable save button :(
+ oneSelectivity.addPropertyChangeListener(new PropertyChangeListener() {
+ public void propertyChange(PropertyChangeEvent evt) {
+ inputContentUI.changeModel.setStayChanged(true);
+ }
+ });
+ }
+ }
+
+ // set table model
+ GearPopulationSelectivityModel model = new GearPopulationSelectivityModel(selectivitiesList);
+ inputContentUI.selectivityTable.setModel(model);
+ inputContentUI.selectivityTable.setDefaultRenderer(Equation.class, model);
+ inputContentUI.selectivityTable.setDefaultEditor(Equation.class, new EquationTableEditor());
+ }
+
+ protected void addSelectivity() {
+ inputContentUI.getAction().addSelectivity(inputContentUI.getPopulation(),
+ inputContentUI.selectivityEquation.getEditor().getText(), inputContentUI.getBean());
+ setSelectivityTableModel();
+ }
+
+ protected void removeSelectivity() {
+ GearPopulationSelectivityModel model = (GearPopulationSelectivityModel)inputContentUI.selectivityTable.getModel();
+ Selectivity selectedSelectivity = model.getSelectivities().get(inputContentUI.selectivityTable.getSelectedRow());
+ inputContentUI.getAction().removeSelectivity(inputContentUI.getBean(), selectedSelectivity);
+ inputContentUI.getSaveVerifier().removeCurrentEntity(selectedSelectivity.getTopiaId());
+ setSelectivityTableModel();
+ inputContentUI.removeSelectivityButton.setEnabled(false);
+ }
+
+ protected GenericComboModel<Population> getSelectivityPopulationModel() {
+ List<Species> species = inputContentUI.getFisheryRegion().getSpecies();
+ List<Population> populations = new ArrayList<>();
+ if (species != null) {
+ for (Species s : species) {
+ if (s.getPopulation() != null) {
+ populations.addAll(s.getPopulation());
+ }
+ }
+ }
+ GenericComboModel<Population> selectivityPopulationModel = new GenericComboModel<>(populations);
+ return selectivityPopulationModel;
+ }
+
+ protected void selectivityChanged() {
+ inputContentUI.setPopulation((Population)inputContentUI.fieldSelectivityPopulation.getSelectedItem());
+ }
+}
Property changes on: trunk/src/main/java/fr/ifremer/isisfish/ui/input/gear/SelectivityHandler.java
___________________________________________________________________
Added: svn:eol-style
+ native
Added: svn:keywords
+ Author Date Id Revision HeadURL
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/gear/SelectivityUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/gear/SelectivityUI.jaxx 2015-05-18 09:52:01 UTC (rev 4226)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/gear/SelectivityUI.jaxx 2015-05-20 12:09:09 UTC (rev 4227)
@@ -29,6 +29,8 @@
<fr.ifremer.isisfish.entities.Population id='population' javaBean='null'/>
+ <SelectivityHandler id="handler" />
+
<BeanValidator id='validator' context="selectivity"
bean='{getBean()}' beanClass='fr.ifremer.isisfish.entities.Gear'
uiClass="jaxx.runtime.validator.swing.ui.ImageValidationUI">
@@ -37,116 +39,17 @@
<fr.ifremer.isisfish.ui.input.ChangeModel id="changeModel" changed="{validator.isChanged()}"
valid="{validator.isValid()}" />
- <import>
- fr.ifremer.isisfish.entities.Equation
- fr.ifremer.isisfish.entities.Gear
- fr.ifremer.isisfish.entities.Population
- fr.ifremer.isisfish.entities.Selectivity
- fr.ifremer.isisfish.entities.Species
- fr.ifremer.isisfish.ui.models.common.GenericComboModel
- fr.ifremer.isisfish.ui.widget.editor.EquationTableEditor
- java.beans.PropertyChangeEvent
- java.beans.PropertyChangeListener
- java.util.ArrayList
- javax.swing.DefaultComboBoxModel
- </import>
-
<script><![CDATA[
-protected void $afterCompleteSetup() {
- addPropertyChangeListener(PROPERTY_BEAN, new PropertyChangeListener() {
- public void propertyChange(PropertyChangeEvent evt) {
- if (evt.getNewValue() == null) {
- setPopulation(null);
- selectivityTable.setModel(new GearPopulationSelectivityModel());
- }
- if (evt.getNewValue() != null) {
- refresh();
- }
- }
- });
-}
-
-@Override
-public void resetChangeModel() {
- changeModel.setStayChanged(false);
-}
-
-public void refresh() {
-
- Gear gear = (Gear)getSaveVerifier().getEntity(Gear.class);
-
- // add null before, for second to be considered as a changed event
- // otherwize, setBean has no effect
- //setBean(null);
- //setBean(gear);
-
- if (getBean() != null) {
- setSelectivityTableModel();
- fieldSelectivityPopulation.setModel(getSelectivityPopulationModel());
+ protected void $afterCompleteSetup() {
+ handler.init(this);
}
-}
-protected void setSelectivityTableModel() {
-
- List<Selectivity> selectivitiesList = new ArrayList<Selectivity>();
-
- // set model even if no selectivity
- // to clear data
- if (getBean().getPopulationSelectivity() != null) {
- // move collection to list
- // and add all entity to verifier
- for (Selectivity oneSelectivity : getBean().getPopulationSelectivity()) {
- getSaveVerifier().addCurrentEntity(oneSelectivity);
- selectivitiesList.add(oneSelectivity);
-
- // hack to enable save button :(
- oneSelectivity.addPropertyChangeListener(new PropertyChangeListener() {
- public void propertyChange(PropertyChangeEvent evt) {
- changeModel.setStayChanged(true);
- }
- });
- }
+ @Override
+ public void resetChangeModel() {
+ changeModel.setStayChanged(false);
}
-
- // set table model
- GearPopulationSelectivityModel model = new GearPopulationSelectivityModel(selectivitiesList);
- selectivityTable.setModel(model);
- selectivityTable.setDefaultRenderer(Equation.class, model);
- selectivityTable.setDefaultEditor(Equation.class, new EquationTableEditor());
-}
-
-protected void addSelectivity() {
- getAction().addSelectivity(getPopulation(), selectivityEquation.getEditor().getText(), getBean());
- setSelectivityTableModel();
-}
-
-protected void removeSelectivity() {
- GearPopulationSelectivityModel model = (GearPopulationSelectivityModel)selectivityTable.getModel();
- Selectivity selectedSelectivity = model.getSelectivities().get(selectivityTable.getSelectedRow());
- getAction().removeSelectivity(getBean(), selectedSelectivity);
- getSaveVerifier().removeCurrentEntity(selectedSelectivity.getTopiaId());
- setSelectivityTableModel();
- removeSelectivityButton.setEnabled(false);
-}
-
-protected DefaultComboBoxModel getSelectivityPopulationModel() {
- List<Species> species = getFisheryRegion().getSpecies();
- List<Population> populations = new ArrayList<Population>();
- if (species != null) {
- for (Species s : species) {
- if (s.getPopulation() != null) {
- populations.addAll(s.getPopulation());
- }
- }
- }
- GenericComboModel<Population> selectivityPopulationModel = new GenericComboModel<>(populations);
- return selectivityPopulationModel;
-}
-
-protected void selectivityChanged() {
- setPopulation((Population)fieldSelectivityPopulation.getSelectedItem());
-}
]]></script>
+
<JPanel id='body'>
<Table>
<row>
@@ -157,7 +60,7 @@
<JLabel text="isisfish.selectivity.selectPopulation" enabled='{isActive()}' decorator='boxed' />
</cell>
<cell fill='horizontal' weightx='1.0'>
- <JComboBox id="fieldSelectivityPopulation" onItemStateChanged='selectivityChanged()'
+ <JComboBox id="fieldSelectivityPopulation" onItemStateChanged='handler.selectivityChanged()'
genericType="fr.ifremer.isisfish.entities.Population"
enabled='{isActive()}' decorator='boxed' />
</cell>
@@ -173,7 +76,7 @@
</row>
<row>
<cell columns='2' fill='horizontal' weightx='1.0'>
- <JButton id="addSelectivityButton" text="isisfish.common.add" onActionPerformed='addSelectivity()'
+ <JButton id="addSelectivityButton" text="isisfish.common.add" onActionPerformed='handler.addSelectivity()'
enabled='{getPopulation() != null}' decorator='boxed' />
</cell>
</row>
@@ -189,7 +92,7 @@
</row>
<row>
<cell columns='2' fill='horizontal' weightx='1.0'>
- <JButton id="removeSelectivityButton" text="isisfish.common.remove" onActionPerformed='removeSelectivity()'
+ <JButton id="removeSelectivityButton" text="isisfish.common.remove" onActionPerformed='handler.removeSelectivity()'
enabled='false' decorator='boxed' />
</cell>
</row>
Added: trunk/src/main/java/fr/ifremer/isisfish/ui/input/metier/MetierHandler.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/metier/MetierHandler.java (rev 0)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/metier/MetierHandler.java 2015-05-20 12:09:09 UTC (rev 4227)
@@ -0,0 +1,46 @@
+/*
+ * #%L
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2015 Ifremer, Codelutin, Chatellier Eric
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+package fr.ifremer.isisfish.ui.input.metier;
+
+import static org.nuiton.i18n.I18n.n;
+import static org.nuiton.i18n.I18n.t;
+
+import fr.ifremer.isisfish.ui.input.InputContentHandler;
+
+/**
+ * Metier handler.
+ */
+public class MetierHandler extends InputContentHandler<MetierUI> {
+
+ protected void init(final MetierUI metierUI) {
+ super.init(metierUI);
+
+ metierUI.setButtonTitle(t("isisfish.input.continueTripTypes"));
+ metierUI.setNextPath(n("isisfish.input.tree.triptypes"));
+
+ // install change listener
+ // (depends on sensitivity can't be done on constructor)
+ metierUI.installChangeListener(metierUI.metierTab);
+ }
+}
Property changes on: trunk/src/main/java/fr/ifremer/isisfish/ui/input/metier/MetierHandler.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Copied: trunk/src/main/java/fr/ifremer/isisfish/ui/input/metier/MetierSeasonInfoComboRenderer.java (from rev 4226, trunk/src/main/java/fr/ifremer/isisfish/ui/input/renderer/MetierSeasonInfoComboRenderer.java)
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/metier/MetierSeasonInfoComboRenderer.java (rev 0)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/metier/MetierSeasonInfoComboRenderer.java 2015-05-20 12:09:09 UTC (rev 4227)
@@ -0,0 +1,70 @@
+/*
+ * #%L
+ * IsisFish
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2009 - 2010 Ifremer, CodeLutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+package fr.ifremer.isisfish.ui.input.metier;
+
+import java.awt.Component;
+
+import javax.swing.DefaultListCellRenderer;
+import javax.swing.JLabel;
+import javax.swing.JList;
+
+import fr.ifremer.isisfish.entities.MetierSeasonInfo;
+
+/**
+ * Renderer pour la combo des {@link MetierSeasonInfo}.
+ *
+ * @author chatellier
+ * @version $Revision$
+ *
+ * Last update : $Date$
+ * By : $Author$
+ */
+public class MetierSeasonInfoComboRenderer extends DefaultListCellRenderer {
+
+ /** serialVersionUID. */
+ private static final long serialVersionUID = -8277883340386163087L;
+
+ /*
+ * @see javax.swing.ListCellRenderer#getListCellRendererComponent(javax.swing.JList, java.lang.Object, int, boolean, boolean)
+ */
+ @Override
+ public Component getListCellRendererComponent(JList<?> list, Object value,
+ int index, boolean isSelected, boolean cellHasFocus) {
+
+ // this must be used to have alterned highlight rows and default
+ // selection color
+ JLabel c = (JLabel) super.getListCellRendererComponent(list, value,
+ index, isSelected, cellHasFocus);
+
+ MetierSeasonInfo metierSeasonInfo = (MetierSeasonInfo) value;
+
+ // there is no default selection
+ if (value != null) {
+ c.setText(metierSeasonInfo.getFirstMonth() + "-" + metierSeasonInfo.getLastMonth());
+ }
+ return c;
+ }
+}
Added: trunk/src/main/java/fr/ifremer/isisfish/ui/input/metier/MetierSeasonInfoSpeciesHandler.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/metier/MetierSeasonInfoSpeciesHandler.java (rev 0)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/metier/MetierSeasonInfoSpeciesHandler.java 2015-05-20 12:09:09 UTC (rev 4227)
@@ -0,0 +1,143 @@
+/*
+ * #%L
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2015 Ifremer, Codelutin, Chatellier Eric
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+package fr.ifremer.isisfish.ui.input.metier;
+
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.util.ArrayList;
+import java.util.List;
+
+import fr.ifremer.isisfish.entities.Equation;
+import fr.ifremer.isisfish.entities.MetierSeasonInfo;
+import fr.ifremer.isisfish.entities.Species;
+import fr.ifremer.isisfish.entities.TargetSpecies;
+import fr.ifremer.isisfish.ui.input.InputAction;
+import fr.ifremer.isisfish.ui.input.InputContentHandler;
+import fr.ifremer.isisfish.ui.models.common.GenericComboModel;
+import fr.ifremer.isisfish.ui.widget.editor.EquationTableEditor;
+
+/**
+ * Metier tab handler.
+ */
+public class MetierSeasonInfoSpeciesHandler extends InputContentHandler<MetierSeasonInfoSpeciesUI> {
+
+ protected void init(final MetierSeasonInfoSpeciesUI inputContentUI) {
+ super.init(inputContentUI);
+
+ inputContentUI.addPropertyChangeListener(MetierSeasonInfoSpeciesUI.PROPERTY_BEAN, new PropertyChangeListener() {
+ public void propertyChange(PropertyChangeEvent evt) {
+ setSeasonModel();
+ inputContentUI.setSpecies(null);
+ inputContentUI.setMetierSeasonInfo(null);
+ setTargetSpeciesModel();
+ setTableTargetSpeciesModel();
+ }
+ });
+ }
+
+ protected void setSeasonModel() {
+ List<MetierSeasonInfo> metierSeasonInfo = null;
+
+ if (inputContentUI.getBean() != null) {
+ metierSeasonInfo = inputContentUI.getBean().getMetierSeasonInfo();
+ }
+ GenericComboModel<MetierSeasonInfo> seasonModel = new GenericComboModel<>(metierSeasonInfo);
+ inputContentUI.fieldMetierSeasonInfo.setModel(seasonModel);
+ }
+
+ protected void metierSeasonInfoChanged() {
+ MetierSeasonInfo selectedMSI = (MetierSeasonInfo)inputContentUI.fieldMetierSeasonInfo.getSelectedItem();
+ inputContentUI.setMetierSeasonInfo(selectedMSI);
+ if (selectedMSI != null) {
+ inputContentUI.getSaveVerifier().addCurrentEntity(inputContentUI.getMetierSeasonInfo());
+ setTableTargetSpeciesModel();
+ }
+ }
+
+ protected void setTargetSpeciesModel() {
+ List<Species> species = inputContentUI.getFisheryRegion().getSpecies();
+ GenericComboModel<Species> fieldTargetSpeciesModel = new GenericComboModel<>(species);
+ inputContentUI.fieldTargetSpecies.setModel(fieldTargetSpeciesModel);
+ }
+
+ protected void speciesChanged() {
+ Species species = (Species)inputContentUI.fieldTargetSpecies.getSelectedItem();
+ inputContentUI.setSpecies(species);
+ }
+
+ protected void setTableTargetSpeciesModel() {
+ List<TargetSpecies> targetSpecies = new ArrayList<>();
+
+ if (inputContentUI.getBean() != null && inputContentUI.getMetierSeasonInfo() != null) {
+ // SpeciesTargetSpecies can be null durring region creation
+ if (inputContentUI.getMetierSeasonInfo().getSpeciesTargetSpecies() != null) {
+ // move collection to list
+ // and add all entity to verifier
+ for (TargetSpecies oneTargetSpecies : inputContentUI.getMetierSeasonInfo().getSpeciesTargetSpecies()) {
+ targetSpecies.add(oneTargetSpecies);
+ inputContentUI.getSaveVerifier().addCurrentEntity(oneTargetSpecies);
+ oneTargetSpecies.addPropertyChangeListener(new PropertyChangeListener() {
+ public void propertyChange(PropertyChangeEvent evt) {
+ inputContentUI.changeModel.setStayChanged(true);
+ }
+ });
+ }
+ }
+ }
+
+ // set table model
+ MetierSeasonInfoTargetSpeciesTableModel model = new MetierSeasonInfoTargetSpeciesTableModel(targetSpecies);
+ inputContentUI.tableTargetSpecies.setModel(model);
+ inputContentUI.tableTargetSpecies.setDefaultRenderer(Equation.class, model);
+ inputContentUI.tableTargetSpecies.setDefaultEditor(Equation.class, new EquationTableEditor());
+ }
+
+ protected void add() {
+ Species selectedSpecies = (Species)inputContentUI.fieldTargetSpecies.getSelectedItem();
+ if (selectedSpecies != null) {
+ // il n'y en a pas a la creation de la base
+ //Formule selectedFormule = (Formule)targetFactor.getFormuleComboBox().getSelectedItem();
+ inputContentUI.getContextValue(InputAction.class).addTargetSpecies(
+ inputContentUI.getBean(),
+ inputContentUI.getMetierSeasonInfo(),
+ selectedSpecies,
+ inputContentUI.targetFactor.getEditor().getText(),
+ inputContentUI.fieldPrimaryCatch.isSelected());
+ setTableTargetSpeciesModel();
+ }
+ }
+
+ protected void remove() {
+ // TODO change delete selected truc from model
+ Object[] targetSpecies = inputContentUI.getMetierSeasonInfo().getSpeciesTargetSpecies().toArray();
+
+ Object o = targetSpecies[inputContentUI.tableTargetSpecies.getSelectedRow()];
+ if (o != null) {
+ TargetSpecies ts = (TargetSpecies)o;
+ inputContentUI.getAction().removeTargetSpecies(inputContentUI.getMetierSeasonInfo(), ts);
+ inputContentUI.getSaveVerifier().removeCurrentEntity(ts.getTopiaId());
+ setTableTargetSpeciesModel();
+ }
+ }
+}
Property changes on: trunk/src/main/java/fr/ifremer/isisfish/ui/input/metier/MetierSeasonInfoSpeciesHandler.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/metier/MetierSeasonInfoSpeciesUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/metier/MetierSeasonInfoSpeciesUI.jaxx 2015-05-18 09:52:01 UTC (rev 4226)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/metier/MetierSeasonInfoSpeciesUI.jaxx 2015-05-20 12:09:09 UTC (rev 4227)
@@ -31,22 +31,7 @@
<fr.ifremer.isisfish.entities.Species id='species' javaBean='null'/>
- <import>
- fr.ifremer.isisfish.entities.MetierSeasonInfo
- fr.ifremer.isisfish.ui.models.common.GenericListModel
- fr.ifremer.isisfish.ui.models.common.GenericComboModel
- fr.ifremer.isisfish.entities.Equation
- fr.ifremer.isisfish.entities.Metier
- fr.ifremer.isisfish.entities.Species
- fr.ifremer.isisfish.entities.TargetSpecies
- fr.ifremer.isisfish.ui.widget.editor.EquationTableEditor
- java.beans.PropertyChangeEvent
- java.beans.PropertyChangeListener
- java.util.ArrayList
- java.util.List
- java.awt.Dimension
- fr.ifremer.isisfish.ui.input.InputAction
- </import>
+ <MetierSeasonInfoSpeciesHandler id="handler" />
<BeanValidator id='validator' context="metier"
bean='{getMetierSeasonInfo()}' beanClass='fr.ifremer.isisfish.entities.MetierSeasonInfo'
@@ -56,110 +41,21 @@
<fr.ifremer.isisfish.ui.input.ChangeModel id="changeModel" changed="{validator.isChanged()}"
valid="{validator.isValid()}" />
- <script><![CDATA[
+ <import>
+ java.awt.Dimension
+ </import>
-protected void $afterCompleteSetup() {
- addPropertyChangeListener(PROPERTY_BEAN, new PropertyChangeListener() {
- public void propertyChange(PropertyChangeEvent evt) {
- setSeasonModel();
- setSpecies(null);
- setMetierSeasonInfo(null);
- setTargetSpeciesModel();
- setTableTargetSpeciesModel();
- }
- });
-}
-
-@Override
-public void resetChangeModel() {
- changeModel.setStayChanged(false);
-}
-
-protected void setSeasonModel() {
- List<MetierSeasonInfo> metierSeasonInfo = null;
-
- if (getBean() != null) {
- metierSeasonInfo = getBean().getMetierSeasonInfo();
+ <script><![CDATA[
+ protected void $afterCompleteSetup() {
+ handler.init(this);
}
- GenericComboModel<MetierSeasonInfo> seasonModel = new GenericComboModel<>(metierSeasonInfo);
- fieldMetierSeasonInfo.setModel(seasonModel);
-}
-protected void metierSeasonInfoChanged() {
- MetierSeasonInfo selectedMSI = (MetierSeasonInfo)fieldMetierSeasonInfo.getSelectedItem();
- setMetierSeasonInfo(selectedMSI);
- if (selectedMSI != null) {
- getSaveVerifier().addCurrentEntity(getMetierSeasonInfo());
- setTableTargetSpeciesModel();
+ @Override
+ public void resetChangeModel() {
+ changeModel.setStayChanged(false);
}
-}
-
-protected void setTargetSpeciesModel() {
- List<Species> species = getFisheryRegion().getSpecies();
- GenericComboModel<Species> fieldTargetSpeciesModel = new GenericComboModel<>(species);
- fieldTargetSpecies.setModel(fieldTargetSpeciesModel);
-}
-
-protected void speciesChanged() {
- Species species = (Species)fieldTargetSpecies.getSelectedItem();
- setSpecies(species);
-}
-
-protected void setTableTargetSpeciesModel() {
- List<TargetSpecies> targetSpecies = new ArrayList<TargetSpecies>();
-
- if (getBean() != null && getMetierSeasonInfo() != null) {
- // SpeciesTargetSpecies can be null durring region creation
- if (getMetierSeasonInfo().getSpeciesTargetSpecies() != null) {
- // move collection to list
- // and add all entity to verifier
- for (TargetSpecies oneTargetSpecies : getMetierSeasonInfo().getSpeciesTargetSpecies()) {
- targetSpecies.add(oneTargetSpecies);
- getSaveVerifier().addCurrentEntity(oneTargetSpecies);
- oneTargetSpecies.addPropertyChangeListener(new PropertyChangeListener() {
- public void propertyChange(PropertyChangeEvent evt) {
- changeModel.setStayChanged(true);
- }
- });
- }
- }
- }
-
- // set table model
- MetierSeasonInfoTargetSpeciesTableModel model = new MetierSeasonInfoTargetSpeciesTableModel(targetSpecies);
- tableTargetSpecies.setModel(model);
- tableTargetSpecies.setDefaultRenderer(Equation.class, model);
- tableTargetSpecies.setDefaultEditor(Equation.class, new EquationTableEditor());
-}
-
-protected void add() {
- Species selectedSpecies = (Species)fieldTargetSpecies.getSelectedItem();
- if (selectedSpecies != null) {
- // il n'y en a pas a la creation de la base
- //Formule selectedFormule = (Formule)targetFactor.getFormuleComboBox().getSelectedItem();
- getContextValue(InputAction.class).addTargetSpecies(
- getBean(),
- getMetierSeasonInfo(),
- selectedSpecies,
- targetFactor.getEditor().getText(),
- fieldPrimaryCatch.isSelected());
- setTableTargetSpeciesModel();
- }
-}
-
-protected void remove() {
- // TODO change delete selected truc from model
- Object[] targetSpecies = getMetierSeasonInfo().getSpeciesTargetSpecies().toArray();
-
- Object o = targetSpecies[tableTargetSpecies.getSelectedRow()];
- if (o != null) {
- TargetSpecies ts = (TargetSpecies)o;
- getAction().removeTargetSpecies(getMetierSeasonInfo(), ts);
- getSaveVerifier().removeCurrentEntity(ts.getTopiaId());
- setTableTargetSpeciesModel();
- }
-}
]]></script>
+
<JPanel id="body">
<Table>
<row>
@@ -170,9 +66,9 @@
<JLabel text="isisfish.metierSeasonInfoSpecies.selectSeason" enabled='{isActive()}'/>
</cell>
<cell fill='horizontal' weightx='1.0'>
- <JComboBox id="fieldMetierSeasonInfo" onItemStateChanged='metierSeasonInfoChanged()'
+ <JComboBox id="fieldMetierSeasonInfo" onItemStateChanged='handler.metierSeasonInfoChanged()'
genericType="fr.ifremer.isisfish.entities.MetierSeasonInfo"
- renderer="{new fr.ifremer.isisfish.ui.input.renderer.MetierSeasonInfoComboRenderer()}"
+ renderer="{new MetierSeasonInfoComboRenderer()}"
enabled='{isActive() && (isSensitivity() || !changeModel.isChanged() ) }'/>
</cell>
</row>
@@ -182,7 +78,7 @@
enabled='{getMetierSeasonInfo() != null}' decorator='boxed'/>
</cell>
<cell fill='horizontal' weightx='1.0'>
- <JComboBox id="fieldTargetSpecies" onItemStateChanged='speciesChanged()'
+ <JComboBox id="fieldTargetSpecies" onItemStateChanged='handler.speciesChanged()'
genericType="fr.ifremer.isisfish.entities.Species"
enabled='{getMetierSeasonInfo() != null}' decorator='boxed'/>
</cell>
@@ -208,7 +104,7 @@
</row>
<row>
<cell columns='2' fill='horizontal' weightx='1.0'>
- <JButton id="add" text="isisfish.common.add" onActionPerformed='add()'
+ <JButton id="add" text="isisfish.common.add" onActionPerformed='handler.add()'
enabled='{getMetierSeasonInfo() != null && getSpecies() != null}' decorator='boxed'/>
</cell>
</row>
@@ -225,7 +121,7 @@
<row>
<cell columns='2' fill='horizontal' weightx='1.0'>
<JButton id="remove" text="isisfish.common.remove"
- onActionPerformed='remove()' enabled='false' decorator='boxed'/>
+ onActionPerformed='handler.remove()' enabled='false' decorator='boxed'/>
</cell>
</row>
</Table>
Added: trunk/src/main/java/fr/ifremer/isisfish/ui/input/metier/MetierSeasonInfoZoneHandler.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/metier/MetierSeasonInfoZoneHandler.java (rev 0)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/metier/MetierSeasonInfoZoneHandler.java 2015-05-20 12:09:09 UTC (rev 4227)
@@ -0,0 +1,211 @@
+/*
+ * #%L
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2015 Ifremer, Codelutin, Chatellier Eric
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+package fr.ifremer.isisfish.ui.input.metier;
+
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.swing.event.ListSelectionListener;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import fr.ifremer.isisfish.entities.MetierSeasonInfo;
+import fr.ifremer.isisfish.entities.Zone;
+import fr.ifremer.isisfish.types.Month;
+import fr.ifremer.isisfish.ui.input.InputAction;
+import fr.ifremer.isisfish.ui.input.InputContentHandler;
+import fr.ifremer.isisfish.ui.models.common.GenericComboModel;
+import fr.ifremer.isisfish.ui.models.common.GenericListModel;
+import fr.ifremer.isisfish.ui.widget.Interval;
+
+/**
+ * Metier tab handler.
+ */
+public class MetierSeasonInfoZoneHandler extends InputContentHandler<MetierSeasonInfoZoneUI> {
+
+ /** Class logger. */
+ private static final Log log = LogFactory.getLog(MetierSeasonInfoZoneHandler.class);
+
+ protected Interval interval = null;
+ protected boolean init = false;
+
+ protected void init(final MetierSeasonInfoZoneUI inputContentUI) {
+ super.init(inputContentUI);
+
+ /*
+ * Don't add both in same listener.
+ * When first is set, last value from getPopulationSeasonInfo()
+ * is erased by interval.getLast() default value.
+ */
+ inputContentUI.ip.addPropertyChangeListener("first", new PropertyChangeListener() {
+ @Override
+ public void propertyChange(PropertyChangeEvent evt) {
+ if (inputContentUI.getMetierSeasonInfo() != null) {
+ inputContentUI.getMetierSeasonInfo().setFirstMonth(new Month(interval.getFirst()));
+ }
+ }
+ });
+ inputContentUI.ip.addPropertyChangeListener("last", new PropertyChangeListener() {
+ @Override
+ public void propertyChange(PropertyChangeEvent evt) {
+ if (inputContentUI.getMetierSeasonInfo() != null) {
+ inputContentUI.getMetierSeasonInfo().setLastMonth(new Month(interval.getLast()));
+ }
+ }
+ });
+
+ inputContentUI.addPropertyChangeListener(MetierSeasonInfoZoneUI.PROPERTY_BEAN, new PropertyChangeListener() {
+ public void propertyChange(PropertyChangeEvent evt) {
+ if (evt.getNewValue() == null) {
+
+ }
+ if (evt.getNewValue() != null) {
+ refresh();
+ }
+ }
+ });
+ }
+
+ protected void save() {
+ inputContentUI.getSaveVerifier().save();
+ setMetierSeasonInfoCombo();
+ }
+
+ protected void create() {
+ MetierSeasonInfo newMSI = inputContentUI.getContextValue(InputAction.class).createMetierSeasonInfo(inputContentUI.getBean());
+ inputContentUI.setMetierSeasonInfo(newMSI);
+ setMetierSeasonInfoCombo();
+ }
+
+ protected void delete() {
+ inputContentUI.getContextValue(InputAction.class).removeMetierSeasonInfo(inputContentUI.getBean(), inputContentUI.getMetierSeasonInfo());
+ inputContentUI.setMetierSeasonInfo(null);
+ setMetierSeasonInfoCombo();
+ }
+
+ public void refresh() {
+
+ inputContentUI.setMetierSeasonInfo(null);
+
+ if (inputContentUI.getBean() != null) {
+ // Model instanciation
+ interval = new Interval();
+ interval.setMin(0);
+ interval.setMax(11);
+ interval.setFirst(0);
+ interval.setLast(2);
+
+ setMetierSeasonInfoCombo();
+ setSeason();
+ setMetierZone();
+
+ inputContentUI.ip.setLabelRenderer(Month.MONTH);
+ inputContentUI.ip.setModel(interval);
+ }
+ }
+
+ protected void setSeason() {
+ if (inputContentUI.getMetierSeasonInfo() != null) {
+
+ // register selected item in save verifier
+ inputContentUI.getSaveVerifier().addCurrentEntity(inputContentUI.getMetierSeasonInfo());
+
+ try {
+ if (log.isDebugEnabled()) {
+ log.debug("Refresh interval : ");
+ }
+ Month firstMonth = inputContentUI.getMetierSeasonInfo().getFirstMonth();
+ if (firstMonth != null) {
+ interval.setFirst(firstMonth.getMonthNumber());
+ if (log.isDebugEnabled()) {
+ log.debug(" first : " + interval.getFirst());
+ }
+ } else {
+ interval.setFirst(0);
+ }
+
+ Month lastMonth = inputContentUI.getMetierSeasonInfo().getLastMonth();
+ if (lastMonth != null) {
+ interval.setLast(lastMonth.getMonthNumber());
+ if (log.isDebugEnabled()) {
+ log.debug(" last : " + interval.getLast());
+ }
+ } else {
+ interval.setLast(3);
+ }
+ } catch (Exception e) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't display season", e);
+ }
+ }
+ }
+ }
+ protected void setMetierZone() {
+ if (inputContentUI.getMetierSeasonInfo() != null) {
+ ListSelectionListener[] listeners = inputContentUI.metierZones.getListSelectionListeners();
+ for (ListSelectionListener listener : listeners) {
+ inputContentUI.metierZones.removeListSelectionListener(listener);
+ }
+
+ List<Zone> allZones = inputContentUI.getFisheryRegion().getZone();
+ GenericListModel<Zone> model = new GenericListModel<>(allZones);
+ inputContentUI.metierZones.setModel(model);
+ // restore selection
+ if (inputContentUI.metierSeasonInfo.getZone() != null) {
+ for (Zone zone : inputContentUI.metierSeasonInfo.getZone()) {
+ int index = allZones.indexOf(zone);
+ inputContentUI.metierZones.getSelectionModel().addSelectionInterval(index, index);
+ }
+ }
+
+ for (ListSelectionListener listener : listeners) {
+ inputContentUI.metierZones.addListSelectionListener(listener);
+ }
+ }
+ }
+
+ protected void setMetierSeasonInfoCombo() {
+ List<MetierSeasonInfo> metierSeasonInfoList = inputContentUI.getBean().getMetierSeasonInfo();
+ GenericComboModel<MetierSeasonInfo> metierSeasonInfoModel = new GenericComboModel<>(metierSeasonInfoList);
+ inputContentUI.metierSeasonInfoCombo.setModel(metierSeasonInfoModel);
+ metierSeasonInfoModel.setSelectedItem(inputContentUI.getMetierSeasonInfo());
+ }
+
+ protected void metierZonesChanged() {
+ List<Zone> selected = inputContentUI.metierZones.getSelectedValuesList();
+ List<Zone> zones = new ArrayList<>(selected);
+ inputContentUI.getMetierSeasonInfo().setZone(zones);
+ }
+
+ protected void seasonChanged() {
+ init = true;
+ inputContentUI.setMetierSeasonInfo((MetierSeasonInfo)inputContentUI.metierSeasonInfoCombo.getSelectedItem());
+ setSeason();
+ setMetierZone();
+ init = false;
+ }
+}
Property changes on: trunk/src/main/java/fr/ifremer/isisfish/ui/input/metier/MetierSeasonInfoZoneHandler.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/metier/MetierSeasonInfoZoneUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/metier/MetierSeasonInfoZoneUI.jaxx 2015-05-18 09:52:01 UTC (rev 4226)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/metier/MetierSeasonInfoZoneUI.jaxx 2015-05-20 12:09:09 UTC (rev 4227)
@@ -29,21 +29,7 @@
<fr.ifremer.isisfish.entities.MetierSeasonInfo id='metierSeasonInfo' javaBean='null'/>
- <import>
- fr.ifremer.isisfish.entities.Metier
- fr.ifremer.isisfish.entities.MetierSeasonInfo
- fr.ifremer.isisfish.entities.Zone
- fr.ifremer.isisfish.types.Month
- fr.ifremer.isisfish.ui.models.common.GenericComboModel
- fr.ifremer.isisfish.ui.models.common.GenericListModel
- fr.ifremer.isisfish.ui.widget.Interval
- fr.ifremer.isisfish.ui.widget.IntervalPanel
- java.beans.PropertyChangeEvent
- java.beans.PropertyChangeListener
- java.util.ArrayList
- java.awt.Dimension
- fr.ifremer.isisfish.ui.input.InputAction
- </import>
+ <MetierSeasonInfoZoneHandler id="handler" />
<BeanValidator id='validator' context="metier"
bean='{getBean()}' beanClass='fr.ifremer.isisfish.entities.Metier'
@@ -58,177 +44,21 @@
<fr.ifremer.isisfish.ui.input.ChangeModel id="changeModel" changed="{validator.isChanged() || validatorSeason.isChanged()}"
valid="{validator.isValid() && validatorSeason.isValid()}" />
- <script><![CDATA[
-
- protected Interval interval = null;
- protected boolean init = false;
+ <import>
+ java.awt.Dimension
+ </import>
+ <script><![CDATA[
protected void $afterCompleteSetup() {
- /*
- * Don't add both in same listener.
- * When first is set, last value from getPopulationSeasonInfo()
- * is erased by interval.getLast() default value.
- */
- ip.addPropertyChangeListener("first", new PropertyChangeListener() {
- @Override
- public void propertyChange(PropertyChangeEvent evt) {
- if (getMetierSeasonInfo() != null) {
- getMetierSeasonInfo().setFirstMonth(new Month(interval.getFirst()));
- }
- }
- });
- ip.addPropertyChangeListener("last", new PropertyChangeListener() {
- @Override
- public void propertyChange(PropertyChangeEvent evt) {
- if (getMetierSeasonInfo() != null) {
- getMetierSeasonInfo().setLastMonth(new Month(interval.getLast()));
- }
- }
- });
-
- addPropertyChangeListener(PROPERTY_BEAN, new PropertyChangeListener() {
- public void propertyChange(PropertyChangeEvent evt) {
- if (evt.getNewValue() == null) {
-
- }
- if (evt.getNewValue() != null) {
- refresh();
- }
- }
- });
+ handler.init(this);
}
@Override
public void resetChangeModel() {
changeModel.setStayChanged(false);
}
-
- protected void save() {
- getSaveVerifier().save();
- setMetierSeasonInfoCombo();
- }
-
- protected void create() {
- MetierSeasonInfo newMSI = getContextValue(InputAction.class).createMetierSeasonInfo(getBean());
- setMetierSeasonInfo(newMSI);
- setMetierSeasonInfoCombo();
- }
-
- protected void delete() {
- getContextValue(InputAction.class).removeMetierSeasonInfo(getBean(), getMetierSeasonInfo());
- setMetierSeasonInfo(null);
- setMetierSeasonInfoCombo();
- }
-
- public void refresh() {
-
- if (log.isDebugEnabled()) {
- log.debug("Refresh called in ui : " + this);
- }
-
- setMetierSeasonInfo(null);
-
- if (getBean() != null) {
- // Model instanciation
- interval = new Interval();
- interval.setMin(0);
- interval.setMax(11);
- interval.setFirst(0);
- interval.setLast(2);
-
- setMetierSeasonInfoCombo();
- setSeason();
- setMetierZone();
-
- ip.setLabelRenderer(Month.MONTH);
- ip.setModel(interval);
- }
- }
-
- protected void setSeason() {
- if (getMetierSeasonInfo() != null) {
-
- // register selected item in save verifier
- getSaveVerifier().addCurrentEntity(getMetierSeasonInfo());
-
- try {
- if (log.isDebugEnabled()) {
- log.debug("Refresh interval : ");
- }
- Month firstMonth = getMetierSeasonInfo().getFirstMonth();
- if (firstMonth != null) {
- interval.setFirst(firstMonth.getMonthNumber());
- if (log.isDebugEnabled()) {
- log.debug(" first : " + interval.getFirst());
- }
- } else {
- interval.setFirst(0);
- }
-
- Month lastMonth = getMetierSeasonInfo().getLastMonth();
- if (lastMonth != null) {
- interval.setLast(lastMonth.getMonthNumber());
- if (log.isDebugEnabled()) {
- log.debug(" last : " + interval.getLast());
- }
- } else {
- interval.setLast(3);
- }
- } catch (Exception e) {
- if (log.isErrorEnabled()) {
- log.error("Can't display season", e);
- }
- }
- }
- }
- protected void setMetierZone() {
- if (getMetierSeasonInfo() != null) {
- ListSelectionListener[] listeners = metierZones.getListSelectionListeners();
- for (ListSelectionListener listener : listeners) {
- metierZones.removeListSelectionListener(listener);
- }
-
- List<Zone> allZones = getFisheryRegion().getZone();
- GenericListModel<Zone> model = new GenericListModel<>(allZones);
- metierZones.setModel(model);
- // restore selection
- if (metierSeasonInfo.getZone() != null) {
- for (Zone zone : metierSeasonInfo.getZone()) {
- int index = allZones.indexOf(zone);
- metierZones.getSelectionModel().addSelectionInterval(index, index);
- }
- }
-
- for (ListSelectionListener listener : listeners) {
- metierZones.addListSelectionListener(listener);
- }
- }
- }
-
- protected void setMetierSeasonInfoCombo() {
- List<MetierSeasonInfo> metierSeasonInfoList = getBean().getMetierSeasonInfo();
- GenericComboModel<MetierSeasonInfo> metierSeasonInfoModel = new GenericComboModel<>(metierSeasonInfoList);
- metierSeasonInfoCombo.setModel(metierSeasonInfoModel);
- metierSeasonInfoModel.setSelectedItem(getMetierSeasonInfo());
- }
-
- protected void metierZonesChanged() {
- List<Zone> selected = metierZones.getSelectedValuesList();
- List<Zone> zones = new ArrayList<Zone>();
- for (Zone o : selected) {
- zones.add(o);
- }
- getMetierSeasonInfo().setZone(zones);
- }
-
- protected void seasonChanged() {
- init = true;
- setMetierSeasonInfo((MetierSeasonInfo)metierSeasonInfoCombo.getSelectedItem());
- setSeason();
- setMetierZone();
- init = false;
- }
]]></script>
+
<JPanel id="body">
<Table>
<row>
@@ -239,10 +69,10 @@
<JLabel text="isisfish.metierSeasonInfoZone.selectSeason" enabled='{isActive()}'/>
</cell>
<cell fill='horizontal' weightx='1.0'>
- <JComboBox id="metierSeasonInfoCombo" onItemStateChanged='seasonChanged()'
+ <JComboBox id="metierSeasonInfoCombo" onItemStateChanged='handler.seasonChanged()'
genericType="fr.ifremer.isisfish.entities.MetierSeasonInfo"
enabled='{isActive() && (isSensitivity() || !changeModel.isChanged() ) }'
- renderer="{new fr.ifremer.isisfish.ui.input.renderer.MetierSeasonInfoComboRenderer()}" />
+ renderer="{new MetierSeasonInfoComboRenderer()}" />
</cell>
</row>
<row>
@@ -250,7 +80,7 @@
<JLabel text="isisfish.metierSeasonInfoZone.season" enabled='{getMetierSeasonInfo() != null}'/>
</cell>
<cell fill='horizontal' weightx='1.0'>
- <IntervalPanel id='ip' enabled='{getMetierSeasonInfo() != null}' decorator='boxed'/>
+ <fr.ifremer.isisfish.ui.widget.IntervalPanel id='ip' enabled='{getMetierSeasonInfo() != null}' decorator='boxed'/>
</cell>
</row>
<row>
@@ -259,7 +89,7 @@
</cell>
<cell fill='both' weightx='1.0' weighty='0.7'>
<JScrollPane minimumSize='{new Dimension(0,0)}' preferredSize='{new Dimension(0,0)}'>
- <JList id="metierZones" onValueChanged='metierZonesChanged()'
+ <JList id="metierZones" onValueChanged='handler.metierZonesChanged()'
genericType="fr.ifremer.isisfish.entities.Zone"
enabled='{getMetierSeasonInfo() != null}' decorator='boxed'/>
</JScrollPane>
@@ -289,7 +119,7 @@
<JButton id='save' decorator='boxed'
text="isisfish.common.save"
enabled="{changeModel.isValid() && changeModel.isChanged()}"
- onActionPerformed="save();validator.setChanged(false);validatorSeason.setChanged(false);"/>
+ onActionPerformed="handler.save();validator.setChanged(false);validatorSeason.setChanged(false);"/>
</cell>
<cell fill='horizontal' weightx='0.5'>
<JButton id='cancel' decorator='boxed'
@@ -303,13 +133,13 @@
<JButton id='create' decorator='boxed'
text="isisfish.common.new"
enabled="{!changeModel.isChanged()}"
- onActionPerformed="create()"/>
+ onActionPerformed="handler.create()"/>
</cell>
<cell fill='horizontal' weightx='0.5'>
<JButton id='delete' decorator='boxed'
text="isisfish.common.remove"
enabled="{getMetierSeasonInfo() != null}"
- onActionPerformed="delete()"/>
+ onActionPerformed="handler.delete()"/>
</cell>
</row>
</Table>
Added: trunk/src/main/java/fr/ifremer/isisfish/ui/input/metier/MetierTabHandler.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/metier/MetierTabHandler.java (rev 0)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/metier/MetierTabHandler.java 2015-05-20 12:09:09 UTC (rev 4227)
@@ -0,0 +1,64 @@
+/*
+ * #%L
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2015 Ifremer, Codelutin, Chatellier Eric
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+package fr.ifremer.isisfish.ui.input.metier;
+
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+
+import fr.ifremer.isisfish.entities.Gear;
+import fr.ifremer.isisfish.ui.input.InputContentHandler;
+import fr.ifremer.isisfish.ui.models.common.GenericComboModel;
+
+/**
+ * Metier tab handler.
+ */
+public class MetierTabHandler extends InputContentHandler<MetierTabUI> {
+
+ protected boolean init;
+
+ protected void init(final MetierTabUI metierTabUI) {
+ super.init(metierTabUI);
+
+ metierTabUI.addPropertyChangeListener(MetierTabUI.PROPERTY_BEAN, new PropertyChangeListener() {
+ public void propertyChange(PropertyChangeEvent evt) {
+ GenericComboModel<Gear> model = new GenericComboModel<>(metierTabUI.getFisheryRegion().getGear());
+ if (evt.getNewValue() == null) {
+
+ }
+ if (evt.getNewValue() != null) {
+ init = true;
+ model.setSelectedItem(metierTabUI.bean.getGear());
+ init = false;
+ }
+ metierTabUI.fieldMetierGear.setModel(model);
+ }
+ });
+ }
+
+ protected void gearChanged() {
+ if (!init) {
+ inputContentUI.getBean().setGear((Gear)inputContentUI.fieldMetierGear.getSelectedItem());
+ }
+ }
+}
Property changes on: trunk/src/main/java/fr/ifremer/isisfish/ui/input/metier/MetierTabHandler.java
___________________________________________________________________
Added: svn:eol-style
+ native
Added: svn:keywords
+ Author Date Id Revision HeadURL
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/metier/MetierTabUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/metier/MetierTabUI.jaxx 2015-05-18 09:52:01 UTC (rev 4226)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/metier/MetierTabUI.jaxx 2015-05-20 12:09:09 UTC (rev 4227)
@@ -5,7 +5,7 @@
$Id$
$HeadURL$
%%
- Copyright (C) 2009 - 2011 Ifremer, Code Lutin, Chatellier Eric
+ Copyright (C) 2009 - 2015 Ifremer, Code Lutin, Chatellier Eric
%%
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as
@@ -27,61 +27,24 @@
<!-- bean property -->
<fr.ifremer.isisfish.entities.Metier id='bean' javaBean='null'/>
- <import>
- fr.ifremer.isisfish.entities.Gear
- fr.ifremer.isisfish.entities.Metier
- fr.ifremer.isisfish.ui.models.common.GenericComboModel
- java.beans.PropertyChangeEvent
- java.beans.PropertyChangeListener
- java.awt.Dimension
- </import>
-
+ <MetierTabHandler id="handler" />
+
<BeanValidator id='validator' context="metier"
bean='{getBean()}' beanClass='fr.ifremer.isisfish.entities.Metier'
uiClass="jaxx.runtime.validator.swing.ui.ImageValidationUI">
<field name="name" component="fieldMetierName" />
</BeanValidator>
- <script><![CDATA[
-protected boolean init = false;
+ <import>
+ java.awt.Dimension
+ </import>
-protected void $afterCompleteSetup() {
- addPropertyChangeListener(PROPERTY_BEAN, new PropertyChangeListener() {
- public void propertyChange(PropertyChangeEvent evt) {
- GenericComboModel<Gear> model = new GenericComboModel<>(getFisheryRegion().getGear());
- if (evt.getNewValue() == null) {
-
- }
- if (evt.getNewValue() != null) {
- init = true;
- model.setSelectedItem(bean.getGear());
- init = false;
- }
- fieldMetierGear.setModel(model);
- }
- });
-}
-
-/*public void refresh() {
-
- if (log.isDebugEnabled()) {
- log.debug("Refresh called in ui : " + this);
+ <script><![CDATA[
+ protected void $afterCompleteSetup() {
+ handler.init(this);
}
-
- Metier metier = getSaveVerifier().getEntity(Metier.class);
-
- // add null before, for second to be considered as a changed event
- // otherwize, setBean has no effect
- setBean(null);
- setBean(metier);
-}*/
-
-protected void gearChanged() {
- if (!init) {
- getBean().setGear((Gear)fieldMetierGear.getSelectedItem());
- }
-}
]]></script>
+
<JPanel id="body">
<Table>
<row>
@@ -102,7 +65,7 @@
<JLabel text="isisfish.common.gear" enabled='{isActive()}'/>
</cell>
<cell fill='horizontal' weightx='1.0'>
- <JComboBox id="fieldMetierGear" onItemStateChanged='gearChanged()'
+ <JComboBox id="fieldMetierGear" onItemStateChanged='handler.gearChanged()'
genericType="fr.ifremer.isisfish.entities.Gear"
enabled='{isActive()}' decorator='boxed'/>
</cell>
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/metier/MetierUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/metier/MetierUI.jaxx 2015-05-18 09:52:01 UTC (rev 4226)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/metier/MetierUI.jaxx 2015-05-20 12:09:09 UTC (rev 4227)
@@ -5,7 +5,7 @@
$Id$
$HeadURL$
%%
- Copyright (C) 2009 - 2011 Ifremer, Code Lutin, Chatellier Eric
+ Copyright (C) 2009 - 2015 Ifremer, Code Lutin, Chatellier Eric
%%
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as
@@ -26,36 +26,29 @@
<fr.ifremer.isisfish.entities.Metier id='bean' javaBean='null'/>
- <import>
- static org.nuiton.i18n.I18n.t
- static org.nuiton.i18n.I18n.n
- </import>
+ <MetierHandler id="handler" />
-<script><![CDATA[
-protected void $afterCompleteSetup() {
- setButtonTitle(t("isisfish.input.continueTripTypes"));
- setNextPath(n("isisfish.input.tree.triptypes"));
-
- // install change listener
- // (depends on sensitivity can't be done on constructor)
- installChangeListener(metierTab);
-}
+ <script><![CDATA[
+ protected void $afterCompleteSetup() {
+ handler.init(this);
+ }
-@Override
-public void setLayer(boolean active) {
- super.setLayer(active);
- metierTabUI.setLayer(active);
- metierSeasonInfoUI.setLayer(active);
- metierSeasonSpeciesUI.setLayer(active);
-}
-
-@Override
-public void resetChangeModel() {
- metierTabUI.resetChangeModel();
- metierSeasonInfoUI.resetChangeModel();
- metierSeasonSpeciesUI.resetChangeModel();
-}
+ @Override
+ public void setLayer(boolean active) {
+ super.setLayer(active);
+ metierTabUI.setLayer(active);
+ metierSeasonInfoUI.setLayer(active);
+ metierSeasonSpeciesUI.setLayer(active);
+ }
+
+ @Override
+ public void resetChangeModel() {
+ metierTabUI.resetChangeModel();
+ metierSeasonInfoUI.resetChangeModel();
+ metierSeasonSpeciesUI.resetChangeModel();
+ }
]]></script>
+
<JPanel id="body">
<JTabbedPane id="metierTab" constraints='BorderLayout.CENTER'>
<tab title='isisfish.metier.title'>
Added: trunk/src/main/java/fr/ifremer/isisfish/ui/input/observation/ObservationHandler.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/observation/ObservationHandler.java (rev 0)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/observation/ObservationHandler.java 2015-05-20 12:09:09 UTC (rev 4227)
@@ -0,0 +1,74 @@
+/*
+ * #%L
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2015 Ifremer, Codelutin, Chatellier Eric
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+package fr.ifremer.isisfish.ui.input.observation;
+
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+
+import org.nuiton.math.matrix.MatrixND;
+import org.nuiton.math.matrix.gui.MatrixPanelEvent;
+
+import fr.ifremer.isisfish.ui.input.InputContentHandler;
+
+/**
+ * Observation handler.
+ */
+public class ObservationHandler extends InputContentHandler<ObservationUI> {
+
+ protected void init(final ObservationUI inputContentUI) {
+ super.init(inputContentUI);
+
+ inputContentUI.addPropertyChangeListener(ObservationUI.PROPERTY_BEAN, new PropertyChangeListener() {
+ public void propertyChange(PropertyChangeEvent evt) {
+ if (evt.getNewValue() == null) {
+ inputContentUI.fieldObservationValue.setMatrix(null);
+ }
+ if (evt.getNewValue() != null) {
+ setObservationValueMatrix();
+ }
+ }
+ });
+ }
+
+ protected void setObservationValueMatrix() {
+ MatrixND prop = inputContentUI.getBean().getValue();
+ if (prop != null) {
+ inputContentUI.fieldObservationValue.setMatrix(prop.copy());
+ } else {
+ inputContentUI.fieldObservationValue.setMatrix(null);
+ }
+ }
+
+ protected void createObservationValueMatrix() {
+ inputContentUI.getAction().createObservationValueMatrix(inputContentUI.getBean());
+ setObservationValueMatrix();
+ }
+
+ protected void observationValueMatrixChanged(MatrixPanelEvent event) {
+ MatrixND mat = inputContentUI.fieldObservationValue.getMatrix();
+ if (inputContentUI.getBean() != null && mat != null) {
+ inputContentUI.getBean().setValue(mat.copy());
+ }
+ }
+}
Property changes on: trunk/src/main/java/fr/ifremer/isisfish/ui/input/observation/ObservationHandler.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/observation/ObservationUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/observation/ObservationUI.jaxx 2015-05-18 09:52:01 UTC (rev 4226)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/observation/ObservationUI.jaxx 2015-05-20 12:09:09 UTC (rev 4227)
@@ -5,7 +5,7 @@
$Id$
$HeadURL$
%%
- Copyright (C) 2014 Ifremer, Code Lutin, Chatellier Eric
+ Copyright (C) 2014 - 2015 Ifremer, Code Lutin, Chatellier Eric
%%
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as
@@ -23,64 +23,25 @@
#L%
-->
<fr.ifremer.isisfish.ui.input.InputContentUI
- superGenericType='fr.ifremer.isisfish.entities.Observation'>
+ superGenericType='fr.ifremer.isisfish.entities.Observation'>
- <!-- bean property -->
- <fr.ifremer.isisfish.entities.Observation
- id='bean' javaBean='null' />
+ <!-- bean property -->
+ <fr.ifremer.isisfish.entities.Observation id='bean' javaBean='null' />
- <import>
- static org.nuiton.i18n.I18n.t
- static org.nuiton.i18n.I18n.n
- org.nuiton.math.matrix.gui.MatrixPanelEvent
- org.nuiton.math.matrix.MatrixND
- java.beans.PropertyChangeEvent
- java.beans.PropertyChangeListener
- </import>
+ <ObservationHandler id="handler" />
- <BeanValidator id='validator'
- bean='{getBean()}' beanClass='fr.ifremer.isisfish.entities.Observation'
- uiClass="jaxx.runtime.validator.swing.ui.ImageValidationUI">
- <field name="name" component="fieldObservationName" />
- </BeanValidator>
+ <BeanValidator id='validator'
+ bean='{getBean()}' beanClass='fr.ifremer.isisfish.entities.Observation'
+ uiClass="jaxx.runtime.validator.swing.ui.ImageValidationUI">
+ <field name="name" component="fieldObservationName" />
+ </BeanValidator>
- <script><![CDATA[
-
-protected void $afterCompleteSetup() {
- addPropertyChangeListener(PROPERTY_BEAN, new PropertyChangeListener() {
- public void propertyChange(PropertyChangeEvent evt) {
- if (evt.getNewValue() == null) {
- fieldObservationValue.setMatrix(null);
- }
- if (evt.getNewValue() != null) {
- setObservationValueMatrix();
- }
- }
- });
-}
-
-protected void setObservationValueMatrix() {
- MatrixND prop = getBean().getValue();
- if (prop != null) {
- fieldObservationValue.setMatrix(prop.copy());
- } else {
- fieldObservationValue.setMatrix(null);
+ <script><![CDATA[
+ protected void $afterCompleteSetup() {
+ handler.init(this);
}
-}
-
-protected void createObservationValueMatrix() {
- getAction().createObservationValueMatrix(getBean());
- setObservationValueMatrix();
-}
-
-protected void observationValueMatrixChanged(MatrixPanelEvent event) {
- MatrixND mat = fieldObservationValue.getMatrix();
- if (getBean() != null && mat != null) {
- getBean().setValue(mat.copy());
- }
-}
-
]]></script>
+
<JPanel id="body">
<Table>
<row>
@@ -124,7 +85,7 @@
<row>
<cell columns='2' fill='both' weighty='1' weightx='1.0'>
<org.nuiton.math.matrix.gui.MatrixPanelEditor
- id="fieldObservationValue" onMatrixChanged="observationValueMatrixChanged(event)"
+ id="fieldObservationValue" onMatrixChanged="handler.observationValueMatrixChanged(event)"
enabled='{isActive()}' decorator='boxed'
_sensitivityBean='{fr.ifremer.isisfish.entities.Observation.class}'
_sensitivityMethod='"Value"' />
@@ -135,7 +96,7 @@
<JPanel/>
</cell>
<cell fill='horizontal' weightx='1.0'>
- <JButton text="isisfish.common.newMatrix" onActionPerformed='createObservationValueMatrix()' enabled='{isActive()}' decorator='boxed'/>
+ <JButton text="isisfish.common.newMatrix" onActionPerformed='handler.createObservationValueMatrix()' enabled='{isActive()}' decorator='boxed'/>
</cell>
</row>
</Table>
Added: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationBasicsHandler.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationBasicsHandler.java (rev 0)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationBasicsHandler.java 2015-05-20 12:09:09 UTC (rev 4227)
@@ -0,0 +1,137 @@
+/*
+ * #%L
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2015 Ifremer, Codelutin, Chatellier Eric
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+package fr.ifremer.isisfish.ui.input.population;
+
+import static org.nuiton.i18n.I18n.t;
+
+import java.awt.BorderLayout;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.util.List;
+
+import javax.swing.JFrame;
+import javax.swing.JOptionPane;
+import javax.swing.table.DefaultTableModel;
+
+import fr.ifremer.isisfish.entities.Population;
+import fr.ifremer.isisfish.entities.PopulationGroup;
+import fr.ifremer.isisfish.entities.Species;
+import fr.ifremer.isisfish.ui.input.InputAction;
+import fr.ifremer.isisfish.ui.input.InputContentHandler;
+import fr.ifremer.isisfish.ui.input.InputUI;
+import jaxx.runtime.JAXXUtil;
+
+/**
+ * Population handler.
+ */
+public class PopulationBasicsHandler extends InputContentHandler<PopulationBasicsUI> {
+
+ protected void init(final PopulationBasicsUI inputContentUI) {
+ super.init(inputContentUI);
+
+ inputContentUI.addPropertyChangeListener(PopulationBasicsUI.PROPERTY_BEAN, new PropertyChangeListener() {
+ public void propertyChange(PropertyChangeEvent evt) {
+ if (evt.getNewValue() == null) {
+ inputContentUI.fieldPopulationBasicsName.setText("");
+ inputContentUI.fieldPopulationBasicsGeographicID.setText("");
+ inputContentUI.fieldPopulationBasicsNbClasses.setText("");
+ inputContentUI.fieldPopulationBasicsComment.setText("");
+ inputContentUI.tableAgeLength.setModel(new DefaultTableModel());
+ }
+ if (evt.getNewValue() != null) {
+ setTableAgeLengthModel();
+ }
+ }
+ });
+ }
+
+ public void refresh() {
+ Population population = inputContentUI.getSaveVerifier().getEntity(Population.class);
+
+ // add null before, for second to be considered as a changed event
+ // otherwize, setBean has no effect
+ inputContentUI.setBean(null);
+ inputContentUI.setBean(population);
+
+ if (inputContentUI.getBean() != null) {
+ setTableAgeLengthModel();
+ }
+ //getSaveVerifier().addCurrentPanel(growthEquation, growthReverseEquation);
+ }
+
+ /**
+ * Open creation classe wizard after confirmation.
+ */
+ protected void createGroups() {
+
+ int response = JOptionPane.showConfirmDialog(inputContentUI, t("isisfish.populationBasics.confirmCreateGroups"),
+ t("isisfish.common.confirm"), JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE);
+
+ if (response == JOptionPane.YES_OPTION) {
+ JFrame wizardFrame = new JFrame();
+ wizardFrame.setLayout(new BorderLayout());
+ WizardGroupCreationUI wizard = new WizardGroupCreationUI(inputContentUI);
+ wizard.getHandler().initParent(inputContentUI);
+ wizardFrame.add(wizard, BorderLayout.CENTER);
+ wizardFrame.setTitle(t("isisfish.wizardGroupCreation.title"));
+ Species species = inputContentUI.getBean().getSpecies();
+ wizard.getHandler().setAgeType(species.isAgeGroupType());
+ if (wizard.getHandler().isAgeType()) {
+ wizard.getHandler().setCard("singleGroupAge");
+ } else {
+ wizard.getHandler().setCard("beginGroupLength");
+ }
+ wizardFrame.pack();
+ wizardFrame.setLocationRelativeTo(inputContentUI);
+ wizardFrame.setVisible(true);
+ }
+
+ }
+
+ protected void setTableAgeLengthModel() {
+ List<PopulationGroup> popGroup = inputContentUI.getBean().getPopulationGroup();
+ if (popGroup != null){
+ DefaultTableModel model = new DefaultTableModel(2, popGroup.size() + 1);
+ model.setValueAt("Age", 0, 0);
+ model.setValueAt("Lengths", 1, 0);
+ int cnt = 1;
+ for (PopulationGroup pg : popGroup){
+ model.setValueAt(pg.getAge(), 0, cnt);
+ model.setValueAt(pg.getLength(), 1, cnt);
+ cnt++;
+ }
+ inputContentUI.tableAgeLength.setModel(model);
+ }
+ }
+
+ protected void create() {
+ // find species node
+ InputUI inputUI = inputContentUI.getContextValue(InputUI.class, JAXXUtil.PARENT);
+ Species species = inputUI.getHandler().findSpecies(inputUI);
+ // create node and select it
+ Population population = inputContentUI.getContextValue(InputAction.class).createPopulation(inputContentUI.getTopiaContext(), species);
+ inputUI.getHandler().insertTreeNode(inputUI, Population.class, population);
+ inputContentUI.setInfoText(t("isisfish.message.creation.finished"));
+ }
+}
Property changes on: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationBasicsHandler.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationBasicsUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationBasicsUI.jaxx 2015-05-18 09:52:01 UTC (rev 4226)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationBasicsUI.jaxx 2015-05-20 12:09:09 UTC (rev 4227)
@@ -5,7 +5,7 @@
$Id$
$HeadURL$
%%
- Copyright (C) 2009 - 2012 Ifremer, Code Lutin, Chatellier Eric
+ Copyright (C) 2009 - 2015 Ifremer, Code Lutin, Chatellier Eric
%%
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as
@@ -27,20 +27,7 @@
<!-- bean property -->
<fr.ifremer.isisfish.entities.Population id='bean' javaBean='null'/>
- <import>
- static org.nuiton.i18n.I18n.t
- fr.ifremer.isisfish.entities.Species;
- fr.ifremer.isisfish.entities.PopulationGroup;
- fr.ifremer.isisfish.entities.Population;
- javax.swing.table.DefaultTableModel;
- java.beans.PropertyChangeEvent;
- java.beans.PropertyChangeListener;
- javax.swing.JOptionPane
- javax.swing.JFrame
- java.awt.BorderLayout
- fr.ifremer.isisfish.ui.input.InputUI
- fr.ifremer.isisfish.ui.input.InputAction
- </import>
+ <PopulationBasicsHandler id="handler" />
<BeanValidator id='validator' context="basics"
bean='{getBean()}' beanClass='fr.ifremer.isisfish.entities.Population'
@@ -49,93 +36,11 @@
</BeanValidator>
<script><![CDATA[
-protected void $afterCompleteSetup() {
- addPropertyChangeListener(PROPERTY_BEAN, new PropertyChangeListener() {
- public void propertyChange(PropertyChangeEvent evt) {
- if (evt.getNewValue() == null) {
- fieldPopulationBasicsName.setText("");
- fieldPopulationBasicsGeographicID.setText("");
- fieldPopulationBasicsNbClasses.setText("");
- fieldPopulationBasicsComment.setText("");
- tableAgeLength.setModel(new DefaultTableModel());
- }
- if (evt.getNewValue() != null) {
- setTableAgeLengthModel();
- }
- }
- });
-}
-
-public void refresh() {
- Population population = getSaveVerifier().getEntity(Population.class);
-
- // add null before, for second to be considered as a changed event
- // otherwize, setBean has no effect
- setBean(null);
- setBean(population);
-
- if (getBean() != null) {
- setTableAgeLengthModel();
+ protected void $afterCompleteSetup() {
+ handler.init(this);
}
- //getSaveVerifier().addCurrentPanel(growthEquation, growthReverseEquation);
-}
+ ]]></script>
-/**
- * Open creation classe wizard after confirmation.
- */
-protected void createGroups() {
-
- int response = JOptionPane.showConfirmDialog(this, t("isisfish.populationBasics.confirmCreateGroups"),
- t("isisfish.common.confirm"), JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE);
-
- if (response == JOptionPane.YES_OPTION) {
- JFrame wizardFrame = new JFrame();
- wizardFrame.setLayout(new BorderLayout());
- WizardGroupCreationUI wizard = new WizardGroupCreationUI(this);
- wizard.init(this);
- wizardFrame.add(wizard, BorderLayout.CENTER);
- wizardFrame.setTitle(t("isisfish.wizardGroupCreation.title"));
- Species species = getBean().getSpecies();
- wizard.setAgeType(species.isAgeGroupType());
- if (wizard.isAgeType()) {
- wizard.setCard("singleGroupAge");
- } else {
- wizard.setCard("beginGroupLength");
- }
- wizardFrame.pack();
- wizardFrame.setLocationRelativeTo(this);
- wizardFrame.setVisible(true);
- }
-
-}
-
-protected void setTableAgeLengthModel() {
- java.util.List<PopulationGroup> popGroup = getBean().getPopulationGroup();
- if (popGroup != null){
- DefaultTableModel model = new DefaultTableModel(2, popGroup.size() + 1);
- model.setValueAt("Age", 0, 0);
- model.setValueAt("Lengths", 1, 0);
- int cnt = 1;
- for (PopulationGroup pg : popGroup){
- model.setValueAt(pg.getAge(), 0, cnt);
- model.setValueAt(pg.getLength(), 1, cnt);
- cnt++;
- }
- tableAgeLength.setModel(model);
- }
-}
-
-protected void create() {
- // find species node
- InputUI inputUI = getContextValue(InputUI.class, JAXXUtil.PARENT);
- Species species = inputUI.getHandler().findSpecies(inputUI);
- // create node and select it
- Population population = getContextValue(InputAction.class).createPopulation(getTopiaContext(), species);
- inputUI.getHandler().insertTreeNode(inputUI, Population.class, population);
- setInfoText(t("isisfish.message.creation.finished"));
-}
- ]]>
- </script>
<JPanel id="body">
<Table>
<row>
@@ -176,7 +81,7 @@
</cell>
<cell fill='horizontal'>
<JButton id="buttonPopulationBasicsCreateClasses" text="isisfish.populationBasics.recreateClasses"
- onActionPerformed='createGroups()' enabled='{isActive()}' decorator='boxed'/>
+ onActionPerformed='handler.createGroups()' enabled='{isActive()}' decorator='boxed'/>
</cell>
<cell fill='horizontal'>
<JCheckBox id="fieldPopulationBasicsPlusGroup" text="isisfish.populationBasics.plusGroup"
@@ -277,7 +182,7 @@
<JButton id='create' decorator='boxed'
text="isisfish.common.new"
enabled="{!validator.isChanged()}"
- onActionPerformed="create()"/>
+ onActionPerformed="handler.create()"/>
</cell>
<cell fill='horizontal' weightx='0.5'>
<JButton id='delete' decorator='boxed'
Added: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationCapturabilityHandler.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationCapturabilityHandler.java (rev 0)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationCapturabilityHandler.java 2015-05-20 12:09:09 UTC (rev 4227)
@@ -0,0 +1,87 @@
+/*
+ * #%L
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2015 Ifremer, Codelutin, Chatellier Eric
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+package fr.ifremer.isisfish.ui.input.population;
+
+import java.awt.CardLayout;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+
+import org.nuiton.math.matrix.gui.MatrixPanelEvent;
+
+import fr.ifremer.isisfish.ui.input.InputContentHandler;
+
+/**
+ * Population handler.
+ */
+public class PopulationCapturabilityHandler extends InputContentHandler<PopulationCapturabilityUI> {
+
+ protected void init(final PopulationCapturabilityUI inputContentUI) {
+ super.init(inputContentUI);
+
+ inputContentUI.addPropertyChangeListener(PopulationCapturabilityUI.PROPERTY_BEAN, new PropertyChangeListener() {
+ public void propertyChange(PropertyChangeEvent evt) {
+ if (evt.getNewValue() == null) {
+ inputContentUI.fieldPopulationCapturabilityComment.setText("");
+ inputContentUI.fieldPopulationCapturability.setMatrix(null);
+ }
+ if (evt.getNewValue() != null) {
+ if (inputContentUI.getBean().getCapturability() != null) {
+ inputContentUI.fieldPopulationCapturability.setMatrix(inputContentUI.getBean().getCapturability().copy());
+ }
+ refreshHidablePanel();
+ }
+ }
+ });
+ }
+
+ protected void populationCapturabilityMatrixChanged(MatrixPanelEvent event) {
+ if (inputContentUI.getBean() != null && inputContentUI.fieldPopulationCapturability.getMatrix() != null) {
+ inputContentUI.getBean().setCapturability(inputContentUI.fieldPopulationCapturability.getMatrix().copy());
+ }
+ }
+
+ protected void useEquationChanged() {
+ inputContentUI.getBean().setCapturabilityEquationUsed(inputContentUI.fieldUseCapturabilityEquation.isSelected());
+
+ // compute matrix again to not diplay values computed by equation
+ if (!inputContentUI.fieldUseCapturabilityEquation.isSelected()) {
+ if (inputContentUI.getBean().getCapturability() != null) {
+ inputContentUI.fieldPopulationCapturability.setMatrix(inputContentUI.getBean().getCapturability().copy());
+ }
+ }
+ refreshHidablePanel();
+ }
+
+ protected void refreshHidablePanel() {
+ if (inputContentUI.getBean() != null) {
+ if (inputContentUI.getBean().isCapturabilityEquationUsed()) {
+ inputContentUI.fieldUseCapturabilityEquation.setSelected(true);
+ ((CardLayout)inputContentUI.hidablePanel.getLayout()).show(inputContentUI.hidablePanel, "fieldUseEquation");
+ } else {
+ inputContentUI.fieldUseCapturabilityEquation.setSelected(false);
+ ((CardLayout)inputContentUI.hidablePanel.getLayout()).show(inputContentUI.hidablePanel, "fieldUseMatrix");
+ }
+ }
+ }
+}
Property changes on: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationCapturabilityHandler.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationCapturabilityUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationCapturabilityUI.jaxx 2015-05-18 09:52:01 UTC (rev 4226)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationCapturabilityUI.jaxx 2015-05-20 12:09:09 UTC (rev 4227)
@@ -5,7 +5,7 @@
$Id$
$HeadURL$
%%
- Copyright (C) 2009 - 2011 Ifremer, Code Lutin, Chatellier Eric
+ Copyright (C) 2009 - 2015 Ifremer, Code Lutin, Chatellier Eric
%%
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as
@@ -27,14 +27,7 @@
<!-- bean property -->
<fr.ifremer.isisfish.entities.Population id='bean' javaBean='null'/>
- <import>
- fr.ifremer.isisfish.entities.Population
- org.nuiton.math.matrix.gui.MatrixPanelEvent
- java.beans.PropertyChangeEvent
- java.beans.PropertyChangeListener
- org.nuiton.math.matrix.gui.MatrixPanelListener
- java.awt.CardLayout
- </import>
+ <PopulationCapturabilityHandler id="handler" />
<BeanValidator id='validator' context="capturability"
bean='{getBean()}' beanClass='fr.ifremer.isisfish.entities.Population'
@@ -42,68 +35,11 @@
</BeanValidator>
<script><![CDATA[
-protected void $afterCompleteSetup() {
- addPropertyChangeListener(PROPERTY_BEAN, new PropertyChangeListener() {
- public void propertyChange(PropertyChangeEvent evt) {
- if (evt.getNewValue() == null) {
- fieldPopulationCapturabilityComment.setText("");
- fieldPopulationCapturability.setMatrix(null);
- }
- if (evt.getNewValue() != null) {
- if (getBean().getCapturability() != null) {
- fieldPopulationCapturability.setMatrix(getBean().getCapturability().copy());
- }
- refreshHidablePanel();
- }
- }
- });
-}
-
-protected void populationCapturabilityMatrixChanged(MatrixPanelEvent event) {
- if (getBean() != null && fieldPopulationCapturability.getMatrix() != null) {
- getBean().setCapturability(fieldPopulationCapturability.getMatrix().copy());
+ protected void $afterCompleteSetup() {
+ handler.init(this);
}
-}
+ ]]></script>
-/*public void refresh() {
- Population population = getSaveVerifier().getEntity(Population.class);
-
- // add null before, for second to be considered as a changed event
- // otherwize, setBean has no effect
- setBean(null);
- setBean(population);
-
- if (getBean() != null){
- if (getBean().getCapturability() != null) {
- fieldPopulationCapturability.setMatrix(getBean().getCapturability().copy());
- }
- }
-}*/
-protected void useEquationChanged() {
- getBean().setCapturabilityEquationUsed(fieldUseCapturabilityEquation.isSelected());
-
- // compute matrix again to not diplay values computed by equation
- if (!fieldUseCapturabilityEquation.isSelected()) {
- if (getBean().getCapturability() != null) {
- fieldPopulationCapturability.setMatrix(getBean().getCapturability().copy());
- }
- }
- refreshHidablePanel();
-}
-protected void refreshHidablePanel() {
- if (getBean() != null) {
- if (getBean().isCapturabilityEquationUsed()) {
- fieldUseCapturabilityEquation.setSelected(true);
- ((CardLayout) hidablePanel.getLayout()).show(hidablePanel, "fieldUseEquation");
- }
- else {
- fieldUseCapturabilityEquation.setSelected(false);
- ((CardLayout) hidablePanel.getLayout()).show(hidablePanel, "fieldUseMatrix");
- }
- }
-}
- ]]>
- </script>
<JPanel id="body">
<Table>
<row>
@@ -114,18 +50,18 @@
<row>
<cell columns='2' fill='horizontal' weightx='1.0' anchor='east'>
<JCheckBox id="fieldUseCapturabilityEquation" selected='{getBean().isCapturabilityEquationUsed()}'
- text="isisfish.populationCapturability.useCapturabilityEquation" onActionPerformed='useEquationChanged()'
+ text="isisfish.populationCapturability.useCapturabilityEquation" onActionPerformed='handler.useEquationChanged()'
enabled='{isActive()}' decorator='boxed'/>
</cell>
</row>
<row>
<cell columns='2' fill='both' weightx='1.0' weighty='0.5'>
- <JPanel id="hidablePanel" layout='{new CardLayout()}'>
+ <JPanel id="hidablePanel" layout='{new java.awt.CardLayout()}'>
<org.nuiton.math.matrix.gui.MatrixPanelEditor id ='fieldPopulationCapturability'
matrix='{getBean().getCapturability() == null ? null : getBean().getCapturability().copy()}'
enabled='{isActive()}' decorator='boxed' _sensitivityBean='{Population.class}' _sensitivityMethod='"Capturability"'
- onMatrixChanged="populationCapturabilityMatrixChanged(event)"
+ onMatrixChanged="handler.populationCapturabilityMatrixChanged(event)"
constraints='"fieldUseMatrix"' />
<fr.ifremer.isisfish.ui.input.InputOneEquationUI id='capturabilityEquation' constructorParams='this'
text='isisfish.common.capturability' active='{isActive()}'
Added: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationEquationHandler.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationEquationHandler.java (rev 0)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationEquationHandler.java 2015-05-20 12:09:09 UTC (rev 4227)
@@ -0,0 +1,36 @@
+/*
+ * #%L
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2015 Ifremer, Codelutin, Chatellier Eric
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+package fr.ifremer.isisfish.ui.input.population;
+
+import fr.ifremer.isisfish.ui.input.InputContentHandler;
+
+/**
+ * Population handler.
+ */
+public class PopulationEquationHandler extends InputContentHandler<PopulationEquationUI> {
+
+ protected void init(final PopulationEquationUI inputContentUI) {
+ super.init(inputContentUI);
+ }
+}
Property changes on: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationEquationHandler.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationEquationUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationEquationUI.jaxx 2015-05-18 09:52:01 UTC (rev 4226)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationEquationUI.jaxx 2015-05-20 12:09:09 UTC (rev 4227)
@@ -5,7 +5,7 @@
$Id$
$HeadURL$
%%
- Copyright (C) 2009 - 2011 Ifremer, Code Lutin, Chatellier Eric
+ Copyright (C) 2009 - 2015 Ifremer, Code Lutin, Chatellier Eric
%%
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as
@@ -27,9 +27,7 @@
<!-- bean property -->
<fr.ifremer.isisfish.entities.Population id='bean' javaBean='null'/>
- <import>
- fr.ifremer.isisfish.entities.Population;
- </import>
+ <PopulationEquationHandler id="handler" />
<BeanValidator id='validator' context="equation"
bean='{getBean()}' beanClass='fr.ifremer.isisfish.entities.Population'
@@ -37,18 +35,11 @@
</BeanValidator>
<script><![CDATA[
-/*public void refresh() {
- Population population = getSaveVerifier().getEntity(Population.class);
-
- // add null before, for second to be considered as a changed event
- // otherwize, setBean has no effect
- setBean(null);
- setBean(population);
+ protected void $afterCompleteSetup() {
+ handler.init(this);
+ }
+ ]]></script>
- getSaveVerifier().addCurrentPanel(naturalDeathRate, meanWeight, price);
-}*/
- ]]>
- </script>
<JPanel id="body">
<Table>
<row>
Added: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationGroupHandler.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationGroupHandler.java (rev 0)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationGroupHandler.java 2015-05-20 12:09:09 UTC (rev 4227)
@@ -0,0 +1,113 @@
+/*
+ * #%L
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2015 Ifremer, Codelutin, Chatellier Eric
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+package fr.ifremer.isisfish.ui.input.population;
+
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.nuiton.math.matrix.MatrixND;
+
+import fr.ifremer.isisfish.entities.Population;
+import fr.ifremer.isisfish.entities.PopulationGroup;
+import fr.ifremer.isisfish.ui.input.InputContentHandler;
+import fr.ifremer.isisfish.ui.models.common.GenericComboModel;
+
+/**
+ * Population handler.
+ */
+public class PopulationGroupHandler extends InputContentHandler<PopulationGroupUI> {
+
+ /** Class logger. */
+ private static final Log log = LogFactory.getLog(PopulationGroupHandler.class);
+
+ protected void init(final PopulationGroupUI inputContentUI) {
+ super.init(inputContentUI);
+
+ inputContentUI.addPropertyChangeListener(PopulationGroupUI.PROPERTY_BEAN, new PropertyChangeListener() {
+ public void propertyChange(PropertyChangeEvent evt) {
+
+ GenericComboModel<PopulationGroup> groupModel = new GenericComboModel<>();
+
+ if (evt.getNewValue() == null) {
+ inputContentUI.setPopulationGroup(null);
+ }
+ if (evt.getNewValue() != null) {
+ groupModel.setElementList(inputContentUI.getBean().getPopulationGroup());
+ }
+
+ inputContentUI.populationGroupPopulationGroupComboBox.setModel(groupModel);
+ }
+ });
+
+ inputContentUI.addPropertyChangeListener(PopulationGroupUI.PROPERTY_POPULATION_GROUP, new PropertyChangeListener() {
+ public void propertyChange(PropertyChangeEvent evt) {
+ if (evt.getNewValue() == null) {
+ inputContentUI.fieldPopulationGroupMeanWeight.setText("");
+ inputContentUI.fieldPopulationGroupPrice.setText("");
+ inputContentUI.fieldPopulationGroupReproductionRate.setText("");
+ inputContentUI.fieldPopulationGroupMaturityOgive.setText("");
+ inputContentUI.fieldPopulationGroupAge.setText("");
+ inputContentUI.fieldPopulationGroupMinLength.setText("");
+ inputContentUI.fieldPopulationGroupMaxLength.setText("");
+ inputContentUI.fieldPopulationGroupComment.setText("");
+ inputContentUI.fieldPopulationGroupNaturalDeathRate.setMatrix(null);
+ }
+ if (evt.getNewValue() != null) {
+
+ }
+ }
+ });
+ }
+
+ protected void setNaturalDeathRateMatrix() {
+ try {
+ Population population = inputContentUI.getBean();
+ MatrixND naturalDeathRateMatrix = population.getNaturalDeathRateMatrix();
+
+ // extract only line for this population group
+ MatrixND naturalDeathRateMatrix2 = naturalDeathRateMatrix.getSubMatrix(0, inputContentUI.getPopulationGroup());
+ inputContentUI.fieldPopulationGroupNaturalDeathRate.setMatrix(naturalDeathRateMatrix2.copy());
+ } catch (Exception e) {
+ // can happen if population has no zone yet
+ // TODO maybe display a message
+ if (log.isWarnEnabled()) {
+ log.warn("No zone defined for this population group", e);
+ }
+ }
+ }
+
+ /**
+ * Called on PopulationGroup combo box selection.
+ */
+ protected void populationGroupChanged() {
+ PopulationGroup selectedPopulationGroup = (PopulationGroup)inputContentUI.populationGroupPopulationGroupComboBox.getSelectedItem();
+ inputContentUI.setPopulationGroup(selectedPopulationGroup);
+ if (selectedPopulationGroup != null) {
+ inputContentUI.getSaveVerifier().addCurrentEntity(selectedPopulationGroup);
+ setNaturalDeathRateMatrix();
+ }
+ }
+}
Property changes on: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationGroupHandler.java
___________________________________________________________________
Added: svn:eol-style
+ native
Added: svn:keywords
+ Author Date Id Revision HeadURL
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationGroupUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationGroupUI.jaxx 2015-05-18 09:52:01 UTC (rev 4226)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationGroupUI.jaxx 2015-05-20 12:09:09 UTC (rev 4227)
@@ -39,14 +39,7 @@
<fr.ifremer.isisfish.entities.PopulationGroup id='populationGroup' javaBean='null'/>
- <import>
- fr.ifremer.isisfish.entities.PopulationGroup
- fr.ifremer.isisfish.entities.Population
- org.nuiton.math.matrix.MatrixND
- java.beans.PropertyChangeEvent
- java.beans.PropertyChangeListener
- fr.ifremer.isisfish.ui.models.common.GenericComboModel
- </import>
+ <PopulationGroupHandler id="handler" />
<BeanValidator id='validator' context="group"
bean='{getBean()}' beanClass='fr.ifremer.isisfish.entities.Population'
@@ -63,78 +56,16 @@
valid="{validator.isValid() && validatorGroup.isValid()}" />
<script><![CDATA[
-protected void $afterCompleteSetup() {
- addPropertyChangeListener(PROPERTY_BEAN, new PropertyChangeListener() {
- public void propertyChange(PropertyChangeEvent evt) {
-
- GenericComboModel<PopulationGroup> groupModel = new GenericComboModel<>();
-
- if (evt.getNewValue() == null) {
- setPopulationGroup(null);
- }
- if (evt.getNewValue() != null) {
- groupModel.setElementList(getBean().getPopulationGroup());
- }
-
- populationGroupPopulationGroupComboBox.setModel(groupModel);
- }
- });
-
- addPropertyChangeListener(PROPERTY_POPULATION_GROUP, new PropertyChangeListener() {
- public void propertyChange(PropertyChangeEvent evt) {
- if (evt.getNewValue() == null) {
- fieldPopulationGroupMeanWeight.setText("");
- fieldPopulationGroupPrice.setText("");
- fieldPopulationGroupReproductionRate.setText("");
- fieldPopulationGroupMaturityOgive.setText("");
- fieldPopulationGroupAge.setText("");
- fieldPopulationGroupMinLength.setText("");
- fieldPopulationGroupMaxLength.setText("");
- fieldPopulationGroupComment.setText("");
- fieldPopulationGroupNaturalDeathRate.setMatrix(null);
- }
- if (evt.getNewValue() != null) {
-
- }
- }
- });
-}
-
-@Override
-public void resetChangeModel() {
- changeModel.setStayChanged(false);
-}
-
-protected void setNaturalDeathRateMatrix() {
- try {
- Population population = getBean();
- MatrixND naturalDeathRateMatrix = population.getNaturalDeathRateMatrix();
-
- // extract only line for this population group
- MatrixND naturalDeathRateMatrix2 = naturalDeathRateMatrix.getSubMatrix(0, getPopulationGroup());
- fieldPopulationGroupNaturalDeathRate.setMatrix(naturalDeathRateMatrix2.copy());
- } catch (Exception e) {
- // can happen if population has no zone yet
- // TODO maybe display a message
- if (log.isWarnEnabled()) {
- log.warn("No zone defined for this population group", e);
- }
+ protected void $afterCompleteSetup() {
+ handler.init(this);
}
-}
-/**
- * Called on PopulationGroup combo box selection.
- */
-protected void populationGroupChanged() {
- PopulationGroup selectedPopulationGroup = (PopulationGroup)populationGroupPopulationGroupComboBox.getSelectedItem();
- setPopulationGroup(selectedPopulationGroup);
- if (selectedPopulationGroup != null) {
- getSaveVerifier().addCurrentEntity(selectedPopulationGroup);
- setNaturalDeathRateMatrix();
+ @Override
+ public void resetChangeModel() {
+ changeModel.setStayChanged(false);
}
-}
- ]]>
- </script>
+ ]]></script>
+
<JPanel id="body">
<Table>
<row>
@@ -144,7 +75,7 @@
<cell columns='2' fill='horizontal' weightx='1.0'>
<JComboBox id='populationGroupPopulationGroupComboBox'
genericType="fr.ifremer.isisfish.entities.PopulationGroup"
- onActionPerformed='populationGroupChanged()' enabled='{isActive()}'/>
+ onActionPerformed='handler.populationGroupChanged()' enabled='{isActive()}'/>
</cell>
</row>
<row>
Added: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationHandler.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationHandler.java (rev 0)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationHandler.java 2015-05-20 12:09:09 UTC (rev 4227)
@@ -0,0 +1,46 @@
+/*
+ * #%L
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2015 Ifremer, Codelutin, Chatellier Eric
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+package fr.ifremer.isisfish.ui.input.population;
+
+import static org.nuiton.i18n.I18n.n;
+import static org.nuiton.i18n.I18n.t;
+
+import fr.ifremer.isisfish.ui.input.InputContentHandler;
+
+/**
+ * Population handler.
+ */
+public class PopulationHandler extends InputContentHandler<PopulationUI> {
+
+ protected void init(final PopulationUI inputContentUI) {
+ super.init(inputContentUI);
+
+ inputContentUI.setButtonTitle(t("isisfish.input.continueGears"));
+ inputContentUI.setNextPath(n("isisfish.input.tree.gears"));
+
+ // install change listener
+ // (depends on sensitivity can't be done on constructor)
+ inputContentUI.installChangeListener(inputContentUI.populationTab);
+ }
+}
Property changes on: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationHandler.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationEmigrationHandler.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationEmigrationHandler.java (rev 0)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationEmigrationHandler.java 2015-05-20 12:09:09 UTC (rev 4227)
@@ -0,0 +1,122 @@
+/*
+ * #%L
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2015 Ifremer, Codelutin, Chatellier Eric
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+package fr.ifremer.isisfish.ui.input.population;
+
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+
+import org.nuiton.math.matrix.MatrixND;
+import org.nuiton.math.matrix.gui.MatrixPanelEvent;
+
+import fr.ifremer.isisfish.entities.PopulationGroup;
+import fr.ifremer.isisfish.entities.PopulationSeasonInfo;
+import fr.ifremer.isisfish.entities.Zone;
+import fr.ifremer.isisfish.ui.input.InputAction;
+import fr.ifremer.isisfish.ui.input.InputContentHandler;
+import fr.ifremer.isisfish.ui.models.common.GenericComboModel;
+
+/**
+ * Population handler.
+ */
+public class PopulationMigrationEmigrationHandler extends InputContentHandler<PopulationMigrationEmigrationUI> {
+
+ protected void init(final PopulationMigrationEmigrationUI inputContentUI) {
+ super.init(inputContentUI);
+
+ inputContentUI.addPropertyChangeListener(PopulationMigrationEmigrationUI.PROPERTY_BEAN, new PropertyChangeListener() {
+ public void propertyChange(PropertyChangeEvent evt) {
+ if (evt.getNewValue() == null) {
+ inputContentUI.fieldPopulationMigrationEmigrationCoefficient.setText("");
+ inputContentUI.populationMigrationEmigrationTable.setMatrix(null);
+ }
+ if (evt.getNewValue() != null) {
+
+ }
+ setFieldPopulationMigrationMigrationGroupChooserModel();
+ setFieldPopulationMigrationMigrationDepartureZoneChooserModel();
+ setAddButton();
+ }
+ });
+ }
+
+ public void init(PopulationSeasonInfo pi) {
+ // add null before, for second to be considered as a changed event
+ // otherwize, setBean has no effect
+ //setPopInfo(null);
+ //setPopInfo(pi);
+ inputContentUI.populationMigrationEmigrationTable.setMatrix(inputContentUI.getPopInfo().getEmigrationMatrix().copy());
+ }
+
+ protected void populationMigrationEmigrationMatrixChanged(MatrixPanelEvent event) {
+ inputContentUI.remove.setEnabled(inputContentUI.populationMigrationEmigrationTable.getTable().getSelectedRow() != -1);
+ if (inputContentUI.popInfo != null) {
+ inputContentUI.popInfo.setMigrationMatrix(inputContentUI.populationMigrationEmigrationTable.getMatrix().clone());
+ }
+ }
+
+ protected void setFieldPopulationMigrationMigrationGroupChooserModel() {
+ GenericComboModel<PopulationGroup> groups = new GenericComboModel<>();
+ if (inputContentUI.getBean() != null && inputContentUI.getBean().getPopulationGroup() != null) {
+ //jaxx.runtime.SwingUtil.fillComboBox(fieldPopulationMigrationEmigrationGroupChooser,getBean().getPopulationGroup(), null, true);
+ groups.setElementList(inputContentUI.getBean().getPopulationGroup());
+ }
+ inputContentUI.fieldPopulationMigrationEmigrationGroupChooser.setModel(groups);
+ }
+
+ protected void setFieldPopulationMigrationMigrationDepartureZoneChooserModel() {
+ GenericComboModel<Zone> zones = new GenericComboModel<>();
+ if (inputContentUI.getBean() != null && inputContentUI.getBean().getPopulationZone() != null) {
+ //jaxx.runtime.SwingUtil.fillComboBox(fieldPopulationMigrationEmigrationDepartureZoneChooser,getBean().getPopulationZone(), null, true);
+ zones.setElementList(inputContentUI.getBean().getPopulationZone());
+ }
+ inputContentUI.fieldPopulationMigrationEmigrationDepartureZoneChooser.setModel(zones);
+ }
+
+ protected void add() {
+ inputContentUI.getContextValue(InputAction.class).addEmigration(inputContentUI.getPopInfo(),
+ (PopulationGroup)inputContentUI.fieldPopulationMigrationEmigrationGroupChooser.getSelectedItem(),
+ (Zone)inputContentUI.fieldPopulationMigrationEmigrationDepartureZoneChooser.getSelectedItem(),
+ Double.parseDouble(inputContentUI.fieldPopulationMigrationEmigrationCoefficient.getText()));
+ inputContentUI.populationMigrationEmigrationTable.setMatrix(inputContentUI.getPopInfo().getEmigrationMatrix().clone());
+ }
+
+ protected void remove() {
+ int row = inputContentUI.populationMigrationEmigrationTable.getTable().getSelectedRow();
+ if (row != -1) {
+ Object group = inputContentUI.populationMigrationEmigrationTable.getTable().getValueAt(row, 0);
+ Object arrival = inputContentUI.populationMigrationEmigrationTable.getTable().getValueAt(row, 1);
+
+ MatrixND mat = inputContentUI.popInfo.getEmigrationMatrix().clone();
+ mat.setValue(group, arrival, 0);
+ inputContentUI.popInfo.setEmigrationMatrix(mat);
+ inputContentUI.populationMigrationEmigrationTable.setMatrix(inputContentUI.getPopInfo().getEmigrationMatrix().copy());
+ }
+ }
+
+ protected void setAddButton() {
+ inputContentUI.add.setEnabled(inputContentUI.isActive() && inputContentUI.fieldPopulationMigrationEmigrationGroupChooser.getSelectedItem() != null
+ && inputContentUI.fieldPopulationMigrationEmigrationDepartureZoneChooser.getSelectedItem() != null
+ && !inputContentUI.fieldPopulationMigrationEmigrationCoefficient.getText().equals(""));
+ }
+}
Property changes on: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationEmigrationHandler.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationEmigrationUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationEmigrationUI.jaxx 2015-05-18 09:52:01 UTC (rev 4226)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationEmigrationUI.jaxx 2015-05-20 12:09:09 UTC (rev 4227)
@@ -28,97 +28,14 @@
<fr.ifremer.isisfish.entities.Population id='bean' javaBean='null'/>
<fr.ifremer.isisfish.entities.PopulationSeasonInfo id='popInfo' javaBean='null'/>
- <import>
- fr.ifremer.isisfish.entities.Population
- fr.ifremer.isisfish.entities.PopulationGroup
- fr.ifremer.isisfish.entities.PopulationSeasonInfo
- fr.ifremer.isisfish.entities.Zone
- org.nuiton.math.matrix.MatrixND
- org.nuiton.math.matrix.gui.MatrixPanelEvent
- java.beans.PropertyChangeEvent
- java.beans.PropertyChangeListener
- org.nuiton.math.matrix.gui.MatrixPanelListener
- fr.ifremer.isisfish.ui.input.InputAction
- fr.ifremer.isisfish.ui.models.common.GenericComboModel
- </import>
+ <PopulationMigrationEmigrationHandler id="handler" />
<script><![CDATA[
-protected void $afterCompleteSetup() {
- addPropertyChangeListener(PROPERTY_BEAN, new PropertyChangeListener() {
- public void propertyChange(PropertyChangeEvent evt) {
- if (evt.getNewValue() == null) {
- fieldPopulationMigrationEmigrationCoefficient.setText("");
- populationMigrationEmigrationTable.setMatrix(null);
- }
- if (evt.getNewValue() != null) {
-
- }
- setFieldPopulationMigrationMigrationGroupChooserModel();
- setFieldPopulationMigrationMigrationDepartureZoneChooserModel();
- setAddButton();
- }
- });
-}
-
-public void init(PopulationSeasonInfo pi){
- // add null before, for second to be considered as a changed event
- // otherwize, setBean has no effect
- //setPopInfo(null);
- //setPopInfo(pi);
- populationMigrationEmigrationTable.setMatrix(getPopInfo().getEmigrationMatrix().copy());
-}
-
-protected void populationMigrationEmigrationMatrixChanged(MatrixPanelEvent event) {
- remove.setEnabled(populationMigrationEmigrationTable.getTable().getSelectedRow() != -1);
- if (popInfo != null) {
- popInfo.setMigrationMatrix(populationMigrationEmigrationTable.getMatrix().clone());
+ protected void $afterCompleteSetup() {
+ handler.init(this);
}
-}
+ ]]></script>
-protected void setFieldPopulationMigrationMigrationGroupChooserModel() {
- GenericComboModel<PopulationGroup> groups = new GenericComboModel<>();
- if (getBean() != null && getBean().getPopulationGroup() != null) {
- //jaxx.runtime.SwingUtil.fillComboBox(fieldPopulationMigrationEmigrationGroupChooser,getBean().getPopulationGroup(), null, true);
- groups.setElementList(getBean().getPopulationGroup());
- }
- fieldPopulationMigrationEmigrationGroupChooser.setModel(groups);
-}
-protected void setFieldPopulationMigrationMigrationDepartureZoneChooserModel() {
- GenericComboModel<Zone> zones = new GenericComboModel<>();
- if (getBean() != null && getBean().getPopulationZone() != null){
- //jaxx.runtime.SwingUtil.fillComboBox(fieldPopulationMigrationEmigrationDepartureZoneChooser,getBean().getPopulationZone(), null, true);
- zones.setElementList(getBean().getPopulationZone());
- }
- fieldPopulationMigrationEmigrationDepartureZoneChooser.setModel(zones);
-}
-protected void add() {
- getContextValue(InputAction.class).addEmigration(
- getPopInfo(),
- (PopulationGroup) fieldPopulationMigrationEmigrationGroupChooser.getSelectedItem(),
- (Zone) fieldPopulationMigrationEmigrationDepartureZoneChooser.getSelectedItem(),
- Double.parseDouble(fieldPopulationMigrationEmigrationCoefficient.getText()));
- populationMigrationEmigrationTable.setMatrix(getPopInfo().getEmigrationMatrix().clone());
-}
-
-protected void remove() {
- int row = populationMigrationEmigrationTable.getTable().getSelectedRow();
- if (row != -1) {
- Object group = populationMigrationEmigrationTable.getTable().getValueAt(row, 0);
- Object arrival = populationMigrationEmigrationTable.getTable().getValueAt(row, 1);
-
- MatrixND mat = popInfo.getEmigrationMatrix().clone();
- mat.setValue(group, arrival, 0);
- popInfo.setEmigrationMatrix(mat);
- populationMigrationEmigrationTable.setMatrix(getPopInfo().getEmigrationMatrix().copy());
- }
-}
-protected void setAddButton() {
- add.setEnabled(isActive()
- && fieldPopulationMigrationEmigrationGroupChooser.getSelectedItem() != null
- && fieldPopulationMigrationEmigrationDepartureZoneChooser.getSelectedItem() != null
- && !fieldPopulationMigrationEmigrationCoefficient.getText().equals(""));
-}
-]]></script>
<JPanel id="body">
<Table>
<row>
@@ -128,13 +45,13 @@
<cell fill='horizontal' weightx='0.5'>
<JComboBox id="fieldPopulationMigrationEmigrationGroupChooser"
genericType="fr.ifremer.isisfish.entities.PopulationGroup"
- enabled='{isActive()}' onItemStateChanged='setAddButton()'/>
+ enabled='{isActive()}' onItemStateChanged='handler.setAddButton()'/>
</cell>
<cell>
<JLabel text="isisfish.populationMigrationEmigration.coefficient" enabled='{isActive()}'/>
</cell>
<cell fill='horizontal' weightx='0.5'>
- <JTextField id="fieldPopulationMigrationEmigrationCoefficient" enabled='{isActive()}' onKeyReleased='setAddButton()'/>
+ <JTextField id="fieldPopulationMigrationEmigrationCoefficient" enabled='{isActive()}' onKeyReleased='handler.setAddButton()'/>
</cell>
</row>
<row>
@@ -144,7 +61,7 @@
<cell fill='horizontal' weightx='0.5'>
<JComboBox id="fieldPopulationMigrationEmigrationDepartureZoneChooser"
genericType="fr.ifremer.isisfish.entities.Zone"
- enabled='{isActive()}' onItemStateChanged='setAddButton()'/>
+ enabled='{isActive()}' onItemStateChanged='handler.setAddButton()'/>
</cell>
<cell columns='2' fill='horizontal' weightx='0.5'>
<JPanel/>
@@ -152,7 +69,7 @@
</row>
<row columns='4'>
<cell fill='horizontal' weightx='1.0'>
- <JButton id="add" text="isisfish.common.add" onActionPerformed='add()'
+ <JButton id="add" text="isisfish.common.add" onActionPerformed='handler.add()'
enabled='false'/>
</cell>
</row>
@@ -160,13 +77,13 @@
<cell fill='both' weightx='1.0' weighty='1.0'>
<org.nuiton.math.matrix.gui.MatrixPanelEditor id='populationMigrationEmigrationTable'
linearModel="true" enabled='{isActive()}'
- onMatrixChanged="populationMigrationEmigrationMatrixChanged(event)"/>
+ onMatrixChanged="handler.populationMigrationEmigrationMatrixChanged(event)"/>
</cell>
</row>
<row>
<cell columns='4' fill='horizontal' weightx='1.0'>
<JButton id="remove" text="isisfish.common.remove"
- onActionPerformed='remove()' enabled='{isActive()}'/>
+ onActionPerformed='handler.remove()' enabled='{isActive()}'/>
</cell>
</row>
</Table>
Added: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationEquationHandler.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationEquationHandler.java (rev 0)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationEquationHandler.java 2015-05-20 12:09:09 UTC (rev 4227)
@@ -0,0 +1,41 @@
+/*
+ * #%L
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2015 Ifremer, Codelutin, Chatellier Eric
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+package fr.ifremer.isisfish.ui.input.population;
+
+import fr.ifremer.isisfish.entities.PopulationSeasonInfo;
+import fr.ifremer.isisfish.ui.input.InputContentHandler;
+
+/**
+ * Population handler.
+ */
+public class PopulationMigrationEquationHandler extends InputContentHandler<PopulationMigrationEquationUI> {
+
+ protected void init(final PopulationMigrationEquationUI inputContentUI) {
+ super.init(inputContentUI);
+ }
+
+ public void init(PopulationSeasonInfo pi) {
+
+ }
+}
Property changes on: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationEquationHandler.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationEquationUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationEquationUI.jaxx 2015-05-18 09:52:01 UTC (rev 4226)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationEquationUI.jaxx 2015-05-20 12:09:09 UTC (rev 4227)
@@ -29,24 +29,20 @@
<fr.ifremer.isisfish.entities.PopulationSeasonInfo id='popInfo' javaBean='null'/>
- <import>
- fr.ifremer.isisfish.entities.PopulationSeasonInfo;
- fr.ifremer.isisfish.entities.Population;
- </import>
+ <PopulationMigrationEquationHandler id="handler" />
<script><![CDATA[
-public void init(PopulationSeasonInfo populationSeasonInfo) {
- // add null before, for second to be considered as a changed event
- // otherwize, setBean has no effect
- //setPopInfo(null);
- //setPopInfo(populationSeasonInfo);
-}
+ protected void $afterCompleteSetup() {
+ handler.init(this);
+ }
+ /*public void init(PopulationSeasonInfo populationSeasonInfo) {
+ // add null before, for second to be considered as a changed event
+ // otherwize, setBean has no effect
+ //setPopInfo(null);
+ //setPopInfo(populationSeasonInfo);
+ }*/
+ ]]></script>
-/*public void refresh() {
- getSaveVerifier().addCurrentPanel(immigrationEquation, emigrationEquation, migrationEquation);
-}*/
- ]]>
- </script>
<JPanel id="body">
<Table>
<row>
Added: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationHandler.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationHandler.java (rev 0)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationHandler.java 2015-05-20 12:09:09 UTC (rev 4227)
@@ -0,0 +1,115 @@
+/*
+ * #%L
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2015 Ifremer, Codelutin, Chatellier Eric
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+package fr.ifremer.isisfish.ui.input.population;
+
+import java.awt.CardLayout;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+
+import fr.ifremer.isisfish.entities.PopulationSeasonInfo;
+import fr.ifremer.isisfish.ui.input.InputContentHandler;
+import fr.ifremer.isisfish.ui.models.common.GenericComboModel;
+
+/**
+ * Population handler.
+ */
+public class PopulationMigrationHandler extends InputContentHandler<PopulationMigrationUI> {
+
+ protected void init(final PopulationMigrationUI inputContentUI) {
+ super.init(inputContentUI);
+
+ inputContentUI.addPropertyChangeListener(PopulationMigrationUI.PROPERTY_BEAN, new PropertyChangeListener() {
+ public void propertyChange(PropertyChangeEvent evt) {
+ if (evt.getNewValue() == null) {
+ inputContentUI.fieldPopulationMigrationComment.setText("");
+ inputContentUI.fieldUseEquationMigration.setSelected(false);
+ }
+ if (evt.getNewValue() != null) {
+
+ }
+ refresh();
+ }
+ });
+ }
+
+ public void refresh() {
+ //Population population = inputContentUI.getSaveVerifier().getEntity(Population.class);
+
+ // add null before, for second to be considered as a changed event
+ // otherwize, setBean has no effect
+ //setBean(null);
+ //setBean(population);
+
+ // refresh psi list in combo box
+ GenericComboModel<PopulationSeasonInfo> model = (GenericComboModel<PopulationSeasonInfo>)inputContentUI.fieldPopulationMigrationSeasonChooser.getModel();
+ if (inputContentUI.getBean() != null) {
+ PopulationSeasonInfo previousSelected = (PopulationSeasonInfo)model.getSelectedItem();
+ model.setElementList(inputContentUI.getBean().getPopulationSeasonInfo());
+
+ // do this to keep selected after cancel/refresh
+ if (previousSelected != null) {
+ for (PopulationSeasonInfo psi : inputContentUI.getBean().getPopulationSeasonInfo()) {
+ if (psi.getTopiaId().equals(previousSelected.getTopiaId())) {
+ model.setSelectedItem(psi);
+ }
+ }
+ }
+
+ seasonChanged();
+ } else {
+ model.setElementList(null);
+ }
+ }
+
+ protected void seasonChanged() {
+ GenericComboModel<PopulationSeasonInfo> model = (GenericComboModel<PopulationSeasonInfo>)inputContentUI.fieldPopulationMigrationSeasonChooser.getModel();
+ PopulationSeasonInfo selectedPSI = (PopulationSeasonInfo)model.getSelectedItem();
+ inputContentUI.setPopInfo(selectedPSI);
+ if (inputContentUI.getPopInfo() != null) {
+ inputContentUI.getSaveVerifier().addCurrentEntity(inputContentUI.getPopInfo());
+ inputContentUI.populationMigrationEquationUI.getHandler().init(inputContentUI.getPopInfo());
+ inputContentUI.populationMigrationMigrationUI.getHandler().init(inputContentUI.getPopInfo());
+ inputContentUI.populationMigrationImmigrationUI.getHandler().init(inputContentUI.getPopInfo());
+ inputContentUI.populationMigrationEmigrationUI.getHandler().init(inputContentUI.getPopInfo());
+ }
+ refreshHidablePanel();
+ }
+
+ protected void useEquationChanged() {
+ inputContentUI.getPopInfo().setUseEquationMigration(inputContentUI.fieldUseEquationMigration.isSelected());
+ refreshHidablePanel();
+ }
+
+ protected void refreshHidablePanel() {
+ if (inputContentUI.getPopInfo() != null) {
+ if (inputContentUI.getPopInfo().isUseEquationMigration()) {
+ inputContentUI.fieldUseEquationMigration.setSelected(true);
+ ((CardLayout)inputContentUI.hidablePanel.getLayout()).show(inputContentUI.hidablePanel, "fieldUseEquation");
+ } else {
+ inputContentUI.fieldUseEquationMigration.setSelected(false);
+ ((CardLayout)inputContentUI.hidablePanel.getLayout()).show(inputContentUI.hidablePanel, "fieldUseMatrix");
+ }
+ }
+ }
+}
Property changes on: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationHandler.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationImmigrationHandler.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationImmigrationHandler.java (rev 0)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationImmigrationHandler.java 2015-05-20 12:09:09 UTC (rev 4227)
@@ -0,0 +1,121 @@
+/*
+ * #%L
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2015 Ifremer, Codelutin, Chatellier Eric
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+package fr.ifremer.isisfish.ui.input.population;
+
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+
+import org.nuiton.math.matrix.MatrixND;
+import org.nuiton.math.matrix.gui.MatrixPanelEvent;
+
+import fr.ifremer.isisfish.entities.PopulationGroup;
+import fr.ifremer.isisfish.entities.PopulationSeasonInfo;
+import fr.ifremer.isisfish.entities.Zone;
+import fr.ifremer.isisfish.ui.input.InputAction;
+import fr.ifremer.isisfish.ui.input.InputContentHandler;
+import fr.ifremer.isisfish.ui.models.common.GenericComboModel;
+
+/**
+ * Population handler.
+ */
+public class PopulationMigrationImmigrationHandler extends InputContentHandler<PopulationMigrationImmigrationUI> {
+
+ protected void init(final PopulationMigrationImmigrationUI inputContentUI) {
+ super.init(inputContentUI);
+
+ inputContentUI.addPropertyChangeListener(PopulationMigrationImmigrationUI.PROPERTY_BEAN, new PropertyChangeListener() {
+ public void propertyChange(PropertyChangeEvent evt) {
+ if (evt.getNewValue() == null) {
+ inputContentUI.fieldPopulationMigrationImmigrationCoefficient.setText("");
+ inputContentUI.populationMigrationImmigrationTable.setMatrix(null);
+ }
+ if (evt.getNewValue() != null) {
+
+ }
+ setFieldPopulationMigrationMigrationGroupChooserModel();
+ setFieldPopulationMigrationMigrationArrivalZoneChooserModel();
+ setAddButton();
+ }
+ });
+ }
+
+ protected void populationMigrationImmigrationMatrixChanged(MatrixPanelEvent event) {
+ if (inputContentUI.getPopInfo() != null) {
+ inputContentUI.getPopInfo().setImmigrationMatrix(inputContentUI.populationMigrationImmigrationTable.getMatrix().clone());
+ }
+ }
+
+ public void init(PopulationSeasonInfo populationSeasonInfo) {
+ // add null before, for second to be considered as a changed event
+ // otherwize, setBean has no effect
+ //setPopInfo(null);
+ //setPopInfo(populationSeasonInfo);
+
+ inputContentUI.populationMigrationImmigrationTable.setMatrix(inputContentUI.getPopInfo().getImmigrationMatrix().copy());
+ }
+
+ protected void setFieldPopulationMigrationMigrationGroupChooserModel() {
+ GenericComboModel<PopulationGroup> groups = new GenericComboModel<>();
+ if (inputContentUI.getBean() != null && inputContentUI.getBean().getPopulationGroup() != null) {
+ groups.setElementList(inputContentUI.getBean().getPopulationGroup());
+ }
+ inputContentUI.fieldPopulationMigrationImmigrationGroupChooser.setModel(groups);
+ }
+
+ protected void setFieldPopulationMigrationMigrationArrivalZoneChooserModel() {
+ GenericComboModel<Zone> zones = new GenericComboModel<>();
+ if (inputContentUI.getBean() != null && inputContentUI.getBean().getPopulationZone() != null) {
+ //jaxx.runtime.SwingUtil.fillComboBox(fieldPopulationMigrationMigrationArrivalZoneChooser,getBean().getPopulationZone(), null, true);
+ zones.setElementList(inputContentUI.getBean().getPopulationZone());
+ }
+ inputContentUI.fieldPopulationMigrationImmigrationArrivalZoneChooser.setModel(zones);
+ }
+
+ protected void add() {
+ inputContentUI.getContextValue(InputAction.class).addImmigration(inputContentUI.getPopInfo(),
+ (PopulationGroup)inputContentUI.fieldPopulationMigrationImmigrationGroupChooser.getSelectedItem(),
+ (Zone)inputContentUI.fieldPopulationMigrationImmigrationArrivalZoneChooser.getSelectedItem(),
+ Double.parseDouble(inputContentUI.fieldPopulationMigrationImmigrationCoefficient.getText()));
+ inputContentUI.populationMigrationImmigrationTable.setMatrix(inputContentUI.getPopInfo().getImmigrationMatrix().clone());
+ }
+
+ protected void remove() {
+ int row = inputContentUI.populationMigrationImmigrationTable.getTable().getSelectedRow();
+ if (row != -1) {
+ Object group = inputContentUI.populationMigrationImmigrationTable.getTable().getValueAt(row, 0);
+ Object departure = inputContentUI.populationMigrationImmigrationTable.getTable().getValueAt(row, 1);
+
+ MatrixND mat = inputContentUI.getPopInfo().getImmigrationMatrix().clone();
+ mat.setValue(group, departure, 0);
+ inputContentUI.getPopInfo().setImmigrationMatrix(mat);
+ inputContentUI.populationMigrationImmigrationTable.setMatrix(inputContentUI.getPopInfo().getImmigrationMatrix().copy());
+ }
+ }
+
+ protected void setAddButton() {
+ inputContentUI.add.setEnabled(inputContentUI.isActive() && inputContentUI.fieldPopulationMigrationImmigrationGroupChooser.getSelectedItem() != null
+ && !inputContentUI.fieldPopulationMigrationImmigrationCoefficient.getText().equals("")
+ && inputContentUI.fieldPopulationMigrationImmigrationArrivalZoneChooser.getSelectedItem() != null);
+ }
+}
Property changes on: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationImmigrationHandler.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationImmigrationUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationImmigrationUI.jaxx 2015-05-18 09:52:01 UTC (rev 4226)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationImmigrationUI.jaxx 2015-05-20 12:09:09 UTC (rev 4227)
@@ -28,97 +28,14 @@
<fr.ifremer.isisfish.entities.Population id='bean' javaBean='null'/>
<fr.ifremer.isisfish.entities.PopulationSeasonInfo id='popInfo' javaBean='null'/>
- <import>
- java.beans.PropertyChangeEvent
- java.beans.PropertyChangeListener
- fr.ifremer.isisfish.entities.Population
- fr.ifremer.isisfish.entities.PopulationGroup
- fr.ifremer.isisfish.entities.PopulationSeasonInfo
- fr.ifremer.isisfish.entities.Zone
- org.nuiton.math.matrix.MatrixND
- org.nuiton.math.matrix.gui.MatrixPanelEvent
- org.nuiton.math.matrix.gui.MatrixPanelListener
- fr.ifremer.isisfish.ui.input.InputAction
- fr.ifremer.isisfish.ui.models.common.GenericComboModel
- </import>
+ <PopulationMigrationImmigrationHandler id="handler" />
<script><![CDATA[
-protected void $afterCompleteSetup() {
- addPropertyChangeListener(PROPERTY_BEAN, new PropertyChangeListener() {
- public void propertyChange(PropertyChangeEvent evt) {
- if (evt.getNewValue() == null) {
- fieldPopulationMigrationImmigrationCoefficient.setText("");
- populationMigrationImmigrationTable.setMatrix(null);
- }
- if (evt.getNewValue() != null) {
-
- }
- setFieldPopulationMigrationMigrationGroupChooserModel();
- setFieldPopulationMigrationMigrationArrivalZoneChooserModel();
- setAddButton();
- }
- });
-}
-
-protected void populationMigrationImmigrationMatrixChanged(MatrixPanelEvent event) {
- if (getPopInfo() != null){
- getPopInfo().setImmigrationMatrix(populationMigrationImmigrationTable.getMatrix().clone());
+ protected void $afterCompleteSetup() {
+ handler.init(this);
}
-}
+ ]]></script>
-public void init(PopulationSeasonInfo populationSeasonInfo) {
- // add null before, for second to be considered as a changed event
- // otherwize, setBean has no effect
- //setPopInfo(null);
- //setPopInfo(populationSeasonInfo);
-
- populationMigrationImmigrationTable.setMatrix(getPopInfo().getImmigrationMatrix().copy());
-}
-
-protected void setFieldPopulationMigrationMigrationGroupChooserModel(){
- GenericComboModel<PopulationGroup> groups = new GenericComboModel<>();
- if (getBean() != null && getBean().getPopulationGroup() != null){
- groups.setElementList(getBean().getPopulationGroup());
- }
- fieldPopulationMigrationImmigrationGroupChooser.setModel(groups);
-}
-protected void setFieldPopulationMigrationMigrationArrivalZoneChooserModel(){
- GenericComboModel<Zone> zones = new GenericComboModel<>();
- if (getBean() != null && getBean().getPopulationZone() != null){
- //jaxx.runtime.SwingUtil.fillComboBox(fieldPopulationMigrationMigrationArrivalZoneChooser,getBean().getPopulationZone(), null, true);
- zones.setElementList(getBean().getPopulationZone());
- }
- fieldPopulationMigrationImmigrationArrivalZoneChooser.setModel(zones);
-}
-protected void add() {
- getContextValue(InputAction.class).addImmigration(getPopInfo(),
- (PopulationGroup) fieldPopulationMigrationImmigrationGroupChooser.getSelectedItem(),
- (Zone) fieldPopulationMigrationImmigrationArrivalZoneChooser.getSelectedItem(),
- Double.parseDouble(fieldPopulationMigrationImmigrationCoefficient.getText()));
- populationMigrationImmigrationTable.setMatrix(getPopInfo().getImmigrationMatrix().clone());
-}
-protected void remove() {
- int row = populationMigrationImmigrationTable.getTable().getSelectedRow();
- if (row != -1) {
- Object group = populationMigrationImmigrationTable.getTable().getValueAt(row, 0);
- Object departure = populationMigrationImmigrationTable.getTable().getValueAt(row, 1);
-
- MatrixND mat = getPopInfo().getImmigrationMatrix().clone();
- mat.setValue(group, departure, 0);
- getPopInfo().setImmigrationMatrix(mat);
- populationMigrationImmigrationTable.setMatrix(getPopInfo().getImmigrationMatrix().copy());
- }
-}
-
-protected void setAddButton() {
- add.setEnabled(isActive() &&
- fieldPopulationMigrationImmigrationGroupChooser.getSelectedItem() != null &&
- !fieldPopulationMigrationImmigrationCoefficient.getText().equals("") &&
- fieldPopulationMigrationImmigrationArrivalZoneChooser.getSelectedItem() != null
- );
-}
- ]]>
- </script>
<JPanel id="body">
<Table>
<row>
@@ -128,13 +45,13 @@
<cell fill='horizontal' weightx='0.5'>
<JComboBox id="fieldPopulationMigrationImmigrationGroupChooser"
genericType="fr.ifremer.isisfish.entities.PopulationGroup"
- enabled='{isActive()}' onActionPerformed='setAddButton()'/>
+ enabled='{isActive()}' onActionPerformed='handler.setAddButton()'/>
</cell>
<cell>
<JLabel text="isisfish.populationMigrationImmigration.coefficient" enabled='{isActive()}'/>
</cell>
<cell fill='horizontal' weightx='0.5'>
- <JTextField id="fieldPopulationMigrationImmigrationCoefficient" enabled='{isActive()}' onKeyReleased='setAddButton()'/>
+ <JTextField id="fieldPopulationMigrationImmigrationCoefficient" enabled='{isActive()}' onKeyReleased='handler.setAddButton()'/>
</cell>
</row>
<row>
@@ -144,7 +61,7 @@
<cell fill='horizontal' weightx='0.5'>
<JComboBox id="fieldPopulationMigrationImmigrationArrivalZoneChooser"
genericType="fr.ifremer.isisfish.entities.Zone"
- enabled='{isActive()}' onActionPerformed='setAddButton()'/>
+ enabled='{isActive()}' onActionPerformed='handler.setAddButton()'/>
</cell>
<cell columns='2' fill='horizontal' weightx='0.5'>
<JPanel/>
@@ -152,7 +69,7 @@
</row>
<row columns='4'>
<cell fill='horizontal' weightx='1.0'>
- <JButton id="add" text="isisfish.common.add" onActionPerformed='add()'
+ <JButton id="add" text="isisfish.common.add" onActionPerformed='handler.add()'
enabled='false'/>
</cell>
</row>
@@ -160,13 +77,13 @@
<cell fill='both' weightx='1.0' weighty='1.0'>
<org.nuiton.math.matrix.gui.MatrixPanelEditor id='populationMigrationImmigrationTable'
linearModel="true" enabled='{isActive()}'
- onMatrixChanged="populationMigrationImmigrationMatrixChanged(event)"/>
+ onMatrixChanged="handler.populationMigrationImmigrationMatrixChanged(event)"/>
</cell>
</row>
<row>
<cell columns='4' fill='horizontal' weightx='1.0'>
<JButton id="remove" text="isisfish.common.remove"
- onActionPerformed='remove()' enabled='{isActive()}'/>
+ onActionPerformed='handler.remove()' enabled='{isActive()}'/>
</cell>
</row>
</Table>
Added: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationMigrationHandler.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationMigrationHandler.java (rev 0)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationMigrationHandler.java 2015-05-20 12:09:09 UTC (rev 4227)
@@ -0,0 +1,132 @@
+/*
+ * #%L
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2015 Ifremer, Codelutin, Chatellier Eric
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+package fr.ifremer.isisfish.ui.input.population;
+
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+
+import org.nuiton.math.matrix.MatrixND;
+import org.nuiton.math.matrix.gui.MatrixPanelEvent;
+
+import fr.ifremer.isisfish.entities.PopulationGroup;
+import fr.ifremer.isisfish.entities.PopulationSeasonInfo;
+import fr.ifremer.isisfish.entities.Zone;
+import fr.ifremer.isisfish.ui.input.InputContentHandler;
+import fr.ifremer.isisfish.ui.models.common.GenericComboModel;
+
+/**
+ * Population handler.
+ */
+public class PopulationMigrationMigrationHandler extends InputContentHandler<PopulationMigrationMigrationUI> {
+
+ protected void init(final PopulationMigrationMigrationUI inputContentUI) {
+ super.init(inputContentUI);
+
+ inputContentUI.addPropertyChangeListener(PopulationMigrationMigrationUI.PROPERTY_BEAN, new PropertyChangeListener() {
+ public void propertyChange(PropertyChangeEvent evt) {
+ if (evt.getNewValue() == null) {
+ inputContentUI.fieldPopulationMigrationMigrationCoefficient.setText("");
+ inputContentUI.populationMigrationMigrationTable.setMatrix(null);
+ }
+ if (evt.getNewValue() != null) {
+
+ }
+ setFieldPopulationMigrationMigrationGroupChooserModel();
+ setFieldPopulationMigrationMigrationDepartureZoneChooserModel();
+ setFieldPopulationMigrationMigrationArrivalZoneChooserModel();
+ setAddButton();
+ }
+ });
+ }
+
+ protected void populationMigrationMigrationMatrixChanged(MatrixPanelEvent event) {
+ if (inputContentUI.getPopInfo() != null) {
+ inputContentUI.getPopInfo().setMigrationMatrix(inputContentUI.populationMigrationMigrationTable.getMatrix().clone());
+ }
+ }
+
+ public void init(PopulationSeasonInfo pi) {
+ // add null before, for second to be considered as a changed event
+ // otherwize, setBean has no effect
+ //setPopInfo(null);
+ //setPopInfo(pi);
+
+ inputContentUI.populationMigrationMigrationTable.setMatrix(inputContentUI.getPopInfo().getMigrationMatrix().copy());
+ }
+
+ protected void setFieldPopulationMigrationMigrationGroupChooserModel() {
+ GenericComboModel<PopulationGroup> groups = new GenericComboModel<>();
+ if (inputContentUI.getBean() != null && inputContentUI.getBean().getPopulationGroup() != null) {
+ groups.setElementList(inputContentUI.getBean().getPopulationGroup());
+ }
+ inputContentUI.fieldPopulationMigrationMigrationGroupChooser.setModel(groups);
+ }
+
+ protected void setFieldPopulationMigrationMigrationDepartureZoneChooserModel() {
+ GenericComboModel<Zone> zones = new GenericComboModel<>();
+ if (inputContentUI.getBean() != null && inputContentUI.getBean().getPopulationZone() != null) {
+ //jaxx.runtime.SwingUtil.fillComboBox(fieldPopulationMigrationMigrationDepartureZoneChooser,getBean().getPopulationZone(), null, true);
+ zones.setElementList(inputContentUI.getBean().getPopulationZone());
+ }
+ inputContentUI.fieldPopulationMigrationMigrationDepartureZoneChooser.setModel(zones);
+ }
+
+ protected void setFieldPopulationMigrationMigrationArrivalZoneChooserModel() {
+ GenericComboModel<Zone> zones = new GenericComboModel<>();
+ if (inputContentUI.getBean() != null && inputContentUI.getBean().getPopulationZone() != null) {
+ //jaxx.runtime.SwingUtil.fillComboBox(fieldPopulationMigrationMigrationArrivalZoneChooser,getBean().getPopulationZone(), null, true);
+ zones.setElementList(inputContentUI.getBean().getPopulationZone());
+ }
+ inputContentUI.fieldPopulationMigrationMigrationArrivalZoneChooser.setModel(zones);
+ }
+
+ protected void add() {
+ inputContentUI.getAction().addMigration(inputContentUI.getPopInfo(), (PopulationGroup)inputContentUI.fieldPopulationMigrationMigrationGroupChooser.getSelectedItem(),
+ (Zone)inputContentUI.fieldPopulationMigrationMigrationDepartureZoneChooser.getSelectedItem(),
+ (Zone)inputContentUI.fieldPopulationMigrationMigrationArrivalZoneChooser.getSelectedItem(),
+ Double.parseDouble(inputContentUI.fieldPopulationMigrationMigrationCoefficient.getText()));
+ inputContentUI.populationMigrationMigrationTable.setMatrix(inputContentUI.getPopInfo().getMigrationMatrix().clone());
+ }
+
+ protected void remove() {
+ int row = inputContentUI.populationMigrationMigrationTable.getTable().getSelectedRow();
+ if (row != -1) {
+ Object group = inputContentUI.populationMigrationMigrationTable.getTable().getValueAt(row, 0);
+ Object departure = inputContentUI.populationMigrationMigrationTable.getTable().getValueAt(row, 1);
+ Object arrival = inputContentUI.populationMigrationMigrationTable.getTable().getValueAt(row, 2);
+
+ MatrixND mat = inputContentUI.getPopInfo().getMigrationMatrix().clone();
+ mat.setValue(group, departure, arrival, 0);
+ inputContentUI.getPopInfo().setMigrationMatrix(mat);
+ inputContentUI.populationMigrationMigrationTable.setMatrix(inputContentUI.getPopInfo().getMigrationMatrix().copy());
+ }
+ }
+
+ protected void setAddButton() {
+ inputContentUI.add.setEnabled(inputContentUI.isActive() && inputContentUI.fieldPopulationMigrationMigrationGroupChooser.getSelectedItem() != null
+ && !inputContentUI.fieldPopulationMigrationMigrationCoefficient.getText().equals("")
+ && inputContentUI.fieldPopulationMigrationMigrationDepartureZoneChooser.getSelectedItem() != null
+ && inputContentUI.fieldPopulationMigrationMigrationArrivalZoneChooser.getSelectedItem() != null);
+ }
+}
Property changes on: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationMigrationHandler.java
___________________________________________________________________
Added: svn:eol-style
+ native
Added: svn:keywords
+ Author Date Id Revision HeadURL
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationMigrationUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationMigrationUI.jaxx 2015-05-18 09:52:01 UTC (rev 4226)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationMigrationUI.jaxx 2015-05-20 12:09:09 UTC (rev 4227)
@@ -33,107 +33,14 @@
<Boolean id='zoneArrivalSelected' javaBean='false'/>
<Boolean id='coefNonVide' javaBean='false'/>
- <import>
- fr.ifremer.isisfish.entities.PopulationSeasonInfo
- fr.ifremer.isisfish.entities.Population
- fr.ifremer.isisfish.entities.PopulationGroup
- fr.ifremer.isisfish.entities.PopulationSeasonInfo
- fr.ifremer.isisfish.entities.Zone
- org.nuiton.math.matrix.MatrixND
- org.nuiton.math.matrix.gui.MatrixPanelEvent
- java.beans.PropertyChangeEvent
- java.beans.PropertyChangeListener
- org.nuiton.math.matrix.gui.MatrixPanelListener
- javax.swing.text.Document
- fr.ifremer.isisfish.ui.models.common.GenericComboModel
- </import>
+ <PopulationMigrationMigrationHandler id="handler" />
<script><![CDATA[
-protected void $afterCompleteSetup() {
- addPropertyChangeListener(PROPERTY_BEAN, new PropertyChangeListener() {
- public void propertyChange(PropertyChangeEvent evt) {
- if (evt.getNewValue() == null) {
- fieldPopulationMigrationMigrationCoefficient.setText("");
- populationMigrationMigrationTable.setMatrix(null);
- }
- if (evt.getNewValue() != null) {
-
- }
- setFieldPopulationMigrationMigrationGroupChooserModel();
- setFieldPopulationMigrationMigrationDepartureZoneChooserModel();
- setFieldPopulationMigrationMigrationArrivalZoneChooserModel();
- setAddButton();
- }
- });
-}
-
-protected void populationMigrationMigrationMatrixChanged(MatrixPanelEvent event) {
- if (getPopInfo() != null) {
- getPopInfo().setMigrationMatrix(populationMigrationMigrationTable.getMatrix().clone());
+ protected void $afterCompleteSetup() {
+ handler.init(this);
}
-}
-public void init(PopulationSeasonInfo pi) {
- // add null before, for second to be considered as a changed event
- // otherwize, setBean has no effect
- //setPopInfo(null);
- //setPopInfo(pi);
+ ]]></script>
- populationMigrationMigrationTable.setMatrix(getPopInfo().getMigrationMatrix().copy());
-}
-
-protected void setFieldPopulationMigrationMigrationGroupChooserModel() {
- GenericComboModel<PopulationGroup> groups = new GenericComboModel<>();
- if (getBean() != null && getBean().getPopulationGroup() != null){
- groups.setElementList(getBean().getPopulationGroup());
- }
- fieldPopulationMigrationMigrationGroupChooser.setModel(groups);
-}
-protected void setFieldPopulationMigrationMigrationDepartureZoneChooserModel(){
- GenericComboModel<Zone> zones = new GenericComboModel<>();
- if (getBean() != null && getBean().getPopulationZone() != null){
- //jaxx.runtime.SwingUtil.fillComboBox(fieldPopulationMigrationMigrationDepartureZoneChooser,getBean().getPopulationZone(), null, true);
- zones.setElementList(getBean().getPopulationZone());
- }
- fieldPopulationMigrationMigrationDepartureZoneChooser.setModel(zones);
-}
-protected void setFieldPopulationMigrationMigrationArrivalZoneChooserModel(){
- GenericComboModel<Zone> zones = new GenericComboModel<>();
- if (getBean() != null && getBean().getPopulationZone() != null){
- //jaxx.runtime.SwingUtil.fillComboBox(fieldPopulationMigrationMigrationArrivalZoneChooser,getBean().getPopulationZone(), null, true);
- zones.setElementList(getBean().getPopulationZone());
- }
- fieldPopulationMigrationMigrationArrivalZoneChooser.setModel(zones);
-}
-protected void add() {
- getAction().addMigration(getPopInfo(),
- (PopulationGroup) fieldPopulationMigrationMigrationGroupChooser.getSelectedItem(),
- (Zone) fieldPopulationMigrationMigrationDepartureZoneChooser.getSelectedItem(),
- (Zone) fieldPopulationMigrationMigrationArrivalZoneChooser.getSelectedItem(),
- Double.parseDouble(fieldPopulationMigrationMigrationCoefficient.getText()));
- populationMigrationMigrationTable.setMatrix(getPopInfo().getMigrationMatrix().clone());
-}
-protected void remove() {
- int row = populationMigrationMigrationTable.getTable().getSelectedRow();
- if (row != -1) {
- Object group = populationMigrationMigrationTable.getTable().getValueAt(row, 0);
- Object departure = populationMigrationMigrationTable.getTable().getValueAt(row, 1);
- Object arrival = populationMigrationMigrationTable.getTable().getValueAt(row, 2);
-
- MatrixND mat = getPopInfo().getMigrationMatrix().clone();
- mat.setValue(group, departure, arrival, 0);
- getPopInfo().setMigrationMatrix(mat);
- populationMigrationMigrationTable.setMatrix(getPopInfo().getMigrationMatrix().copy());
- }
-}
-protected void setAddButton() {
- add.setEnabled(isActive() &&
- fieldPopulationMigrationMigrationGroupChooser.getSelectedItem() != null &&
- !fieldPopulationMigrationMigrationCoefficient.getText().equals("") &&
- fieldPopulationMigrationMigrationDepartureZoneChooser.getSelectedItem() != null &&
- fieldPopulationMigrationMigrationArrivalZoneChooser.getSelectedItem() != null);
-}
- ]]>
- </script>
<JPanel id="body">
<Table>
<row>
@@ -142,16 +49,17 @@
</cell>
<cell fill='horizontal' weightx='0.5'>
<JComboBox id="fieldPopulationMigrationMigrationGroupChooser" enabled='{isActive()}'
- onItemStateChanged="setAddButton()"/>
+ genericType="fr.ifremer.isisfish.entities.PopulationGroup"
+ onItemStateChanged="handler.setAddButton()"/>
</cell>
<cell>
<JLabel text="isisfish.populationMigrationMigration.coefficient" enabled='{isActive()}'/>
</cell>
<cell fill='horizontal' weightx='0.5'>
<JTextField id="fieldPopulationMigrationMigrationCoefficient" enabled='{isActive()}'/>
- <Document initializer="fieldPopulationMigrationMigrationCoefficient.getDocument()"
- onInsertUpdate='setAddButton()'
- onRemoveUpdate='setAddButton()' />
+ <javax.swing.text.Document initializer="fieldPopulationMigrationMigrationCoefficient.getDocument()"
+ onInsertUpdate='handler.setAddButton()'
+ onRemoveUpdate='handler.setAddButton()' />
</cell>
</row>
<row>
@@ -161,7 +69,7 @@
<cell fill='horizontal' weightx='0.5'>
<JComboBox id="fieldPopulationMigrationMigrationDepartureZoneChooser" enabled='{isActive()}'
genericType="fr.ifremer.isisfish.entities.Zone"
- onItemStateChanged="setAddButton()"/>
+ onItemStateChanged="handler.setAddButton()"/>
</cell>
<cell>
<JLabel text="isisfish.populationMigrationMigration.arrivalZone" enabled='{isActive()}'/>
@@ -169,25 +77,25 @@
<cell fill='horizontal' weightx='0.5'>
<JComboBox id="fieldPopulationMigrationMigrationArrivalZoneChooser" enabled='{isActive()}'
genericType="fr.ifremer.isisfish.entities.Zone"
- onItemStateChanged="setAddButton()"/>
+ onItemStateChanged="handler.setAddButton()"/>
</cell>
</row>
<row columns='4'>
<cell fill='horizontal' weightx='1.0'>
- <JButton id="add" text="isisfish.common.add" onActionPerformed='add()' enabled='false'/>
+ <JButton id="add" text="isisfish.common.add" onActionPerformed='handler.add()' enabled='false'/>
</cell>
</row>
<row columns='4'>
<cell fill='both' weightx='1.0' weighty='1.0'>
<org.nuiton.math.matrix.gui.MatrixPanelEditor id='populationMigrationMigrationTable'
linearModel='{true}' enabled='{isActive()}'
- onMatrixChanged="populationMigrationMigrationMatrixChanged(event)" />
+ onMatrixChanged="handler.populationMigrationMigrationMatrixChanged(event)" />
</cell>
</row>
<row>
<cell columns='4' fill='horizontal' weightx='1.0'>
<JButton id="remove" text="isisfish.common.remove"
- onActionPerformed='remove()' enabled='{isActive()}' />
+ onActionPerformed='handler.remove()' enabled='{isActive()}' />
</cell>
</row>
</Table>
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationUI.jaxx 2015-05-18 09:52:01 UTC (rev 4226)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationUI.jaxx 2015-05-20 12:09:09 UTC (rev 4227)
@@ -5,7 +5,7 @@
$Id$
$HeadURL$
%%
- Copyright (C) 2009 - 2011 Ifremer, Code Lutin, Chatellier Eric
+ Copyright (C) 2009 - 2015 Ifremer, Code Lutin, Chatellier Eric
%%
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as
@@ -29,16 +29,7 @@
<fr.ifremer.isisfish.entities.PopulationSeasonInfo id='popInfo' javaBean='null'/>
- <import>
- static org.nuiton.i18n.I18n.t
- fr.ifremer.isisfish.entities.PopulationSeasonInfo;
- fr.ifremer.isisfish.entities.Population;
- fr.ifremer.isisfish.ui.models.common.GenericComboModel;
- fr.ifremer.isisfish.ui.input.renderer.PopulationSeasonInfoComboRenderer;
- java.beans.PropertyChangeEvent;
- java.beans.PropertyChangeListener;
- java.awt.CardLayout
- </import>
+ <PopulationMigrationHandler id="handler" />
<BeanValidator id='validator' context="migration"
bean='{getBean()}' beanClass='fr.ifremer.isisfish.entities.Population'
@@ -54,92 +45,22 @@
valid="{validator.isValid() && validatorSeason.isValid()}" />
<script><![CDATA[
-protected void $afterCompleteSetup() {
- addPropertyChangeListener(PROPERTY_BEAN, new PropertyChangeListener() {
- public void propertyChange(PropertyChangeEvent evt) {
- if (evt.getNewValue() == null) {
- fieldPopulationMigrationComment.setText("");
- fieldUseEquationMigration.setSelected(false);
- }
- if (evt.getNewValue() != null) {
+ protected void $afterCompleteSetup() {
+ handler.init(this);
+ }
- }
- refresh();
- }
- });
-}
-
-@Override
-public void resetChangeModel() {
- changeModel.setStayChanged(false);
-}
-
-public void refresh() {
- Population population = getSaveVerifier().getEntity(Population.class);
-
- // add null before, for second to be considered as a changed event
- // otherwize, setBean has no effect
- //setBean(null);
- //setBean(population);
-
- // refresh psi list in combo box
- GenericComboModel<PopulationSeasonInfo> model = (GenericComboModel<PopulationSeasonInfo>)fieldPopulationMigrationSeasonChooser.getModel();
- if (getBean() != null) {
- PopulationSeasonInfo previousSelected = (PopulationSeasonInfo)model.getSelectedItem();
- model.setElementList(getBean().getPopulationSeasonInfo());
-
- // do this to keep selected after cancel/refresh
- if (previousSelected != null) {
- for (PopulationSeasonInfo psi : getBean().getPopulationSeasonInfo()) {
- if (psi.getTopiaId().equals(previousSelected.getTopiaId())) {
- model.setSelectedItem(psi);
- }
- }
- }
-
- seasonChanged();
+ @Override
+ public void resetChangeModel() {
+ changeModel.setStayChanged(false);
}
- else {
- model.setElementList(null);
- }
-}
-protected void seasonChanged() {
- GenericComboModel<PopulationSeasonInfo> model = (GenericComboModel<PopulationSeasonInfo>)fieldPopulationMigrationSeasonChooser.getModel();
- PopulationSeasonInfo selectedPSI = (PopulationSeasonInfo)model.getSelectedItem();
- setPopInfo(selectedPSI);
- if (getPopInfo() != null) {
- getSaveVerifier().addCurrentEntity(getPopInfo());
- populationMigrationEquationUI.init(getPopInfo());
- populationMigrationMigrationUI.init(getPopInfo());
- populationMigrationImmigrationUI.init(getPopInfo());
- populationMigrationEmigrationUI.init(getPopInfo());
+ @Override
+ public void setLayer(boolean active) {
+ super.setLayer(active);
+ populationMigrationEquationUI.setLayer(active);
}
- refreshHidablePanel();
-}
-protected void useEquationChanged() {
- getPopInfo().setUseEquationMigration(fieldUseEquationMigration.isSelected());
- refreshHidablePanel();
-}
-protected void refreshHidablePanel() {
- if (getPopInfo() != null) {
- if (getPopInfo().isUseEquationMigration()) {
- fieldUseEquationMigration.setSelected(true);
- ((CardLayout) hidablePanel.getLayout()).show(hidablePanel, "fieldUseEquation");
- }
- else {
- fieldUseEquationMigration.setSelected(false);
- ((CardLayout) hidablePanel.getLayout()).show(hidablePanel, "fieldUseMatrix");
- }
- }
-}
-@Override
-public void setLayer(boolean active) {
- super.setLayer(active);
- populationMigrationEquationUI.setLayer(active);
-}
- ]]>
- </script>
+ ]]></script>
+
<JPanel id='body'>
<Table>
<row>
@@ -149,22 +70,22 @@
<cell fill='horizontal' weightx='1.0'>
<JComboBox id="fieldPopulationMigrationSeasonChooser"
genericType="PopulationSeasonInfo"
- model='{new GenericComboModel<PopulationSeasonInfo>()}'
+ model='{new fr.ifremer.isisfish.ui.models.common.GenericComboModel<PopulationSeasonInfo>()}'
renderer="{new PopulationSeasonInfoComboRenderer()}"
- onActionPerformed='seasonChanged()'
+ onActionPerformed='handler.seasonChanged()'
enabled='{isActive()}'/>
</cell>
</row>
<row>
<cell columns='2' anchor='west'>
<JCheckBox id="fieldUseEquationMigration" selected='{getPopInfo().isUseEquationMigration()}'
- text="isisfish.populationMigration.useEquation" onActionPerformed='useEquationChanged()'
+ text="isisfish.populationMigration.useEquation" onActionPerformed='handler.useEquationChanged()'
enabled='{getPopInfo() != null}' decorator='boxed'/>
</cell>
</row>
<row>
<cell columns='2' fill='both' weightx='1.0' weighty='0.7'>
- <JPanel id="hidablePanel" layout='{new CardLayout()}'>
+ <JPanel id="hidablePanel" layout='{new java.awt.CardLayout()}'>
<JTabbedPane id="fieldUseMatrix" constraints='"fieldUseMatrix"' enabled='{getPopInfo() != null}'>
<tab title='{t("isisfish.populationMigrationMigration.title")}'>
<PopulationMigrationMigrationUI id="populationMigrationMigrationUI" constructorParams='this' decorator='boxed'
Added: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationPriceHandler.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationPriceHandler.java (rev 0)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationPriceHandler.java 2015-05-20 12:09:09 UTC (rev 4227)
@@ -0,0 +1,36 @@
+/*
+ * #%L
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2015 Ifremer, Codelutin, Chatellier Eric
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+package fr.ifremer.isisfish.ui.input.population;
+
+import fr.ifremer.isisfish.ui.input.InputContentHandler;
+
+/**
+ * Population handler.
+ */
+public class PopulationPriceHandler extends InputContentHandler<PopulationPriceUI> {
+
+ protected void init(final PopulationPriceUI inputContentUI) {
+ super.init(inputContentUI);
+ }
+}
Property changes on: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationPriceHandler.java
___________________________________________________________________
Added: svn:eol-style
+ native
Added: svn:keywords
+ Author Date Id Revision HeadURL
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationPriceUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationPriceUI.jaxx 2015-05-18 09:52:01 UTC (rev 4226)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationPriceUI.jaxx 2015-05-20 12:09:09 UTC (rev 4227)
@@ -5,7 +5,7 @@
$Id$
$HeadURL$
%%
- Copyright (C) 2009 - 2011 Ifremer, Code Lutin, Chatellier Eric
+ Copyright (C) 2009 - 2015 Ifremer, Code Lutin, Chatellier Eric
%%
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as
@@ -27,9 +27,7 @@
<!-- bean property -->
<fr.ifremer.isisfish.entities.Population id='bean' javaBean='null'/>
- <import>
- fr.ifremer.isisfish.entities.Population;
- </import>
+ <PopulationPriceHandler id="handler" />
<BeanValidator id='validator' context="equation"
bean='{getBean()}' beanClass='fr.ifremer.isisfish.entities.Population'
@@ -37,18 +35,11 @@
</BeanValidator>
<script><![CDATA[
-/*public void refresh() {
- Population population = getSaveVerifier().getEntity(Population.class);
-
- // add null before, for second to be considered as a changed event
- // otherwize, setBean has no effect
- setBean(null);
- setBean(population);
+ protected void $afterCompleteSetup() {
+ handler.init(this);
+ }
+ ]]></script>
- getSaveVerifier().addCurrentPanel(naturalDeathRate, meanWeight, price);
-}*/
- ]]>
- </script>
<JPanel id="body">
<Table>
<row>
Added: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationRecruitmentHandler.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationRecruitmentHandler.java (rev 0)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationRecruitmentHandler.java 2015-05-20 12:09:09 UTC (rev 4227)
@@ -0,0 +1,61 @@
+/*
+ * #%L
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2015 Ifremer, Codelutin, Chatellier Eric
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+package fr.ifremer.isisfish.ui.input.population;
+
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+
+import org.nuiton.math.matrix.gui.MatrixPanelEvent;
+
+import fr.ifremer.isisfish.ui.input.InputContentHandler;
+
+/**
+ * Population handler.
+ */
+public class PopulationRecruitmentHandler extends InputContentHandler<PopulationRecruitmentUI> {
+
+ protected void init(final PopulationRecruitmentUI inputContentUI) {
+ super.init(inputContentUI);
+
+ inputContentUI.addPropertyChangeListener(PopulationRecruitmentUI.PROPERTY_BEAN, new PropertyChangeListener() {
+ public void propertyChange(PropertyChangeEvent evt) {
+ if (evt.getNewValue() == null) {
+ inputContentUI.fieldPopulationMonthGapBetweenReproRecrutement.setText("");
+ inputContentUI.fieldPopulationRecruitmentComment.setText("");
+ }
+ if (evt.getNewValue() != null) {
+
+ }
+ }
+ });
+ }
+
+ protected void populationRecruitmentDistributionMatrixChanged(MatrixPanelEvent event) {
+ if (inputContentUI.getBean() != null){
+ if (inputContentUI.fieldPopulationRecruitmentDistribution.getMatrix() != null){
+ inputContentUI.getBean().setRecruitmentDistribution(inputContentUI.fieldPopulationRecruitmentDistribution.getMatrix().copy());
+ }
+ }
+ }
+}
Property changes on: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationRecruitmentHandler.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationRecruitmentUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationRecruitmentUI.jaxx 2015-05-18 09:52:01 UTC (rev 4226)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationRecruitmentUI.jaxx 2015-05-20 12:09:09 UTC (rev 4227)
@@ -27,13 +27,7 @@
<!-- bean property -->
<fr.ifremer.isisfish.entities.Population id='bean' javaBean='null'/>
- <import>
- fr.ifremer.isisfish.entities.Population;
- org.nuiton.math.matrix.gui.MatrixPanelEvent;
- java.beans.PropertyChangeEvent;
- java.beans.PropertyChangeListener;
- org.nuiton.math.matrix.gui.MatrixPanelListener;
- </import>
+ <PopulationRecruitmentHandler id="handler" />
<BeanValidator id='validator' context="recruitement"
bean='{getBean()}' beanClass='fr.ifremer.isisfish.entities.Population'
@@ -41,48 +35,11 @@
</BeanValidator>
<script><![CDATA[
-protected void $afterCompleteSetup() {
- addPropertyChangeListener(PROPERTY_BEAN, new PropertyChangeListener() {
- public void propertyChange(PropertyChangeEvent evt) {
- if (evt.getNewValue() == null) {
- fieldPopulationMonthGapBetweenReproRecrutement.setText("");
- fieldPopulationRecruitmentComment.setText("");
- }
- if (evt.getNewValue() != null) {
-
- }
- }
- });
-}
-
-protected void populationRecruitmentDistributionMatrixChanged(MatrixPanelEvent event) {
- if (getBean() != null){
- if (fieldPopulationRecruitmentDistribution.getMatrix() != null){
- getBean().setRecruitmentDistribution(fieldPopulationRecruitmentDistribution.getMatrix().copy());
- }
+ protected void $afterCompleteSetup() {
+ handler.init(this);
}
-}
+ ]]></script>
-/*public void refresh() {
- Population population = getSaveVerifier().getEntity(Population.class);
-
- // add null before, for second to be considered as a changed event
- // otherwize, setBean has no effect
- setBean(null);
- setBean(population);
-
- if (getBean() != null && getBean().getRecruitmentDistribution() != null) {
- fieldPopulationRecruitmentDistribution.setMatrix(getBean().getRecruitmentDistribution().copy());
-
- // chatellier : number editor is not working
- //fieldPopulationMonthGapBetweenReproRecrutement.init();
- }
-
- // TODO add only once
- //fieldPopulationRecruitmentDistribution.addMatrixListener(listener);
-}*/
- ]]>
- </script>
<JPanel id='body'>
<Table>
<row>
@@ -119,7 +76,7 @@
<org.nuiton.math.matrix.gui.MatrixPanelEditor id ='fieldPopulationRecruitmentDistribution'
matrix='{getBean() == null ? null : bean.getRecruitmentDistribution().copy()}'
enabled='{isActive()}' decorator='boxed' _sensitivityBean='{Population.class}' _sensitivityMethod='"RecruitmentDistribution"'
- onMatrixChanged="populationRecruitmentDistributionMatrixChanged(event)" />
+ onMatrixChanged="handler.populationRecruitmentDistributionMatrixChanged(event)" />
</cell>
<cell>
<JButton icon="table.png" toolTipText="isisfish.common.newMatrix"
Copied: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationSeasonInfoComboRenderer.java (from rev 4226, trunk/src/main/java/fr/ifremer/isisfish/ui/input/renderer/PopulationSeasonInfoComboRenderer.java)
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationSeasonInfoComboRenderer.java (rev 0)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationSeasonInfoComboRenderer.java 2015-05-20 12:09:09 UTC (rev 4227)
@@ -0,0 +1,70 @@
+/*
+ * #%L
+ * IsisFish
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2009 - 2010 Ifremer, CodeLutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+package fr.ifremer.isisfish.ui.input.population;
+
+import java.awt.Component;
+
+import javax.swing.DefaultListCellRenderer;
+import javax.swing.JLabel;
+import javax.swing.JList;
+
+import fr.ifremer.isisfish.entities.PopulationSeasonInfo;
+
+/**
+ * Renderer pour la combo des {@link PopulationSeasonInfo}.
+ *
+ * @author chatellier
+ * @version $Revision$
+ *
+ * Last update : $Date$
+ * By : $Author$
+ */
+public class PopulationSeasonInfoComboRenderer extends DefaultListCellRenderer {
+
+ /** serialVersionUID. */
+ private static final long serialVersionUID = -8277883340386163087L;
+
+ /*
+ * @see javax.swing.ListCellRenderer#getListCellRendererComponent(javax.swing.JList, java.lang.Object, int, boolean, boolean)
+ */
+ @Override
+ public Component getListCellRendererComponent(JList<?> list, Object value,
+ int index, boolean isSelected, boolean cellHasFocus) {
+
+ // this must be used to have alterned highlight rows and default
+ // selection color
+ JLabel c = (JLabel) super.getListCellRendererComponent(list, value,
+ index, isSelected, cellHasFocus);
+
+ PopulationSeasonInfo populationSeasonInfo = (PopulationSeasonInfo) value;
+
+ // there is no default selection
+ if (value != null) {
+ c.setText(populationSeasonInfo.getFirstMonth() + " - " + populationSeasonInfo.getLastMonth());
+ }
+ return c;
+ }
+}
Added: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationSeasonSpacializedHandler.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationSeasonSpacializedHandler.java (rev 0)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationSeasonSpacializedHandler.java 2015-05-20 12:09:09 UTC (rev 4227)
@@ -0,0 +1,105 @@
+/*
+ * #%L
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2015 Ifremer, Codelutin, Chatellier Eric
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+package fr.ifremer.isisfish.ui.input.population;
+
+import static org.nuiton.i18n.I18n.t;
+
+import javax.swing.JOptionPane;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.nuiton.math.matrix.MatrixND;
+import org.nuiton.math.matrix.gui.MatrixPanelEditor;
+import org.nuiton.math.matrix.gui.MatrixPanelEvent;
+
+import fr.ifremer.isisfish.entities.PopulationSeasonInfo;
+import fr.ifremer.isisfish.ui.input.InputContentHandler;
+import fr.ifremer.isisfish.ui.util.ErrorHelper;
+
+/**
+ * Population handler.
+ */
+public class PopulationSeasonSpacializedHandler extends InputContentHandler<PopulationSeasonSpacializedUI> {
+
+ /** Class logger. */
+ private static final Log log = LogFactory.getLog(PopulationSeasonsHandler.class);
+
+ protected void init(final PopulationSeasonSpacializedUI inputContentUI) {
+ super.init(inputContentUI);
+ }
+
+ protected void populationSeasonLengthMatrixChanged(MatrixPanelEvent event) {
+ if (inputContentUI.getPopulationSeasonInfo() != null && inputContentUI.matrixPanelPopulationSeasonLengthChange.getMatrix() != null) {
+ // must be a copy for fire event
+ MatrixND lengthChangeMatrix = inputContentUI.matrixPanelPopulationSeasonLengthChange.getMatrix().copy();
+ inputContentUI.getPopulationSeasonInfo().setLengthChangeMatrix(lengthChangeMatrix);
+ }
+ }
+
+ /**
+ * Called on spacialized radio button change.
+ */
+ protected void spacializedActionPerformed() {
+ PopulationSeasonInfo popInfo = inputContentUI.getPopulationSeasonInfo();
+ boolean spacializedSelection = inputContentUI.radioPopulationSeasonGroupChangeLengthNoSpacialized.isSelected();
+ popInfo.setSimpleLengthChangeMatrix(spacializedSelection);
+ try {
+ MatrixND lengthChangeMatrix = popInfo.getLengthChangeMatrix();
+ if (lengthChangeMatrix != null) {
+ if (popInfo.isSimpleLengthChangeMatrix()) {
+ lengthChangeMatrix = popInfo.unspacializeLengthChangeMatrix(lengthChangeMatrix);
+ } else {
+ lengthChangeMatrix = popInfo.spacializeLengthChangeMatrix(lengthChangeMatrix);
+ }
+ popInfo.setLengthChangeMatrix(lengthChangeMatrix);
+ inputContentUI.matrixPanelPopulationSeasonLengthChange.setMatrix(lengthChangeMatrix);
+ }
+ } catch(Exception eee) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't (un)spacialize Matrix Change Of Group", eee);
+ }
+ ErrorHelper.showErrorDialog(t("isisfish.error.input.spacializematrix"), eee);
+ }
+ }
+
+ protected void computeMatrixChangeOfGroup() {
+ PopulationSeasonInfo popInfo = inputContentUI.getPopulationSeasonInfo();
+ MatrixND lengthChangeMatrix = popInfo.computeLengthChangeMatrix();
+ if (!popInfo.isSimpleLengthChangeMatrix()){
+ lengthChangeMatrix = popInfo.spacializeLengthChangeMatrix(lengthChangeMatrix);
+ }
+ popInfo.setLengthChangeMatrix(lengthChangeMatrix);
+ }
+
+ protected void showSpacializedMatrixChangeOfGroup() {
+ PopulationSeasonInfo popInfo = inputContentUI.getPopulationSeasonInfo();
+ MatrixND lengthChangeMatrix = popInfo.getLengthChangeMatrix();
+ if (popInfo.isSimpleLengthChangeMatrix()) {
+ lengthChangeMatrix = popInfo.spacializeLengthChangeMatrix(lengthChangeMatrix);
+ }
+ MatrixPanelEditor panel = new MatrixPanelEditor(false, 800, 300);
+ panel.setMatrix(lengthChangeMatrix);
+ JOptionPane.showMessageDialog(inputContentUI, panel, t("isisfish.populationSeasons.spacialized.visualisation"), JOptionPane.INFORMATION_MESSAGE);
+ }
+}
Property changes on: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationSeasonSpacializedHandler.java
___________________________________________________________________
Added: svn:eol-style
+ native
Added: svn:keywords
+ Author Date Id Revision HeadURL
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationSeasonSpacializedUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationSeasonSpacializedUI.jaxx 2015-05-18 09:52:01 UTC (rev 4226)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationSeasonSpacializedUI.jaxx 2015-05-20 12:09:09 UTC (rev 4227)
@@ -31,76 +31,12 @@
<Boolean id='ageGroupType' javaBean='false'/>
- <import>
- static org.nuiton.i18n.I18n.t
- fr.ifremer.isisfish.entities.PopulationSeasonInfo;
- fr.ifremer.isisfish.ui.util.ErrorHelper;
- org.nuiton.math.matrix.MatrixND;
- org.nuiton.math.matrix.gui.MatrixPanelEditor;
- org.nuiton.math.matrix.gui.MatrixPanelEvent;
- org.nuiton.math.matrix.gui.MatrixPanelListener;
- javax.swing.JOptionPane
- </import>
+ <PopulationSeasonSpacializedHandler id="handler" />
<script><![CDATA[
-protected void populationSeasonLengthMatrixChanged(MatrixPanelEvent event) {
- if (getPopulationSeasonInfo() != null && matrixPanelPopulationSeasonLengthChange.getMatrix() != null) {
- // must be a copy for fire event
- MatrixND lengthChangeMatrix = matrixPanelPopulationSeasonLengthChange.getMatrix().copy();
- getPopulationSeasonInfo().setLengthChangeMatrix(lengthChangeMatrix);
+ protected void $afterCompleteSetup() {
+ handler.init(this);
}
-}
-
-/*public void refresh() {
- // TODO add only once
- //matrixPanelPopulationSeasonLengthChange.addMatrixListener(matrixPanelListener);
-}*/
-
-/**
- * Called on spacialized radio button change.
- */
-protected void spacializedActionPerformed() {
- PopulationSeasonInfo popInfo = getPopulationSeasonInfo();
- boolean spacializedSelection = radioPopulationSeasonGroupChangeLengthNoSpacialized.isSelected();
- popInfo.setSimpleLengthChangeMatrix(spacializedSelection);
- try {
- MatrixND lengthChangeMatrix = popInfo.getLengthChangeMatrix();
- if (lengthChangeMatrix != null) {
- if (popInfo.isSimpleLengthChangeMatrix()) {
- lengthChangeMatrix = popInfo.unspacializeLengthChangeMatrix(lengthChangeMatrix);
- } else {
- lengthChangeMatrix = popInfo.spacializeLengthChangeMatrix(lengthChangeMatrix);
- }
- popInfo.setLengthChangeMatrix(lengthChangeMatrix);
- matrixPanelPopulationSeasonLengthChange.setMatrix(lengthChangeMatrix);
- }
- } catch(Exception eee) {
- if (log.isErrorEnabled()) {
- log.error("Can't (un)spacialize Matrix Change Of Group", eee);
- }
- ErrorHelper.showErrorDialog(t("isisfish.error.input.spacializematrix"), eee);
- }
-}
-
-protected void computeMatrixChangeOfGroup() {
- PopulationSeasonInfo popInfo = getPopulationSeasonInfo();
- MatrixND lengthChangeMatrix = popInfo.computeLengthChangeMatrix();
- if (!popInfo.isSimpleLengthChangeMatrix()){
- lengthChangeMatrix = popInfo.spacializeLengthChangeMatrix(lengthChangeMatrix);
- }
- popInfo.setLengthChangeMatrix(lengthChangeMatrix);
-}
-
-protected void showSpacializedMatrixChangeOfGroup() {
- PopulationSeasonInfo popInfo = getPopulationSeasonInfo();
- MatrixND lengthChangeMatrix = popInfo.getLengthChangeMatrix();
- if (popInfo.isSimpleLengthChangeMatrix()) {
- lengthChangeMatrix = popInfo.spacializeLengthChangeMatrix(lengthChangeMatrix);
- }
- MatrixPanelEditor panel = new MatrixPanelEditor(false, 800, 300);
- panel.setMatrix(lengthChangeMatrix);
- JOptionPane.showMessageDialog(this, panel, t("isisfish.populationSeasons.spacialized.visualisation"), JOptionPane.INFORMATION_MESSAGE);
-}
]]></script>
<JPanel id='body'>
@@ -114,7 +50,7 @@
buttonGroup="radioPopulationSeasonGroupChangeLengthSpacializedGroup"
selected='{getPopulationSeasonInfo().isSimpleLengthChangeMatrix()}'
enabled='{getPopulationSeasonInfo() != null}'
- text="isisfish.populationSeasons.noSpacialized" onActionPerformed='spacializedActionPerformed()'
+ text="isisfish.populationSeasons.noSpacialized" onActionPerformed='handler.spacializedActionPerformed()'
visible='{isAgeGroupType()}' decorator='boxed' />
</cell>
<cell fill='horizontal' weightx='0.5'>
@@ -122,7 +58,7 @@
buttonGroup="radioPopulationSeasonGroupChangeLengthSpacializedGroup"
selected='{!getPopulationSeasonInfo().isSimpleLengthChangeMatrix()}'
enabled='{getPopulationSeasonInfo() != null}'
- text="isisfish.populationSeasons.spacialized" onActionPerformed='spacializedActionPerformed()'
+ text="isisfish.populationSeasons.spacialized" onActionPerformed='handler.spacializedActionPerformed()'
visible='{isAgeGroupType()}' decorator='boxed' />
</cell>
</row>
@@ -133,12 +69,12 @@
</cell>
<cell fill='horizontal' weightx='0.5'>
<JButton text="isisfish.populationSeasons.computeCoefficient" decorator='boxed' visible='{isAgeGroupType()}'
- enabled='{getPopulationSeasonInfo() != null}' onActionPerformed='computeMatrixChangeOfGroup()'/>
+ enabled='{getPopulationSeasonInfo() != null}' onActionPerformed='handler.computeMatrixChangeOfGroup()'/>
</cell>
<cell fill='horizontal' weightx='0.5'>
<JButton id="buttonPopulationSeasonGroupChangeLengthButtonShow" text="isisfish.populationSeasons.showSpacialized"
enabled='{radioPopulationSeasonGroupChangeLengthNoSpacialized.isSelected() && getPopulationSeasonInfo() != null}'
- onActionPerformed='showSpacializedMatrixChangeOfGroup()'
+ onActionPerformed='handler.showSpacializedMatrixChangeOfGroup()'
visible='{isAgeGroupType()}' decorator='boxed'/>
</cell>
</row>
@@ -152,7 +88,7 @@
_sensitivityBean='{PopulationSeasonInfo.class}' _sensitivityMethod='"LengthChangeMatrix"'
visible='{isAgeGroupType()}' decorator='boxed'
matrix='{getPopulationSeasonInfo() == null ? null : getPopulationSeasonInfo().getLengthChangeMatrix().copy()}'
- onMatrixChanged="populationSeasonLengthMatrixChanged(event)" />
+ onMatrixChanged="handler.populationSeasonLengthMatrixChanged(event)" />
</cell>
</row>
</Table>
Added: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationSeasonsHandler.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationSeasonsHandler.java (rev 0)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationSeasonsHandler.java 2015-05-20 12:09:09 UTC (rev 4227)
@@ -0,0 +1,234 @@
+/*
+ * #%L
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2015 Ifremer, Codelutin, Chatellier Eric
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+package fr.ifremer.isisfish.ui.input.population;
+
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.nuiton.math.matrix.MatrixND;
+import org.nuiton.math.matrix.gui.MatrixPanelEvent;
+
+import fr.ifremer.isisfish.entities.PopulationSeasonInfo;
+import fr.ifremer.isisfish.types.Month;
+import fr.ifremer.isisfish.ui.input.InputAction;
+import fr.ifremer.isisfish.ui.input.InputContentHandler;
+import fr.ifremer.isisfish.ui.models.common.GenericComboModel;
+import fr.ifremer.isisfish.ui.widget.Interval;
+
+/**
+ * Population handler.
+ */
+public class PopulationSeasonsHandler extends InputContentHandler<PopulationSeasonsUI> {
+
+ /** Class logger. */
+ private static final Log log = LogFactory.getLog(PopulationSeasonsHandler.class);
+
+ protected Interval seasonInterval;
+
+ protected boolean init = false;
+
+ protected void init(final PopulationSeasonsUI inputContentUI) {
+ super.init(inputContentUI);
+
+ inputContentUI.addPropertyChangeListener(PopulationSeasonsUI.PROPERTY_BEAN, new PropertyChangeListener() {
+ public void propertyChange(PropertyChangeEvent evt) {
+ if (evt.getNewValue() == null) {
+ inputContentUI.fieldPopulationSeasonComment.setText("");
+ inputContentUI.fieldPopulationSeasonReproductionDistribution.setMatrix(null);
+ }
+ if (evt.getNewValue() != null) {
+ refresh();
+ }
+ }
+ });
+
+ /*
+ * Don't add both in same listener.
+ * When first is set, last value from getPopulationSeasonInfo()
+ * is erased by interval.getLast() default value.
+ */
+ inputContentUI.seasonIntervalPanel.addPropertyChangeListener("first", new PropertyChangeListener() {
+ @Override
+ public void propertyChange(PropertyChangeEvent evt) {
+ if (inputContentUI.getPopulationSeasonInfo() != null) {
+ inputContentUI.getPopulationSeasonInfo().setFirstMonth(new Month(seasonInterval.getFirst()));
+ setReproductionDistributionMatrix();
+ }
+ }
+ });
+ inputContentUI.seasonIntervalPanel.addPropertyChangeListener("last", new PropertyChangeListener() {
+ @Override
+ public void propertyChange(PropertyChangeEvent evt) {
+ if (inputContentUI.getPopulationSeasonInfo() != null) {
+ inputContentUI.getPopulationSeasonInfo().setLastMonth(new Month(seasonInterval.getLast()));
+ setReproductionDistributionMatrix();
+ }
+ }
+ });
+ }
+
+ protected void create() {
+ PopulationSeasonInfo seasonNew = inputContentUI.getContextValue(InputAction.class).createPopulationSeasonInfo(inputContentUI.getBean());
+ inputContentUI.setPopulationSeasonInfo(seasonNew);
+ setPopulationSeasonInfoCombo();
+ }
+
+ protected void delete() {
+ inputContentUI.getContextValue(InputAction.class).removePopulationSeasonInfo(inputContentUI.getBean(), inputContentUI.getPopulationSeasonInfo());
+ inputContentUI.setPopulationSeasonInfo(null);
+ setPopulationSeasonInfoCombo();
+ }
+
+ protected void save() {
+ inputContentUI.getSaveVerifier().save();
+ setPopulationSeasonInfoCombo();
+ }
+
+ protected void populationSeasonReproductionDistributionMatrixChanged(MatrixPanelEvent event) {
+ if (inputContentUI.getPopulationSeasonInfo() != null && inputContentUI.fieldPopulationSeasonReproductionDistribution.getMatrix() != null) {
+ MatrixND reproductionDistribution = inputContentUI.fieldPopulationSeasonReproductionDistribution.getMatrix().copy();
+ if (log.isDebugEnabled()) {
+ log.debug("Matrix ReproductionDistribution modified : " + reproductionDistribution);
+ }
+ inputContentUI.getPopulationSeasonInfo().setReproductionDistribution(reproductionDistribution);
+ }
+ }
+
+ public void refresh() {
+ //Population population = inputContentUI.getSaveVerifier().getEntity(Population.class);
+
+ // add null before, for second to be considered as a changed event
+ // otherwize, setBean has no effect
+ //setBean(null);
+ //setBean(population);
+
+ inputContentUI.setPopulationSeasonInfo(null);
+
+ // Model instanciation
+ seasonInterval = new Interval();
+ seasonInterval.setMin(0);
+ seasonInterval.setMax(11);
+ seasonInterval.setFirst(0);
+ seasonInterval.setLast(2);
+
+ setPopulationSeasonInfoCombo();
+ setSeasonInterval();
+
+ inputContentUI.seasonIntervalPanel.setLabelRenderer(Month.MONTH);
+ inputContentUI.seasonIntervalPanel.setModel(seasonInterval);
+
+ //fieldPopulationSeasonReproductionDistribution.addMatrixListener(matrixPanelListener);
+
+ /*if(getPopulationSeasonInfo() != null) {
+ PopulationSeasonInfo popInfo = getPopulationSeasonInfo();
+ setPopulationSeasonInfo(null);
+ setPopulationSeasonInfo(popInfo);
+ getSaveVerifier().addCurrentEntity(getPopulationSeasonInfo());
+ }*/
+ //getSaveVerifier().addCurrentPanel(populationSeasonSpecializedUI);
+ }
+
+ protected void setSeasonInterval() {
+ if (inputContentUI.getPopulationSeasonInfo() != null) {
+ try {
+ if (log.isDebugEnabled()) {
+ log.debug("Updating interval : ");
+ }
+ Month firstMonth = inputContentUI.getPopulationSeasonInfo().getFirstMonth();
+
+ if (firstMonth != null) {
+ seasonInterval.setFirst(firstMonth.getMonthNumber());
+
+ if (log.isDebugEnabled()) {
+ log.debug(" first : " + seasonInterval.getFirst());
+ }
+ } else {
+ seasonInterval.setFirst(0);
+ }
+
+ Month lastMonth = inputContentUI.getPopulationSeasonInfo().getLastMonth();
+ if (lastMonth != null) {
+ seasonInterval.setLast(lastMonth.getMonthNumber());
+ if (log.isDebugEnabled()) {
+ log.debug(" last : " + seasonInterval.getLast());
+ }
+ } else {
+ seasonInterval.setLast(3);
+ }
+ } catch (Exception e) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't display interval", e);
+ }
+ }
+ }
+ }
+
+ protected void setPopulationSeasonInfoCombo() {
+ if (inputContentUI.getBean() != null) {
+ GenericComboModel<PopulationSeasonInfo> populationSeasonInfoModel = new GenericComboModel<>(inputContentUI.getBean().getPopulationSeasonInfo());
+ inputContentUI.fieldPopulationSeasonInfoChooser.setModel(populationSeasonInfoModel);
+ populationSeasonInfoModel.setSelectedItem(inputContentUI.getPopulationSeasonInfo());
+ }
+ }
+
+ protected void seasonGroupChanged() {
+ if (inputContentUI.getPopulationSeasonInfo() != null) {
+ inputContentUI.getPopulationSeasonInfo().setGroupChange(inputContentUI.fieldPopulationSeasonGroupChange.isSelected());
+ }
+ }
+
+ protected void seasonChanged() {
+ init = true;
+ PopulationSeasonInfo seasonInfoSelected = (PopulationSeasonInfo)inputContentUI.fieldPopulationSeasonInfoChooser.getSelectedItem();
+ if (log.isDebugEnabled()) {
+ log.debug("Season changed : " + seasonInfoSelected);
+ }
+ inputContentUI.setPopulationSeasonInfo(seasonInfoSelected);
+ if (seasonInfoSelected != null) {
+ inputContentUI.getSaveVerifier().addCurrentEntity(seasonInfoSelected);
+ }
+ setSeasonInterval();
+ setReproductionDistributionMatrix();
+ init = false;
+ }
+
+ protected void setReproductionDistributionMatrix() {
+ if (inputContentUI.getPopulationSeasonInfo() != null){
+ MatrixND reproductionDistribution = inputContentUI.getPopulationSeasonInfo().getReproductionDistribution();
+ // must be a copy (otherwise, modify current entity matrix)
+ if (reproductionDistribution != null){
+ inputContentUI.fieldPopulationSeasonReproductionDistribution.setMatrix(reproductionDistribution.copy());
+ }
+ }
+ }
+
+ // TODO une methode isXXX ne prend pas de parametre
+ // et ne fait rien
+ protected boolean isAgeGroupType(boolean result) {
+ inputContentUI.populationSeasonSpecializedUI.setVisible(result);
+ return result;
+ }
+}
Property changes on: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationSeasonsHandler.java
___________________________________________________________________
Added: svn:eol-style
+ native
Added: svn:keywords
+ Author Date Id Revision HeadURL
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationSeasonsUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationSeasonsUI.jaxx 2015-05-18 09:52:01 UTC (rev 4226)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationSeasonsUI.jaxx 2015-05-20 12:09:09 UTC (rev 4227)
@@ -29,19 +29,7 @@
<fr.ifremer.isisfish.entities.PopulationSeasonInfo id='populationSeasonInfo' javaBean='null'/>
- <import>
- java.beans.PropertyChangeEvent
- java.beans.PropertyChangeListener
- fr.ifremer.isisfish.ui.models.common.GenericComboModel
- fr.ifremer.isisfish.entities.PopulationSeasonInfo
- fr.ifremer.isisfish.types.Month
- fr.ifremer.isisfish.entities.Population
- fr.ifremer.isisfish.ui.widget.Interval
- org.nuiton.math.matrix.MatrixND
- org.nuiton.math.matrix.gui.MatrixPanelEvent
- org.nuiton.math.matrix.gui.MatrixPanelListener
- fr.ifremer.isisfish.ui.input.InputAction
- </import>
+ <PopulationSeasonsHandler id="handler" />
<BeanValidator id='validator' context="seasons"
bean='{getBean()}' beanClass='fr.ifremer.isisfish.entities.Population'
@@ -58,202 +46,22 @@
valid="{validator.isValid() && validatorSeason.isValid()}" />
<script><![CDATA[
-protected Interval seasonInterval;
-
-protected boolean init = false;
-
-protected void $afterCompleteSetup() {
- addPropertyChangeListener(PROPERTY_BEAN, new PropertyChangeListener() {
- public void propertyChange(PropertyChangeEvent evt) {
- if (evt.getNewValue() == null) {
- fieldPopulationSeasonComment.setText("");
- fieldPopulationSeasonReproductionDistribution.setMatrix(null);
- }
- if (evt.getNewValue() != null) {
- refresh();
- }
- }
- });
-
- /*
- * Don't add both in same listener.
- * When first is set, last value from getPopulationSeasonInfo()
- * is erased by interval.getLast() default value.
- */
- seasonIntervalPanel.addPropertyChangeListener("first", new PropertyChangeListener() {
- @Override
- public void propertyChange(PropertyChangeEvent evt) {
- if (getPopulationSeasonInfo() != null) {
- getPopulationSeasonInfo().setFirstMonth(new Month(seasonInterval.getFirst()));
- setReproductionDistributionMatrix();
- }
- }
- });
- seasonIntervalPanel.addPropertyChangeListener("last", new PropertyChangeListener() {
- @Override
- public void propertyChange(PropertyChangeEvent evt) {
- if (getPopulationSeasonInfo() != null) {
- getPopulationSeasonInfo().setLastMonth(new Month(seasonInterval.getLast()));
- setReproductionDistributionMatrix();
- }
- }
- });
-}
-
-@Override
-public void resetChangeModel() {
- changeModel.setStayChanged(false);
-}
-
-protected void create() {
- PopulationSeasonInfo seasonNew = getContextValue(InputAction.class).createPopulationSeasonInfo(getBean());
- setPopulationSeasonInfo(seasonNew);
- setPopulationSeasonInfoCombo();
-}
-
-protected void delete() {
- getContextValue(InputAction.class).removePopulationSeasonInfo(getBean(), getPopulationSeasonInfo());
- setPopulationSeasonInfo(null);
- setPopulationSeasonInfoCombo();
-}
-
-protected void save() {
- getSaveVerifier().save();
- setPopulationSeasonInfoCombo();
-}
-
-protected void populationSeasonReproductionDistributionMatrixChanged(MatrixPanelEvent event) {
- if (getPopulationSeasonInfo() != null && fieldPopulationSeasonReproductionDistribution.getMatrix() != null) {
- MatrixND reproductionDistribution = fieldPopulationSeasonReproductionDistribution.getMatrix().copy();
- if (log.isDebugEnabled()) {
- log.debug("Matrix ReproductionDistribution modified : " + reproductionDistribution);
- }
- getPopulationSeasonInfo().setReproductionDistribution(reproductionDistribution);
+ protected void $afterCompleteSetup() {
+ handler.init(this);
}
-}
-public void refresh() {
- Population population = getSaveVerifier().getEntity(Population.class);
-
- // add null before, for second to be considered as a changed event
- // otherwize, setBean has no effect
- //setBean(null);
- //setBean(population);
-
- setPopulationSeasonInfo(null);
-
- // Model instanciation
- seasonInterval = new Interval();
- seasonInterval.setMin(0);
- seasonInterval.setMax(11);
- seasonInterval.setFirst(0);
- seasonInterval.setLast(2);
-
- setPopulationSeasonInfoCombo();
- setSeasonInterval();
-
- seasonIntervalPanel.setLabelRenderer(Month.MONTH);
- seasonIntervalPanel.setModel(seasonInterval);
-
- //fieldPopulationSeasonReproductionDistribution.addMatrixListener(matrixPanelListener);
-
- /*if(getPopulationSeasonInfo() != null) {
- PopulationSeasonInfo popInfo = getPopulationSeasonInfo();
- setPopulationSeasonInfo(null);
- setPopulationSeasonInfo(popInfo);
- getSaveVerifier().addCurrentEntity(getPopulationSeasonInfo());
- }*/
- //getSaveVerifier().addCurrentPanel(populationSeasonSpecializedUI);
-}
-
-protected void setSeasonInterval() {
- if(getPopulationSeasonInfo() != null) {
- try {
- if (log.isDebugEnabled()) {
- log.debug("Updating interval : ");
- }
- Month firstMonth = getPopulationSeasonInfo().getFirstMonth();
-
- if (firstMonth != null) {
- seasonInterval.setFirst(firstMonth.getMonthNumber());
-
- if (log.isDebugEnabled()) {
- log.debug(" first : " + seasonInterval.getFirst());
- }
- } else {
- seasonInterval.setFirst(0);
- }
-
- Month lastMonth = getPopulationSeasonInfo().getLastMonth();
- if (lastMonth != null) {
- seasonInterval.setLast(lastMonth.getMonthNumber());
- if (log.isDebugEnabled()) {
- log.debug(" last : " + seasonInterval.getLast());
- }
- } else {
- seasonInterval.setLast(3);
- }
- } catch (Exception e) {
- if (log.isErrorEnabled()) {
- log.error("Can't display interval", e);
- }
- }
+ @Override
+ public void resetChangeModel() {
+ changeModel.setStayChanged(false);
}
-}
-protected void setPopulationSeasonInfoCombo() {
- if (getBean() != null) {
- GenericComboModel<PopulationSeasonInfo> populationSeasonInfoModel = new GenericComboModel<>(getBean().getPopulationSeasonInfo());
- fieldPopulationSeasonInfoChooser.setModel(populationSeasonInfoModel);
- populationSeasonInfoModel.setSelectedItem(getPopulationSeasonInfo());
+ @Override
+ public void setLayer(boolean active) {
+ super.setLayer(active);
+ populationSeasonSpecializedUI.setLayer(active);
}
-}
+ ]]></script>
-protected void seasonGroupChanged() {
- if (getPopulationSeasonInfo() != null) {
- getPopulationSeasonInfo().setGroupChange(fieldPopulationSeasonGroupChange.isSelected());
- }
-}
-
-protected void seasonChanged() {
- init = true;
- PopulationSeasonInfo seasonInfoSelected = (PopulationSeasonInfo)fieldPopulationSeasonInfoChooser.getSelectedItem();
- if (log.isDebugEnabled()) {
- log.debug("Season changed : " + seasonInfoSelected);
- }
- setPopulationSeasonInfo(seasonInfoSelected);
- if (seasonInfoSelected != null) {
- getSaveVerifier().addCurrentEntity(seasonInfoSelected);
- }
- setSeasonInterval();
- setReproductionDistributionMatrix();
- init = false;
-}
-
-protected void setReproductionDistributionMatrix() {
- if (getPopulationSeasonInfo() != null){
- MatrixND reproductionDistribution = getPopulationSeasonInfo().getReproductionDistribution();
- // must be a copy (otherwise, modify current entity matrix)
- if (reproductionDistribution != null){
- fieldPopulationSeasonReproductionDistribution.setMatrix(reproductionDistribution.copy());
- }
- }
-}
-
-// TODO une methode isXXX ne prend pas de parametre
-// et ne fait rien
-protected boolean isAgeGroupType(boolean result) {
- populationSeasonSpecializedUI.setVisible(result);
- return result;
-}
-
-@Override
-public void setLayer(boolean active) {
- super.setLayer(active);
- populationSeasonSpecializedUI.setLayer(active);
-}
- ]]>
- </script>
<JPanel id='body'>
<Table>
<row>
@@ -266,8 +74,8 @@
<cell fill='horizontal' weightx='1.0'>
<JComboBox id="fieldPopulationSeasonInfoChooser"
genericType="PopulationSeasonInfo"
- onItemStateChanged='seasonChanged()' enabled='{isActive() && (isSensitivity() || !changeModel.isChanged() ) }'
- renderer="{new fr.ifremer.isisfish.ui.input.renderer.PopulationSeasonInfoComboRenderer()}"/>
+ onItemStateChanged='handler.seasonChanged()' enabled='{isActive() && (isSensitivity() || !changeModel.isChanged() ) }'
+ renderer="{new PopulationSeasonInfoComboRenderer()}"/>
</cell>
</row>
<row>
@@ -284,16 +92,18 @@
<JPanel/>
</cell>
<cell fill='both' weightx='1.0'>
- <JCheckBox id="fieldPopulationSeasonGroupChange" text="isisfish.populationSeasons.changeGroup" selected='{getPopulationSeasonInfo().isGroupChange()}'
+ <JCheckBox id="fieldPopulationSeasonGroupChange" text="isisfish.populationSeasons.changeGroup"
+ selected='{getPopulationSeasonInfo().isGroupChange()}'
decorator='boxed' _sensitivityBean='{PopulationSeasonInfo.class}' _sensitivityMethod='"GroupChange"'
- onActionPerformed='seasonGroupChanged()' enabled='{getPopulationSeasonInfo() != null}' visible='{isAgeGroupType(getPopulationSeasonInfo().getPopulation().getSpecies().isAgeGroupType())}'/>
+ onActionPerformed='handler.seasonGroupChanged()' enabled='{getPopulationSeasonInfo() != null}'
+ visible='{handler.isAgeGroupType(getPopulationSeasonInfo().getPopulation().getSpecies().isAgeGroupType())}'/>
</cell>
</row>
<row>
<cell columns='2' fill='both' weightx='1.0' weighty='0.6'>
<PopulationSeasonSpacializedUI id='populationSeasonSpecializedUI' constructorParams='this' bean='{getBean()}'
populationSeasonInfo='{getPopulationSeasonInfo()}'
- ageGroupType='{isAgeGroupType(!getPopulationSeasonInfo().getPopulation().getSpecies().isAgeGroupType())}'/>
+ ageGroupType='{handler.isAgeGroupType(!getPopulationSeasonInfo().getPopulation().getSpecies().isAgeGroupType())}'/>
</cell>
</row>
<row>
@@ -317,7 +127,7 @@
enabled='{getPopulationSeasonInfo() != null}'
visible='{getPopulationSeasonInfo().isReproduction()}'
decorator='boxed' _sensitivityBean='{PopulationSeasonInfo.class}' _sensitivityMethod='"ReproductionDistribution"'
- onMatrixChanged="populationSeasonReproductionDistributionMatrixChanged(event)" />
+ onMatrixChanged="handler.populationSeasonReproductionDistributionMatrixChanged(event)" />
</cell>
</row>
<row>
@@ -344,7 +154,7 @@
<JButton id='save' decorator='boxed'
text="isisfish.common.save"
enabled="{changeModel.isValid() && changeModel.isChanged()}"
- onActionPerformed="save();validator.setChanged(false);validatorSeason.setChanged(false);"/>
+ onActionPerformed="handler.save();validator.setChanged(false);validatorSeason.setChanged(false);"/>
</cell>
<cell fill='horizontal' weightx='0.5'>
<JButton id='cancel' decorator='boxed'
@@ -358,13 +168,13 @@
<JButton id='create' decorator='boxed'
text="isisfish.common.new"
enabled="{!changeModel.isChanged()}"
- onActionPerformed="create()"/>
+ onActionPerformed="handler.create()"/>
</cell>
<cell fill='horizontal' weightx='0.5'>
<JButton id='delete' decorator='boxed'
text="isisfish.common.remove"
enabled="{getPopulationSeasonInfo() != null}"
- onActionPerformed="delete()"/>
+ onActionPerformed="handler.delete()"/>
</cell>
</row>
</Table>
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationUI.jaxx 2015-05-18 09:52:01 UTC (rev 4226)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationUI.jaxx 2015-05-20 12:09:09 UTC (rev 4227)
@@ -5,7 +5,7 @@
$Id$
$HeadURL$
%%
- Copyright (C) 2009 - 2012 Ifremer, Code Lutin, Chatellier Eric
+ Copyright (C) 2009 - 2015 Ifremer, Code Lutin, Chatellier Eric
%%
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as
@@ -27,51 +27,43 @@
<!-- bean property -->
<fr.ifremer.isisfish.entities.Population id='bean' javaBean='null'/>
- <import>
- static org.nuiton.i18n.I18n.t
- static org.nuiton.i18n.I18n.n
- </import>
+ <PopulationHandler id="handler" />
<script><![CDATA[
-protected void $afterCompleteSetup() {
- setButtonTitle(t("isisfish.input.continueGears"));
- setNextPath(n("isisfish.input.tree.gears"));
-
- // install change listener
- // (depends on sensitivity can't be done on constructor)
- installChangeListener(populationTab);
-}
+ protected void $afterCompleteSetup() {
+ handler.init(this);
+ }
-@Override
-public void setLayer(boolean active) {
- super.setLayer(active);
- populationBasicsUI.setLayer(active);
- populationZoneUI.setLayer(active);
- populationSeasonsUI.setLayer(active);
- populationEquationUI.setLayer(active);
- populationRecruitementUI.setLayer(active);
- populationGroupUI.setLayer(active);
- populationCapturabilityUI.setLayer(active);
- populationMigrationUI.setLayer(active);
- populationPriceUI.setLayer(active);
- variablesUI.setLayer(active);
-}
+ @Override
+ public void setLayer(boolean active) {
+ super.setLayer(active);
+ populationBasicsUI.setLayer(active);
+ populationZoneUI.setLayer(active);
+ populationSeasonsUI.setLayer(active);
+ populationEquationUI.setLayer(active);
+ populationRecruitementUI.setLayer(active);
+ populationGroupUI.setLayer(active);
+ populationCapturabilityUI.setLayer(active);
+ populationMigrationUI.setLayer(active);
+ populationPriceUI.setLayer(active);
+ variablesUI.setLayer(active);
+ }
-@Override
-public void resetChangeModel() {
- populationBasicsUI.resetChangeModel();
- populationZoneUI.resetChangeModel();
- populationSeasonsUI.resetChangeModel();
- populationEquationUI.resetChangeModel();
- populationRecruitementUI.resetChangeModel();
- populationGroupUI.resetChangeModel();
- populationCapturabilityUI.resetChangeModel();
- populationMigrationUI.resetChangeModel();
- populationPriceUI.resetChangeModel();
- variablesUI.resetChangeModel();
-}
- ]]>
- </script>
+ @Override
+ public void resetChangeModel() {
+ populationBasicsUI.resetChangeModel();
+ populationZoneUI.resetChangeModel();
+ populationSeasonsUI.resetChangeModel();
+ populationEquationUI.resetChangeModel();
+ populationRecruitementUI.resetChangeModel();
+ populationGroupUI.resetChangeModel();
+ populationCapturabilityUI.resetChangeModel();
+ populationMigrationUI.resetChangeModel();
+ populationPriceUI.resetChangeModel();
+ variablesUI.resetChangeModel();
+ }
+ ]]></script>
+
<JPanel id='body'>
<JTabbedPane id="populationTab">
<!-- Saisie des populations -->
Added: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationZonesEditorHandler.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationZonesEditorHandler.java (rev 0)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationZonesEditorHandler.java 2015-05-20 12:09:09 UTC (rev 4227)
@@ -0,0 +1,145 @@
+/*
+ * #%L
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2015 Ifremer, Codelutin, Chatellier Eric
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+package fr.ifremer.isisfish.ui.input.population;
+
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.swing.JList;
+
+import org.nuiton.math.matrix.gui.MatrixPanelEvent;
+
+import fr.ifremer.isisfish.entities.Zone;
+import fr.ifremer.isisfish.ui.input.InputContentHandler;
+import fr.ifremer.isisfish.ui.models.common.GenericListModel;
+
+/**
+ * Population handler.
+ */
+public class PopulationZonesEditorHandler extends InputContentHandler<PopulationZonesEditorUI> {
+
+ protected boolean init = false;
+
+ protected void init(final PopulationZonesEditorUI inputContentUI) {
+ super.init(inputContentUI);
+
+ inputContentUI.addPropertyChangeListener(PopulationZonesEditorUI.PROPERTY_BEAN, new PropertyChangeListener() {
+ public void propertyChange(PropertyChangeEvent evt) {
+ if (evt.getNewValue() == null) {
+ setPopulationZonesPresenceModel();
+ setFieldPopulationZonesReproductionModel(getSelectedValues(inputContentUI.populationZonesPresence));
+ setFieldPopulationZonesRecruitmentModel(getSelectedValues(inputContentUI.populationZonesPresence));
+ setFieldPopulationMappingZoneReproZoneRecru();
+ }
+ if (evt.getNewValue() != null) {
+ init = true;
+ setPopulationZonesPresenceModel();
+ setFieldPopulationZonesReproductionModel(getSelectedValues(inputContentUI.populationZonesPresence));
+ setFieldPopulationZonesRecruitmentModel(getSelectedValues(inputContentUI.populationZonesPresence));
+ setFieldPopulationMappingZoneReproZoneRecru();
+ init = false;
+ }
+ }
+ });
+ }
+
+ protected void populationMappingZoneReproZoneRecruMatrixChanged(MatrixPanelEvent event) {
+ inputContentUI.getBean().setMappingZoneReproZoneRecru(inputContentUI.fieldPopulationMappingZoneReproZoneRecru.getMatrix().clone());
+ }
+
+ protected void setFieldPopulationMappingZoneReproZoneRecru() {
+ if (inputContentUI.getBean() != null) {
+ if (inputContentUI.getBean().getMappingZoneReproZoneRecru() != null) {
+ inputContentUI.fieldPopulationMappingZoneReproZoneRecru.setMatrix(inputContentUI.getBean().getMappingZoneReproZoneRecru().copy());
+ }
+ }
+ }
+ protected void setPopulationZonesPresenceModel() {
+ if (inputContentUI.getBean() != null) {
+ List<Zone> zones = inputContentUI.getFisheryRegion().getZone();
+ setModel(zones, inputContentUI.getBean().getPopulationZone(), inputContentUI.populationZonesPresence);
+ }
+ }
+ protected void setFieldPopulationZonesReproductionModel(List<Zone> zones) {
+ if (inputContentUI.getBean() != null) {
+ setModel(zones, inputContentUI.getBean().getReproductionZone(), inputContentUI.fieldPopulationZonesReproduction);
+ }
+ }
+ protected void setFieldPopulationZonesRecruitmentModel(List<Zone> zones) {
+ if (inputContentUI.getBean() != null) {
+ setModel(zones, inputContentUI.getBean().getRecruitmentZone(), inputContentUI.fieldPopulationZonesRecruitment);
+ }
+ }
+
+ /**
+ * Change model of {@code associatedList} with all available zones, but keep
+ * selection with {@code selectedZones}.
+ */
+ protected void setModel(List<Zone> availableZones, List<Zone> selectedZones, JList<Zone> associatedList) {
+ GenericListModel<Zone> zoneModel = new GenericListModel<>(availableZones);
+ associatedList.setModel(zoneModel);
+
+ // can be null at population init
+ if (selectedZones != null) {
+ for (Zone selectedZone : selectedZones) {
+ int index = availableZones.indexOf(selectedZone);
+ associatedList.addSelectionInterval(index, index);
+ }
+ }
+ }
+
+ protected void presenceChanged() {
+ if (!init) {
+ inputContentUI.getBean().setPopulationZone(getSelectedValues(inputContentUI.populationZonesPresence));
+ setFieldPopulationZonesReproductionModel(getSelectedValues(inputContentUI.populationZonesPresence));
+ setFieldPopulationZonesRecruitmentModel(getSelectedValues(inputContentUI.populationZonesPresence));
+ setFieldPopulationMappingZoneReproZoneRecru();
+ }
+ }
+
+ protected void reproductionChanged() {
+ if (!init) {
+ inputContentUI.getBean().setReproductionZone(getSelectedValues(inputContentUI.fieldPopulationZonesReproduction));
+ setFieldPopulationMappingZoneReproZoneRecru();
+ }
+ }
+
+ protected void recruitementChanged() {
+ if (!init) {
+ inputContentUI.getBean().setRecruitmentZone(getSelectedValues(inputContentUI.fieldPopulationZonesRecruitment));
+ setFieldPopulationMappingZoneReproZoneRecru();
+ }
+ }
+
+ /**
+ * Get selected values for components as list.
+ */
+ protected List<Zone> getSelectedValues(JList<Zone> component) {
+ List<Zone> selectedValues = component.getSelectedValuesList();
+ List<Zone> selectedZone = new ArrayList<>(selectedValues);
+ return selectedZone;
+ }
+}
Property changes on: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationZonesEditorHandler.java
___________________________________________________________________
Added: svn:eol-style
+ native
Added: svn:keywords
+ Author Date Id Revision HeadURL
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationZonesEditorUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationZonesEditorUI.jaxx 2015-05-18 09:52:01 UTC (rev 4226)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationZonesEditorUI.jaxx 2015-05-20 12:09:09 UTC (rev 4227)
@@ -27,129 +27,18 @@
<!-- bean property -->
<fr.ifremer.isisfish.entities.Population id='bean' javaBean='null'/>
+ <PopulationZonesEditorHandler id="handler" />
+
<import>
- fr.ifremer.isisfish.entities.Zone
- fr.ifremer.isisfish.ui.models.common.GenericListModel
- org.nuiton.math.matrix.gui.MatrixPanelEvent
- org.nuiton.math.matrix.gui.MatrixPanelListener
- java.beans.PropertyChangeEvent
- java.beans.PropertyChangeListener
- java.util.List
- java.util.ArrayList
java.awt.Dimension
</import>
<script><![CDATA[
-protected boolean init = false;
-
-protected void $afterCompleteSetup() {
- addPropertyChangeListener(PROPERTY_BEAN, new PropertyChangeListener() {
- public void propertyChange(PropertyChangeEvent evt) {
- if (evt.getNewValue() == null) {
- setPopulationZonesPresenceModel();
- setFieldPopulationZonesReproductionModel(getSelectedValues(populationZonesPresence));
- setFieldPopulationZonesRecruitmentModel(getSelectedValues(populationZonesPresence));
- setFieldPopulationMappingZoneReproZoneRecru();
- }
- if (evt.getNewValue() != null) {
- init = true;
- setPopulationZonesPresenceModel();
- setFieldPopulationZonesReproductionModel(getSelectedValues(populationZonesPresence));
- setFieldPopulationZonesRecruitmentModel(getSelectedValues(populationZonesPresence));
- setFieldPopulationMappingZoneReproZoneRecru();
- init = false;
- }
- }
- });
-}
-
-protected void populationMappingZoneReproZoneRecruMatrixChanged(MatrixPanelEvent event) {
- getBean().setMappingZoneReproZoneRecru(fieldPopulationMappingZoneReproZoneRecru.getMatrix().clone());
-}
-
-/*public void refresh() {
- setPopulationZonesPresenceModel();
- setFieldPopulationZonesReproductionModel(getSelectedValues(populationZonesPresence));
- setFieldPopulationZonesRecruitmentModel(getSelectedValues(populationZonesPresence));
- //fieldPopulationMappingZoneReproZoneRecru.removeMatrixPanelListener(listener);
- setFieldPopulationMappingZoneReproZoneRecru();
- //fieldPopulationMappingZoneReproZoneRecru.addMatrixListener(listener);
-}*/
-
-protected void setFieldPopulationMappingZoneReproZoneRecru() {
- if (getBean() != null) {
- if (getBean().getMappingZoneReproZoneRecru() != null) {
- fieldPopulationMappingZoneReproZoneRecru.setMatrix(getBean().getMappingZoneReproZoneRecru().copy());
- }
+ protected void $afterCompleteSetup() {
+ handler.init(this);
}
-}
-protected void setPopulationZonesPresenceModel() {
- if (getBean() != null) {
- java.util.List<Zone> zones = getFisheryRegion().getZone();
- setModel(zones, getBean().getPopulationZone(), populationZonesPresence);
- }
-}
-protected void setFieldPopulationZonesReproductionModel(List<Zone> zones) {
- if (getBean() != null) {
- setModel(zones, getBean().getReproductionZone(), fieldPopulationZonesReproduction);
- }
-}
-protected void setFieldPopulationZonesRecruitmentModel(List<Zone> zones) {
- if (getBean() != null) {
- setModel(zones, getBean().getRecruitmentZone(), fieldPopulationZonesRecruitment);
- }
-}
+ ]]></script>
-/**
- * Change model of {@code associatedList} with all available zones, but keep
- * selection with {@code selectedZones}.
- */
-protected void setModel(List<Zone> availableZones, List<Zone> selectedZones, JList<Zone> associatedList) {
- GenericListModel<Zone> zoneModel = new GenericListModel<>(availableZones);
- associatedList.setModel(zoneModel);
-
- // can be null at population init
- if (selectedZones != null) {
- for (Zone selectedZone : selectedZones) {
- int index = availableZones.indexOf(selectedZone);
- associatedList.addSelectionInterval(index, index);
- }
- }
-}
-
-protected void presenceChanged() {
- if (!init) {
- getBean().setPopulationZone(getSelectedValues(populationZonesPresence));
- setFieldPopulationZonesReproductionModel(getSelectedValues(populationZonesPresence));
- setFieldPopulationZonesRecruitmentModel(getSelectedValues(populationZonesPresence));
- setFieldPopulationMappingZoneReproZoneRecru();
- }
-}
-
-protected void reproductionChanged() {
- if (!init) {
- getBean().setReproductionZone(getSelectedValues(fieldPopulationZonesReproduction));
- setFieldPopulationMappingZoneReproZoneRecru();
- }
-}
-
-protected void recruitementChanged() {
- if (!init) {
- getBean().setRecruitmentZone(getSelectedValues(fieldPopulationZonesRecruitment));
- setFieldPopulationMappingZoneReproZoneRecru();
- }
-}
-
-/**
- * Get selected values for components as list.
- */
-protected List<Zone> getSelectedValues(JList<Zone> component) {
- List<Zone> selectedValues = component.getSelectedValuesList();
- List<Zone> selectedZone = new ArrayList<Zone>(selectedValues);
- return selectedZone;
-}
- ]]>
- </script>
<JPanel id='body'>
<Table>
<row>
@@ -167,19 +56,19 @@
<cell fill='both' weightx='0.3' weighty='0.5'>
<JScrollPane minimumSize='{new Dimension(0,0)}' preferredSize='{new Dimension(0,0)}'>
<JList id="populationZonesPresence" genericType="fr.ifremer.isisfish.entities.Zone"
- onValueChanged='presenceChanged()' enabled='{isActive()}'/>
+ onValueChanged='handler.presenceChanged()' enabled='{isActive()}'/>
</JScrollPane>
</cell>
<cell fill='both' weightx='0.3' weighty='0.5'>
<JScrollPane minimumSize='{new Dimension(0,0)}' preferredSize='{new Dimension(0,0)}'>
<JList id="fieldPopulationZonesReproduction" genericType="fr.ifremer.isisfish.entities.Zone"
- onValueChanged='reproductionChanged()' enabled='{isActive()}'/>
+ onValueChanged='handler.reproductionChanged()' enabled='{isActive()}'/>
</JScrollPane>
</cell>
<cell fill='both' weightx='0.3' weighty='0.5'>
<JScrollPane minimumSize='{new Dimension(0,0)}' preferredSize='{new Dimension(0,0)}'>
<JList id="fieldPopulationZonesRecruitment" genericType="fr.ifremer.isisfish.entities.Zone"
- onValueChanged='recruitementChanged()' enabled='{isActive()}'/>
+ onValueChanged='handler.recruitementChanged()' enabled='{isActive()}'/>
</JScrollPane>
</cell>
</row>
@@ -192,7 +81,7 @@
<cell columns='3' fill='both' weightx='1.0' weighty='0.5'>
<org.nuiton.math.matrix.gui.MatrixPanelEditor id='fieldPopulationMappingZoneReproZoneRecru'
constructorParams='false' enabled='{isActive()}'
- onMatrixChanged="populationMappingZoneReproZoneRecruMatrixChanged(event)"
+ onMatrixChanged="handler.populationMappingZoneReproZoneRecruMatrixChanged(event)"
decorator='boxed'
_sensitivityBean='{fr.ifremer.isisfish.entities.Population.class}' _sensitivityMethod='"MappingZoneReproZoneRecru"' />
</cell>
Added: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationZonesHandler.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationZonesHandler.java (rev 0)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationZonesHandler.java 2015-05-20 12:09:09 UTC (rev 4227)
@@ -0,0 +1,37 @@
+/*
+ * #%L
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2015 Ifremer, Codelutin, Chatellier Eric
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+package fr.ifremer.isisfish.ui.input.population;
+
+import fr.ifremer.isisfish.ui.input.InputContentHandler;
+
+/**
+ * Population handler.
+ */
+public class PopulationZonesHandler extends InputContentHandler<PopulationZonesUI> {
+
+ protected void init(final PopulationZonesUI inputContentUI) {
+ super.init(inputContentUI);
+
+ }
+}
Property changes on: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationZonesHandler.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationZonesUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationZonesUI.jaxx 2015-05-18 09:52:01 UTC (rev 4226)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationZonesUI.jaxx 2015-05-20 12:09:09 UTC (rev 4227)
@@ -27,30 +27,25 @@
<!-- bean property -->
<fr.ifremer.isisfish.entities.Population id='bean' javaBean='null'/>
+ <PopulationZonesHandler id="handler" />
+
<BeanValidator id='validator' context="zones"
bean='{getBean()}' beanClass='fr.ifremer.isisfish.entities.Population'
uiClass="jaxx.runtime.validator.swing.ui.ImageValidationUI">
</BeanValidator>
<script><![CDATA[
-/*public void refresh() {
- Population population = getSaveVerifier().getEntity(Population.class);
-
- // add null before, for second to be considered as a changed event
- // otherwize, setBean has no effect
- setBean(null);
- setBean(population);
+ protected void $afterCompleteSetup() {
+ handler.init(this);
+ }
- getSaveVerifier().addCurrentPanel(popZones);
-}*/
+ @Override
+ public void setLayer(boolean active) {
+ super.setLayer(active);
+ popZones.setLayer(active);
+ }
+ ]]></script>
-@Override
-public void setLayer(boolean active) {
- super.setLayer(active);
- popZones.setLayer(active);
-}
- ]]>
- </script>
<JPanel id='body'>
<Table>
<row>
Added: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/WizardGroupCreationHandler.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/WizardGroupCreationHandler.java (rev 0)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/WizardGroupCreationHandler.java 2015-05-20 12:09:09 UTC (rev 4227)
@@ -0,0 +1,421 @@
+/*
+ * #%L
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2015 Ifremer, Codelutin, Chatellier Eric
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+package fr.ifremer.isisfish.ui.input.population;
+
+import java.awt.CardLayout;
+
+import javax.swing.JFrame;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.nuiton.topia.TopiaContext;
+
+import fr.ifremer.isisfish.IsisFishDAOHelper;
+import fr.ifremer.isisfish.entities.Equation;
+import fr.ifremer.isisfish.entities.Population;
+import fr.ifremer.isisfish.entities.PopulationGroup;
+import fr.ifremer.isisfish.entities.PopulationGroupDAO;
+
+/**
+ * wizard group creation handler.
+ */
+public class WizardGroupCreationHandler {
+
+ /** Class logger. */
+ private static final Log log = LogFactory.getLog(WizardGroupCreationHandler.class);
+
+ protected WizardGroupCreationUI wizardUI;
+
+ protected String current = null;
+ protected boolean ageType = false;
+ protected boolean inputType = false;
+ protected boolean sameSizeType = false;
+ protected boolean growthCurveType = false;
+
+ protected double first = 0;
+ protected double last = 0;
+
+ protected String maxLength = "";
+ protected int numberOfGroup = 0;
+ protected double groupSize = 0;
+
+ protected double step = 1;
+ protected PopulationBasicsUI popBasic;
+
+ protected void init(final WizardGroupCreationUI wizardUI) {
+ this.wizardUI = wizardUI;
+ }
+
+ public void initParent(PopulationBasicsUI popBasic) {
+ this.popBasic = popBasic;
+ }
+
+ /**
+ * @return Returns the ageType.
+ */
+ public boolean isAgeType() {
+ return this.ageType;
+ }
+
+ /**
+ * @param ageType The ageType to set.
+ */
+ public void setAgeType(boolean ageType) {
+ this.ageType = ageType;
+ }
+
+ /**
+ * @return Returns the inputType.
+ */
+ public boolean isInputType() {
+ return this.inputType;
+ }
+
+ /**
+ * @param inputType The inputType to set.
+ */
+ public void setInputType(boolean inputType) {
+ this.inputType = inputType;
+ }
+
+ /**
+ * @return Returns the sameSizeType.
+ */
+ public boolean isSameSizeType() {
+ return this.sameSizeType;
+ }
+
+ /**
+ * @param sameSizeType The sameSizeType to set.
+ */
+ public void setSameSizeType(boolean sameSizeType) {
+ this.sameSizeType = sameSizeType;
+ }
+
+ /**
+ * @return Returns the growthCurveType.
+ */
+ public boolean isGrowthCurveType() {
+ return this.growthCurveType;
+ }
+
+ /**
+ * @param growthCurveType The growthCurveType to set.
+ */
+ public void setGrowthCurveType(boolean growthCurveType) {
+ this.growthCurveType = growthCurveType;
+ }
+
+ /**
+ * @return Returns the first.
+ */
+ public double getFirst() {
+ return this.first;
+ }
+
+ /**
+ * @param first The first to set.
+ */
+ public void setFirst(double first) {
+ this.first = first;
+ }
+
+ /**
+ * @return Returns the last.
+ */
+ public double getLast() {
+ return this.last;
+ }
+
+ /**
+ * @param last The last to set.
+ */
+ public void setLast(double last) {
+ this.last = last;
+ }
+
+ /**
+ * @return Returns the maxLength.
+ */
+ public String getMaxLength() {
+ return this.maxLength;
+ }
+
+ /**
+ * @param maxLength The maxLength to set.
+ */
+ public void setMaxLength(String maxLength) {
+ this.maxLength = maxLength;
+ }
+
+ /**
+ * @return Returns the numberOfGroup.
+ */
+ public int getNumberOfGroup() {
+ return this.numberOfGroup;
+ }
+
+ /**
+ * @param numberOfGroup The numberOfGroup to set.
+ */
+ public void setNumberOfGroup(int numberOfGroup) {
+ this.numberOfGroup = numberOfGroup;
+ }
+
+ /**
+ * @return Returns the groupSize.
+ */
+ public double getGroupSize() {
+ return this.groupSize;
+ }
+
+ /**
+ * @param groupSize The groupSize to set.
+ */
+ public void setGroupSize(double groupSize) {
+ this.groupSize = groupSize;
+ }
+
+ /**
+ * @return Returns the step.
+ */
+ public double getStep() {
+ return this.step;
+ }
+
+ /**
+ * @param step The step to set.
+ */
+ public void setStep(double step) {
+ this.step = step;
+ }
+
+ public void setCard(String name) {
+ current = name;
+ ((CardLayout) wizardUI.wizardPanels.getLayout()).show(wizardUI.wizardPanels, name);
+ }
+
+ protected void prev() {
+ if (isAgeType()) {
+ // do nothing only one panel
+ } else {
+ setCard("beginGroupLength");
+ }
+ wizardUI.prev.setEnabled(false);
+ wizardUI.next.setEnabled(true);
+ wizardUI.finish.setEnabled(false);
+ }
+
+ protected void next() {
+ if (isAgeType()) {
+ // do nothing only one panel
+ } else if (isInputType()) {
+ setCard("endInputGroupLength");
+ } else if (isSameSizeType()) {
+ setCard("endSameSizeGroupLength");
+ } else if (isGrowthCurveType()) {
+ setCard("endGrowthCurveGroupLength");
+ }
+ wizardUI.prev.setEnabled(true);
+ wizardUI.next.setEnabled(false);
+ wizardUI.finish.setEnabled(true);
+ }
+
+ protected void finish() {
+ if (log.isDebugEnabled()) {
+ log.debug("wizardGroupFinish called");
+ }
+
+ try {
+ Population pop = popBasic.getBean();
+ // remove all old group
+ pop.clearPopulationGroup();
+
+ TopiaContext isisContext = pop.getTopiaContext();
+ PopulationGroupDAO populationGroupDAO = IsisFishDAOHelper.getPopulationGroupDAO(isisContext);
+
+ if (isAgeType()) {
+ double ageFirst = getFirst();
+ double ageLast = getLast();
+ for (int id = 0; id + ageFirst <= ageLast; id++) {
+ PopulationGroup group = populationGroupDAO.create();
+ group.setId(id);
+ group.setPopulation(pop);
+ group.setAge(ageFirst + id);
+ pop.addPopulationGroup(group);
+ populationGroupDAO.update(group);
+ }
+ } else if (isInputType()) {
+ double minLength = getFirst();
+ String[] values = getMaxLength().split(";");
+ for (int i = 0; i < values.length; i++) {
+ if (!"".equals(values[i])) {
+ double length = Double.parseDouble(values[i]);
+ PopulationGroup group = populationGroupDAO.create();
+ group.setId(i);
+ group.setPopulation(pop);
+ group.setMinLength(minLength);
+ group.setMaxLength(length);
+ pop.addPopulationGroup(group);
+ populationGroupDAO.update(group);
+ minLength = length;
+ }
+ }
+
+ } else if (isSameSizeType()) {
+ double minLength = getFirst();
+ int numberOfGroup = getNumberOfGroup();
+ double step = getGroupSize();
+ if (numberOfGroup < 0) {
+ // return new OutputView("Error.xml", "error", t("isisfish.error.number.classes.upper.zero"));
+ }
+ if (step == 0) {
+ // return new OutputView("Error.xml", "error", t"isisfish.error.no.null.time.step"));
+ }
+
+ double maxLength = minLength;
+ for (int i = 0; i < numberOfGroup; i++) {
+ maxLength = minLength + step;
+ PopulationGroup group = populationGroupDAO.create();
+ group.setId(i);
+ group.setPopulation(pop);
+ group.setMinLength(minLength);
+ group.setMaxLength(maxLength);
+ pop.addPopulationGroup(group);
+ populationGroupDAO.update(group);
+ minLength = maxLength;
+ }
+ } else if (isGrowthCurveType()) {
+ double minLength = getFirst();
+ int numberOfGroup = getNumberOfGroup();
+ int step = (int) getStep();
+
+ Equation equation = pop.getGrowth();
+ if (equation == null) {
+ // return new OutputView("Error.xml", "error", t("isisfish.error.growth.equation.before.create.group.population"));
+ }
+ double deltat = -1;
+ double Lmin = minLength;
+ for (int i = 0; i < numberOfGroup; i++) {
+ // on creer la classe avec une valeur Lmax fausses ...
+ PopulationGroup group = populationGroupDAO.create();
+ group.setId(i);
+ group.setPopulation(pop);
+ group.setMinLength(Lmin);
+ group.setMaxLength(Lmin);
+ pop.addPopulationGroup(group);
+
+ if (deltat < 0) {
+ // premier passage, recuperation de l'age minimum
+ deltat = pop.getAge(minLength, group);
+ }
+ // incrementation pour calculer la longueur max de la classe
+ deltat += step;
+
+ // ... pour pouvoir avoir la classe pour l'equation
+ double Lmax = pop.getLength(deltat, group);
+ group.setMaxLength(Lmax);
+ Lmin = Lmax;
+ }
+ }
+ popBasic.getHandler().refresh();
+ cancel();
+ } catch (Exception e) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't create PopulationGroup", e);
+ }
+ }
+
+ }
+
+ protected void cancel() {
+ wizardUI.getParentContainer(JFrame.class).dispose();
+ }
+
+ protected void refreshChoice() {
+ setInputType(wizardUI.beginGroupLengthTypeInput.isSelected());
+ setSameSizeType(wizardUI.beginGroupLengthTypeSameSize.isSelected());
+ setGrowthCurveType(wizardUI.beginGroupLengthTypeGrowthCurve.isSelected());
+ }
+
+ protected void stepChanged() {
+ if (!wizardUI.fieldStep.getText().equals("")) {
+ setStep(Double.parseDouble(wizardUI.fieldStep.getText()));
+ }
+ }
+
+ protected void firstAgeChanged() {
+ if (!wizardUI.firstAge.getText().equals("")) {
+ setFirst(Double.parseDouble(wizardUI.firstAge.getText()));
+ }
+ }
+
+ protected void lastAgeChanged() {
+ if (!wizardUI.lastAge.getText().equals("")) {
+ setLast(Double.parseDouble(wizardUI.lastAge.getText()));
+ }
+ }
+
+ protected void firstInputLengthChanged() {
+ if (!wizardUI.firstInputLength.getText().equals("")) {
+ setFirst(Double.parseDouble(wizardUI.firstInputLength.getText()));
+ }
+ }
+
+ protected void maximalGroupsLengthChanged() {
+ if (!wizardUI.maximalGroupsLength.getText().equals("")) {
+ setMaxLength(wizardUI.maximalGroupsLength.getText());
+ }
+ }
+
+ protected void firstSizeLengthChanged() {
+ if (!wizardUI.firstSizeLength.getText().equals("")) {
+ setFirst(Double.parseDouble(wizardUI.firstSizeLength.getText()));
+ }
+ }
+
+ protected void sameSizeNumberOfGroupChanged() {
+ if (!wizardUI.sameSizeNumberOfGroup.getText().equals("")) {
+ setNumberOfGroup(Integer.parseInt(wizardUI.sameSizeNumberOfGroup.getText()));
+ }
+ }
+
+ protected void groupWidthChanged() {
+ if (!wizardUI.groupWidth.getText().equals("")) {
+ setGroupSize(Double.parseDouble(wizardUI.groupWidth.getText()));
+ }
+ }
+
+ protected void growthCurveFirstGroupChanged() {
+ if (!wizardUI.growthCurveFirstGroup.getText().equals("")) {
+ setFirst(Double.parseDouble(wizardUI.growthCurveFirstGroup.getText()));
+ }
+ }
+
+ protected void fieldNumberOfGroupChanged() {
+ if (!wizardUI.fieldNumberOfGroup.getText().equals("")) {
+ setNumberOfGroup(Integer.parseInt(wizardUI.fieldNumberOfGroup.getText()));
+ }
+ }
+}
Property changes on: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/WizardGroupCreationHandler.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/WizardGroupCreationUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/WizardGroupCreationUI.jaxx 2015-05-18 09:52:01 UTC (rev 4226)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/WizardGroupCreationUI.jaxx 2015-05-20 12:09:09 UTC (rev 4227)
@@ -5,7 +5,7 @@
$Id$
$HeadURL$
%%
- Copyright (C) 2009 - 2011 Ifremer, Code Lutin, Chatellier Eric
+ Copyright (C) 2009 - 2015 Ifremer, Code Lutin, Chatellier Eric
%%
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as
@@ -23,375 +23,16 @@
#L%
-->
<JPanel id="wizardGroup" layout='{new BorderLayout()}'>
- <import>
- org.nuiton.topia.TopiaContext
- fr.ifremer.isisfish.IsisFishDAOHelper
- fr.ifremer.isisfish.entities.Equation
- fr.ifremer.isisfish.entities.Population
- fr.ifremer.isisfish.entities.PopulationGroup
- fr.ifremer.isisfish.entities.PopulationGroupDAO
- java.awt.CardLayout
- javax.swing.JFrame
- </import>
+ <WizardGroupCreationHandler id="handler" />
+
<script><![CDATA[
+ protected void $afterCompleteSetup() {
+ handler.init(this);
+ }
+ ]]></script>
- protected String current = null;
- protected boolean ageType = false;
- protected boolean inputType = false;
- protected boolean sameSizeType = false;
- protected boolean growthCurveType = false;
-
- protected double first = 0;
- protected double last = 0;
-
- protected String maxLength = "";
- protected int numberOfGroup = 0;
- protected double groupSize = 0;
-
- protected double step = 1;
- protected PopulationBasicsUI popBasic;
-
- public void init(PopulationBasicsUI popBasic) {
- this.popBasic = popBasic;
- }
-
- /**
- * @return Returns the ageType.
- */
- public boolean isAgeType() {
- return this.ageType;
- }
-
- /**
- * @param ageType The ageType to set.
- */
- public void setAgeType(boolean ageType) {
- this.ageType = ageType;
- }
-
- /**
- * @return Returns the inputType.
- */
- public boolean isInputType() {
- return this.inputType;
- }
-
- /**
- * @param inputType The inputType to set.
- */
- public void setInputType(boolean inputType) {
- this.inputType = inputType;
- }
-
- /**
- * @return Returns the sameSizeType.
- */
- public boolean isSameSizeType() {
- return this.sameSizeType;
- }
-
- /**
- * @param sameSizeType The sameSizeType to set.
- */
- public void setSameSizeType(boolean sameSizeType) {
- this.sameSizeType = sameSizeType;
- }
-
- /**
- * @return Returns the growthCurveType.
- */
- public boolean isGrowthCurveType() {
- return this.growthCurveType;
- }
-
- /**
- * @param growthCurveType The growthCurveType to set.
- */
- public void setGrowthCurveType(boolean growthCurveType) {
- this.growthCurveType = growthCurveType;
- }
-
- /**
- * @return Returns the first.
- */
- public double getFirst() {
- return this.first;
- }
-
- /**
- * @param first The first to set.
- */
- public void setFirst(double first) {
- this.first = first;
- }
-
- /**
- * @return Returns the last.
- */
- public double getLast() {
- return this.last;
- }
-
- /**
- * @param last The last to set.
- */
- public void setLast(double last) {
- this.last = last;
- }
-
- /**
- * @return Returns the maxLength.
- */
- public String getMaxLength() {
- return this.maxLength;
- }
-
- /**
- * @param maxLength The maxLength to set.
- */
- public void setMaxLength(String maxLength) {
- this.maxLength = maxLength;
- }
-
- /**
- * @return Returns the numberOfGroup.
- */
- public int getNumberOfGroup() {
- return this.numberOfGroup;
- }
-
- /**
- * @param numberOfGroup The numberOfGroup to set.
- */
- public void setNumberOfGroup(int numberOfGroup) {
- this.numberOfGroup = numberOfGroup;
- }
-
- /**
- * @return Returns the groupSize.
- */
- public double getGroupSize() {
- return this.groupSize;
- }
-
- /**
- * @param groupSize The groupSize to set.
- */
- public void setGroupSize(double groupSize) {
- this.groupSize = groupSize;
- }
-
- /**
- * @return Returns the step.
- */
- public double getStep() {
- return this.step;
- }
-
- /**
- * @param step The step to set.
- */
- public void setStep(double step) {
- this.step = step;
- }
-
- public void setCard(String name){
- current = name;
- ((CardLayout) wizardPanels.getLayout()).show(wizardPanels, name);
- }
- protected void prev(){
- if (isAgeType()) {
- // do nothing only one panel
- } else {
- setCard("beginGroupLength");
- }
- prev.setEnabled(false);
- next.setEnabled(true);
- finish.setEnabled(false);
- }
- protected void next(){
- if (isAgeType()) {
- // do nothing only one panel
- } else if (isInputType()) {
- setCard("endInputGroupLength");
- } else if (isSameSizeType()) {
- setCard("endSameSizeGroupLength");
- } else if (isGrowthCurveType()) {
- setCard("endGrowthCurveGroupLength");
- }
- prev.setEnabled(true);
- next.setEnabled(false);
- finish.setEnabled(true);
- }
- protected void finish() {
- if (log.isDebugEnabled()) {
- log.debug("wizardGroupFinish called");
- }
-
- try {
- Population pop = popBasic.getBean();
- // remove all old group
- pop.clearPopulationGroup();
-
- TopiaContext isisContext = pop.getTopiaContext();
- PopulationGroupDAO populationGroupDAO = IsisFishDAOHelper.getPopulationGroupDAO(isisContext);
-
- if (isAgeType()) {
- double ageFirst = getFirst();
- double ageLast = getLast();
- for (int id=0; id + ageFirst <= ageLast; id++) {
- PopulationGroup group = populationGroupDAO.create();
- group.setId(id);
- group.setPopulation(pop);
- group.setAge(ageFirst + id);
- pop.addPopulationGroup(group);
- populationGroupDAO.update(group);
- }
- } else if (isInputType()) {
- double minLength = getFirst();
- String [] values = getMaxLength().split(";");
- for(int i=0; i<values.length; i++){
- if (!"".equals(values[i])) {
- double length = Double.parseDouble(values[i]);
- PopulationGroup group = populationGroupDAO.create();
- group.setId(i);
- group.setPopulation(pop);
- group.setMinLength(minLength);
- group.setMaxLength(length);
- pop.addPopulationGroup(group);
- populationGroupDAO.update(group);
- minLength = length;
- }
- }
-
- } else if (isSameSizeType()) {
- double minLength = getFirst();
- int numberOfGroup = getNumberOfGroup();
- double step = getGroupSize();
- if (numberOfGroup < 0){
-// return new OutputView("Error.xml", "error", t("isisfish.error.number.classes.upper.zero"));
- }
- if (step == 0){
-// return new OutputView("Error.xml", "error", t"isisfish.error.no.null.time.step"));
- }
-
- double maxLength = minLength;
- for(int i=0; i<numberOfGroup; i++){
- maxLength = minLength + step;
- PopulationGroup group = populationGroupDAO.create();
- group.setId(i);
- group.setPopulation(pop);
- group.setMinLength(minLength);
- group.setMaxLength(maxLength);
- pop.addPopulationGroup(group);
- populationGroupDAO.update(group);
- minLength = maxLength;
- }
- } else if (isGrowthCurveType()) {
- double minLength = getFirst();
- int numberOfGroup = getNumberOfGroup();
- int step = (int)getStep();
-
- Equation equation = pop.getGrowth();
- if(equation == null){
-// return new OutputView("Error.xml", "error", t("isisfish.error.growth.equation.before.create.group.population"));
- }
- double deltat = -1;
- double Lmin = minLength;
- for(int i=0; i<numberOfGroup; i++){
- // on creer la classe avec une valeur Lmax fausses ...
- PopulationGroup group = populationGroupDAO.create();
- group.setId(i);
- group.setPopulation(pop);
- group.setMinLength(Lmin);
- group.setMaxLength(Lmin);
- pop.addPopulationGroup(group);
-
- if(deltat < 0) {
- // premier passage, recuperation de l'age minimum
- deltat = pop.getAge(minLength, group);
- }
- // incrementation pour calculer la longueur max de la classe
- deltat += step;
-
- // ... pour pouvoir avoir la classe pour l'equation
- double Lmax = pop.getLength(deltat, group);
- group.setMaxLength(Lmax);
- Lmin = Lmax;
- }
- }
- popBasic.refresh();
- cancel();
- }
- catch(Exception e) {
- if (log.isErrorEnabled()) {
- log.error("Can't create PopulationGroup", e);
- }
- }
-
- }
- protected void cancel(){
- getParentContainer(JFrame.class).dispose();
- }
- protected void refreshChoice(){
- setInputType(beginGroupLengthTypeInput.isSelected());
- setSameSizeType(beginGroupLengthTypeSameSize.isSelected());
- setGrowthCurveType(beginGroupLengthTypeGrowthCurve.isSelected());
- }
- protected void stepChanged(){
- if (!fieldStep.getText().equals("")){
- setStep(Double.parseDouble(fieldStep.getText()));
- }
- }
- protected void firstAgeChanged(){
- if (!firstAge.getText().equals("")){
- setFirst(Double.parseDouble(firstAge.getText()));
- }
- }
- protected void lastAgeChanged(){
- if(!lastAge.getText().equals("")){
- setLast(Double.parseDouble(lastAge.getText()));
- }
- }
- protected void firstInputLengthChanged(){
- if(!firstInputLength.getText().equals("")){
- setFirst(Double.parseDouble(firstInputLength.getText()));
- }
- }
- protected void maximalGroupsLengthChanged(){
- if(!maximalGroupsLength.getText().equals("")){
- setMaxLength(maximalGroupsLength.getText());
- }
- }
- protected void firstSizeLengthChanged(){
- if(!firstSizeLength.getText().equals("")){
- setFirst(Double.parseDouble(firstSizeLength.getText()));
- }
- }
- protected void sameSizeNumberOfGroupChanged(){
- if(!sameSizeNumberOfGroup.getText().equals("")){
- setNumberOfGroup(Integer.parseInt(sameSizeNumberOfGroup.getText()));
- }
- }
- protected void groupWidthChanged(){
- if(!groupWidth.getText().equals("")){
- setGroupSize(Double.parseDouble(groupWidth.getText()));
- }
- }
- protected void growthCurveFirstGroupChanged(){
- if(!growthCurveFirstGroup.getText().equals("")){
- setFirst(Double.parseDouble(growthCurveFirstGroup.getText()));
- }
- }
- protected void fieldNumberOfGroupChanged(){
- if(!fieldNumberOfGroup.getText().equals("")){
- setNumberOfGroup(Integer.parseInt(fieldNumberOfGroup.getText()));
- }
- }
- ]]>
- </script>
- <JPanel id="wizardPanels" layout='{new CardLayout()}' constraints='BorderLayout.CENTER'>
+ <JPanel id="wizardPanels" layout='{new java.awt.CardLayout()}' constraints='BorderLayout.CENTER'>
<Table constraints='"beginGroupLength"'>
<row>
<cell fill='horizontal' weightx='1.0'>
@@ -400,17 +41,20 @@
</row>
<row>
<cell fill='horizontal' weightx='1.0'>
- <JRadioButton id="beginGroupLengthTypeInput" buttonGroup="groupLengthType" text="isisfish.wizardGroupCreation.allValues" onActionPerformed='refreshChoice()'/>
+ <JRadioButton id="beginGroupLengthTypeInput" buttonGroup="groupLengthType"
+ text="isisfish.wizardGroupCreation.allValues" onActionPerformed='handler.refreshChoice()'/>
</cell>
</row>
<row>
<cell fill='horizontal' weightx='1.0'>
- <JRadioButton id="beginGroupLengthTypeSameSize" buttonGroup="groupLengthType" text="isisfish.wizardGroupCreation.allGroupsSameSize" onActionPerformed='refreshChoice()'/>
+ <JRadioButton id="beginGroupLengthTypeSameSize" buttonGroup="groupLengthType"
+ text="isisfish.wizardGroupCreation.allGroupsSameSize" onActionPerformed='handler.refreshChoice()'/>
</cell>
</row>
<row>
<cell fill='horizontal' weightx='1.0'>
- <JRadioButton id="beginGroupLengthTypeGrowthCurve" buttonGroup="groupLengthType" text="isisfish.wizardGroupCreation.computedGrowthCurve" onActionPerformed='refreshChoice()'/>
+ <JRadioButton id="beginGroupLengthTypeGrowthCurve" buttonGroup="groupLengthType"
+ text="isisfish.wizardGroupCreation.computedGrowthCurve" onActionPerformed='handler.refreshChoice()'/>
</cell>
</row>
</Table>
@@ -425,7 +69,7 @@
<JLabel text="isisfish.wizardGroupCreation.firstAge"/>
</cell>
<cell fill='horizontal' weightx='1.0'>
- <JTextField id="firstAge" onFocusLost='firstAgeChanged()'/>
+ <JTextField id="firstAge" onFocusLost='handler.firstAgeChanged()'/>
</cell>
</row>
<row>
@@ -433,7 +77,7 @@
<JLabel text="isisfish.wizardGroupCreation.lastAge"/>
</cell>
<cell fill='horizontal' weightx='1.0'>
- <JTextField id="lastAge" onFocusLost='lastAgeChanged()'/>
+ <JTextField id="lastAge" onFocusLost='handler.lastAgeChanged()'/>
</cell>
</row>
<row>
@@ -463,7 +107,7 @@
<JLabel text="isisfish.wizardGroupCreation.firstLength"/>
</cell>
<cell fill='horizontal' weightx='1.0'>
- <JTextField id="firstInputLength" onFocusLost='firstInputLengthChanged()'/>
+ <JTextField id="firstInputLength" onFocusLost='handler.firstInputLengthChanged()'/>
</cell>
</row>
<row>
@@ -471,7 +115,7 @@
<JLabel text="isisfish.wizardGroupCreation.maxGroupsLength"/>
</cell>
<cell fill='horizontal' weightx='1.0'>
- <JTextField id="maximalGroupsLength" onFocusLost='maximalGroupsLengthChanged()'/>
+ <JTextField id="maximalGroupsLength" onFocusLost='handler.maximalGroupsLengthChanged()'/>
</cell>
</row>
<row>
@@ -491,7 +135,7 @@
<JLabel text="isisfish.wizardGroupCreation.firstLength"/>
</cell>
<cell fill='horizontal' weightx='1.0'>
- <JTextField id="firstSizeLength" onFocusLost='firstSizeLengthChanged()'/>
+ <JTextField id="firstSizeLength" onFocusLost='handler.firstSizeLengthChanged()'/>
</cell>
</row>
<row>
@@ -499,7 +143,7 @@
<JLabel text="isisfish.wizardGroupCreation.numberGroup"/>
</cell>
<cell fill='horizontal' weightx='1.0'>
- <JTextField id="sameSizeNumberOfGroup" onFocusLost='sameSizeNumberOfGroupChanged()'/>
+ <JTextField id="sameSizeNumberOfGroup" onFocusLost='handler.sameSizeNumberOfGroupChanged()'/>
</cell>
</row>
<row>
@@ -507,7 +151,7 @@
<JLabel text="isisfish.wizardGroupCreation.groupWidth"/>
</cell>
<cell fill='horizontal' weightx='1.0'>
- <JTextField id="groupWidth" onFocusLost='groupWidthChanged()'/>
+ <JTextField id="groupWidth" onFocusLost='handler.groupWidthChanged()'/>
</cell>
</row>
<row>
@@ -537,7 +181,7 @@
<JLabel text="isisfish.wizardGroupCreation.firstGroup"/>
</cell>
<cell fill='horizontal' weightx='1.0'>
- <JTextField id="growthCurveFirstGroup" onFocusLost='growthCurveFirstGroupChanged()'/>
+ <JTextField id="growthCurveFirstGroup" onFocusLost='handler.growthCurveFirstGroupChanged()'/>
</cell>
</row>
<row>
@@ -545,7 +189,7 @@
<JLabel text="isisfish.wizardGroupCreation.numberGroups"/>
</cell>
<cell fill='horizontal' weightx='1.0'>
- <JTextField id="fieldNumberOfGroup" onFocusLost='fieldNumberOfGroupChanged()'/>
+ <JTextField id="fieldNumberOfGroup" onFocusLost='handler.fieldNumberOfGroupChanged()'/>
</cell>
</row>
<row>
@@ -553,7 +197,7 @@
<JLabel text="isisfish.wizardGroupCreation.timeStep"/>
</cell>
<cell fill='horizontal' weightx='1.0'>
- <JTextField id="fieldStep" onFocusLost='stepChanged()'/>
+ <JTextField id="fieldStep" onFocusLost='handler.stepChanged()'/>
</cell>
</row>
<row>
@@ -566,16 +210,16 @@
<Table id="navButton" constraints='BorderLayout.SOUTH'>
<row>
<cell fill='horizontal' weightx='0.2'>
- <JButton id='prev' enabled='false' text="isisfish.common.prev" onActionPerformed='prev()'/>
+ <JButton id='prev' enabled='false' text="isisfish.common.prev" onActionPerformed='handler.prev()'/>
</cell>
<cell fill='horizontal' weightx='0.2'>
- <JButton id='next' text="isisfish.common.next" onActionPerformed='next()'/>
+ <JButton id='next' text="isisfish.common.next" onActionPerformed='handler.next()'/>
</cell>
<cell fill='horizontal' weightx='0.2'>
- <JButton id='finish' enabled='false' text="isisfish.common.finish" onActionPerformed='finish()'/>
+ <JButton id='finish' enabled='false' text="isisfish.common.finish" onActionPerformed='handler.finish()'/>
</cell>
<cell fill='horizontal' weightx='0.2'>
- <JButton id='cancel' text="isisfish.common.cancel" onActionPerformed='cancel()'/>
+ <JButton id='cancel' text="isisfish.common.cancel" onActionPerformed='handler.cancel()'/>
</cell>
</row>
</Table>
Added: trunk/src/main/java/fr/ifremer/isisfish/ui/input/port/PortHandler.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/port/PortHandler.java (rev 0)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/port/PortHandler.java 2015-05-20 12:09:09 UTC (rev 4227)
@@ -0,0 +1,106 @@
+/*
+ * #%L
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2015 Ifremer, Codelutin, Chatellier Eric
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+package fr.ifremer.isisfish.ui.input.port;
+
+import static org.nuiton.i18n.I18n.n;
+import static org.nuiton.i18n.I18n.t;
+
+import java.awt.event.MouseEvent;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+
+import com.bbn.openmap.event.SelectMouseMode;
+
+import fr.ifremer.isisfish.entities.Cell;
+import fr.ifremer.isisfish.map.CellSelectionLayer;
+import fr.ifremer.isisfish.map.OpenMapEvents;
+import fr.ifremer.isisfish.ui.input.InputContentHandler;
+import fr.ifremer.isisfish.ui.models.common.GenericListModel;
+
+/**
+ * Port handler.
+ */
+public class PortHandler extends InputContentHandler<PortUI> {
+
+ protected boolean init = false;
+
+ protected void init(final PortUI inputContentUI) {
+ super.init(inputContentUI);
+
+ new OpenMapEvents(inputContentUI.portMap, new SelectMouseMode(false), CellSelectionLayer.SINGLE_SELECTION) {
+ @Override
+ public boolean mouseClicked(MouseEvent e) {
+ if (inputContentUI.getBean() != null) { // impossible de desactiver la carte :(
+ for (Cell c : inputContentUI.portMap.getSelectedCells()) {
+ if (inputContentUI.getBean().getCell() != null) {
+ if (!inputContentUI.getBean().getCell().getTopiaId().equals(c.getTopiaId())){
+ inputContentUI.portCell.setSelectedValue(c, true);
+ return true;
+ }
+ } else {
+ inputContentUI.portCell.setSelectedValue(c, true);
+ return true;
+ }
+ }
+ }
+ return true;
+ }
+ };
+
+ inputContentUI.setButtonTitle(t("isisfish.input.continueSpecies"));
+ inputContentUI.setNextPath(n("isisfish.input.tree.species"));
+
+ inputContentUI.addPropertyChangeListener(PortUI.PROPERTY_BEAN, new PropertyChangeListener() {
+ public void propertyChange(PropertyChangeEvent evt) {
+ if (evt.getNewValue() == null) {
+ inputContentUI.fieldPortName.setText("");
+ inputContentUI.fieldPortComment.setText("");
+ }
+ if (evt.getNewValue() != null) {
+
+ }
+ fillCellList();
+ }
+ });
+ }
+
+ protected void fillCellList() {
+ GenericListModel<Cell> cellModel = new GenericListModel<>();
+ if (inputContentUI.getBean() != null) {
+ init = true;
+ cellModel.setElementList(inputContentUI.getFisheryRegion().getCell());
+ inputContentUI.portCell.setModel(cellModel);
+ inputContentUI.portCell.setSelectedValue(inputContentUI.getBean().getCell(), true);
+ init = false;
+ } else {
+ inputContentUI.portCell.setModel(cellModel);
+ }
+ }
+
+ protected void portChanged() {
+ if (inputContentUI.getBean() != null && !init) {
+ inputContentUI.getBean().setCell(inputContentUI.portCell.getSelectedValue());
+ }
+ }
+}
Property changes on: trunk/src/main/java/fr/ifremer/isisfish/ui/input/port/PortHandler.java
___________________________________________________________________
Added: svn:eol-style
+ native
Added: svn:keywords
+ Author Date Id Revision HeadURL
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/port/PortUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/port/PortUI.jaxx 2015-05-18 09:52:01 UTC (rev 4226)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/port/PortUI.jaxx 2015-05-20 12:09:09 UTC (rev 4227)
@@ -27,20 +27,7 @@
<!-- bean property -->
<fr.ifremer.isisfish.entities.Port id='bean' javaBean='null'/>
- <import>
- static org.nuiton.i18n.I18n.t
- static org.nuiton.i18n.I18n.n
- fr.ifremer.isisfish.entities.Port
- fr.ifremer.isisfish.entities.Cell
- fr.ifremer.isisfish.map.CellSelectionLayer
- fr.ifremer.isisfish.map.CopyMapToClipboardListener
- fr.ifremer.isisfish.map.OpenMapEvents
- com.bbn.openmap.event.SelectMouseMode
- java.beans.PropertyChangeEvent
- java.beans.PropertyChangeListener
- java.awt.event.MouseEvent
- fr.ifremer.isisfish.ui.models.common.GenericListModel
- </import>
+ <PortHandler id="handler" />
<BeanValidator id='validator'
bean='{getBean()}' beanClass='fr.ifremer.isisfish.entities.Port'
@@ -50,79 +37,11 @@
</BeanValidator>
<script><![CDATA[
-boolean init = false;
-
-protected void $afterCompleteSetup() {
-
- //portMap.init(portMapInfo);
- new OpenMapEvents(portMap, new SelectMouseMode(false), CellSelectionLayer.SINGLE_SELECTION) {
- @Override
- public boolean mouseClicked(MouseEvent e) {
- if (getBean() != null) { // impossible de desactiver la carte :(
- for (Cell c : portMap.getSelectedCells()) {
- if (getBean().getCell() != null) {
- if (!getBean().getCell().getTopiaId().equals(c.getTopiaId())){
- portCell.setSelectedValue(c, true);
- return true;
- }
- }
- else {
- portCell.setSelectedValue(c, true);
- return true;
- }
- }
- }
- return true;
- }
- };
-
- setButtonTitle(t("isisfish.input.continueSpecies"));
- setNextPath(n("isisfish.input.tree.species"));
-
- addPropertyChangeListener(PROPERTY_BEAN, new PropertyChangeListener() {
- public void propertyChange(PropertyChangeEvent evt) {
- if (evt.getNewValue() == null) {
- fieldPortName.setText("");
- fieldPortComment.setText("");
- }
- if (evt.getNewValue() != null) {
-
- }
- fillCellList();
- }
- });
-}
-
-/*public void refresh() {
- Port port = getSaveVerifier().getEntity(Port.class);
-
- // add null before, for second to be considered as a changed event
- // otherwize, setBean has no effect
- setBean(null);
- setBean(port);
- // reload region in map
- refreshRegionInMap(portMap);
-}*/
-
-protected void fillCellList() {
- GenericListModel<Cell> cellModel = new GenericListModel<>();
- if (getBean() != null) {
- init = true;
- cellModel.setElementList(getFisheryRegion().getCell());
- portCell.setModel(cellModel);
- portCell.setSelectedValue(getBean().getCell(), true);
- init = false;
- } else {
- portCell.setModel(cellModel);
+ protected void $afterCompleteSetup() {
+ handler.init(this);
}
-}
-
-protected void portChanged() {
- if (getBean() != null && !init) {
- getBean().setCell(portCell.getSelectedValue());
- }
-}
]]></script>
+
<JPanel id="body">
<JSplitPane oneTouchExpandable="true" dividerLocation="270" orientation="horizontal">
<Table>
@@ -147,7 +66,7 @@
<JScrollPane id="spPortCell">
<JList id="portCell"
genericType="fr.ifremer.isisfish.entities.Cell" selectionMode="{javax.swing.ListSelectionModel.SINGLE_SELECTION}"
- onValueChanged='portChanged()' enabled='{isActive()}' decorator='boxed' />
+ onValueChanged='handler.portChanged()' enabled='{isActive()}' decorator='boxed' />
</JScrollPane>
</cell>
</row>
@@ -159,7 +78,8 @@
<row>
<cell columns='2' fill='both' weighty='0.3' weightx='1.0' >
<JScrollPane>
- <JTextArea id="fieldPortComment" text='{SwingUtil.getStringValue(getBean().getComment())}' onKeyReleased='getBean().setComment(fieldPortComment.getText())' enabled='{isActive()}' decorator='boxed'/>
+ <JTextArea id="fieldPortComment" text='{SwingUtil.getStringValue(getBean().getComment())}'
+ onKeyReleased='getBean().setComment(fieldPortComment.getText())' enabled='{isActive()}' decorator='boxed'/>
</JScrollPane>
</cell>
</row>
Added: trunk/src/main/java/fr/ifremer/isisfish/ui/input/setofvessels/EffortDescriptionHandler.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/setofvessels/EffortDescriptionHandler.java (rev 0)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/setofvessels/EffortDescriptionHandler.java 2015-05-20 12:09:09 UTC (rev 4227)
@@ -0,0 +1,106 @@
+/*
+ * #%L
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2015 Ifremer, Codelutin, Chatellier Eric
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+package fr.ifremer.isisfish.ui.input.setofvessels;
+
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.util.ArrayList;
+import java.util.List;
+
+import fr.ifremer.isisfish.entities.EffortDescription;
+import fr.ifremer.isisfish.entities.Metier;
+import fr.ifremer.isisfish.ui.input.InputAction;
+import fr.ifremer.isisfish.ui.input.InputContentHandler;
+import fr.ifremer.isisfish.ui.models.common.GenericListModel;
+
+/**
+ * set of vessels handler.
+ */
+public class EffortDescriptionHandler extends InputContentHandler<EffortDescriptionUI> {
+
+ protected void init(final EffortDescriptionUI inputContentUI) {
+ super.init(inputContentUI);
+
+ inputContentUI.addPropertyChangeListener(EffortDescriptionUI.PROPERTY_BEAN, new PropertyChangeListener() {
+ public void propertyChange(PropertyChangeEvent evt) {
+ GenericListModel<Metier> metierModel = (GenericListModel<Metier>)inputContentUI.fieldEffortDescriptionMetierList.getModel();
+ if (evt.getNewValue() == null) {
+ metierModel.setElementList(null);
+ }
+ if (evt.getNewValue() != null) {
+ metierModel.setElementList(inputContentUI.getFisheryRegion().getMetier());
+ setEffortDescriptionEffortDescriptionList();
+ }
+ }
+ });
+ }
+
+ /**
+ * Get input action from context.
+ */
+ @Deprecated
+ protected InputAction getInputAction() {
+ return inputContentUI.getContextValue(InputAction.class);
+ }
+
+ protected void onFieldEffortDescriptionMetierListValueChanged() {
+ // active le bouton seulement si l'interface est active
+ // dans le cas de sensitivity par exemple
+ if (inputContentUI.isActive()) {
+ inputContentUI.buttonEffortDescriptionAdd.setEnabled(inputContentUI.fieldEffortDescriptionMetierList.getSelectedIndex() != -1);
+ }
+ }
+
+ protected void onFieldEffortDescriptionEffortDescriptionListValueChanged() {
+ // active le bouton seulement si l'interface est active
+ // dans le cas de sensitivity par exemple
+ if (inputContentUI.isActive()) {
+ inputContentUI.removeEffortDescriptionButton.setEnabled(inputContentUI.fieldEffortDescriptionEffortDescriptionList.getSelectedIndex() != -1);
+ }
+ }
+
+ protected void setEffortDescriptionEffortDescriptionList() {
+ GenericListModel<EffortDescription> model = new GenericListModel<>();
+ if (inputContentUI.getBean() != null && inputContentUI.getBean().getPossibleMetiers() != null) {
+ List<EffortDescription> effortDescriptions = new ArrayList<>(inputContentUI.getBean().getPossibleMetiers());
+ model.setElementList(effortDescriptions);
+ }
+ inputContentUI.fieldEffortDescriptionEffortDescriptionList.setModel(model);
+ }
+
+ protected void addEffortDescriptions() {
+ List<Metier> selectedValues = inputContentUI.fieldEffortDescriptionMetierList.getSelectedValuesList();
+ for (Metier selectedMetier : selectedValues) {
+ getInputAction().addEffortDescription(inputContentUI.getBean(), selectedMetier);
+ }
+ setEffortDescriptionEffortDescriptionList();
+ }
+ protected void removeEffortDescriptions() {
+ List<EffortDescription> selectedValues = inputContentUI.fieldEffortDescriptionEffortDescriptionList.getSelectedValuesList();
+ for (EffortDescription selectedEffortDescription : selectedValues) {
+ getInputAction().removeEffortDescription(inputContentUI.getBean(), selectedEffortDescription);
+ }
+ setEffortDescriptionEffortDescriptionList();
+ }
+}
Property changes on: trunk/src/main/java/fr/ifremer/isisfish/ui/input/setofvessels/EffortDescriptionHandler.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Copied: trunk/src/main/java/fr/ifremer/isisfish/ui/input/setofvessels/EffortDescriptionListRenderer.java (from rev 4226, trunk/src/main/java/fr/ifremer/isisfish/ui/input/renderer/EffortDescriptionListRenderer.java)
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/setofvessels/EffortDescriptionListRenderer.java (rev 0)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/setofvessels/EffortDescriptionListRenderer.java 2015-05-20 12:09:09 UTC (rev 4227)
@@ -0,0 +1,67 @@
+/*
+ * #%L
+ * IsisFish
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2009 - 2010 Ifremer, CodeLutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+package fr.ifremer.isisfish.ui.input.setofvessels;
+
+import java.awt.Component;
+
+import javax.swing.DefaultListCellRenderer;
+import javax.swing.JLabel;
+import javax.swing.JList;
+
+import fr.ifremer.isisfish.entities.EffortDescription;
+
+/**
+ * Renderer pour liste des {@link EffortDescription}.
+ *
+ * @author chatellier
+ * @version $Revision$
+ *
+ * Last update : $Date$
+ * By : $Author$
+ */
+public class EffortDescriptionListRenderer extends DefaultListCellRenderer {
+
+ /** serialVersionUID. */
+ private static final long serialVersionUID = 1113492654780402245L;
+
+ /*
+ * @see javax.swing.ListCellRenderer#getListCellRendererComponent(javax.swing.JList, java.lang.Object, int, boolean, boolean)
+ */
+ @Override
+ public Component getListCellRendererComponent(JList<?> list, Object value,
+ int index, boolean isSelected, boolean cellHasFocus) {
+
+ // this must be used to have alterned highlight rows and default
+ // selection color
+ JLabel c = (JLabel) super.getListCellRendererComponent(list, value,
+ index, isSelected, cellHasFocus);
+
+ EffortDescription effort = (EffortDescription) value;
+ c.setText(effort.getPossibleMetiers().getName());
+
+ return c;
+ }
+}
Added: trunk/src/main/java/fr/ifremer/isisfish/ui/input/setofvessels/EffortDescriptionParametersHandler.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/setofvessels/EffortDescriptionParametersHandler.java (rev 0)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/setofvessels/EffortDescriptionParametersHandler.java 2015-05-20 12:09:09 UTC (rev 4227)
@@ -0,0 +1,109 @@
+/*
+ * #%L
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2015 Ifremer, Codelutin, Chatellier Eric
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+package fr.ifremer.isisfish.ui.input.setofvessels;
+
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.util.ArrayList;
+import java.util.List;
+
+import fr.ifremer.isisfish.entities.EffortDescription;
+import fr.ifremer.isisfish.ui.input.InputContentHandler;
+import fr.ifremer.isisfish.ui.models.common.GenericListModel;
+
+/**
+ * set of vessels handler.
+ */
+public class EffortDescriptionParametersHandler extends InputContentHandler<EffortDescriptionParametersUI> {
+
+ protected void init(final EffortDescriptionParametersUI inputContentUI) {
+ super.init(inputContentUI);
+
+ inputContentUI.addPropertyChangeListener(EffortDescriptionParametersUI.PROPERTY_BEAN, new PropertyChangeListener() {
+ public void propertyChange(PropertyChangeEvent evt) {
+ if (evt.getNewValue() == null) {
+ inputContentUI.setEffortDescription(null);
+ }
+ if (evt.getNewValue() != null) {
+ GenericListModel<EffortDescription> model = new GenericListModel<>();
+ // getBean().getPossibleMetiers() can be null at region creation
+ if (inputContentUI.getBean() != null && inputContentUI.getBean().getPossibleMetiers() != null) {
+ List<EffortDescription> effortDescriptions = new ArrayList<>(inputContentUI.getBean().getPossibleMetiers());
+ model.setElementList(effortDescriptions);
+ }
+ inputContentUI.fieldEffortDescriptionEffortDescriptionList.setModel(model);
+ }
+ }
+ });
+ inputContentUI.addPropertyChangeListener(EffortDescriptionParametersUI.PROPERTY_EFFORT_DESCRIPTION, new PropertyChangeListener() {
+ public void propertyChange(PropertyChangeEvent evt) {
+ if (evt.getNewValue() == null) {
+ inputContentUI.fieldEffortDescriptionFishingOperation.setText("");
+ inputContentUI.fieldEffortDescriptionFishingOperationDuration.setText("");
+ inputContentUI.fieldEffortDescriptionGearsNumberPerOperation.setText("");
+ inputContentUI.fieldEffortDescriptionCrewSize.setText("");
+ inputContentUI.fieldEffortDescriptionUnitCostOfFishing.setText("");
+ inputContentUI.fieldEffortDescriptionFixedCrewSalary.setText("");
+ inputContentUI.fieldEffortDescriptionCrewFoodCost.setText("");
+ inputContentUI.fieldEffortDescriptionCrewShareRate.setText("");
+ inputContentUI.fieldEffortDescriptionRepairAndMaintenanceGearCost.setText("");
+ inputContentUI.fieldEffortDescriptionLandingCosts.setText("");
+ inputContentUI.fieldEffortDescriptionOtherRunningCost.setText("");
+ }
+ if (evt.getNewValue() != null) {
+ // FIX non working binding in jaxx 2.4.1
+ if (inputContentUI.getEffortDescription().getFishingOperationDuration() == null) {
+ inputContentUI.fieldEffortDescriptionFishingOperationDuration.setText("");
+ }
+ }
+ }
+ });
+ }
+
+ protected void effortDescriptionSelectionChanged() {
+ EffortDescription selectedEffort = (EffortDescription)inputContentUI.fieldEffortDescriptionEffortDescriptionList.getSelectedValue();
+ inputContentUI.setEffortDescription(selectedEffort);
+
+ if (inputContentUI.getEffortDescription() != null) {
+ inputContentUI.getSaveVerifier().addCurrentEntity(inputContentUI.getEffortDescription());
+ selectedEffort.addPropertyChangeListener(new PropertyChangeListener() {
+ public void propertyChange(PropertyChangeEvent evt) {
+ inputContentUI.changeModel.setStayChanged(true);
+ }
+ });
+
+ /* NumberEditor is not working
+ fieldEffortDescriptionFishingOperation.init();
+ fieldEffortDescriptionGearsNumberPerOperation.init();
+ fieldEffortDescriptionCrewSize.init();
+ fieldEffortDescriptionUnitCostOfFishing.init();
+ fieldEffortDescriptionFixedCrewSalary.init();
+ fieldEffortDescriptionCrewFoodCost.init();
+ fieldEffortDescriptionCrewShareRate.init();
+ fieldEffortDescriptionRepairAndMaintenanceGearCost.init();
+ fieldEffortDescriptionLandingCosts.init();
+ fieldEffortDescriptionOtherRunningCost.init();*/
+ }
+ }
+}
Property changes on: trunk/src/main/java/fr/ifremer/isisfish/ui/input/setofvessels/EffortDescriptionParametersHandler.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/setofvessels/EffortDescriptionParametersUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/setofvessels/EffortDescriptionParametersUI.jaxx 2015-05-18 09:52:01 UTC (rev 4226)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/setofvessels/EffortDescriptionParametersUI.jaxx 2015-05-20 12:09:09 UTC (rev 4227)
@@ -29,18 +29,8 @@
<fr.ifremer.isisfish.entities.EffortDescription id='effortDescription' javaBean='null'/>
- <import>
- static org.nuiton.i18n.I18n.t
- java.util.ArrayList;
- fr.ifremer.isisfish.entities.EffortDescription;
- fr.ifremer.isisfish.entities.SetOfVessels;
- fr.ifremer.isisfish.types.TimeUnit;
- fr.ifremer.isisfish.ui.models.common.GenericListModel;
- fr.ifremer.isisfish.ui.input.renderer.EffortDescriptionListRenderer;
- java.beans.PropertyChangeEvent;
- java.beans.PropertyChangeListener;
- </import>
-
+ <EffortDescriptionParametersHandler id="handler" />
+
<BeanValidator id='validator' context="effortdescriptionparameters"
bean='{getBean()}' beanClass='fr.ifremer.isisfish.entities.SetOfVessels'
uiClass="jaxx.runtime.validator.swing.ui.ImageValidationUI">
@@ -54,89 +44,21 @@
<fr.ifremer.isisfish.ui.input.ChangeModel id="changeModel" changed="{validator.isChanged() || validatorEffort.isChanged()}"
valid="{validator.isValid() && validatorEffort.isValid()}"/>
- <script><![CDATA[
-protected void $afterCompleteSetup() {
- addPropertyChangeListener(PROPERTY_BEAN, new PropertyChangeListener() {
- public void propertyChange(PropertyChangeEvent evt) {
- if (evt.getNewValue() == null) {
- setEffortDescription(null);
- }
- if (evt.getNewValue() != null) {
- GenericListModel<EffortDescription> model = new GenericListModel<>();
- // getBean().getPossibleMetiers() can be null at region creation
- if (getBean() != null && getBean().getPossibleMetiers() != null) {
- List<EffortDescription> effortDescriptions = new ArrayList<EffortDescription>(getBean().getPossibleMetiers());
- model.setElementList(effortDescriptions);
- }
- fieldEffortDescriptionEffortDescriptionList.setModel(model);
- }
- }
- });
- addPropertyChangeListener(PROPERTY_EFFORT_DESCRIPTION, new PropertyChangeListener() {
- public void propertyChange(PropertyChangeEvent evt) {
- if (evt.getNewValue() == null) {
- fieldEffortDescriptionFishingOperation.setText("");
- fieldEffortDescriptionFishingOperationDuration.setText("");
- fieldEffortDescriptionGearsNumberPerOperation.setText("");
- fieldEffortDescriptionCrewSize.setText("");
- fieldEffortDescriptionUnitCostOfFishing.setText("");
- fieldEffortDescriptionFixedCrewSalary.setText("");
- fieldEffortDescriptionCrewFoodCost.setText("");
- fieldEffortDescriptionCrewShareRate.setText("");
- fieldEffortDescriptionRepairAndMaintenanceGearCost.setText("");
- fieldEffortDescriptionLandingCosts.setText("");
- fieldEffortDescriptionOtherRunningCost.setText("");
- }
- if (evt.getNewValue() != null) {
- // FIX non working binding in jaxx 2.4.1
- if (getEffortDescription().getFishingOperationDuration() == null) {
- fieldEffortDescriptionFishingOperationDuration.setText("");
- }
- }
- }
- });
-}
+ <import>
+ fr.ifremer.isisfish.types.TimeUnit
+ </import>
-@Override
-public void resetChangeModel() {
- changeModel.setStayChanged(false);
-}
-
-/*public void refresh() {
- SetOfVessels setOfVessels = getSaveVerifier().getEntity(SetOfVessels.class);
-
- // twice event for jaxx bindings detection
- setBean(null);
- setBean(setOfVessels);
-}*/
-
-protected void effortDescriptionSelectionChanged() {
- EffortDescription selectedEffort = (EffortDescription)fieldEffortDescriptionEffortDescriptionList.getSelectedValue();
- setEffortDescription(selectedEffort);
-
- if (getEffortDescription() != null) {
- getSaveVerifier().addCurrentEntity(getEffortDescription());
- selectedEffort.addPropertyChangeListener(new PropertyChangeListener() {
- public void propertyChange(PropertyChangeEvent evt) {
- changeModel.setStayChanged(true);
- }
- });
-
- /* NumberEditor is not working
- fieldEffortDescriptionFishingOperation.init();
- fieldEffortDescriptionGearsNumberPerOperation.init();
- fieldEffortDescriptionCrewSize.init();
- fieldEffortDescriptionUnitCostOfFishing.init();
- fieldEffortDescriptionFixedCrewSalary.init();
- fieldEffortDescriptionCrewFoodCost.init();
- fieldEffortDescriptionCrewShareRate.init();
- fieldEffortDescriptionRepairAndMaintenanceGearCost.init();
- fieldEffortDescriptionLandingCosts.init();
- fieldEffortDescriptionOtherRunningCost.init();*/
+ <script><![CDATA[
+ protected void $afterCompleteSetup() {
+ handler.init(this);
}
-}
- ]]>
- </script>
+
+ @Override
+ public void resetChangeModel() {
+ changeModel.setStayChanged(false);
+ }
+ ]]></script>
+
<JPanel id="body">
<Table>
<row>
@@ -144,7 +66,7 @@
<JScrollPane>
<JList id="fieldEffortDescriptionEffortDescriptionList" selectionMode="{javax.swing.ListSelectionModel.SINGLE_SELECTION}"
genericType="EffortDescription"
- onValueChanged='effortDescriptionSelectionChanged()'
+ onValueChanged='handler.effortDescriptionSelectionChanged()'
cellRenderer='{new EffortDescriptionListRenderer()}'
enabled='{isActive()}' />
</JScrollPane>
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/setofvessels/EffortDescriptionUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/setofvessels/EffortDescriptionUI.jaxx 2015-05-18 09:52:01 UTC (rev 4226)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/setofvessels/EffortDescriptionUI.jaxx 2015-05-20 12:09:09 UTC (rev 4227)
@@ -27,18 +27,7 @@
<!-- bean property -->
<fr.ifremer.isisfish.entities.SetOfVessels id='bean' javaBean='null'/>
- <import>
- java.util.ArrayList
- fr.ifremer.isisfish.entities.EffortDescription
- fr.ifremer.isisfish.entities.SetOfVessels
- fr.ifremer.isisfish.entities.Metier
- fr.ifremer.isisfish.ui.models.common.GenericListModel
- fr.ifremer.isisfish.ui.input.renderer.MetierListRenderer
- fr.ifremer.isisfish.ui.input.renderer.EffortDescriptionListRenderer
- java.beans.PropertyChangeEvent
- java.beans.PropertyChangeListener
- fr.ifremer.isisfish.ui.input.InputAction
- </import>
+ <EffortDescriptionHandler id="handler" />
<BeanValidator id='validator' context="effortdescription"
bean='{getBean()}' beanClass='fr.ifremer.isisfish.entities.SetOfVessels'
@@ -46,96 +35,30 @@
</BeanValidator>
<script><![CDATA[
-/**
- * Get input action from context.
- */
-protected InputAction getInputAction() {
- return getContextValue(InputAction.class);
-}
-
-protected void $afterCompleteSetup() {
- addPropertyChangeListener(PROPERTY_BEAN, new PropertyChangeListener() {
- public void propertyChange(PropertyChangeEvent evt) {
- GenericListModel<Metier> metierModel = (GenericListModel<Metier>)fieldEffortDescriptionMetierList.getModel();
- if (evt.getNewValue() == null) {
- metierModel.setElementList(null);
- }
- if (evt.getNewValue() != null) {
- metierModel.setElementList(getFisheryRegion().getMetier());
- setEffortDescriptionEffortDescriptionList();
- }
- }
- });
-}
-
-/*public void refresh() {
- SetOfVessels setOfVessels = getSaveVerifier().getEntity(SetOfVessels.class);
-
- // twice event for jaxx bindings detection
- setBean(null);
- setBean(setOfVessels);
-}*/
-
-protected void onFieldEffortDescriptionMetierListValueChanged() {
- // active le bouton seulement si l'interface est active
- // dans le cas de sensitivity par exemple
- if (isActive()) {
- buttonEffortDescriptionAdd.setEnabled(fieldEffortDescriptionMetierList.getSelectedIndex() != -1);
+ protected void $afterCompleteSetup() {
+ handler.init(this);
}
-}
+ ]]></script>
-protected void onFieldEffortDescriptionEffortDescriptionListValueChanged() {
- // active le bouton seulement si l'interface est active
- // dans le cas de sensitivity par exemple
- if (isActive()) {
- removeEffortDescriptionButton.setEnabled(fieldEffortDescriptionEffortDescriptionList.getSelectedIndex() != -1);
- }
-}
-
-protected void setEffortDescriptionEffortDescriptionList() {
- GenericListModel<EffortDescription> model = new GenericListModel<>();
- if (getBean() != null && getBean().getPossibleMetiers() != null) {
- List<EffortDescription> effortDescriptions = new ArrayList<>(getBean().getPossibleMetiers());
- model.setElementList(effortDescriptions);
- }
- fieldEffortDescriptionEffortDescriptionList.setModel(model);
-}
-
-protected void addEffortDescriptions() {
- List<Metier> selectedValues = fieldEffortDescriptionMetierList.getSelectedValuesList();
- for (Metier selectedMetier : selectedValues) {
- getInputAction().addEffortDescription(getBean(), selectedMetier);
- }
- setEffortDescriptionEffortDescriptionList();
-}
-protected void removeEffortDescriptions() {
- List<EffortDescription> selectedValues = fieldEffortDescriptionEffortDescriptionList.getSelectedValuesList();
- for (EffortDescription selectedEffortDescription : selectedValues) {
- getInputAction().removeEffortDescription(getBean(), selectedEffortDescription);
- }
- setEffortDescriptionEffortDescriptionList();
-}
- ]]>
- </script>
<JPanel id="body">
<Table>
<row>
<cell columns='2' fill='both' weightx='1.0' weighty='1.0'>
<JScrollPane>
<JList id="fieldEffortDescriptionMetierList" selectionMode="{javax.swing.ListSelectionModel.MULTIPLE_INTERVAL_SELECTION}"
- genericType="Metier"
- model='{new GenericListModel<Metier>()}' cellRenderer='{new MetierListRenderer()}'
- onValueChanged='onFieldEffortDescriptionMetierListValueChanged()' enabled='{isActive()}' decorator='boxed' />
+ genericType="fr.ifremer.isisfish.entities.Metier"
+ model='{new fr.ifremer.isisfish.ui.models.common.GenericListModel<fr.ifremer.isisfish.entities.Metier>()}' cellRenderer='{new MetierListRenderer()}'
+ onValueChanged='handler.onFieldEffortDescriptionMetierListValueChanged()' enabled='{isActive()}' decorator='boxed' />
</JScrollPane>
</cell>
</row>
<row>
<cell fill='horizontal' weightx='0.5'>
- <JButton id="buttonEffortDescriptionAdd" text="isisfish.common.add" onActionPerformed='addEffortDescriptions()' enabled='false'
+ <JButton id="buttonEffortDescriptionAdd" text="isisfish.common.add" onActionPerformed='handler.addEffortDescriptions()' enabled='false'
decorator='boxed' />
</cell>
<cell fill='horizontal' weightx='0.5'>
- <JButton id='removeEffortDescriptionButton' text="isisfish.common.remove" onActionPerformed='removeEffortDescriptions()'
+ <JButton id='removeEffortDescriptionButton' text="isisfish.common.remove" onActionPerformed='handler.removeEffortDescriptions()'
enabled='false' decorator='boxed' />
</cell>
</row>
@@ -143,9 +66,9 @@
<cell columns='2' fill='both' weightx='1.0' weighty='1.0'>
<JScrollPane>
<JList id="fieldEffortDescriptionEffortDescriptionList" selectionMode="{javax.swing.ListSelectionModel.MULTIPLE_INTERVAL_SELECTION}"
- genericType="EffortDescription"
+ genericType="fr.ifremer.isisfish.entities.EffortDescription"
cellRenderer='{new EffortDescriptionListRenderer()}'
- onValueChanged='onFieldEffortDescriptionEffortDescriptionListValueChanged()' enabled='{isActive()}' decorator='boxed' />
+ onValueChanged='handler.onFieldEffortDescriptionEffortDescriptionListValueChanged()' enabled='{isActive()}' decorator='boxed' />
</JScrollPane>
</cell>
</row>
Copied: trunk/src/main/java/fr/ifremer/isisfish/ui/input/setofvessels/MetierListRenderer.java (from rev 4226, trunk/src/main/java/fr/ifremer/isisfish/ui/input/renderer/MetierListRenderer.java)
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/setofvessels/MetierListRenderer.java (rev 0)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/setofvessels/MetierListRenderer.java 2015-05-20 12:09:09 UTC (rev 4227)
@@ -0,0 +1,67 @@
+/*
+ * #%L
+ * IsisFish
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2009 - 2010 Ifremer, CodeLutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+package fr.ifremer.isisfish.ui.input.setofvessels;
+
+import java.awt.Component;
+
+import javax.swing.DefaultListCellRenderer;
+import javax.swing.JLabel;
+import javax.swing.JList;
+
+import fr.ifremer.isisfish.entities.Metier;
+
+/**
+ * Renderer pour liste des metiers.
+ *
+ * @author chatellier
+ * @version $Revision$
+ *
+ * Last update : $Date$
+ * By : $Author$
+ */
+public class MetierListRenderer extends DefaultListCellRenderer {
+
+ /** serialVersionUID. */
+ private static final long serialVersionUID = 1113492654780402245L;
+
+ /*
+ * @see javax.swing.ListCellRenderer#getListCellRendererComponent(javax.swing.JList, java.lang.Object, int, boolean, boolean)
+ */
+ @Override
+ public Component getListCellRendererComponent(JList<?> list, Object value,
+ int index, boolean isSelected, boolean cellHasFocus) {
+
+ // this must be used to have alterned highlight rows and default
+ // selection color
+ JLabel c = (JLabel) super.getListCellRendererComponent(list, value,
+ index, isSelected, cellHasFocus);
+
+ Metier metier = (Metier) value;
+ c.setText(metier.getName());
+
+ return c;
+ }
+}
Added: trunk/src/main/java/fr/ifremer/isisfish/ui/input/setofvessels/SetOfVesselsBasicsHandler.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/setofvessels/SetOfVesselsBasicsHandler.java (rev 0)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/setofvessels/SetOfVesselsBasicsHandler.java 2015-05-20 12:09:09 UTC (rev 4227)
@@ -0,0 +1,76 @@
+/*
+ * #%L
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2015 Ifremer, Codelutin, Chatellier Eric
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+package fr.ifremer.isisfish.ui.input.setofvessels;
+
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+
+import fr.ifremer.isisfish.entities.Port;
+import fr.ifremer.isisfish.entities.VesselType;
+import fr.ifremer.isisfish.ui.input.InputContentHandler;
+import fr.ifremer.isisfish.ui.models.common.GenericComboModel;
+
+/**
+ * set of vessels handler.
+ */
+public class SetOfVesselsBasicsHandler extends InputContentHandler<SetOfVesselsBasicsUI> {
+
+ protected boolean init;
+
+ protected void init(final SetOfVesselsBasicsUI inputContentUI) {
+ super.init(inputContentUI);
+
+ inputContentUI.addPropertyChangeListener(SetOfVesselsBasicsUI.PROPERTY_BEAN, new PropertyChangeListener() {
+ public void propertyChange(PropertyChangeEvent evt) {
+ if (evt.getNewValue() == null) {
+
+ }
+ if (evt.getNewValue() != null) {
+ init = true;
+
+ GenericComboModel<Port> modelPort = new GenericComboModel<>(inputContentUI.getFisheryRegion().getPort());
+ inputContentUI.fieldSetOfVesselsPort.setModel(modelPort);
+ inputContentUI.fieldSetOfVesselsPort.setSelectedItem(inputContentUI.getBean().getPort());
+
+ GenericComboModel<VesselType> modelVessel = new GenericComboModel<>(inputContentUI.getFisheryRegion().getVesselType());
+ inputContentUI.fieldSetOfVesselsVesselType.setModel(modelVessel);
+ inputContentUI.fieldSetOfVesselsVesselType.setSelectedItem(inputContentUI.getBean().getVesselType());
+
+ init=false;
+ }
+ }
+ });
+ }
+
+ protected void portChanged() {
+ if (!init) {
+ inputContentUI.getBean().setPort((Port)inputContentUI.fieldSetOfVesselsPort.getSelectedItem());
+ }
+ }
+ protected void vesselTypeChanged() {
+ if (!init) {
+ inputContentUI.getBean().setVesselType((VesselType)inputContentUI.fieldSetOfVesselsVesselType.getSelectedItem());
+ }
+ }
+}
Property changes on: trunk/src/main/java/fr/ifremer/isisfish/ui/input/setofvessels/SetOfVesselsBasicsHandler.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/setofvessels/SetOfVesselsBasicsUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/setofvessels/SetOfVesselsBasicsUI.jaxx 2015-05-18 09:52:01 UTC (rev 4226)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/setofvessels/SetOfVesselsBasicsUI.jaxx 2015-05-20 12:09:09 UTC (rev 4227)
@@ -27,14 +27,7 @@
<!-- bean property -->
<fr.ifremer.isisfish.entities.SetOfVessels id='bean' javaBean='null'/>
- <import>
- fr.ifremer.isisfish.entities.Port
- fr.ifremer.isisfish.entities.VesselType
- fr.ifremer.isisfish.entities.SetOfVessels
- fr.ifremer.isisfish.ui.models.common.GenericComboModel
- java.beans.PropertyChangeEvent
- java.beans.PropertyChangeListener
- </import>
+ <SetOfVesselsBasicsHandler id="handler" />
<BeanValidator id='validator' context="basics"
bean='{getBean()}' beanClass='fr.ifremer.isisfish.entities.SetOfVessels'
@@ -43,64 +36,11 @@
</BeanValidator>
<script><![CDATA[
-boolean init = false;
-
-protected void $afterCompleteSetup() {
- addPropertyChangeListener(PROPERTY_BEAN, new PropertyChangeListener() {
- public void propertyChange(PropertyChangeEvent evt) {
- if (evt.getNewValue() == null) {
-
- }
- if (evt.getNewValue() != null) {
- init = true;
-
- GenericComboModel<Port> modelPort = new GenericComboModel<>(getFisheryRegion().getPort());
- fieldSetOfVesselsPort.setModel(modelPort);
- fieldSetOfVesselsPort.setSelectedItem(getBean().getPort());
-
- GenericComboModel<VesselType> modelVessel = new GenericComboModel<>(getFisheryRegion().getVesselType());
- fieldSetOfVesselsVesselType.setModel(modelVessel);
- fieldSetOfVesselsVesselType.setSelectedItem(getBean().getVesselType());
-
- init=false;
- }
- }
- });
-}
-
-/*public void refresh() {
- SetOfVessels setOfVessels = (SetOfVessels)getSaveVerifier().getEntity(SetOfVessels.class);
-
- // add null before, for second to be considered as a changed event
- // otherwize, setBean has no effect
- setBean(null);
- setBean(setOfVessels);
-
- if (getBean() != null) {
- init = true;
- jaxx.runtime.SwingUtil.fillComboBox(fieldSetOfVesselsPort,getFisheryRegion().getPort(), getBean().getPort(), true);
- jaxx.runtime.SwingUtil.fillComboBox(fieldSetOfVesselsVesselType,getFisheryRegion().getVesselType(), getBean().getVesselType(), true);
- init=false;
- getSaveVerifier().addCurrentPanel(technicalEfficiency);
-
- // NumberEditor is not working
- //fieldSetOfVesselsNumberOfVessels.init();
- //fieldSetOfVesselsFixedCosts.init();
+ protected void $afterCompleteSetup() {
+ handler.init(this);
}
-}*/
+ ]]></script>
-protected void portChanged() {
- if (!init) {
- getBean().setPort((Port)fieldSetOfVesselsPort.getSelectedItem());
- }
-}
-protected void vesselTypeChanged() {
- if (!init) {
- getBean().setVesselType((VesselType)fieldSetOfVesselsVesselType.getSelectedItem());
- }
-}
- ]]>
- </script>
<JPanel id='body'>
<Table>
<row>
@@ -119,8 +59,8 @@
<JLabel text="isisfish.common.port" enabled='{isActive()}'/>
</cell>
<cell fill='horizontal' weightx='1.0'>
- <JComboBox id="fieldSetOfVesselsPort" onItemStateChanged='portChanged()'
- genericType="Port"
+ <JComboBox id="fieldSetOfVesselsPort" onItemStateChanged='handler.portChanged()'
+ genericType="fr.ifremer.isisfish.entities.Port"
enabled='{isActive()}' decorator='boxed'/>
</cell>
</row>
@@ -129,8 +69,8 @@
<JLabel text="isisfish.setOfVessels.vesselType" enabled='{isActive()}'/>
</cell>
<cell fill='horizontal' weightx='1.0'>
- <JComboBox id="fieldSetOfVesselsVesselType" onItemStateChanged='vesselTypeChanged()'
- genericType="VesselType"
+ <JComboBox id="fieldSetOfVesselsVesselType" onItemStateChanged='handler.vesselTypeChanged()'
+ genericType="fr.ifremer.isisfish.entities.VesselType"
enabled='{isActive()}' decorator='boxed'/>
</cell>
</row>
Added: trunk/src/main/java/fr/ifremer/isisfish/ui/input/setofvessels/SetOfVesselsHandler.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/setofvessels/SetOfVesselsHandler.java (rev 0)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/setofvessels/SetOfVesselsHandler.java 2015-05-20 12:09:09 UTC (rev 4227)
@@ -0,0 +1,46 @@
+/*
+ * #%L
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2015 Ifremer, Codelutin, Chatellier Eric
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+package fr.ifremer.isisfish.ui.input.setofvessels;
+
+import static org.nuiton.i18n.I18n.n;
+import static org.nuiton.i18n.I18n.t;
+
+import fr.ifremer.isisfish.ui.input.InputContentHandler;
+
+/**
+ * set of vessels handler.
+ */
+public class SetOfVesselsHandler extends InputContentHandler<SetOfVesselsUI> {
+
+ protected void init(final SetOfVesselsUI inputContentUI) {
+ super.init(inputContentUI);
+
+ inputContentUI.setButtonTitle(t("isisfish.input.continueStrategies"));
+ inputContentUI.setNextPath(n("isisfish.input.tree.strategies"));
+
+ // install change listener
+ // (depends on sensitivity can't be done on constructor)
+ inputContentUI.installChangeListener(inputContentUI.setOfVesselsTab);
+ }
+}
Property changes on: trunk/src/main/java/fr/ifremer/isisfish/ui/input/setofvessels/SetOfVesselsHandler.java
___________________________________________________________________
Added: svn:eol-style
+ native
Added: svn:keywords
+ Author Date Id Revision HeadURL
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/setofvessels/SetOfVesselsUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/setofvessels/SetOfVesselsUI.jaxx 2015-05-18 09:52:01 UTC (rev 4226)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/setofvessels/SetOfVesselsUI.jaxx 2015-05-20 12:09:09 UTC (rev 4227)
@@ -26,40 +26,29 @@
<fr.ifremer.isisfish.entities.SetOfVessels id='bean' javaBean='null'/>
- <import>
- static org.nuiton.i18n.I18n.t
- static org.nuiton.i18n.I18n.n
- </import>
+ <SetOfVesselsHandler id="handler" />
<script><![CDATA[
-protected void $afterCompleteSetup() {
- setButtonTitle(t("isisfish.input.continueStrategies"));
- setNextPath(n("isisfish.input.tree.strategies"));
+ protected void $afterCompleteSetup() {
+ handler.init(this);
+ }
- // install change listener
- // (depends on sensitivity can't be done on constructor)
- installChangeListener(setOfVesselsTab);
-}
-
-/*public void refresh() {
- getSaveVerifier().addCurrentPanel(setOfVesselsBasicsUI, effortDescriptionUI, effortParametersUI);
-}*/
-
-@Override
-public void setLayer(boolean active) {
- super.setLayer(active);
- setOfVesselsBasicsUI.setLayer(active);
- effortDescriptionUI.setLayer(active);
- effortParametersUI.setLayer(active);
-}
-
-@Override
-public void resetChangeModel() {
- setOfVesselsBasicsUI.resetChangeModel();
- effortDescriptionUI.resetChangeModel();
- effortParametersUI.resetChangeModel();
-}
+ @Override
+ public void setLayer(boolean active) {
+ super.setLayer(active);
+ setOfVesselsBasicsUI.setLayer(active);
+ effortDescriptionUI.setLayer(active);
+ effortParametersUI.setLayer(active);
+ }
+
+ @Override
+ public void resetChangeModel() {
+ setOfVesselsBasicsUI.resetChangeModel();
+ effortDescriptionUI.resetChangeModel();
+ effortParametersUI.resetChangeModel();
+ }
]]></script>
+
<JPanel id="body">
<JTabbedPane id="setOfVesselsTab">
<tab title='isisfish.setOfVessels.title'>
Added: trunk/src/main/java/fr/ifremer/isisfish/ui/input/species/SpeciesHandler.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/species/SpeciesHandler.java (rev 0)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/species/SpeciesHandler.java 2015-05-20 12:09:09 UTC (rev 4227)
@@ -0,0 +1,74 @@
+/*
+ * #%L
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2015 Ifremer, Codelutin, Chatellier Eric
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+package fr.ifremer.isisfish.ui.input.species;
+
+import static org.nuiton.i18n.I18n.n;
+import static org.nuiton.i18n.I18n.t;
+
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+
+import fr.ifremer.isisfish.ui.input.InputContentHandler;
+import fr.ifremer.isisfish.ui.input.InputUI;
+
+/**
+ * Species handler.
+ */
+public class SpeciesHandler extends InputContentHandler<SpeciesUI> {
+
+ protected void init(final SpeciesUI inputContentUI) {
+ super.init(inputContentUI);
+
+ inputContentUI.setButtonTitle(t("isisfish.input.continuePopulations"));
+
+ inputContentUI.addPropertyChangeListener(SpeciesUI.PROPERTY_BEAN, new PropertyChangeListener() {
+ public void propertyChange(PropertyChangeEvent evt) {
+ if (evt.getNewValue() == null) {
+ inputContentUI.fieldSpeciesName.setText("");
+ inputContentUI.fieldSpeciesScientificName.setText("");
+ inputContentUI.fieldSpeciesCodeRubbin.setText("");
+ inputContentUI.fieldSpeciesCEE.setText("");
+ inputContentUI.fieldSpeciesComment.setText("");
+ }
+ if (evt.getNewValue() != null) {
+
+ }
+ }
+ });
+ }
+
+ protected void goTo() {
+ // FIXME il ne faut pas appeler le parent
+ // on ne sais jamais de quel type est le parent
+ InputUI inputUI = inputContentUI.getParentContainer(InputUI.class);
+ if (inputUI != null) {
+ if (inputContentUI.getBean() == null) {
+ inputUI.getHandler().setTreeSelection(inputContentUI, n("isisfish.input.tree.species"), n("isisfish.input.tree.populations"));
+ }
+ else {
+ inputUI.getHandler().setTreeSelection(inputContentUI, inputContentUI.getBean().getTopiaId(), n("isisfish.input.tree.populations"));
+ }
+ }
+ }
+}
Property changes on: trunk/src/main/java/fr/ifremer/isisfish/ui/input/species/SpeciesHandler.java
___________________________________________________________________
Added: svn:eol-style
+ native
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: trunk/src/main/java/fr/ifremer/isisfish/ui/input/species/SpeciesStructuredHandler.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/species/SpeciesStructuredHandler.java (rev 0)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/species/SpeciesStructuredHandler.java 2015-05-20 12:09:09 UTC (rev 4227)
@@ -0,0 +1,42 @@
+/*
+ * #%L
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2015 Ifremer, Codelutin, Chatellier Eric
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+package fr.ifremer.isisfish.ui.input.species;
+
+import fr.ifremer.isisfish.ui.input.InputContentHandler;
+
+/**
+ * Species structured handler.
+ */
+public class SpeciesStructuredHandler extends InputContentHandler<SpeciesStructuredUI> {
+
+ protected void init(final SpeciesStructuredUI inputContentUI) {
+ super.init(inputContentUI);
+ }
+
+ protected void dynamicChanged() {
+ if (inputContentUI.getBean() != null) {
+ inputContentUI.getBean().setAgeGroupType(inputContentUI.fieldSpeciesDynamicAge.isSelected());
+ }
+ }
+}
Property changes on: trunk/src/main/java/fr/ifremer/isisfish/ui/input/species/SpeciesStructuredHandler.java
___________________________________________________________________
Added: svn:eol-style
+ native
Added: svn:keywords
+ Author Date Id Revision HeadURL
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/species/SpeciesStructuredUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/species/SpeciesStructuredUI.jaxx 2015-05-18 09:52:01 UTC (rev 4226)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/species/SpeciesStructuredUI.jaxx 2015-05-20 12:09:09 UTC (rev 4227)
@@ -5,7 +5,7 @@
$Id$
$HeadURL$
%%
- Copyright (C) 2009 - 2011 Ifremer, Code Lutin, Chatellier Eric
+ Copyright (C) 2009 - 2015 Ifremer, Code Lutin, Chatellier Eric
%%
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as
@@ -26,20 +26,20 @@
<fr.ifremer.isisfish.entities.Species id='bean' javaBean='null'/>
+ <SpeciesStructuredHandler id="handler" />
+
<script><![CDATA[
- protected void dynamicChanged() {
- if (getBean() != null) {
- getBean().setAgeGroupType(fieldSpeciesDynamicAge.isSelected());
- }
+ protected void $afterCompleteSetup() {
+ handler.init(this);
}
- ]]>
- </script>
+ ]]></script>
+
<JPanel id='body'>
<Table>
<row>
<cell fill='horizontal' weightx='0.5'>
<JRadioButton id="fieldSpeciesDynamicAge" text="isisfish.species.age" selected='{getBean().isAgeGroupType()}'
- buttonGroup="structuredGroup" onItemStateChanged='dynamicChanged()' enabled='{isActive()}'/>
+ buttonGroup="structuredGroup" onItemStateChanged='handler.dynamicChanged()' enabled='{isActive()}'/>
</cell>
<cell fill='horizontal' weightx='0.5'>
<JRadioButton id="fieldSpeciesDynamicLength" text="isisfish.species.length" selected='{!getBean().isAgeGroupType()}'
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/species/SpeciesUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/species/SpeciesUI.jaxx 2015-05-18 09:52:01 UTC (rev 4226)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/species/SpeciesUI.jaxx 2015-05-20 12:09:09 UTC (rev 4227)
@@ -5,7 +5,7 @@
$Id$
$HeadURL$
%%
- Copyright (C) 2009 - 2011 Ifremer, Code Lutin, Chatellier Eric
+ Copyright (C) 2009 - 2015 Ifremer, Code Lutin, Chatellier Eric
%%
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as
@@ -27,15 +27,7 @@
<!-- bean property -->
<fr.ifremer.isisfish.entities.Species id='bean' javaBean='null'/>
- <import>
- static org.nuiton.i18n.I18n.t
- static org.nuiton.i18n.I18n.n
- fr.ifremer.isisfish.entities.Species
- java.beans.PropertyChangeEvent
- java.beans.PropertyChangeListener
- fr.ifremer.isisfish.ui.input.InputAction
- fr.ifremer.isisfish.ui.input.InputUI
- </import>
+ <SpeciesHandler id="handler" />
<BeanValidator id='validator'
bean='{getBean()}' beanClass='fr.ifremer.isisfish.entities.Species'
@@ -44,56 +36,16 @@
</BeanValidator>
<script><![CDATA[
-protected void $afterCompleteSetup() {
- setButtonTitle(t("isisfish.input.continuePopulations"));
-
- addPropertyChangeListener(PROPERTY_BEAN, new PropertyChangeListener() {
- public void propertyChange(PropertyChangeEvent evt) {
- if (evt.getNewValue() == null) {
- fieldSpeciesName.setText("");
- fieldSpeciesScientificName.setText("");
- fieldSpeciesCodeRubbin.setText("");
- fieldSpeciesCEE.setText("");
- fieldSpeciesComment.setText("");
- }
- if (evt.getNewValue() != null) {
-
- }
- }
- });
-}
-
-@Override
-protected void goTo() {
- // FIXME il ne faut pas appeler le parent
- // on ne sais jamais de quel type est le parent
- InputUI inputUI = getParentContainer(InputUI.class);
- if (inputUI != null) {
- if (getBean() == null) {
- inputUI.getHandler().setTreeSelection(this, n("isisfish.input.tree.species"), n("isisfish.input.tree.populations"));
- }
- else {
- inputUI.getHandler().setTreeSelection(this, getBean().getTopiaId(), n("isisfish.input.tree.populations"));
- }
+ protected void $afterCompleteSetup() {
+ handler.init(this);
}
-}
-
-/*public void refresh() {
- Species species = (Species)getSaveVerifier().getEntity(Species.class);
- // add null before, for second to be considered as a changed event
- // otherwize, setBean has no effect
- setBean(null);
- setBean(species);
-
- if (getBean() != null) {
- setNextPath("$root/$species/" + getBean().getTopiaId() + "/$populations");
- // Number Editor is not working
- //fieldSpeciesCEE.init();
+ @Override
+ protected void goTo() {
+ handler.goTo();
}
-}*/
- ]]>
- </script>
+ ]]></script>
+
<JPanel id='body'>
<Table>
<row>
Added: trunk/src/main/java/fr/ifremer/isisfish/ui/input/strategy/StrategyHandler.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/strategy/StrategyHandler.java (rev 0)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/strategy/StrategyHandler.java 2015-05-20 12:09:09 UTC (rev 4227)
@@ -0,0 +1,45 @@
+/*
+ * #%L
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2015 Ifremer, Codelutin, Chatellier Eric
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+package fr.ifremer.isisfish.ui.input.strategy;
+
+import static org.nuiton.i18n.I18n.n;
+import static org.nuiton.i18n.I18n.t;
+
+import fr.ifremer.isisfish.ui.input.InputContentHandler;
+
+/**
+ * Strategy handler.
+ */
+public class StrategyHandler extends InputContentHandler<StrategyUI> {
+
+ protected void init(final StrategyUI inputContentUI) {
+ super.init(inputContentUI);
+
+ inputContentUI.setButtonTitle(t("isisfish.input.continueObservations"));
+ inputContentUI.setNextPath(n("isisfish.input.tree.observations"));
+ // install change listener
+ // (depends on sensitivity can't be done on constructor)
+ inputContentUI.installChangeListener(inputContentUI.strategyTab);
+ }
+}
Property changes on: trunk/src/main/java/fr/ifremer/isisfish/ui/input/strategy/StrategyHandler.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/src/main/java/fr/ifremer/isisfish/ui/input/strategy/StrategyMonthInfoHandler.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/strategy/StrategyMonthInfoHandler.java (rev 0)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/strategy/StrategyMonthInfoHandler.java 2015-05-20 12:09:09 UTC (rev 4227)
@@ -0,0 +1,93 @@
+/*
+ * #%L
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2015 Ifremer, Codelutin, Chatellier Eric
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+package fr.ifremer.isisfish.ui.input.strategy;
+
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+
+import org.nuiton.math.matrix.MatrixND;
+import org.nuiton.math.matrix.gui.MatrixPanelEvent;
+
+import fr.ifremer.isisfish.ui.input.InputContentHandler;
+
+/**
+ * Strategy handler.
+ */
+public class StrategyMonthInfoHandler extends InputContentHandler<StrategyMonthInfoUI> {
+
+ protected void init(final StrategyMonthInfoUI inputContentUI) {
+ super.init(inputContentUI);
+
+ inputContentUI.addPropertyChangeListener(StrategyMonthInfoUI.PROPERTY_BEAN, new PropertyChangeListener() {
+ public void propertyChange(PropertyChangeEvent evt) {
+ if (evt.getNewValue() == null) {
+ inputContentUI.setStrategyMonthInfo0(null);
+ inputContentUI.setStrategyMonthInfo1(null);
+ inputContentUI.setStrategyMonthInfo2(null);
+ inputContentUI.setStrategyMonthInfo3(null);
+ inputContentUI.setStrategyMonthInfo4(null);
+ inputContentUI.setStrategyMonthInfo5(null);
+ inputContentUI.setStrategyMonthInfo6(null);
+ inputContentUI.setStrategyMonthInfo7(null);
+ inputContentUI.setStrategyMonthInfo8(null);
+ inputContentUI.setStrategyMonthInfo9(null);
+ inputContentUI.setStrategyMonthInfo10(null);
+ inputContentUI.setStrategyMonthInfo11(null);
+ inputContentUI.fieldStrategyProportion.setMatrix(null);
+ }
+ if (evt.getNewValue() != null) {
+ inputContentUI.setStrategyMonthInfo0(inputContentUI.getBean().getStrategyMonthInfo().get(0));
+ inputContentUI.setStrategyMonthInfo1(inputContentUI.getBean().getStrategyMonthInfo().get(1));
+ inputContentUI.setStrategyMonthInfo2(inputContentUI.getBean().getStrategyMonthInfo().get(2));
+ inputContentUI.setStrategyMonthInfo3(inputContentUI.getBean().getStrategyMonthInfo().get(3));
+ inputContentUI.setStrategyMonthInfo4(inputContentUI.getBean().getStrategyMonthInfo().get(4));
+ inputContentUI.setStrategyMonthInfo5(inputContentUI.getBean().getStrategyMonthInfo().get(5));
+ inputContentUI.setStrategyMonthInfo6(inputContentUI.getBean().getStrategyMonthInfo().get(6));
+ inputContentUI.setStrategyMonthInfo7(inputContentUI.getBean().getStrategyMonthInfo().get(7));
+ inputContentUI.setStrategyMonthInfo8(inputContentUI.getBean().getStrategyMonthInfo().get(8));
+ inputContentUI.setStrategyMonthInfo9(inputContentUI.getBean().getStrategyMonthInfo().get(9));
+ inputContentUI.setStrategyMonthInfo10(inputContentUI.getBean().getStrategyMonthInfo().get(10));
+ inputContentUI.setStrategyMonthInfo11(inputContentUI.getBean().getStrategyMonthInfo().get(11));
+ setProportionMetierMatrix();
+ }
+ }
+ });
+ }
+
+ protected void setProportionMetierMatrix() {
+ MatrixND prop = inputContentUI.getBean().getProportionMetier();
+ if (prop != null) {
+ inputContentUI.fieldStrategyProportion.setMatrix(prop.copy());
+ } else {
+ inputContentUI.fieldStrategyProportion.setMatrix(null);
+ }
+ }
+
+ protected void strategyProportionMatrixChanged(MatrixPanelEvent event) {
+ MatrixND mat = inputContentUI.fieldStrategyProportion.getMatrix();
+ if (inputContentUI.getBean() != null && mat != null) {
+ inputContentUI.getBean().setProportionMetier(mat.copy());
+ }
+ }
+}
Property changes on: trunk/src/main/java/fr/ifremer/isisfish/ui/input/strategy/StrategyMonthInfoHandler.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/strategy/StrategyMonthInfoUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/strategy/StrategyMonthInfoUI.jaxx 2015-05-18 09:52:01 UTC (rev 4226)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/strategy/StrategyMonthInfoUI.jaxx 2015-05-20 12:09:09 UTC (rev 4227)
@@ -5,7 +5,7 @@
$Id$
$HeadURL$
%%
- Copyright (C) 2009 - 2011 Ifremer, Code Lutin, Chatellier Eric
+ Copyright (C) 2009 - 2015 Ifremer, Code Lutin, Chatellier Eric
%%
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as
@@ -39,15 +39,7 @@
<fr.ifremer.isisfish.entities.StrategyMonthInfo id='strategyMonthInfo10' javaBean='null'/>
<fr.ifremer.isisfish.entities.StrategyMonthInfo id='strategyMonthInfo11' javaBean='null'/>
- <import>
- static org.nuiton.i18n.I18n.t
- org.apache.commons.lang3.StringUtils
- java.beans.PropertyChangeEvent
- java.beans.PropertyChangeListener
- static org.nuiton.i18n.I18n.t
- org.nuiton.math.matrix.gui.MatrixPanelEvent
- org.nuiton.math.matrix.MatrixND
- </import>
+ <StrategyMonthInfoHandler id="handler" />
<BeanValidator id='validator' context="month"
bean='{getBean()}' beanClass='fr.ifremer.isisfish.entities.Strategy'
@@ -105,90 +97,39 @@
<fr.ifremer.isisfish.ui.input.ChangeModel id="changeModel" changed="{validator0.isChanged() || validator1.isChanged() || validator2.isChanged() || validator3.isChanged() || validator4.isChanged() || validator5.isChanged() || validator6.isChanged() || validator7.isChanged() || validator8.isChanged() || validator9.isChanged() || validator10.isChanged() || validator11.isChanged()}"
valid="{validator0.isValid() && validator1.isValid() && validator2.isValid() && validator3.isValid() && validator4.isValid() && validator5.isValid() && validator6.isValid() && validator7.isValid() && validator8.isValid() && validator9.isValid() && validator10.isValid() && validator11.isValid()}" />
-
- <script><![CDATA[
-protected void $afterCompleteSetup() {
- addPropertyChangeListener(PROPERTY_BEAN, new PropertyChangeListener() {
- public void propertyChange(PropertyChangeEvent evt) {
- if (evt.getNewValue() == null) {
- setStrategyMonthInfo0(null);
- setStrategyMonthInfo1(null);
- setStrategyMonthInfo2(null);
- setStrategyMonthInfo3(null);
- setStrategyMonthInfo4(null);
- setStrategyMonthInfo5(null);
- setStrategyMonthInfo6(null);
- setStrategyMonthInfo7(null);
- setStrategyMonthInfo8(null);
- setStrategyMonthInfo9(null);
- setStrategyMonthInfo10(null);
- setStrategyMonthInfo11(null);
- fieldStrategyProportion.setMatrix(null);
- }
- if (evt.getNewValue() != null) {
- setStrategyMonthInfo0(getBean().getStrategyMonthInfo().get(0));
- setStrategyMonthInfo1(getBean().getStrategyMonthInfo().get(1));
- setStrategyMonthInfo2(getBean().getStrategyMonthInfo().get(2));
- setStrategyMonthInfo3(getBean().getStrategyMonthInfo().get(3));
- setStrategyMonthInfo4(getBean().getStrategyMonthInfo().get(4));
- setStrategyMonthInfo5(getBean().getStrategyMonthInfo().get(5));
- setStrategyMonthInfo6(getBean().getStrategyMonthInfo().get(6));
- setStrategyMonthInfo7(getBean().getStrategyMonthInfo().get(7));
- setStrategyMonthInfo8(getBean().getStrategyMonthInfo().get(8));
- setStrategyMonthInfo9(getBean().getStrategyMonthInfo().get(9));
- setStrategyMonthInfo10(getBean().getStrategyMonthInfo().get(10));
- setStrategyMonthInfo11(getBean().getStrategyMonthInfo().get(11));
- setProportionMetierMatrix();
- }
- }
- });
-}
-@Override
-public void resetChangeModel() {
- changeModel.setStayChanged(false);
-}
+ <import>
+ org.apache.commons.lang3.StringUtils
+ </import>
-/*@Override
-public void refresh() {
- //getSaveVerifier().addCurrentPanel(strategyJanuary, strategyFebuary, strategyMarch,
- // strategyApril, strategyMay, strategyJune,
- // strategyJuly, strategyAugust, strategySeptember,
- // strategyOctober, strategyNovember, strategyDecember);
-}*/
+ <script><![CDATA[
+ protected void $afterCompleteSetup() {
+ handler.init(this);
+ }
-@Override
-public void setLayer(boolean active) {
- super.setLayer(active);
- strategyJanuary.setLayer(active);
- strategyFebuary.setLayer(active);
- strategyMarch.setLayer(active);
- strategyApril.setLayer(active);
- strategyMay.setLayer(active);
- strategyJune.setLayer(active);
- strategyJuly.setLayer(active);
- strategyAugust.setLayer(active);
- strategySeptember.setLayer(active);
- strategyOctober.setLayer(active);
- strategyNovember.setLayer(active);
- strategyDecember.setLayer(active);
-}
-protected void setProportionMetierMatrix() {
- MatrixND prop = getBean().getProportionMetier();
- if (prop != null) {
- fieldStrategyProportion.setMatrix(prop.copy());
+ @Override
+ public void resetChangeModel() {
+ changeModel.setStayChanged(false);
}
- else {
- fieldStrategyProportion.setMatrix(null);
+
+ @Override
+ public void setLayer(boolean active) {
+ super.setLayer(active);
+ strategyJanuary.setLayer(active);
+ strategyFebuary.setLayer(active);
+ strategyMarch.setLayer(active);
+ strategyApril.setLayer(active);
+ strategyMay.setLayer(active);
+ strategyJune.setLayer(active);
+ strategyJuly.setLayer(active);
+ strategyAugust.setLayer(active);
+ strategySeptember.setLayer(active);
+ strategyOctober.setLayer(active);
+ strategyNovember.setLayer(active);
+ strategyDecember.setLayer(active);
}
-}
-protected void strategyProportionMatrixChanged(MatrixPanelEvent event) {
- MatrixND mat = fieldStrategyProportion.getMatrix();
- if (getBean() != null && mat != null) {
- getBean().setProportionMetier(mat.copy());
- }
-}
]]></script>
+
<JPanel id='body'>
<Table constraints='BorderLayout.CENTER'>
<row>
@@ -253,7 +194,7 @@
<row>
<cell fill='both' weightx='1' weighty='1' columns="4">
<org.nuiton.math.matrix.gui.MatrixPanelEditor id="fieldStrategyProportion"
- onMatrixChanged="strategyProportionMatrixChanged(event)"
+ onMatrixChanged="handler.strategyProportionMatrixChanged(event)"
enabled='{isActive()}' decorator='boxed'
_sensitivityBean='{fr.ifremer.isisfish.entities.Strategy.class}' _sensitivityMethod='"ProportionMetier"'/>
</cell>
Added: trunk/src/main/java/fr/ifremer/isisfish/ui/input/strategy/StrategyOneMonthInfoHandler.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/strategy/StrategyOneMonthInfoHandler.java (rev 0)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/strategy/StrategyOneMonthInfoHandler.java 2015-05-20 12:09:09 UTC (rev 4227)
@@ -0,0 +1,73 @@
+/*
+ * #%L
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2015 Ifremer, Codelutin, Chatellier Eric
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+package fr.ifremer.isisfish.ui.input.strategy;
+
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+
+import fr.ifremer.isisfish.entities.TripType;
+import fr.ifremer.isisfish.ui.input.InputContentHandler;
+import fr.ifremer.isisfish.ui.models.common.GenericComboModel;
+
+/**
+ * Strategy one month info handler.
+ */
+public class StrategyOneMonthInfoHandler extends InputContentHandler<StrategyOneMonthInfoUI> {
+
+ protected boolean init;
+
+ protected void init(final StrategyOneMonthInfoUI inputContentUI) {
+ super.init(inputContentUI);
+
+ inputContentUI.addPropertyChangeListener(StrategyOneMonthInfoUI.PROPERTY_STRATEGY_MONTH_INFO, new PropertyChangeListener() {
+ public void propertyChange(PropertyChangeEvent evt) {
+ if (evt.getNewValue() == null) {
+
+ }
+ if (evt.getNewValue() != null) {
+ init = true;
+ refresh();
+ init = false;
+ }
+ }
+ });
+ }
+
+ protected void refresh() {
+ if (inputContentUI.getStrategyMonthInfo() != null) {
+ inputContentUI.numberOfTrips.putClientProperty("sensitivityBeanID", inputContentUI.getStrategyMonthInfo().getTopiaId());
+ inputContentUI.fieldStrategyMonthInfoMinInactivityDays.putClientProperty("sensitivityBeanID", inputContentUI.getStrategyMonthInfo().getTopiaId());
+
+ GenericComboModel<TripType> model = new GenericComboModel<>(inputContentUI.getFisheryRegion().getTripType());
+ inputContentUI.fieldStrategyMonthInfoTripType.setModel(model);
+ inputContentUI.fieldStrategyMonthInfoTripType.setSelectedItem(inputContentUI.getStrategyMonthInfo().getTripType());
+ }
+ else {
+ // don't put in addPropertyChangeListener
+ // if called after, remove content :(
+ inputContentUI.numberOfTrips.setText("");
+ inputContentUI.fieldStrategyMonthInfoMinInactivityDays.setText("");
+ }
+ }
+}
Property changes on: trunk/src/main/java/fr/ifremer/isisfish/ui/input/strategy/StrategyOneMonthInfoHandler.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/strategy/StrategyOneMonthInfoUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/strategy/StrategyOneMonthInfoUI.jaxx 2015-05-18 09:52:01 UTC (rev 4226)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/strategy/StrategyOneMonthInfoUI.jaxx 2015-05-20 12:09:09 UTC (rev 4227)
@@ -31,51 +31,14 @@
<fr.ifremer.isisfish.entities.StrategyMonthInfo id='strategyMonthInfo' javaBean='null'/>
- <import>
- fr.ifremer.isisfish.entities.Strategy
- fr.ifremer.isisfish.entities.StrategyMonthInfo
- fr.ifremer.isisfish.entities.TripType
- java.beans.PropertyChangeEvent
- java.beans.PropertyChangeListener
- fr.ifremer.isisfish.ui.models.common.GenericComboModel
- </import>
+ <StrategyOneMonthInfoHandler id="handler" />
<script><![CDATA[
-protected boolean init;
-
-protected void $afterCompleteSetup() {
- addPropertyChangeListener(PROPERTY_STRATEGY_MONTH_INFO, new PropertyChangeListener() {
- public void propertyChange(PropertyChangeEvent evt) {
- if (evt.getNewValue() == null) {
-
- }
- if (evt.getNewValue() != null) {
- init = true;
- refresh();
- init = false;
- }
- }
- });
-}
-
-public void refresh() {
- if (getStrategyMonthInfo() != null) {
- numberOfTrips.putClientProperty("sensitivityBeanID", getStrategyMonthInfo().getTopiaId());
- fieldStrategyMonthInfoMinInactivityDays.putClientProperty("sensitivityBeanID", getStrategyMonthInfo().getTopiaId());
-
- GenericComboModel<TripType> model = new GenericComboModel<>(getFisheryRegion().getTripType());
- fieldStrategyMonthInfoTripType.setModel(model);
- fieldStrategyMonthInfoTripType.setSelectedItem(getStrategyMonthInfo().getTripType());
+ protected void $afterCompleteSetup() {
+ handler.init(this);
}
- else {
- // don't put in addPropertyChangeListener
- // if called after, remove content :(
- numberOfTrips.setText("");
- fieldStrategyMonthInfoMinInactivityDays.setText("");
- }
-}
-
]]></script>
+
<JPanel id="body">
<Table>
<row>
@@ -88,7 +51,7 @@
<JComboBox id="fieldStrategyMonthInfoTripType"
genericType="fr.ifremer.isisfish.entities.TripType"
onActionPerformed='getStrategyMonthInfo().setTripType((TripType)fieldStrategyMonthInfoTripType.getSelectedItem())'
- renderer='{new fr.ifremer.isisfish.ui.input.renderer.TripTypeListRenderer(true)}'
+ renderer='{new fr.ifremer.isisfish.ui.input.triptype.TripTypeListRenderer(true)}'
enabled='{isActive()}' decorator='boxed'/>
</cell>
</row>
Added: trunk/src/main/java/fr/ifremer/isisfish/ui/input/strategy/StrategyTabHandler.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/strategy/StrategyTabHandler.java (rev 0)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/strategy/StrategyTabHandler.java 2015-05-20 12:09:09 UTC (rev 4227)
@@ -0,0 +1,70 @@
+/*
+ * #%L
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2015 Ifremer, Codelutin, Chatellier Eric
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+package fr.ifremer.isisfish.ui.input.strategy;
+
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+
+import fr.ifremer.isisfish.entities.SetOfVessels;
+import fr.ifremer.isisfish.ui.input.InputContentHandler;
+import fr.ifremer.isisfish.ui.models.common.GenericComboModel;
+
+/**
+ * Strategy tab handler.
+ */
+public class StrategyTabHandler extends InputContentHandler<StrategyTabUI> {
+
+ protected boolean init;
+
+ protected void init(final StrategyTabUI inputContentUI) {
+ super.init(inputContentUI);
+
+ inputContentUI.addPropertyChangeListener(StrategyTabUI.PROPERTY_BEAN, new PropertyChangeListener() {
+ public void propertyChange(PropertyChangeEvent evt) {
+ if (evt.getNewValue() == null) {
+ inputContentUI.fieldStrategyName.setText("");
+ inputContentUI.fieldStrategyProportionSetOfVessels.setText("");
+ inputContentUI.fieldStrategyComment.setText("");
+ }
+ if (evt.getNewValue() != null) {
+ init = true;
+ setSetOfVesselsModel();
+ init = false;
+ }
+ }
+ });
+ }
+
+ protected void setSetOfVesselsModel() {
+ GenericComboModel<SetOfVessels> modelVessel = new GenericComboModel<>(inputContentUI.getFisheryRegion().getSetOfVessels());
+ inputContentUI.fieldStrategySetOfVessels.setModel(modelVessel);
+ inputContentUI.fieldStrategySetOfVessels.setSelectedItem(inputContentUI.getBean().getSetOfVessels());
+ }
+
+ protected void setOfVesselsChanged() {
+ if (!init) {
+ inputContentUI.getBean().setSetOfVessels((SetOfVessels)inputContentUI.fieldStrategySetOfVessels.getSelectedItem());
+ }
+ }
+}
Property changes on: trunk/src/main/java/fr/ifremer/isisfish/ui/input/strategy/StrategyTabHandler.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/strategy/StrategyTabUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/strategy/StrategyTabUI.jaxx 2015-05-18 09:52:01 UTC (rev 4226)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/strategy/StrategyTabUI.jaxx 2015-05-20 12:09:09 UTC (rev 4227)
@@ -27,13 +27,7 @@
<!-- bean property -->
<fr.ifremer.isisfish.entities.Strategy id='bean' javaBean='null'/>
- <import>
- fr.ifremer.isisfish.entities.Strategy
- fr.ifremer.isisfish.entities.SetOfVessels
- java.beans.PropertyChangeEvent
- java.beans.PropertyChangeListener
- fr.ifremer.isisfish.ui.models.common.GenericComboModel
- </import>
+ <StrategyTabHandler id="handler" />
<BeanValidator id='validator' context="basics"
bean='{getBean()}' beanClass='fr.ifremer.isisfish.entities.Strategy'
@@ -42,66 +36,11 @@
</BeanValidator>
<script><![CDATA[
-protected boolean init;
-
-protected void $afterCompleteSetup() {
- addPropertyChangeListener(PROPERTY_BEAN, new PropertyChangeListener() {
- public void propertyChange(PropertyChangeEvent evt) {
- if (evt.getNewValue() == null) {
- fieldStrategyName.setText("");
- fieldStrategyProportionSetOfVessels.setText("");
- fieldStrategyComment.setText("");
- }
- if (evt.getNewValue() != null) {
- init = true;
- setSetOfVesselsModel();
- init = false;
- }
- }
- });
-}
-
-/*public void refresh() {
- //Strategy strategy = (Strategy)getSaveVerifier().getEntity(Strategy.class);
-
- // add null before, for second to be considered as a changed event
- // otherwize, setBean has no effect
- //setBean(null);
- //setBean(strategy);
-
- if (getBean() != null) {
- setSetOfVesselsModel();
- //fieldStrategyProportionSetOfVessels.init();
-
- // code to replace bindings :
- strategyInactivity.setActive(isActive() && getBean().isInactivityEquationUsed());
-
- //getSaveVerifier().addCurrentPanel(strategyInactivity);
+ protected void $afterCompleteSetup() {
+ handler.init(this);
}
- else {
- // listener seam to be called after refresh and remove content :(
- fieldStrategyName.setText("");
- //fieldStrategyProportionSetOfVessels.setModelText("0.0");
- fieldStrategyProportionSetOfVessels.setText("0.0");
- fieldStrategyComment.setText("");
-
- // code to replace bindings :
- strategyInactivity.setActive(isActive());
- }
-}*/
-
-protected void setSetOfVesselsModel() {
- GenericComboModel<SetOfVessels> modelVessel = new GenericComboModel<>(getFisheryRegion().getSetOfVessels());
- fieldStrategySetOfVessels.setModel(modelVessel);
- fieldStrategySetOfVessels.setSelectedItem(getBean().getSetOfVessels());
-}
-
-protected void setOfVesselsChanged() {
- if (!init) {
- getBean().setSetOfVessels((SetOfVessels)fieldStrategySetOfVessels.getSelectedItem());
- }
-}
]]></script>
+
<JPanel id="body">
<Table>
<row>
@@ -122,7 +61,7 @@
<cell fill='horizontal' weightx='1.0'>
<JComboBox id="fieldStrategySetOfVessels"
genericType="fr.ifremer.isisfish.entities.SetOfVessels"
- onItemStateChanged='setOfVesselsChanged()'
+ onItemStateChanged='handler.setOfVesselsChanged()'
enabled='{isActive()}' decorator='boxed'/>
</cell>
</row>
@@ -147,7 +86,8 @@
<cell fill='horizontal' weightx='1.0'>
<JCheckBox id="fieldUseEquationInactivity" selected='{getBean().isInactivityEquationUsed()}'
text="isisfish.strategy.inactivityEquationUsed"
- onActionPerformed='getBean().setInactivityEquationUsed(fieldUseEquationInactivity.isSelected())' enabled='{isActive()}' decorator='boxed'/>
+ onActionPerformed='getBean().setInactivityEquationUsed(fieldUseEquationInactivity.isSelected())'
+ enabled='{isActive()}' decorator='boxed'/>
</cell>
</row>
<row>
@@ -166,7 +106,8 @@
</cell>
<cell fill='both' weightx='1.0' weighty='0.5'>
<JScrollPane>
- <JTextArea id="fieldStrategyComment" text='{jaxx.runtime.SwingUtil.getStringValue(getBean().getComment())}' onKeyReleased='getBean().setComment(fieldStrategyComment.getText())' enabled='{isActive()}' decorator='boxed'/>
+ <JTextArea id="fieldStrategyComment" text='{jaxx.runtime.SwingUtil.getStringValue(getBean().getComment())}'
+ onKeyReleased='getBean().setComment(fieldStrategyComment.getText())' enabled='{isActive()}' decorator='boxed'/>
</JScrollPane>
</cell>
</row>
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/strategy/StrategyUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/strategy/StrategyUI.jaxx 2015-05-18 09:52:01 UTC (rev 4226)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/strategy/StrategyUI.jaxx 2015-05-20 12:09:09 UTC (rev 4227)
@@ -5,7 +5,7 @@
$Id$
$HeadURL$
%%
- Copyright (C) 2009 - 2011 Ifremer, Code Lutin, Chatellier Eric
+ Copyright (C) 2009 - 2015 Ifremer, Code Lutin, Chatellier Eric
%%
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as
@@ -26,37 +26,27 @@
<fr.ifremer.isisfish.entities.Strategy id='bean' javaBean='null'/>
- <import>
- static org.nuiton.i18n.I18n.t
- static org.nuiton.i18n.I18n.n
- </import>
+ <StrategyHandler id="handler" />
<script><![CDATA[
-protected void $afterCompleteSetup() {
- setButtonTitle(t("isisfish.input.continueObservations"));
- setNextPath(n("isisfish.input.tree.observations"));
- // install change listener
- // (depends on sensitivity can't be done on constructor)
- installChangeListener(strategyTab);
-}
+ protected void $afterCompleteSetup() {
+ handler.init(this);
+ }
-/*public void refresh() {
- getSaveVerifier().addCurrentPanel(strategyMonthInfoUI, strategyTabUI);
-}*/
-
-@Override
-public void setLayer(boolean active) {
- super.setLayer(active);
- strategyTabUI.setLayer(active);
- strategyMonthInfoUI.setLayer(active);
-}
-
-@Override
-public void resetChangeModel() {
- strategyTabUI.resetChangeModel();
- strategyMonthInfoUI.resetChangeModel();
-}
+ @Override
+ public void setLayer(boolean active) {
+ super.setLayer(active);
+ strategyTabUI.setLayer(active);
+ strategyMonthInfoUI.setLayer(active);
+ }
+
+ @Override
+ public void resetChangeModel() {
+ strategyTabUI.resetChangeModel();
+ strategyMonthInfoUI.resetChangeModel();
+ }
]]></script>
+
<JPanel id="body">
<JTabbedPane id="strategyTab">
<tab title='isisfish.strategy.title'>
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/tree/FisheryTreeSelectionModel.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/tree/FisheryTreeSelectionModel.java 2015-05-18 09:52:01 UTC (rev 4226)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/tree/FisheryTreeSelectionModel.java 2015-05-20 12:09:09 UTC (rev 4227)
@@ -23,7 +23,6 @@
package fr.ifremer.isisfish.ui.input.tree;
-import javax.swing.JOptionPane;
import javax.swing.tree.DefaultTreeSelectionModel;
import javax.swing.tree.TreePath;
import javax.swing.tree.TreeSelectionModel;
@@ -104,7 +103,7 @@
// check for non validated modification
InputSaveVerifier inputSaveVerifier = ui.getContextValue(InputSaveVerifier.class);
- if (inputSaveVerifier.checkEdit() == JOptionPane.CANCEL_OPTION) {
+ if (inputSaveVerifier.checkEdit() == InputSaveVerifier.CANCEL_OPTION) {
result = false;
}
Added: trunk/src/main/java/fr/ifremer/isisfish/ui/input/triptype/TripTypeHandler.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/triptype/TripTypeHandler.java (rev 0)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/triptype/TripTypeHandler.java 2015-05-20 12:09:09 UTC (rev 4227)
@@ -0,0 +1,59 @@
+/*
+ * #%L
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2015 Ifremer, Codelutin, Chatellier Eric
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+package fr.ifremer.isisfish.ui.input.triptype;
+
+import static org.nuiton.i18n.I18n.n;
+import static org.nuiton.i18n.I18n.t;
+
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+
+import fr.ifremer.isisfish.ui.input.InputContentHandler;
+
+/**
+ * Trip type handler.
+ */
+public class TripTypeHandler extends InputContentHandler<TripTypeUI> {
+
+ protected void init(final TripTypeUI inputContentUI) {
+ super.init(inputContentUI);
+
+ inputContentUI.setButtonTitle(t("isisfish.input.continueVesselTypes"));
+ inputContentUI.setNextPath(n("isisfish.input.tree.vesseltypes"));
+
+ inputContentUI.addPropertyChangeListener(TripTypeUI.PROPERTY_BEAN, new PropertyChangeListener() {
+ public void propertyChange(PropertyChangeEvent evt) {
+ if (evt.getNewValue() == null) {
+ inputContentUI.fieldTripTypeName.setText("");
+ inputContentUI.fieldTripTypeDuration.setText("");
+ inputContentUI.fieldTripTypeMinTimeBetweenTrip.setText("");
+ inputContentUI.fieldTripTypeComment.setText("");
+ }
+ if (evt.getNewValue() != null) {
+
+ }
+ }
+ });
+ }
+}
Property changes on: trunk/src/main/java/fr/ifremer/isisfish/ui/input/triptype/TripTypeHandler.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Copied: trunk/src/main/java/fr/ifremer/isisfish/ui/input/triptype/TripTypeListRenderer.java (from rev 4226, trunk/src/main/java/fr/ifremer/isisfish/ui/input/renderer/TripTypeListRenderer.java)
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/triptype/TripTypeListRenderer.java (rev 0)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/triptype/TripTypeListRenderer.java 2015-05-20 12:09:09 UTC (rev 4227)
@@ -0,0 +1,85 @@
+/*
+ * #%L
+ * IsisFish
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2009 - 2010 Ifremer, CodeLutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+package fr.ifremer.isisfish.ui.input.triptype;
+
+import java.awt.Component;
+
+import javax.swing.DefaultListCellRenderer;
+import javax.swing.JLabel;
+import javax.swing.JList;
+
+import fr.ifremer.isisfish.entities.TripType;
+
+/**
+ * Renderer pour liste des trip types.
+ *
+ * @author chatellier
+ * @version $Revision$
+ *
+ * Last update : $Date$
+ * By : $Author$
+ */
+public class TripTypeListRenderer extends DefaultListCellRenderer {
+
+ /** serialVersionUID. */
+ private static final long serialVersionUID = 1113492654780402245L;
+
+ /** Append trip type details. */
+ protected boolean appendDetails;
+
+ public TripTypeListRenderer() {
+ this(false);
+ }
+
+ public TripTypeListRenderer(boolean appendDetails) {
+ this.appendDetails = appendDetails;
+ }
+
+ /*
+ * @see javax.swing.ListCellRenderer#getListCellRendererComponent(javax.swing.JList, java.lang.Object, int, boolean, boolean)
+ */
+ @Override
+ public Component getListCellRendererComponent(JList<?> list, Object value,
+ int index, boolean isSelected, boolean cellHasFocus) {
+
+ // this must be used to have alternated highlight rows and default
+ // selection color
+ JLabel c = (JLabel) super.getListCellRendererComponent(list, value,
+ index, isSelected, cellHasFocus);
+
+ TripType tripType = (TripType) value;
+ if (tripType != null) {
+ if (appendDetails) {
+ c.setText(tripType.getName() + "(" + tripType.getTripDuration() + ":"
+ + tripType.getMinTimeBetweenTrip() + ")");
+ } else {
+ c.setText(tripType.getName());
+ }
+ }
+
+ return c;
+ }
+}
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/triptype/TripTypeUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/triptype/TripTypeUI.jaxx 2015-05-18 09:52:01 UTC (rev 4226)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/triptype/TripTypeUI.jaxx 2015-05-20 12:09:09 UTC (rev 4227)
@@ -27,14 +27,7 @@
<!-- bean property -->
<fr.ifremer.isisfish.entities.TripType id='bean' javaBean='null'/>
- <import>
- static org.nuiton.i18n.I18n.t
- static org.nuiton.i18n.I18n.n
- fr.ifremer.isisfish.entities.TripType
- fr.ifremer.isisfish.types.TimeUnit
- java.beans.PropertyChangeEvent
- java.beans.PropertyChangeListener
- </import>
+ <TripTypeHandler id="handler" />
<BeanValidator id='validator'
bean='{getBean()}' beanClass='fr.ifremer.isisfish.entities.TripType'
@@ -42,36 +35,16 @@
<field name="name" component="fieldTripTypeName" />
</BeanValidator>
+ <import>
+ fr.ifremer.isisfish.types.TimeUnit
+ </import>
+
<script><![CDATA[
-protected void $afterCompleteSetup() {
- setButtonTitle(t("isisfish.input.continueVesselTypes"));
- setNextPath(n("isisfish.input.tree.vesseltypes"));
+ protected void $afterCompleteSetup() {
+ handler.init(this);
+ }
+ ]]></script>
- addPropertyChangeListener(PROPERTY_BEAN, new PropertyChangeListener() {
- public void propertyChange(PropertyChangeEvent evt) {
- if (evt.getNewValue() == null) {
- fieldTripTypeName.setText("");
- fieldTripTypeDuration.setText("");
- fieldTripTypeMinTimeBetweenTrip.setText("");
- fieldTripTypeComment.setText("");
- }
- if (evt.getNewValue() != null) {
-
- }
- }
- });
-}
-
-/*public void refresh() {
- TripType tripType = (TripType)getSaveVerifier().getEntity(TripType.class);
-
- // add null before, for second to be considered as a changed event
- // otherwize, setBean has no effect
- setBean(null);
- setBean(tripType);
-}*/
- ]]>
- </script>
<JPanel id="body">
<Table>
<row>
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/variable/EntityVariableHandler.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/variable/EntityVariableHandler.java 2015-05-18 09:52:01 UTC (rev 4226)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/variable/EntityVariableHandler.java 2015-05-20 12:09:09 UTC (rev 4227)
@@ -42,6 +42,8 @@
import fr.ifremer.isisfish.entities.Variable;
import fr.ifremer.isisfish.entities.VariableDAO;
import fr.ifremer.isisfish.entities.VariableType;
+import fr.ifremer.isisfish.ui.input.InputContentHandler;
+import fr.ifremer.isisfish.ui.input.vesseltype.VesselTypeUI;
import fr.ifremer.isisfish.ui.models.common.GenericListModel;
/**
@@ -53,28 +55,44 @@
* Last update : $Date$
* By : $Author$
*/
-public class EntityVariableHandler {
+public class EntityVariableHandler extends InputContentHandler<EntityVariableUI> {
/** Class logger. */
private static final Log log = LogFactory.getLog(EntityVariableHandler.class);
+ protected void init(final EntityVariableUI inputContentUI) {
+ super.init(inputContentUI);
+
+ inputContentUI.addPropertyChangeListener(EntityVariableUI.PROPERTY_BEAN, new java.beans.PropertyChangeListener() {
+ public void propertyChange(java.beans.PropertyChangeEvent evt) {
+ reloadVariables();
+ }
+ });
+
+ inputContentUI.addPropertyChangeListener(EntityVariableUI.PROPERTY_VARIABLE, new java.beans.PropertyChangeListener() {
+ public void propertyChange(java.beans.PropertyChangeEvent evt) {
+ if (evt.getNewValue() == null) {
+ inputContentUI.matrixPanel.setMatrix(null);
+ }
+ }
+ });
+ }
+
/**
* Init view with currently entity variables.
- *
- * @param view view
*/
- public void initView(EntityVariableUI view) {
+ protected void reloadVariables() {
// clear previous
- view.getVariablesList().clearSelection();
+ inputContentUI.getVariablesList().clearSelection();
// fill current list
List<Variable> variables = null;
- GenericListModel<Variable> model = (GenericListModel<Variable>)view.getVariablesList().getModel();
- TopiaEntity bean = view.getBean();
+ GenericListModel<Variable> model = (GenericListModel<Variable>)inputContentUI.getVariablesList().getModel();
+ TopiaEntity bean = inputContentUI.getBean();
if (bean != null) {
try {
- TopiaContext context = view.getTopiaContext();
+ TopiaContext context = inputContentUI.getTopiaContext();
VariableDAO dao = IsisFishDAOHelper.getVariableDAO(context);
variables = dao.findAllByEntityId(bean.getTopiaId());
} catch (TopiaException ex) {
@@ -83,15 +101,15 @@
// try to set entity name in label
try {
- String name = BeanUtils.getProperty(view.getBean(), "name");
- view.getVariableEntityName().setText(name);
+ String name = BeanUtils.getProperty(inputContentUI.getBean(), "name");
+ inputContentUI.getVariableEntityName().setText(name);
} catch (Exception ex) {
if (log.isWarnEnabled()) {
log.warn("Can't get entity name", ex);
}
}
} else {
- view.getVariableEntityName().setText("");
+ inputContentUI.getVariableEntityName().setText("");
}
model.setElementList(variables);
@@ -162,20 +180,6 @@
view.setVariable(variable);
view.getSaveVerifier().addCurrentEntity(variable);
- /*if (variable != null) {
- view.getVariableNameField().setText(variable.getName());
-
- String type = variable.getType();
- view.getVariableTypeCombo().setSelectedItem(type); // fire showSelectedType
-
- if ("double".equals(type)) {
- view.getVariableDoubleValue().setText(String.valueOf(variable.getDoubleValue()));
- } else if ("matrix".equals(type)) {
- //view.get
- } else if ("equation".equals(type)) {
- //cardLayout.show(view.getVariableTypePanel(), "equationtype");
- }
- }*/
}
/**
@@ -228,20 +232,11 @@
break;
} // equation already set by ui component
- //try {
- // save in db
- //TopiaContext context = view.getTopiaContext();
- //VariableDAO dao = IsisFishDAOHelper.getVariableDAO(context);
- //dao.update(variable);
- //context.commitTransaction();
- view.getSaveVerifier().save();
+ view.getSaveVerifier().save();
- // refresh ui (name change)
- GenericListModel<Variable> model = (GenericListModel<Variable>)view.getVariablesList().getModel();
- List<Variable> variables = model.getElementList();
- model.setElementList(variables);
- /*} catch (TopiaException ex) {
- throw new IsisFishRuntimeException("Can't save variable", ex);
- }*/
+ // refresh ui (name change)
+ GenericListModel<Variable> model = (GenericListModel<Variable>)view.getVariablesList().getModel();
+ List<Variable> variables = model.getElementList();
+ model.setElementList(variables);
}
}
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/variable/EntityVariableUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/variable/EntityVariableUI.jaxx 2015-05-18 09:52:01 UTC (rev 4226)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/variable/EntityVariableUI.jaxx 2015-05-20 12:09:09 UTC (rev 4227)
@@ -23,46 +23,31 @@
#L%
-->
<fr.ifremer.isisfish.ui.input.InputContentUI superGenericType='org.nuiton.topia.persistence.TopiaEntityContextable'>
- <import>
- static org.nuiton.i18n.I18n.t
- fr.ifremer.isisfish.ui.models.common.GenericComboModel
- </import>
- <EntityVariableHandler id="varHandler" />
<!-- bean property -->
<org.nuiton.topia.persistence.TopiaEntityContextable id='bean' javaBean='null'/>
<fr.ifremer.isisfish.entities.Variable id="variable" javaBean='null' />
+
+ <EntityVariableHandler id="handler" />
<script><![CDATA[
protected void $afterCompleteSetup() {
- addPropertyChangeListener(PROPERTY_BEAN, new java.beans.PropertyChangeListener() {
- public void propertyChange(java.beans.PropertyChangeEvent evt) {
- varHandler.initView(EntityVariableUI.this);
- }
- });
-
- addPropertyChangeListener(PROPERTY_VARIABLE, new java.beans.PropertyChangeListener() {
- public void propertyChange(java.beans.PropertyChangeEvent evt) {
- if (evt.getNewValue() == null) {
- matrixPanel.setMatrix(null);
- }
- }
- });
+ handler.init(this);
}
]]></script>
<Table>
<row>
<cell fill="both" weightx='1.0' weighty='1.0'>
- <Table border='{BorderFactory.createTitledBorder(t("isisfish.variables.variableslist"))}'>
+ <Table border='{BorderFactory.createTitledBorder(org.nuiton.i18n.I18n.t("isisfish.variables.variableslist"))}'>
<row>
<cell fill="both" weightx='1.0' weighty='1.0'>
<JScrollPane>
<JList id="variablesList" cellRenderer="{new VariableListRenderer()}"
genericType='fr.ifremer.isisfish.entities.Variable'
model="{new fr.ifremer.isisfish.ui.models.common.GenericListModel<Variable>()}"
- onValueChanged="getVarHandler().showSelectedVariable(this)"
+ onValueChanged="handler.showSelectedVariable(this)"
selectionMode="{javax.swing.ListSelectionModel.SINGLE_SELECTION}"
enabled='{isActive()}'/>
</JScrollPane>
@@ -70,14 +55,14 @@
</row>
<row>
<cell fill="horizontal">
- <JButton text="isisfish.variables.addvariable" onActionPerformed="getVarHandler().addNewVariable(this)"
+ <JButton text="isisfish.variables.addvariable" onActionPerformed="handler.addNewVariable(this)"
enabled='{isActive()}' decorator='boxed' />
</cell>
</row>
</Table>
</cell>
<cell fill="both" weightx='3.0' weighty='1.0' rows="2">
- <Table border='{BorderFactory.createTitledBorder(t("isisfish.variables.variabledetail"))}'>
+ <Table border='{BorderFactory.createTitledBorder(org.nuiton.i18n.I18n.t("isisfish.variables.variabledetail"))}'>
<row>
<cell fill="horizontal">
<JLabel text="isisfish.variables.entityname"
@@ -95,11 +80,8 @@
</cell>
<cell fill="horizontal" weightx='1.0'>
<JTextField id="variableNameField" text="{getVariable().getName()}"
- enabled='{isActive() && getVariable() != null}' decorator='boxed' />
- <javax.swing.text.Document
- initializer="variableNameField.getDocument()"
- onInsertUpdate='getVariable().setName(variableNameField.getText())'
- onRemoveUpdate='getVariable().setName(variableNameField.getText())' />
+ enabled='{isActive() && getVariable() != null}' decorator='boxed'
+ onKeyReleased="getVariable().setName(variableNameField.getText())" />
</cell>
</row>
<row>
@@ -108,10 +90,11 @@
enabled='{isActive() && getVariable() != null}'/>
</cell>
<cell fill="horizontal" weightx='1.0'>
- <JComboBox id="variableTypeCombo" model="{new GenericComboModel<fr.ifremer.isisfish.entities.Variable>()}"
- genericType="fr.ifremer.isisfish.entities.Variable"
+ <JComboBox id="variableTypeCombo"
+ model="{new fr.ifremer.isisfish.ui.models.common.EnumComboModel<fr.ifremer.isisfish.entities.VariableType>(fr.ifremer.isisfish.entities.VariableType.class)}"
+ genericType="fr.ifremer.isisfish.entities.VariableType"
selectedItem="{getVariable().getType()}"
- onActionPerformed="getVarHandler().showSelectedType(this)"
+ onActionPerformed="handler.showSelectedType(this)"
enabled='{isActive() && getVariable() != null}' decorator='boxed' />
</cell>
</row>
@@ -121,9 +104,9 @@
<JPanel id="variableTypePanel" layout="{variableTypeLayout}">
<!-- double -->
- <Table constraints='"doubletype"'>
+ <Table constraints='"doubletype"' insets="0">
<row>
- <cell fill="horizontal" anchor="northeast" weighty='1.0'>
+ <cell fill="horizontal" anchor="east" weighty='1.0'>
<JLabel text="isisfish.variables.double.value" enabled='{isActive() && getVariable() != null}' />
</cell>
<cell fill="horizontal" weightx='1.0' anchor="northeast" weighty='1.0'>
@@ -136,7 +119,7 @@
</Table>
<!-- matrix -->
- <Table constraints='"matrixtype"'>
+ <Table constraints='"matrixtype"' insets="0">
<row>
<cell fill="horizontal">
<JLabel text="isisfish.variables.matrix.value"
@@ -155,7 +138,7 @@
</Table>
<!-- equation -->
- <Table constraints='"equationtype"'>
+ <Table constraints='"equationtype"' insets="0">
<row>
<cell fill="both" weightx='1.0' weighty='1.0'>
<fr.ifremer.isisfish.ui.input.InputOneEquationUI id="variableEquationValue"
@@ -181,24 +164,21 @@
<JScrollPane>
<JTextArea id="variableComment" rows="3"
text="{jaxx.runtime.SwingUtil.getStringValue(getVariable().getComment())}"
- enabled='{isActive() && getVariable() != null}' decorator='boxed' />
- <javax.swing.text.Document
- initializer="variableComment.getDocument()"
- onInsertUpdate='getVariable().setComment(variableComment.getText())'
- onRemoveUpdate='getVariable().setComment(variableComment.getText())' />
+ enabled='{isActive() && getVariable() != null}' decorator='boxed'
+ onKeyReleased="getVariable().setComment(variableComment.getText())" />
</JScrollPane>
</cell>
</row>
<row>
<cell anchor="west">
<JButton text="isisfish.variables.deletevariable"
- onActionPerformed="getVarHandler().deleteVariable(this)"
+ onActionPerformed="handler.deleteVariable(this)"
enabled='{isActive() && getVariable() != null}'
decorator='boxed' />
</cell>
<cell anchor="east" weightx='1.0'>
<JButton text="isisfish.variables.savevariable"
- onActionPerformed="getVarHandler().saveVariable(this)"
+ onActionPerformed="handler.saveVariable(this)"
enabled='{isActive() && getVariable() != null}'
decorator='boxed' />
</cell>
Added: trunk/src/main/java/fr/ifremer/isisfish/ui/input/vesseltype/VesselTypeHandler.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/vesseltype/VesselTypeHandler.java (rev 0)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/vesseltype/VesselTypeHandler.java 2015-05-20 12:09:09 UTC (rev 4227)
@@ -0,0 +1,91 @@
+/*
+ * #%L
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2015 Ifremer, Codelutin, Chatellier Eric
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+package fr.ifremer.isisfish.ui.input.vesseltype;
+
+import static org.nuiton.i18n.I18n.n;
+import static org.nuiton.i18n.I18n.t;
+
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.util.ArrayList;
+import java.util.List;
+
+import fr.ifremer.isisfish.entities.TripType;
+import fr.ifremer.isisfish.ui.input.InputContentHandler;
+import fr.ifremer.isisfish.ui.models.common.GenericListModel;
+
+/**
+ * Trip type handler.
+ */
+public class VesselTypeHandler extends InputContentHandler<VesselTypeUI> {
+
+ protected boolean init;
+
+ protected void init(final VesselTypeUI inputContentUI) {
+ super.init(inputContentUI);
+
+ inputContentUI.setButtonTitle(t("isisfish.input.continueSetOfVessels"));
+ inputContentUI.setNextPath(n("isisfish.input.tree.setofvessels"));
+
+ inputContentUI.addPropertyChangeListener(VesselTypeUI.PROPERTY_BEAN, new PropertyChangeListener() {
+ public void propertyChange(PropertyChangeEvent evt) {
+ if (evt.getNewValue() == null) {
+ inputContentUI.fieldVesselTypeName.setText("");
+ inputContentUI.fieldVesselTypeLength.setText("");
+ inputContentUI.fieldVesselTypeSpeed.setText("");
+ inputContentUI.fieldVesselTypeMaxTripDuration.setText("");
+ inputContentUI.fieldVesselTypeActivityRange.setText("");
+ inputContentUI.fieldVesselTypeMinCrewSize.setText("");
+ inputContentUI.fieldVesselTypeSpeed.setText("");
+ inputContentUI.fieldVesselTypeUnitFuelCostOfTravel.setText("");
+ inputContentUI.fieldVesselTypeComment.setText("");
+ }
+ if (evt.getNewValue() != null) {
+ setTripTypeListModel();
+ }
+ }
+ });
+ }
+
+ protected void setTripTypeListModel() {
+ init = true;
+ List<TripType> tripTypes = inputContentUI.getFisheryRegion().getTripType();
+ GenericListModel<TripType> tripTypeModel = new GenericListModel<>(tripTypes);
+ inputContentUI.vesselTypeTripType.setModel(tripTypeModel);
+
+ if (inputContentUI.getBean() != null && inputContentUI.getBean().getTripType() != null) {
+ for (TripType tripType : inputContentUI.getBean().getTripType()) {
+ int index = tripTypes.indexOf(tripType);
+ inputContentUI.vesselTypeTripType.addSelectionInterval(index, index);
+ }
+ }
+ init = false;
+ }
+ protected void tripTypeChanged() {
+ if (!init) {
+ List<TripType> tripTypes = new ArrayList<>(inputContentUI.vesselTypeTripType.getSelectedValuesList());
+ inputContentUI.getBean().setTripType(tripTypes);
+ }
+ }
+}
Property changes on: trunk/src/main/java/fr/ifremer/isisfish/ui/input/vesseltype/VesselTypeHandler.java
___________________________________________________________________
Added: svn:eol-style
+ native
Added: svn:keywords
+ Author Date Id Revision HeadURL
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/vesseltype/VesselTypeUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/vesseltype/VesselTypeUI.jaxx 2015-05-18 09:52:01 UTC (rev 4226)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/vesseltype/VesselTypeUI.jaxx 2015-05-20 12:09:09 UTC (rev 4227)
@@ -27,16 +27,7 @@
<!-- bean property -->
<fr.ifremer.isisfish.entities.VesselType id='bean' javaBean='null'/>
- <import>
- static org.nuiton.i18n.I18n.t
- static org.nuiton.i18n.I18n.n
- fr.ifremer.isisfish.entities.VesselType
- fr.ifremer.isisfish.entities.TripType
- fr.ifremer.isisfish.types.TimeUnit
- fr.ifremer.isisfish.ui.models.common.GenericListModel
- java.beans.PropertyChangeEvent
- java.beans.PropertyChangeListener
- </import>
+ <VesselTypeHandler id="handler" />
<BeanValidator id='validator'
bean='{getBean()}' beanClass='fr.ifremer.isisfish.entities.VesselType'
@@ -44,76 +35,16 @@
<field name="name" component="fieldVesselTypeName" />
</BeanValidator>
- <script><![CDATA[
-protected boolean init;
+ <import>
+ fr.ifremer.isisfish.types.TimeUnit
+ </import>
-protected void $afterCompleteSetup() {
- setButtonTitle(t("isisfish.input.continueSetOfVessels"));
- setNextPath(n("isisfish.input.tree.setofvessels"));
-
- addPropertyChangeListener(PROPERTY_BEAN, new PropertyChangeListener() {
- public void propertyChange(PropertyChangeEvent evt) {
- if (evt.getNewValue() == null) {
- fieldVesselTypeName.setText("");
- fieldVesselTypeLength.setText("");
- fieldVesselTypeSpeed.setText("");
- fieldVesselTypeMaxTripDuration.setText("");
- fieldVesselTypeActivityRange.setText("");
- fieldVesselTypeMinCrewSize.setText("");
- fieldVesselTypeSpeed.setText("");
- fieldVesselTypeUnitFuelCostOfTravel.setText("");
- fieldVesselTypeComment.setText("");
- }
- if (evt.getNewValue() != null) {
- setTripTypeListModel();
- }
- }
- });
-}
-
-/*public void refresh() {
- VesselType vesselType = getSaveVerifier().getEntity(VesselType.class);
-
- // add null before, for second to be considered as a changed event
- // otherwize, setBean has no effect
- setBean(null);
- setBean(vesselType);
-
- if (getBean() != null) {
- setListModel();
-
- // NumberEditor is not working
- //fieldVesselTypeLength.init();
- //fieldVesselTypeLength.init();
- //fieldVesselTypeSpeed.init();
- //fieldVesselTypeActivityRange.init();
- //fieldVesselTypeMinCrewSize.init();
- //fieldVesselTypeSpeed.init();
- //fieldVesselTypeUnitFuelCostOfTravel.init();
+ <script><![CDATA[
+ protected void $afterCompleteSetup() {
+ handler.init(this);
}
-}*/
-
-protected void setTripTypeListModel() {
- init = true;
- List<TripType> tripTypes = getFisheryRegion().getTripType();
- GenericListModel<TripType> tripTypeModel = new GenericListModel<>(tripTypes);
- vesselTypeTripType.setModel(tripTypeModel);
-
- if (getBean() != null && getBean().getTripType() != null) {
- for (TripType tripType : getBean().getTripType()) {
- int index = tripTypes.indexOf(tripType);
- vesselTypeTripType.addSelectionInterval(index, index);
- }
- }
- init = false;
-}
-protected void tripTypeChanged() {
- if (!init) {
- List<TripType> tripTypes = new ArrayList<TripType>(vesselTypeTripType.getSelectedValuesList());
- getBean().setTripType(tripTypes);
- }
-}
]]></script>
+
<JPanel id="body">
<Table>
<row>
@@ -214,9 +145,9 @@
</cell>
<cell fill='both' weightx='1.0' weighty='0.7'>
<JScrollPane>
- <JList id="vesselTypeTripType" onValueChanged='tripTypeChanged()'
+ <JList id="vesselTypeTripType" onValueChanged='handler.tripTypeChanged()'
genericType="fr.ifremer.isisfish.entities.TripType"
- cellRenderer="{new fr.ifremer.isisfish.ui.input.renderer.TripTypeListRenderer()}"
+ cellRenderer="{new fr.ifremer.isisfish.ui.input.triptype.TripTypeListRenderer()}"
enabled='{isActive()}' decorator='boxed' _sensitivityBean='{VesselType.class}' _sensitivityMethod='"TripType"'/>
</JScrollPane>
</cell>
Added: trunk/src/main/java/fr/ifremer/isisfish/ui/input/zone/ZoneBasicsHandler.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/zone/ZoneBasicsHandler.java (rev 0)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/zone/ZoneBasicsHandler.java 2015-05-20 12:09:09 UTC (rev 4227)
@@ -0,0 +1,124 @@
+/*
+ * #%L
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2015 Ifremer, Codelutin, Chatellier Eric
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+package fr.ifremer.isisfish.ui.input.zone;
+
+import java.awt.event.MouseEvent;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.swing.event.ListSelectionEvent;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import com.bbn.openmap.event.SelectMouseMode;
+
+import fr.ifremer.isisfish.entities.Cell;
+import fr.ifremer.isisfish.map.CellSelectionLayer;
+import fr.ifremer.isisfish.map.OpenMapEvents;
+import fr.ifremer.isisfish.ui.input.InputContentHandler;
+import fr.ifremer.isisfish.ui.models.common.GenericListModel;
+
+/**
+ * Zone handler.
+ */
+public class ZoneBasicsHandler extends InputContentHandler<ZoneBasicsUI> {
+
+ /** Class logger. */
+ private static final Log log = LogFactory.getLog(ZoneBasicsHandler.class);
+
+ protected void init(final ZoneBasicsUI zoneBasicsUI) {
+ super.init(zoneBasicsUI);
+
+ new OpenMapEvents(zoneBasicsUI.zoneMap, new SelectMouseMode(false), CellSelectionLayer.MULT_SELECTION) {
+ @Override
+ public boolean mouseClicked(MouseEvent e) {
+ boolean result = false;
+ if (zoneBasicsUI.getBean() != null) { // impossible de desactiver la carte :(
+ zoneBasicsUI.getBean().setCell(zoneBasicsUI.zoneMap.getSelectedCells());
+ setZoneCells();
+ }
+ return result;
+ }
+ };
+
+ zoneBasicsUI.addPropertyChangeListener(ZoneBasicsUI.PROPERTY_BEAN, new PropertyChangeListener() {
+ public void propertyChange(PropertyChangeEvent evt) {
+ if (evt.getNewValue() == null) {
+ zoneBasicsUI.fieldZoneName.setText("");
+ zoneBasicsUI.fieldZoneComment.setText("");
+ zoneBasicsUI.zoneMap.setSelectedCells();
+ }
+ if (evt.getNewValue() != null) {
+
+ }
+ setZoneCells();
+ }
+ });
+ }
+
+ protected void setZoneCells() {
+ GenericListModel<Cell> zoneModel = new GenericListModel<>();
+ if (inputContentUI.getBean() != null) {
+
+ // build model
+ List<Cell> cells = inputContentUI.getFisheryRegion().getCell();
+ zoneModel.setElementList(cells);
+ inputContentUI.zoneCells.setModel(zoneModel);
+
+ // restore selection
+ int firstIndex = -1;
+ if (inputContentUI.getBean().getCell() != null) {
+ for (Cell selectedCell : inputContentUI.getBean().getCell()) {
+ int index = cells.indexOf(selectedCell);
+ inputContentUI.zoneCells.addSelectionInterval(index, index);
+
+ if (firstIndex == -1) {
+ firstIndex = index;
+ }
+ }
+ }
+
+ // sroll to visible
+ if (firstIndex != -1) {
+ inputContentUI.zoneCells.ensureIndexIsVisible(firstIndex);
+ }
+ } else {
+ inputContentUI.zoneCells.setModel(zoneModel);
+ }
+ }
+
+ public void zoneCellsChange(ListSelectionEvent event) {
+ // sans ca, ca boucle (modification depuis la carte)
+ if (event.getValueIsAdjusting()) {
+ // pas a faie dans le cas d'une AS
+ if (inputContentUI.isActive()) {
+ List<Cell> cells = new ArrayList<>(inputContentUI.zoneCells.getSelectedValuesList());
+ inputContentUI.getBean().setCell(cells);
+ }
+ }
+ }
+}
Property changes on: trunk/src/main/java/fr/ifremer/isisfish/ui/input/zone/ZoneBasicsHandler.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/zone/ZoneBasicsUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/zone/ZoneBasicsUI.jaxx 2015-05-18 09:52:01 UTC (rev 4226)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/zone/ZoneBasicsUI.jaxx 2015-05-20 12:09:09 UTC (rev 4227)
@@ -27,20 +27,7 @@
<!-- bean property -->
<fr.ifremer.isisfish.entities.Zone id='bean' javaBean='null'/>
- <import>
- javax.swing.event.ListSelectionEvent
- fr.ifremer.isisfish.entities.Cell
- fr.ifremer.isisfish.entities.Zone
- fr.ifremer.isisfish.map.CellSelectionLayer
- fr.ifremer.isisfish.map.CopyMapToClipboardListener
- fr.ifremer.isisfish.map.OpenMapEvents
- fr.ifremer.isisfish.ui.models.common.GenericListModel
- com.bbn.openmap.event.SelectMouseMode
- java.beans.PropertyChangeEvent
- java.beans.PropertyChangeListener
- java.awt.event.MouseEvent
- java.util.ArrayList
- </import>
+ <ZoneBasicsHandler id="handler" />
<BeanValidator id='validator'
bean='{getBean()}' beanClass='fr.ifremer.isisfish.entities.Zone'
@@ -50,68 +37,11 @@
</BeanValidator>
<script><![CDATA[
-protected void $afterCompleteSetup() {
-
- //zoneMap.init(zoneMapInfo);
- new OpenMapEvents(zoneMap, new SelectMouseMode(false), CellSelectionLayer.MULT_SELECTION) {
- @Override
- public boolean mouseClicked(MouseEvent e) {
- boolean result = false;
- if (getBean() != null) { // impossible de desactiver la carte :(
- getBean().setCell(zoneMap.getSelectedCells());
- setZoneCells();
- }
- return result;
- }
- };
-
- addPropertyChangeListener(PROPERTY_BEAN, new PropertyChangeListener() {
- public void propertyChange(PropertyChangeEvent evt) {
- if (evt.getNewValue() == null) {
- fieldZoneName.setText("");
- fieldZoneComment.setText("");
- zoneMap.setSelectedCells();
- }
- if (evt.getNewValue() != null) {
-
- }
- setZoneCells();
- }
- });
-}
-
-protected void setZoneCells() {
- GenericListModel<Cell> zoneModel = new GenericListModel<Cell>();
- if (getBean() != null) {
- List<Cell> cells = getFisheryRegion().getCell();
- zoneModel.setElementList(cells);
- zoneCells.setModel(zoneModel);
- if (getBean().getCell() != null) {
- for (Cell selectedCell : getBean().getCell()) {
- int index = cells.indexOf(selectedCell);
- zoneCells.addSelectionInterval(index, index);
- }
- }
- } else {
- zoneCells.setModel(zoneModel);
+ protected void $afterCompleteSetup() {
+ handler.init(this);
}
-}
+ ]]></script>
-protected void zoneCellsChange(ListSelectionEvent event) {
- // sans ca, ca boucle (modification depuis la carte)
- if (event.getValueIsAdjusting()) {
- // pas a faie dans le cas d'une AS
- if (isActive()) {
- List<Cell> cells = new ArrayList<Cell>();
- for (Cell o : zoneCells.getSelectedValuesList()) {
- cells.add(o);
- }
- getBean().setCell(cells);
- }
- }
-}
-]]>
- </script>
<JPanel id='body'>
<JSplitPane oneTouchExpandable="true" dividerLocation="200" orientation="horizontal">
<Table>
@@ -138,7 +68,7 @@
<JScrollPane id="spZoneCells">
<JList id="zoneCells" enabled='{isActive()}'
genericType="fr.ifremer.isisfish.entities.Cell"
- onValueChanged='zoneCellsChange(event)' decorator='boxed'/>
+ onValueChanged='handler.zoneCellsChange(event)' decorator='boxed'/>
</JScrollPane>
</cell>
</row>
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/zone/ZoneHandler.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/zone/ZoneHandler.java 2015-05-18 09:52:01 UTC (rev 4226)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/zone/ZoneHandler.java 2015-05-20 12:09:09 UTC (rev 4227)
@@ -26,9 +26,6 @@
import static org.nuiton.i18n.I18n.n;
import static org.nuiton.i18n.I18n.t;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
import fr.ifremer.isisfish.ui.input.InputContentHandler;
/**
@@ -36,17 +33,14 @@
*/
public class ZoneHandler extends InputContentHandler<ZoneUI> {
- /** Class logger. */
- private static final Log log = LogFactory.getLog(ZoneHandler.class);
+ protected void init(final ZoneUI inputContentUI) {
+ super.init(inputContentUI);
- protected void init(final ZoneUI zoneUI) {
- super.init(zoneUI);
+ inputContentUI.setButtonTitle(t("isisfish.input.continuePorts"));
+ inputContentUI.setNextPath(n("isisfish.input.tree.ports"));
- zoneUI.setButtonTitle(t("isisfish.input.continuePorts"));
- zoneUI.setNextPath(n("isisfish.input.tree.ports"));
-
// install change listener
// (depends on sensitivity can't be done on constructor)
- zoneUI.installChangeListener(zoneUI.zoneTab);
+ inputContentUI.installChangeListener(inputContentUI.zoneTab);
}
}
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/zone/ZoneUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/zone/ZoneUI.jaxx 2015-05-18 09:52:01 UTC (rev 4226)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/zone/ZoneUI.jaxx 2015-05-20 12:09:09 UTC (rev 4227)
@@ -29,22 +29,22 @@
<ZoneHandler id="handler" />
<script><![CDATA[
- protected void $afterCompleteSetup() {
- handler.init(this);
- }
+ protected void $afterCompleteSetup() {
+ handler.init(this);
+ }
- @Override
- public void setLayer(boolean active) {
- super.setLayer(active);
- zoneBasicsUI.setLayer(active);
- variablesUI.setLayer(active);
- }
-
- @Override
- public void resetChangeModel() {
- zoneBasicsUI.resetChangeModel();
- variablesUI.resetChangeModel();
- }
+ @Override
+ public void setLayer(boolean active) {
+ super.setLayer(active);
+ zoneBasicsUI.setLayer(active);
+ variablesUI.setLayer(active);
+ }
+
+ @Override
+ public void resetChangeModel() {
+ zoneBasicsUI.resetChangeModel();
+ variablesUI.resetChangeModel();
+ }
]]></script>
<JPanel id="body">
Added: trunk/src/main/java/fr/ifremer/isisfish/ui/models/common/EnumComboModel.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/models/common/EnumComboModel.java (rev 0)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/models/common/EnumComboModel.java 2015-05-20 12:09:09 UTC (rev 4227)
@@ -0,0 +1,45 @@
+/*
+ * #%L
+ * IsisFish
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2015 Ifremer, CodeLutin, Chatellier Eric
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+package fr.ifremer.isisfish.ui.models.common;
+
+import org.jdesktop.swingx.combobox.EnumComboBoxModel;
+
+/**
+ * Just a delegator class to not use external API in Isis.
+ *
+ * @author Eric Chatellier
+ *
+ * @param <E> enum type
+ */
+public class EnumComboModel<E extends Enum<E>> extends EnumComboBoxModel<E>{
+
+ /** serialVersionUID. */
+ private static final long serialVersionUID = -912859822412819321L;
+
+ public EnumComboModel(Class<E> en) {
+ super(en);
+ }
+
+}
Property changes on: trunk/src/main/java/fr/ifremer/isisfish/ui/models/common/EnumComboModel.java
___________________________________________________________________
Added: svn:eol-style
+ native
Added: svn:keywords
+ Author Date Id Revision HeadURL
Modified: trunk/src/main/resources/i18n/isis-fish_en_GB.properties
===================================================================
--- trunk/src/main/resources/i18n/isis-fish_en_GB.properties 2015-05-18 09:52:01 UTC (rev 4226)
+++ trunk/src/main/resources/i18n/isis-fish_en_GB.properties 2015-05-20 12:09:09 UTC (rev 4227)
@@ -990,7 +990,7 @@
isisfish.variables.variabledetail=Variable details
isisfish.variables.variablename=Variable name \:
isisfish.variables.variableslist=Variables
-isisfish.variables.variabletype=Variable type
+isisfish.variables.variabletype=Variable type \:
isisfish.vcs.ask.passphrase=Enter your pass phrase (if your private key have one).
isisfish.vcs.ask.passphrase.title=Ask your pass phrase
isisfish.vcs.commit=vcs.commit
1
0
r4226 - in trunk: . src/test/java/fr/ifremer/isisfish/ui src/test/java/fr/ifremer/isisfish/ui/input
by echatellier@users.forge.codelutin.com 18 May '15
by echatellier@users.forge.codelutin.com 18 May '15
18 May '15
Author: echatellier
Date: 2015-05-18 09:52:01 +0000 (Mon, 18 May 2015)
New Revision: 4226
Url: http://forge.codelutin.com/projects/isis-fish/repository/revisions/4226
Log:
Update libs.
Move from fest to assertj.
Modified:
trunk/pom.xml
trunk/src/test/java/fr/ifremer/isisfish/ui/AbstractFestIT.java
trunk/src/test/java/fr/ifremer/isisfish/ui/input/InputIT.java
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2015-05-07 16:16:34 UTC (rev 4225)
+++ trunk/pom.xml 2015-05-18 09:52:01 UTC (rev 4226)
@@ -77,7 +77,7 @@
<dependency>
<groupId>org.ow2.asm</groupId>
<artifactId>asm</artifactId>
- <version>5.0.3</version>
+ <version>5.0.4</version>
<scope>compile</scope>
</dependency>
@@ -237,29 +237,29 @@
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
- <version>2.2</version>
+ <version>2.3</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
- <version>2.2</version>
+ <version>2.3</version>
<scope>compile</scope>
</dependency>
<dependency>
- <groupId>org.apache.logging.log4j</groupId>
- <artifactId>log4j-jcl</artifactId>
- <version>2.2</version>
- <scope>runtime</scope>
+ <groupId>org.apache.logging.log4j</groupId>
+ <artifactId>log4j-jcl</artifactId>
+ <version>2.3</version>
+ <scope>runtime</scope>
</dependency>
<dependency>
- <groupId>org.apache.logging.log4j</groupId>
- <artifactId>log4j-slf4j-impl</artifactId>
- <version>2.2</version>
- <scope>runtime</scope>
+ <groupId>org.apache.logging.log4j</groupId>
+ <artifactId>log4j-slf4j-impl</artifactId>
+ <version>2.3</version>
+ <scope>runtime</scope>
</dependency>
<dependency>
@@ -387,13 +387,19 @@
<version>4.12</version>
<scope>test</scope>
</dependency>
-
+
<dependency>
- <groupId>org.easytesting</groupId>
- <artifactId>fest-swing</artifactId>
- <version>1.2.1</version>
+ <groupId>org.assertj</groupId>
+ <artifactId>assertj-swing</artifactId>
+ <version>2.0.0</version>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.assertj</groupId>
+ <artifactId>assertj-swing-junit</artifactId>
+ <version>2.0.0</version>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<!-- ************************************************************* -->
Modified: trunk/src/test/java/fr/ifremer/isisfish/ui/AbstractFestIT.java
===================================================================
--- trunk/src/test/java/fr/ifremer/isisfish/ui/AbstractFestIT.java 2015-05-07 16:16:34 UTC (rev 4225)
+++ trunk/src/test/java/fr/ifremer/isisfish/ui/AbstractFestIT.java 2015-05-18 09:52:01 UTC (rev 4226)
@@ -24,11 +24,11 @@
*/
package fr.ifremer.isisfish.ui;
-import org.fest.swing.edt.FailOnThreadViolationRepaintManager;
-import org.fest.swing.edt.GuiActionRunner;
-import org.fest.swing.edt.GuiQuery;
-import org.fest.swing.exception.WaitTimedOutError;
-import org.fest.swing.fixture.FrameFixture;
+import org.assertj.swing.edt.FailOnThreadViolationRepaintManager;
+import org.assertj.swing.edt.GuiActionRunner;
+import org.assertj.swing.edt.GuiQuery;
+import org.assertj.swing.exception.WaitTimedOutError;
+import org.assertj.swing.fixture.FrameFixture;
import org.junit.After;
import org.junit.Assume;
import org.junit.Before;
@@ -47,7 +47,7 @@
protected FrameFixture mainWindow;
@BeforeClass
- public static void setUpOnce() {
+ public static void setUpOnce() throws Exception {
Assume.assumeTrue(!java.awt.GraphicsEnvironment.isHeadless());
FailOnThreadViolationRepaintManager.install();
}
Modified: trunk/src/test/java/fr/ifremer/isisfish/ui/input/InputIT.java
===================================================================
--- trunk/src/test/java/fr/ifremer/isisfish/ui/input/InputIT.java 2015-05-07 16:16:34 UTC (rev 4225)
+++ trunk/src/test/java/fr/ifremer/isisfish/ui/input/InputIT.java 2015-05-18 09:52:01 UTC (rev 4226)
@@ -28,7 +28,7 @@
import java.io.IOException;
import org.apache.commons.lang3.SystemUtils;
-import org.fest.swing.core.matcher.JButtonMatcher;
+import org.assertj.swing.core.matcher.JButtonMatcher;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
@@ -83,9 +83,10 @@
public void testImportRegion() throws IOException {
openDemoRegion();
mainWindow.menuItem("menuRegionExport").click();
- File f = new File(SystemUtils.JAVA_IO_TMPDIR, "isis-export.zip");
+ File f = File.createTempFile("isis-export", ".zip"); // bug file exists
f.deleteOnExit();
mainWindow.fileChooser().selectFile(f).approve();
+ mainWindow.optionPane().yesButton().click(); // bug file exists
mainWindow.menuItem("menuRegionImportRename").click();
mainWindow.fileChooser().selectFile(f).approve();
1
0
r4225 - in trunk/src/main/java/fr/ifremer/isisfish: types ui/input/cell ui/input/gear ui/input/population ui/input/port ui/input/setofvessels ui/input/zone
by echatellier@users.forge.codelutin.com 07 May '15
by echatellier@users.forge.codelutin.com 07 May '15
07 May '15
Author: echatellier
Date: 2015-05-07 16:16:34 +0000 (Thu, 07 May 2015)
New Revision: 4225
Url: http://forge.codelutin.com/projects/isis-fish/repository/revisions/4225
Log:
Replace Combobox and Lit by non deprecated
Modified:
trunk/src/main/java/fr/ifremer/isisfish/types/RangeOfValues.java
trunk/src/main/java/fr/ifremer/isisfish/ui/input/cell/CellHandler.java
trunk/src/main/java/fr/ifremer/isisfish/ui/input/gear/RangeOfValuesUI.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationGroupUI.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationEmigrationUI.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationImmigrationUI.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationMigrationUI.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationUI.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/input/port/PortUI.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/input/setofvessels/SetOfVesselsBasicsUI.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/input/zone/ZoneBasicsUI.jaxx
Modified: trunk/src/main/java/fr/ifremer/isisfish/types/RangeOfValues.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/types/RangeOfValues.java 2015-05-07 13:57:54 UTC (rev 4224)
+++ trunk/src/main/java/fr/ifremer/isisfish/types/RangeOfValues.java 2015-05-07 16:16:34 UTC (rev 4225)
@@ -5,7 +5,7 @@
* $Id$
* $HeadURL$
* %%
- * Copyright (C) 2006 - 2011 Ifremer, Code Lutin, Cédric Pineau, Benjamin Poussin, Chatellier Eric
+ * Copyright (C) 2006 - 2015 Ifremer, Code Lutin, Cédric Pineau, Benjamin Poussin, Chatellier Eric
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
@@ -58,7 +58,7 @@
protected String type = TYPE_STRING;
protected boolean continueRange = false;
protected String values = "";
- protected List possibleValues = null;
+ protected List<Object> possibleValues = null;
public RangeOfValues(String typeValue) {
setTypeValues(typeValue);
@@ -166,9 +166,9 @@
return s;
}
- public List getPossibleValues() {
+ public List<Object> getPossibleValues() {
if (possibleValues == null) {
- possibleValues = new ArrayList();
+ possibleValues = new ArrayList<>();
String g = getValues();
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/cell/CellHandler.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/cell/CellHandler.java 2015-05-07 13:57:54 UTC (rev 4224)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/cell/CellHandler.java 2015-05-07 16:16:34 UTC (rev 4225)
@@ -41,6 +41,7 @@
import fr.ifremer.isisfish.map.OpenMapEvents;
import fr.ifremer.isisfish.ui.input.InputContentHandler;
import fr.ifremer.isisfish.ui.input.InputUI;
+import fr.ifremer.isisfish.ui.models.common.GenericComboModel;
import fr.ifremer.isisfish.ui.sensitivity.SensitivityTabUI;
/**
@@ -51,7 +52,7 @@
/** Class logger. */
private static final Log log = LogFactory.getLog(CellHandler.class);
- protected boolean cellChanged;
+ protected boolean init;
protected void init(final CellUI cellUI) {
super.init(cellUI);
@@ -82,6 +83,8 @@
cellUI.addPropertyChangeListener(CellUI.PROPERTY_BEAN, new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent evt) {
+ init = true;
+ GenericComboModel<Cell> cellModel = new GenericComboModel<>();
if (evt.getNewValue() == null) {
cellUI.fieldCellName.setText("");
cellUI.fieldCellLatitude.setText("");
@@ -90,16 +93,18 @@
cellUI.fieldCellLand.setSelected(false);
}
if (evt.getNewValue() != null) {
- cellChanged = false;
- jaxx.runtime.SwingUtil.fillComboBox(cellUI.fieldCell, cellUI.getFisheryRegion().getCell(), cellUI.getBean());
- cellChanged = true;
+ //jaxx.runtime.SwingUtil.fillComboBox(cellUI.fieldCell, cellUI.getFisheryRegion().getCell(), cellUI.getBean());
+ cellModel.setElementList(cellUI.getFisheryRegion().getCell());
+ cellModel.setSelectedItem(cellUI.getBean());
}
+ cellUI.fieldCell.setModel(cellModel);
+ init = false;
}
});
}
protected void fieldCellChanged(ItemEvent event) {
- if (cellChanged && event.getStateChange() == ItemEvent.SELECTED) {
+ if (!init && event.getStateChange() == ItemEvent.SELECTED) {
Cell c = (Cell)inputContentUI.fieldCell.getSelectedItem();
if (c==null) {
return;
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/gear/RangeOfValuesUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/gear/RangeOfValuesUI.jaxx 2015-05-07 13:57:54 UTC (rev 4224)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/gear/RangeOfValuesUI.jaxx 2015-05-07 16:16:34 UTC (rev 4225)
@@ -32,63 +32,58 @@
fr.ifremer.isisfish.entities.Gear
java.beans.PropertyChangeEvent;
java.beans.PropertyChangeListener
+ java.util.List
java.util.ArrayList
+ fr.ifremer.isisfish.ui.models.common.GenericComboModel
</import>
<script><![CDATA[
+
boolean init = false;
protected void $afterCompleteSetup() {
addPropertyChangeListener(PROPERTY_BEAN, new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent evt) {
+
+ GenericComboModel<String> gearParamTypeModel = new GenericComboModel<>();
if (evt.getNewValue() == null) {
fieldGearParamPossibleValue.setText("");
+ fieldGearParamType.setSelectedItem(null);
+ fieldGearParamType.setModel(gearParamTypeModel);
}
if (evt.getNewValue() != null) {
- java.util.List<Object> values = new ArrayList<Object>();
+ init = true;
+
+ List<String> values = new ArrayList<String>();
for (String value : RangeOfValues.getPossibleTypes()) {
values.add(value);
}
-
- init = true;
- jaxx.runtime.SwingUtil.fillComboBox(fieldGearParamType, values, getBean().getPossibleValue() == null ? null : getBean().getPossibleValue().getType(), true);
+ gearParamTypeModel.setElementList(values);
+
+ fieldGearParamType.setModel(gearParamTypeModel);
+ if (getBean().getPossibleValue() != null) {
+ fieldGearParamType.setSelectedItem(getBean().getPossibleValue().getType());
+ }
+
init = false;
}
}
});
}
-/*public void refresh() {
- Gear gear = getSaveVerifier().getEntity(Gear.class);
-
- // add null before, for second to be considered as a changed event
- // otherwize, setBean has no effect
- setBean(null);
- setBean(gear);
-
- if (getBean() != null) {
- java.util.List<Object> values = new ArrayList<Object>();
- for (String value : RangeOfValues.getPossibleTypes()) {
- values.add(value);
- }
-
- init = true;
- jaxx.runtime.SwingUtil.fillComboBox(fieldGearParamType, values, getBean().getPossibleValue() == null ? null : getBean().getPossibleValue().getType(), true);
- init = false;
- }
-}*/
-
protected void gearParamChanged() {
if (fieldGearParamType.getSelectedItem() != null && !init) {
getBean().setPossibleValue(new RangeOfValues(fieldGearParamType.getSelectedItem().toString().concat("[" + fieldGearParamPossibleValue.getText() + "]")));
}
}
- ]]></script>
+ ]]></script>
<JPanel id='body'>
<Table>
<row>
<cell fill='horizontal' weightx='0.5'>
- <JAXXComboBox id="fieldGearParamType" onActionPerformed='gearParamChanged()' enabled='{isActive()}'/>
+ <JComboBox id="fieldGearParamType"
+ genericType="String"
+ onItemStateChanged='gearParamChanged()' enabled='{isActive()}'/>
</cell>
<cell fill='horizontal' weightx='0.5'>
<JTextField id="fieldGearParamPossibleValue" text='{getBean().getPossibleValue() == null ? "" : getBean().getPossibleValue().getValues()}'
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationGroupUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationGroupUI.jaxx 2015-05-07 13:57:54 UTC (rev 4224)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationGroupUI.jaxx 2015-05-07 16:16:34 UTC (rev 4225)
@@ -5,7 +5,7 @@
$Id$
$HeadURL$
%%
- Copyright (C) 2009 - 2011 Ifremer, Code Lutin, Chatellier Eric
+ Copyright (C) 2009 - 2015 Ifremer, Code Lutin, Chatellier Eric
%%
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as
@@ -40,11 +40,12 @@
<fr.ifremer.isisfish.entities.PopulationGroup id='populationGroup' javaBean='null'/>
<import>
- fr.ifremer.isisfish.entities.PopulationGroup;
- fr.ifremer.isisfish.entities.Population;
- org.nuiton.math.matrix.MatrixND;
- java.beans.PropertyChangeEvent;
- java.beans.PropertyChangeListener;
+ fr.ifremer.isisfish.entities.PopulationGroup
+ fr.ifremer.isisfish.entities.Population
+ org.nuiton.math.matrix.MatrixND
+ java.beans.PropertyChangeEvent
+ java.beans.PropertyChangeListener
+ fr.ifremer.isisfish.ui.models.common.GenericComboModel
</import>
<BeanValidator id='validator' context="group"
@@ -65,14 +66,17 @@
protected void $afterCompleteSetup() {
addPropertyChangeListener(PROPERTY_BEAN, new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent evt) {
+
+ GenericComboModel<PopulationGroup> groupModel = new GenericComboModel<>();
+
if (evt.getNewValue() == null) {
setPopulationGroup(null);
}
if (evt.getNewValue() != null) {
- if (getBean().getPopulationGroup() != null) {
- jaxx.runtime.SwingUtil.fillComboBox(populationGroupPopulationGroupComboBox, getBean().getPopulationGroup(), getPopulationGroup(), true);
- }
+ groupModel.setElementList(getBean().getPopulationGroup());
}
+
+ populationGroupPopulationGroupComboBox.setModel(groupModel);
}
});
@@ -82,6 +86,7 @@
fieldPopulationGroupMeanWeight.setText("");
fieldPopulationGroupPrice.setText("");
fieldPopulationGroupReproductionRate.setText("");
+ fieldPopulationGroupMaturityOgive.setText("");
fieldPopulationGroupAge.setText("");
fieldPopulationGroupMinLength.setText("");
fieldPopulationGroupMaxLength.setText("");
@@ -100,18 +105,6 @@
changeModel.setStayChanged(false);
}
-/*public void refresh() {
- //if (!isActive()) {
- setPopGroupNotNull(false);
- //}
- Population population = getSaveVerifier().getEntity(Population.class);
-
- // add null before, for second to be considered as a changed event
- // otherwize, setBean has no effect
- setBean(null);
- setBean(population);
-}*/
-
protected void setNaturalDeathRateMatrix() {
try {
Population population = getBean();
@@ -149,8 +142,9 @@
<JLabel text="isisfish.common.populationGroup" enabled='{isActive()}'/>
</cell>
<cell columns='2' fill='horizontal' weightx='1.0'>
- <JAXXComboBox id='populationGroupPopulationGroupComboBox' onActionPerformed='populationGroupChanged()'
- enabled='{isActive()}'/>
+ <JComboBox id='populationGroupPopulationGroupComboBox'
+ genericType="fr.ifremer.isisfish.entities.PopulationGroup"
+ onActionPerformed='populationGroupChanged()' enabled='{isActive()}'/>
</cell>
</row>
<row>
@@ -168,7 +162,7 @@
</cell>
<cell columns='2' fill='horizontal' weightx='1.0'>
<JTextField id="fieldPopulationGroupMeanWeight" text='{String.valueOf(getPopulationGroup().getMeanWeight())}'
- enabled="false" decorator='boxed'/>
+ enabled='{isActive()}' editable="false" decorator='boxed'/>
</cell>
</row>
<row>
@@ -177,7 +171,7 @@
</cell>
<cell columns='2' fill='horizontal' weightx='1.0'>
<JTextField id="fieldPopulationGroupMaturityOgive" text='{String.valueOf(getPopulationGroup().getMaturityOgive())}'
- enabled="false" decorator='boxed'/>
+ enabled='{isActive()}' editable="false" decorator='boxed'/>
</cell>
</row>
<row>
@@ -186,7 +180,7 @@
</cell>
<cell columns='2' fill='horizontal' weightx='1.0'>
<JTextField id="fieldPopulationGroupReproductionRate" text='{String.valueOf(getPopulationGroup().getReproductionRate())}'
- enabled="false" decorator='boxed'/>
+ enabled='{isActive()}' editable="false" decorator='boxed'/>
</cell>
</row>
<row>
@@ -195,7 +189,7 @@
</cell>
<cell columns='2' fill='horizontal' weightx='1.0'>
<JTextField id="fieldPopulationGroupPrice" text='{String.valueOf(getPopulationGroup().getPrice())}'
- enabled="false" decorator='boxed'/>
+ enabled='{isActive()}' editable="false" decorator='boxed'/>
</cell>
</row>
<row>
@@ -205,7 +199,7 @@
<cell columns='2' fill='horizontal' weightx='1.0'>
<!-- non editable age field -->
<JTextField id="fieldPopulationGroupAge" text='{String.valueOf(getPopulationGroup().getAge())}'
- enabled='false' decorator='boxed'/>
+ enabled='{isActive()}' editable="false" decorator='boxed'/>
</cell>
</row>
<row>
@@ -216,13 +210,13 @@
<!-- non editable min length field -->
<JTextField id="fieldPopulationGroupMinLength" text='{String.valueOf(getPopulationGroup().getMinLength())}'
toolTipText="isisfish.populationGroup.minimumLength"
- enabled='false' decorator='boxed' />
+ enabled='{isActive()}' editable="false" decorator='boxed' />
</cell>
<cell fill='both' weightx='0.5'>
<!-- non editable max length field -->
<JTextField id="fieldPopulationGroupMaxLength" text='{String.valueOf(getPopulationGroup().getMaxLength())}'
toolTipText="isisfish.populationGroup.maximumLength"
- enabled='false' decorator='boxed'/>
+ enabled='{isActive()}' editable="false" decorator='boxed'/>
</cell>
</row>
<row>
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationEmigrationUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationEmigrationUI.jaxx 2015-05-07 13:57:54 UTC (rev 4224)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationEmigrationUI.jaxx 2015-05-07 16:16:34 UTC (rev 4225)
@@ -5,7 +5,7 @@
$Id$
$HeadURL$
%%
- Copyright (C) 2009 - 2011 Ifremer, Code Lutin, Chatellier Eric
+ Copyright (C) 2009 - 2015 Ifremer, Code Lutin, Chatellier Eric
%%
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as
@@ -28,10 +28,6 @@
<fr.ifremer.isisfish.entities.Population id='bean' javaBean='null'/>
<fr.ifremer.isisfish.entities.PopulationSeasonInfo id='popInfo' javaBean='null'/>
- <Boolean id='gPopSelected' javaBean='false'/>
- <Boolean id='zoneDepartSelected' javaBean='false'/>
- <Boolean id='coefNonVide' javaBean='false'/>
-
<import>
fr.ifremer.isisfish.entities.Population
fr.ifremer.isisfish.entities.PopulationGroup
@@ -43,6 +39,7 @@
java.beans.PropertyChangeListener
org.nuiton.math.matrix.gui.MatrixPanelListener
fr.ifremer.isisfish.ui.input.InputAction
+ fr.ifremer.isisfish.ui.models.common.GenericComboModel
</import>
<script><![CDATA[
@@ -50,11 +47,15 @@
addPropertyChangeListener(PROPERTY_BEAN, new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent evt) {
if (evt.getNewValue() == null) {
+ fieldPopulationMigrationEmigrationCoefficient.setText("");
populationMigrationEmigrationTable.setMatrix(null);
}
if (evt.getNewValue() != null) {
- refreshPanel();
+
}
+ setFieldPopulationMigrationMigrationGroupChooserModel();
+ setFieldPopulationMigrationMigrationDepartureZoneChooserModel();
+ setAddButton();
}
});
}
@@ -66,46 +67,37 @@
//setPopInfo(pi);
populationMigrationEmigrationTable.setMatrix(getPopInfo().getEmigrationMatrix().copy());
}
-
-/*public void refresh(){
- Population population = getSaveVerifier().getEntity(Population.class);
-
- // setBean(null); useless here
- setBean(population);
-
- refreshPanel();
-}*/
-
-public void refreshPanel() {
- setFieldPopulationMigrationMigrationGroupChooserModel();
- setFieldPopulationMigrationMigrationDepartureZoneChooserModel();
- setAddButton();
-}
protected void populationMigrationEmigrationMatrixChanged(MatrixPanelEvent event) {
remove.setEnabled(populationMigrationEmigrationTable.getTable().getSelectedRow() != -1);
- if (popInfo != null){
+ if (popInfo != null) {
popInfo.setMigrationMatrix(populationMigrationEmigrationTable.getMatrix().clone());
}
}
-protected void setFieldPopulationMigrationMigrationGroupChooserModel(){
- if (getBean() != null && getBean().getPopulationGroup() != null){
- jaxx.runtime.SwingUtil.fillComboBox(fieldPopulationMigrationEmigrationGroupChooser,getBean().getPopulationGroup(), null, true);
+protected void setFieldPopulationMigrationMigrationGroupChooserModel() {
+ GenericComboModel<PopulationGroup> groups = new GenericComboModel<>();
+ if (getBean() != null && getBean().getPopulationGroup() != null) {
+ //jaxx.runtime.SwingUtil.fillComboBox(fieldPopulationMigrationEmigrationGroupChooser,getBean().getPopulationGroup(), null, true);
+ groups.setElementList(getBean().getPopulationGroup());
}
+ fieldPopulationMigrationEmigrationGroupChooser.setModel(groups);
}
-protected void setFieldPopulationMigrationMigrationDepartureZoneChooserModel(){
+protected void setFieldPopulationMigrationMigrationDepartureZoneChooserModel() {
+ GenericComboModel<Zone> zones = new GenericComboModel<>();
if (getBean() != null && getBean().getPopulationZone() != null){
- jaxx.runtime.SwingUtil.fillComboBox(fieldPopulationMigrationEmigrationDepartureZoneChooser,getBean().getPopulationZone(), null, true);
+ //jaxx.runtime.SwingUtil.fillComboBox(fieldPopulationMigrationEmigrationDepartureZoneChooser,getBean().getPopulationZone(), null, true);
+ zones.setElementList(getBean().getPopulationZone());
}
+ fieldPopulationMigrationEmigrationDepartureZoneChooser.setModel(zones);
}
-protected void add(){
+protected void add() {
getContextValue(InputAction.class).addEmigration(
getPopInfo(),
(PopulationGroup) fieldPopulationMigrationEmigrationGroupChooser.getSelectedItem(),
(Zone) fieldPopulationMigrationEmigrationDepartureZoneChooser.getSelectedItem(),
Double.parseDouble(fieldPopulationMigrationEmigrationCoefficient.getText()));
- populationMigrationEmigrationTable.setMatrix(getPopInfo().getEmigrationMatrix().clone());
+ populationMigrationEmigrationTable.setMatrix(getPopInfo().getEmigrationMatrix().clone());
}
protected void remove() {
@@ -120,20 +112,11 @@
populationMigrationEmigrationTable.setMatrix(getPopInfo().getEmigrationMatrix().copy());
}
}
-protected void groupChanged() {
- setGPopSelected(fieldPopulationMigrationEmigrationGroupChooser.getSelectedItem() != null);
- setAddButton();
-}
-protected void coefChanged() {
- setCoefNonVide(!fieldPopulationMigrationEmigrationCoefficient.getText().equals(""));
- setAddButton();
-}
-protected void zoneChanged() {
- setZoneDepartSelected(fieldPopulationMigrationEmigrationDepartureZoneChooser.getSelectedItem() != null);
- setAddButton();
-}
protected void setAddButton() {
- add.setEnabled(getGPopSelected() && getZoneDepartSelected() && getCoefNonVide());
+ add.setEnabled(isActive()
+ && fieldPopulationMigrationEmigrationGroupChooser.getSelectedItem() != null
+ && fieldPopulationMigrationEmigrationDepartureZoneChooser.getSelectedItem() != null
+ && !fieldPopulationMigrationEmigrationCoefficient.getText().equals(""));
}
]]></script>
<JPanel id="body">
@@ -143,13 +126,15 @@
<JLabel text="isisfish.common.populationGroup" enabled='{isActive()}'/>
</cell>
<cell fill='horizontal' weightx='0.5'>
- <JAXXComboBox id="fieldPopulationMigrationEmigrationGroupChooser" enabled='{isActive()}' onActionPerformed='groupChanged()'/>
+ <JComboBox id="fieldPopulationMigrationEmigrationGroupChooser"
+ genericType="fr.ifremer.isisfish.entities.PopulationGroup"
+ enabled='{isActive()}' onItemStateChanged='setAddButton()'/>
</cell>
<cell>
<JLabel text="isisfish.populationMigrationEmigration.coefficient" enabled='{isActive()}'/>
</cell>
<cell fill='horizontal' weightx='0.5'>
- <JTextField id="fieldPopulationMigrationEmigrationCoefficient" enabled='{isActive()}' onKeyReleased='coefChanged()'/>
+ <JTextField id="fieldPopulationMigrationEmigrationCoefficient" enabled='{isActive()}' onKeyReleased='setAddButton()'/>
</cell>
</row>
<row>
@@ -157,7 +142,9 @@
<JLabel text="isisfish.populationMigrationEmigration.departureZone" enabled='{isActive()}'/>
</cell>
<cell fill='horizontal' weightx='0.5'>
- <JAXXComboBox id="fieldPopulationMigrationEmigrationDepartureZoneChooser" enabled='{isActive()}' onActionPerformed='zoneChanged()'/>
+ <JComboBox id="fieldPopulationMigrationEmigrationDepartureZoneChooser"
+ genericType="fr.ifremer.isisfish.entities.Zone"
+ enabled='{isActive()}' onItemStateChanged='setAddButton()'/>
</cell>
<cell columns='2' fill='horizontal' weightx='0.5'>
<JPanel/>
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationImmigrationUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationImmigrationUI.jaxx 2015-05-07 13:57:54 UTC (rev 4224)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationImmigrationUI.jaxx 2015-05-07 16:16:34 UTC (rev 4225)
@@ -5,7 +5,7 @@
$Id$
$HeadURL$
%%
- Copyright (C) 2009 - 2011 Ifremer, Code Lutin, Chatellier Eric
+ Copyright (C) 2009 - 2015 Ifremer, Code Lutin, Chatellier Eric
%%
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as
@@ -28,10 +28,6 @@
<fr.ifremer.isisfish.entities.Population id='bean' javaBean='null'/>
<fr.ifremer.isisfish.entities.PopulationSeasonInfo id='popInfo' javaBean='null'/>
- <Boolean id='gPopSelected' javaBean='false'/>
- <Boolean id='zoneDepartSelected' javaBean='false'/>
- <Boolean id='coefNonVide' javaBean='false'/>
-
<import>
java.beans.PropertyChangeEvent
java.beans.PropertyChangeListener
@@ -43,6 +39,7 @@
org.nuiton.math.matrix.gui.MatrixPanelEvent
org.nuiton.math.matrix.gui.MatrixPanelListener
fr.ifremer.isisfish.ui.input.InputAction
+ fr.ifremer.isisfish.ui.models.common.GenericComboModel
</import>
<script><![CDATA[
@@ -50,11 +47,15 @@
addPropertyChangeListener(PROPERTY_BEAN, new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent evt) {
if (evt.getNewValue() == null) {
+ fieldPopulationMigrationImmigrationCoefficient.setText("");
populationMigrationImmigrationTable.setMatrix(null);
}
if (evt.getNewValue() != null) {
- refreshPanel();
+
}
+ setFieldPopulationMigrationMigrationGroupChooserModel();
+ setFieldPopulationMigrationMigrationArrivalZoneChooserModel();
+ setAddButton();
}
});
}
@@ -74,27 +75,20 @@
populationMigrationImmigrationTable.setMatrix(getPopInfo().getImmigrationMatrix().copy());
}
-/*public void refresh(){
- Population population = getVerifier().getEntity(Population.class);
- setBean(population);
-
- refreshPanel();
-}*/
-
-public void refreshPanel(){
- setFieldPopulationMigrationMigrationGroupChooserModel();
- setFieldPopulationMigrationMigrationArrivalZoneChooserModel();
- setAddButton();
-}
protected void setFieldPopulationMigrationMigrationGroupChooserModel(){
+ GenericComboModel<PopulationGroup> groups = new GenericComboModel<>();
if (getBean() != null && getBean().getPopulationGroup() != null){
- jaxx.runtime.SwingUtil.fillComboBox(fieldPopulationMigrationImmigrationGroupChooser, getBean().getPopulationGroup(), null, true);
+ groups.setElementList(getBean().getPopulationGroup());
}
+ fieldPopulationMigrationImmigrationGroupChooser.setModel(groups);
}
protected void setFieldPopulationMigrationMigrationArrivalZoneChooserModel(){
+ GenericComboModel<Zone> zones = new GenericComboModel<>();
if (getBean() != null && getBean().getPopulationZone() != null){
- jaxx.runtime.SwingUtil.fillComboBox(fieldPopulationMigrationImmigrationArrivalZoneChooser, getBean().getPopulationZone(), null, true);
+ //jaxx.runtime.SwingUtil.fillComboBox(fieldPopulationMigrationMigrationArrivalZoneChooser,getBean().getPopulationZone(), null, true);
+ zones.setElementList(getBean().getPopulationZone());
}
+ fieldPopulationMigrationImmigrationArrivalZoneChooser.setModel(zones);
}
protected void add() {
getContextValue(InputAction.class).addImmigration(getPopInfo(),
@@ -115,21 +109,14 @@
populationMigrationImmigrationTable.setMatrix(getPopInfo().getImmigrationMatrix().copy());
}
}
-protected void groupChanged(){
- setGPopSelected(fieldPopulationMigrationImmigrationGroupChooser.getSelectedItem() != null);
- setAddButton();
+
+protected void setAddButton() {
+ add.setEnabled(isActive() &&
+ fieldPopulationMigrationImmigrationGroupChooser.getSelectedItem() != null &&
+ !fieldPopulationMigrationImmigrationCoefficient.getText().equals("") &&
+ fieldPopulationMigrationImmigrationArrivalZoneChooser.getSelectedItem() != null
+ );
}
-protected void coefChanged(){
- setCoefNonVide(!fieldPopulationMigrationImmigrationCoefficient.getText().equals(""));
- setAddButton();
-}
-protected void zoneChanged(){
- setZoneDepartSelected(fieldPopulationMigrationImmigrationArrivalZoneChooser.getSelectedItem() != null);
- setAddButton();
-}
-protected void setAddButton(){
- add.setEnabled(getGPopSelected() && getZoneDepartSelected() && getCoefNonVide());
-}
]]>
</script>
<JPanel id="body">
@@ -139,13 +126,15 @@
<JLabel text="isisfish.common.populationGroup" enabled='{isActive()}'/>
</cell>
<cell fill='horizontal' weightx='0.5'>
- <JAXXComboBox id="fieldPopulationMigrationImmigrationGroupChooser" enabled='{isActive()}' onActionPerformed='groupChanged()'/>
+ <JComboBox id="fieldPopulationMigrationImmigrationGroupChooser"
+ genericType="fr.ifremer.isisfish.entities.PopulationGroup"
+ enabled='{isActive()}' onActionPerformed='setAddButton()'/>
</cell>
<cell>
<JLabel text="isisfish.populationMigrationImmigration.coefficient" enabled='{isActive()}'/>
</cell>
<cell fill='horizontal' weightx='0.5'>
- <JTextField id="fieldPopulationMigrationImmigrationCoefficient" enabled='{isActive()}' onKeyReleased='coefChanged()'/>
+ <JTextField id="fieldPopulationMigrationImmigrationCoefficient" enabled='{isActive()}' onKeyReleased='setAddButton()'/>
</cell>
</row>
<row>
@@ -153,7 +142,9 @@
<JLabel text="isisfish.populationMigrationImmigration.arrivalZone" enabled='{isActive()}'/>
</cell>
<cell fill='horizontal' weightx='0.5'>
- <JAXXComboBox id="fieldPopulationMigrationImmigrationArrivalZoneChooser" enabled='{isActive()}' onActionPerformed='zoneChanged()'/>
+ <JComboBox id="fieldPopulationMigrationImmigrationArrivalZoneChooser"
+ genericType="fr.ifremer.isisfish.entities.Zone"
+ enabled='{isActive()}' onActionPerformed='setAddButton()'/>
</cell>
<cell columns='2' fill='horizontal' weightx='0.5'>
<JPanel/>
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationMigrationUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationMigrationUI.jaxx 2015-05-07 13:57:54 UTC (rev 4224)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationMigrationUI.jaxx 2015-05-07 16:16:34 UTC (rev 4225)
@@ -5,7 +5,7 @@
$Id$
$HeadURL$
%%
- Copyright (C) 2009 - 2011 Ifremer, Code Lutin, Chatellier Eric
+ Copyright (C) 2009 - 2015 Ifremer, Code Lutin, Chatellier Eric
%%
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as
@@ -34,17 +34,18 @@
<Boolean id='coefNonVide' javaBean='false'/>
<import>
- fr.ifremer.isisfish.entities.PopulationSeasonInfo;
- fr.ifremer.isisfish.entities.Population;
- fr.ifremer.isisfish.entities.PopulationGroup;
- fr.ifremer.isisfish.entities.PopulationSeasonInfo;
- fr.ifremer.isisfish.entities.Zone;
- org.nuiton.math.matrix.MatrixND;
- org.nuiton.math.matrix.gui.MatrixPanelEvent;
- java.beans.PropertyChangeEvent;
- java.beans.PropertyChangeListener;
- org.nuiton.math.matrix.gui.MatrixPanelListener;
+ fr.ifremer.isisfish.entities.PopulationSeasonInfo
+ fr.ifremer.isisfish.entities.Population
+ fr.ifremer.isisfish.entities.PopulationGroup
+ fr.ifremer.isisfish.entities.PopulationSeasonInfo
+ fr.ifremer.isisfish.entities.Zone
+ org.nuiton.math.matrix.MatrixND
+ org.nuiton.math.matrix.gui.MatrixPanelEvent
+ java.beans.PropertyChangeEvent
+ java.beans.PropertyChangeListener
+ org.nuiton.math.matrix.gui.MatrixPanelListener
javax.swing.text.Document
+ fr.ifremer.isisfish.ui.models.common.GenericComboModel
</import>
<script><![CDATA[
@@ -52,11 +53,16 @@
addPropertyChangeListener(PROPERTY_BEAN, new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent evt) {
if (evt.getNewValue() == null) {
+ fieldPopulationMigrationMigrationCoefficient.setText("");
populationMigrationMigrationTable.setMatrix(null);
}
if (evt.getNewValue() != null) {
- refreshPanel();
+
}
+ setFieldPopulationMigrationMigrationGroupChooserModel();
+ setFieldPopulationMigrationMigrationDepartureZoneChooserModel();
+ setFieldPopulationMigrationMigrationArrivalZoneChooserModel();
+ setAddButton();
}
});
}
@@ -75,37 +81,30 @@
populationMigrationMigrationTable.setMatrix(getPopInfo().getMigrationMatrix().copy());
}
-/*public void refresh() {
- Population population = getSaveVerifier().getEntity(Population.class);
- // setBean(null); is useless here
- setBean(population);
-
- refreshPanel();
-}*/
-
-public void refreshPanel(){
- setFieldPopulationMigrationMigrationGroupChooserModel();
- setFieldPopulationMigrationMigrationDepartureZoneChooserModel();
- setFieldPopulationMigrationMigrationArrivalZoneChooserModel();
-
- //setAddButton();
-}
-protected void setFieldPopulationMigrationMigrationGroupChooserModel(){
+protected void setFieldPopulationMigrationMigrationGroupChooserModel() {
+ GenericComboModel<PopulationGroup> groups = new GenericComboModel<>();
if (getBean() != null && getBean().getPopulationGroup() != null){
- jaxx.runtime.SwingUtil.fillComboBox(fieldPopulationMigrationMigrationGroupChooser,getBean().getPopulationGroup(), null, true);
+ groups.setElementList(getBean().getPopulationGroup());
}
+ fieldPopulationMigrationMigrationGroupChooser.setModel(groups);
}
protected void setFieldPopulationMigrationMigrationDepartureZoneChooserModel(){
+ GenericComboModel<Zone> zones = new GenericComboModel<>();
if (getBean() != null && getBean().getPopulationZone() != null){
- jaxx.runtime.SwingUtil.fillComboBox(fieldPopulationMigrationMigrationDepartureZoneChooser,getBean().getPopulationZone(), null, true);
+ //jaxx.runtime.SwingUtil.fillComboBox(fieldPopulationMigrationMigrationDepartureZoneChooser,getBean().getPopulationZone(), null, true);
+ zones.setElementList(getBean().getPopulationZone());
}
+ fieldPopulationMigrationMigrationDepartureZoneChooser.setModel(zones);
}
protected void setFieldPopulationMigrationMigrationArrivalZoneChooserModel(){
+ GenericComboModel<Zone> zones = new GenericComboModel<>();
if (getBean() != null && getBean().getPopulationZone() != null){
- jaxx.runtime.SwingUtil.fillComboBox(fieldPopulationMigrationMigrationArrivalZoneChooser,getBean().getPopulationZone(), null, true);
+ //jaxx.runtime.SwingUtil.fillComboBox(fieldPopulationMigrationMigrationArrivalZoneChooser,getBean().getPopulationZone(), null, true);
+ zones.setElementList(getBean().getPopulationZone());
}
+ fieldPopulationMigrationMigrationArrivalZoneChooser.setModel(zones);
}
-protected void add(){
+protected void add() {
getAction().addMigration(getPopInfo(),
(PopulationGroup) fieldPopulationMigrationMigrationGroupChooser.getSelectedItem(),
(Zone) fieldPopulationMigrationMigrationDepartureZoneChooser.getSelectedItem(),
@@ -126,22 +125,6 @@
populationMigrationMigrationTable.setMatrix(getPopInfo().getMigrationMatrix().copy());
}
}
-/*protected void groupChanged(){
- setGPopSelected(fieldPopulationMigrationMigrationGroupChooser.getSelectedItem() != null);
- setAddButton();
-}
-protected void coefChanged(){
- setCoefNonVide(!fieldPopulationMigrationMigrationCoefficient.getText().equals(""));
- setAddButton();
-}
-protected void zoneDepartueChanged(){
- setZoneDepartSelected(fieldPopulationMigrationMigrationDepartureZoneChooser.getSelectedItem() != null);
- setAddButton();
-}
-protected void zoneArrivalChanged(){
- setZoneArrivalSelected(fieldPopulationMigrationMigrationArrivalZoneChooser.getSelectedItem() != null);
- setAddButton();
-}*/
protected void setAddButton() {
add.setEnabled(isActive() &&
fieldPopulationMigrationMigrationGroupChooser.getSelectedItem() != null &&
@@ -158,7 +141,7 @@
<JLabel text="isisfish.common.populationGroup" enabled='{isActive()}'/>
</cell>
<cell fill='horizontal' weightx='0.5'>
- <JAXXComboBox id="fieldPopulationMigrationMigrationGroupChooser" enabled='{isActive()}'
+ <JComboBox id="fieldPopulationMigrationMigrationGroupChooser" enabled='{isActive()}'
onItemStateChanged="setAddButton()"/>
</cell>
<cell>
@@ -176,14 +159,16 @@
<JLabel text="isisfish.populationMigrationMigration.departureZone" enabled='{isActive()}'/>
</cell>
<cell fill='horizontal' weightx='0.5'>
- <JAXXComboBox id="fieldPopulationMigrationMigrationDepartureZoneChooser" enabled='{isActive()}'
+ <JComboBox id="fieldPopulationMigrationMigrationDepartureZoneChooser" enabled='{isActive()}'
+ genericType="fr.ifremer.isisfish.entities.Zone"
onItemStateChanged="setAddButton()"/>
</cell>
<cell>
<JLabel text="isisfish.populationMigrationMigration.arrivalZone" enabled='{isActive()}'/>
</cell>
<cell fill='horizontal' weightx='0.5'>
- <JAXXComboBox id="fieldPopulationMigrationMigrationArrivalZoneChooser" enabled='{isActive()}'
+ <JComboBox id="fieldPopulationMigrationMigrationArrivalZoneChooser" enabled='{isActive()}'
+ genericType="fr.ifremer.isisfish.entities.Zone"
onItemStateChanged="setAddButton()"/>
</cell>
</row>
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationUI.jaxx 2015-05-07 13:57:54 UTC (rev 4224)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationUI.jaxx 2015-05-07 16:16:34 UTC (rev 4225)
@@ -62,8 +62,9 @@
fieldUseEquationMigration.setSelected(false);
}
if (evt.getNewValue() != null) {
- refresh();
+
}
+ refresh();
}
});
}
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/port/PortUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/port/PortUI.jaxx 2015-05-07 13:57:54 UTC (rev 4224)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/port/PortUI.jaxx 2015-05-07 16:16:34 UTC (rev 4225)
@@ -5,7 +5,7 @@
$Id$
$HeadURL$
%%
- Copyright (C) 2009 - 2011 Ifremer, Code Lutin, Chatellier Eric
+ Copyright (C) 2009 - 2015 Ifremer, Code Lutin, Chatellier Eric
%%
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as
@@ -39,6 +39,7 @@
java.beans.PropertyChangeEvent
java.beans.PropertyChangeListener
java.awt.event.MouseEvent
+ fr.ifremer.isisfish.ui.models.common.GenericListModel
</import>
<BeanValidator id='validator'
@@ -49,7 +50,7 @@
</BeanValidator>
<script><![CDATA[
-boolean portChanged = true;
+boolean init = false;
protected void $afterCompleteSetup() {
@@ -61,12 +62,12 @@
for (Cell c : portMap.getSelectedCells()) {
if (getBean().getCell() != null) {
if (!getBean().getCell().getTopiaId().equals(c.getTopiaId())){
- portCell.setSelectedValue(c);
+ portCell.setSelectedValue(c, true);
return true;
}
}
else {
- portCell.setSelectedValue(c);
+ portCell.setSelectedValue(c, true);
return true;
}
}
@@ -85,8 +86,9 @@
fieldPortComment.setText("");
}
if (evt.getNewValue() != null) {
- fillCellList();
+
}
+ fillCellList();
}
});
}
@@ -103,17 +105,21 @@
}*/
protected void fillCellList() {
+ GenericListModel<Cell> cellModel = new GenericListModel<>();
if (getBean() != null) {
- portChanged = false;
- portCell.fillList(getFisheryRegion().getCell(), getBean().getCell());
- portCell.setSelectedValue(getBean().getCell());
- portChanged = true;
+ init = true;
+ cellModel.setElementList(getFisheryRegion().getCell());
+ portCell.setModel(cellModel);
+ portCell.setSelectedValue(getBean().getCell(), true);
+ init = false;
+ } else {
+ portCell.setModel(cellModel);
}
}
protected void portChanged() {
- if (portChanged) {
- getBean().setCell((Cell)portCell.getSelectedValue());
+ if (getBean() != null && !init) {
+ getBean().setCell(portCell.getSelectedValue());
}
}
]]></script>
@@ -139,7 +145,8 @@
<row>
<cell columns='2' fill='both' weighty='0.7' weightx='1.0'>
<JScrollPane id="spPortCell">
- <JAXXList id="portCell" selectedValue='{getBean().getCell()}' selectionMode="0"
+ <JList id="portCell"
+ genericType="fr.ifremer.isisfish.entities.Cell" selectionMode="{javax.swing.ListSelectionModel.SINGLE_SELECTION}"
onValueChanged='portChanged()' enabled='{isActive()}' decorator='boxed' />
</JScrollPane>
</cell>
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/setofvessels/SetOfVesselsBasicsUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/setofvessels/SetOfVesselsBasicsUI.jaxx 2015-05-07 13:57:54 UTC (rev 4224)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/setofvessels/SetOfVesselsBasicsUI.jaxx 2015-05-07 16:16:34 UTC (rev 4225)
@@ -5,7 +5,7 @@
$Id$
$HeadURL$
%%
- Copyright (C) 2009 - 2011 Ifremer, Code Lutin, Chatellier Eric
+ Copyright (C) 2009 - 2015 Ifremer, Code Lutin, Chatellier Eric
%%
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/zone/ZoneBasicsUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/zone/ZoneBasicsUI.jaxx 2015-05-07 13:57:54 UTC (rev 4224)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/zone/ZoneBasicsUI.jaxx 2015-05-07 16:16:34 UTC (rev 4225)
@@ -73,23 +73,27 @@
zoneMap.setSelectedCells();
}
if (evt.getNewValue() != null) {
- setZoneCells();
+
}
+ setZoneCells();
}
});
}
protected void setZoneCells() {
+ GenericListModel<Cell> zoneModel = new GenericListModel<Cell>();
if (getBean() != null) {
List<Cell> cells = getFisheryRegion().getCell();
- GenericListModel<Cell> model = new GenericListModel<Cell>(cells);
- zoneCells.setModel(model);
+ zoneModel.setElementList(cells);
+ zoneCells.setModel(zoneModel);
if (getBean().getCell() != null) {
for (Cell selectedCell : getBean().getCell()) {
int index = cells.indexOf(selectedCell);
zoneCells.addSelectionInterval(index, index);
}
}
+ } else {
+ zoneCells.setModel(zoneModel);
}
}
1
0
r4224 - trunk/src/main/java/fr/ifremer/isisfish/vcs
by echatellier@users.forge.codelutin.com 07 May '15
by echatellier@users.forge.codelutin.com 07 May '15
07 May '15
Author: echatellier
Date: 2015-05-07 13:57:54 +0000 (Thu, 07 May 2015)
New Revision: 4224
Url: http://forge.codelutin.com/projects/isis-fish/repository/revisions/4224
Log:
Fix cast
Modified:
trunk/src/main/java/fr/ifremer/isisfish/vcs/VCSFactory.java
Modified: trunk/src/main/java/fr/ifremer/isisfish/vcs/VCSFactory.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/vcs/VCSFactory.java 2015-05-07 13:50:30 UTC (rev 4223)
+++ trunk/src/main/java/fr/ifremer/isisfish/vcs/VCSFactory.java 2015-05-07 13:57:54 UTC (rev 4224)
@@ -125,7 +125,7 @@
String host, String path, File sshKeyFile, String login, String password) {
VCS result = null;
try {
- Class<VCS> clazz = (Class<VCS>) ConvertUtils.convert(classname, VCS.class);
+ Class<VCS> clazz = (Class<VCS>) ConvertUtils.convert(classname, Class.class);
result = (VCS) ConstructorUtils.invokeConstructor(clazz,
new Object[]{dataDir, protocol, host, path, sshKeyFile, login, password});
} catch (Exception eee) {
1
0
r4223 - in trunk/src/main/java/fr/ifremer/isisfish: simulator/launcher ui/script
by echatellier@users.forge.codelutin.com 07 May '15
by echatellier@users.forge.codelutin.com 07 May '15
07 May '15
Author: echatellier
Date: 2015-05-07 13:50:30 +0000 (Thu, 07 May 2015)
New Revision: 4223
Url: http://forge.codelutin.com/projects/isis-fish/repository/revisions/4223
Log:
Fix deprecated freemarker constructor
Modified:
trunk/src/main/java/fr/ifremer/isisfish/simulator/launcher/SSHSimulatorLauncher.java
trunk/src/main/java/fr/ifremer/isisfish/ui/script/ScriptAction.java
Modified: trunk/src/main/java/fr/ifremer/isisfish/simulator/launcher/SSHSimulatorLauncher.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/simulator/launcher/SSHSimulatorLauncher.java 2015-05-07 13:27:52 UTC (rev 4222)
+++ trunk/src/main/java/fr/ifremer/isisfish/simulator/launcher/SSHSimulatorLauncher.java 2015-05-07 13:50:30 UTC (rev 4223)
@@ -141,7 +141,7 @@
*/
protected void initFreemarker() {
- freemarkerConfiguration = new Configuration();
+ freemarkerConfiguration = new Configuration(Configuration.VERSION_2_3_0);
// needed to overwrite "Defaults to default system encoding."
// fix encoding issue on some systems
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/script/ScriptAction.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/script/ScriptAction.java 2015-05-07 13:27:52 UTC (rev 4222)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/script/ScriptAction.java 2015-05-07 13:50:30 UTC (rev 4223)
@@ -67,7 +67,6 @@
import org.apache.commons.logging.LogFactory;
import org.nuiton.util.FileUtil;
import org.nuiton.util.ZipUtil;
-import org.nuiton.widget.SwingUtil;
import fr.ifremer.isisfish.IsisFish;
import fr.ifremer.isisfish.IsisFishRuntimeException;
@@ -138,7 +137,7 @@
this.scriptUI = scriptUI;
- freemarkerConfiguration = new Configuration();
+ freemarkerConfiguration = new Configuration(Configuration.VERSION_2_3_0);
// needed to overwrite "Defaults to default system encoding."
// fix encoding issue on some systems
freemarkerConfiguration.setDefaultEncoding("utf-8");
1
0
r4222 - in trunk/src/main/java/fr/ifremer/isisfish/ui: input input/cell input/fisheryregion input/gear input/metier input/population input/setofvessels input/strategy input/variable input/vesseltype input/zone models/sensitivityanalysis models/sensitivityexport models/simulationplan result script sensitivity sensitivity/wizard simulator
by echatellier@users.forge.codelutin.com 07 May '15
by echatellier@users.forge.codelutin.com 07 May '15
07 May '15
Author: echatellier
Date: 2015-05-07 13:27:52 +0000 (Thu, 07 May 2015)
New Revision: 4222
Url: http://forge.codelutin.com/projects/isis-fish/repository/revisions/4222
Log:
generics, generics everywhere...
Removed:
trunk/src/main/java/fr/ifremer/isisfish/ui/input/variable/VariableTypeComboModel.java
trunk/src/main/java/fr/ifremer/isisfish/ui/models/sensitivityanalysis/SensitivityAnalysisComboModel.java
trunk/src/main/java/fr/ifremer/isisfish/ui/models/sensitivityanalysis/SensitivityAnalysisListModel.java
trunk/src/main/java/fr/ifremer/isisfish/ui/models/sensitivityexport/SensitivityExportListModel.java
trunk/src/main/java/fr/ifremer/isisfish/ui/models/simulationplan/SimulationPlanComboModel.java
trunk/src/main/java/fr/ifremer/isisfish/ui/models/simulationplan/SimulationPlanListModel.java
Modified:
trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputAction.java
trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputHandler.java
trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputOneEquationUI.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/input/cell/CellUI.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/input/fisheryregion/FisheryRegionHandler.java
trunk/src/main/java/fr/ifremer/isisfish/ui/input/fisheryregion/FisheryRegionUI.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/input/gear/SelectivityUI.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/input/metier/MetierSeasonInfoSpeciesUI.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/input/metier/MetierSeasonInfoZoneUI.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/input/metier/MetierTabUI.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationZonesEditorUI.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/input/setofvessels/EffortDescriptionUI.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/input/strategy/StrategyOneMonthInfoUI.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/input/strategy/StrategyTabUI.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/input/variable/EntityVariableHandler.java
trunk/src/main/java/fr/ifremer/isisfish/ui/input/variable/EntityVariableUI.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/input/vesseltype/VesselTypeUI.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/input/zone/ZoneBasicsUI.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/result/ResultHandler.java
trunk/src/main/java/fr/ifremer/isisfish/ui/result/ResultSimulationFrame.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/script/ScriptTypesComboModel.java
trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/SensitivityChooserUI.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/SensitivitySecondPassUI.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/wizard/SensitivityWizardHandler.java
trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/AdvancedParamsUI.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/ExportUI.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/OptimizationUI.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/ParamsUI.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/ResultChoiceUI.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/SensUI.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/SimulAction.java
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputAction.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputAction.java 2015-05-07 09:51:50 UTC (rev 4221)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputAction.java 2015-05-07 13:27:52 UTC (rev 4222)
@@ -849,7 +849,7 @@
* @param fisheryRegion fishery region
* @param selectedMaps la liste de map a retirer
*/
- public void removeMap(FisheryRegion fisheryRegion, Object[] selectedMaps) {
+ public void removeMap(FisheryRegion fisheryRegion, List<String> selectedMaps) {
if (log.isTraceEnabled()) {
log.trace("removeMap called");
}
@@ -860,8 +860,7 @@
RegionStorage regionStorage = RegionStorage.getRegion(fisheryRegion.getName());
File mapDir = regionStorage.getMapRepository();
- for (Object selectedMap : selectedMaps) {
- String mapName = (String)selectedMap;
+ for (String mapName : selectedMaps) {
maps.remove(mapName);
// remove on disk too, if possible
File mapFile = new File(mapDir, mapName);
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputHandler.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputHandler.java 2015-05-07 09:51:50 UTC (rev 4221)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputHandler.java 2015-05-07 13:27:52 UTC (rev 4222)
@@ -270,7 +270,7 @@
*/
protected void refreshRegionList(InputUI inputUI, String selectedItem) {
// refresh region list
- GenericComboModel regionsModel = new GenericComboModel(RegionStorage.getRegionNames());
+ GenericComboModel<String> regionsModel = new GenericComboModel<>(RegionStorage.getRegionNames());
inputUI.getFieldCurrentRegion().setModel(regionsModel);
// event is fired by setSelectedItem to call #regionChange
if (selectedItem != null) {
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputOneEquationUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputOneEquationUI.jaxx 2015-05-07 09:51:50 UTC (rev 4221)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputOneEquationUI.jaxx 2015-05-07 13:27:52 UTC (rev 4222)
@@ -249,6 +249,7 @@
</cell>
<cell fill='horizontal' weightx='1.0'>
<JComboBox id="formuleComboBox" onActionPerformed='formuleChanged()' enabled='{isActive()}'
+ genericType="fr.ifremer.isisfish.entities.Formule"
renderer="{new fr.ifremer.isisfish.ui.input.renderer.FormuleComboRenderer()}" />
</cell>
</row>
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/cell/CellUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/cell/CellUI.jaxx 2015-05-07 09:51:50 UTC (rev 4221)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/cell/CellUI.jaxx 2015-05-07 13:27:52 UTC (rev 4222)
@@ -47,6 +47,7 @@
<row>
<cell fill='horizontal' columns='2' weightx='1.0'>
<JComboBox id="fieldCell" onItemStateChanged='handler.fieldCellChanged(event)'
+ genericType="fr.ifremer.isisfish.entities.Cell"
model='{new javax.swing.DefaultComboBoxModel()}' enabled='{getBean() != null}'/>
</cell>
</row>
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/fisheryregion/FisheryRegionHandler.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/fisheryregion/FisheryRegionHandler.java 2015-05-07 09:51:50 UTC (rev 4221)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/fisheryregion/FisheryRegionHandler.java 2015-05-07 13:27:52 UTC (rev 4222)
@@ -28,6 +28,7 @@
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
+import java.util.List;
import javax.swing.DefaultListModel;
@@ -88,8 +89,8 @@
}
protected void setFieldMapfilesModel(FisheryRegion region) {
- DefaultListModel model = new DefaultListModel();
- java.util.List<String> mapList = region.getMapFileList();
+ DefaultListModel<String> model = new DefaultListModel<>();
+ List<String> mapList = region.getMapFileList();
if (mapList != null) {
int cnt = 0;
for (String map : mapList) {
@@ -106,7 +107,7 @@
}
protected void delMap() {
- getInputAction().removeMap(inputContentUI.getBean(), inputContentUI.fieldMapfiles.getSelectedValues());
+ getInputAction().removeMap(inputContentUI.getBean(), inputContentUI.fieldMapfiles.getSelectedValuesList());
setFieldMapfilesModel(inputContentUI.getBean());
}
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/fisheryregion/FisheryRegionUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/fisheryregion/FisheryRegionUI.jaxx 2015-05-07 09:51:50 UTC (rev 4221)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/fisheryregion/FisheryRegionUI.jaxx 2015-05-07 13:27:52 UTC (rev 4222)
@@ -70,7 +70,7 @@
bean='{getBean()}' property='minLatitude'
decorator='boxed' useSign='true'/-->
<JTextField id="fieldLatMin" text='{String.valueOf(getBean().getMinLatitude())}' decorator='boxed'
- onKeyReleased='getBean().setMinLatitude(Float.parseFloat(fieldLatMin.getText()))'/>
+ onKeyReleased='getBean().setMinLatitude(Float.parseFloat(fieldLatMin.getText()))'/>
</cell>
</row>
<row>
@@ -82,7 +82,7 @@
bean='{getBean()}' property='maxLatitude'
decorator='boxed' useSign='true'/-->
<JTextField id="fieldLatMax" text='{String.valueOf(getBean().getMaxLatitude())}' decorator='boxed'
- onKeyReleased='getBean().setMaxLatitude(Float.parseFloat(fieldLatMax.getText()))'/>
+ onKeyReleased='getBean().setMaxLatitude(Float.parseFloat(fieldLatMax.getText()))'/>
</cell>
</row>
<row>
@@ -94,7 +94,7 @@
bean='{getBean()}' property='minLongitude'
decorator='boxed' useSign='true'/-->
<JTextField id="fieldLongMin" text='{String.valueOf(getBean().getMinLongitude())}' decorator='boxed'
- onKeyReleased='getBean().setMinLongitude(Float.parseFloat(fieldLongMin.getText()))'/>
+ onKeyReleased='getBean().setMinLongitude(Float.parseFloat(fieldLongMin.getText()))'/>
</cell>
</row>
<row>
@@ -106,7 +106,7 @@
bean='{getBean()}' property='maxLongitude'
decorator='boxed' useSign='true'/-->
<JTextField id="fieldLongMax" text='{String.valueOf(getBean().getMaxLongitude())}' decorator='boxed'
- onKeyReleased='getBean().setMaxLongitude(Float.parseFloat(fieldLongMax.getText()))'/>
+ onKeyReleased='getBean().setMaxLongitude(Float.parseFloat(fieldLongMax.getText()))'/>
</cell>
</row>
<row>
@@ -123,7 +123,7 @@
bean='{getBean()}' property='cellLengthLatitude'
decorator='boxed' useSign='true'/-->
<JTextField id="fieldCellLengthLatitude" text='{String.valueOf(getBean().getCellLengthLatitude())}' decorator='boxed'
- onKeyReleased='getBean().setCellLengthLatitude(Float.parseFloat(fieldCellLengthLatitude.getText()))'/>
+ onKeyReleased='getBean().setCellLengthLatitude(Float.parseFloat(fieldCellLengthLatitude.getText()))'/>
</cell>
</row>
<row>
@@ -135,13 +135,14 @@
bean='{getBean()}' property='cellLengthLongitude'
decorator='boxed' useSign='true'/-->
<JTextField id="fieldCellLengthLongitude" text='{String.valueOf(getBean().getCellLengthLongitude())}' decorator='boxed'
- onKeyReleased='getBean().setCellLengthLongitude(Float.parseFloat(fieldCellLengthLongitude.getText()))'/>
+ onKeyReleased='getBean().setCellLengthLongitude(Float.parseFloat(fieldCellLengthLongitude.getText()))'/>
</cell>
</row>
<row>
<cell columns='3' fill='both' weightx='1.0' weighty='0.6'>
<JScrollPane>
- <JList id="fieldMapfiles" decorator='boxed'/>
+ <JList id="fieldMapfiles" genericType="String"
+ decorator='boxed'/>
</JScrollPane>
</cell>
</row>
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/gear/SelectivityUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/gear/SelectivityUI.jaxx 2015-05-07 09:51:50 UTC (rev 4221)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/gear/SelectivityUI.jaxx 2015-05-07 13:27:52 UTC (rev 4222)
@@ -5,7 +5,7 @@
$Id$
$HeadURL$
%%
- Copyright (C) 2009 - 2011 Ifremer, Code Lutin, Chatellier Eric
+ Copyright (C) 2009 - 2015 Ifremer, Code Lutin, Chatellier Eric
%%
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as
@@ -158,6 +158,7 @@
</cell>
<cell fill='horizontal' weightx='1.0'>
<JComboBox id="fieldSelectivityPopulation" onItemStateChanged='selectivityChanged()'
+ genericType="fr.ifremer.isisfish.entities.Population"
enabled='{isActive()}' decorator='boxed' />
</cell>
</row>
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/metier/MetierSeasonInfoSpeciesUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/metier/MetierSeasonInfoSpeciesUI.jaxx 2015-05-07 09:51:50 UTC (rev 4221)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/metier/MetierSeasonInfoSpeciesUI.jaxx 2015-05-07 13:27:52 UTC (rev 4222)
@@ -5,7 +5,7 @@
$Id$
$HeadURL$
%%
- Copyright (C) 2009 - 2011 Ifremer, Code Lutin, Chatellier Eric
+ Copyright (C) 2009 - 2015 Ifremer, Code Lutin, Chatellier Eric
%%
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as
@@ -81,7 +81,7 @@
if (getBean() != null) {
metierSeasonInfo = getBean().getMetierSeasonInfo();
}
- GenericComboModel<MetierSeasonInfo> seasonModel = new GenericComboModel(metierSeasonInfo);
+ GenericComboModel<MetierSeasonInfo> seasonModel = new GenericComboModel<>(metierSeasonInfo);
fieldMetierSeasonInfo.setModel(seasonModel);
}
@@ -171,6 +171,7 @@
</cell>
<cell fill='horizontal' weightx='1.0'>
<JComboBox id="fieldMetierSeasonInfo" onItemStateChanged='metierSeasonInfoChanged()'
+ genericType="fr.ifremer.isisfish.entities.MetierSeasonInfo"
renderer="{new fr.ifremer.isisfish.ui.input.renderer.MetierSeasonInfoComboRenderer()}"
enabled='{isActive() && (isSensitivity() || !changeModel.isChanged() ) }'/>
</cell>
@@ -182,6 +183,7 @@
</cell>
<cell fill='horizontal' weightx='1.0'>
<JComboBox id="fieldTargetSpecies" onItemStateChanged='speciesChanged()'
+ genericType="fr.ifremer.isisfish.entities.Species"
enabled='{getMetierSeasonInfo() != null}' decorator='boxed'/>
</cell>
</row>
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/metier/MetierSeasonInfoZoneUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/metier/MetierSeasonInfoZoneUI.jaxx 2015-05-07 09:51:50 UTC (rev 4221)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/metier/MetierSeasonInfoZoneUI.jaxx 2015-05-07 13:27:52 UTC (rev 4222)
@@ -5,7 +5,7 @@
$Id$
$HeadURL$
%%
- Copyright (C) 2009 - 2011 Ifremer, Code Lutin, Chatellier Eric
+ Copyright (C) 2009 - 2015 Ifremer, Code Lutin, Chatellier Eric
%%
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as
@@ -213,10 +213,10 @@
}
protected void metierZonesChanged() {
- Object[] selected = metierZones.getSelectedValues();
+ List<Zone> selected = metierZones.getSelectedValuesList();
List<Zone> zones = new ArrayList<Zone>();
- for (Object o : selected){
- zones.add((Zone)o);
+ for (Zone o : selected) {
+ zones.add(o);
}
getMetierSeasonInfo().setZone(zones);
}
@@ -239,7 +239,9 @@
<JLabel text="isisfish.metierSeasonInfoZone.selectSeason" enabled='{isActive()}'/>
</cell>
<cell fill='horizontal' weightx='1.0'>
- <JComboBox id="metierSeasonInfoCombo" onItemStateChanged='seasonChanged()' enabled='{isActive() && (isSensitivity() || !changeModel.isChanged() ) }'
+ <JComboBox id="metierSeasonInfoCombo" onItemStateChanged='seasonChanged()'
+ genericType="fr.ifremer.isisfish.entities.MetierSeasonInfo"
+ enabled='{isActive() && (isSensitivity() || !changeModel.isChanged() ) }'
renderer="{new fr.ifremer.isisfish.ui.input.renderer.MetierSeasonInfoComboRenderer()}" />
</cell>
</row>
@@ -258,6 +260,7 @@
<cell fill='both' weightx='1.0' weighty='0.7'>
<JScrollPane minimumSize='{new Dimension(0,0)}' preferredSize='{new Dimension(0,0)}'>
<JList id="metierZones" onValueChanged='metierZonesChanged()'
+ genericType="fr.ifremer.isisfish.entities.Zone"
enabled='{getMetierSeasonInfo() != null}' decorator='boxed'/>
</JScrollPane>
</cell>
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/metier/MetierTabUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/metier/MetierTabUI.jaxx 2015-05-07 09:51:50 UTC (rev 4221)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/metier/MetierTabUI.jaxx 2015-05-07 13:27:52 UTC (rev 4222)
@@ -103,7 +103,8 @@
</cell>
<cell fill='horizontal' weightx='1.0'>
<JComboBox id="fieldMetierGear" onItemStateChanged='gearChanged()'
- enabled='{isActive()}' decorator='boxed'/>
+ genericType="fr.ifremer.isisfish.entities.Gear"
+ enabled='{isActive()}' decorator='boxed'/>
</cell>
</row>
<row>
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationZonesEditorUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationZonesEditorUI.jaxx 2015-05-07 09:51:50 UTC (rev 4221)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationZonesEditorUI.jaxx 2015-05-07 13:27:52 UTC (rev 4222)
@@ -5,7 +5,7 @@
$Id$
$HeadURL$
%%
- Copyright (C) 2009 - 2011 Ifremer, Code Lutin, Chatellier Eric
+ Copyright (C) 2009 - 2015 Ifremer, Code Lutin, Chatellier Eric
%%
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as
@@ -104,7 +104,7 @@
* Change model of {@code associatedList} with all available zones, but keep
* selection with {@code selectedZones}.
*/
-protected void setModel(List<Zone> availableZones, List<Zone> selectedZones, JList associatedList) {
+protected void setModel(List<Zone> availableZones, List<Zone> selectedZones, JList<Zone> associatedList) {
GenericListModel<Zone> zoneModel = new GenericListModel<>(availableZones);
associatedList.setModel(zoneModel);
@@ -143,12 +143,9 @@
/**
* Get selected values for components as list.
*/
-protected List<Zone> getSelectedValues(JList component) {
- Object[] selectedValues = component.getSelectedValues();
- List<Zone> selectedZone = new ArrayList<Zone>();
- for (Object value : selectedValues) {
- selectedZone.add((Zone)value);
- }
+protected List<Zone> getSelectedValues(JList<Zone> component) {
+ List<Zone> selectedValues = component.getSelectedValuesList();
+ List<Zone> selectedZone = new ArrayList<Zone>(selectedValues);
return selectedZone;
}
]]>
@@ -169,17 +166,20 @@
<row>
<cell fill='both' weightx='0.3' weighty='0.5'>
<JScrollPane minimumSize='{new Dimension(0,0)}' preferredSize='{new Dimension(0,0)}'>
- <JList id="populationZonesPresence" onValueChanged='presenceChanged()' enabled='{isActive()}'/>
+ <JList id="populationZonesPresence" genericType="fr.ifremer.isisfish.entities.Zone"
+ onValueChanged='presenceChanged()' enabled='{isActive()}'/>
</JScrollPane>
</cell>
<cell fill='both' weightx='0.3' weighty='0.5'>
<JScrollPane minimumSize='{new Dimension(0,0)}' preferredSize='{new Dimension(0,0)}'>
- <JList id="fieldPopulationZonesReproduction" onValueChanged='reproductionChanged()' enabled='{isActive()}'/>
+ <JList id="fieldPopulationZonesReproduction" genericType="fr.ifremer.isisfish.entities.Zone"
+ onValueChanged='reproductionChanged()' enabled='{isActive()}'/>
</JScrollPane>
</cell>
<cell fill='both' weightx='0.3' weighty='0.5'>
<JScrollPane minimumSize='{new Dimension(0,0)}' preferredSize='{new Dimension(0,0)}'>
- <JList id="fieldPopulationZonesRecruitment" onValueChanged='recruitementChanged()' enabled='{isActive()}'/>
+ <JList id="fieldPopulationZonesRecruitment" genericType="fr.ifremer.isisfish.entities.Zone"
+ onValueChanged='recruitementChanged()' enabled='{isActive()}'/>
</JScrollPane>
</cell>
</row>
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/setofvessels/EffortDescriptionUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/setofvessels/EffortDescriptionUI.jaxx 2015-05-07 09:51:50 UTC (rev 4221)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/setofvessels/EffortDescriptionUI.jaxx 2015-05-07 13:27:52 UTC (rev 4222)
@@ -5,7 +5,7 @@
$Id$
$HeadURL$
%%
- Copyright (C) 2009 - 2011 Ifremer, Code Lutin, Chatellier Eric
+ Copyright (C) 2009 - 2015 Ifremer, Code Lutin, Chatellier Eric
%%
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as
@@ -95,24 +95,22 @@
protected void setEffortDescriptionEffortDescriptionList() {
GenericListModel<EffortDescription> model = new GenericListModel<>();
if (getBean() != null && getBean().getPossibleMetiers() != null) {
- List<EffortDescription> effortDescriptions = new ArrayList<EffortDescription>(getBean().getPossibleMetiers());
+ List<EffortDescription> effortDescriptions = new ArrayList<>(getBean().getPossibleMetiers());
model.setElementList(effortDescriptions);
}
fieldEffortDescriptionEffortDescriptionList.setModel(model);
}
protected void addEffortDescriptions() {
- Object[] selectedValues = (Object[])fieldEffortDescriptionMetierList.getSelectedValues();
- for (Object selectedValue : selectedValues) {
- Metier selectedMetier = (Metier)selectedValue;
+ List<Metier> selectedValues = fieldEffortDescriptionMetierList.getSelectedValuesList();
+ for (Metier selectedMetier : selectedValues) {
getInputAction().addEffortDescription(getBean(), selectedMetier);
}
setEffortDescriptionEffortDescriptionList();
}
protected void removeEffortDescriptions() {
- Object[] selectedValues = (Object[])fieldEffortDescriptionEffortDescriptionList.getSelectedValues();
- for (Object selectedValue : selectedValues) {
- EffortDescription selectedEffortDescription = (EffortDescription)selectedValue;
+ List<EffortDescription> selectedValues = fieldEffortDescriptionEffortDescriptionList.getSelectedValuesList();
+ for (EffortDescription selectedEffortDescription : selectedValues) {
getInputAction().removeEffortDescription(getBean(), selectedEffortDescription);
}
setEffortDescriptionEffortDescriptionList();
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/strategy/StrategyOneMonthInfoUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/strategy/StrategyOneMonthInfoUI.jaxx 2015-05-07 09:51:50 UTC (rev 4221)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/strategy/StrategyOneMonthInfoUI.jaxx 2015-05-07 13:27:52 UTC (rev 4222)
@@ -5,7 +5,7 @@
$Id$
$HeadURL$
%%
- Copyright (C) 2009 - 2011 Ifremer, Code Lutin, Chatellier Eric
+ Copyright (C) 2009 - 2015 Ifremer, Code Lutin, Chatellier Eric
%%
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as
@@ -86,6 +86,7 @@
<row>
<cell columns='2' fill='horizontal' weightx='1.0'>
<JComboBox id="fieldStrategyMonthInfoTripType"
+ genericType="fr.ifremer.isisfish.entities.TripType"
onActionPerformed='getStrategyMonthInfo().setTripType((TripType)fieldStrategyMonthInfoTripType.getSelectedItem())'
renderer='{new fr.ifremer.isisfish.ui.input.renderer.TripTypeListRenderer(true)}'
enabled='{isActive()}' decorator='boxed'/>
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/strategy/StrategyTabUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/strategy/StrategyTabUI.jaxx 2015-05-07 09:51:50 UTC (rev 4221)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/strategy/StrategyTabUI.jaxx 2015-05-07 13:27:52 UTC (rev 4222)
@@ -121,6 +121,7 @@
</cell>
<cell fill='horizontal' weightx='1.0'>
<JComboBox id="fieldStrategySetOfVessels"
+ genericType="fr.ifremer.isisfish.entities.SetOfVessels"
onItemStateChanged='setOfVesselsChanged()'
enabled='{isActive()}' decorator='boxed'/>
</cell>
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/variable/EntityVariableHandler.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/variable/EntityVariableHandler.java 2015-05-07 09:51:50 UTC (rev 4221)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/variable/EntityVariableHandler.java 2015-05-07 13:27:52 UTC (rev 4222)
@@ -129,7 +129,7 @@
* @param view view
*/
public void deleteVariable(EntityVariableUI view) {
- JList variableList = view.getVariablesList();
+ JList<Variable> variableList = view.getVariablesList();
Variable variable = (Variable)variableList.getSelectedValue();
try {
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/variable/EntityVariableUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/variable/EntityVariableUI.jaxx 2015-05-07 09:51:50 UTC (rev 4221)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/variable/EntityVariableUI.jaxx 2015-05-07 13:27:52 UTC (rev 4222)
@@ -5,7 +5,7 @@
$Id$
$HeadURL$
%%
- Copyright (C) 2012 Ifremer, Code Lutin, Chatellier Eric
+ Copyright (C) 2012 - 2015 Ifremer, Code Lutin, Chatellier Eric
%%
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as
@@ -25,6 +25,7 @@
<fr.ifremer.isisfish.ui.input.InputContentUI superGenericType='org.nuiton.topia.persistence.TopiaEntityContextable'>
<import>
static org.nuiton.i18n.I18n.t
+ fr.ifremer.isisfish.ui.models.common.GenericComboModel
</import>
<EntityVariableHandler id="varHandler" />
@@ -107,7 +108,8 @@
enabled='{isActive() && getVariable() != null}'/>
</cell>
<cell fill="horizontal" weightx='1.0'>
- <JComboBox id="variableTypeCombo" model="{new VariableTypeComboModel()}"
+ <JComboBox id="variableTypeCombo" model="{new GenericComboModel<fr.ifremer.isisfish.entities.Variable>()}"
+ genericType="fr.ifremer.isisfish.entities.Variable"
selectedItem="{getVariable().getType()}"
onActionPerformed="getVarHandler().showSelectedType(this)"
enabled='{isActive() && getVariable() != null}' decorator='boxed' />
Deleted: trunk/src/main/java/fr/ifremer/isisfish/ui/input/variable/VariableTypeComboModel.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/variable/VariableTypeComboModel.java 2015-05-07 09:51:50 UTC (rev 4221)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/variable/VariableTypeComboModel.java 2015-05-07 13:27:52 UTC (rev 4222)
@@ -1,76 +0,0 @@
-/*
- * #%L
- * IsisFish
- *
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2012 Ifremer, CodeLutin, Chatellier Eric
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-
-package fr.ifremer.isisfish.ui.input.variable;
-
-import javax.swing.DefaultComboBoxModel;
-
-import fr.ifremer.isisfish.entities.VariableType;
-
-/**
- * Modele pour la liste des type possible de variable.
- *
- * @author chatellier
- * @version $Revision$
- *
- * Last update : $Date$
- * By : $Author$
- */
-public class VariableTypeComboModel extends DefaultComboBoxModel<VariableType> {
-
- /** serialVersionUID. */
- private static final long serialVersionUID = 6171850179969290032L;
-
- /** Values list */
- protected VariableType[] variableTypes;
-
- /**
- * Empty constructor.
- */
- public VariableTypeComboModel() {
- variableTypes = VariableType.values();
- }
-
- /*
- * @see javax.swing.ListModel#getElementAt(int)
- */
- @Override
- public VariableType getElementAt(int index) {
- return variableTypes[index];
- }
-
- /*
- * @see javax.swing.ListModel#getSize()
- */
- @Override
- public int getSize() {
- int size = 0;
-
- if (variableTypes != null) {
- size = variableTypes.length;
- }
- return size;
- }
-}
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/vesseltype/VesselTypeUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/vesseltype/VesselTypeUI.jaxx 2015-05-07 09:51:50 UTC (rev 4221)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/vesseltype/VesselTypeUI.jaxx 2015-05-07 13:27:52 UTC (rev 4222)
@@ -5,7 +5,7 @@
$Id$
$HeadURL$
%%
- Copyright (C) 2009 - 2011 Ifremer, Code Lutin, Chatellier Eric
+ Copyright (C) 2009 - 2015 Ifremer, Code Lutin, Chatellier Eric
%%
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as
@@ -109,10 +109,7 @@
}
protected void tripTypeChanged() {
if (!init) {
- java.util.List<TripType> tripTypes = new java.util.ArrayList<TripType>();
- for (Object o : vesselTypeTripType.getSelectedValues()) {
- tripTypes.add((TripType)o);
- }
+ List<TripType> tripTypes = new ArrayList<TripType>(vesselTypeTripType.getSelectedValuesList());
getBean().setTripType(tripTypes);
}
}
@@ -218,6 +215,7 @@
<cell fill='both' weightx='1.0' weighty='0.7'>
<JScrollPane>
<JList id="vesselTypeTripType" onValueChanged='tripTypeChanged()'
+ genericType="fr.ifremer.isisfish.entities.TripType"
cellRenderer="{new fr.ifremer.isisfish.ui.input.renderer.TripTypeListRenderer()}"
enabled='{isActive()}' decorator='boxed' _sensitivityBean='{VesselType.class}' _sensitivityMethod='"TripType"'/>
</JScrollPane>
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/zone/ZoneBasicsUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/input/zone/ZoneBasicsUI.jaxx 2015-05-07 09:51:50 UTC (rev 4221)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/zone/ZoneBasicsUI.jaxx 2015-05-07 13:27:52 UTC (rev 4222)
@@ -5,7 +5,7 @@
$Id$
$HeadURL$
%%
- Copyright (C) 2009 - 2012 Ifremer, Code Lutin, Chatellier Eric
+ Copyright (C) 2009 - 2015 Ifremer, Code Lutin, Chatellier Eric
%%
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as
@@ -98,9 +98,9 @@
if (event.getValueIsAdjusting()) {
// pas a faie dans le cas d'une AS
if (isActive()) {
- java.util.List<Cell> cells = new ArrayList<Cell>();
- for (Object o : zoneCells.getSelectedValues()) {
- cells.add((Cell) o);
+ List<Cell> cells = new ArrayList<Cell>();
+ for (Cell o : zoneCells.getSelectedValuesList()) {
+ cells.add(o);
}
getBean().setCell(cells);
}
@@ -133,6 +133,7 @@
<cell columns='2' fill='both' weighty='0.7' weightx='1.0'>
<JScrollPane id="spZoneCells">
<JList id="zoneCells" enabled='{isActive()}'
+ genericType="fr.ifremer.isisfish.entities.Cell"
onValueChanged='zoneCellsChange(event)' decorator='boxed'/>
</JScrollPane>
</cell>
Deleted: trunk/src/main/java/fr/ifremer/isisfish/ui/models/sensitivityanalysis/SensitivityAnalysisComboModel.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/models/sensitivityanalysis/SensitivityAnalysisComboModel.java 2015-05-07 09:51:50 UTC (rev 4221)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/models/sensitivityanalysis/SensitivityAnalysisComboModel.java 2015-05-07 13:27:52 UTC (rev 4222)
@@ -1,109 +0,0 @@
-/*
- * #%L
- * IsisFish
- *
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2009 - 2011 Ifremer, Code Lutin, Chatellier Eric
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-
-package fr.ifremer.isisfish.ui.models.sensitivityanalysis;
-
-import java.util.List;
-
-import javax.swing.DefaultComboBoxModel;
-
-/**
- * Model pour la liste des calculateurs de sensibilite.
- *
- * @author chatellier
- * @version $Revision$
- *
- * Last update : $Date$
- * By : $Author$
- */
-public class SensitivityAnalysisComboModel extends DefaultComboBoxModel<String> {
-
- /** serialVersionUID. */
- private static final long serialVersionUID = -4070846632975105788L;
-
- /** SensitivityAnalysis names. */
- protected List<String> sensitivityAnalysisNames;
-
- /**
- * Empty constructor.
- */
- public SensitivityAnalysisComboModel() {
- this(null);
- }
-
- /**
- * Constructor with calculator list.
- *
- * @param sensitivityAnalysisNames sensitivity analysis Names
- */
- public SensitivityAnalysisComboModel(List<String> sensitivityAnalysisNames) {
- setSensitivityCalculatorNames(sensitivityAnalysisNames);
- }
-
- /**
- * Get sensitivity analysis plan names.
- *
- * @return the sensitivity analysis plan names
- */
- public List<String> getSensitivityAnalysisNames() {
- return sensitivityAnalysisNames;
- }
-
- /**
- * Set sensitivity analysis names.
- *
- * @param sensitivityAnalysisNames the names to set
- */
- public void setSensitivityCalculatorNames(List<String> sensitivityAnalysisNames) {
- this.sensitivityAnalysisNames = sensitivityAnalysisNames;
-
- // default first selected
- /* disable default selection
- if (!sensitivityAnalysisNames.isEmpty()) {
- setSelectedItem(sensitivityAnalysisNames.get(0));
- }*/
- }
-
- /*
- * @see javax.swing.ListModel#getElementAt(int)
- */
- @Override
- public String getElementAt(int index) {
- return sensitivityAnalysisNames.get(index);
- }
-
- /*
- * @see javax.swing.ListModel#getSize()
- */
- @Override
- public int getSize() {
- int size = 0;
-
- if (sensitivityAnalysisNames != null) {
- size = sensitivityAnalysisNames.size();
- }
- return size;
- }
-}
Deleted: trunk/src/main/java/fr/ifremer/isisfish/ui/models/sensitivityanalysis/SensitivityAnalysisListModel.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/models/sensitivityanalysis/SensitivityAnalysisListModel.java 2015-05-07 09:51:50 UTC (rev 4221)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/models/sensitivityanalysis/SensitivityAnalysisListModel.java 2015-05-07 13:27:52 UTC (rev 4222)
@@ -1,104 +0,0 @@
-/*
- * #%L
- * IsisFish
- *
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2009 - 2010 Ifremer, Code Lutin
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-
-package fr.ifremer.isisfish.ui.models.sensitivityanalysis;
-
-import java.util.List;
-
-import javax.swing.AbstractListModel;
-
-import fr.ifremer.isisfish.simulator.sensitivity.SensitivityAnalysis;
-
-/**
- * Model pour la liste des instances de calculateurs.
- *
- * @author chatellier
- * @version $Revision$
- *
- * Last update : $Date$
- * By : $Author$
- */
-public class SensitivityAnalysisListModel extends AbstractListModel<SensitivityAnalysis> {
-
- /** serialVersionUID. */
- private static final long serialVersionUID = -4070846632975105788L;
-
- protected List<SensitivityAnalysis> sensitivityAnalysis;
-
- /**
- * Empty constructor.
- */
- public SensitivityAnalysisListModel() {
- this(null);
- }
-
- /**
- * Constructor with list.
- *
- * @param sensitivityAnalysis analysis list
- */
- public SensitivityAnalysisListModel(List<SensitivityAnalysis> sensitivityAnalysis) {
- setSensitivityAnalysis(sensitivityAnalysis);
- }
-
- /**
- * Get analysis list.
- *
- * @return the analysis
- */
- public List<SensitivityAnalysis> getSensitivityAnalysis() {
- return sensitivityAnalysis;
- }
-
- /**
- * Set analysis list.
- *
- * @param sensitivityAnalysis the analysis to set
- */
- public void setSensitivityAnalysis(List<SensitivityAnalysis> sensitivityAnalysis) {
- this.sensitivityAnalysis = sensitivityAnalysis;
- }
-
- /*
- * @see javax.swing.ListModel#getElementAt(int)
- */
- @Override
- public SensitivityAnalysis getElementAt(int index) {
- return sensitivityAnalysis.get(index);
- }
-
- /*
- * @see javax.swing.ListModel#getSize()
- */
- @Override
- public int getSize() {
- int size = 0;
-
- if (sensitivityAnalysis != null) {
- size = sensitivityAnalysis.size();
- }
- return size;
- }
-}
Deleted: trunk/src/main/java/fr/ifremer/isisfish/ui/models/sensitivityexport/SensitivityExportListModel.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/models/sensitivityexport/SensitivityExportListModel.java 2015-05-07 09:51:50 UTC (rev 4221)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/models/sensitivityexport/SensitivityExportListModel.java 2015-05-07 13:27:52 UTC (rev 4222)
@@ -1,105 +0,0 @@
-/*
- * #%L
- * IsisFish
- *
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2009 - 2010 Ifremer, Code Lutin
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-
-package fr.ifremer.isisfish.ui.models.sensitivityexport;
-
-import java.util.List;
-
-import javax.swing.AbstractListModel;
-
-import fr.ifremer.isisfish.export.SensitivityExport;
-
-/**
- * Model pour la liste des instances d'exports.
- *
- * @author chatellier
- * @version $Revision$
- *
- * Last update : $Date$
- * By : $Author$
- */
-public class SensitivityExportListModel extends AbstractListModel<SensitivityExport> {
-
- /** serialVersionUID. */
- private static final long serialVersionUID = -4070846632975105788L;
-
- protected List<SensitivityExport> exports;
-
- /**
- * Empty constructor.
- */
- public SensitivityExportListModel() {
- this(null);
- }
-
- /**
- * Constructor with plan list.
- *
- * @param exports exports
- */
- public SensitivityExportListModel(List<SensitivityExport> exports) {
- super();
- setSensitivityExports(exports);
- }
-
- /**
- * Get exports list.
- *
- * @return the exports
- */
- public List<SensitivityExport> getSensitivityExports() {
- return exports;
- }
-
- /**
- * Set exports list.
- *
- * @param exports the exports to set
- */
- public void setSensitivityExports(List<SensitivityExport> exports) {
- this.exports = exports;
- }
-
- /*
- * @see javax.swing.ListModel#getElementAt(int)
- */
- @Override
- public SensitivityExport getElementAt(int index) {
- return exports.get(index);
- }
-
- /*
- * @see javax.swing.ListModel#getSize()
- */
- @Override
- public int getSize() {
- int size = 0;
-
- if (exports != null) {
- size = exports.size();
- }
- return size;
- }
-}
Deleted: trunk/src/main/java/fr/ifremer/isisfish/ui/models/simulationplan/SimulationPlanComboModel.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/models/simulationplan/SimulationPlanComboModel.java 2015-05-07 09:51:50 UTC (rev 4221)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/models/simulationplan/SimulationPlanComboModel.java 2015-05-07 13:27:52 UTC (rev 4222)
@@ -1,108 +0,0 @@
-/*
- * #%L
- * IsisFish
- *
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2009 - 2011 Ifremer, Code Lutin, Chatellier Eric
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-
-package fr.ifremer.isisfish.ui.models.simulationplan;
-
-import java.util.List;
-
-import javax.swing.DefaultComboBoxModel;
-
-/**
- * Model pour la liste des plans de simulation.
- *
- * @author chatellier
- * @version $Revision$
- *
- * Last update : $Date$
- * By : $Author$
- */
-public class SimulationPlanComboModel extends DefaultComboBoxModel<String> {
-
- /** serialVersionUID. */
- private static final long serialVersionUID = -4070846632975105788L;
-
- /** Analyze plan names. */
- protected List<String> simulationPlanNames;
-
- /**
- * Empty constructor.
- */
- public SimulationPlanComboModel() {
- this(null);
- }
-
- /**
- * Constructor with simulation plans list.
- *
- * @param simulationPlanNames simulation names
- */
- public SimulationPlanComboModel(List<String> simulationPlanNames) {
- setSimulationPlanNames(simulationPlanNames);
- }
-
- /**
- * Get simulation plan names.
- *
- * @return the simulation plan names
- */
- public List<String> getSimulationPlanNames() {
- return simulationPlanNames;
- }
-
- /**
- * Set simulation plan names.
- *
- * @param simulationPlanNames the simulation plan names to set
- */
- public void setSimulationPlanNames(List<String> simulationPlanNames) {
- this.simulationPlanNames = simulationPlanNames;
-
- // default first selected
- if (!simulationPlanNames.isEmpty()) {
- setSelectedItem(simulationPlanNames.get(0));
- }
- }
-
- /*
- * @see javax.swing.ListModel#getElementAt(int)
- */
- @Override
- public String getElementAt(int index) {
- return simulationPlanNames.get(index);
- }
-
- /*
- * @see javax.swing.ListModel#getSize()
- */
- @Override
- public int getSize() {
- int size = 0;
-
- if (simulationPlanNames != null) {
- size = simulationPlanNames.size();
- }
- return size;
- }
-}
Deleted: trunk/src/main/java/fr/ifremer/isisfish/ui/models/simulationplan/SimulationPlanListModel.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/models/simulationplan/SimulationPlanListModel.java 2015-05-07 09:51:50 UTC (rev 4221)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/models/simulationplan/SimulationPlanListModel.java 2015-05-07 13:27:52 UTC (rev 4222)
@@ -1,104 +0,0 @@
-/*
- * #%L
- * IsisFish
- *
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2009 - 2011 Ifremer, Code Lutin, Chatellier Eric
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-
-package fr.ifremer.isisfish.ui.models.simulationplan;
-
-import java.util.List;
-
-import javax.swing.AbstractListModel;
-
-import fr.ifremer.isisfish.simulator.SimulationPlan;
-
-/**
- * Model pour la liste des instances de plans de simulation.
- *
- * @author chatellier
- * @version $Revision$
- *
- * Last update : $Date$
- * By : $Author$
- */
-public class SimulationPlanListModel extends AbstractListModel<SimulationPlan> {
-
- /** serialVersionUID. */
- private static final long serialVersionUID = -4070846632975105788L;
-
- protected List<SimulationPlan> plans;
-
- /**
- * Empty constructor.
- */
- public SimulationPlanListModel() {
- this(null);
- }
-
- /**
- * Constructor with plan list.
- *
- * @param plans plans
- */
- public SimulationPlanListModel(List<SimulationPlan> plans) {
- setSimulationPlan(plans);
- }
-
- /**
- * Get plans list.
- *
- * @return the plans
- */
- public List<SimulationPlan> getSimulationPlans() {
- return plans;
- }
-
- /**
- * Set plans list.
- *
- * @param plans the plans to set
- */
- public void setSimulationPlan(List<SimulationPlan> plans) {
- this.plans = plans;
- }
-
- /*
- * @see javax.swing.ListModel#getElementAt(int)
- */
- @Override
- public SimulationPlan getElementAt(int index) {
- return plans.get(index);
- }
-
- /*
- * @see javax.swing.ListModel#getSize()
- */
- @Override
- public int getSize() {
- int size = 0;
-
- if (plans != null) {
- size = plans.size();
- }
- return size;
- }
-}
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/result/ResultHandler.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/result/ResultHandler.java 2015-05-07 09:51:50 UTC (rev 4221)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/result/ResultHandler.java 2015-05-07 13:27:52 UTC (rev 4222)
@@ -202,7 +202,7 @@
matrixViewerPanel.addMatrixFilter(new SumByYearMatrixFilter());
// init available results list
- GenericComboModel<String> model = new GenericComboModel<String>(resultStorage.getResultName());
+ GenericComboModel<String> model = new GenericComboModel<>(resultStorage.getResultName());
resultSimulationFrame.getResultsComboBox().setModel(model);
resultSimulationFrame.getResultsComboBox().addItemListener(new ItemListener() {
@Override
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/result/ResultSimulationFrame.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/result/ResultSimulationFrame.jaxx 2015-05-07 09:51:50 UTC (rev 4221)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/result/ResultSimulationFrame.jaxx 2015-05-07 13:27:52 UTC (rev 4222)
@@ -47,7 +47,9 @@
<Table>
<row>
<cell><JLabel text="isisfish.result.selectResult" /></cell>
- <cell fill="horizontal" weightx="1"><JComboBox id="resultsComboBox" /></cell>
+ <cell fill="horizontal" weightx="1">
+ <JComboBox id="resultsComboBox" genericType="String" />
+ </cell>
</row>
<row>
<cell fill="both" weightx="1" weighty="1" columns="2">
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/script/ScriptTypesComboModel.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/script/ScriptTypesComboModel.java 2015-05-07 09:51:50 UTC (rev 4221)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/script/ScriptTypesComboModel.java 2015-05-07 13:27:52 UTC (rev 4222)
@@ -41,7 +41,7 @@
* Last update : $Date$
* By : $Author$
*/
-public class ScriptTypesComboModel extends DefaultComboBoxModel {
+public class ScriptTypesComboModel extends DefaultComboBoxModel<ScriptMapping> {
/** serialVersionUID. */
private static final long serialVersionUID = -4070846632975105788L;
@@ -71,7 +71,7 @@
* @see javax.swing.ListModel#getElementAt(int)
*/
@Override
- public Object getElementAt(int index) {
+ public ScriptMapping getElementAt(int index) {
return mappings.get(index);
}
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/SensitivityChooserUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/SensitivityChooserUI.jaxx 2015-05-07 09:51:50 UTC (rev 4221)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/SensitivityChooserUI.jaxx 2015-05-07 13:27:52 UTC (rev 4222)
@@ -5,7 +5,7 @@
$Id$
$HeadURL$
%%
- Copyright (C) 2009 - 2014 Ifremer, CodeLutin, Chatellier Eric
+ Copyright (C) 2009 - 2015 Ifremer, CodeLutin, Chatellier Eric
%%
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as
@@ -38,10 +38,9 @@
fr.ifremer.isisfish.simulator.sensitivity.SensitivityAnalysis
fr.ifremer.isisfish.simulator.sensitivity.domain.ContinuousDomain
fr.ifremer.isisfish.ui.models.common.GenericListModel
- fr.ifremer.isisfish.ui.models.sensitivityexport.SensitivityExportListModel
+ fr.ifremer.isisfish.ui.models.common.GenericComboModel
fr.ifremer.isisfish.ui.models.sensitivityexport.SensitivityExportListRenderer
fr.ifremer.isisfish.ui.models.sensitivityexport.SensitivityExportNameListRenderer
- fr.ifremer.isisfish.ui.models.sensitivityanalysis.SensitivityAnalysisComboModel
fr.ifremer.isisfish.ui.models.sensitivityanalysis.SensitivityAnalysisComboRenderer
fr.ifremer.isisfish.ui.models.common.ScriptParametersTableCellEditor
fr.ifremer.isisfish.ui.models.common.ScriptParametersTableCellRenderer
@@ -79,7 +78,7 @@
public ComboBoxModel<String> getSensitivityAnalysisModel() {
List<String> sensitivityNames = getSimulAction().getSensitivityAnalysisNames();
- SensitivityAnalysisComboModel model = new SensitivityAnalysisComboModel(sensitivityNames);
+ GenericComboModel<String> model = new GenericComboModel<>(sensitivityNames);
return model;
}
@@ -151,7 +150,7 @@
protected GenericListModel<String> getAvailableExportListModel() {
List<String> exportNames = getSimulAction().getSensitivityExportNames();
- GenericListModel<String> model = new GenericListModel<String>(exportNames);
+ GenericListModel<String> model = new GenericListModel<>(exportNames);
return model;
}
@@ -161,9 +160,9 @@
* Export name can be duplicated.
*/
protected void addExports() {
- Object[] exportNames = (Object[])availableSensitivityExports.getSelectedValues();
- for (Object exportName : exportNames) {
- getSimulAction().addSensitivityExport(this, (String)exportName);
+ List<String> exportNames = availableSensitivityExports.getSelectedValuesList();
+ for (String exportName : exportNames) {
+ getSimulAction().addSensitivityExport(this, exportName);
}
setSensitivityExportListModel();
}
@@ -172,9 +171,9 @@
* Remove multiple export.
*/
protected void removeExports() {
- Object[] exports = (Object[])selectedSensitivityExports.getSelectedValues();
- for (Object export : exports) {
- getSimulAction().removeSensitivityExport((SensitivityExport)export);
+ List<SensitivityExport> exports = selectedSensitivityExports.getSelectedValuesList();
+ for (SensitivityExport export : exports) {
+ getSimulAction().removeSensitivityExport(export);
}
setSensitivityExportListModel();
}
@@ -191,8 +190,8 @@
* Set model (refresh export JList).
*/
public void setSensitivityExportListModel() {
- java.util.List<SensitivityExport> exports = getSimulAction().getSensitivityExports();
- SensitivityExportListModel model = new SensitivityExportListModel(exports);
+ List<SensitivityExport> exports = getSimulAction().getSensitivityExports();
+ GenericListModel<SensitivityExport> model = new GenericListModel<>(exports);
selectedSensitivityExports.setModel(model);
selectedSensitivityExports.setCellRenderer(new SensitivityExportListRenderer());
@@ -243,6 +242,7 @@
</cell>
<cell fill="horizontal" weightx="1.0">
<JComboBox id="fieldSensitivityAnalysisSelect" model='{getSensitivityAnalysisModel()}'
+ genericType="String"
renderer='{new SensitivityAnalysisComboRenderer()}' onActionPerformed='sensitivityAnalysisChanged()'/>
</cell>
</row>
@@ -277,6 +277,7 @@
<JScrollPane>
<JList id="availableSensitivityExports" selectionMode="{javax.swing.ListSelectionModel.MULTIPLE_INTERVAL_SELECTION}"
model='{getAvailableExportListModel()}' cellRenderer='{new SensitivityExportNameListRenderer()}'
+ genericType="String"
onValueChanged='availableSensitivityExportSelection()' />
</JScrollPane>
</cell>
@@ -302,6 +303,7 @@
<cell fill="both" weightx="0.5" weighty="1.0">
<JScrollPane>
<JList id="selectedSensitivityExports" selectionMode="{javax.swing.ListSelectionModel.MULTIPLE_INTERVAL_SELECTION}"
+ genericType="fr.ifremer.isisfish.export.SensitivityExport"
onValueChanged='selectedSensitivityExportSelection()' />
</JScrollPane>
</cell>
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/SensitivitySecondPassUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/SensitivitySecondPassUI.jaxx 2015-05-07 09:51:50 UTC (rev 4221)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/SensitivitySecondPassUI.jaxx 2015-05-07 13:27:52 UTC (rev 4222)
@@ -5,7 +5,7 @@
$Id$
$HeadURL$
%%
- Copyright (C) 2009 - 2014 Ifremer, CodeLutin, Chatellier Eric
+ Copyright (C) 2009 - 2015 Ifremer, CodeLutin, Chatellier Eric
%%
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as
@@ -84,7 +84,7 @@
}
}
- GenericComboModel<String> model = new GenericComboModel<String>(asNames);
+ GenericComboModel<String> model = new GenericComboModel<>(asNames);
return model;
}
@@ -104,7 +104,7 @@
try {
String selectedSimulationName = (String)fieldSensitivitySimulationSelect.getSelectedItem();
- java.util.List<File> files = getSimulAction().getSensitivitySecondPassResults(selectedSimulationName);
+ List<File> files = getSimulAction().getSensitivitySecondPassResults(selectedSimulationName);
String content = "";
for(File file : files) {
@@ -114,8 +114,7 @@
content += "\n";
}
textAreaSensitivitySecondpassResult.setText(content);
- }
- catch(IOException e) {
+ } catch(IOException e) {
if (log.isErrorEnabled()) {
log.error("Can't run second pass", e);
}
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/wizard/SensitivityWizardHandler.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/wizard/SensitivityWizardHandler.java 2015-05-07 09:51:50 UTC (rev 4221)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/wizard/SensitivityWizardHandler.java 2015-05-07 13:27:52 UTC (rev 4222)
@@ -301,7 +301,7 @@
try {
context = regionStorage.getStorage().beginTransaction();
List list = context.findAll("from " + value.getClass().getName());
- JComboBox c = new JComboBox(list.toArray());
+ JComboBox c = new JComboBox<>(list.toArray());
c.setSelectedItem(value);
result = c;
} catch (TopiaException ex) {
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/AdvancedParamsUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/AdvancedParamsUI.jaxx 2015-05-07 09:51:50 UTC (rev 4221)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/AdvancedParamsUI.jaxx 2015-05-07 13:27:52 UTC (rev 4222)
@@ -5,7 +5,7 @@
$Id$
$HeadURL$
%%
- Copyright (C) 2009 - 2014 Ifremer, CodeLutin, Chatellier Eric
+ Copyright (C) 2009 - 2015 Ifremer, CodeLutin, Chatellier Eric
%%
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as
@@ -142,13 +142,17 @@
<JLabel text="isisfish.advancedParams.simulatorUse"/>
</cell>
<cell columns="4" fill="horizontal">
- <JComboBox id="fieldSimulAdvParamsSimulatorSelect" model='{new DefaultComboBoxModel(getContextValue(SimulAction.class).getSimulatorNames().toArray())}'
+ <JComboBox id="fieldSimulAdvParamsSimulatorSelect"
+ genericType="String"
+ model='{new DefaultComboBoxModel(getContextValue(SimulAction.class).getSimulatorNames().toArray())}'
onActionPerformed='setSimulatorName()'/>
</cell>
</row>
<row>
<cell columns="2" fill="horizontal">
- <JCheckBox id="fieldSimulationStatistique" text="isisfish.advancedParams.simulationStatistique" selected='{getContextValue(SimulAction.class).getSimulationParameter().getUseStatistic()}'
+ <JCheckBox id="fieldSimulationStatistique"
+ text="isisfish.advancedParams.simulationStatistique"
+ selected='{getContextValue(SimulAction.class).getSimulationParameter().getUseStatistic()}'
onActionPerformed='getContextValue(SimulAction.class).getSimulationParameter().setUseStatistic(fieldSimulationStatistique.isSelected());'/>
</cell>
<cell columns="2" fill="horizontal">
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/ExportUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/ExportUI.jaxx 2015-05-07 09:51:50 UTC (rev 4221)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/ExportUI.jaxx 2015-05-07 13:27:52 UTC (rev 4222)
@@ -5,7 +5,7 @@
$Id$
$HeadURL$
%%
- Copyright (C) 2005 - 2014 Ifremer, CodeLutin, Chatellier Eric
+ Copyright (C) 2005 - 2015 Ifremer, CodeLutin, Chatellier Eric
%%
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as
@@ -66,10 +66,10 @@
protected void saveSimulationExports(ListSelectionEvent event) {
// Set exports (this can save empty list (not a big deal))
- Object[] values = listSimulExportChoose.getSelectedValues();
- java.util.List<String> exportNames = new LinkedList<String>();
- for (Object o : values) {
- exportNames.add((String) o);
+ List<String> values = listSimulExportChoose.getSelectedValuesList();
+ List<String> exportNames = new LinkedList<>();
+ for (String o : values) {
+ exportNames.add(o);
}
getSimulAction().getSimulationParameter().setExportNames(exportNames);
@@ -80,10 +80,10 @@
protected void saveConfigExports() {
// Set exports (this can save empty list (not a big deal))
- Object[] values = listSimulExportChoose.getSelectedValues();
- java.util.List<String> exportNames = new LinkedList<String>();
- for (Object o : values) {
- exportNames.add((String) o);
+ List<String> values = listSimulExportChoose.getSelectedValuesList();
+ List<String> exportNames = new LinkedList<String>();
+ for (String o : values) {
+ exportNames.add(o);
}
getSimulAction().getSimulationParameter().setExportNames(exportNames);
@@ -102,6 +102,7 @@
<cell fill="both" weightx="1.0" weighty="1.0">
<JScrollPane>
<JList id="listSimulExportChoose" selectionMode="{javax.swing.ListSelectionModel.MULTIPLE_INTERVAL_SELECTION}"
+ genericType="String"
cellRenderer='{new fr.ifremer.isisfish.ui.models.export.ExportNameListRenderer()}'
onValueChanged='saveSimulationExports(event)' />
</JScrollPane>
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/OptimizationUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/OptimizationUI.jaxx 2015-05-07 09:51:50 UTC (rev 4221)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/OptimizationUI.jaxx 2015-05-07 13:27:52 UTC (rev 4222)
@@ -5,7 +5,7 @@
$Id$
$HeadURL$
%%
- Copyright (C) 2013 - 2014 Ifremer, CodeLutin, Chatellier Eric
+ Copyright (C) 2013 - 2015 Ifremer, CodeLutin, Chatellier Eric
%%
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/ParamsUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/ParamsUI.jaxx 2015-05-07 09:51:50 UTC (rev 4221)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/ParamsUI.jaxx 2015-05-07 13:27:52 UTC (rev 4222)
@@ -5,7 +5,7 @@
$Id$
$HeadURL$
%%
- Copyright (C) 2005 - 2014 Ifremer, CodeLutin, Chatellier Eric
+ Copyright (C) 2005 - 2015 Ifremer, CodeLutin, Chatellier Eric
%%
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as
@@ -82,7 +82,7 @@
@Override
public void simulationStop(SimulationService simService, final SimulationJob job) {
- final GenericComboModel<String> model = (GenericComboModel)fieldSimulParamsSelect.getModel();
+ final GenericComboModel<String> model = (GenericComboModel<String>)fieldSimulParamsSelect.getModel();
SwingUtilities.invokeLater(new Runnable() {
public void run() {
model.addElement(job.getId());
@@ -294,7 +294,7 @@
}
protected void strategySelected(){
- simulAction.setStrategies(listSimulParamsStrategies.getSelectedValues());
+ simulAction.setStrategies(listSimulParamsStrategies.getSelectedValuesList());
}
protected ComboBoxModel<String> getSimulParamsSelectModel() {
@@ -322,6 +322,7 @@
</cell>
<cell fill="horizontal" weightx="1.0">
<FilterableComboBox id="fieldSimulParamsSelect"
+ genericType="String"
model='{getSimulParamsSelectModel()}'
onActionPerformed='loadOldSimulation()' />
</cell>
@@ -434,6 +435,7 @@
weighty="1">
<JScrollPane>
<JList id="listSimulParamsStrategies"
+ genericType="fr.ifremer.isisfish.entities.Strategy"
selectionMode="{javax.swing.ListSelectionModel.MULTIPLE_INTERVAL_SELECTION}"
selectionModel="{new jaxx.runtime.swing.OneClicListSelectionModel(listSimulParamsStrategies.getSelectionModel(), listSimulParamsStrategies.getModel())}"
onValueChanged='strategySelected()'
@@ -444,6 +446,7 @@
weighty="1">
<JScrollPane>
<JList id="listSimulParamsPopulations"
+ genericType="fr.ifremer.isisfish.entities.Population"
selectionMode="{javax.swing.ListSelectionModel.MULTIPLE_INTERVAL_SELECTION}"
selectionModel="{new jaxx.runtime.swing.OneClicListSelectionModel(listSimulParamsPopulations.getSelectionModel(), listSimulParamsPopulations.getModel())}"
onValueChanged='simulAction.populationSelected(this)'
@@ -541,6 +544,7 @@
</cell>
<cell fill="horizontal" weightx="0.4">
<JComboBox id="comboSelLauncher"
+ genericType="fr.ifremer.isisfish.simulator.launcher.SimulatorLauncher"
model='{new DefaultComboBoxModel(simulAction.getSimulationLauncher().toArray())}' />
</cell>
<cell fill="horizontal" weightx="0.4">
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/ResultChoiceUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/ResultChoiceUI.jaxx 2015-05-07 09:51:50 UTC (rev 4221)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/ResultChoiceUI.jaxx 2015-05-07 13:27:52 UTC (rev 4222)
@@ -5,7 +5,7 @@
$Id$
$HeadURL$
%%
- Copyright (C) 2005 - 2014 Ifremer, CodeLutin, Chatellier Eric
+ Copyright (C) 2005 - 2015 Ifremer, CodeLutin, Chatellier Eric
%%
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as
@@ -54,7 +54,7 @@
// userResults = intersection(userResults,availableResult)
userResults.retainAll(availableResults);
- GenericListModel<String> resultModel = new GenericListModel<String>(availableResults);
+ GenericListModel<String> resultModel = new GenericListModel<>(availableResults);
listResultNames.setModel(resultModel);
for (String userResult : userResults) {
@@ -64,11 +64,11 @@
}
protected void saveParametersResultNames(ListSelectionEvent event) {
- getContextValue(SimulAction.class).saveParametersResultNames(listResultNames.getSelectedValues());
+ getContextValue(SimulAction.class).saveParametersResultNames(listResultNames.getSelectedValuesList());
}
protected void saveConfigResultNames() {
- getContextValue(SimulAction.class).saveConfigurationResultNames(listResultNames.getSelectedValues());
+ getContextValue(SimulAction.class).saveConfigurationResultNames(listResultNames.getSelectedValuesList());
setStatusMessage(t("isisfish.resultChoice.saved"));
}
@@ -82,6 +82,7 @@
<JLabel text="isisfish.resultChoice.save" horizontalAlignment="center" constraints='BorderLayout.NORTH'/>
<JScrollPane constraints='BorderLayout.CENTER'>
<JList id="listResultNames" selectionMode="{javax.swing.ListSelectionModel.MULTIPLE_INTERVAL_SELECTION}"
+ genericType="String"
cellRenderer='{new fr.ifremer.isisfish.ui.models.result.ResultListRenderer()}'
onValueChanged='saveParametersResultNames(event)' />
</JScrollPane>
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/SensUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/SensUI.jaxx 2015-05-07 09:51:50 UTC (rev 4221)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/SensUI.jaxx 2015-05-07 13:27:52 UTC (rev 4222)
@@ -5,7 +5,7 @@
$Id$
$HeadURL$
%%
- Copyright (C) 2005 - 2011 Ifremer, CodeLutin, Chatellier Eric
+ Copyright (C) 2005 - 2015 Ifremer, CodeLutin, Chatellier Eric
%%
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as
@@ -25,19 +25,19 @@
<Table>
<import>
java.awt.Dimension
- javax.swing.table.DefaultTableModel;
- fr.ifremer.isisfish.datastore.SimulationPlanStorage;
- fr.ifremer.isisfish.datastore.StorageChangeEvent;
- fr.ifremer.isisfish.datastore.StorageChangeListener;
- fr.ifremer.isisfish.simulator.SimulationPlan;
- fr.ifremer.isisfish.ui.models.simulationplan.SimulationPlanComboModel;
- fr.ifremer.isisfish.ui.models.simulationplan.SimulationPlanComboRenderer;
- fr.ifremer.isisfish.ui.models.simulationplan.SimulationPlanListModel;
- fr.ifremer.isisfish.ui.models.simulationplan.SimulationPlanListRenderer;
- fr.ifremer.isisfish.ui.models.common.ScriptParametersTableModel;
- fr.ifremer.isisfish.ui.models.common.ScriptParametersTableCellEditor;
- fr.ifremer.isisfish.ui.models.common.ScriptParametersTableCellRenderer;
- fr.ifremer.isisfish.datastore.RegionStorage;
+ javax.swing.table.DefaultTableModel
+ fr.ifremer.isisfish.datastore.SimulationPlanStorage
+ fr.ifremer.isisfish.datastore.StorageChangeEvent
+ fr.ifremer.isisfish.datastore.StorageChangeListener
+ fr.ifremer.isisfish.simulator.SimulationPlan
+ fr.ifremer.isisfish.ui.models.common.GenericComboModel
+ fr.ifremer.isisfish.ui.models.simulationplan.SimulationPlanComboRenderer
+ fr.ifremer.isisfish.ui.models.common.GenericListModel
+ fr.ifremer.isisfish.ui.models.simulationplan.SimulationPlanListRenderer
+ fr.ifremer.isisfish.ui.models.common.ScriptParametersTableModel
+ fr.ifremer.isisfish.ui.models.common.ScriptParametersTableCellEditor
+ fr.ifremer.isisfish.ui.models.common.ScriptParametersTableCellRenderer
+ fr.ifremer.isisfish.datastore.RegionStorage
</import>
<SimulAction id='simulAction' javaBean='getContextValue(SimulAction.class)' />
@@ -66,18 +66,18 @@
/**
* Refresh simulation plan names list.
*/
- protected SimulationPlanComboModel getSimulationPlansComboModel() {
+ protected GenericComboModel<String> getSimulationPlansComboModel() {
List<String> simulationPlanNames = simulAction.getSimulationPlanNames();
- SimulationPlanComboModel model = new SimulationPlanComboModel(simulationPlanNames);
+ GenericComboModel<String> model = new GenericComboModel<>(simulationPlanNames);
return model;
}
/**
* Refresh simulation simulation plan list.
*/
- protected SimulationPlanListModel getSimulationSimulationPlansListModel() {
+ protected GenericListModel<SimulationPlan> getSimulationSimulationPlansListModel() {
List<SimulationPlan> simulationPlans = simulAction.getParamSimulationPlans();
- SimulationPlanListModel model = new SimulationPlanListModel(simulationPlans);
+ GenericListModel<SimulationPlan> model = new GenericListModel<>(simulationPlans);
return model;
}
@@ -105,12 +105,10 @@
if (getContextValue(SimulAction.class).getParamSimulationPlans().isEmpty()) {
buttonSimulParamsSimulationPlansClear.setEnabled(false);
buttonSimulParamsSimulationPlansRemove.setEnabled(false);
- }
- else {
+ } else {
if (listSimulParamsSimulationPlansList.getSelectedIndex() != -1) {
buttonSimulParamsSimulationPlansRemove.setEnabled(true);
- }
- else {
+ } else {
buttonSimulParamsSimulationPlansRemove.setEnabled(false);
}
buttonSimulParamsSimulationPlansClear.setEnabled(true);
@@ -127,8 +125,7 @@
cellEditor.setRegionStorage(getContextValue(RegionStorage.class));
simulParamsSimulationPlans.getColumnModel().getColumn(0).setCellRenderer(new ScriptParametersTableCellRenderer(selectedSimulationPlan));
simulParamsSimulationPlans.getColumnModel().getColumn(1).setCellEditor(cellEditor);
- }
- else {
+ } else {
// clear table
simulParamsSimulationPlans.setModel(new DefaultTableModel());
}
@@ -138,6 +135,7 @@
<row>
<cell columns="2" fill="horizontal" weightx="1.0">
<JComboBox id="fieldSimulParamsSimulationPlansSelect" model='{getSimulationPlansComboModel()}'
+ genericType="String"
renderer='{new SimulationPlanComboRenderer()}' />
</cell>
</row>
@@ -145,6 +143,7 @@
<cell fill="both" weightx="0.5">
<JScrollPane minimumSize='{new Dimension(0,0)}' preferredSize='{new Dimension(0,0)}'>
<JList id="listSimulParamsSimulationPlansList" selectionMode="{javax.swing.ListSelectionModel.SINGLE_SELECTION}"
+ genericType="fr.ifremer.isisfish.simulator.SimulationPlan"
onValueChanged='setSimulationPlanButtons()' model='{getSimulationSimulationPlansListModel()}'
cellRenderer='{new SimulationPlanListRenderer()}'/>
</JScrollPane>
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/SimulAction.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/SimulAction.java 2015-05-07 09:51:50 UTC (rev 4221)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/SimulAction.java 2015-05-07 13:27:52 UTC (rev 4222)
@@ -25,6 +25,13 @@
package fr.ifremer.isisfish.ui.simulator;
+import static fr.ifremer.isisfish.simulator.SimulationParameterPropertiesHelper.DOT;
+import static fr.ifremer.isisfish.simulator.SimulationParameterPropertiesHelper.NUMBER_KEY;
+import static fr.ifremer.isisfish.simulator.SimulationParameterPropertiesHelper.PARAMETERS_KEY;
+import static fr.ifremer.isisfish.simulator.SimulationParameterPropertiesHelper.PARAMETER_KEY;
+import static fr.ifremer.isisfish.simulator.SimulationParameterPropertiesHelper.POPULATION_KEY;
+import static fr.ifremer.isisfish.simulator.SimulationParameterPropertiesHelper.RULES_KEY;
+import static fr.ifremer.isisfish.simulator.SimulationParameterPropertiesHelper.RULE_KEY;
import static org.nuiton.i18n.I18n.t;
import java.awt.BorderLayout;
@@ -37,6 +44,8 @@
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Collection;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Properties;
@@ -51,10 +60,8 @@
import javax.swing.JComponent;
import javax.swing.JPanel;
-import jaxx.runtime.SwingUtil;
-
+import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.io.IOUtils;
-import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.nuiton.math.matrix.MatrixND;
@@ -99,17 +106,8 @@
import fr.ifremer.isisfish.ui.sensitivity.wizard.SensitivityWizardHandler;
import fr.ifremer.isisfish.ui.util.ErrorHelper;
import fr.ifremer.isisfish.ui.widget.editor.ScriptParameterDialog;
-import java.util.HashMap;
-import java.util.LinkedHashMap;
+import jaxx.runtime.SwingUtil;
-import static fr.ifremer.isisfish.simulator.SimulationParameterPropertiesHelper.DOT;
-import static fr.ifremer.isisfish.simulator.SimulationParameterPropertiesHelper.NUMBER_KEY;
-import static fr.ifremer.isisfish.simulator.SimulationParameterPropertiesHelper.PARAMETER_KEY;
-import static fr.ifremer.isisfish.simulator.SimulationParameterPropertiesHelper.PARAMETERS_KEY;
-import static fr.ifremer.isisfish.simulator.SimulationParameterPropertiesHelper.POPULATION_KEY;
-import static fr.ifremer.isisfish.simulator.SimulationParameterPropertiesHelper.RULES_KEY;
-import static fr.ifremer.isisfish.simulator.SimulationParameterPropertiesHelper.RULE_KEY;
-
/**
* SimulAction.
*
@@ -350,6 +348,7 @@
/**
* Recursive rename and delete rule factor path.
*
+ * @param factorGroup factorGroup
* @param ruleIndex rule index to to delete
*/
protected void preRemoveRule(FactorGroup factorGroup, int ruleIndex) {
@@ -411,11 +410,8 @@
*
* @param strategies
*/
- public void setStrategies(Object[] strategies) {
- List<Strategy> result = new ArrayList<Strategy>();
- for (Object o : strategies) {
- result.add((Strategy) o);
- }
+ public void setStrategies(List<Strategy> strategies) {
+ List<Strategy> result = new ArrayList<Strategy>(strategies);
param.setStrategies(result);
}
@@ -458,11 +454,8 @@
*
* @param populations populations to set
*/
- public void setPopulations(Object[] populations) {
- List<Population> result = new ArrayList<Population>();
- for (Object o : populations) {
- result.add((Population) o);
- }
+ public void setPopulations(List<Population> populations) {
+ List<Population> result = new ArrayList<Population>(populations);
param.setPopulations(result);
}
@@ -599,11 +592,8 @@
*/
public List<String> getExportNames() {
- List<String> result = new ArrayList<String>();
List<String> exportNames = ExportStorage.getExportNames();
- for (String export : exportNames) {
- result.add(export);
- }
+ List<String> result = new ArrayList<String>(exportNames);
return result;
}
@@ -626,11 +616,8 @@
* ResultUI
*/
- public void saveParametersResultNames(Object[] resultNames) {
- List<String> resultNamesString = new ArrayList<String>();
- for (Object o : resultNames) {
- resultNamesString.add(o.toString());
- }
+ public void saveParametersResultNames(List<String> resultNames) {
+ List<String> resultNamesString = new ArrayList<>(resultNames);
param.setResultEnabled(resultNamesString);
if (log.isDebugEnabled()) {
@@ -638,11 +625,8 @@
}
}
- public void saveConfigurationResultNames(Object[] resultNames) {
- List<String> resultNamesString = new ArrayList<String>();
- for (Object o : resultNames) {
- resultNamesString.add(o.toString());
- }
+ public void saveConfigurationResultNames(List<String> resultNames) {
+ List<String> resultNamesString = new ArrayList<>(resultNames);
IsisFish.config.setDefaultResultNames(resultNamesString);
if (log.isDebugEnabled()) {
@@ -1211,13 +1195,12 @@
public void populationSelected(final ParamsUI paramsUI) {
CardLayout layout = (CardLayout)paramsUI.getPopulationEffectivesPanel().getLayout();
- Object[] selectedPopulationsValues = paramsUI.getListSimulParamsPopulations().getSelectedValues();
- if (ArrayUtils.isNotEmpty(selectedPopulationsValues)) {
+ List<Population> selectedPopulationsValues = paramsUI.getListSimulParamsPopulations().getSelectedValuesList();
+ if (CollectionUtils.isNotEmpty(selectedPopulationsValues)) {
paramsUI.getPopulationEffectivesTabbedPane().removeAll();
setPopulations(selectedPopulationsValues);
- for (Object selectedPopulationValue : selectedPopulationsValues) {
- Population selectedPopulation = (Population)selectedPopulationValue;
+ for (Population selectedPopulation : selectedPopulationsValues) {
final MatrixPanelEditor matrixPanel = new MatrixPanelEditor();
MatrixND populationEffectives = getSimulationParameter().getNumberOf(selectedPopulation);
matrixPanel.setMatrix(populationEffectives);
1
0
r4221 - in trunk/src/main/java/fr/ifremer/isisfish/ui: script util vcs
by echatellier@users.forge.codelutin.com 07 May '15
by echatellier@users.forge.codelutin.com 07 May '15
07 May '15
Author: echatellier
Date: 2015-05-07 09:51:50 +0000 (Thu, 07 May 2015)
New Revision: 4221
Url: http://forge.codelutin.com/projects/isis-fish/repository/revisions/4221
Log:
Remove unused code (UI deprecated code)
Removed:
trunk/src/main/java/fr/ifremer/isisfish/ui/script/ExportDialogUI.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/script/ImportDialogUI.css
trunk/src/main/java/fr/ifremer/isisfish/ui/script/ImportDialogUI.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/script/action/
trunk/src/main/java/fr/ifremer/isisfish/ui/util/IDialog.java
trunk/src/main/java/fr/ifremer/isisfish/ui/util/IsisAction.java
trunk/src/main/java/fr/ifremer/isisfish/ui/util/IsisActionWithBackup.java
trunk/src/main/java/fr/ifremer/isisfish/ui/util/JaxxUtil.java
trunk/src/main/java/fr/ifremer/isisfish/ui/vcs/CommitDialogUI.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/vcs/UpdateConfirmDialogUI.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/vcs/UpdateDialogUI.jaxx
Modified:
trunk/src/main/java/fr/ifremer/isisfish/ui/script/ScriptAction.java
trunk/src/main/java/fr/ifremer/isisfish/ui/script/ScriptUI.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/vcs/VCSConfigUI.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/vcs/VCSGenerateSshKeyUI.jaxx
trunk/src/main/java/fr/ifremer/isisfish/ui/vcs/VCSPassPhraseUI.jaxx
Deleted: trunk/src/main/java/fr/ifremer/isisfish/ui/script/ExportDialogUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/script/ExportDialogUI.jaxx 2015-05-07 09:43:46 UTC (rev 4220)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/script/ExportDialogUI.jaxx 2015-05-07 09:51:50 UTC (rev 4221)
@@ -1,86 +0,0 @@
-<!--
- #%L
- IsisFish
-
- $Id$
- $HeadURL$
- %%
- Copyright (C) 2009 - 2010 Ifremer, CodeLutin
- %%
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as
- published by the Free Software Foundation, either version 3 of the
- License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public
- License along with this program. If not, see
- <http://www.gnu.org/licenses/gpl-3.0.html>.
- #L%
- -->
-<JDialog modal="true" resizable='false' title='isisfish.script.export'>
- <script>
-
-// public org.nuiton.vcs.ui.FieldModelUtil.ModuleFile model;
- public Object model = null;
- public boolean isOkEnabled() {
- return !isEmpty(); // && model.getSelected(0).size() > 0;
- }
- public boolean isEmpty() {
- return model == null; // || model.getRowCount() == 0;
- }
-
- public void doCheckAll() {
-// if (model!=null) model.checkAll();
- doRefresh();
- }
-
- public void doRefresh() {
- fr.ifremer.isisfish.ui.util.JaxxUtil.refresh(this,"items.enabled",
- "checkAll.enabled","ok.enabled","chooseDir.enabled",
- "archivePath.enabled");
- }
-
- </script>
- <Table anchor='center'>
- <row weighty="2">
- <cell columns='2' fill='both'>
- <JScrollPane id='table'>
- <JTable id="items" autoResizeMode='3'
- enabled='{!isEmpty()}' onMouseClicked="doRefresh()"/>
- </JScrollPane>
- </cell>
- </row>
- <row fill='horizontal'>
- <cell weightx="1" fill='both'>
- <JTextField id='archivePath' font-size='11' columns='30' height='25' enabled='{!isEmpty()}'/>
- </cell>
- <cell fill='both'>
- <JButton id='chooseDir'
- text='isisfish.script.export.chooseDir'
- toolTipText='isisfish.script.export.tooltip.chooseDir'
- enabled='{!isEmpty()}'
- />
- <!-- onActionPerformed="fr.ifremer.isisfish.ui.UIHelper.openDirChooser(archivePath,ok)" -->
- </cell>
- </row>
- <row fill='horizontal'>
- <cell columns="2" fill='both'>
- <JPanel layout='{new GridLayout(0, 3, 2, 2)}'>
- <JCheckBox id='checkAll'
- text='isisfish.script.export.checkAll'
- toolTipText='isisfish.script.export.tooltip.checkAll'
- enabled='{!isEmpty()}'
- onActionPerformed="doCheckAll()" />
- <JButton id='okButton'
- enabled='{isOkEnabled()}'/>
- <JButton id='cancelButton' />
- </JPanel>
- </cell>
- </row>
- </Table>
-</JDialog>
Deleted: trunk/src/main/java/fr/ifremer/isisfish/ui/script/ImportDialogUI.css
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/script/ImportDialogUI.css 2015-05-07 09:43:46 UTC (rev 4220)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/script/ImportDialogUI.css 2015-05-07 09:51:50 UTC (rev 4221)
@@ -1,31 +0,0 @@
-/*
- * #%L
- * IsisFish
- *
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2009 - 2010 Ifremer, CodeLutin
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-#newFilesLabel {
- foreground: "{new java.awt.Color(051,102,225)}";
-}
-
-#conflictFilesLabel {
- foreground: red;
-}
Deleted: trunk/src/main/java/fr/ifremer/isisfish/ui/script/ImportDialogUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/script/ImportDialogUI.jaxx 2015-05-07 09:43:46 UTC (rev 4220)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/script/ImportDialogUI.jaxx 2015-05-07 09:51:50 UTC (rev 4221)
@@ -1,127 +0,0 @@
-<!--
- #%L
- IsisFish
-
- $Id$
- $HeadURL$
- %%
- Copyright (C) 2009 - 2010 Ifremer, CodeLutin
- %%
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as
- published by the Free Software Foundation, either version 3 of the
- License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public
- License along with this program. If not, see
- <http://www.gnu.org/licenses/gpl-3.0.html>.
- #L%
- -->
-<JDialog modal="true" resizable='false' title='isisfish.script.import'>
- <import>
- java.io.File
- java.awt.Color
- </import>
- <style source="ImportDialogUI.css" />
-
- <FileSelectionTableModel id='newFilesTableModel' javaBean='null' />
- <FileSelectionTableModel id='conflictFilesTableModel' javaBean='null' />
-
- <Boolean id="okEnabled" javaBean='false' />
- <Boolean id="newItemEmpty" javaBean='false' />
- <Boolean id="conflictItemEmpty" javaBean='false' />
- <Boolean id="bothEmpty" javaBean='false' />
-
- <script><![CDATA[
-
- /*public boolean isOkEnabled() {
- return (!isConflictItemEmpty() && !conflictFilesTableModel.getSelectedFiles().isEmpty()) ||
- (!isNewItemEmpty() && !newFilesTableModel.getSelectedFiles().isEmpty());
- }*/
-
- public void refresh() {
- setConflictItemEmpty(conflictFilesTableModel.getRowCount() == 0);
- setNewItemEmpty(newFilesTableModel.getRowCount() == 0);
- setBothEmpty(isConflictItemEmpty() && isNewItemEmpty());
-
- setOkEnabled((!isConflictItemEmpty() && !conflictFilesTableModel.getSelectedFiles().isEmpty()) ||
- (!isNewItemEmpty() && !newFilesTableModel.getSelectedFiles().isEmpty()));
- }
-
- public void doCheckAll() {
- boolean selection = checkAllCheckbox.isSelected();
- newFilesTableModel.setAllChecked(selection);
- conflictFilesTableModel.setAllChecked(selection);
- }
-
- protected void performImport() {
- File archiveFile = new File(archivePath.getText());
- getContextValue(ScriptAction.class).performImportScript(archiveFile, newFilesTableModel, conflictFilesTableModel);
- }
-
- protected void cancel() {
- dispose();
- }
- ]]></script>
- <Table>
- <row weighty="1" fill='both'>
- <cell weighty="1" weightx="1" fill="both">
- <Table>
- <row>
- <cell weightx="1">
- <JLabel id='newFilesLabel' font-size='12' visible='{!isNewItemEmpty()}'
- text='isisfish.script.import.labelAdd' />
- </cell>
- </row>
- <row fill='both'>
- <cell weighty="1">
- <JScrollPane visible='{!isNewItemEmpty()}'>
- <JTable id="newFilesTable" autoResizeMode='{JTable.AUTO_RESIZE_LAST_COLUMN}'
- onMouseClicked="refresh()" />
- </JScrollPane>
- </cell>
- </row>
- <row>
- <cell weightx="1">
- <JLabel id='conflictFilesLabel' font-size='12' visible='{!isConflictItemEmpty()}'
- text='isisfish.script.import.labelOverwrite' />
- </cell>
- </row>
- <row fill='both' >
- <cell weighty="1">
- <JScrollPane visible='{!isConflictItemEmpty()}'>
- <JTable id="conflictFilesTable" autoResizeMode='{JTable.AUTO_RESIZE_LAST_COLUMN}'
- onMouseClicked="refresh()" />
- </JScrollPane>
- </cell>
- </row>
- </Table>
- </cell>
- </row>
- <row fill='horizontal'>
- <cell weightx="1" fill='both'>
- <JTextField id='archivePath' editable='false' height='25'/>
- </cell>
- </row>
- <row fill='horizontal'>
- <cell fill='both'>
- <JPanel layout='{new GridLayout(0, 3, 2, 2)}'>
- <JCheckBox id='checkAllCheckbox' text='isisfish.script.import.checkAll'
- toolTipText='isisfish.script.import.tooltip.checkAll'
- enabled='{!isBothEmpty()}'
- onActionPerformed='doCheckAll()'
- selected='true' />
- <JButton id='okButton' text='isisfish.script.import.import'
- enabled='{isOkEnabled()}'/>
- <JButton id='cancelButton' text='isisfish.script.import.cancel'
- onActionPerformed="cancel()" />
- </JPanel>
- </cell>
- </row>
- </Table>
-</JDialog>
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/script/ScriptAction.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/script/ScriptAction.java 2015-05-07 09:43:46 UTC (rev 4220)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/script/ScriptAction.java 2015-05-07 09:51:50 UTC (rev 4221)
@@ -5,7 +5,7 @@
* $Id$
* $HeadURL$
* %%
- * Copyright (C) 2006 - 2012 Ifremer, Code Lutin, Cédric Pineau, Benjamin Poussin, Chatellier Eric
+ * Copyright (C) 2006 - 2015 Ifremer, Code Lutin, Cédric Pineau, Benjamin Poussin, Chatellier Eric
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
@@ -89,7 +89,6 @@
import fr.ifremer.isisfish.ui.script.model.ScriptTree;
import fr.ifremer.isisfish.ui.script.model.ScriptTreeModel;
import fr.ifremer.isisfish.ui.util.ErrorHelper;
-import fr.ifremer.isisfish.ui.vcs.UpdateDialogUI;
import fr.ifremer.isisfish.util.CompileHelper;
import fr.ifremer.isisfish.util.JavadocHelper;
import fr.ifremer.isisfish.vcs.VCSException;
@@ -701,25 +700,6 @@
return scriptFileFilter;
}
- //public static Object updateScript()
- public void updateScript() {
- try {
- log.debug("updateScript called for ");
- //TODO Use VCS UI dialog
- UpdateDialogUI ui = new UpdateDialogUI();
- ui.setVisible(true);
- //TODO Use FileState new mechanism to obtain state
- if (codeStorage != null) {
- codeStorage.update();
- codeStorage.reload();
- }
- } catch (VCSException ex) {
- if (log.isErrorEnabled()) {
- log.error("Error on script update", ex);
- }
- }
- }
-
/**
* Check script content.
*
@@ -862,167 +842,6 @@
}
/**
- * Show a improved script dialog with multiple selection support.
- */
- public void importScript() {
-
- if (log.isDebugEnabled()) {
- log.debug("importScript ");
- }
-
- File root = IsisFish.config.getDatabaseDirectory();
- try {
- // ask user form a .zip file
- File file = FileUtil.getFile(".*.zip$",
- t("isisfish.message.import.scripts.zipped"));
- if (file != null) {
-
- //frame.setInfoText(t("isisfish.message.import.scripts.file", file));
-
- // get two list of relative path (one for new files,
- // one for exisiting files)
- List<String>[] explode = scanZip(file, root);
- List<String> newFiles = explode[0];
- List<String> conflictFiles = explode[1];
-
- // build model for dialog (list of new items), (list of exisiting items)
- FileSelectionTableModel modelNewItems = null;
- FileSelectionTableModel modelItems = null;
-
- // si'il y a des nouveau fichiers
- //if (!newFiles.isEmpty()) {
- modelNewItems = new FileSelectionTableModel(newFiles);
- //}
-
- // s'il y a des fichier en conflic
- //if (!conflictFiles.isEmpty()) {
- modelItems = new FileSelectionTableModel(conflictFiles);
- //}
-
- // create import dialog
- // TODO do a better code
- ImportDialogUI dialog = new ImportDialogUI();
- dialog.setNewFilesTableModel(modelNewItems);
- dialog.setConflictFilesTableModel(modelItems);
- dialog.getConflictFilesTable().setModel(modelItems);
- dialog.getNewFilesTable().setModel(modelNewItems);
- // can't be in ui :(
- dialog.getNewFilesTable().getColumnModel().getColumn(0)
- .setWidth(30);
- dialog.getConflictFilesTable().getColumnModel().getColumn(0)
- .setWidth(30);
- dialog.getArchivePath().setText(file.getAbsolutePath());
- dialog.refresh();
- dialog.pack();
- SwingUtil.center(dialog);
- dialog.setVisible(true);
- setStatusMessage(t("isisfish.message.import.scripts.file.done", file));
- } else {
- setStatusMessage(t("isisfish.message.import.scripts.file.cancelled"));
- }
- } catch (Exception eee) {
- returnError(t("isisfish.error.script.import", eee.getMessage()),
- eee);
- }
- }
-
- /**
- * Perform import script action called by {@link ImportDialogUI}.
- *
- * @param sourceScriptArchive source archive file
- * @param selectedFiles selected non conflict files model
- * @param selectedConflictFiles selected conflict files model
- */
- public void performImportScript(File sourceScriptArchive,
- FileSelectionTableModel selectedFiles,
- FileSelectionTableModel selectedConflictFiles) {
-
- File sourceDirectory = IsisFish.config.getDatabaseDirectory();
-
- List<String> filesToImports = new ArrayList<String>();
- if (selectedFiles != null) {
- filesToImports.addAll(selectedFiles.getSelectedFiles());
- }
-
- if (selectedConflictFiles != null) {
- // do backup stuff (only backup conflict files)
- backupScripts(selectedConflictFiles.getSelectedFiles(),
- sourceDirectory);
-
- filesToImports.addAll(selectedConflictFiles.getSelectedFiles());
- }
-
- // unflate files to destination (root)
- try {
- if (log.isInfoEnabled()) {
- for (String newFile : filesToImports) {
- log.info("unzip " + newFile);
- }
- }
- ZipUtil.uncompress(sourceScriptArchive, sourceDirectory,
- filesToImports, null, null);
-
- } catch (IOException e1) {
- throw new RuntimeException(e1);
- }
- if (log.isInfoEnabled()) {
- log.info("Unzip " + filesToImports.size() + " entry(ies) from '"
- + sourceScriptArchive + "'");
- }
- }
-
- /**
- * Make a backup a given files to current isis backup directory.
- *
- * @param paths
- */
- protected void backupScripts(List<String> paths, File destination) {
-
- File backupDirectory = IsisFish.config.getBackupSessionDirectory();
-
- if (log.isDebugEnabled()) {
- log.debug("Backup directory is : " + backupDirectory);
- }
- String suffix = "_"
- + IsisFish.config.getBackupSessionDirectory().getName();
- try {
- for (String path : paths) {
-
- //backup(new File(src, path), path, suffix);
-
- File sourceFile = new File(destination, path);
-
- if (!sourceFile.exists()) {
- return;
- }
- if (sourceFile.isDirectory()) {
- File dst = new File(backupDirectory, path);
- dst.mkdirs();
- } else {
- int extension = path.lastIndexOf(".");
- if (extension != -1) {
- path = path.substring(0, extension) + suffix + "."
- + path.substring(extension + 1);
- } else {
- path += suffix;
- }
- File dst = new File(destination, path);
- if (!dst.getParentFile().exists()) {
- dst.getParentFile().mkdirs();
- }
- if (log.isInfoEnabled()) {
- log.info("Copying " + sourceFile.getName() + " to "
- + dst);
- }
- FileUtils.copyFile(sourceFile, dst);
- }
- }
- } catch (Exception ex) {
- throw new IsisFishRuntimeException("Can't backup scripts", ex);
- }
- }
-
- /**
* Copy a single file to destination directory.
*
* @param src file to copy
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/script/ScriptUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/script/ScriptUI.jaxx 2015-05-07 09:43:46 UTC (rev 4220)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/script/ScriptUI.jaxx 2015-05-07 09:51:50 UTC (rev 4221)
@@ -5,7 +5,7 @@
$Id$
$HeadURL$
%%
- Copyright (C) 2009 - 2014 Ifremer, CodeLutin, Chatellier Eric
+ Copyright (C) 2009 - 2015 Ifremer, CodeLutin, Chatellier Eric
%%
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as
@@ -71,11 +71,6 @@
<JMenuItem id="miSave" text="isisfish.script.menu.save"
onActionPerformed="getScriptAction().saveScript()" icon="script_save.png" enabled='{isSingleFileSelected()}' />
<JSeparator/>
- <JMenuItem id="miImport" text="isisfish.script.menu.txtImport"
- enabled="false" onActionPerformed="getScriptAction().importScript()" icon="page_white_compressed.png" />
- <JMenuItem id="miExport" text="isisfish.script.menu.txtExport"
- onActionPerformed="getScriptAction().exportScript()" icon="page_white_compressed.png" enabled='{isFileSelected()}' />
- <JSeparator/>
<JMenuItem id="miDelete" text="isisfish.script.menu.deleteLocaly"
onActionPerformed='getScriptAction().deleteScript(false)' icon="script_delete.png" enabled='{isSingleFileSelected()}' />
</JMenu>
@@ -92,8 +87,6 @@
onActionPerformed="getScriptAction().commitScript()" enabled='{isSingleFileSelected()}' />
<JMenuItem id="miDiffVCS" text="isisfish.script.menu.diff" accelerator="mnDiffVCS"
onActionPerformed="getScriptAction().diffScript()" enabled='{isSingleFileSelected()}' />
- <JMenuItem id="miUpdateVCS" text="isisfish.script.menu.update" icon="database_refresh.png"
- onActionPerformed="getScriptAction().updateScript()"/>
<JSeparator/>
<JMenuItem id="miDeleteVCS" text="isisfish.script.menu.deleteLocalyServer"
onActionPerformed='getScriptAction().deleteScript(true)' icon="database_delete.png"/>
Deleted: trunk/src/main/java/fr/ifremer/isisfish/ui/util/IDialog.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/util/IDialog.java 2015-05-07 09:43:46 UTC (rev 4220)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/util/IDialog.java 2015-05-07 09:51:50 UTC (rev 4221)
@@ -1,84 +0,0 @@
-/*
- * #%L
- * IsisFish
- *
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2009 - 2010 Ifremer, CodeLutin
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-
-package fr.ifremer.isisfish.ui.util;
-
-import javax.swing.AbstractAction;
-import javax.swing.JButton;
-import java.awt.Dimension;
-
-public interface IDialog {
- /**
- * @return the ok button (jaxx generated)
- */
- JButton getOk();
-
- /**
- * @return the cancel button (jaxx generated)
- */
- JButton getCancel();
-
- /**
- * to doRefresh dialog (use processDataBinding)
- */
- void doRefresh();
-
- /**
- * @return <code>true</code> if ok button is enabled, <code>false</code>
- * otherwise
- */
- boolean isOkEnabled();
-
- /**
- * @return <code>true</code> if dialog has no data, <code>false</code>
- * otherwise
- */
- boolean isEmpty();
-
- int computeWidth();
-
- int computeHeight();
-
- // ------------------ JDialog methods
- void setVisible(boolean b);
-
- void setSize(int width, int height);
-
- void setMaximumSize(Dimension dimension);
-
- void setOkAction(AbstractAction okAction);
-
- void setCancelAction(AbstractAction cancelAction);
-
- void setMaxWidth(int maxWidth);
-
- void setMinHeight(int minHeight);
-
- void setMaxHeight(int maxHeight);
-
- void repaint();
-
- void setTitle(String s);
-}
Deleted: trunk/src/main/java/fr/ifremer/isisfish/ui/util/IsisAction.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/util/IsisAction.java 2015-05-07 09:43:46 UTC (rev 4220)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/util/IsisAction.java 2015-05-07 09:51:50 UTC (rev 4221)
@@ -1,113 +0,0 @@
-/*
- * #%L
- * IsisFish
- *
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2009 - 2010 Ifremer, CodeLutin
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-
-package fr.ifremer.isisfish.ui.util;
-
-import javax.swing.AbstractAction;
-import javax.swing.JDialog;
-import java.awt.event.ActionEvent;
-
-public abstract class IsisAction extends AbstractAction {
- /**
- * flag to say if something has been done in this action (is init in
- * {@link #prepare()} method)
- */
- protected boolean used;
- /**
- * dialog source of the action (of <code>null</code> if none)
- */
- protected JDialog dialog;
-
- private static final long serialVersionUID = -968662451138199001L;
-
- protected IsisAction() {
- this(null);
- }
-
- protected IsisAction(JDialog dialog) {
- this.dialog = dialog;
- }
-
-
- public void actionPerformed(ActionEvent e) {
-
- try {
- // just prepare action and set used field value
- used = prepare();
-
- // perform action if there is something to do
- if (used) {
- perform(e);
- }
- } finally {
- //TODO Fix lock between few dialog
- // after action perfored
- finish();
- }
- }
- /**
- * Prepare data for action, and find out if there is really something to
- * do here.
- *
- * @return <code>true</code> if there is something to do here,
- * <code>false</code> otherwise
- */
- protected abstract boolean prepare();
-
- /**
- * perform safelly action after {@link #prepare()} was invoked
- * This method is only called if used was <code>true</code>
- *
- * @param e event source
- */
- protected abstract void perform(ActionEvent e);
-
- /**
- * called inside {@link #actionPerformed(java.awt.event.ActionEvent)} after
- * {@link #perform(java.awt.event.ActionEvent)} was invoked (so can't
- * be come here is nothing was to be done in this action.
- */
- protected void finish() {
- if (dialog != null && needDispose()) {
- dialog.dispose();
- }
- }
-
- /**
- * @return <code>true</code> if we have to dispose dialog,
- * <code>false</code> otherwise
- */
- protected boolean needDispose() {
- return used;
- }
-
- /**
- * @return <code>true</code> if something was done in the action performed,
- * <code>false</code> otherwise
- */
- public boolean isUsed() {
- return used;
- }
-}
Deleted: trunk/src/main/java/fr/ifremer/isisfish/ui/util/IsisActionWithBackup.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/util/IsisActionWithBackup.java 2015-05-07 09:43:46 UTC (rev 4220)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/util/IsisActionWithBackup.java 2015-05-07 09:51:50 UTC (rev 4221)
@@ -1,87 +0,0 @@
-/*
- * #%L
- * IsisFish
- *
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2009 - 2010 Ifremer, CodeLutin
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-
-package fr.ifremer.isisfish.ui.util;
-
-import java.awt.event.ActionEvent;
-import java.io.File;
-import java.util.List;
-
-import javax.swing.JDialog;
-
-import fr.ifremer.isisfish.IsisFish;
-import fr.ifremer.isisfish.ui.script.action.BackupAction;
-
-/**
- * This abstract action perform a backup action.
- *
- * @author chatellier
- * @version $Revision$
- *
- * Last update : $Date$
- * By : $Author$
- *
- * @deprecated C'est pas evident de faire des Actions swing avec jaxx
- */
-public abstract class IsisActionWithBackup extends IsisAction {
-
- /** serialVersionUID. */
- private static final long serialVersionUID = -5498329861390316586L;
-
- /** Root directory of files to be backupped. */
- protected File root;
-
- /**
- * Constructor.
- *
- * @param dialog dialog ???
- * @param root root directory of files to be backupped
- */
- protected IsisActionWithBackup(JDialog dialog, File root) {
- super(dialog);
- this.root = root;
- }
-
- /**
- * obtain the list of relative path to {@link #root} directory needed
- * to be backuped in {@code #backupRoot} directory
- *
- * @return the list of relative path to files to backup
- */
- protected abstract List<String> getFilesToBackup();
-
- /**
- * Just perform a {@link BackupAction}.
- *
- * Need to be overridden and called by {@code super.perform(e)}
- */
- @Override
- protected void perform(ActionEvent e) {
- // do backup stuff here
- BackupAction backupAction = new BackupAction(root, IsisFish.config
- .getBackupSessionDirectory(), getFilesToBackup());
- backupAction.actionPerformed(e);
- }
-}
Deleted: trunk/src/main/java/fr/ifremer/isisfish/ui/util/JaxxUtil.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/util/JaxxUtil.java 2015-05-07 09:43:46 UTC (rev 4220)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/util/JaxxUtil.java 2015-05-07 09:51:50 UTC (rev 4221)
@@ -1,70 +0,0 @@
-/*
- * #%L
- * IsisFish
- *
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2009 - 2010 Ifremer, CodeLutin
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-package fr.ifremer.isisfish.ui.util;
-
-import jaxx.runtime.JAXXObject;
-
-import javax.swing.JCheckBox;
-import javax.swing.JComboBox;
-import javax.swing.JTextField;
-import java.util.Map;
-
-/** some util generic algorithm for jaxx objects */
-public class JaxxUtil {
-
- public static void doReset(Map<String, ?> $objectMap) {
-
- if ($objectMap == null) return;
-
- for (Map.Entry<String, ?> o : $objectMap.entrySet()) {
- Class aClass = o.getValue().getClass();
- Object val = o.getValue();
- if (JTextField.class.isAssignableFrom(aClass))
- ((JTextField) val).setText("");
- else if (JCheckBox.class.isAssignableFrom(aClass))
- ((JCheckBox) val).setSelected(false);
- else if (JComboBox.class.isAssignableFrom(aClass))
- ((JComboBox) val).setSelectedIndex(-1);
- }
- }
-
- /**
- * Refresh dialog and process data binding for given keys
- *
- * @param dial jaxx dialog
- * @param keyFirst first to refresh
- * @param keys keys to refresh
- */
- public static void refresh(JAXXObject dial, String keyFirst, String... keys) {
- if (!IDialog.class.isAssignableFrom(dial.getClass())) return;
-
- IDialog dialog = (IDialog) dial;
- dialog.getOk().setEnabled(dialog.isOkEnabled());
- dial.processDataBinding(keyFirst);
- for (String key : keys) dial.processDataBinding(key);
- dialog.repaint();
- }
-}
-
Deleted: trunk/src/main/java/fr/ifremer/isisfish/ui/vcs/CommitDialogUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/vcs/CommitDialogUI.jaxx 2015-05-07 09:43:46 UTC (rev 4220)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/vcs/CommitDialogUI.jaxx 2015-05-07 09:51:50 UTC (rev 4221)
@@ -1,88 +0,0 @@
-<!--
- #%L
- IsisFish
-
- $Id$
- $HeadURL$
- %%
- Copyright (C) 2009 - 2010 Ifremer, CodeLutin
- %%
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as
- published by the Free Software Foundation, either version 3 of the
- License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public
- License along with this program. If not, see
- <http://www.gnu.org/licenses/gpl-3.0.html>.
- #L%
- -->
-<JDialog modal="true" title='isisfish.vcs.commit'>
- <import>
- java.awt.Color
- </import>
- <script><![CDATA[
- // FIXME a refaire
-
-// protected ModuleFile<VCSFileState> model;
- protected Object model;
-
- public CommitDialogUI(Dialog owner, boolean modal) {
- super(owner, modal);
-
- }
- public boolean isEmpty() {
- return items.getRowCount()==0;
- }
- public boolean isOkEnabled() {
- return !isEmpty();
- }
- public void doRefresh() {
- fr.ifremer.isisfish.ui.util.JaxxUtil.refresh(this,"ok.enabled");
- }
- protected void reSize(JTable table) {
- // implements me...
- }
- ]]>
- </script>
- <Table weightx="1">
- <row>
- <cell columns='2'>
- <JLabel id='label' font-size='12'
- foreground='{new Color(051,102,225)}'
- text='isisfish.vcs.commit.label'/>
- </cell>
- </row>
- <row>
- <cell columns='2' weighty="1" weightx='1' fill='both'>
- <JScrollPane id='scroll' verticalScrollBarPolicy='20' >
- <JTable id="items" onComponentResized="reSize(items)"/>
- </JScrollPane>
- </cell>
- </row>
- <row>
- <cell columns='2' fill='horizontal'>
- <JScrollPane height='50' verticalScrollBarPolicy='21'
- horizontalScrollBarPolicy='30'>
- <JTextArea id='message' rows='2' columns='80'/>
- </JScrollPane>
- </cell>
- </row>
- <row weightx="1" fill='horizontal'>
- <cell>
- <JButton id='ok' text='isisfish.vcs.commit.ok'
- enabled='{isOkEnabled()}'
- onActionPerformed='/*fr.ifremer.isisfish.versionning.ui.VCSUIHelper.COMMIT_MSG=message.getText();*/dispose()'/>
- </cell>
- <cell>
- <JButton id='cancel' text='isisfish.vcs.commit.cancel'
- onActionPerformed='dispose()'/>
- </cell>
- </row>
- </Table>
-</JDialog>
Deleted: trunk/src/main/java/fr/ifremer/isisfish/ui/vcs/UpdateConfirmDialogUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/vcs/UpdateConfirmDialogUI.jaxx 2015-05-07 09:43:46 UTC (rev 4220)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/vcs/UpdateConfirmDialogUI.jaxx 2015-05-07 09:51:50 UTC (rev 4221)
@@ -1,94 +0,0 @@
-<!--
- #%L
- IsisFish
-
- $Id$
- $HeadURL$
- %%
- Copyright (C) 2009 - 2010 Ifremer, CodeLutin
- %%
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as
- published by the Free Software Foundation, either version 3 of the
- License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public
- License along with this program. If not, see
- <http://www.gnu.org/licenses/gpl-3.0.html>.
- #L%
- -->
-<JDialog modal="true" title='isisfish.vcs.updateconfirm'>
- <import>
- java.awt.Color
- </import>
- <script><![CDATA[
- // FIXME a refaire
-
-// protected ModuleFile<VCSFileState> model;
- protected Object model;
-
- public void doCheckAll() {
-// if (model != null && model.getRowCount()>0) {
-// model.checkAll();
-// doRefresh();
-// }
- }
- public boolean isEmpty() {
- return model==null; // || model.getRowCount()==0;
- }
- public boolean isOkEnabled() {
- return !isEmpty(); // && model.getSelectedSize(0)>0;
- }
- protected void reSize(JTable table) {
- // implements me...
- }
- public void doRefresh() {
- fr.ifremer.isisfish.ui.util.JaxxUtil.refresh(this,"checkAll.enabled","ok.enabled");
- }
- ]]>
- </script>
- <Table weightx="1">
- <row>
- <cell columns='4'>
- <JLabel font-size='12' foreground='{new Color(051,102,225)}'
- text='isisfish.vcs.updateconfirm.label'/>
- </cell>
- </row>
- <row>
- <cell columns='4'>
- <JLabel id='label2' font-size='12' foreground='{Color.RED}'
- text='isisfish.vcs.updateconfirm.label2'/>
- </cell>
- </row>
- <row>
- <cell columns='4' weighty="1" fill='both'>
- <JScrollPane id='table'>
- <JTable id="items" autoResizeMode='3'
- rowSelectionAllowed="true"
- onMouseClicked="doRefresh()"
- onComponentResized="reSize(items)"/>
- </JScrollPane>
- </cell>
- </row>
- <row weightx="1" fill='horizontal'>
- <cell columns="2" fill='both'>
- <JPanel layout='{new GridLayout(0, 3, 2, 2)}'>
- <JCheckBox id='checkAll'
- text='isisfish.vcs.updateconfirm.checkAll'
- toolTipText='isisfish.vcs.updateconfirm.tooltip.checkAll'
- enabled='{!isEmpty()}'
- onActionPerformed="doCheckAll()"/>
- <JButton id='ok' text='isisfish.vcs.updateconfirm.ok'
- enabled='{isOkEnabled()}'/>
- <JButton id='cancel'
- text='isisfish.vcs.updateconfirm.cancel'/>
- </JPanel>
- </cell>
- </row>
- </Table>
-</JDialog>
Deleted: trunk/src/main/java/fr/ifremer/isisfish/ui/vcs/UpdateDialogUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/vcs/UpdateDialogUI.jaxx 2015-05-07 09:43:46 UTC (rev 4220)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/vcs/UpdateDialogUI.jaxx 2015-05-07 09:51:50 UTC (rev 4221)
@@ -1,187 +0,0 @@
-<!--
- #%L
- IsisFish
-
- $Id$
- $HeadURL$
- %%
- Copyright (C) 2009 - 2010 Ifremer, CodeLutin
- %%
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as
- published by the Free Software Foundation, either version 3 of the
- License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public
- License along with this program. If not, see
- <http://www.gnu.org/licenses/gpl-3.0.html>.
- #L%
- -->
-<JDialog modal="true" title='isisfish.vcs.update'>
- <script><![CDATA[
- // FIXME a refaire
-
-// protected org.nuiton.vcs.VCSRepositoryState model;
- protected Object model;
-
- public void doCheckAll() {
-// if (model!=null) {
-// model.checkAll(checkAll.isSelected());
-// doRefresh();
-// }
- }
-
- public boolean isEmpty() {
- return model==null; // || model.isModelEmpty();
- }
-
- public boolean isOkEnabled() {
- return !isEmpty(); // && model.getModelSelectedSize()>0;
- }
-
- public void doRefresh() {
- fr.ifremer.isisfish.ui.util.JaxxUtil.refresh(this,"checkAll.enabled","ok.enabled");
- }
-
-// protected void reSize(VCSState state,JTable table) {
-//
-// }
- ]]>
- </script>
- <Table weightx="1">
- <row>
- <cell columns='3' weighty="1" fill='both'>
- <JSplitPane id='splitPane' orientation='vertical'
- oneTouchExpandable='true'>
- <JSplitPane id='splitPane2' orientation='horizontal'
- oneTouchExpandable='true'>
- <Table weightx="1" id='tableRemote'>
- <row>
- <cell columns="2" anchor='northwest'>
- <JLabel text='isisfish.vcs.update.remote'
- toolTipText='isisfish.vcs.update.tooltip.remote'/>
- </cell>
- </row>
- <row>
- <cell>
- <JLabel id='label_missing'
- text='isisfish.vcs.update.remote.missing'
- toolTipText='isisfish.vcs.update.remote.tooltip.missing'/>
- </cell>
- </row>
- <row>
- <cell weighty="1" fill='both'>
- <JScrollPane id='scroll_missing'>
- <JTable id="table_missing"
- autoResizeMode='3'
- onMouseClicked="doRefresh()"/>
- </JScrollPane>
- </cell>
- </row>
- <row>
- <cell>
- <JLabel id='label_outofdate'
- text='isisfish.vcs.update.remote.outofdate'
- toolTipText='isisfish.vcs.update.remote.tooltip.outofdate'/>
- </cell>
- </row>
- <row>
- <cell weighty="1" fill='both'>
- <JScrollPane id='scroll_outofdate'>
- <JTable id="table_outofdate"
- autoResizeMode='3'
- onMouseClicked="doRefresh()"
- rowSelectionAllowed="true"/>
- </JScrollPane>
- </cell>
- </row>
- </Table>
- <Table weightx="1" id='tableLocal'>
- <row>
- <cell columns="2" anchor='west'>
- <JLabel text='isisfish.vcs.update.local'
- toolTipText='isisfish.vcs.update.tooltip.local'/>
- </cell>
- </row>
- <row>
- <cell>
- <JLabel id='label_unversionned'
- text='isisfish.vcs.update.local.unversionned'
- toolTipText='isisfish.vcs.update.local.tooltip.unversionned'/>
- </cell>
- </row>
- <row>
- <cell weighty="1" fill='both'>
- <JScrollPane id='scroll_unversionned'>
- <JTable id="table_unversionned"
- autoResizeMode='3'
- rowSelectionAllowed="true"
- onMouseClicked="doRefresh()"/>
- </JScrollPane>
- </cell>
- </row>
- <row>
- <cell>
- <JLabel id='label_modified'
- text='isisfish.vcs.update.local.modified'
- toolTipText='isisfish.vcs.update.local.tooltip.modified'/>
- </cell>
- </row>
- <row>
- <cell weighty="1" fill='both'>
- <JScrollPane id='scroll_modified'>
- <JTable id="table_modified"
- autoResizeMode='3'
- rowSelectionAllowed="true"
- onMouseClicked="doRefresh()"/>
- </JScrollPane>
- </cell>
- </row>
- <row>
- <cell>
- <JLabel id='label_outofdateAndModified'
- text='isisfish.vcs.update.local.outofdateAndModified'
- toolTipText='isisfish.vcs.update.local.tooltip.outofdateAndModified'/>
- </cell>
- </row>
- <row>
- <cell weighty="1" fill='both'>
- <JScrollPane id='scroll_outofdateAndModified'>
- <JTable id="table_outofdateAndModified"
- autoResizeMode='3'
- rowSelectionAllowed="true"
- onMouseClicked="doRefresh()"/>
- </JScrollPane>
- </cell>
- </row>
- </Table>
- </JSplitPane>
- <JScrollPane>
- <JTextPane id="logText" editable="false"
- focusable='false'/>
- </JScrollPane>
- </JSplitPane>
- </cell>
- </row>
- <row weightx="1" fill='horizontal'>
- <cell columns="3" fill='both'>
- <JPanel layout='{new GridLayout(0, 3, 2, 2)}'>
- <JCheckBox id='checkAll'
- text='isisfish.vcs.update.checkAll'
- toolTipText='isisfish.vcs.update.tooltip.checkAll'
- enabled='{!isEmpty()}'
- onActionPerformed="doCheckAll()"/>
- <JButton id='ok' text='isisfish.vcs.update.ok'
- enabled='{isOkEnabled()}'
- onActionPerformed="dispose()"/>
- <JButton id='cancel' text='isisfish.vcs.update.cancel'/>
- </JPanel>
- </cell>
- </row>
- </Table>
-</JDialog>
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/vcs/VCSConfigUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/vcs/VCSConfigUI.jaxx 2015-05-07 09:43:46 UTC (rev 4220)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/vcs/VCSConfigUI.jaxx 2015-05-07 09:51:50 UTC (rev 4221)
@@ -5,7 +5,7 @@
$Id$
$HeadURL$
%%
- Copyright (C) 2009 - 2010 Ifremer, CodeLutin
+ Copyright (C) 2009 - 2015 Ifremer, CodeLutin
%%
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/vcs/VCSGenerateSshKeyUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/vcs/VCSGenerateSshKeyUI.jaxx 2015-05-07 09:43:46 UTC (rev 4220)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/vcs/VCSGenerateSshKeyUI.jaxx 2015-05-07 09:51:50 UTC (rev 4221)
@@ -5,7 +5,7 @@
$Id$
$HeadURL$
%%
- Copyright (C) 2009 - 2010 Ifremer, CodeLutin
+ Copyright (C) 2009 - 2015 Ifremer, CodeLutin
%%
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/vcs/VCSPassPhraseUI.jaxx
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/vcs/VCSPassPhraseUI.jaxx 2015-05-07 09:43:46 UTC (rev 4220)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/vcs/VCSPassPhraseUI.jaxx 2015-05-07 09:51:50 UTC (rev 4221)
@@ -5,7 +5,7 @@
$Id$
$HeadURL$
%%
- Copyright (C) 2009 - 2010 Ifremer, CodeLutin
+ Copyright (C) 2009 - 2015 Ifremer, CodeLutin
%%
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as
1
0