r297 - in trunk: tutti-persistence/src/main/java/fr/ifremer/tutti/persistence tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service tutti-persistence/src/main/xmi tutti-persistence-adagio/src/main/java/fr/ifremer/tutti/persistence tutti-persistence-adagio/src/main/java/fr/ifremer/tutti/persistence/service tutti-persistence-dev/src/main/java/fr/ifremer/tutti/persistence tutti-service/src/main/java/fr/ifremer/
Author: tchemit Date: 2013-02-01 23:27:32 +0100 (Fri, 01 Feb 2013) New Revision: 297 Url: http://forge.codelutin.com/projects/tutti/repository/revisions/297 Log: - suppression des propri?\195?\169t?\195?\169s de FishingOperation - utilisation des actions pour la supresion de lots - ajout de l'action de renommage (pas encore implant?\195?\169) - action de suppression des protocoles Added: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/DeleteProtocolAction.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/RemoveSpeciesBatchAction.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/RemoveSpeciesSubBatchAction.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/RenameSpeciesBatchAction.java trunk/tutti-ui-swing/src/main/resources/icons/action-batch-rename.png Modified: trunk/tutti-persistence-adagio/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistenceAdagioImpl.java trunk/tutti-persistence-adagio/src/main/java/fr/ifremer/tutti/persistence/service/ProtocolPersistenceServiceImpl.java trunk/tutti-persistence-dev/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistenceDevImpl.java trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistence.java trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/TuttiEntities.java trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/ProtocolPersistenceService.java trunk/tutti-persistence/src/main/xmi/tutti-persistence.zargo trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/PersistenceService.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/ChangeScreenAction.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/TuttiUIContext.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/ExportProtocolAction.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/SelectCruiseUI.css trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/SelectCruiseUI.jaxx trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/SelectCruiseUIHandler.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/CancelEditFishingOperationAction.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUI.css trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUI.jaxx trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIHandler.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIModel.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/CreateSpeciesBatchUIModel.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/ExportProtocolSpeciesAction.java trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistence.java =================================================================== --- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistence.java 2013-02-01 18:37:33 UTC (rev 296) +++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistence.java 2013-02-01 22:27:32 UTC (rev 297) @@ -206,6 +206,8 @@ List<TuttiProtocol> getAllProtocol(); + boolean isProtocolExist(String id); + TuttiProtocol getProtocol(String id); @Transactional(readOnly = false) Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/TuttiEntities.java =================================================================== --- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/TuttiEntities.java 2013-02-01 18:37:33 UTC (rev 296) +++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/TuttiEntities.java 2013-02-01 22:27:32 UTC (rev 297) @@ -33,6 +33,7 @@ import fr.ifremer.tutti.persistence.entities.data.FishingOperationAware; import fr.ifremer.tutti.persistence.entities.referential.Caracteristic; import fr.ifremer.tutti.persistence.entities.referential.CaracteristicType; +import org.apache.commons.collections.CollectionUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.hibernate.cfg.Environment; @@ -290,4 +291,15 @@ return CaracteristicType.QUALITATIVE == c.getCaracteristicType(); } + public static <E> List<E> getList(List<E> list) { + List<E> result; + if (CollectionUtils.isEmpty(list)) { + result = Lists.newArrayList(); + } else { + result = Lists.newArrayList(list); + } + + return result; + } + } Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/ProtocolPersistenceService.java =================================================================== --- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/ProtocolPersistenceService.java 2013-02-01 18:37:33 UTC (rev 296) +++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/ProtocolPersistenceService.java 2013-02-01 22:27:32 UTC (rev 297) @@ -37,6 +37,8 @@ //@Transactional(readOnly = true) public interface ProtocolPersistenceService { + boolean isProtocolExist(String id); + List<String> getAllProtocolId(); List<String> getAllProtocolNames(); Modified: trunk/tutti-persistence/src/main/xmi/tutti-persistence.zargo =================================================================== (Binary files differ) Modified: trunk/tutti-persistence-adagio/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistenceAdagioImpl.java =================================================================== --- trunk/tutti-persistence-adagio/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistenceAdagioImpl.java 2013-02-01 18:37:33 UTC (rev 296) +++ trunk/tutti-persistence-adagio/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistenceAdagioImpl.java 2013-02-01 22:27:32 UTC (rev 297) @@ -301,6 +301,11 @@ //------------------------------------------------------------------------// @Override + public boolean isProtocolExist(String id) { + return protocolService.isProtocolExist(id); + } + + @Override public List<String> getAllProtocolNames() { return protocolService.getAllProtocolId(); } Modified: trunk/tutti-persistence-adagio/src/main/java/fr/ifremer/tutti/persistence/service/ProtocolPersistenceServiceImpl.java =================================================================== --- trunk/tutti-persistence-adagio/src/main/java/fr/ifremer/tutti/persistence/service/ProtocolPersistenceServiceImpl.java 2013-02-01 18:37:33 UTC (rev 296) +++ trunk/tutti-persistence-adagio/src/main/java/fr/ifremer/tutti/persistence/service/ProtocolPersistenceServiceImpl.java 2013-02-01 22:27:32 UTC (rev 297) @@ -25,7 +25,7 @@ */ import com.google.common.collect.Lists; -import fr.ifremer.tutti.persistence.config.TuttiPersistenceAdagioConfig; +import fr.ifremer.tutti.persistence.entities.TuttiEntities; import fr.ifremer.tutti.persistence.entities.protocol.SpeciesProtocol; import fr.ifremer.tutti.persistence.entities.protocol.TuttiProtocol; import fr.ifremer.tutti.persistence.entities.protocol.TuttiProtocols; @@ -56,6 +56,11 @@ public static final String TUTTI_PROTOCOL_EXTENSION = "tuttiProtocol"; @Override + public boolean isProtocolExist(String id) { + return getAllProtocolId().contains(id); + } + + @Override public List<String> getAllProtocolId() { File protocolDirectory = config.getProtocolDirectory(); @@ -114,18 +119,21 @@ TuttiProtocol result = new TuttiProtocol(); protocolBinder.copy(bean, result); result.setId(UUID.randomUUID().toString()); - result.setLengthClassesPmfmId(Lists.newArrayList(bean.getLengthClassesPmfmId())); - result.setEnvironmentPmfmId(Lists.newArrayList(bean.getEnvironmentPmfmId())); - result.setGearPmfmId(Lists.newArrayList(bean.getGearPmfmId())); - result.setHydrologyPmfmId(Lists.newArrayList(bean.getHydrologyPmfmId())); + + result.setLengthClassesPmfmId(TuttiEntities.getList(bean.getLengthClassesPmfmId())); + result.setEnvironmentPmfmId(TuttiEntities.getList(bean.getEnvironmentPmfmId())); + result.setGearPmfmId(TuttiEntities.getList(bean.getGearPmfmId())); + result.setHydrologyPmfmId(TuttiEntities.getList(bean.getHydrologyPmfmId())); Binder<SpeciesProtocol, SpeciesProtocol> speciesProtocolBinder = BinderFactory.newBinder(SpeciesProtocol.class); List<SpeciesProtocol> species = Lists.newArrayList(); - for (SpeciesProtocol speciesProtocol : bean.getSpecies()) { - SpeciesProtocol s = new SpeciesProtocol(); - speciesProtocolBinder.copy(speciesProtocol, s); - s.setId(UUID.randomUUID().toString()); - species.add(s); + if (!bean.isSpeciesEmpty()) { + for (SpeciesProtocol speciesProtocol : bean.getSpecies()) { + SpeciesProtocol s = new SpeciesProtocol(); + speciesProtocolBinder.copy(speciesProtocol, s); + s.setId(UUID.randomUUID().toString()); + species.add(s); + } } result.setSpecies(species); @@ -169,51 +177,6 @@ } } - -// @Override -// public void toFile(TuttiProtocol protocol, File file) throws IOException { -// -// String id = protocol.getId(); -// -// BufferedWriter fileWriter = Files.newWriter(file, Charsets.UTF_8); -// try { -// YamlWriter writer = new YamlWriter(fileWriter, createConfig()); -// writer.write(protocol); -// writer.close(); -// fileWriter.close(); -// } catch (YamlException e) { -// throw new IOException("Could not transform protocol " + id + " to file " + file, e); -// } finally { -// Closeables.closeQuietly(fileWriter); -// } -// } -// -// @Override -// public TuttiProtocol fromFile(File file) throws IOException { -// -// -// Reader fileReader = Files.newReader(file, Charsets.UTF_8); -// try { -// YamlReader reader = new YamlReader(fileReader, createConfig()); -// TuttiProtocol result = reader.read(TuttiProtocol.class); -// fileReader.close(); -// return result; -// } catch (YamlException e) { -// throw new IOException("Could not import protocol from file " + file, e); -// } finally { -// Closeables.closeQuietly(fileReader); -// } -// } -// -// protected YamlConfig createConfig() { -// YamlConfig result = new YamlConfig(); -// result.setClassTag(SpeciesProtocol.class.getSimpleName(), -// SpeciesProtocol.class); -// result.writeConfig.setAlwaysWriteClassname(false); -// result.writeConfig.setWriteRootTags(false); -// return result; -// } - protected File getProtocolFile(String id) { File protocolDirectory = config.getProtocolDirectory(); File result = new File(protocolDirectory, id + "." + TUTTI_PROTOCOL_EXTENSION); Modified: trunk/tutti-persistence-dev/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistenceDevImpl.java =================================================================== --- trunk/tutti-persistence-dev/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistenceDevImpl.java 2013-02-01 18:37:33 UTC (rev 296) +++ trunk/tutti-persistence-dev/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistenceDevImpl.java 2013-02-01 22:27:32 UTC (rev 297) @@ -410,40 +410,37 @@ @Override public List<String> getAllProtocolNames() { - List<String> result = getTransformedDataList(TuttiProtocol.class.getName(), GET_PROTOCOL_NAME); - return result; + throw new IllegalStateException("method 'getAllProtocolNames' not implemented"); } @Override public List<TuttiProtocol> getAllProtocol() { - List<TuttiProtocol> result = getDataInNewList(TuttiProtocol.class.getName()); - return result; + throw new IllegalStateException("method 'getAllProtocol' not implemented"); } @Override + public boolean isProtocolExist(String id) { + throw new IllegalStateException("method 'isProtocolExist' not implemented"); + } + + @Override public TuttiProtocol getProtocol(String id) { - TuttiProtocol result = getBean(TuttiProtocol.class.getName(), id); - return result; + throw new IllegalStateException("method 'getProtocol' not implemented"); } @Override public TuttiProtocol createProtocol(TuttiProtocol bean) { - TuttiProtocol result = create(TuttiProtocol.class.getName(), bean); - return result; + throw new IllegalStateException("method 'createProtocol' not implemented"); } @Override public TuttiProtocol saveProtocol(TuttiProtocol bean) { - TuttiProtocol result = save(TuttiProtocol.class.getName(), bean); - return result; + throw new IllegalStateException("method 'saveProtocol' not implemented"); } @Override public void deleteProtocol(String id) { - List<IdAware> data = getData(TuttiProtocol.class.getName()); - TuttiProtocol protocol = getProtocol(id); - data.remove(protocol); - persistToFile(TuttiProtocol.class.getName()); + throw new IllegalStateException("method 'deleteProtocol' not implemented"); } //------------------------------------------------------------------------// Modified: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/PersistenceService.java =================================================================== --- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/PersistenceService.java 2013-02-01 18:37:33 UTC (rev 296) +++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/PersistenceService.java 2013-02-01 22:27:32 UTC (rev 297) @@ -143,6 +143,11 @@ } @Override + public boolean isProtocolExist(String id) { + return protocolPersistenceService.isProtocolExist(id); + } + + @Override public List<String> getAllProtocolNames() { return protocolPersistenceService.getAllProtocolNames(); } @@ -358,6 +363,11 @@ //------------------------------------------------------------------------// @Override + public boolean isProtocolExist(String id) { + return driver.isProtocolExist(id); + } + + @Override public List<String> getAllProtocolNames() { return driver.getAllProtocolNames(); } Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/ChangeScreenAction.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/ChangeScreenAction.java 2013-02-01 18:37:33 UTC (rev 296) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/ChangeScreenAction.java 2013-02-01 22:27:32 UTC (rev 297) @@ -1,6 +1,30 @@ package fr.ifremer.tutti.ui.swing; +/* + * #%L + * Tutti :: UI + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2012 - 2013 Ifremer + * %% + * 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% + */ + import java.awt.event.ActionEvent; /** Property changes on: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/ChangeScreenAction.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/TuttiUIContext.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/TuttiUIContext.java 2013-02-01 18:37:33 UTC (rev 296) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/TuttiUIContext.java 2013-02-01 22:27:32 UTC (rev 297) @@ -30,7 +30,6 @@ import fr.ifremer.tutti.persistence.RessourceClassLoader; import fr.ifremer.tutti.persistence.entities.data.Cruise; import fr.ifremer.tutti.persistence.entities.data.Program; -import fr.ifremer.tutti.persistence.entities.protocol.TuttiProtocol; import fr.ifremer.tutti.service.PersistenceService; import fr.ifremer.tutti.service.TuttiService; import fr.ifremer.tutti.service.TuttiServiceContext; @@ -344,8 +343,7 @@ if (isProtocolFilled()) { - TuttiProtocol protocol = persistenceService.getProtocol(protocolId); - if (protocol == null) { + if (!persistenceService.isProtocolExist(protocolId)) { // not found in this db Added: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/DeleteProtocolAction.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/DeleteProtocolAction.java (rev 0) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/DeleteProtocolAction.java 2013-02-01 22:27:32 UTC (rev 297) @@ -0,0 +1,91 @@ +package fr.ifremer.tutti.ui.swing.content.home; + +/* + * #%L + * Tutti :: UI + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2012 - 2013 Ifremer + * %% + * 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% + */ + +import com.google.common.base.Preconditions; +import fr.ifremer.tutti.persistence.entities.protocol.TuttiProtocol; +import fr.ifremer.tutti.service.PersistenceService; +import fr.ifremer.tutti.ui.swing.AbstractTuttiAction; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import java.awt.event.ActionEvent; +import java.util.List; + +import static org.nuiton.i18n.I18n._; + +/** + * To delete the selected protocol. + * + * @author tchemit <chemit@codelutin.com> + * @since 1.0 + */ +public class DeleteProtocolAction extends AbstractTuttiAction<SelectCruiseUIModel, SelectCruiseUIHandler> { + + private static final long serialVersionUID = 1L; + + /** Logger. */ + private static final Log log = LogFactory.getLog(EditProtocolAction.class); + + public DeleteProtocolAction(SelectCruiseUIHandler handler) { + super(handler, + "deleteProtocol", + "delete", + _("tutti.action.deleteProtocol"), + _("tutti.action.deleteProtocol.tip"), + true + ); + } + + @Override + protected void doAction(ActionEvent e) { + TuttiProtocol protocol = getModel().getProtocol(); + Preconditions.checkNotNull(protocol); + String id = protocol.getId(); + Preconditions.checkNotNull(id); + if (log.isInfoEnabled()) { + log.info("Delete protocol: " + id); + } + + PersistenceService service = getContext().getService(PersistenceService.class); + service.deleteProtocol(id); + + getModel().setProtocol(null); + + List<TuttiProtocol> protocols = getModel().getProtocols(); + protocols.remove(protocol); + + if (log.isInfoEnabled()) { + log.info("nb protocols: " + protocols.size()); + } + // reset (will clear combo-box) + getModel().setProtocols(null); + + // set new list + getModel().setProtocols(protocols); + + getHandler().resetEditProtolAction(); + } +} \ No newline at end of file Property changes on: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/DeleteProtocolAction.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/ExportProtocolAction.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/ExportProtocolAction.java 2013-02-01 18:37:33 UTC (rev 296) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/ExportProtocolAction.java 2013-02-01 22:27:32 UTC (rev 297) @@ -112,5 +112,7 @@ sendMessage("Protocole [" + protocol.getName() + "] exporté dans le fichier " + file.getName() + "."); + + getHandler().resetEditProtolAction(); } } Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/SelectCruiseUI.css =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/SelectCruiseUI.css 2013-02-01 18:37:33 UTC (rev 296) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/SelectCruiseUI.css 2013-02-01 22:27:32 UTC (rev 297) @@ -87,8 +87,9 @@ model: {handler.newComboModel(newProtocolAction, importProtocolAction)}; renderer: {new ActionListCellRenderer()}; } + #editProtocolComboBox { - model: {handler.newComboModel(editProtocolAction, cloneProtocolAction, exportProtocolAction)}; + model: {handler.newComboModel(editProtocolAction, cloneProtocolAction, exportProtocolAction, deleteProtocolAction)}; enabled: {model.isProtocolFound()}; renderer: {new ActionListCellRenderer()}; } Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/SelectCruiseUI.jaxx =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/SelectCruiseUI.jaxx 2013-02-01 18:37:33 UTC (rev 296) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/SelectCruiseUI.jaxx 2013-02-01 22:27:32 UTC (rev 297) @@ -78,6 +78,7 @@ <EditProtocolAction id='editProtocolAction' constructorParams='handler'/> <CloneProtocolAction id='cloneProtocolAction' constructorParams='handler'/> <ExportProtocolAction id='exportProtocolAction' constructorParams='handler'/> + <DeleteProtocolAction id='deleteProtocolAction' constructorParams='handler'/> <EditCatchesAction id='editCatchesAction' constructorParams='handler'/> <ValidateCatchesAction id='validateCatchesAction' constructorParams='handler'/> Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/SelectCruiseUIHandler.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/SelectCruiseUIHandler.java 2013-02-01 18:37:33 UTC (rev 296) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/SelectCruiseUIHandler.java 2013-02-01 22:27:32 UTC (rev 297) @@ -167,6 +167,20 @@ model.getProtocols(), model.getProtocol()); + model.addPropertyChangeListener(SelectCruiseUIModel.PROPERTY_PROTOCOLS, new PropertyChangeListener() { + @Override + public void propertyChange(PropertyChangeEvent evt) { + // reload combo box + BeanComboBox<TuttiProtocol> combobox = ui.getProtocolCombobox(); + List<TuttiProtocol> protocols = (List<TuttiProtocol>) evt.getNewValue(); + + combobox.setData(null); + combobox.setData(protocols); + + ui.applyDataBinding(SelectCruiseUI.BINDING_PROTOCOL_COMBOBOX_ENABLED); + } + }); + model.addPropertyChangeListener(SelectCruiseUIModel.PROPERTY_PROGRAM, new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { @@ -224,7 +238,17 @@ ui.applyDataBinding(SelectCruiseUI.BINDING_EDIT_CRUISE_BUTTON_ENABLED); ui.applyDataBinding(SelectCruiseUI.BINDING_EDIT_CATCHES_BUTTON_ENABLED); ui.applyDataBinding(SelectCruiseUI.BINDING_VALIDATE_CATCHES_BUTTON_ENABLED); + } + protected boolean resetEditProtolAction; + + public void resetEditProtolAction() { + resetEditProtolAction = true; + try { + ui.getEditProtocolComboBox().setSelectedIndex(0); + } finally { + resetEditProtolAction = false; + } } @Override @@ -239,10 +263,12 @@ } public void startExistingProtocolAction(ActionEvent event) { - JComboBox newProtocolCombo = (JComboBox) event.getSource(); - Action selectedAction = (Action) newProtocolCombo.getSelectedItem(); + if (!resetEditProtolAction) { + JComboBox newProtocolCombo = (JComboBox) event.getSource(); + Action selectedAction = (Action) newProtocolCombo.getSelectedItem(); - selectedAction.actionPerformed(event); + selectedAction.actionPerformed(event); + } } public void startNewProtocolAction(ActionEvent event) { Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/CancelEditFishingOperationAction.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/CancelEditFishingOperationAction.java 2013-02-01 18:37:33 UTC (rev 296) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/CancelEditFishingOperationAction.java 2013-02-01 22:27:32 UTC (rev 297) @@ -1,6 +1,30 @@ package fr.ifremer.tutti.ui.swing.content.operation; +/* + * #%L + * Tutti :: UI + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2012 - 2013 Ifremer + * %% + * 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% + */ + import fr.ifremer.tutti.ui.swing.AbstractTuttiAction; import java.awt.event.ActionEvent; import org.apache.commons.logging.Log; Property changes on: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/CancelEditFishingOperationAction.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/RemoveSpeciesBatchAction.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/RemoveSpeciesBatchAction.java (rev 0) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/RemoveSpeciesBatchAction.java 2013-02-01 22:27:32 UTC (rev 297) @@ -0,0 +1,152 @@ +package fr.ifremer.tutti.ui.swing.content.operation.catches.species; + +/* + * #%L + * Tutti :: UI + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2012 - 2013 Ifremer + * %% + * 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% + */ + +import com.google.common.base.Preconditions; +import com.google.common.collect.Sets; +import fr.ifremer.tutti.persistence.TuttiPersistence; +import fr.ifremer.tutti.persistence.entities.TuttiEntities; +import fr.ifremer.tutti.service.PersistenceService; +import fr.ifremer.tutti.ui.swing.AbstractTuttiAction; +import fr.ifremer.tutti.ui.swing.util.table.AbstractSelectTableAction; +import jaxx.runtime.swing.ErrorDialogUI; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.jdesktop.swingx.JXTable; + +import java.awt.event.ActionEvent; +import java.util.Set; + +import static org.nuiton.i18n.I18n._; + +/** + * To remove a species batch and all his children. + * + * @author tchemit <chemit@codelutin.com> + * @since 1.0 + */ +public class RemoveSpeciesBatchAction extends AbstractTuttiAction<SpeciesBatchUIModel, SpeciesBatchUIHandler> { + + private static final long serialVersionUID = 1L; + + /** Logger. */ + private static final Log log = + LogFactory.getLog(RemoveSpeciesBatchAction.class); + + protected RemoveSpeciesSubBatchAction removeSpeciesSubBatchAction; + + public RemoveSpeciesBatchAction(SpeciesBatchUIHandler handler) { + super(handler, + "removeSpeciesBatch", + "batch-delete", + _("tutti.action.removeSpeciesBatch"), + _("tutti.action.removeSpeciesBatch.tip"), + false + ); + + removeSpeciesSubBatchAction = new RemoveSpeciesSubBatchAction(handler); + } + + @Override + protected void doAction(ActionEvent event) { + + TuttiPersistence persistenceService = + getContext().getService(PersistenceService.class); + + SpeciesBatchUIHandler handler = getHandler(); + + JXTable table = handler.getTable(); + + int rowIndex = table.getSelectedRow(); + + Preconditions.checkState(rowIndex != -1, + "Cant remove batch if no batch selected"); + + SpeciesBatchTableModel tableModel = handler.getTableModel(); + SpeciesBatchRowModel selectedBatch = tableModel.getEntry(rowIndex); + + Preconditions.checkState(!TuttiEntities.isNew(selectedBatch), + "Can't remove batch if batch is not persisted"); + + if (!selectedBatch.isBatchRoot()) { + + // remove all sub batches of his parent + SpeciesBatchRowModel parentBatch = selectedBatch.getBatchParent(); + + // get parent row index + int parentIndex = tableModel.getRowIndex(parentBatch); + + // select it + table.setRowSelectionInterval(parentIndex, parentIndex); + + // remove all his children + removeSpeciesSubBatchAction.doAction(event); + + } else { + + // remove selected batch and all his children + + try { + + // remove parent batch (will destroy all his childs from db) + persistenceService.deleteSpeciesBatch(selectedBatch.getId()); + + // update speciesUsed + handler.removeFromSpeciesUsed(selectedBatch); + + // collect of rows to remove from model + Set<SpeciesBatchRowModel> rowToRemove = + Sets.newHashSet(selectedBatch); + + handler.collectChilds(selectedBatch, rowToRemove); + + // remove all rows from the model + getModel().getRows().removeAll(rowToRemove); + + // refresh table from parent batch row index to the end + tableModel.fireTableDataChanged(); + + if (tableModel.getRowCount() > 0) { + + // select first row + AbstractSelectTableAction.doSelectCell(table, 0, 0); + } else { + + table.clearSelection(); + } + + if (table.isEditing()) { + + // but no edit it + table.getCellEditor().stopCellEditing(); + } + } catch (Exception e) { + + ErrorDialogUI.showError(e); + } + } + } + +} Property changes on: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/RemoveSpeciesBatchAction.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/RemoveSpeciesSubBatchAction.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/RemoveSpeciesSubBatchAction.java (rev 0) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/RemoveSpeciesSubBatchAction.java 2013-02-01 22:27:32 UTC (rev 297) @@ -0,0 +1,129 @@ +package fr.ifremer.tutti.ui.swing.content.operation.catches.species; + +/* + * #%L + * Tutti :: UI + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2012 - 2013 Ifremer + * %% + * 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% + */ + +import com.google.common.base.Preconditions; +import com.google.common.collect.Sets; +import fr.ifremer.tutti.persistence.TuttiPersistence; +import fr.ifremer.tutti.persistence.entities.TuttiEntities; +import fr.ifremer.tutti.service.PersistenceService; +import fr.ifremer.tutti.ui.swing.AbstractTuttiAction; +import fr.ifremer.tutti.ui.swing.util.table.AbstractSelectTableAction; +import jaxx.runtime.swing.ErrorDialogUI; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.jdesktop.swingx.JXTable; + +import java.awt.event.ActionEvent; +import java.util.Set; + +import static org.nuiton.i18n.I18n._; + +/** + * To remove a species batch children. + * + * @author tchemit <chemit@codelutin.com> + * @since 1.0 + */ +public class RemoveSpeciesSubBatchAction extends AbstractTuttiAction<SpeciesBatchUIModel, SpeciesBatchUIHandler> { + + private static final long serialVersionUID = 1L; + + /** Logger. */ + private static final Log log = + LogFactory.getLog(RemoveSpeciesSubBatchAction.class); + + public RemoveSpeciesSubBatchAction(SpeciesBatchUIHandler handler) { + super(handler, + "removeSpeciesSubBatch", + "batch-delete", + _("tutti.action.removeSpeciesSubBatch"), + _("tutti.action.removeSpeciesSubBatch.tip"), + false + ); + + + } + + @Override + protected void doAction(ActionEvent event) { + + TuttiPersistence persistenceService = + getContext().getService(PersistenceService.class); + + SpeciesBatchUIHandler handler = getHandler(); + + JXTable table = handler.getTable(); + + int rowIndex = table.getSelectedRow(); + + Preconditions.checkState(rowIndex != -1, + "Cant remove sub batch if no batch selected"); + + SpeciesBatchRowModel parentBatch = handler.getTableModel().getEntry(rowIndex); + + Preconditions.checkState(!TuttiEntities.isNew(parentBatch), + "Can't remove sub batch if batch is not persisted"); + + try { + + // save parent batch (will destroy all his childs from db) + persistenceService.deleteSpeciesSubBatch(parentBatch.getId()); + + if (parentBatch.isBatchRoot()) { + + // update speciesUsed + handler.removeFromSpeciesUsed(parentBatch); + } + + // collect of rows to remove from model + Set<SpeciesBatchRowModel> rowToRemove = Sets.newHashSet(); + + handler.collectChilds(parentBatch, rowToRemove); + + // remove all rows from the model + getModel().getRows().removeAll(rowToRemove); + + // remove childs from parent batch + parentBatch.setBatchChilds(null); + + // refresh table from parent batch row index to the end + handler.getTableModel().fireTableDataChanged(); + + // select parent batch row + AbstractSelectTableAction.doSelectCell(table, rowIndex, 0); + + if (table.isEditing()) { + + // but no edit it + table.getCellEditor().stopCellEditing(); + } + } catch (Exception e) { + + ErrorDialogUI.showError(e); + } + } + +} Property changes on: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/RemoveSpeciesSubBatchAction.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/RenameSpeciesBatchAction.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/RenameSpeciesBatchAction.java (rev 0) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/RenameSpeciesBatchAction.java 2013-02-01 22:27:32 UTC (rev 297) @@ -0,0 +1,75 @@ +package fr.ifremer.tutti.ui.swing.content.operation.catches.species; + +/* + * #%L + * Tutti :: UI + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2012 - 2013 Ifremer + * %% + * 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% + */ + +import fr.ifremer.tutti.persistence.TuttiPersistence; +import fr.ifremer.tutti.persistence.entities.referential.Species; +import fr.ifremer.tutti.service.PersistenceService; +import fr.ifremer.tutti.ui.swing.AbstractTuttiAction; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import java.awt.event.ActionEvent; +import java.util.List; + +import static org.nuiton.i18n.I18n._; + +/** + * To rename the species for a species batch and all his children. + * + * @author tchemit <chemit@codelutin.com> + * @since 1.0 + */ +public class RenameSpeciesBatchAction extends AbstractTuttiAction<SpeciesBatchUIModel, SpeciesBatchUIHandler> { + + private static final long serialVersionUID = 1L; + + /** Logger. */ + private static final Log log = LogFactory.getLog(RenameSpeciesBatchAction.class); + + protected List<Species> allSpecies; + + public RenameSpeciesBatchAction(SpeciesBatchUIHandler handler) { + super(handler, + "renameSpeciesBatch", + "batch-rename", + _("tutti.action.renameSpeciesBatch"), + _("tutti.action.renameSpeciesBatch.tip"), + false + ); + + TuttiPersistence persistenceService = + getContext().getService(PersistenceService.class); + allSpecies = persistenceService.getAllSpecies(); + } + + @Override + protected void doAction(ActionEvent event) { + SpeciesBatchUIHandler handler = getHandler(); + + // TODO + } + +} Property changes on: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/RenameSpeciesBatchAction.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUI.css =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUI.css 2013-02-01 18:37:33 UTC (rev 296) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUI.css 2013-02-01 22:27:32 UTC (rev 297) @@ -95,7 +95,6 @@ numberPattern: {INT_6_DIGITS_PATTERN}; } - #tablePopup { label: "tutti.title.batchActions"; } @@ -109,21 +108,22 @@ } #removeSpeciesBatchMenu { - text: "tutti.action.removeSpeciesBatch"; - toolTipText: "tutti.action.removeSpeciesBatch.tip"; + action: {removeSpeciesBatchAction}; mnemonic: R; - actionIcon: batch-delete; enabled: {model.isTableViewModeAll() && model.isRemoveSpeciesBatchEnabled()}; } #removeSpeciesSubBatchMenu { - text: "tutti.action.removeSpeciesSubBatch"; - toolTipText: "tutti.action.removeSpeciesSubBatch.tip"; + action: {removeSpeciesSubBatchAction}; mnemonic: R; - actionIcon: batch-delete; enabled: {model.isTableViewModeAll() && model.isRemoveSpeciesSubBatchEnabled()}; } +#renameSpeciesBatchMenu { + action: {renameSpeciesBatchAction}; + enabled: {model.isTableViewModeAll() && model.isRenameSpeciesBatchEnabled()}; +} + #table { selectionMode: {ListSelectionModel.SINGLE_SELECTION}; selectionBackground: {null}; Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUI.jaxx =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUI.jaxx 2013-02-01 18:37:33 UTC (rev 296) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUI.jaxx 2013-02-01 22:27:32 UTC (rev 297) @@ -65,6 +65,10 @@ <SwingValidatorMessageTableModel id='errorTableModel'/> + <RenameSpeciesBatchAction id='renameSpeciesBatchAction' constructorParams='handler'/> + <RemoveSpeciesBatchAction id='removeSpeciesBatchAction' constructorParams='handler'/> + <RemoveSpeciesSubBatchAction id='removeSpeciesSubBatchAction' constructorParams='handler'/> + <BeanValidator id='validator' bean='model' errorTableModel='errorTableModel' uiClass='jaxx.runtime.validator.swing.ui.ImageValidationUI'> <field name='speciesTotalWeight' component='speciesTotalWeightField'/> @@ -84,10 +88,9 @@ <!--onPopupMenuWillBecomeVisible='handler.updateTablePopup()'>--> <JMenuItem id='splitSpeciesBatchMenu' onActionPerformed='handler.splitSpeciesBatch()'/> - <JMenuItem id='removeSpeciesBatchMenu' - onActionPerformed='handler.removeSpeciesBatch()'/> - <JMenuItem id='removeSpeciesSubBatchMenu' - onActionPerformed='handler.removeSpeciesSubBatch()'/> + <JMenuItem id='removeSpeciesBatchMenu'/> + <JMenuItem id='removeSpeciesSubBatchMenu'/> + <JMenuItem id='renameSpeciesBatchMenu'/> </JPopupMenu> <Table id='form' fill='both' constraints='BorderLayout.NORTH'> Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIHandler.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIHandler.java 2013-02-01 18:37:33 UTC (rev 296) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIHandler.java 2013-02-01 22:27:32 UTC (rev 297) @@ -57,11 +57,11 @@ import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil; import fr.ifremer.tutti.ui.swing.util.editor.AttachmentCellComponent; import fr.ifremer.tutti.ui.swing.util.editor.LongTextCellComponent; -import fr.ifremer.tutti.ui.swing.util.table.AbstractSelectTableAction; import fr.ifremer.tutti.ui.swing.util.table.ColumnIdentifier; import jaxx.runtime.JAXXUtil; +import jaxx.runtime.SwingUtil; import jaxx.runtime.context.JAXXContextEntryDef; -import jaxx.runtime.swing.ErrorDialogUI; +import jaxx.runtime.validator.swing.SwingValidator; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -69,6 +69,7 @@ import org.jdesktop.swingx.table.DefaultTableColumnModelExt; import org.nuiton.util.decorator.Decorator; +import javax.swing.JOptionPane; import javax.swing.RowFilter; import javax.swing.table.TableCellRenderer; import javax.swing.table.TableColumnModel; @@ -78,12 +79,9 @@ import java.util.EnumMap; import java.util.List; import java.util.Set; -import javax.swing.JOptionPane; -import jaxx.runtime.SwingUtil; -import jaxx.runtime.validator.swing.SwingValidator; -import static org.nuiton.i18n.I18n.n_; import static org.nuiton.i18n.I18n._; +import static org.nuiton.i18n.I18n.n_; /** * @author tchemit <chemit@codelutin.com> @@ -624,7 +622,7 @@ getTable().setRowFilter(filter); } }); - + } @Override @@ -646,7 +644,7 @@ createBatchEditor.getHandler().openUI(getModel()); parent.getHandler().setSelectedCard(EditCatchesUIHandler.CREATE_BATCH_CARD); } - + public void addSpeciesBatch(CreateSpeciesBatchUIModel createModel) { if (createModel.isValid()) { @@ -676,7 +674,7 @@ } public void splitSpeciesBatch() { - + JXTable table = getTable(); // get selected row @@ -692,19 +690,19 @@ boolean split = true; if (parentBatch.getWeight() != null) { int i = JOptionPane.showConfirmDialog( - ui, - _("tutti.dialog.catches.species.split.weightNotNull.message"), - _("tutti.dialog.catches.species.split.weightNotNull.title"), - JOptionPane.OK_CANCEL_OPTION); - + ui, + _("tutti.dialog.catches.species.split.weightNotNull.message"), + _("tutti.dialog.catches.species.split.weightNotNull.title"), + JOptionPane.OK_CANCEL_OPTION); + if (i == JOptionPane.OK_OPTION) { parentBatch.setWeight(null); - + } else { split = false; } } - + if (split) { if (log.isInfoEnabled()) { log.info("Open split batch ui for row [" + rowIndex + ']'); @@ -725,7 +723,7 @@ // get selected row int insertRow = table.getSelectedRow(); - + SpeciesBatchTableModel tableModel = getTableModel(); SpeciesBatchRowModel parentBatch = tableModel.getEntry(insertRow); @@ -764,7 +762,7 @@ // save new batches saveRows(newBatches); - + SpeciesBatchUIModel model = getModel(); model.setLeafNumber(model.getLeafNumber() + newBatches.size() - 1); } @@ -776,134 +774,6 @@ // table.requestFocus(); } - public void removeSpeciesBatch() { - - JXTable table = getTable(); - - int rowIndex = table.getSelectedRow(); - - Preconditions.checkState(rowIndex != -1, - "Cant remove batch if no batch selected"); - - SpeciesBatchTableModel tableModel = getTableModel(); - SpeciesBatchRowModel selectedBatch = tableModel.getEntry(rowIndex); - - Preconditions.checkState(!TuttiEntities.isNew(selectedBatch), - "Can't remove batch if batch is not persisted"); - - if (!selectedBatch.isBatchRoot()) { - - // remove all sub batches of his parent - SpeciesBatchRowModel parentBatch = selectedBatch.getBatchParent(); - - // get parent row index - int parentIndex = tableModel.getRowIndex(parentBatch); - - // select it - table.setRowSelectionInterval(parentIndex, parentIndex); - - // remove all his children - removeSpeciesSubBatch(); - - } else { - - // remove selected batch and all his children - - try { - - // remove parent batch (will destroy all his childs from db) - persistenceService.deleteSpeciesBatch(selectedBatch.getId()); - - // update speciesUsed - removeFromSpeciesUsed(selectedBatch); - - // collect of rows to remove from model - Set<SpeciesBatchRowModel> rowToRemove = - Sets.newHashSet(selectedBatch); - - collectChilds(selectedBatch, rowToRemove); - - // remove all rows from the model - getModel().getRows().removeAll(rowToRemove); - - // refresh table from parent batch row index to the end - tableModel.fireTableDataChanged(); - - if (tableModel.getRowCount() > 0) { - - // select first row - AbstractSelectTableAction.doSelectCell(table, 0, 0); - } else { - - table.clearSelection(); - } - - if (table.isEditing()) { - - // but no edit it - table.getCellEditor().stopCellEditing(); - } - } catch (Exception e) { - - ErrorDialogUI.showError(e); - } - } - } - - public void removeSpeciesSubBatch() { - - JXTable table = getTable(); - - int rowIndex = table.getSelectedRow(); - - Preconditions.checkState(rowIndex != -1, - "Cant remove sub batch if no batch selected"); - - SpeciesBatchRowModel parentBatch = getTableModel().getEntry(rowIndex); - - Preconditions.checkState(!TuttiEntities.isNew(parentBatch), - "Can't remove sub batch if batch is not persisted"); - - try { - - // save parent batch (will destroy all his childs from db) - persistenceService.deleteSpeciesSubBatch(parentBatch.getId()); - - if (parentBatch.isBatchRoot()) { - - // update speciesUsed - removeFromSpeciesUsed(parentBatch); - } - - // collect of rows to remove from model - Set<SpeciesBatchRowModel> rowToRemove = Sets.newHashSet(); - - collectChilds(parentBatch, rowToRemove); - - // remove all rows from the model - getModel().getRows().removeAll(rowToRemove); - - // remove childs from parent batch - parentBatch.setBatchChilds(null); - - // refresh table from parent batch row index to the end - getTableModel().fireTableDataChanged(); - - // select parent batch row - AbstractSelectTableAction.doSelectCell(table, rowIndex, 0); - - if (table.isEditing()) { - - // but no edit it - table.getCellEditor().stopCellEditing(); - } - } catch (Exception e) { - - ErrorDialogUI.showError(e); - } - - } - public void updateTotalFromFrequencies(SpeciesBatchRowModel row) { Float totalNumber = null; Float totalWeight = null; @@ -1045,6 +915,7 @@ boolean enableAdd = true; // CollectionUtils.isNotEmpty(getModel().getAvailableSpecies()); + boolean enableRename = false; boolean enableSplit = false; boolean enableRemove = false; boolean enableRemoveSub = false; @@ -1066,13 +937,19 @@ enableSplit = true; enableRemove = true; enableRemoveSub = true; + enableRename = true; } if (enableSplit) { // can split if selected batch is a leaf enableSplit = row.isBatchLeaf(); + } + if (enableRename) { + + // can rename if selected batch is a parent + enableRename = row.isBatchRoot(); } if (enableRemove) { @@ -1091,7 +968,7 @@ getModel().setSplitSpeciesBatchEnabled(enableSplit); getModel().setRemoveSpeciesBatchEnabled(enableRemove); getModel().setRemoveSpeciesSubBatchEnabled(enableRemoveSub); - + getModel().setRenameSpeciesBatchEnabled(enableRename); } protected void collectChilds(SpeciesBatchRowModel row, @@ -1211,8 +1088,8 @@ } SpeciesBatchUIModel model = getModel(); model.getSpeciesUsed().remove(row.getSortedUnsortedCategoryValue(), - row.getSpecies()); - + row.getSpecies()); + if (row.isBatchRoot()) { model.setRootNumber(model.getRootNumber() - 1); } @@ -1227,8 +1104,8 @@ } SpeciesBatchUIModel model = getModel(); model.getSpeciesUsed().put(row.getSortedUnsortedCategoryValue(), - row.getSpecies()); - + row.getSpecies()); + model.setRootNumber(model.getRootNumber() + 1); } Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIModel.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIModel.java 2013-02-01 18:37:33 UTC (rev 296) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIModel.java 2013-02-01 22:27:32 UTC (rev 297) @@ -51,6 +51,8 @@ public static final String PROPERTY_REMOVE_SPECIES_SUB_BATCH_ENABLED = "removeSpeciesSubBatchEnabled"; + public static final String PROPERTY_RENAME_SPECIES_BATCH_ENABLED = "renameSpeciesBatchEnabled"; + public static final String PROPERTY_REMOVE_SPECIES_BATCH_ENABLED = "removeSpeciesBatchEnabled"; public static final String PROPERTY_TABLE_VIEW_MODE_ALL = "tableViewModeAll"; @@ -58,9 +60,9 @@ public static final String PROPERTY_TABLE_VIEW_MODE_LEAF = "tableViewModeLeaf"; public static final String PROPERTY_TABLE_VIEW_MODE_ROOT = "tableViewModeRoot"; - + public static final String PROPERTY_ROOT_NUMBER = "rootNumber"; - + public static final String PROPERTY_LEAF_NUMBER = "leafNumber"; /** @@ -119,17 +121,15 @@ * @since 0.3 */ protected boolean removeSpeciesSubBatchEnabled; - - /** - * @since 1.0 - */ + + /** @since 1.0 */ protected int rootNumber; - - /** - * @since 1.0 - */ + + /** @since 1.0 */ protected int leafNumber; + private boolean renameSpeciesBatchEnabled; + public SpeciesBatchUIModel(EditCatchesUIModel catchesUIModel) { super(catchesUIModel, EditCatchesUIModel.PROPERTY_SPECIES_TOTAL_WEIGHT, @@ -179,7 +179,7 @@ public void setSpeciesTotalInertWeight(Float speciesTotalInertWeight) { catchesUIModel.setSpeciesTotalInertWeight(speciesTotalInertWeight); } - + public Float getSpeciesTotalLivingNotItemizedWeight() { return catchesUIModel.getSpeciesTotalLivingNotItemizedWeight(); } @@ -187,7 +187,7 @@ public void setSpeciesTotalLivingNotItemizedWeight(Float speciesTotalLivingNotItemizedWeight) { catchesUIModel.setSpeciesTotalLivingNotItemizedWeight(speciesTotalLivingNotItemizedWeight); } - + public List<SampleCategoryType> getSamplingOrder() { return samplingOrder; } @@ -244,7 +244,7 @@ this.rootNumber = rootNumber; firePropertyChange(PROPERTY_ROOT_NUMBER, oldValue, rootNumber); } - + public int getLeafNumber() { return leafNumber; } @@ -254,7 +254,7 @@ this.leafNumber = leafNumber; firePropertyChange(PROPERTY_LEAF_NUMBER, oldValue, leafNumber); } - + public boolean isCreateSpeciesBatchEnabled() { return createSpeciesBatchEnabled; } @@ -294,4 +294,14 @@ this.removeSpeciesSubBatchEnabled = removeSpeciesSubBatchEnabled; firePropertyChange(PROPERTY_REMOVE_SPECIES_SUB_BATCH_ENABLED, oldValue, removeSpeciesSubBatchEnabled); } + + public void setRenameSpeciesBatchEnabled(boolean renameSpeciesBatchEnabled) { + Object oldValue = isRenameSpeciesBatchEnabled(); + this.renameSpeciesBatchEnabled = renameSpeciesBatchEnabled; + firePropertyChange(PROPERTY_RENAME_SPECIES_BATCH_ENABLED, oldValue, renameSpeciesBatchEnabled); + } + + public boolean isRenameSpeciesBatchEnabled() { + return renameSpeciesBatchEnabled; + } } Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/CreateSpeciesBatchUIModel.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/CreateSpeciesBatchUIModel.java 2013-02-01 18:37:33 UTC (rev 296) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/CreateSpeciesBatchUIModel.java 2013-02-01 22:27:32 UTC (rev 297) @@ -94,13 +94,17 @@ } public List<Species> getAvailableSpecies() { - log.info("getAvailableSpecies " + availableSpecies); + if (log.isDebugEnabled()) { + log.debug("getAvailableSpecies " + availableSpecies); + } return availableSpecies; } public void setAvailableSpecies(List<Species> availableSpecies) { - - log.info("setAvailableSpecies " + availableSpecies); + + if (log.isDebugEnabled()) { + log.debug("setAvailableSpecies " + availableSpecies); + } Object oldValue = getAvailableSpecies(); this.availableSpecies = availableSpecies; firePropertyChange(PROPERTY_AVAILABLE_SPECIES, oldValue, availableSpecies); Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/ExportProtocolSpeciesAction.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/ExportProtocolSpeciesAction.java 2013-02-01 18:37:33 UTC (rev 296) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/ExportProtocolSpeciesAction.java 2013-02-01 22:27:32 UTC (rev 297) @@ -68,7 +68,7 @@ // choose file to export file = TuttiUIUtil.chooseFile( getContext().getMainUI(), - _("tutti.title.choose.protocolSpeciesFile"), + _("tutti.title.choose.protocolSpeciesExportFile"), _("tutti.action.chooseProtocolSpeciesFile"), null, "^.*\\.csv", _("tutti.file.csv") Modified: trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties =================================================================== --- trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties 2013-02-01 18:37:33 UTC (rev 296) +++ trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties 2013-02-01 22:27:32 UTC (rev 297) @@ -22,6 +22,8 @@ tutti.action.configuration=Configuration tutti.action.configuration.tip=Configurer Tutti tutti.action.createSpeciesBatch=Créer un lot pour une espèce +tutti.action.deleteProtocol=Supprimer +tutti.action.deleteProtocol.tip=Supprimer le protocole sélectioné tutti.action.editCatches=Saisir les captures tutti.action.editCatches.tip=Saisir des captures tutti.action.editCruise=Éditer @@ -35,7 +37,7 @@ tutti.action.editSelectedProgram=Série de campagne tutti.action.editSelectedProgram.tip=Éditer la série de campagne sélectionnée tutti.action.editSelectedProtocol=Protocole -tutti.action.editSelectedProtocol.tip=Éditer le protocole sélectionnée +tutti.action.editSelectedProtocol.tip=Éditer le protocole sélectionné tutti.action.exit=Quitter tutti.action.exit.tip=Quitter l'application tutti.action.exportAllCaracteristic=Exporter toutes les caractéristiques @@ -44,8 +46,8 @@ tutti.action.exportProtocol.tip=Exporter le protocole sélectionné tutti.action.exportProtocolCaracteristic=Exporter les caractéristiques tutti.action.exportProtocolCaracteristic.tip=Exporter les caractéristiques du protocole -tutti.action.exportProtocolSpecies= -tutti.action.exportProtocolSpecies.tip= +tutti.action.exportProtocolSpecies=Exporter les espèces +tutti.action.exportProtocolSpecies.tip=Exporter les espèces du protocole tutti.action.generate=Générer tutti.action.generateCampaignName=Générer le nom tutti.action.importProtocol=Importer @@ -71,6 +73,8 @@ tutti.action.removeSpeciesBatch.tip=Supprimer le lot courant (celui de la ligne sélectionnée) et tous ces fils tutti.action.removeSpeciesSubBatch=Supprimer les lots fils tutti.action.removeSpeciesSubBatch.tip=Supprimer tous les lots fils du lot sélectionné +tutti.action.renameSpeciesBatch=Corriger l'espèce +tutti.action.renameSpeciesBatch.tip=Corriger l'espèce sur tout le lot sélectionné tutti.action.reset.fishingOperationValidState=Réinitialiser tutti.action.save=Enregistrer tutti.action.saveCruise=Enregistrer @@ -90,9 +94,9 @@ tutti.action.validate=Valider tutti.action.validateCatches=Valider les captures tutti.action.validateCatches.tip=Valider les captures -tutti.application.basedir.description= +tutti.application.basedir.description=Répertoire principale de l'application tutti.application.config=Configuration de l'application Tutti -tutti.application.directory.description= +tutti.application.directory.description=Répertoire contentant uniquement tutti tutti.application.name=Tutti tutti.config.category.applications=Application tutti.config.category.applications.description=Application @@ -104,11 +108,11 @@ tutti.config.programId=Identifiant de la dernière série de campagne utilisée tutti.config.protocolId=Identifiant du dernier protocole utilisé tutti.config.ui.autoPopupNumberEditor=Toujours afficher le pavé numérique lors de l'édition d'un nombre -tutti.config.ui.color.cellWithValue= +tutti.config.ui.color.cellWithValue=Couleur d'une cellule avec des données tutti.config.ui.color.rowInvalid=Ligne invalide tutti.config.ui.color.rowReadOnly=Cellule non éditable tutti.config.ui.config=Chemin du fichier de configuration des interfaces graphiques -tutti.config.ui.coordinateEditorType= +tutti.config.ui.coordinateEditorType=Type de l'éditeur de coordonnées tutti.config.ui.dateFormat=Format de dates tutti.config.ui.shortcut.closePopup=Fermer une popup tutti.config.ui.showNumberEditorButton=Afficher le pavé numérique de saisie @@ -340,12 +344,12 @@ tutti.table.species.sampleCategory.header.weight=Poids (kg) tutti.timeeditor.H=H tutti.title.about=À propos de Tutti -tutti.title.choose.protocolCaracteristicExportFile= +tutti.title.choose.protocolCaracteristicExportFile=Choisir le fichier où exporter les caractéristiques tutti.title.choose.protocolCaracteristicImportFile=Choisir le fichier des caractéristiques à importer tutti.title.choose.protocolExportFile=Choisir le fichier où exporter le protocole tutti.title.choose.protocolImportFile=Choisir le fichier du protocole à importer -tutti.title.choose.protocolSpeciesFile= -tutti.title.choose.protocolSpeciesImportFile= +tutti.title.choose.protocolSpeciesExportFile=Choisir le fichier où expoerter les espèces de protocole +tutti.title.choose.protocolSpeciesImportFile=Choisir le fichier des espèces de protocole à importer tutti.title.create.cruise=Créer une nouvelle campagne tutti.title.create.program=Créer une nouvelle série de campagne tutti.title.create.protocol=Créer un nouveau protocol de saisie @@ -368,9 +372,8 @@ tutti.to.be.done=< A FAIRE > tutti.tooltip.attachment.none=Pas de pièce-jointes tutti.tooltip.comment.none=Pas de commentaire -tutti.update.application.url.description= -tutti.update.database.url.description= -tutti.update.location.description= +tutti.update.application.url.description=URL de mise à jour de la jre et de l'application +tutti.update.database.url.description=URL de mise à jour de la base de données tutti.validator.alert.none=Aucune alerte tutti.validator.alert.one=1 alerte tutti.validator.alert.several=%s alertes Added: trunk/tutti-ui-swing/src/main/resources/icons/action-batch-rename.png =================================================================== (Binary files differ) Property changes on: trunk/tutti-ui-swing/src/main/resources/icons/action-batch-rename.png ___________________________________________________________________ Added: svn:mime-type + image/png Added: svn:keywords + Author Date Id Revision HeadURL
participants (1)
-
tchemit@users.forge.codelutin.com