Tutti-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
- 4130 discussions
r61 - in trunk/tutti-ui-swing/src/main: java/fr/ifremer/tutti/ui/swing/content/operation/species java/fr/ifremer/tutti/ui/swing/util/editor resources/icons
by kmorin@users.forge.codelutin.com 14 Dec '12
by kmorin@users.forge.codelutin.com 14 Dec '12
14 Dec '12
Author: kmorin
Date: 2012-12-14 17:59:59 +0100 (Fri, 14 Dec 2012)
New Revision: 61
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/61
Log:
add attachment editor to the species table
Added:
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/AttachmentCellComponent.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/AttachmentEditorUI.css
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/AttachmentEditorUI.jaxx
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/AttachmentEditorUIHandler.java
trunk/tutti-ui-swing/src/main/resources/icons/action-delete.png
Modified:
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/species/SpeciesBatchRowModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/species/SpeciesBatchTableModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/species/SpeciesBatchUI.jaxx
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/species/SpeciesBatchUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/LongTextCellComponent.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/LongTextEditorUIHandler.java
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/species/SpeciesBatchRowModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/species/SpeciesBatchRowModel.java 2012-12-14 16:59:03 UTC (rev 60)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/species/SpeciesBatchRowModel.java 2012-12-14 16:59:59 UTC (rev 61)
@@ -25,6 +25,7 @@
*/
import com.google.common.collect.Lists;
+import fr.ifremer.tutti.persistence.entities.data.Attachment;
import fr.ifremer.tutti.persistence.entities.data.SpeciesBatch;
import fr.ifremer.tutti.persistence.entities.data.SpeciesBatchFrequency;
import fr.ifremer.tutti.persistence.entities.data.VracHorsVracEnum;
@@ -76,6 +77,8 @@
public static final String PROPERTY_COMPUTED_NUMBER = "computedNumber";
public static final String PROPERTY_COMPUTED_WEIGHT = "computedWeight";
+
+ public static final String PROPERTY_ATTACHMENTS = "attachments";
/**
* Species observed.
@@ -167,6 +170,13 @@
* @since 0.2
*/
protected String comment;
+
+ /**
+ * Attachments
+ *
+ * @since 0.2
+ */
+ protected List<Attachment> attachments;
/**
* List of frequencies observed for this batch.
@@ -334,6 +344,16 @@
firePropertyChange(PROPERTY_COMMENT, oldValue, comment);
}
+ public List<Attachment> getAttachments() {
+ return attachments;
+ }
+
+ public void setAttachments(List<Attachment> attachments) {
+ Object oldValue = getAttachments();
+ this.attachments = attachments;
+ firePropertyChange(PROPERTY_ATTACHMENTS, oldValue, attachments);
+ }
+
public List<SpeciesFrequencyRowModel> getFrequency() {
return frequency;
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/species/SpeciesBatchTableModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/species/SpeciesBatchTableModel.java 2012-12-14 16:59:03 UTC (rev 60)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/species/SpeciesBatchTableModel.java 2012-12-14 16:59:59 UTC (rev 61)
@@ -111,8 +111,8 @@
n_("tutti.table.species.batch.header.comment"),
n_("tutti.table.species.batch.header.comment"));
- public static final ColumnIdentifier<SpeciesBatchRowModel> FILE = ColumnIdentifier.newId(
- null,
+ public static final ColumnIdentifier<SpeciesBatchRowModel> ATTACHMENTS = ColumnIdentifier.newId(
+ SpeciesBatchRowModel.PROPERTY_ATTACHMENTS,
n_("tutti.table.species.batch.header.file"),
n_("tutti.table.species.batch.header.file"));
@@ -124,8 +124,8 @@
setNoneEditableCols(
SAMPLE_WEIGHT,
- SAMPLING_RATIO,
- FILE
+ SAMPLING_RATIO/*,
+ FILE*/
);
noneEditableColIfNoSpecies = Sets.newHashSet();
noneEditableColIfNoSpecies.add(COMPUTED_NUMBER);
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/species/SpeciesBatchUI.jaxx
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/species/SpeciesBatchUI.jaxx 2012-12-14 16:59:03 UTC (rev 60)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/species/SpeciesBatchUI.jaxx 2012-12-14 16:59:59 UTC (rev 61)
@@ -31,6 +31,7 @@
fr.ifremer.tutti.ui.swing.content.operation.FishingOperationsUI
fr.ifremer.tutti.ui.swing.content.operation.species.SpeciesFrequencyUI
fr.ifremer.tutti.ui.swing.util.editor.LongTextEditorUI
+ fr.ifremer.tutti.ui.swing.util.editor.AttachmentEditorUI
org.jdesktop.swingx.JXTable
@@ -79,6 +80,8 @@
<SpeciesFrequencyUI id='frequencyUI' constructorParams='handler.getContext()'/>
<LongTextEditorUI id='longTextEditorUI'/>
+
+ <AttachmentEditorUI id='attachmentEditorUI'/>
<Table id='form' fill='both' constraints='BorderLayout.NORTH'>
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/species/SpeciesBatchUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/species/SpeciesBatchUIHandler.java 2012-12-14 16:59:03 UTC (rev 60)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/species/SpeciesBatchUIHandler.java 2012-12-14 16:59:59 UTC (rev 61)
@@ -41,6 +41,7 @@
import fr.ifremer.tutti.ui.swing.content.operation.FishingOperationsUI;
import fr.ifremer.tutti.ui.swing.util.TuttiBeanMonitor;
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.AbstractTuttiTableUIHandler;
import fr.ifremer.tutti.ui.swing.util.table.TableRowModificationListener;
@@ -117,6 +118,7 @@
SpeciesBatchRowModel.PROPERTY_AGE,
SpeciesBatchRowModel.PROPERTY_WEIGHT,
SpeciesBatchRowModel.PROPERTY_COMMENT,
+ SpeciesBatchRowModel.PROPERTY_ATTACHMENTS,
SpeciesBatchRowModel.PROPERTY_FREQUENCY);
this.ui = ui;
this.persistenceService = context.getService(PersistenceService.class);
@@ -308,7 +310,9 @@
{ // File column
addColumnToModel(columnModel,
- SpeciesBatchTableModel.FILE);
+ AttachmentCellComponent.newEditor(ui.getAttachmentEditorUI()),
+ AttachmentCellComponent.newRender(),
+ SpeciesBatchTableModel.ATTACHMENTS);
}
return columnModel;
}
Copied: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/AttachmentCellComponent.java (from rev 57, trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/LongTextCellComponent.java)
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/AttachmentCellComponent.java (rev 0)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/AttachmentCellComponent.java 2012-12-14 16:59:59 UTC (rev 61)
@@ -0,0 +1,260 @@
+package fr.ifremer.tutti.ui.swing.util.editor;
+
+import fr.ifremer.tutti.ui.swing.util.ComponentResizer;
+import com.google.common.base.Preconditions;
+import fr.ifremer.tutti.ui.swing.AbstractTuttiBeanUIModel;
+import fr.ifremer.tutti.ui.swing.util.ComponentMover;
+import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil;
+import fr.ifremer.tutti.ui.swing.util.table.AbstractSelectTableAction;
+import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableModel;
+import fr.ifremer.tutti.ui.swing.util.table.ColumnIdentifier;
+import java.awt.event.WindowAdapter;
+import java.awt.Color;
+import java.awt.Component;
+import java.awt.Frame;
+import java.awt.event.KeyAdapter;
+import java.awt.event.KeyEvent;
+import java.awt.event.MouseAdapter;
+import java.awt.event.MouseEvent;
+import java.awt.event.WindowEvent;
+import javax.swing.AbstractCellEditor;
+import javax.swing.BorderFactory;
+import javax.swing.JButton;
+import javax.swing.JDialog;
+import javax.swing.JTable;
+import javax.swing.border.LineBorder;
+import javax.swing.table.TableCellEditor;
+import javax.swing.table.TableCellRenderer;
+import jaxx.runtime.JAXXUtil;
+import jaxx.runtime.SwingUtil;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * Component to edit a cell containing attachments
+ *
+ * @author kmorin
+ * @since 0.2
+ */
+public class AttachmentCellComponent extends JButton {
+
+ /** Logger. */
+ private static final Log log = LogFactory.getLog(AttachmentCellComponent.class);
+
+ public AttachmentCellComponent() {
+ setContentAreaFilled(false);
+ setOpaque(false);
+ setIcon(SwingUtil.createActionIcon("edit"));
+ }
+
+ public static TableCellRenderer newRender() {
+ return new AttachmentCellRenderer();
+ }
+
+ public static TableCellEditor newEditor(AttachmentEditorUI ui) {
+ return new AttachmentCellEditor(ui);
+ }
+
+
+ public static class AttachmentCellEditor extends AbstractCellEditor implements TableCellEditor {
+
+ protected final AttachmentCellComponent component;
+
+ protected final AttachmentEditorUI ui;
+
+ protected Frame frame;
+
+ protected JTable table;
+
+ protected AbstractTuttiTableModel<AbstractTuttiBeanUIModel> tableModel;
+
+ protected ColumnIdentifier<AbstractTuttiBeanUIModel> columnIdentifier;
+
+ protected AbstractTuttiBeanUIModel editRow;
+
+ protected Integer rowIndex;
+
+ protected Integer columnIndex;
+
+ public AttachmentCellEditor(AttachmentEditorUI ui) {
+ this.ui = ui;
+
+ component = new AttachmentCellComponent();
+ component.setBorder(new LineBorder(Color.BLACK));
+ component.addKeyListener(new KeyAdapter() {
+ @Override
+ public void keyReleased(KeyEvent e) {
+ if (e.getKeyCode() == KeyEvent.VK_ENTER ||
+ e.getKeyCode() == KeyEvent.VK_SPACE) {
+ e.consume();
+ startEdit();
+ }
+ }
+ });
+
+ component.addMouseListener(new MouseAdapter() {
+ @Override
+ public void mouseClicked(MouseEvent e) {
+ e.consume();
+ startEdit();
+ }
+ });
+ }
+
+ protected void startEdit() {
+ if (frame == null) {
+ frame = SwingUtil.getParentContainer(ui, Frame.class);
+ }
+
+ ui.setBorder(BorderFactory.createTitledBorder(_(columnIdentifier.getHeaderI18nKey())));
+ ui.setBean(editRow);
+ ui.setProperty(columnIdentifier.getPropertyName());
+
+ JDialog editor = new JDialog(frame, true);
+ editor.setUndecorated(true);
+ editor.add(ui);
+ editor.setResizable(true);
+ editor.pack();
+
+ ComponentResizer cr = new ComponentResizer();
+ cr.registerComponent(editor);
+ ComponentMover cm = new ComponentMover();
+ cm.setDragInsets(cr.getDragInsets());
+ cm.registerComponent(editor);
+
+ editor.addWindowListener(new WindowAdapter() {
+
+ @Override
+ public void windowClosed(WindowEvent e) {
+ Component ui = (Component) e.getSource();
+ if (log.isInfoEnabled()) {
+ log.info("Destroy ui " + ui);
+ }
+ JAXXUtil.destroy(ui);
+ }
+ });
+
+ // Computes the location of bottom left corner of the cell
+ Component comp = component;
+ int x = 0;
+ int y = component.getHeight();
+ while (comp != null) {
+ x += comp.getX();
+ y += comp.getY();
+ comp = comp.getParent();
+ }
+ // if the editor is too big on the right,
+ // then align its right side to the right side of the cell
+ if (x + editor.getWidth() > frame.getX() + frame.getWidth()) {
+ x = x - editor.getWidth() + component.getWidth();
+ }
+ editor.setLocation(x, y);
+ editor.setVisible(true);
+
+ int r = rowIndex;
+ int c = columnIndex;
+
+ // stop edition
+ stopCellEditing();
+
+ // reselect this cell
+ AbstractSelectTableAction.doSelectCell(table, r, c);
+ }
+
+ @Override
+ public Component getTableCellEditorComponent(JTable table,
+ Object value,
+ boolean isSelected,
+ int row,
+ int column) {
+ if (tableModel == null) {
+ tableModel = (AbstractTuttiTableModel<AbstractTuttiBeanUIModel>) table.getModel();
+ this.table = table;
+ columnIdentifier = tableModel.getPropertyName(column);
+ }
+
+ rowIndex = row;
+ columnIndex = column;
+
+ editRow = tableModel.getEntry(row);
+
+ return component;
+ }
+
+ @Override
+ public Object getCellEditorValue() {
+
+ Preconditions.checkNotNull(editRow, "No editRow found in editor.");
+
+ String propertyName = columnIdentifier.getPropertyName();
+ Object result = TuttiUIUtil.getProperty(editRow, propertyName);
+ if (log.isInfoEnabled()) {
+ log.info("editor value (" + propertyName + "): " + result);
+ }
+
+ return result;
+ }
+
+ @Override
+ public boolean stopCellEditing() {
+ boolean b = super.stopCellEditing();
+ if (b) {
+ rowIndex = null;
+ editRow = null;
+ columnIndex = null;
+ }
+ return b;
+ }
+
+ @Override
+ public void cancelCellEditing() {
+ super.cancelCellEditing();
+ rowIndex = null;
+ columnIndex = null;
+ editRow = null;
+ }
+ }
+
+ public static class AttachmentCellRenderer implements TableCellRenderer {
+
+ protected final AttachmentCellComponent component;
+
+ protected String propertyName;
+
+ public AttachmentCellRenderer() {
+ component = new AttachmentCellComponent();
+ }
+
+ @Override
+ public Component getTableCellRendererComponent(JTable table,
+ Object value,
+ boolean isSelected,
+ boolean hasFocus,
+ int row,
+ int column) {
+
+ String text;
+ if (value == null) {
+ if (propertyName == null) {
+ AbstractTuttiTableModel tableModel =
+ (AbstractTuttiTableModel) table.getModel();
+ ColumnIdentifier columnIdentifier = tableModel.getPropertyName(column);
+ propertyName = columnIdentifier.getPropertyName();
+ }
+ // use HTML to show the tooltip in italic
+ text = "<html><body><i>" + _("tutti.tooltip." + propertyName + ".none") + "</i></body></html>";
+
+ } else {
+ // use html to display the tooltip on several lines
+ text = "<html><body>" + String.valueOf(value).replace("\n", "<br/>") + "</body></html>";
+ }
+
+ boolean editable = table.isCellEditable(row, column);
+ component.setEnabled(editable);
+ component.setToolTipText(text);
+ return component;
+ }
+ }
+}
Copied: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/AttachmentEditorUI.css (from rev 57, trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/LongTextEditorUI.css)
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/AttachmentEditorUI.css (rev 0)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/AttachmentEditorUI.css 2012-12-14 16:59:59 UTC (rev 61)
@@ -0,0 +1,23 @@
+#fileLabel {
+ text: "tutti.label.attachmentEditor.file";
+ labelFor: {file};
+}
+
+#fileNameLabel {
+ text: "tutti.label.attachmentEditor.fileName";
+ labelFor: {fileName};
+}
+
+#fileCommentLabel {
+ text: "tutti.label.attachmentEditor.fileComment";
+ labelFor: {fileComment};
+}
+
+#addButton {
+ actionIcon: "add";
+}
+
+#closeButton {
+ actionIcon: "close";
+ text: "tutti.action.close";
+}
Copied: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/AttachmentEditorUI.jaxx (from rev 57, trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/LongTextEditorUI.jaxx)
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/AttachmentEditorUI.jaxx (rev 0)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/AttachmentEditorUI.jaxx 2012-12-14 16:59:59 UTC (rev 61)
@@ -0,0 +1,64 @@
+<Table id='mainPanel'>
+
+ <import>
+ fr.ifremer.tutti.ui.swing.AbstractTuttiBeanUIModel
+ fr.ifremer.tutti.persistence.entities.data.Attachment
+ </import>
+
+ <!-- bean property linked state -->
+ <String id='property' javaBean='""'/>
+
+ <!-- if true, display the form to add attachments
+ and the button to remove existing attachments -->
+ <Boolean id='editable' javaBean='true'/>
+
+ <!-- bean property -->
+ <AbstractTuttiBeanUIModel id='bean' javaBean='null'/>
+
+ <AttachmentEditorUIHandler id='handler' constructorParams='this'/>
+
+ <Attachment id='model' javaBean='null'/>
+
+ <row fill='both'>
+ <cell fill='both' weightx='1' columns='3'>
+ <VBox id='attachments'></VBox>
+ </cell>
+ </row>
+ <row fill='both'>
+ <cell fill='both' weightx='1'>
+ <JLabel id='fileLabel'/>
+ </cell>
+ <cell fill='both' weightx='1'>
+ <JTextField id='file'
+ onMouseClicked='handler.chooseFile()'/>
+ </cell>
+ <cell fill='both' rows='3'>
+ <JButton id='addButton'
+ onActionPerformed='handler.addAttachment()'/>
+ </cell>
+ </row>
+ <row fill='both'>
+ <cell fill='both' weightx='1'>
+ <JLabel id='fileNameLabel'/>
+ </cell>
+ <cell fill='both' weightx='1'>
+ <JTextField id='fileName'/>
+ </cell>
+ </row>
+ <row fill='both' weighty='1'>
+ <cell fill='both' weightx='1'>
+ <JLabel id='fileCommentLabel'/>
+ </cell>
+ <cell fill='both' weightx='1'>
+ <JScrollPane>
+ <JTextArea id='fileComment' rows='3'/>
+ </JScrollPane>
+ </cell>
+ </row>
+ <row fill='both'>
+ <!-- actions -->
+ <cell fill='both' weightx='1' columns='3'>
+ <JButton id='closeButton' onActionPerformed='handler.close()'/>
+ </cell>
+ </row>
+</Table>
\ No newline at end of file
Copied: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/AttachmentEditorUIHandler.java (from rev 57, trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/LongTextEditorUIHandler.java)
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/AttachmentEditorUIHandler.java (rev 0)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/AttachmentEditorUIHandler.java 2012-12-14 16:59:59 UTC (rev 61)
@@ -0,0 +1,174 @@
+package fr.ifremer.tutti.ui.swing.util.editor;
+
+import com.google.common.collect.Lists;
+import fr.ifremer.tutti.persistence.entities.data.Attachment;
+import fr.ifremer.tutti.ui.swing.AbstractTuttiBeanUIModel;
+import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil;
+import java.awt.Cursor;
+import java.awt.Desktop;
+import java.awt.Window;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.MouseAdapter;
+import java.awt.event.MouseEvent;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.io.File;
+import java.io.IOException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.List;
+import javax.swing.JButton;
+import javax.swing.JDialog;
+import javax.swing.JFileChooser;
+import javax.swing.JLabel;
+import javax.swing.SwingConstants;
+import jaxx.runtime.SwingUtil;
+import jaxx.runtime.swing.HBox;
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * Handler of the LongTextEditorUI
+ * @author kmorin
+ * @since 0.2
+ */
+public class AttachmentEditorUIHandler {
+
+ private static final Log log = LogFactory.getLog(AttachmentEditorUIHandler.class);
+
+ private final AttachmentEditorUI ui;
+
+ private JFileChooser fileChooser = new JFileChooser();
+
+ public AttachmentEditorUIHandler(AttachmentEditorUI attachmentEditorUI) {
+ ui = attachmentEditorUI;
+
+ ui.addPropertyChangeListener(new PropertyChangeListener() {
+
+ public void propertyChange(PropertyChangeEvent evt) {
+ init();
+ }
+ });
+ }
+
+ public void init() {
+ resetFields();
+ ui.getAttachments().removeAll();
+ AbstractTuttiBeanUIModel bean = ui.getBean();
+ String property = ui.getProperty();
+ if (bean != null && !StringUtils.isEmpty(property)) {
+ List<Attachment> list = (List<Attachment>) TuttiUIUtil.getProperty(bean, property);
+ if (list != null) {
+ for (Attachment attachment : list) {
+ addAttachment(attachment);
+ }
+ }
+ }
+ }
+
+ protected void addAttachment(final Attachment attachment) {
+ final HBox hbox = new HBox();
+ hbox.setVerticalAlignment(SwingConstants.CENTER);
+
+ JButton deleteButton = new JButton(SwingUtil.createActionIcon("delete"));
+ deleteButton.addActionListener(new ActionListener() {
+
+ public void actionPerformed(ActionEvent e) {
+ AbstractTuttiBeanUIModel bean = ui.getBean();
+ String property = ui.getProperty();
+ List<Attachment> list = (List<Attachment>) TuttiUIUtil.getProperty(bean, property);
+ if (list != null) {
+ list.remove(attachment);
+ TuttiUIUtil.setProperty(bean, property, list);
+ }
+
+ ui.getAttachments().remove(hbox);
+
+ JDialog parent = SwingUtil.getParentContainer(ui, JDialog.class);
+ parent.pack();
+ }
+ });
+ hbox.add(deleteButton);
+
+ final JLabel label = new JLabel("<html><body><a href=''>"
+ + attachment.getName() + "</a></body></html>");
+ label.setToolTipText(attachment.getComment());
+ label.addMouseListener(new MouseAdapter() {
+
+ @Override
+ public void mouseClicked(MouseEvent e) {
+ SwingUtil.openLink("file://" + attachment.getFile().getAbsolutePath());
+ }
+
+ @Override
+ public void mouseEntered(MouseEvent e) {
+ label.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
+ }
+
+ @Override
+ public void mouseExited(MouseEvent e) {
+ label.setCursor(Cursor.getDefaultCursor());
+ }
+
+ });
+ hbox.add(label);
+
+ ui.getAttachments().add(hbox);
+ }
+
+ /**
+ * closes the editor
+ */
+ public void close() {
+ if (log.isInfoEnabled()) {
+ log.info("Will close UI " + ui);
+ }
+ SwingUtil.getParentContainer(ui, Window.class).dispose();
+ }
+
+ public void chooseFile() {
+ if (fileChooser.showOpenDialog(ui) == JFileChooser.APPROVE_OPTION) {
+ File file = fileChooser.getSelectedFile();
+ ui.getModel().setFile(file);
+ ui.getFile().setText(file.getAbsolutePath());
+ }
+ }
+
+ public void addAttachment() {
+ AbstractTuttiBeanUIModel bean = ui.getBean();
+ String property = ui.getProperty();
+ List<Attachment> list = (List<Attachment>) TuttiUIUtil.getProperty(bean, property);
+ if (list == null) {
+ list = Lists.newArrayList();
+ }
+ Attachment attachment = ui.getModel();
+ File file = attachment.getFile();
+ if (file != null) {
+ String name = ui.getFileName().getText();
+ if (StringUtils.isEmpty(name)) {
+ name = file.getName();
+ }
+ attachment.setName(name);
+ attachment.setComment(ui.getFileComment().getText());
+ list.add(attachment);
+ TuttiUIUtil.setProperty(bean, property, list);
+
+ resetFields();
+ addAttachment(attachment);
+
+ JDialog parent = SwingUtil.getParentContainer(ui, JDialog.class);
+ parent.pack();
+ }
+ }
+
+ protected void resetFields() {
+ ui.setModel(new Attachment());
+ fileChooser.setSelectedFile(null);
+ ui.getFile().setText("");
+ ui.getFileName().setText("");
+ ui.getFileComment().setText("");
+ }
+
+}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/LongTextCellComponent.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/LongTextCellComponent.java 2012-12-14 16:59:03 UTC (rev 60)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/LongTextCellComponent.java 2012-12-14 16:59:59 UTC (rev 61)
@@ -1,7 +1,3 @@
-/*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
package fr.ifremer.tutti.ui.swing.util.editor;
import fr.ifremer.tutti.ui.swing.util.ComponentResizer;
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/LongTextEditorUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/LongTextEditorUIHandler.java 2012-12-14 16:59:03 UTC (rev 60)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/LongTextEditorUIHandler.java 2012-12-14 16:59:59 UTC (rev 61)
@@ -1,7 +1,3 @@
-/*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
package fr.ifremer.tutti.ui.swing.util.editor;
import fr.ifremer.tutti.ui.swing.AbstractTuttiBeanUIModel;
Added: trunk/tutti-ui-swing/src/main/resources/icons/action-delete.png
===================================================================
(Binary files differ)
Property changes on: trunk/tutti-ui-swing/src/main/resources/icons/action-delete.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
1
0
14 Dec '12
Author: kmorin
Date: 2012-12-14 17:59:03 +0100 (Fri, 14 Dec 2012)
New Revision: 60
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/60
Log:
add attachment class
Modified:
trunk/tutti-persistence/src/main/xmi/tutti-persistence.zargo
Modified: trunk/tutti-persistence/src/main/xmi/tutti-persistence.zargo
===================================================================
(Binary files differ)
1
0
14 Dec '12
Author: kmorin
Date: 2012-12-14 17:28:45 +0100 (Fri, 14 Dec 2012)
New Revision: 59
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/59
Log:
add translation
Modified:
trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties
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 2012-12-14 10:12:14 UTC (rev 58)
+++ trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties 2012-12-14 16:28:45 UTC (rev 59)
@@ -41,6 +41,9 @@
tutti.config.ui.autoPopupNumberEditor=Toujours afficher le pav\u00c3\u00a9 num\u00c3\u00a9rique lors de l'\u00c3\u00a9dition d'un nombre
tutti.config.ui.config=Chemin du fichier de configuration des interfaces graphiques
tutti.config.ui.showNumberEditorButton=Afficher le pav\u00c3\u00a9 num\u00c3\u00a9rique de saisie
+tutti.label.attachmentEditor.file=Fichier
+tutti.label.attachmentEditor.fileComment=Commentaire
+tutti.label.attachmentEditor.fileName=Nom
tutti.label.benthos.sampleTotalWeight=Poids total \u00c3\u00a9chantillonn\u00c3\u00a9
tutti.label.benthos.totalWeight=Poids total
tutti.label.comment=Commentaire
1
0
r58 - in trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation: accidental benthos macrowaste plankton
by kmorin@users.forge.codelutin.com 14 Dec '12
by kmorin@users.forge.codelutin.com 14 Dec '12
14 Dec '12
Author: kmorin
Date: 2012-12-14 11:12:14 +0100 (Fri, 14 Dec 2012)
New Revision: 58
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/58
Log:
add comment editor to the tables with a comment column
Modified:
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/accidental/AccidentalBatchUI.jaxx
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/accidental/AccidentalBatchUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/benthos/BenthosBatchUI.jaxx
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/benthos/BenthosBatchUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/macrowaste/MacroWasteBatchUI.jaxx
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/macrowaste/MacroWasteBatchUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/plankton/PlanktonBatchUI.jaxx
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/plankton/PlanktonBatchUIHandler.java
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/accidental/AccidentalBatchUI.jaxx
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/accidental/AccidentalBatchUI.jaxx 2012-12-13 17:13:46 UTC (rev 57)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/accidental/AccidentalBatchUI.jaxx 2012-12-14 10:12:14 UTC (rev 58)
@@ -29,6 +29,7 @@
fr.ifremer.tutti.ui.swing.TuttiUIContext
fr.ifremer.tutti.ui.swing.content.operation.FishingOperationsUI
+ fr.ifremer.tutti.ui.swing.util.editor.LongTextEditorUI
jaxx.runtime.swing.editor.NumberEditor
@@ -60,6 +61,8 @@
<AccidentalBatchUIModel id='model'
initializer='getContextValue(AccidentalBatchUIModel.class)'/>
+ <LongTextEditorUI id='longTextEditorUI'/>
+
<JScrollPane id='tableScrollPane' constraints='BorderLayout.CENTER'>
<JXTable id='table' onFocusLost='handler.saveSelectedRowIfRequired(event);'/>
</JScrollPane>
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/accidental/AccidentalBatchUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/accidental/AccidentalBatchUIHandler.java 2012-12-13 17:13:46 UTC (rev 57)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/accidental/AccidentalBatchUIHandler.java 2012-12-14 10:12:14 UTC (rev 58)
@@ -35,6 +35,7 @@
import fr.ifremer.tutti.ui.swing.content.operation.FishingOperationsUI;
import fr.ifremer.tutti.ui.swing.util.TuttiBeanMonitor;
import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil;
+import fr.ifremer.tutti.ui.swing.util.editor.LongTextCellComponent;
import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableUIHandler;
import fr.ifremer.tutti.ui.swing.util.table.TableRowModificationListener;
import jaxx.runtime.SwingUtil;
@@ -154,6 +155,8 @@
{ // Comment column
addColumnToModel(columnModel,
+ LongTextCellComponent.newEditor(ui.getLongTextEditorUI()),
+ LongTextCellComponent.newRender(),
AccidentalBatchTableModel.COMMENT);
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/benthos/BenthosBatchUI.jaxx
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/benthos/BenthosBatchUI.jaxx 2012-12-13 17:13:46 UTC (rev 57)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/benthos/BenthosBatchUI.jaxx 2012-12-14 10:12:14 UTC (rev 58)
@@ -29,6 +29,7 @@
fr.ifremer.tutti.ui.swing.TuttiUIContext
fr.ifremer.tutti.ui.swing.content.operation.FishingOperationsUI
+ fr.ifremer.tutti.ui.swing.util.editor.LongTextEditorUI
jaxx.runtime.swing.editor.NumberEditor
@@ -71,6 +72,8 @@
<field name='sampleTotalWeight' component='sampleTotalWeightField'/>
</BeanValidator>
+ <LongTextEditorUI id='longTextEditorUI'/>
+
<Table id='form' fill='both' constraints='BorderLayout.NORTH'>
<!-- Poids total -->
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/benthos/BenthosBatchUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/benthos/BenthosBatchUIHandler.java 2012-12-13 17:13:46 UTC (rev 57)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/benthos/BenthosBatchUIHandler.java 2012-12-14 10:12:14 UTC (rev 58)
@@ -35,6 +35,7 @@
import fr.ifremer.tutti.ui.swing.content.operation.FishingOperationsUI;
import fr.ifremer.tutti.ui.swing.util.TuttiBeanMonitor;
import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil;
+import fr.ifremer.tutti.ui.swing.util.editor.LongTextCellComponent;
import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableUIHandler;
import fr.ifremer.tutti.ui.swing.util.table.TableRowModificationListener;
import jaxx.runtime.SwingUtil;
@@ -186,6 +187,8 @@
{ // Comment column
addColumnToModel(columnModel,
+ LongTextCellComponent.newEditor(ui.getLongTextEditorUI()),
+ LongTextCellComponent.newRender(),
BenthosBatchTableModel.COMMENT);
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/macrowaste/MacroWasteBatchUI.jaxx
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/macrowaste/MacroWasteBatchUI.jaxx 2012-12-13 17:13:46 UTC (rev 57)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/macrowaste/MacroWasteBatchUI.jaxx 2012-12-14 10:12:14 UTC (rev 58)
@@ -29,6 +29,7 @@
fr.ifremer.tutti.ui.swing.TuttiUIContext
fr.ifremer.tutti.ui.swing.content.operation.FishingOperationsUI
+ fr.ifremer.tutti.ui.swing.util.editor.LongTextEditorUI
jaxx.runtime.swing.editor.NumberEditor
@@ -70,6 +71,8 @@
<field name='totalWeight' component='totalWeightField'/>
</BeanValidator>
+ <LongTextEditorUI id='longTextEditorUI'/>
+
<Table id='form' fill='both' constraints='BorderLayout.NORTH'>
<!-- Poids total -->
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/macrowaste/MacroWasteBatchUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/macrowaste/MacroWasteBatchUIHandler.java 2012-12-13 17:13:46 UTC (rev 57)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/macrowaste/MacroWasteBatchUIHandler.java 2012-12-14 10:12:14 UTC (rev 58)
@@ -35,6 +35,7 @@
import fr.ifremer.tutti.ui.swing.content.operation.FishingOperationsUI;
import fr.ifremer.tutti.ui.swing.util.TuttiBeanMonitor;
import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil;
+import fr.ifremer.tutti.ui.swing.util.editor.LongTextCellComponent;
import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableUIHandler;
import fr.ifremer.tutti.ui.swing.util.table.TableRowModificationListener;
import jaxx.runtime.SwingUtil;
@@ -157,6 +158,8 @@
{ // Comment column
addColumnToModel(columnModel,
+ LongTextCellComponent.newEditor(ui.getLongTextEditorUI()),
+ LongTextCellComponent.newRender(),
MacroWasteBatchTableModel.COMMENT);
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/plankton/PlanktonBatchUI.jaxx
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/plankton/PlanktonBatchUI.jaxx 2012-12-13 17:13:46 UTC (rev 57)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/plankton/PlanktonBatchUI.jaxx 2012-12-14 10:12:14 UTC (rev 58)
@@ -29,6 +29,7 @@
fr.ifremer.tutti.ui.swing.TuttiUIContext
fr.ifremer.tutti.ui.swing.content.operation.FishingOperationsUI
+ fr.ifremer.tutti.ui.swing.util.editor.LongTextEditorUI
jaxx.runtime.swing.editor.NumberEditor
@@ -71,6 +72,8 @@
<field name='sampleTotalWeight' component='sampleTotalWeightField'/>
</BeanValidator>
+ <LongTextEditorUI id='longTextEditorUI'/>
+
<Table id='form' fill='both' constraints='BorderLayout.NORTH'>
<!-- Poids total -->
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/plankton/PlanktonBatchUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/plankton/PlanktonBatchUIHandler.java 2012-12-13 17:13:46 UTC (rev 57)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/plankton/PlanktonBatchUIHandler.java 2012-12-14 10:12:14 UTC (rev 58)
@@ -35,6 +35,7 @@
import fr.ifremer.tutti.ui.swing.content.operation.FishingOperationsUI;
import fr.ifremer.tutti.ui.swing.util.TuttiBeanMonitor;
import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil;
+import fr.ifremer.tutti.ui.swing.util.editor.LongTextCellComponent;
import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableUIHandler;
import fr.ifremer.tutti.ui.swing.util.table.TableRowModificationListener;
import jaxx.runtime.SwingUtil;
@@ -186,6 +187,8 @@
{ // Comment column
addColumnToModel(columnModel,
+ LongTextCellComponent.newEditor(ui.getLongTextEditorUI()),
+ LongTextCellComponent.newRender(),
PlanktonBatchTableModel.COMMENT);
}
1
0
r57 - in trunk/tutti-ui-swing/src/main: java/fr/ifremer/tutti/ui/swing/content/operation/species java/fr/ifremer/tutti/ui/swing/util java/fr/ifremer/tutti/ui/swing/util/editor resources/i18n
by kmorin@users.forge.codelutin.com 13 Dec '12
by kmorin@users.forge.codelutin.com 13 Dec '12
13 Dec '12
Author: kmorin
Date: 2012-12-13 18:13:46 +0100 (Thu, 13 Dec 2012)
New Revision: 57
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/57
Log:
create comment editor
Added:
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/ComponentMover.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/ComponentResizer.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/LongTextCellComponent.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/LongTextEditorUI.css
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/LongTextEditorUI.jaxx
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/LongTextEditorUIHandler.java
Modified:
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/species/SpeciesBatchUI.jaxx
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/species/SpeciesBatchUIHandler.java
trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/species/SpeciesBatchUI.jaxx
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/species/SpeciesBatchUI.jaxx 2012-12-13 15:37:44 UTC (rev 56)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/species/SpeciesBatchUI.jaxx 2012-12-13 17:13:46 UTC (rev 57)
@@ -30,6 +30,7 @@
fr.ifremer.tutti.ui.swing.TuttiUIContext
fr.ifremer.tutti.ui.swing.content.operation.FishingOperationsUI
fr.ifremer.tutti.ui.swing.content.operation.species.SpeciesFrequencyUI
+ fr.ifremer.tutti.ui.swing.util.editor.LongTextEditorUI
org.jdesktop.swingx.JXTable
@@ -76,6 +77,8 @@
</BeanValidator>
<SpeciesFrequencyUI id='frequencyUI' constructorParams='handler.getContext()'/>
+
+ <LongTextEditorUI id='longTextEditorUI'/>
<Table id='form' fill='both' constraints='BorderLayout.NORTH'>
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/species/SpeciesBatchUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/species/SpeciesBatchUIHandler.java 2012-12-13 15:37:44 UTC (rev 56)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/species/SpeciesBatchUIHandler.java 2012-12-13 17:13:46 UTC (rev 57)
@@ -41,6 +41,7 @@
import fr.ifremer.tutti.ui.swing.content.operation.FishingOperationsUI;
import fr.ifremer.tutti.ui.swing.util.TuttiBeanMonitor;
import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil;
+import fr.ifremer.tutti.ui.swing.util.editor.LongTextCellComponent;
import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableUIHandler;
import fr.ifremer.tutti.ui.swing.util.table.TableRowModificationListener;
import jaxx.runtime.SwingUtil;
@@ -299,6 +300,8 @@
{ // Comment column
addColumnToModel(columnModel,
+ LongTextCellComponent.newEditor(ui.getLongTextEditorUI()),
+ LongTextCellComponent.newRender(),
SpeciesBatchTableModel.COMMENT);
}
Added: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/ComponentMover.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/ComponentMover.java (rev 0)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/ComponentMover.java 2012-12-13 17:13:46 UTC (rev 57)
@@ -0,0 +1,375 @@
+package fr.ifremer.tutti.ui.swing.util;
+
+import java.awt.*;
+import java.awt.event.*;
+import javax.swing.JComponent;
+import javax.swing.SwingUtilities;
+
+/**
+ * This class allows you to move a Component by using a mouse. The Component
+ * moved can be a high level Window (ie. Window, Frame, Dialog) in which case
+ * the Window is moved within the desktop. Or the Component can belong to a
+ * Container in which case the Component is moved within the Container.
+ *
+ * When moving a Window, the listener can be added to a child Component of
+ * the Window. In this case attempting to move the child will result in the
+ * Window moving. For example, you might create a custom "Title Bar" for an
+ * undecorated Window and moving of the Window is accomplished by moving the
+ * title bar only. Multiple components can be registered as "window movers".
+ *
+ * Components can be registered when the class is created. Additional
+ * components can be added at any time using the registerComponent() method.
+ */
+public class ComponentMover extends MouseAdapter
+{
+ private Insets dragInsets = new Insets(0, 0, 0, 0);
+ private Dimension snapSize = new Dimension(1, 1);
+ private Insets edgeInsets = new Insets(0, 0, 0, 0);
+ private boolean changeCursor = true;
+ private boolean autoLayout = false;
+
+ private Class destinationClass;
+ private Component destinationComponent;
+ private Component destination;
+ private Component source;
+
+ private Point pressed;
+ private Point location;
+
+ private Cursor originalCursor;
+ private boolean autoscrolls;
+ private boolean potentialDrag;
+
+
+ /**
+ * Constructor for moving individual components. The components must be
+ * regisetered using the registerComponent() method.
+ */
+ public ComponentMover()
+ {
+ }
+
+ /**
+ * Constructor to specify a Class of Component that will be moved when
+ * drag events are generated on a registered child component. The events
+ * will be passed to the first ancestor of this specified class.
+ *
+ * @param destinationClass the Class of the ancestor component
+ * @param component the Components to be registered for forwarding
+ * drag events to the ancestor Component.
+ */
+ public ComponentMover(Class destinationClass, Component... components)
+ {
+ this.destinationClass = destinationClass;
+ registerComponent( components );
+ }
+
+ /**
+ * Constructor to specify a parent component that will be moved when drag
+ * events are generated on a registered child component.
+ *
+ * @param destinationComponent the component drage events should be forwareded to
+ * @param components the Components to be registered for forwarding drag
+ * events to the parent component to be moved
+ */
+ public ComponentMover(Component destinationComponent, Component... components)
+ {
+ this.destinationComponent = destinationComponent;
+ registerComponent( components );
+ }
+
+ /**
+ * Get the auto layout property
+ *
+ * @return the auto layout property
+ */
+ public boolean isAutoLayout()
+ {
+ return autoLayout;
+ }
+
+ /**
+ * Set the auto layout property
+ *
+ * @param autoLayout when true layout will be invoked on the parent container
+ */
+ public void setAutoLayout(boolean autoLayout)
+ {
+ this.autoLayout = autoLayout;
+ }
+
+ /**
+ * Get the change cursor property
+ *
+ * @return the change cursor property
+ */
+ public boolean isChangeCursor()
+ {
+ return changeCursor;
+ }
+
+ /**
+ * Set the change cursor property
+ *
+ * @param changeCursor when true the cursor will be changed to the
+ * Cursor.MOVE_CURSOR while the mouse is pressed
+ */
+ public void setChangeCursor(boolean changeCursor)
+ {
+ this.changeCursor = changeCursor;
+ }
+
+ /**
+ * Get the drag insets
+ *
+ * @return the drag insets
+ */
+ public Insets getDragInsets()
+ {
+ return dragInsets;
+ }
+
+ /**
+ * Set the drag insets. The insets specify an area where mouseDragged
+ * events should be ignored and therefore the component will not be moved.
+ * This will prevent these events from being confused with a
+ * MouseMotionListener that supports component resizing.
+ *
+ * @param dragInsets
+ */
+ public void setDragInsets(Insets dragInsets)
+ {
+ this.dragInsets = dragInsets;
+ }
+
+ /**
+ * Get the bounds insets
+ *
+ * @return the bounds insets
+ */
+ public Insets getEdgeInsets()
+ {
+ return edgeInsets;
+ }
+
+ /**
+ * Set the edge insets. The insets specify how close to each edge of the parent
+ * component that the child component can be moved. Positive values means the
+ * component must be contained within the parent. Negative values means the
+ * component can be moved outside the parent.
+ *
+ * @param edgeInsets
+ */
+ public void setEdgeInsets(Insets edgeInsets)
+ {
+ this.edgeInsets = edgeInsets;
+ }
+
+ /**
+ * Remove listeners from the specified component
+ *
+ * @param component the component the listeners are removed from
+ */
+ public void deregisterComponent(Component... components)
+ {
+ for (Component component : components)
+ component.removeMouseListener( this );
+ }
+
+ /**
+ * Add the required listeners to the specified component
+ *
+ * @param component the component the listeners are added to
+ */
+ public void registerComponent(Component... components)
+ {
+ for (Component component : components)
+ component.addMouseListener( this );
+ }
+
+ /**
+ * Get the snap size
+ *
+ * @return the snap size
+ */
+ public Dimension getSnapSize()
+ {
+ return snapSize;
+ }
+
+ /**
+ * Set the snap size. Forces the component to be snapped to
+ * the closest grid position. Snapping will occur when the mouse is
+ * dragged half way.
+ */
+ public void setSnapSize(Dimension snapSize)
+ {
+ if (snapSize.width < 1
+ || snapSize.height < 1)
+ throw new IllegalArgumentException("Snap sizes must be greater than 0");
+
+ this.snapSize = snapSize;
+ }
+
+ /**
+ * Setup the variables used to control the moving of the component:
+ *
+ * source - the source component of the mouse event
+ * destination - the component that will ultimately be moved
+ * pressed - the Point where the mouse was pressed in the destination
+ * component coordinates.
+ */
+ @Override
+ public void mousePressed(MouseEvent e)
+ {
+ source = e.getComponent();
+ int width = source.getSize().width - dragInsets.left - dragInsets.right;
+ int height = source.getSize().height - dragInsets.top - dragInsets.bottom;
+ Rectangle r = new Rectangle(dragInsets.left, dragInsets.top, width, height);
+
+ if (r.contains(e.getPoint()))
+ setupForDragging(e);
+ }
+
+ private void setupForDragging(MouseEvent e)
+ {
+ source.addMouseMotionListener( this );
+ potentialDrag = true;
+
+ // Determine the component that will ultimately be moved
+
+ if (destinationComponent != null)
+ {
+ destination = destinationComponent;
+ }
+ else if (destinationClass == null)
+ {
+ destination = source;
+ }
+ else // forward events to destination component
+ {
+ destination = SwingUtilities.getAncestorOfClass(destinationClass, source);
+ }
+
+ pressed = e.getLocationOnScreen();
+ location = destination.getLocation();
+
+ if (changeCursor)
+ {
+ originalCursor = source.getCursor();
+ source.setCursor( Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR) );
+ }
+
+ // Making sure autoscrolls is false will allow for smoother dragging of
+ // individual components
+
+ if (destination instanceof JComponent)
+ {
+ JComponent jc = (JComponent)destination;
+ autoscrolls = jc.getAutoscrolls();
+ jc.setAutoscrolls( false );
+ }
+ }
+
+ /**
+ * Move the component to its new location. The dragged Point must be in
+ * the destination coordinates.
+ */
+ @Override
+ public void mouseDragged(MouseEvent e)
+ {
+ Point dragged = e.getLocationOnScreen();
+ int dragX = getDragDistance(dragged.x, pressed.x, snapSize.width);
+ int dragY = getDragDistance(dragged.y, pressed.y, snapSize.height);
+
+ int locationX = location.x + dragX;
+ int locationY = location.y + dragY;
+
+ // Mouse dragged events are not generated for every pixel the mouse
+ // is moved. Adjust the location to make sure we are still on a
+ // snap value.
+
+ while (locationX < edgeInsets.left)
+ locationX += snapSize.width;
+
+ while (locationY < edgeInsets.top)
+ locationY += snapSize.height;
+
+ Dimension d = getBoundingSize( destination );
+
+ while (locationX + destination.getSize().width + edgeInsets.right > d.width)
+ locationX -= snapSize.width;
+
+ while (locationY + destination.getSize().height + edgeInsets.bottom > d.height)
+ locationY -= snapSize.height;
+
+ // Adjustments are finished, move the component
+
+ destination.setLocation(locationX, locationY);
+ }
+
+ /*
+ * Determine how far the mouse has moved from where dragging started
+ * (Assume drag direction is down and right for positive drag distance)
+ */
+ private int getDragDistance(int larger, int smaller, int snapSize)
+ {
+ int halfway = snapSize / 2;
+ int drag = larger - smaller;
+ drag += (drag < 0) ? -halfway : halfway;
+ drag = (drag / snapSize) * snapSize;
+
+ return drag;
+ }
+
+ /*
+ * Get the bounds of the parent of the dragged component.
+ */
+ private Dimension getBoundingSize(Component source)
+ {
+ if (source instanceof Window)
+ {
+ GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment();
+ Rectangle bounds = env.getMaximumWindowBounds();
+ return new Dimension(bounds.width, bounds.height);
+ }
+ else
+ {
+ return source.getParent().getSize();
+ }
+ }
+
+ /**
+ * Restore the original state of the Component
+ */
+ @Override
+ public void mouseReleased(MouseEvent e)
+ {
+ if (!potentialDrag) return;
+
+ source.removeMouseMotionListener( this );
+ potentialDrag = false;
+
+ if (changeCursor)
+ source.setCursor( originalCursor );
+
+ if (destination instanceof JComponent)
+ {
+ ((JComponent)destination).setAutoscrolls( autoscrolls );
+ }
+
+ // Layout the components on the parent container
+
+ if (autoLayout)
+ {
+ if (destination instanceof JComponent)
+ {
+ ((JComponent)destination).revalidate();
+ }
+ else
+ {
+ destination.validate();
+ }
+ }
+ }
+}
Added: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/ComponentResizer.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/ComponentResizer.java (rev 0)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/ComponentResizer.java 2012-12-13 17:13:46 UTC (rev 57)
@@ -0,0 +1,458 @@
+package fr.ifremer.tutti.ui.swing.util;
+
+import java.awt.*;
+import java.awt.event.*;
+import java.util.*;
+import javax.swing.JComponent;
+import javax.swing.SwingUtilities;
+
+/**
+ * The ComponentResizer allows you to resize a component by dragging a border
+ * of the component.
+ */
+public class ComponentResizer extends MouseAdapter
+{
+ private final static Dimension MINIMUM_SIZE = new Dimension(10, 10);
+ private final static Dimension MAXIMUM_SIZE =
+ new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE);
+
+ private static Map<Integer, Integer> cursors = new HashMap<Integer, Integer>();
+ {
+ cursors.put(1, Cursor.N_RESIZE_CURSOR);
+ cursors.put(2, Cursor.W_RESIZE_CURSOR);
+ cursors.put(4, Cursor.S_RESIZE_CURSOR);
+ cursors.put(8, Cursor.E_RESIZE_CURSOR);
+ cursors.put(3, Cursor.NW_RESIZE_CURSOR);
+ cursors.put(9, Cursor.NE_RESIZE_CURSOR);
+ cursors.put(6, Cursor.SW_RESIZE_CURSOR);
+ cursors.put(12, Cursor.SE_RESIZE_CURSOR);
+ }
+
+ private Insets dragInsets;
+ private Dimension snapSize;
+
+ private int direction;
+ protected static final int NORTH = 1;
+ protected static final int WEST = 2;
+ protected static final int SOUTH = 4;
+ protected static final int EAST = 8;
+
+ private Cursor sourceCursor;
+ private boolean resizing;
+ private Rectangle bounds;
+ private Point pressed;
+ private boolean autoscrolls;
+
+ private Dimension minimumSize = MINIMUM_SIZE;
+ private Dimension maximumSize = MAXIMUM_SIZE;
+
+ /**
+ * Convenience contructor. All borders are resizable in increments of
+ * a single pixel. Components must be registered separately.
+ */
+ public ComponentResizer()
+ {
+ this(new Insets(5, 5, 5, 5), new Dimension(1, 1));
+ }
+
+ /**
+ * Convenience contructor. All borders are resizable in increments of
+ * a single pixel. Components can be registered when the class is created
+ * or they can be registered separately afterwards.
+ *
+ * @param components components to be automatically registered
+ */
+ public ComponentResizer(Component... components)
+ {
+ this(new Insets(5, 5, 5, 5), new Dimension(1, 1), components);
+ }
+
+ /**
+ * Convenience contructor. Eligible borders are resisable in increments of
+ * a single pixel. Components can be registered when the class is created
+ * or they can be registered separately afterwards.
+ *
+ * @param dragInsets Insets specifying which borders are eligible to be
+ * resized.
+ * @param components components to be automatically registered
+ */
+ public ComponentResizer(Insets dragInsets, Component... components)
+ {
+ this(dragInsets, new Dimension(1, 1), components);
+ }
+
+ /**
+ * Create a ComponentResizer.
+ *
+ * @param dragInsets Insets specifying which borders are eligible to be
+ * resized.
+ * @param snapSize Specify the dimension to which the border will snap to
+ * when being dragged. Snapping occurs at the halfway mark.
+ * @param components components to be automatically registered
+ */
+ public ComponentResizer(Insets dragInsets, Dimension snapSize, Component... components)
+ {
+ setDragInsets( dragInsets );
+ setSnapSize( snapSize );
+ registerComponent( components );
+ }
+
+ /**
+ * Get the drag insets
+ *
+ * @return the drag insets
+ */
+ public Insets getDragInsets()
+ {
+ return dragInsets;
+ }
+
+ /**
+ * Set the drag dragInsets. The insets specify an area where mouseDragged
+ * events are recognized from the edge of the border inwards. A value of
+ * 0 for any size will imply that the border is not resizable. Otherwise
+ * the appropriate drag cursor will appear when the mouse is inside the
+ * resizable border area.
+ *
+ * @param dragInsets Insets to control which borders are resizeable.
+ */
+ public void setDragInsets(Insets dragInsets)
+ {
+ validateMinimumAndInsets(minimumSize, dragInsets);
+
+ this.dragInsets = dragInsets;
+ }
+
+ /**
+ * Get the components maximum size.
+ *
+ * @return the maximum size
+ */
+ public Dimension getMaximumSize()
+ {
+ return maximumSize;
+ }
+
+ /**
+ * Specify the maximum size for the component. The component will still
+ * be constrained by the size of its parent.
+ *
+ * @param maximumSize the maximum size for a component.
+ */
+ public void setMaximumSize(Dimension maximumSize)
+ {
+ this.maximumSize = maximumSize;
+ }
+
+ /**
+ * Get the components minimum size.
+ *
+ * @return the minimum size
+ */
+ public Dimension getMinimumSize()
+ {
+ return minimumSize;
+ }
+
+ /**
+ * Specify the minimum size for the component. The minimum size is
+ * constrained by the drag insets.
+ *
+ * @param minimumSize the minimum size for a component.
+ */
+ public void setMinimumSize(Dimension minimumSize)
+ {
+ validateMinimumAndInsets(minimumSize, dragInsets);
+
+ this.minimumSize = minimumSize;
+ }
+
+ /**
+ * Remove listeners from the specified component
+ *
+ * @param component the component the listeners are removed from
+ */
+ public void deregisterComponent(Component... components)
+ {
+ for (Component component : components)
+ {
+ component.removeMouseListener( this );
+ component.removeMouseMotionListener( this );
+ }
+ }
+
+ /**
+ * Add the required listeners to the specified component
+ *
+ * @param component the component the listeners are added to
+ */
+ public void registerComponent(Component... components)
+ {
+ for (Component component : components)
+ {
+ component.addMouseListener( this );
+ component.addMouseMotionListener( this );
+ }
+ }
+
+ /**
+ * Get the snap size.
+ *
+ * @return the snap size.
+ */
+ public Dimension getSnapSize()
+ {
+ return snapSize;
+ }
+
+ /**
+ * Control how many pixels a border must be dragged before the size of
+ * the component is changed. The border will snap to the size once
+ * dragging has passed the halfway mark.
+ *
+ * @param snapSize Dimension object allows you to separately spcify a
+ * horizontal and vertical snap size.
+ */
+ public void setSnapSize(Dimension snapSize)
+ {
+ this.snapSize = snapSize;
+ }
+
+ /**
+ * When the components minimum size is less than the drag insets then
+ * we can't determine which border should be resized so we need to
+ * prevent this from happening.
+ */
+ private void validateMinimumAndInsets(Dimension minimum, Insets drag)
+ {
+ int minimumWidth = drag.left + drag.right;
+ int minimumHeight = drag.top + drag.bottom;
+
+ if (minimum.width < minimumWidth
+ || minimum.height < minimumHeight)
+ {
+ String message = "Minimum size cannot be less than drag insets";
+ throw new IllegalArgumentException( message );
+ }
+ }
+
+ /**
+ */
+ @Override
+ public void mouseMoved(MouseEvent e)
+ {
+ Component source = e.getComponent();
+ Point location = e.getPoint();
+ direction = 0;
+
+ if (location.x < dragInsets.left)
+ direction += WEST;
+
+ if (location.x > source.getWidth() - dragInsets.right - 1)
+ direction += EAST;
+
+ if (location.y < dragInsets.top)
+ direction += NORTH;
+
+ if (location.y > source.getHeight() - dragInsets.bottom - 1)
+ direction += SOUTH;
+
+ // Mouse is no longer over a resizable border
+
+ if (direction == 0)
+ {
+ source.setCursor( sourceCursor );
+ }
+ else // use the appropriate resizable cursor
+ {
+ int cursorType = cursors.get( direction );
+ Cursor cursor = Cursor.getPredefinedCursor( cursorType );
+ source.setCursor( cursor );
+ }
+ }
+
+ @Override
+ public void mouseEntered(MouseEvent e)
+ {
+ if (! resizing)
+ {
+ Component source = e.getComponent();
+ sourceCursor = source.getCursor();
+ }
+ }
+
+ @Override
+ public void mouseExited(MouseEvent e)
+ {
+ if (! resizing)
+ {
+ Component source = e.getComponent();
+ source.setCursor( sourceCursor );
+ }
+ }
+
+ @Override
+ public void mousePressed(MouseEvent e)
+ {
+ // The mouseMoved event continually updates this variable
+
+ if (direction == 0) return;
+
+ // Setup for resizing. All future dragging calculations are done based
+ // on the original bounds of the component and mouse pressed location.
+
+ resizing = true;
+
+ Component source = e.getComponent();
+ pressed = e.getPoint();
+ SwingUtilities.convertPointToScreen(pressed, source);
+ bounds = source.getBounds();
+
+ // Making sure autoscrolls is false will allow for smoother resizing
+ // of components
+
+ if (source instanceof JComponent)
+ {
+ JComponent jc = (JComponent)source;
+ autoscrolls = jc.getAutoscrolls();
+ jc.setAutoscrolls( false );
+ }
+ }
+
+ /**
+ * Restore the original state of the Component
+ */
+ @Override
+ public void mouseReleased(MouseEvent e)
+ {
+ resizing = false;
+
+ Component source = e.getComponent();
+ source.setCursor( sourceCursor );
+
+ if (source instanceof JComponent)
+ {
+ ((JComponent)source).setAutoscrolls( autoscrolls );
+ }
+ }
+
+ /**
+ * Resize the component ensuring location and size is within the bounds
+ * of the parent container and that the size is within the minimum and
+ * maximum constraints.
+ *
+ * All calculations are done using the bounds of the component when the
+ * resizing started.
+ */
+ @Override
+ public void mouseDragged(MouseEvent e)
+ {
+ if (resizing == false) return;
+
+ Component source = e.getComponent();
+ Point dragged = e.getPoint();
+ SwingUtilities.convertPointToScreen(dragged, source);
+
+ changeBounds(source, direction, bounds, pressed, dragged);
+ }
+
+ protected void changeBounds(Component source, int direction, Rectangle bounds, Point pressed, Point current)
+ {
+ // Start with original locaton and size
+
+ int x = bounds.x;
+ int y = bounds.y;
+ int width = bounds.width;
+ int height = bounds.height;
+
+ // Resizing the West or North border affects the size and location
+
+ if (WEST == (direction & WEST))
+ {
+ int drag = getDragDistance(pressed.x, current.x, snapSize.width);
+ int maximum = Math.min(width + x, maximumSize.width);
+ drag = getDragBounded(drag, snapSize.width, width, minimumSize.width, maximum);
+
+ x -= drag;
+ width += drag;
+ }
+
+ if (NORTH == (direction & NORTH))
+ {
+ int drag = getDragDistance(pressed.y, current.y, snapSize.height);
+ int maximum = Math.min(height + y, maximumSize.height);
+ drag = getDragBounded(drag, snapSize.height, height, minimumSize.height, maximum);
+
+ y -= drag;
+ height += drag;
+ }
+
+ // Resizing the East or South border only affects the size
+
+ if (EAST == (direction & EAST))
+ {
+ int drag = getDragDistance(current.x, pressed.x, snapSize.width);
+ Dimension boundingSize = getBoundingSize( source );
+ int maximum = Math.min(boundingSize.width - x, maximumSize.width);
+ drag = getDragBounded(drag, snapSize.width, width, minimumSize.width, maximum);
+ width += drag;
+ }
+
+ if (SOUTH == (direction & SOUTH))
+ {
+ int drag = getDragDistance(current.y, pressed.y, snapSize.height);
+ Dimension boundingSize = getBoundingSize( source );
+ int maximum = Math.min(boundingSize.height - y, maximumSize.height);
+ drag = getDragBounded(drag, snapSize.height, height, minimumSize.height, maximum);
+ height += drag;
+ }
+
+ source.setBounds(x, y, width, height);
+ source.validate();
+ }
+
+ /*
+ * Determine how far the mouse has moved from where dragging started
+ */
+ private int getDragDistance(int larger, int smaller, int snapSize)
+ {
+ int halfway = snapSize / 2;
+ int drag = larger - smaller;
+ drag += (drag < 0) ? -halfway : halfway;
+ drag = (drag / snapSize) * snapSize;
+
+ return drag;
+ }
+
+ /*
+ * Adjust the drag value to be within the minimum and maximum range.
+ */
+ private int getDragBounded(int drag, int snapSize, int dimension, int minimum, int maximum)
+ {
+ while (dimension + drag < minimum)
+ drag += snapSize;
+
+ while (dimension + drag > maximum)
+ drag -= snapSize;
+
+
+ return drag;
+ }
+
+ /*
+ * Keep the size of the component within the bounds of its parent.
+ */
+ private Dimension getBoundingSize(Component source)
+ {
+ if (source instanceof Window)
+ {
+ GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment();
+ Rectangle bounds = env.getMaximumWindowBounds();
+ return new Dimension(bounds.width, bounds.height);
+ }
+ else
+ {
+ return source.getParent().getSize();
+ }
+ }
+}
Added: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/LongTextCellComponent.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/LongTextCellComponent.java (rev 0)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/LongTextCellComponent.java 2012-12-13 17:13:46 UTC (rev 57)
@@ -0,0 +1,268 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package fr.ifremer.tutti.ui.swing.util.editor;
+
+import fr.ifremer.tutti.ui.swing.util.ComponentResizer;
+import com.google.common.base.Preconditions;
+import fr.ifremer.tutti.ui.swing.AbstractTuttiBeanUIModel;
+import fr.ifremer.tutti.ui.swing.util.ComponentMover;
+import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil;
+import fr.ifremer.tutti.ui.swing.util.table.AbstractSelectTableAction;
+import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableModel;
+import fr.ifremer.tutti.ui.swing.util.table.ColumnIdentifier;
+import java.awt.event.WindowAdapter;
+import java.awt.Color;
+import java.awt.Component;
+import java.awt.Frame;
+import java.awt.Insets;
+import java.awt.event.KeyAdapter;
+import java.awt.event.KeyEvent;
+import java.awt.event.MouseAdapter;
+import java.awt.event.MouseEvent;
+import java.awt.event.WindowEvent;
+import javax.swing.AbstractCellEditor;
+import javax.swing.BorderFactory;
+import javax.swing.JButton;
+import javax.swing.JDialog;
+import javax.swing.JTable;
+import javax.swing.border.LineBorder;
+import javax.swing.table.TableCellEditor;
+import javax.swing.table.TableCellRenderer;
+import jaxx.runtime.JAXXUtil;
+import jaxx.runtime.SwingUtil;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * Component to edit a cell in a popup with a text area
+ *
+ * @author kmorin
+ * @since 0.2
+ */
+public class LongTextCellComponent extends JButton{
+
+ /** Logger. */
+ private static final Log log = LogFactory.getLog(LongTextCellComponent.class);
+
+ public LongTextCellComponent() {
+ setContentAreaFilled(false);
+ setOpaque(false);
+ setIcon(SwingUtil.createActionIcon("edit"));
+ }
+
+ public static TableCellRenderer newRender() {
+ return new LongTextCellRenderer();
+ }
+
+ public static TableCellEditor newEditor(LongTextEditorUI ui) {
+ return new LongTextCellEditor(ui);
+ }
+
+
+ public static class LongTextCellEditor extends AbstractCellEditor implements TableCellEditor {
+
+ public static final int DEFAULT_EDITOR_WIDTH = 400;
+ public static final int DEFAULT_EDITOR_HEIGHT = 200;
+
+ protected final LongTextCellComponent component;
+
+ protected final LongTextEditorUI ui;
+
+ protected Frame frame;
+
+ protected JTable table;
+
+ protected AbstractTuttiTableModel<AbstractTuttiBeanUIModel> tableModel;
+
+ protected ColumnIdentifier<AbstractTuttiBeanUIModel> columnIdentifier;
+
+ protected AbstractTuttiBeanUIModel editRow;
+
+ protected Integer rowIndex;
+
+ protected Integer columnIndex;
+
+ public LongTextCellEditor(LongTextEditorUI ui) {
+ this.ui = ui;
+
+ component = new LongTextCellComponent();
+ component.setBorder(new LineBorder(Color.BLACK));
+ component.addKeyListener(new KeyAdapter() {
+ @Override
+ public void keyReleased(KeyEvent e) {
+ if (e.getKeyCode() == KeyEvent.VK_ENTER ||
+ e.getKeyCode() == KeyEvent.VK_SPACE) {
+ e.consume();
+ startEdit();
+ }
+ }
+ });
+
+ component.addMouseListener(new MouseAdapter() {
+ @Override
+ public void mouseClicked(MouseEvent e) {
+ e.consume();
+ startEdit();
+ }
+ });
+ }
+
+ protected void startEdit() {
+ if (frame == null) {
+ frame = SwingUtil.getParentContainer(ui, Frame.class);
+ }
+
+ ui.setBorder(BorderFactory.createTitledBorder(_(columnIdentifier.getHeaderI18nKey())));
+ ui.setBean(editRow);
+ ui.setProperty(columnIdentifier.getPropertyName());
+
+ JDialog editor = new JDialog(frame, true);
+ editor.setUndecorated(true);
+ editor.add(ui);
+ editor.setSize(DEFAULT_EDITOR_WIDTH, DEFAULT_EDITOR_HEIGHT);
+ editor.setResizable(true);
+
+ ComponentResizer cr = new ComponentResizer();
+ cr.registerComponent(editor);
+ ComponentMover cm = new ComponentMover();
+ cm.setDragInsets(cr.getDragInsets());
+ cm.registerComponent(editor);
+
+ editor.addWindowListener(new WindowAdapter() {
+
+ @Override
+ public void windowClosed(WindowEvent e) {
+ Component ui = (Component) e.getSource();
+ if (log.isInfoEnabled()) {
+ log.info("Destroy ui " + ui);
+ }
+ JAXXUtil.destroy(ui);
+ }
+ });
+
+ // Computes the location of bottom left corner of the cell
+ Component comp = component;
+ int x = 0;
+ int y = component.getHeight();
+ while (comp != null) {
+ x += comp.getX();
+ y += comp.getY();
+ comp = comp.getParent();
+ }
+ // if the editor is too big on the right,
+ // then align its right side to the right side of the cell
+ if (x + editor.getWidth() > frame.getX() + frame.getWidth()) {
+ x = x - editor.getWidth() + component.getWidth();
+ }
+ editor.setLocation(x, y);
+ editor.setVisible(true);
+
+ int r = rowIndex;
+ int c = columnIndex;
+
+ // stop edition
+ stopCellEditing();
+
+ // reselect this cell
+ AbstractSelectTableAction.doSelectCell(table, r, c);
+ }
+
+ @Override
+ public Component getTableCellEditorComponent(JTable table,
+ Object value,
+ boolean isSelected,
+ int row,
+ int column) {
+ if (tableModel == null) {
+ tableModel = (AbstractTuttiTableModel<AbstractTuttiBeanUIModel>) table.getModel();
+ this.table = table;
+ columnIdentifier = tableModel.getPropertyName(column);
+ }
+
+ rowIndex = row;
+ columnIndex = column;
+
+ editRow = tableModel.getEntry(row);
+
+ return component;
+ }
+
+ @Override
+ public Object getCellEditorValue() {
+
+ Preconditions.checkNotNull(editRow, "No editRow found in editor.");
+
+ String propertyName = columnIdentifier.getPropertyName();
+ Object result = TuttiUIUtil.getProperty(editRow, propertyName);
+ if (log.isInfoEnabled()) {
+ log.info("editor value (" + propertyName + "): " + result);
+ }
+
+ return result;
+ }
+
+ @Override
+ public boolean stopCellEditing() {
+ boolean b = super.stopCellEditing();
+ if (b) {
+ rowIndex = null;
+ editRow = null;
+ columnIndex = null;
+ }
+ return b;
+ }
+
+ @Override
+ public void cancelCellEditing() {
+ super.cancelCellEditing();
+ rowIndex = null;
+ columnIndex = null;
+ editRow = null;
+ }
+ }
+
+ public static class LongTextCellRenderer implements TableCellRenderer {
+
+ protected final LongTextCellComponent component;
+
+ protected String propertyName;
+
+ public LongTextCellRenderer() {
+ component = new LongTextCellComponent();
+ }
+
+ @Override
+ public Component getTableCellRendererComponent(JTable table,
+ Object value,
+ boolean isSelected,
+ boolean hasFocus,
+ int row,
+ int column) {
+
+ String text;
+ if (value == null) {
+ if (propertyName == null) {
+ AbstractTuttiTableModel tableModel =
+ (AbstractTuttiTableModel) table.getModel();
+ ColumnIdentifier columnIdentifier = tableModel.getPropertyName(column);
+ propertyName = columnIdentifier.getPropertyName();
+ }
+ // use HTML to show the tooltip in italic
+ text = "<html><body><i>" + _("tutti.tooltip." + propertyName + ".none") + "</i></body></html>";
+
+ } else {
+ // use html to display the tooltip on several lines
+ text = "<html><body>" + String.valueOf(value).replace("\n", "<br/>") + "</body></html>";
+ }
+
+ boolean editable = table.isCellEditable(row, column);
+ component.setEnabled(editable);
+ component.setToolTipText(text);
+ return component;
+ }
+ }
+}
Added: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/LongTextEditorUI.css
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/LongTextEditorUI.css (rev 0)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/LongTextEditorUI.css 2012-12-13 17:13:46 UTC (rev 57)
@@ -0,0 +1,4 @@
+#closeButton {
+ actionIcon: "close";
+ text: "tutti.action.close";
+}
Copied: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/LongTextEditorUI.jaxx (from rev 55, trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/species/SpeciesFrequencyUI.jaxx)
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/LongTextEditorUI.jaxx (rev 0)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/LongTextEditorUI.jaxx 2012-12-13 17:13:46 UTC (rev 57)
@@ -0,0 +1,48 @@
+<!--
+ #%L
+ Tutti :: UI
+ $Id$
+ $HeadURL$
+ %%
+ Copyright (C) 2012 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%
+ -->
+<Table id='mainPanel'>
+
+ <!-- bean property linked state -->
+ <String id='property' javaBean='""'/>
+
+ <!-- bean property -->
+ <fr.ifremer.tutti.ui.swing.AbstractTuttiBeanUIModel id='bean' javaBean='null'/>
+
+ <LongTextEditorUIHandler id='handler' constructorParams='this'/>
+
+ <row weighty='1' fill='both'>
+ <cell fill='both' weightx='1'>
+ <JScrollPane>
+ <JTextArea id='textContent'
+ onKeyReleased='handler.setText()'/>
+ </JScrollPane>
+ </cell>
+ </row>
+ <row fill='both'>
+ <!-- actions -->
+ <cell fill='both' weightx='1'>
+ <JButton id='closeButton' onActionPerformed='handler.close()'/>
+ </cell>
+ </row>
+</Table>
\ No newline at end of file
Added: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/LongTextEditorUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/LongTextEditorUIHandler.java (rev 0)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/LongTextEditorUIHandler.java 2012-12-13 17:13:46 UTC (rev 57)
@@ -0,0 +1,75 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package fr.ifremer.tutti.ui.swing.util.editor;
+
+import fr.ifremer.tutti.ui.swing.AbstractTuttiBeanUIModel;
+import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil;
+import java.awt.Window;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import jaxx.runtime.SwingUtil;
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * Handler of the LongTextEditorUI
+ * @author kmorin
+ * @since 0.2
+ */
+public class LongTextEditorUIHandler {
+
+ private static final Log log = LogFactory.getLog(LongTextEditorUIHandler.class);
+
+ private final LongTextEditorUI ui;
+
+ public LongTextEditorUIHandler(LongTextEditorUI longTextEditorUI) {
+ ui = longTextEditorUI;
+
+ ui.addPropertyChangeListener(new PropertyChangeListener() {
+
+ public void propertyChange(PropertyChangeEvent evt) {
+ AbstractTuttiBeanUIModel bean = ui.getBean();
+ String property = ui.getProperty();
+ if (bean != null && !StringUtils.isEmpty(property)) {
+ Object value = TuttiUIUtil.getProperty(bean, property);
+ if (value == null) {
+ value = "";
+ }
+ ui.getTextContent().setText(value.toString());
+ }
+ }
+ });
+ }
+
+ /**
+ * pushes the typed text in the property of the bean
+ */
+ public void setText() {
+ String value = ui.getTextContent().getText();
+ AbstractTuttiBeanUIModel bean = ui.getBean();
+ String property = ui.getProperty();
+ TuttiUIUtil.setProperty(bean, property, value);
+ }
+
+ public void resetText() {
+ AbstractTuttiBeanUIModel bean = ui.getBean();
+ String property = ui.getProperty();
+ TuttiUIUtil.setProperty(bean, property, null);
+
+ ui.getTextContent().setText("");
+ }
+
+ /**
+ * closes the editor
+ */
+ public void close() {
+ if (log.isInfoEnabled()) {
+ log.info("Will close UI " + ui);
+ }
+ SwingUtil.getParentContainer(ui, Window.class).dispose();
+ }
+
+}
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 2012-12-13 15:37:44 UTC (rev 56)
+++ trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties 2012-12-13 17:13:46 UTC (rev 57)
@@ -1,7 +1,7 @@
tutti.about.bottomText=Copyright %s - %s - version %s
-tutti.about.message=<h3>Tutti</h3><p><strong>Outil de saisie de données d'opérations et de captures au cours des campagnes halieutiques.</strong></p><br/><p>Ce logiciel permettra la saisie en mer des données d'opération de pêche (positions, environnement, engin, etc) et des captures associées (composition de la capture en espèces scientifiques avec poids, nombres, tailles etc) pour l'ensemble des campagnes halieutiques réalisées par l'Ifremer.</p><p>Ce projet a été initiée en 2012 par l'<a href\="http\://www.ifremer.fr">Ifremer</a> et réalisé par la société <a href\="http\://codelutin.com">Codelutin</a>.</p><hr/><br/><p>Pour plus d'informations, vous pouvez visiter le <a href\="http\://maven-site.forge.codelutin.com/tutti">site du projet</a>.</p><p>Projet hébergé sur la forge <a href\="http\://forge.codelutin.com/projects/tutti">Forge.codelutin.com</a>.</p>
-tutti.action.about=À propos
-tutti.action.about.tip=À Propos
+tutti.about.message=<h3>Tutti</h3><p><strong>Outil de saisie de donn\u00c3\u00a9es d'op\u00c3\u00a9rations et de captures au cours des campagnes halieutiques.</strong></p><br/><p>Ce logiciel permettra la saisie en mer des donn\u00c3\u00a9es d'op\u00c3\u00a9ration de p\u00c3\u00aache (positions, environnement, engin, etc) et des captures associ\u00c3\u00a9es (composition de la capture en esp\u00c3\u00a8ces scientifiques avec poids, nombres, tailles etc) pour l'ensemble des campagnes halieutiques r\u00c3\u00a9alis\u00c3\u00a9es par l'Ifremer.</p><p>Ce projet a \u00c3\u00a9t\u00c3\u00a9 initi\u00c3\u00a9e en 2012 par l'<a href\="http\://www.ifremer.fr">Ifremer</a> et r\u00c3\u00a9alis\u00c3\u00a9 par la soci\u00c3\u00a9t\u00c3\u00a9 <a href\="http\://codelutin.com">Codelutin</a>.</p><hr/><br/><p>Pour plus d'informations, vous pouvez visiter le <a href\="http\://maven-site.forge.codelutin.com/tutti">site du projet</a>.</p><p>Projet h\u00c3\u00a9berg\u00c3\u00a9 sur la forge <a href\="http\://forge.codelutin.com/projects/tutti">Forge.codelutin.com</a>.</p>
+tutti.action.about=\u00c3\u0080 propos
+tutti.action.about.tip=\u00c3\u0080 Propos
tutti.action.cancel=Annuler
tutti.action.casino-import=Import Casino
tutti.action.catches=Captures
@@ -13,21 +13,21 @@
tutti.action.exit.tip=Quitter l'application
tutti.action.fillCatches=Captures
tutti.action.fillCatches.tip=Saisir des captures
-tutti.action.generate=Générer
-tutti.action.generateCampaignName=Générer le nom
+tutti.action.generate=G\u00c3\u00a9n\u00c3\u00a9rer
+tutti.action.generateCampaignName=G\u00c3\u00a9n\u00c3\u00a9rer le nom
tutti.action.manageProtocol=Protocole
-tutti.action.manageProtocol.tip=Gérer les protocoles
+tutti.action.manageProtocol.tip=G\u00c3\u00a9rer les protocoles
tutti.action.new=Nouveau
tutti.action.pupitri-import=Import PUPITRI
tutti.action.reload.actions=Recharger les actions
tutti.action.reload.home=Reload home screen
tutti.action.reload.ui=Recharger l'interface graphique
-tutti.action.reset.fishingOperationValidState=Réinitialiser
+tutti.action.reset.fishingOperationValidState=R\u00c3\u00a9initialiser
tutti.action.save=Enregistrer
tutti.action.selectCampaign=Campagne
-tutti.action.selectCampaign.tip=Sélectionner la campagne à utiliser
+tutti.action.selectCampaign.tip=S\u00c3\u00a9lectionner la campagne \u00c3\u00a0 utiliser
tutti.action.site=Site
-tutti.action.site.tip=Accéder au site du projet Tutti
+tutti.action.site.tip=Acc\u00c3\u00a9der au site du projet Tutti
tutti.application.config=Configuration de l'application Tutti
tutti.application.name=Tutti
tutti.config.category.applications=Application
@@ -36,84 +36,84 @@
tutti.config.category.other.description=Autres options
tutti.config.category.shortcuts=Raccourcis
tutti.config.category.shortcuts.description=Liste des raccourcis clavier
-tutti.config.cruiseId=Identifiant de la dernière campagne utilisée
-tutti.config.programId=Identifiant de la dernière série de campagne utilisée
-tutti.config.ui.autoPopupNumberEditor=Toujours afficher le pavé numérique lors de l'édition d'un nombre
+tutti.config.cruiseId=Identifiant de la derni\u00c3\u00a8re campagne utilis\u00c3\u00a9e
+tutti.config.programId=Identifiant de la derni\u00c3\u00a8re s\u00c3\u00a9rie de campagne utilis\u00c3\u00a9e
+tutti.config.ui.autoPopupNumberEditor=Toujours afficher le pav\u00c3\u00a9 num\u00c3\u00a9rique lors de l'\u00c3\u00a9dition d'un nombre
tutti.config.ui.config=Chemin du fichier de configuration des interfaces graphiques
-tutti.config.ui.showNumberEditorButton=Afficher le pavé numérique de saisie
-tutti.label.benthos.sampleTotalWeight=Poids total échantillonné
+tutti.config.ui.showNumberEditorButton=Afficher le pav\u00c3\u00a9 num\u00c3\u00a9rique de saisie
+tutti.label.benthos.sampleTotalWeight=Poids total \u00c3\u00a9chantillonn\u00c3\u00a9
tutti.label.benthos.totalWeight=Poids total
tutti.label.comment=Commentaire
tutti.label.cruise=Campagne
-tutti.label.cruise.beginDate=Date de début
+tutti.label.cruise.beginDate=Date de d\u00c3\u00a9but
tutti.label.cruise.country=Pays
tutti.label.cruise.endDate=Date de fin
tutti.label.cruise.name=Nom
tutti.label.cruise.poche=Nombre de poches
-tutti.label.cruise.program=Série
-tutti.label.cruise.surveyPart=Série partielle
-tutti.label.cruise.year=Année
-tutti.label.fishingOperation.averageBottomSalinity=Salinité de fond moyenne
-tutti.label.fishingOperation.averageBottomTemperature=Température de fond moyenne
+tutti.label.cruise.program=S\u00c3\u00a9rie
+tutti.label.cruise.surveyPart=S\u00c3\u00a9rie partielle
+tutti.label.cruise.year=Ann\u00c3\u00a9e
+tutti.label.fishingOperation.averageBottomSalinity=Salinit\u00c3\u00a9 de fond moyenne
+tutti.label.fishingOperation.averageBottomTemperature=Temp\u00c3\u00a9rature de fond moyenne
tutti.label.fishingOperation.beaufortScale=Force du vent
tutti.label.fishingOperation.date=Date
-tutti.label.fishingOperation.distanceChalutee=Distance chalutée
-tutti.label.fishingOperation.duree=Durée
+tutti.label.fishingOperation.distanceChalutee=Distance chalut\u00c3\u00a9e
+tutti.label.fishingOperation.duree=Dur\u00c3\u00a9e
tutti.label.fishingOperation.fishingOperationInvalid=Trait invalide
-tutti.label.fishingOperation.fishingOperationNumber=Numéro de Trait
+tutti.label.fishingOperation.fishingOperationNumber=Num\u00c3\u00a9ro de Trait
tutti.label.fishingOperation.fishingOperationRectiligne=Trait rectiligne
tutti.label.fishingOperation.fishingOperationValid=Trait valide
tutti.label.fishingOperation.gearDate=Date
tutti.label.fishingOperation.gearLatitude=Latitude
tutti.label.fishingOperation.gearLongitude=Longitude
tutti.label.fishingOperation.gearShootingEnd=Fin de traine
-tutti.label.fishingOperation.gearShootingEndBottomSalinity=Salinité de fond fin de traine
-tutti.label.fishingOperation.gearShootingEndBottomTemperature=Température de fond fin de traine
+tutti.label.fishingOperation.gearShootingEndBottomSalinity=Salinit\u00c3\u00a9 de fond fin de traine
+tutti.label.fishingOperation.gearShootingEndBottomTemperature=Temp\u00c3\u00a9rature de fond fin de traine
tutti.label.fishingOperation.gearShootingEndDepth=Profondeur fin de traine
-tutti.label.fishingOperation.gearShootingEndSurfaceSalinity=Salinité de surface fin de traine
+tutti.label.fishingOperation.gearShootingEndSurfaceSalinity=Salinit\u00c3\u00a9 de surface fin de traine
tutti.label.fishingOperation.gearShootingEndSurfaceTemperature=Temperature de surface fin de traine
-tutti.label.fishingOperation.gearShootingStart=Début de traine
-tutti.label.fishingOperation.gearShootingStartBottomSalinity=Salinité de fond début de traine
-tutti.label.fishingOperation.gearShootingStartBottomTemperature=Température de fond début de traine
-tutti.label.fishingOperation.gearShootingStartDepth=Profondeur début de traine
-tutti.label.fishingOperation.gearShootingStartSurfaceSalinity=Salinité de surface début de traine
-tutti.label.fishingOperation.gearShootingStartSurfaceTemperature=Temperature de surface début de traine
+tutti.label.fishingOperation.gearShootingStart=D\u00c3\u00a9but de traine
+tutti.label.fishingOperation.gearShootingStartBottomSalinity=Salinit\u00c3\u00a9 de fond d\u00c3\u00a9but de traine
+tutti.label.fishingOperation.gearShootingStartBottomTemperature=Temp\u00c3\u00a9rature de fond d\u00c3\u00a9but de traine
+tutti.label.fishingOperation.gearShootingStartDepth=Profondeur d\u00c3\u00a9but de traine
+tutti.label.fishingOperation.gearShootingStartSurfaceSalinity=Salinit\u00c3\u00a9 de surface d\u00c3\u00a9but de traine
+tutti.label.fishingOperation.gearShootingStartSurfaceTemperature=Temperature de surface d\u00c3\u00a9but de traine
tutti.label.fishingOperation.gearTime=Heure
-tutti.label.fishingOperation.geometrieMesuree=Géométrie mesurée
-tutti.label.fishingOperation.localite=Localité
+tutti.label.fishingOperation.geometrieMesuree=G\u00c3\u00a9om\u00c3\u00a9trie mesur\u00c3\u00a9e
+tutti.label.fishingOperation.localite=Localit\u00c3\u00a9
tutti.label.fishingOperation.longueurBras=Longueur des funes
tutti.label.fishingOperation.longueurFunes=Longueur des bras
tutti.label.fishingOperation.ouvertureHorizontale=Ouverture horizontale
tutti.label.fishingOperation.ouvertureVerticale=Ouverture verticale
tutti.label.fishingOperation.seaState=Etat de la mer
-tutti.label.fishingOperation.stationNumber=Numéro de la station
+tutti.label.fishingOperation.stationNumber=Num\u00c3\u00a9ro de la station
tutti.label.fishingOperation.strata=Strate
tutti.label.fishingOperation.subStrata=Sous strate
-tutti.label.fishingOperation.systemeFermetureCul=Système de fermeture de cul
+tutti.label.fishingOperation.systemeFermetureCul=Syst\u00c3\u00a8me de fermeture de cul
tutti.label.fishingOperation.windDirection=Direction du vent
tutti.label.frequencyConfiguration.maxStep=Classe max
tutti.label.frequencyConfiguration.minStep=Classe min
-tutti.label.frequencyConfiguration.mode.autoGen=Génération des classes
-tutti.label.frequencyConfiguration.mode.autoGen.tip=Mode où toutes les classes de taille sont générées
+tutti.label.frequencyConfiguration.mode.autoGen=G\u00c3\u00a9n\u00c3\u00a9ration des classes
+tutti.label.frequencyConfiguration.mode.autoGen.tip=Mode o\u00c3\u00b9 toutes les classes de taille sont g\u00c3\u00a9n\u00c3\u00a9r\u00c3\u00a9es
tutti.label.frequencyConfiguration.mode.rafale=Mode "rafale"
-tutti.label.frequencyConfiguration.mode.rafale.tip=Mode où on ne saisit uniquement la classe de taille (les nombres seront alors incrémentés...)
+tutti.label.frequencyConfiguration.mode.rafale.tip=Mode o\u00c3\u00b9 on ne saisit uniquement la classe de taille (les nombres seront alors incr\u00c3\u00a9ment\u00c3\u00a9s...)
tutti.label.frequencyConfiguration.mode.simple=Mode simple
-tutti.label.frequencyConfiguration.mode.simple.tip=Mode par défaut on on doit tout saisir (les classes de tailles et les nombres)
+tutti.label.frequencyConfiguration.mode.simple.tip=Mode par d\u00c3\u00a9faut on on doit tout saisir (les classes de tailles et les nombres)
tutti.label.frequencyConfiguration.no.configuration=< Pas de configuration >
-tutti.label.frequencyConfiguration.rafaleStep=Classe de taille à incrémenter
+tutti.label.frequencyConfiguration.rafaleStep=Classe de taille \u00c3\u00a0 incr\u00c3\u00a9menter
tutti.label.frequencyConfiguration.step=Pas de la classe de taille
tutti.label.list.gear=Engin(s)
tutti.label.list.headOfMission=Chef(s) de mission
tutti.label.list.headOfSortRoom=Reponsable(s) de salle de tri
tutti.label.list.vessel=Navire(s)
tutti.label.macroWaste.totalWeight=Poids total
-tutti.label.no.fishingOperation.selected=< Aucun trait sélectionné >
-tutti.label.plankton.sampleTotalWeight=Poids total échantillonné
+tutti.label.no.fishingOperation.selected=< Aucun trait s\u00c3\u00a9lectionn\u00c3\u00a9 >
+tutti.label.plankton.sampleTotalWeight=Poids total \u00c3\u00a9chantillonn\u00c3\u00a9
tutti.label.plankton.totalWeight=Poids total
-tutti.label.program=Série de campagne
+tutti.label.program=S\u00c3\u00a9rie de campagne
tutti.label.program.name=Nom
tutti.label.program.zone=Zone
-tutti.label.species.sampleVracWeight=Poids total vrac échant.
+tutti.label.species.sampleVracWeight=Poids total vrac \u00c3\u00a9chant.
tutti.label.species.totalHorsVracWeight=Poids total hors vrac
tutti.label.species.totalVracWeight=Poids total vrac
tutti.label.species.totalWeight=Poids total
@@ -122,12 +122,12 @@
tutti.label.tab.fishingOperation=Trait
tutti.label.tab.fishingOperation.environment=Environnement
tutti.label.tab.fishingOperation.gearShooting=Mise en oeuvre de l'engin
-tutti.label.tab.fishingOperation.general=Caractéristiques générales
-tutti.label.tab.fishingOperation.hydrology=Paramètres hydrologiques
-tutti.label.tab.macroDechet=Macro déchets
+tutti.label.tab.fishingOperation.general=Caract\u00c3\u00a9ristiques g\u00c3\u00a9n\u00c3\u00a9rales
+tutti.label.tab.fishingOperation.hydrology=Param\u00c3\u00a8tres hydrologiques
+tutti.label.tab.macroDechet=Macro d\u00c3\u00a9chets
tutti.label.tab.observationIndividuel=Observations individuelles
tutti.label.tab.plancton=Plancton
-tutti.label.tab.species=Espèces
+tutti.label.tab.species=Esp\u00c3\u00a8ces
tutti.legend.frequencyConfiguration=Configuration
tutti.menu.actions=Actions
tutti.menu.actions.tip=Actions
@@ -135,8 +135,8 @@
tutti.menu.file.tip=Fichier
tutti.menu.help=Aide
tutti.menu.help.tip=Aide
-tutti.menu.synchronisationAllegro=Allégro
-tutti.menu.synchronisationAllegro.tip=Synchronisation Allégro
+tutti.menu.synchronisationAllegro=All\u00c3\u00a9gro
+tutti.menu.synchronisationAllegro.tip=Synchronisation All\u00c3\u00a9gro
tutti.menu.synchronisationExport=Export
tutti.menu.synchronisationExport.tip=Effectuer des exports
tutti.menu.synchronisationImport=Import
@@ -144,71 +144,72 @@
tutti.menu.synchronisations=Synchronisation
tutti.menu.synchronisations.tip=Import/Export
tutti.table.benthos.batch.header.comment=Commentaire
-tutti.table.benthos.batch.header.elevationRate=Fraction d'élévation
-tutti.table.benthos.batch.header.file=Pièces jointes
-tutti.table.benthos.batch.header.sampleWeight=Poids échantillonné
-tutti.table.benthos.batch.header.speciesByCode=Espèce
-tutti.table.benthos.batch.header.speciesByGenusCode=Espèce
+tutti.table.benthos.batch.header.elevationRate=Fraction d'\u00c3\u00a9l\u00c3\u00a9vation
+tutti.table.benthos.batch.header.file=Pi\u00c3\u00a8ces jointes
+tutti.table.benthos.batch.header.sampleWeight=Poids \u00c3\u00a9chantillonn\u00c3\u00a9
+tutti.table.benthos.batch.header.speciesByCode=Esp\u00c3\u00a8ce
+tutti.table.benthos.batch.header.speciesByGenusCode=Esp\u00c3\u00a8ce
tutti.table.benthos.batch.header.toConfirm=A Confirmer
tutti.table.benthos.batch.header.weight=Poids
tutti.table.macrowaste.batch.header.comment=Commentaire
-tutti.table.macrowaste.batch.header.file=Pièces jointes
-tutti.table.macrowaste.batch.header.speciesByCode=Espèce
-tutti.table.macrowaste.batch.header.speciesByGenusCode=Espèce
+tutti.table.macrowaste.batch.header.file=Pi\u00c3\u00a8ces jointes
+tutti.table.macrowaste.batch.header.speciesByCode=Esp\u00c3\u00a8ce
+tutti.table.macrowaste.batch.header.speciesByGenusCode=Esp\u00c3\u00a8ce
tutti.table.macrowaste.batch.header.weight=Poids
tutti.table.plankton.batch.header.comment=Commentaire
-tutti.table.plankton.batch.header.elevationRate=Fraction d'élévation
-tutti.table.plankton.batch.header.file=Pièces jointes
-tutti.table.plankton.batch.header.sampleWeight=Poids échantillonné
-tutti.table.plankton.batch.header.speciesByCode=Espèce
-tutti.table.plankton.batch.header.speciesByGenusCode=Espèce
+tutti.table.plankton.batch.header.elevationRate=Fraction d'\u00c3\u00a9l\u00c3\u00a9vation
+tutti.table.plankton.batch.header.file=Pi\u00c3\u00a8ces jointes
+tutti.table.plankton.batch.header.sampleWeight=Poids \u00c3\u00a9chantillonn\u00c3\u00a9
+tutti.table.plankton.batch.header.speciesByCode=Esp\u00c3\u00a8ce
+tutti.table.plankton.batch.header.speciesByGenusCode=Esp\u00c3\u00a8ce
tutti.table.plankton.batch.header.toConfirm=A Confirmer
tutti.table.plankton.batch.header.weight=Poids
tutti.table.species.batch.header.age=Age
tutti.table.species.batch.header.comment=Commentaire
-tutti.table.species.batch.header.computedNumber=Nombre calculé
-tutti.table.species.batch.header.computedWeight=Poids calculé
-tutti.table.species.batch.header.elevationRate=Fraction d'élévation
-tutti.table.species.batch.header.file=Pièces jointes
-tutti.table.species.batch.header.maturity=Maturité
-tutti.table.species.batch.header.sampleWeight=Poids échantillonné
+tutti.table.species.batch.header.computedNumber=Nombre calcul\u00c3\u00a9
+tutti.table.species.batch.header.computedWeight=Poids calcul\u00c3\u00a9
+tutti.table.species.batch.header.elevationRate=Fraction d'\u00c3\u00a9l\u00c3\u00a9vation
+tutti.table.species.batch.header.file=Pi\u00c3\u00a8ces jointes
+tutti.table.species.batch.header.maturity=Maturit\u00c3\u00a9
+tutti.table.species.batch.header.sampleWeight=Poids \u00c3\u00a9chantillonn\u00c3\u00a9
tutti.table.species.batch.header.sex=Sexe
-tutti.table.species.batch.header.speciesByCode=Espèce
-tutti.table.species.batch.header.speciesByGenusCode=Espèce
+tutti.table.species.batch.header.speciesByCode=Esp\u00c3\u00a8ce
+tutti.table.species.batch.header.speciesByGenusCode=Esp\u00c3\u00a8ce
tutti.table.species.batch.header.toConfirm=A Confirmer
tutti.table.species.batch.header.vracHorsVrac=Vrac / Hors Vrac
tutti.table.species.batch.header.weight=Poids
-tutti.table.species.batch.header.weightCategory=Catégorie Poids
-tutti.table.species.frequency.header.computedWeight=Poids calculé
+tutti.table.species.batch.header.weightCategory=Cat\u00c3\u00a9gorie Poids
+tutti.table.species.frequency.header.computedWeight=Poids calcul\u00c3\u00a9
tutti.table.species.frequency.header.lengthStep=Classe de taille
tutti.table.species.frequency.header.number=Nombre
-tutti.table.species.frequency.header.weight=Poids observé
+tutti.table.species.frequency.header.weight=Poids observ\u00c3\u00a9
tutti.timeeditor.H=H
-tutti.title.about=À propos de Tutti
-tutti.title.create.cruise=Créer une nouvelle campagne
-tutti.title.create.program=Créer une nouvelle série de campagne
+tutti.title.about=\u00c3\u0080 propos de Tutti
+tutti.title.create.cruise=Cr\u00c3\u00a9er une nouvelle campagne
+tutti.title.create.program=Cr\u00c3\u00a9er une nouvelle s\u00c3\u00a9rie de campagne
tutti.title.edit.cruise=Editer une campagne existante
-tutti.title.edit.operations=Saisie des opérations de pêches (%s)
-tutti.title.edit.program=Editer une série de campagne existante
+tutti.title.edit.operations=Saisie des op\u00c3\u00a9rations de p\u00c3\u00aaches (%s)
+tutti.title.edit.program=Editer une s\u00c3\u00a9rie de campagne existante
tutti.title.frequency=Saisie des mensurations
-tutti.title.home=Sélection de la campagne
-tutti.title.noSelectedCruise=Pas de campagne sélectionné
-tutti.title.noSelectedProgram=Pas de série de campagne sélectionné
+tutti.title.home=S\u00c3\u00a9lection de la campagne
+tutti.title.noSelectedCruise=Pas de campagne s\u00c3\u00a9lectionn\u00c3\u00a9
+tutti.title.noSelectedProgram=Pas de s\u00c3\u00a9rie de campagne s\u00c3\u00a9lectionn\u00c3\u00a9
tutti.title.selectedCruise=Campagne %s
-tutti.title.selectedProgram=Série de campagne %s
+tutti.title.selectedProgram=S\u00c3\u00a9rie de campagne %s
tutti.to.be.done=< A FAIRE >
-tutti.validator.error.cruise.beginDate.required=La date de début est obligatoire
+tutti.tooltip.comment.none=Aucun
+tutti.validator.error.cruise.beginDate.required=La date de d\u00c3\u00a9but est obligatoire
tutti.validator.error.cruise.country.required=Le pays est obligatoire
tutti.validator.error.cruise.endDate.required=La date de fin est obligatoire
-tutti.validator.error.cruise.gear.required=Au moins un engin doit être sélectionné
-tutti.validator.error.cruise.headOfMission.required=Au moins un chef de mission doit être sélectionné
-tutti.validator.error.cruise.headOfSortRoom.required=Au moins un responsable de salle de tri doit être sélectionné
+tutti.validator.error.cruise.gear.required=Au moins un engin doit \u00c3\u00aatre s\u00c3\u00a9lectionn\u00c3\u00a9
+tutti.validator.error.cruise.headOfMission.required=Au moins un chef de mission doit \u00c3\u00aatre s\u00c3\u00a9lectionn\u00c3\u00a9
+tutti.validator.error.cruise.headOfSortRoom.required=Au moins un responsable de salle de tri doit \u00c3\u00aatre s\u00c3\u00a9lectionn\u00c3\u00a9
tutti.validator.error.cruise.name.required=Le nom de la campagne est obligatoire
tutti.validator.error.cruise.poche.required=Le nombre de poche est obligatoire
-tutti.validator.error.cruise.program.required=La série est obligatoire
-tutti.validator.error.cruise.vessel.required=Au moins un bateau doit être sélectionné
-tutti.validator.error.cruise.year.required=L'année est obligatoire
+tutti.validator.error.cruise.program.required=La s\u00c3\u00a9rie est obligatoire
+tutti.validator.error.cruise.vessel.required=Au moins un bateau doit \u00c3\u00aatre s\u00c3\u00a9lectionn\u00c3\u00a9
+tutti.validator.error.cruise.year.required=L'ann\u00c3\u00a9e est obligatoire
tutti.validator.error.fishingOperation.date.required=La date du fishingOperation est obligatoire
-tutti.validator.error.fishingOperation.stationNumber.required=Le numéro de station est obligatoire
-tutti.validator.error.program.name.required=Le nom de la série est obligatoire
-tutti.validator.error.program.zone.required=La zone de la série est obligatoire
+tutti.validator.error.fishingOperation.stationNumber.required=Le num\u00c3\u00a9ro de station est obligatoire
+tutti.validator.error.program.name.required=Le nom de la s\u00c3\u00a9rie est obligatoire
+tutti.validator.error.program.zone.required=La zone de la s\u00c3\u00a9rie est obligatoire
1
0
Author: tchemit
Date: 2012-12-13 16:37:44 +0100 (Thu, 13 Dec 2012)
New Revision: 56
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/56
Log:
updates libraries
Modified:
trunk/pom.xml
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2012-12-13 01:57:28 UTC (rev 55)
+++ trunk/pom.xml 2012-12-13 15:37:44 UTC (rev 56)
@@ -6,7 +6,7 @@
<parent>
<groupId>org.nuiton</groupId>
<artifactId>mavenpom4redmine</artifactId>
- <version>3.4.4</version>
+ <version>3.4.6</version>
</parent>
<groupId>fr.ifremer</groupId>
@@ -82,17 +82,17 @@
<!-- libraries version -->
- <nuitonUtilsVersion>2.6.4</nuitonUtilsVersion>
+ <nuitonUtilsVersion>2.6.5</nuitonUtilsVersion>
<nuitonI18nVersion>2.5</nuitonI18nVersion>
- <eugenePluginVersion>2.6-SNAPSHOT</eugenePluginVersion>
+ <eugenePluginVersion>2.6</eugenePluginVersion>
<hibernateVersion>3.6.10.Final</hibernateVersion>
<h2Version>1.3.168</h2Version>
<postgresqlVersion>9.1-901-1.jdbc4</postgresqlVersion>
<jaxxVersion>2.5.8-SNAPSHOT</jaxxVersion>
<swingXVersion>1.6.4</swingXVersion>
- <xworkVersion>2.3.4.1</xworkVersion>
+ <xworkVersion>2.3.7</xworkVersion>
<slf4jVersion>1.7.2</slf4jVersion>
1
0
13 Dec '12
Author: tchemit
Date: 2012-12-13 02:57:28 +0100 (Thu, 13 Dec 2012)
New Revision: 55
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/55
Log:
continue batch screens
Added:
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/accidental/AccidentalBatchRowModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/accidental/AccidentalBatchTableModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/accidental/AccidentalBatchUI.css
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/accidental/AccidentalBatchUI.jaxx
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/accidental/AccidentalBatchUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/accidental/AccidentalBatchUIModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/benthos/BenthosBatchRowModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/benthos/BenthosBatchTableModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/benthos/BenthosBatchUI.css
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/benthos/BenthosBatchUI.jaxx
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/benthos/BenthosBatchUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/benthos/BenthosBatchUIModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/macrowaste/MacroWasteBatchRowModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/macrowaste/MacroWasteBatchTableModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/macrowaste/MacroWasteBatchUI.css
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/macrowaste/MacroWasteBatchUI.jaxx
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/macrowaste/MacroWasteBatchUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/macrowaste/MacroWasteBatchUIModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/plankton/PlanktonBatchRowModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/plankton/PlanktonBatchTableModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/plankton/PlanktonBatchUI.css
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/plankton/PlanktonBatchUI.jaxx
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/plankton/PlanktonBatchUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/plankton/PlanktonBatchUIModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/species/SpeciesBatchUI.css
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/species/SpeciesBatchUI.jaxx
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/species/SpeciesBatchUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/species/SpeciesBatchUIModel.java
Removed:
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/accidental/AccidentelTabUI.css
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/accidental/AccidentelTabUI.jaxx
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/accidental/AccidentelTabUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/accidental/AccidentelTabUIModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/accidental/AccidentelTableModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/benthos/BenthosTabUI.css
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/benthos/BenthosTabUI.jaxx
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/benthos/BenthosTabUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/benthos/BenthosTabUIModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/benthos/BenthosTableModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/macrowaste/MacroDechetTabUI.css
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/macrowaste/MacroDechetTabUI.jaxx
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/macrowaste/MacroDechetTabUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/macrowaste/MacroDechetTabUIModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/macrowaste/MacroDechetTableModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/plankton/PlanctonTabUI.css
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/plankton/PlanctonTabUI.jaxx
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/plankton/PlanctonTabUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/plankton/PlanctonTabUIModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/plankton/PlanctonTableModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/species/SpeciesTabUI.css
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/species/SpeciesTabUI.jaxx
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/species/SpeciesTabUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/species/SpeciesTabUIModel.java
Modified:
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/resources/META-INF/services/fr.ifremer.tutti.persistence.entities.IdAware
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/MainUI.css
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/MainUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/TuttiScreen.java
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/FishingOperationTabUI.jaxx
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/FishingOperationTabUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/FishingOperationsUI.css
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/FishingOperationsUI.jaxx
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/FishingOperationsUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/species/SpeciesBatchRowModel.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 2012-12-12 22:50:50 UTC (rev 54)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistence.java 2012-12-13 01:57:28 UTC (rev 55)
@@ -24,16 +24,15 @@
* #L%
*/
-import fr.ifremer.tutti.persistence.entities.data.AccidentelBatch;
+import fr.ifremer.tutti.persistence.entities.data.AccidentalBatch;
import fr.ifremer.tutti.persistence.entities.data.BenthosBatch;
+import fr.ifremer.tutti.persistence.entities.data.Cruise;
import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
-import fr.ifremer.tutti.persistence.entities.data.MacroDechetBatch;
-import fr.ifremer.tutti.persistence.entities.data.PlanctonBatch;
+import fr.ifremer.tutti.persistence.entities.data.MacroWasteBatch;
+import fr.ifremer.tutti.persistence.entities.data.PlanktonBatch;
import fr.ifremer.tutti.persistence.entities.data.Program;
-import fr.ifremer.tutti.persistence.entities.data.Cruise;
import fr.ifremer.tutti.persistence.entities.data.SpeciesBatch;
import fr.ifremer.tutti.persistence.entities.data.SpeciesBatchFrequency;
-import fr.ifremer.tutti.persistence.entities.referential.Strata;
import fr.ifremer.tutti.persistence.entities.referential.BeaufortScale;
import fr.ifremer.tutti.persistence.entities.referential.Country;
import fr.ifremer.tutti.persistence.entities.referential.Gear;
@@ -41,6 +40,7 @@
import fr.ifremer.tutti.persistence.entities.referential.SeaState;
import fr.ifremer.tutti.persistence.entities.referential.Sex;
import fr.ifremer.tutti.persistence.entities.referential.Species;
+import fr.ifremer.tutti.persistence.entities.referential.Strata;
import fr.ifremer.tutti.persistence.entities.referential.Vessel;
import fr.ifremer.tutti.persistence.entities.referential.WeightCategory;
import fr.ifremer.tutti.persistence.entities.referential.Zone;
@@ -162,39 +162,48 @@
BenthosBatch saveBenthosBatch(BenthosBatch bean);
+ void deleteBenthosBatch(String id);
+
//------------------------------------------------------------------------//
//-- Plancton Batch methods --//
//------------------------------------------------------------------------//
- List<PlanctonBatch> getAllPlanctonBatch(String fishingOperationId);
+ List<PlanktonBatch> getAllPlanktonBatch(String fishingOperationId);
- PlanctonBatch getPlanctonBatch(String id);
+ PlanktonBatch getPlanktonBatch(String id);
- PlanctonBatch createPlanctonBatch(PlanctonBatch bean);
+ PlanktonBatch createPlanktonBatch(PlanktonBatch bean);
- PlanctonBatch savePlanctonBatch(PlanctonBatch bean);
+ PlanktonBatch savePlanktonBatch(PlanktonBatch bean);
+ void deletePlanktonBatch(String id);
+
//------------------------------------------------------------------------//
//-- Macrodechet Batch methods --//
//------------------------------------------------------------------------//
- List<MacroDechetBatch> getAllMacroDechetBatch(String fishingOperationId);
+ List<MacroWasteBatch> getAllMacroWasteBatch(String fishingOperationId);
- MacroDechetBatch getMacroDechetBatch(String id);
+ MacroWasteBatch getMacroWasteBatch(String id);
- MacroDechetBatch createMacroDechetBatch(MacroDechetBatch bean);
+ MacroWasteBatch createMacroWasteBatch(MacroWasteBatch bean);
- MacroDechetBatch saveMacroDechetBatch(MacroDechetBatch bean);
+ MacroWasteBatch saveMacroWasteBatch(MacroWasteBatch bean);
+ void deleteMacroWasteBatch(String id);
+
//------------------------------------------------------------------------//
//-- Accidentel Batch methods --//
//------------------------------------------------------------------------//
- List<AccidentelBatch> getAllAccidentelBatch(String fishingOperationId);
+ List<AccidentalBatch> getAllAccidentalBatch(String fishingOperationId);
- AccidentelBatch getAccidentelBatch(String id);
+ AccidentalBatch getAccidentalBatch(String id);
- AccidentelBatch createAccidentelBatch(AccidentelBatch bean);
+ AccidentalBatch createAccidentalBatch(AccidentalBatch bean);
- AccidentelBatch saveAccidentelBatch(AccidentelBatch bean);
+ AccidentalBatch saveAccidentalBatch(AccidentalBatch bean);
+
+ void deleteAccidentalBatch(String id);
+
}
Modified: trunk/tutti-persistence/src/main/resources/META-INF/services/fr.ifremer.tutti.persistence.entities.IdAware
===================================================================
--- trunk/tutti-persistence/src/main/resources/META-INF/services/fr.ifremer.tutti.persistence.entities.IdAware 2012-12-12 22:50:50 UTC (rev 54)
+++ trunk/tutti-persistence/src/main/resources/META-INF/services/fr.ifremer.tutti.persistence.entities.IdAware 2012-12-13 01:57:28 UTC (rev 55)
@@ -1,8 +1,8 @@
-fr.ifremer.tutti.persistence.entities.data.AccidentelBatch
+fr.ifremer.tutti.persistence.entities.data.AccidentalBatch
fr.ifremer.tutti.persistence.entities.data.BenthosBatch
fr.ifremer.tutti.persistence.entities.data.FishingOperation
-fr.ifremer.tutti.persistence.entities.data.MacroDechetBatch
-fr.ifremer.tutti.persistence.entities.data.PlanctonBatch
+fr.ifremer.tutti.persistence.entities.data.MacroWasteBatch
+fr.ifremer.tutti.persistence.entities.data.PlanktonBatch
fr.ifremer.tutti.persistence.entities.data.Program
fr.ifremer.tutti.persistence.entities.data.Cruise
fr.ifremer.tutti.persistence.entities.data.SpeciesBatch
Modified: trunk/tutti-persistence/src/main/xmi/tutti-persistence.zargo
===================================================================
(Binary files differ)
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 2012-12-12 22:50:50 UTC (rev 54)
+++ trunk/tutti-persistence-dev/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistenceDevImpl.java 2012-12-13 01:57:28 UTC (rev 55)
@@ -35,13 +35,13 @@
import fr.ifremer.tutti.persistence.entities.AbstractTuttiEntity;
import fr.ifremer.tutti.persistence.entities.IdAware;
import fr.ifremer.tutti.persistence.entities.TuttiEntities;
-import fr.ifremer.tutti.persistence.entities.data.AccidentelBatch;
+import fr.ifremer.tutti.persistence.entities.data.AccidentalBatch;
import fr.ifremer.tutti.persistence.entities.data.BenthosBatch;
import fr.ifremer.tutti.persistence.entities.data.Cruise;
import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
import fr.ifremer.tutti.persistence.entities.data.FishingOperationAware;
-import fr.ifremer.tutti.persistence.entities.data.MacroDechetBatch;
-import fr.ifremer.tutti.persistence.entities.data.PlanctonBatch;
+import fr.ifremer.tutti.persistence.entities.data.MacroWasteBatch;
+import fr.ifremer.tutti.persistence.entities.data.PlanktonBatch;
import fr.ifremer.tutti.persistence.entities.data.Program;
import fr.ifremer.tutti.persistence.entities.data.SpeciesBatch;
import fr.ifremer.tutti.persistence.entities.data.SpeciesBatchFrequency;
@@ -239,7 +239,7 @@
}
//------------------------------------------------------------------------//
- //-- Program methods --//
+ //-- Program methods --//
//------------------------------------------------------------------------//
@Override
@@ -267,7 +267,7 @@
}
//------------------------------------------------------------------------//
- //-- Cruise methods --//
+ //-- Cruise methods --//
//------------------------------------------------------------------------//
@Override
@@ -300,7 +300,7 @@
}
//------------------------------------------------------------------------//
- //-- FishingOperation methods --//
+ //-- FishingOperation methods --//
//------------------------------------------------------------------------//
@Override
@@ -421,93 +421,113 @@
return result;
}
+ @Override
+ public void deleteBenthosBatch(String id) {
+ remove(BenthosBatch.class, id);
+ }
+
//------------------------------------------------------------------------//
//-- Plancton Batch methods --//
//------------------------------------------------------------------------//
@Override
- public List<PlanctonBatch> getAllPlanctonBatch(String fishingOperationId) {
- List<PlanctonBatch> result = getAllTraitFilterBatches(
- PlanctonBatch.class, fishingOperationId);
+ public List<PlanktonBatch> getAllPlanktonBatch(String fishingOperationId) {
+ List<PlanktonBatch> result = getAllTraitFilterBatches(
+ PlanktonBatch.class, fishingOperationId);
return result;
}
@Override
- public PlanctonBatch getPlanctonBatch(String id) {
- PlanctonBatch result = getBean(PlanctonBatch.class, id);
+ public PlanktonBatch getPlanktonBatch(String id) {
+ PlanktonBatch result = getBean(PlanktonBatch.class, id);
return result;
}
@Override
- public PlanctonBatch createPlanctonBatch(PlanctonBatch bean) {
- PlanctonBatch result = create(PlanctonBatch.class, bean);
+ public PlanktonBatch createPlanktonBatch(PlanktonBatch bean) {
+ PlanktonBatch result = create(PlanktonBatch.class, bean);
return result;
}
@Override
- public PlanctonBatch savePlanctonBatch(PlanctonBatch bean) {
- PlanctonBatch result = save(PlanctonBatch.class, bean);
+ public PlanktonBatch savePlanktonBatch(PlanktonBatch bean) {
+ PlanktonBatch result = save(PlanktonBatch.class, bean);
return result;
}
+ @Override
+ public void deletePlanktonBatch(String id) {
+ remove(PlanktonBatch.class, id);
+ }
+
//------------------------------------------------------------------------//
- //-- Macrodechet Batch methods --//
+ //-- Macrodechet Batch methods --//
//------------------------------------------------------------------------//
@Override
- public List<MacroDechetBatch> getAllMacroDechetBatch(String fishingOperationId) {
- List<MacroDechetBatch> result = getAllTraitFilterBatches(
- MacroDechetBatch.class, fishingOperationId);
+ public List<MacroWasteBatch> getAllMacroWasteBatch(String fishingOperationId) {
+ List<MacroWasteBatch> result = getAllTraitFilterBatches(
+ MacroWasteBatch.class, fishingOperationId);
return result;
}
@Override
- public MacroDechetBatch getMacroDechetBatch(String id) {
- MacroDechetBatch result = getBean(MacroDechetBatch.class, id);
+ public MacroWasteBatch getMacroWasteBatch(String id) {
+ MacroWasteBatch result = getBean(MacroWasteBatch.class, id);
return result;
}
@Override
- public MacroDechetBatch createMacroDechetBatch(MacroDechetBatch bean) {
- MacroDechetBatch result = create(MacroDechetBatch.class, bean);
+ public MacroWasteBatch createMacroWasteBatch(MacroWasteBatch bean) {
+ MacroWasteBatch result = create(MacroWasteBatch.class, bean);
return result;
}
@Override
- public MacroDechetBatch saveMacroDechetBatch(MacroDechetBatch bean) {
- MacroDechetBatch result = save(MacroDechetBatch.class, bean);
+ public MacroWasteBatch saveMacroWasteBatch(MacroWasteBatch bean) {
+ MacroWasteBatch result = save(MacroWasteBatch.class, bean);
return result;
}
+ @Override
+ public void deleteMacroWasteBatch(String id) {
+ remove(MacroWasteBatch.class, id);
+ }
+
//------------------------------------------------------------------------//
//-- Accidentel Batch methods --//
//------------------------------------------------------------------------//
@Override
- public List<AccidentelBatch> getAllAccidentelBatch(String fishingOperationId) {
- List<AccidentelBatch> result = getAllTraitFilterBatches(
- AccidentelBatch.class, fishingOperationId);
+ public List<AccidentalBatch> getAllAccidentalBatch(String fishingOperationId) {
+ List<AccidentalBatch> result = getAllTraitFilterBatches(
+ AccidentalBatch.class, fishingOperationId);
return result;
}
@Override
- public AccidentelBatch getAccidentelBatch(String id) {
- AccidentelBatch result = getBean(AccidentelBatch.class, id);
+ public AccidentalBatch getAccidentalBatch(String id) {
+ AccidentalBatch result = getBean(AccidentalBatch.class, id);
return result;
}
@Override
- public AccidentelBatch createAccidentelBatch(AccidentelBatch bean) {
- AccidentelBatch result = create(AccidentelBatch.class, bean);
+ public AccidentalBatch createAccidentalBatch(AccidentalBatch bean) {
+ AccidentalBatch result = create(AccidentalBatch.class, bean);
return result;
}
@Override
- public AccidentelBatch saveAccidentelBatch(AccidentelBatch bean) {
- AccidentelBatch result = save(AccidentelBatch.class, bean);
+ public AccidentalBatch saveAccidentalBatch(AccidentalBatch bean) {
+ AccidentalBatch result = save(AccidentalBatch.class, bean);
return result;
}
+ @Override
+ public void deleteAccidentalBatch(String id) {
+ remove(AccidentalBatch.class, id);
+ }
+
//------------------------------------------------------------------------//
//-- Internal methods --//
//------------------------------------------------------------------------//
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 2012-12-12 22:50:50 UTC (rev 54)
+++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/PersistenceService.java 2012-12-13 01:57:28 UTC (rev 55)
@@ -26,12 +26,12 @@
import com.google.common.base.Preconditions;
import fr.ifremer.tutti.persistence.TuttiPersistence;
-import fr.ifremer.tutti.persistence.entities.data.AccidentelBatch;
+import fr.ifremer.tutti.persistence.entities.data.AccidentalBatch;
import fr.ifremer.tutti.persistence.entities.data.BenthosBatch;
import fr.ifremer.tutti.persistence.entities.data.Cruise;
import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
-import fr.ifremer.tutti.persistence.entities.data.MacroDechetBatch;
-import fr.ifremer.tutti.persistence.entities.data.PlanctonBatch;
+import fr.ifremer.tutti.persistence.entities.data.MacroWasteBatch;
+import fr.ifremer.tutti.persistence.entities.data.PlanktonBatch;
import fr.ifremer.tutti.persistence.entities.data.Program;
import fr.ifremer.tutti.persistence.entities.data.SpeciesBatch;
import fr.ifremer.tutti.persistence.entities.data.SpeciesBatchFrequency;
@@ -357,90 +357,114 @@
return driver.saveBenthosBatch(bean);
}
+ @Override
+ public void deleteBenthosBatch(String id) {
+ checkDriverExists();
+ driver.deleteBenthosBatch(id);
+ }
+
//------------------------------------------------------------------------//
//-- Plancton Batch methods --//
//------------------------------------------------------------------------//
@Override
- public List<PlanctonBatch> getAllPlanctonBatch(String fishingOperationId) {
+ public List<PlanktonBatch> getAllPlanktonBatch(String fishingOperationId) {
checkDriverExists();
- return driver.getAllPlanctonBatch(fishingOperationId);
+ return driver.getAllPlanktonBatch(fishingOperationId);
}
@Override
- public PlanctonBatch getPlanctonBatch(String id) {
+ public PlanktonBatch getPlanktonBatch(String id) {
checkDriverExists();
- return driver.getPlanctonBatch(id);
+ return driver.getPlanktonBatch(id);
}
@Override
- public PlanctonBatch createPlanctonBatch(PlanctonBatch bean) {
+ public PlanktonBatch createPlanktonBatch(PlanktonBatch bean) {
checkDriverExists();
- return driver.createPlanctonBatch(bean);
+ return driver.createPlanktonBatch(bean);
}
@Override
- public PlanctonBatch savePlanctonBatch(PlanctonBatch bean) {
+ public PlanktonBatch savePlanktonBatch(PlanktonBatch bean) {
checkDriverExists();
- return driver.savePlanctonBatch(bean);
+ return driver.savePlanktonBatch(bean);
}
+ @Override
+ public void deletePlanktonBatch(String id) {
+ checkDriverExists();
+ driver.deletePlanktonBatch(id);
+ }
+
//------------------------------------------------------------------------//
//-- Macrodechet Batch methods --//
//------------------------------------------------------------------------//
@Override
- public List<MacroDechetBatch> getAllMacroDechetBatch(String fishingOperationId) {
+ public List<MacroWasteBatch> getAllMacroWasteBatch(String fishingOperationId) {
checkDriverExists();
- return driver.getAllMacroDechetBatch(fishingOperationId);
+ return driver.getAllMacroWasteBatch(fishingOperationId);
}
@Override
- public MacroDechetBatch getMacroDechetBatch(String id) {
+ public MacroWasteBatch getMacroWasteBatch(String id) {
checkDriverExists();
- return driver.getMacroDechetBatch(id);
+ return driver.getMacroWasteBatch(id);
}
@Override
- public MacroDechetBatch createMacroDechetBatch(MacroDechetBatch bean) {
+ public MacroWasteBatch createMacroWasteBatch(MacroWasteBatch bean) {
checkDriverExists();
- return driver.createMacroDechetBatch(bean);
+ return driver.createMacroWasteBatch(bean);
}
@Override
- public MacroDechetBatch saveMacroDechetBatch(MacroDechetBatch bean) {
+ public MacroWasteBatch saveMacroWasteBatch(MacroWasteBatch bean) {
checkDriverExists();
- return driver.saveMacroDechetBatch(bean);
+ return driver.saveMacroWasteBatch(bean);
}
+ @Override
+ public void deleteMacroWasteBatch(String id) {
+ checkDriverExists();
+ driver.deleteMacroWasteBatch(id);
+ }
+
//------------------------------------------------------------------------//
//-- Accidentel Batch methods --//
//------------------------------------------------------------------------//
@Override
- public List<AccidentelBatch> getAllAccidentelBatch(String fishingOperationId) {
+ public List<AccidentalBatch> getAllAccidentalBatch(String fishingOperationId) {
checkDriverExists();
- return driver.getAllAccidentelBatch(fishingOperationId);
+ return driver.getAllAccidentalBatch(fishingOperationId);
}
@Override
- public AccidentelBatch getAccidentelBatch(String id) {
+ public AccidentalBatch getAccidentalBatch(String id) {
checkDriverExists();
- return driver.getAccidentelBatch(id);
+ return driver.getAccidentalBatch(id);
}
@Override
- public AccidentelBatch createAccidentelBatch(AccidentelBatch bean) {
+ public AccidentalBatch createAccidentalBatch(AccidentalBatch bean) {
checkDriverExists();
- return driver.createAccidentelBatch(bean);
+ return driver.createAccidentalBatch(bean);
}
@Override
- public AccidentelBatch saveAccidentelBatch(AccidentelBatch bean) {
+ public AccidentalBatch saveAccidentalBatch(AccidentalBatch bean) {
checkDriverExists();
- return driver.saveAccidentelBatch(bean);
+ return driver.saveAccidentalBatch(bean);
}
+ @Override
+ public void deleteAccidentalBatch(String id) {
+ checkDriverExists();
+ driver.deleteAccidentalBatch(id);
+ }
+
//------------------------------------------------------------------------//
//-- Internal methods --//
//------------------------------------------------------------------------//
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/MainUI.css
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/MainUI.css 2012-12-12 22:50:50 UTC (rev 54)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/MainUI.css 2012-12-13 01:57:28 UTC (rev 55)
@@ -73,7 +73,7 @@
text: "tutti.action.fillCatches";
toolTipText: "tutti.action.fillCatches.tip";
mnemonic: C;
- enabled: {model.getScreen() != TuttiScreen.FILL_FISHING_OPERATION && model.isCruiseContextFilled()};
+ enabled: {model.getScreen() != TuttiScreen.EDIT_FISHING_OPERATION && model.isCruiseContextFilled()};
/*actionIcon: "catches";*/
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/MainUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/MainUIHandler.java 2012-12-12 22:50:50 UTC (rev 54)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/MainUIHandler.java 2012-12-13 01:57:28 UTC (rev 55)
@@ -24,16 +24,16 @@
* #L%
*/
+import fr.ifremer.tutti.persistence.entities.data.Cruise;
import fr.ifremer.tutti.persistence.entities.data.Program;
-import fr.ifremer.tutti.persistence.entities.data.Cruise;
import fr.ifremer.tutti.service.PersistenceService;
import fr.ifremer.tutti.service.config.TuttiServiceConfigOption;
import fr.ifremer.tutti.ui.swing.config.TuttiConfig;
import fr.ifremer.tutti.ui.swing.config.TuttiConfigOption;
import fr.ifremer.tutti.ui.swing.content.cruise.EditCruiseUI;
-import fr.ifremer.tutti.ui.swing.content.program.EditProgramUI;
import fr.ifremer.tutti.ui.swing.content.home.SelectCruiseUI;
import fr.ifremer.tutti.ui.swing.content.operation.FishingOperationsUI;
+import fr.ifremer.tutti.ui.swing.content.program.EditProgramUI;
import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil;
import jaxx.runtime.SwingUtil;
import jaxx.runtime.swing.AboutPanel;
@@ -114,7 +114,7 @@
if (context.isCruiseContextFilled()) {
// direct fill catches screen
- screen = TuttiScreen.FILL_FISHING_OPERATION;
+ screen = TuttiScreen.EDIT_FISHING_OPERATION;
} else {
// go to select cruise screen
@@ -234,7 +234,7 @@
}
public void showFillCatches() {
- context.setScreen(TuttiScreen.FILL_FISHING_OPERATION);
+ context.setScreen(TuttiScreen.EDIT_FISHING_OPERATION);
}
public void showImportScreen() {
@@ -355,9 +355,9 @@
screenUI = new EditCruiseUI(context);
break;
- case FILL_FISHING_OPERATION:
+ case EDIT_FISHING_OPERATION:
- screenTitle = _("tutti.title.fill.catches");
+ screenTitle = _("tutti.title.edit.operations", getSelectedCruiseTitle());
screenUI = new FishingOperationsUI(context);
break;
}
@@ -397,7 +397,7 @@
protected void closeCurrentBody() {
if (currentBody != null) {
- TuttiUI<?,?> body = (TuttiUI<?,?>) currentBody;
+ TuttiUI<?, ?> body = (TuttiUI<?, ?>) currentBody;
body.getHandler().onCloseUI();
context.getSwingSession().save();
@@ -430,7 +430,16 @@
}
protected void changeTitle() {
+
+ String title = getSelectedCruiseTitle();
+
+ ui.setTitle("Tutti - v " + getConfig().getVersion() + " [ " + title + " ]");
+ }
+
+ protected String getSelectedCruiseTitle() {
+
String surveyId = context.getProgramId();
+
String title;
if (surveyId == null) {
@@ -465,8 +474,7 @@
title += _("tutti.title.selectedCruise", cruise.getName());
}
}
-
- ui.setTitle("Tutti - v " + getConfig().getVersion() + " [ " + title + " ]");
+ return title;
}
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/TuttiScreen.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/TuttiScreen.java 2012-12-12 22:50:50 UTC (rev 54)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/TuttiScreen.java 2012-12-13 01:57:28 UTC (rev 55)
@@ -65,5 +65,5 @@
*
* @since 0.1
*/
- FILL_FISHING_OPERATION
+ EDIT_FISHING_OPERATION
}
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 2012-12-12 22:50:50 UTC (rev 54)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/SelectCruiseUIHandler.java 2012-12-13 01:57:28 UTC (rev 55)
@@ -175,7 +175,7 @@
public void showFishingOperations() {
- context.setScreen(TuttiScreen.FILL_FISHING_OPERATION);
+ context.setScreen(TuttiScreen.EDIT_FISHING_OPERATION);
}
public void showSelectedProgram() {
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/FishingOperationTabUI.jaxx
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/FishingOperationTabUI.jaxx 2012-12-12 22:50:50 UTC (rev 54)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/FishingOperationTabUI.jaxx 2012-12-13 01:57:28 UTC (rev 55)
@@ -84,10 +84,10 @@
<field name='saisisseur' component='saisisseurList'/>
</BeanValidator>
- <JPanel id='traitPane' constraints='BorderLayout.CENTER'
+ <JPanel id='fishingOperationPane' constraints='BorderLayout.CENTER'
layout='{new BorderLayout()}'>
- <JTabbedPane id='traitTabPane' constraints='BorderLayout.CENTER'>
+ <JTabbedPane id='fishingOperationTabPane' constraints='BorderLayout.CENTER'>
<tab id='traitGeneralTab'
title='tutti.label.tab.fishingOperation.general'>
<Table fill='both' id='generalForm'>
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/FishingOperationTabUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/FishingOperationTabUIHandler.java 2012-12-12 22:50:50 UTC (rev 54)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/FishingOperationTabUIHandler.java 2012-12-13 01:57:28 UTC (rev 55)
@@ -28,7 +28,6 @@
import fr.ifremer.tutti.persistence.entities.referential.Person;
import fr.ifremer.tutti.service.PersistenceService;
import fr.ifremer.tutti.ui.swing.AbstractTuttiUIHandler;
-import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -72,7 +71,7 @@
model.addPropertyChangeListener(FishingOperationTabUIModel.PROPERTY_EMPTY, new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
- JPanel form = ui.getTraitPane();
+ JPanel form = ui.getFishingOperationPane();
JLabel noContentPane = ui.getNoTraitPane();
Boolean empty = (Boolean) evt.getNewValue();
@@ -153,9 +152,6 @@
// update model empty property
model.setEmpty(empty);
- // reload bean in validator (? really mandatory?)
-// ui.getValidator().reloadBean();
-
// if new fishingOperation can already cancel his creation
model.setModify(!empty && model.isCreate());
}
@@ -192,13 +188,13 @@
}
// keep selected tab (to resotre it after save)
- int selectedIndex = ui.getTraitTabPane().getSelectedIndex();
+ int selectedIndex = ui.getFishingOperationTabPane().getSelectedIndex();
// persist current fishingOperation
parentUi.getHandler().saveFishingOperation(toSave);
// reselect current tab
- ui.getTraitTabPane().setSelectedIndex(selectedIndex);
+ ui.getFishingOperationTabPane().setSelectedIndex(selectedIndex);
getModel().setModify(false);
}
@@ -219,10 +215,6 @@
getModel().setGearShootingStartLongitude(Float.valueOf(text));
}
-// public void setGearShootingStartTime(String text) {
-// getModel().setGearShootingStartTime(Integer.valueOf(text));
-// }
-
public void setGearShootingEndLatitude(String text) {
getModel().setGearShootingEndLatitude(Float.valueOf(text));
}
@@ -230,8 +222,4 @@
public void setGearShootingEndLongitude(String text) {
getModel().setGearShootingEndLongitude(Float.valueOf(text));
}
-
-// public void setGearShootingEndTime(String text) {
-// getModel().setGearShootingEndTime(Integer.valueOf(text));
-// }
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/FishingOperationsUI.css
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/FishingOperationsUI.css 2012-12-12 22:50:50 UTC (rev 54)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/FishingOperationsUI.css 2012-12-13 01:57:28 UTC (rev 55)
@@ -46,7 +46,7 @@
enabled: {model.getSelectedFishingOperation() != null};
}
-#planctonTab {
+#planktonTab {
enabled: {model.getSelectedFishingOperation() != null};
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/FishingOperationsUI.jaxx
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/FishingOperationsUI.jaxx 2012-12-12 22:50:50 UTC (rev 54)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/FishingOperationsUI.jaxx 2012-12-13 01:57:28 UTC (rev 55)
@@ -28,11 +28,11 @@
fr.ifremer.tutti.persistence.entities.data.FishingOperation
fr.ifremer.tutti.ui.swing.TuttiUIContext
- fr.ifremer.tutti.ui.swing.content.operation.accidental.AccidentelTabUI
- fr.ifremer.tutti.ui.swing.content.operation.benthos.BenthosTabUI
- fr.ifremer.tutti.ui.swing.content.operation.macrowaste.MacroDechetTabUI
- fr.ifremer.tutti.ui.swing.content.operation.plankton.PlanctonTabUI
- fr.ifremer.tutti.ui.swing.content.operation.species.SpeciesTabUI
+ fr.ifremer.tutti.ui.swing.content.operation.accidental.AccidentalBatchUI
+ fr.ifremer.tutti.ui.swing.content.operation.benthos.BenthosBatchUI
+ fr.ifremer.tutti.ui.swing.content.operation.macrowaste.MacroWasteBatchUI
+ fr.ifremer.tutti.ui.swing.content.operation.plankton.PlanktonBatchUI
+ fr.ifremer.tutti.ui.swing.content.operation.species.SpeciesBatchUI
jaxx.runtime.swing.editor.bean.BeanComboBox
@@ -73,23 +73,23 @@
</Table>
<JTabbedPane id='tabPane' constraints='BorderLayout.CENTER'>
- <tab id='traitTab' title='tutti.label.tab.fishingOperation'>
+ <tab id='fishingOperationTab' title='tutti.label.tab.fishingOperation'>
<FishingOperationTabUI id='fishingOperationTabContent' constructorParams='this'/>
</tab>
<tab id='speciesTab' title='tutti.label.tab.species'>
- <SpeciesTabUI id='speciesTabContent' constructorParams='this'/>
+ <SpeciesBatchUI id='speciesTabContent' constructorParams='this'/>
</tab>
<tab id='benthosTab' title='tutti.label.tab.benthos'>
- <BenthosTabUI id='benthosTabContent' constructorParams='this'/>
+ <BenthosBatchUI id='benthosTabContent' constructorParams='this'/>
</tab>
- <tab id='planctonTab' title='tutti.label.tab.plancton'>
- <PlanctonTabUI id='planctonTabContent' constructorParams='this'/>
+ <tab id='planktonTab' title='tutti.label.tab.plancton'>
+ <PlanktonBatchUI id='planktonTabContent' constructorParams='this'/>
</tab>
<tab id='macroDechetTab' title='tutti.label.tab.macroDechet'>
- <MacroDechetTabUI id='macroDechetTabContent' constructorParams='this'/>
+ <MacroWasteBatchUI id='macroDechetTabContent' constructorParams='this'/>
</tab>
<tab id='accidentelTab' title='tutti.label.tab.accidentel'>
- <AccidentelTabUI id='accidentelTabContent' constructorParams='this'/>
+ <AccidentalBatchUI id='accidentelTabContent' constructorParams='this'/>
</tab>
<tab id='observationIndividuelTab' title='tutti.label.tab.observationIndividuel'>
<JLabel text='tutti.to.be.done' horizontalAlignment='{JLabel.CENTER}'/>
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/FishingOperationsUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/FishingOperationsUIHandler.java 2012-12-12 22:50:50 UTC (rev 54)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/FishingOperationsUIHandler.java 2012-12-13 01:57:28 UTC (rev 55)
@@ -127,7 +127,7 @@
// ui will be saved so we do not want to keep selected tab indexes
ui.getTabPane().setSelectedIndex(0);
- ui.getFishingOperationTabContent().getTraitTabPane().setSelectedIndex(0);
+ ui.getFishingOperationTabContent().getFishingOperationTabPane().setSelectedIndex(0);
// when quitting ui, let's de-select fishingOperation (will save any changes)
selectFishingOperation(null);
@@ -167,13 +167,13 @@
ui.getTabPane().setSelectedIndex(0);
// back to general tab of fishingOperation tabs
- ui.getFishingOperationTabContent().getTraitTabPane().setSelectedIndex(0);
+ ui.getFishingOperationTabContent().getFishingOperationTabPane().setSelectedIndex(0);
// propagate fishingOperation to his tabs
ui.getFishingOperationTabContent().selectFishingOperation(fishingOperation);
ui.getSpeciesTabContent().selectFishingOperation(fishingOperation);
ui.getBenthosTabContent().selectFishingOperation(fishingOperation);
- ui.getPlanctonTabContent().selectFishingOperation(fishingOperation);
+ ui.getPlanktonTabContent().selectFishingOperation(fishingOperation);
ui.getMacroDechetTabContent().selectFishingOperation(fishingOperation);
ui.getAccidentelTabContent().selectFishingOperation(fishingOperation);
Added: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/accidental/AccidentalBatchRowModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/accidental/AccidentalBatchRowModel.java (rev 0)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/accidental/AccidentalBatchRowModel.java 2012-12-13 01:57:28 UTC (rev 55)
@@ -0,0 +1,116 @@
+package fr.ifremer.tutti.ui.swing.content.operation.accidental;
+
+/*
+ * #%L
+ * Tutti :: UI
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 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.entities.data.AccidentalBatch;
+import fr.ifremer.tutti.persistence.entities.referential.Species;
+import fr.ifremer.tutti.ui.swing.AbstractTuttiBeanUIModel;
+import org.nuiton.util.beans.Binder;
+import org.nuiton.util.beans.BinderFactory;
+
+/**
+ * Define a benthos batch row.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 0.2
+ */
+public class AccidentalBatchRowModel extends AbstractTuttiBeanUIModel<AccidentalBatch, AccidentalBatchRowModel> {
+
+ private static final long serialVersionUID = 1L;
+
+ public static final String PROPERTY_SPECIES = "species";
+
+ public static final String PROPERTY_WEIGHT = "weight";
+
+ public static final String PROPERTY_COMMENT = "comment";
+
+ /**
+ * Species observed.
+ *
+ * @since 0.2
+ */
+ protected Species species;
+
+ /**
+ * Observed weight.
+ *
+ * @since 0.2
+ */
+ protected Float weight;
+
+ /**
+ * Comment on this catches.
+ *
+ * @since 0.2
+ */
+ protected String comment;
+
+ protected static final Binder<AccidentalBatch, AccidentalBatchRowModel> fromBeanBinder =
+ BinderFactory.newBinder(AccidentalBatch.class,
+ AccidentalBatchRowModel.class);
+
+ protected static final Binder<AccidentalBatchRowModel, AccidentalBatch> toBeanBinder =
+ BinderFactory.newBinder(AccidentalBatchRowModel.class,
+ AccidentalBatch.class);
+
+ public AccidentalBatchRowModel() {
+ super(AccidentalBatch.class, fromBeanBinder, toBeanBinder);
+ }
+
+ public AccidentalBatchRowModel(AccidentalBatch aBatch) {
+ this();
+ fromBean(aBatch);
+ }
+
+ public Species getSpecies() {
+ return species;
+ }
+
+ public void setSpecies(Species species) {
+ Object oldValue = getSpecies();
+ this.species = species;
+ firePropertyChange(PROPERTY_SPECIES, oldValue, species);
+ }
+
+ public Float getWeight() {
+ return weight;
+ }
+
+ public void setWeight(Float weight) {
+ Object oldValue = getWeight();
+ this.weight = weight;
+ firePropertyChange(PROPERTY_WEIGHT, oldValue, weight);
+ }
+
+ public String getComment() {
+ return comment;
+ }
+
+ public void setComment(String comment) {
+ Object oldValue = getComment();
+ this.comment = comment;
+ firePropertyChange(PROPERTY_COMMENT, oldValue, comment);
+ }
+}
Property changes on: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/accidental/AccidentalBatchRowModel.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Copied: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/accidental/AccidentalBatchTableModel.java (from rev 48, trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/accidental/AccidentelTableModel.java)
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/accidental/AccidentalBatchTableModel.java (rev 0)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/accidental/AccidentalBatchTableModel.java 2012-12-13 01:57:28 UTC (rev 55)
@@ -0,0 +1,119 @@
+package fr.ifremer.tutti.ui.swing.content.operation.accidental;
+
+/*
+ * #%L
+ * Tutti :: UI
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 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.content.operation.benthos.BenthosBatchRowModel;
+import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableModel;
+import fr.ifremer.tutti.ui.swing.util.table.ColumnIdentifier;
+
+import javax.swing.table.TableColumnModel;
+
+import static org.nuiton.i18n.I18n.n_;
+
+/**
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 0.2
+ */
+public class AccidentalBatchTableModel extends AbstractTuttiTableModel<AccidentalBatchRowModel> {
+
+ private static final long serialVersionUID = 1L;
+
+ public static final ColumnIdentifier<AccidentalBatchRowModel> SPECIES_BY_CODE = ColumnIdentifier.newId(
+ BenthosBatchRowModel.PROPERTY_SPECIES,
+ n_("tutti.table.benthos.batch.header.speciesByCode"),
+ n_("tutti.table.benthos.batch.header.speciesByCode"));
+
+ public static final ColumnIdentifier<AccidentalBatchRowModel> SPECIES_BY_GENUS_CODE = ColumnIdentifier.newId(
+ BenthosBatchRowModel.PROPERTY_SPECIES,
+ n_("tutti.table.benthos.batch.header.speciesByGenusCode"),
+ n_("tutti.table.benthos.batch.header.speciesByGenusCode"));
+
+ public static final ColumnIdentifier<AccidentalBatchRowModel> WEIGHT = ColumnIdentifier.newId(
+ BenthosBatchRowModel.PROPERTY_WEIGHT,
+ n_("tutti.table.benthos.batch.header.weight"),
+ n_("tutti.table.benthos.batch.header.weight"));
+
+ public static final ColumnIdentifier<AccidentalBatchRowModel> COMMENT = ColumnIdentifier.newId(
+ BenthosBatchRowModel.PROPERTY_COMMENT,
+ n_("tutti.table.benthos.batch.header.comment"),
+ n_("tutti.table.benthos.batch.header.comment"));
+
+ public static final ColumnIdentifier<AccidentalBatchRowModel> FILE = ColumnIdentifier.newId(
+ null,
+ n_("tutti.table.benthos.batch.header.file"),
+ n_("tutti.table.benthos.batch.header.file"));
+
+
+ public AccidentalBatchTableModel(TableColumnModel columnModel) {
+ super(columnModel);
+
+ setNoneEditableCols(
+ FILE
+ );
+ }
+
+ @Override
+ protected AccidentalBatchRowModel createNewRow() {
+ AccidentalBatchRowModel result = new AccidentalBatchRowModel();
+
+ // by default empty row is not valid
+ result.setValid(false);
+ return result;
+ }
+
+ @Override
+ public void setValueAt(Object aValue,
+ int rowIndex,
+ int columnIndex,
+ ColumnIdentifier<AccidentalBatchRowModel> propertyName,
+ AccidentalBatchRowModel entry) {
+ super.setValueAt(aValue, rowIndex, columnIndex, propertyName, entry);
+
+ if (propertyName == SPECIES_BY_CODE) {
+
+ // update also other columns
+ fireTableCellUpdated(rowIndex,
+ SPECIES_BY_GENUS_CODE);
+
+ } else if (propertyName == SPECIES_BY_GENUS_CODE) {
+
+ // update also other columns
+ fireTableCellUpdated(rowIndex,
+ SPECIES_BY_CODE);
+ }
+ }
+
+ @Override
+ protected boolean isCellEditable(int rowIndex,
+ int columnIndex,
+ ColumnIdentifier<AccidentalBatchRowModel> propertyName) {
+
+ boolean result = super.isCellEditable(rowIndex,
+ columnIndex,
+ propertyName);
+
+ return result;
+ }
+}
\ No newline at end of file
Property changes on: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/accidental/AccidentalBatchTableModel.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Copied: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/accidental/AccidentalBatchUI.css (from rev 48, trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/accidental/AccidentelTabUI.css)
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/accidental/AccidentalBatchUI.css (rev 0)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/accidental/AccidentalBatchUI.css 2012-12-13 01:57:28 UTC (rev 55)
@@ -0,0 +1,37 @@
+/*
+ * #%L
+ * Tutti :: UI
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 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%
+ */
+
+NumberEditor {
+ autoPopup: {handler.getConfig().isAutoPopupNumberEditor()};
+ showPopupButton: {handler.getConfig().isShowNumberEditorButton()};
+ bean: {model};
+ showReset: true;
+}
+
+#table {
+ selectionMode: {ListSelectionModel.SINGLE_SELECTION};
+ selectionBackground: {null};
+ selectionForeground: {Color.BLACK};
+ sortable: false;
+}
Property changes on: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/accidental/AccidentalBatchUI.css
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Copied: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/accidental/AccidentalBatchUI.jaxx (from rev 48, trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/accidental/AccidentelTabUI.jaxx)
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/accidental/AccidentalBatchUI.jaxx (rev 0)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/accidental/AccidentalBatchUI.jaxx 2012-12-13 01:57:28 UTC (rev 55)
@@ -0,0 +1,67 @@
+<!--
+ #%L
+ Tutti :: UI
+ $Id$
+ $HeadURL$
+ %%
+ Copyright (C) 2012 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%
+ -->
+<JPanel id='homePanel' layout='{new BorderLayout()}'
+ implements='fr.ifremer.tutti.ui.swing.TuttiUI<AccidentalBatchUIModel, AccidentalBatchUIHandler>'>
+
+ <import>
+ fr.ifremer.tutti.persistence.entities.data.FishingOperation
+
+ fr.ifremer.tutti.ui.swing.TuttiUIContext
+ fr.ifremer.tutti.ui.swing.content.operation.FishingOperationsUI
+
+ jaxx.runtime.swing.editor.NumberEditor
+
+ org.jdesktop.swingx.JXTable
+
+ javax.swing.ListSelectionModel
+
+ java.awt.Color
+
+ static org.nuiton.i18n.I18n._
+ </import>
+
+ <script><![CDATA[
+
+public AccidentalBatchUI(FishingOperationsUI parentUI) {
+ AccidentalBatchUIHandler handler = new AccidentalBatchUIHandler(parentUI, this);
+ setContextValue(handler);
+ handler.beforeInitUI();
+}
+
+public void selectFishingOperation(FishingOperation fishingOperation) { handler.selectFishingOperation(fishingOperation); }
+
+protected void $afterCompleteSetup() { handler.afterInitUI(); }
+ ]]></script>
+
+ <AccidentalBatchUIHandler id='handler'
+ initializer='getContextValue(AccidentalBatchUIHandler.class)'/>
+
+ <AccidentalBatchUIModel id='model'
+ initializer='getContextValue(AccidentalBatchUIModel.class)'/>
+
+ <JScrollPane id='tableScrollPane' constraints='BorderLayout.CENTER'>
+ <JXTable id='table' onFocusLost='handler.saveSelectedRowIfRequired(event);'/>
+ </JScrollPane>
+
+</JPanel>
\ No newline at end of file
Property changes on: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/accidental/AccidentalBatchUI.jaxx
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Copied: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/accidental/AccidentalBatchUIHandler.java (from rev 48, trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/accidental/AccidentelTabUIHandler.java)
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/accidental/AccidentalBatchUIHandler.java (rev 0)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/accidental/AccidentalBatchUIHandler.java 2012-12-13 01:57:28 UTC (rev 55)
@@ -0,0 +1,464 @@
+package fr.ifremer.tutti.ui.swing.content.operation.accidental;
+
+/*
+ * #%L
+ * Tutti :: UI
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 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.collect.Lists;
+import fr.ifremer.tutti.persistence.entities.TuttiEntities;
+import fr.ifremer.tutti.persistence.entities.data.AccidentalBatch;
+import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
+import fr.ifremer.tutti.persistence.entities.referential.Species;
+import fr.ifremer.tutti.service.DecoratorService;
+import fr.ifremer.tutti.service.PersistenceService;
+import fr.ifremer.tutti.ui.swing.TuttiUI;
+import fr.ifremer.tutti.ui.swing.content.operation.FishingOperationsUI;
+import fr.ifremer.tutti.ui.swing.util.TuttiBeanMonitor;
+import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil;
+import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableUIHandler;
+import fr.ifremer.tutti.ui.swing.util.table.TableRowModificationListener;
+import jaxx.runtime.SwingUtil;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.jdesktop.swingx.JXTable;
+import org.jdesktop.swingx.decorator.ComponentAdapter;
+import org.jdesktop.swingx.decorator.HighlightPredicate;
+import org.jdesktop.swingx.decorator.Highlighter;
+import org.jdesktop.swingx.table.DefaultTableColumnModelExt;
+import org.nuiton.util.decorator.Decorator;
+
+import javax.swing.event.ListSelectionListener;
+import javax.swing.table.TableColumnModel;
+import java.awt.Color;
+import java.awt.Component;
+import java.awt.event.FocusEvent;
+import java.util.List;
+
+/**
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 0.2
+ */
+public class AccidentalBatchUIHandler extends AbstractTuttiTableUIHandler<AccidentalBatchRowModel, AccidentalBatchUIModel> {
+
+ /** Logger. */
+ private static final Log log = LogFactory.getLog(AccidentalBatchUIHandler.class);
+
+ /**
+ * UI.
+ *
+ * @since 0.2
+ */
+ private final AccidentalBatchUI ui;
+
+ /**
+ * Persistence service.
+ *
+ * @since 0.2
+ */
+ private final PersistenceService persistenceService;
+
+ /**
+ * To monitor changes on the fishing operation.
+ *
+ * @since 0.2
+ */
+ private final TuttiBeanMonitor<AccidentalBatchUIModel> fishingOperationMonitor;
+
+ public AccidentalBatchUIHandler(FishingOperationsUI parentUi, AccidentalBatchUI ui) {
+ super(parentUi.getHandler().getContext(),
+ AccidentalBatchRowModel.PROPERTY_SPECIES,
+ AccidentalBatchRowModel.PROPERTY_WEIGHT,
+ AccidentalBatchRowModel.PROPERTY_COMMENT);
+ this.ui = ui;
+ this.persistenceService = context.getService(PersistenceService.class);
+ this.fishingOperationMonitor = new TuttiBeanMonitor<AccidentalBatchUIModel>();
+ }
+
+ //------------------------------------------------------------------------//
+ //-- AbstractTuttiTableUIHandler methods --//
+ //------------------------------------------------------------------------//
+
+ @Override
+ protected AccidentalBatchUIModel getModel() {
+ return ui.getModel();
+ }
+
+ @Override
+ protected AccidentalBatchTableModel getTableModel() {
+ return (AccidentalBatchTableModel) getTable().getModel();
+ }
+
+ @Override
+ protected JXTable getTable() {
+ return ui.getTable();
+ }
+
+ @Override
+ protected TableColumnModel createTableColumnModel() {
+
+ DefaultTableColumnModelExt columnModel =
+ new DefaultTableColumnModelExt();
+
+ List<Species> allSpecies = persistenceService.getAllSpecies();
+
+ {
+ // Species (by code) column
+
+ Decorator<Species> decorator = getDecorator(
+ Species.class, DecoratorService.SPECIES_BY_CODE);
+
+ addComboDataColumnToModel(columnModel,
+ AccidentalBatchTableModel.SPECIES_BY_CODE,
+ decorator, allSpecies);
+ }
+
+ {
+ // Species (by genusCode) column
+
+ Decorator<Species> decorator = getDecorator(
+ Species.class, DecoratorService.SPECIES_BY_GENUS);
+
+ addComboDataColumnToModel(columnModel,
+ AccidentalBatchTableModel.SPECIES_BY_GENUS_CODE,
+ decorator, allSpecies);
+
+ }
+
+ { // Weight column
+
+ addFloatColumnToModel(columnModel,
+ AccidentalBatchTableModel.WEIGHT,
+ TuttiUI.DECIMAL3_PATTERN);
+ }
+
+ { // Comment column
+
+ addColumnToModel(columnModel,
+ AccidentalBatchTableModel.COMMENT);
+ }
+
+ { // File column
+
+ addColumnToModel(columnModel,
+ AccidentalBatchTableModel.FILE);
+ }
+ return columnModel;
+ }
+
+ @Override
+ protected void onRowModified(AccidentalBatchRowModel row,
+ String propertyName,
+ Object oldValue,
+ Object newValue) {
+
+ boolean wasValid = row.isValid();
+
+ boolean valid = isRowValid(row);
+
+ if (log.isInfoEnabled()) {
+ log.info("Was valid / Is valid: " + wasValid + " / " + valid);
+ }
+ row.setValid(valid);
+ }
+
+ @Override
+ protected void onRowValidStateChanged(AccidentalBatchRowModel row,
+ Boolean oldValue,
+ Boolean newValue) {
+ int rowIndex = getTableModel().getRowIndex(row);
+
+ if (rowIndex > -1) {
+ getTableModel().fireTableRowsUpdated(rowIndex, rowIndex);
+ }
+ }
+
+ @Override
+ protected void onRowModifyStateChanged(AccidentalBatchRowModel row,
+ Boolean oldValue,
+ Boolean newValue) {
+ }
+
+ @Override
+ protected void onModelRowsChanged(List<AccidentalBatchRowModel> rows) {
+ super.onModelRowsChanged(rows);
+
+ // set valid flag
+ for (AccidentalBatchRowModel row : rows) {
+ boolean valid = isRowValid(row);
+ row.setValid(valid);
+ }
+ }
+
+ //------------------------------------------------------------------------//
+ //-- AbstractTuttiUIHandler methods --//
+ //------------------------------------------------------------------------//
+
+ @Override
+ public void beforeInitUI() {
+
+ if (log.isInfoEnabled()) {
+ log.info("beforeInit: " + ui);
+ }
+
+ AccidentalBatchUIModel model = new AccidentalBatchUIModel();
+ ui.setContextValue(model);
+
+ fishingOperationMonitor.setBean(model);
+ }
+
+ @Override
+ public void afterInitUI() {
+
+ if (log.isInfoEnabled()) {
+ log.info("afterInit: " + ui);
+ }
+
+ initUI(ui);
+
+ JXTable table = getTable();
+
+ // create table column model
+ TableColumnModel columnModel = createTableColumnModel();
+
+ // create table model
+ AccidentalBatchTableModel tableModel =
+ new AccidentalBatchTableModel(columnModel);
+
+ table.setModel(tableModel);
+ table.setColumnModel(columnModel);
+ installTableKeyListener(columnModel, table);
+
+ table.getTableHeader().setReorderingAllowed(false);
+
+
+ Highlighter readOnlyHighlighter = TuttiUIUtil.newBackgroundColorHighlighter(
+ HighlightPredicate.READ_ONLY, Color.LIGHT_GRAY);
+
+ table.addHighlighter(readOnlyHighlighter);
+ Highlighter validHighlighter = TuttiUIUtil.newBackgroundColorHighlighter(
+ new HighlightPredicate.AndHighlightPredicate(HighlightPredicate.EDITABLE, new HighlightPredicate() {
+ @Override
+ public boolean isHighlighted(Component renderer, ComponentAdapter adapter) {
+
+ boolean result = false;
+ if (adapter.isEditable()) {
+ int rowIndex = adapter.convertRowIndexToModel(adapter.row);
+ AccidentalBatchRowModel row = getTableModel().getEntry(rowIndex);
+ result = !row.isValid();
+ }
+ return result;
+ }
+ }), Color.RED);
+ table.addHighlighter(validHighlighter);
+
+ // when model datas change let's propagate it table model
+ listenRowsFromModel();
+
+ // save when row chaged and was modified
+ ListSelectionListener listener = new TableRowModificationListener<AccidentalBatchRowModel>(
+ getTableModel(), getRowMonitor()) {
+ @Override
+ protected void saveSelectedRow() {
+ saveSelectedRowIfRequired();
+ }
+ };
+ table.getSelectionModel().addListSelectionListener(listener);
+
+ // always scroll to selected row
+ SwingUtil.scrollToTableSelection(getTable());
+ }
+
+ @Override
+ public void onCloseUI() {
+ if (log.isInfoEnabled()) {
+ log.info("closing: " + ui);
+ }
+ }
+
+ //------------------------------------------------------------------------//
+ //-- Public methods --//
+ //------------------------------------------------------------------------//
+
+ public void saveSelectedRowIfRequired(FocusEvent event) {
+
+ Component oppositeComponent = event.getOppositeComponent();
+
+ JXTable parentContainer = null;
+
+ if (oppositeComponent != null) {
+
+ // check out if still on table
+ parentContainer = SwingUtil.getParentContainer(
+ oppositeComponent, JXTable.class);
+ }
+
+ if (parentContainer == null) {
+
+ // out of the table can save
+ if (getModel().getFishingOperation() != null) {
+ saveSelectedRowIfRequired();
+ }
+ }
+ }
+
+ public void selectFishingOperation(FishingOperation bean) {
+
+ JXTable table = getTable();
+
+ if (table.isEditing()) {
+
+ // make sure to stop editor
+ table.editingCanceled(null);
+ }
+
+ if (fishingOperationMonitor.wasModified()) {
+
+ // previous fishingOperation was modified, let's save it
+ AccidentalBatchUIModel beanToSave = fishingOperationMonitor.getBean();
+
+ FishingOperation fishingOperation = beanToSave.toBean();
+
+ if (log.isInfoEnabled()) {
+ log.info("FishingOperation " + fishingOperation.getId() +
+ " was modified, will save it.");
+ }
+
+ persistenceService.saveFishingOperation(fishingOperation);
+ }
+
+ // make sure selection is empty (will remove bean from monitor)
+ table.clearSelection();
+
+ boolean empty = bean == null;
+
+ AccidentalBatchUIModel model = getModel();
+
+ List<AccidentalBatchRowModel> rows;
+
+ if (empty) {
+ rows = null;
+ bean = new FishingOperation();
+ model.setFishingOperation(null);
+ } else {
+
+ if (log.isInfoEnabled()) {
+ log.info("Get species batch for fishingOperation: " + bean.getId());
+ }
+ rows = Lists.newArrayList();
+
+ if (!TuttiEntities.isNew(bean)) {
+ List<AccidentalBatch> catches =
+ persistenceService.getAllAccidentalBatch(bean.getId());
+ for (AccidentalBatch aBatch : catches) {
+ AccidentalBatchRowModel entry =
+ new AccidentalBatchRowModel(aBatch);
+ rows.add(entry);
+ }
+ }
+ model.setFishingOperation(bean);
+ }
+
+ model.fromBean(bean);
+ model.setRows(rows);
+
+ fishingOperationMonitor.clearModified();
+ }
+
+ public void cancel() {
+
+ if (log.isInfoEnabled()) {
+ log.info("Cancel edition");
+ }
+ }
+
+ public void save() {
+ if (log.isInfoEnabled()) {
+ log.info("Will save");
+ }
+ }
+
+ //------------------------------------------------------------------------//
+ //-- Internal methods --//
+ //------------------------------------------------------------------------//
+
+ protected boolean isRowValid(AccidentalBatchRowModel row) {
+ boolean result = row.getSpecies() != null && row.getWeight() != null;
+ return result;
+ }
+
+ protected void saveSelectedRowIfRequired() {
+
+ TuttiBeanMonitor<AccidentalBatchRowModel> rowMonitor = getRowMonitor();
+
+ AccidentalBatchRowModel bean = rowMonitor.getBean();
+ if (bean != null) {
+
+ if (bean.isValid()) {
+ // there is a valid bean attached to the monitor
+
+ if (rowMonitor.wasModified()) {
+
+ // monitored bean was modified, save it
+ if (log.isInfoEnabled()) {
+ log.info("Row " + bean + " was modified, will save it");
+ }
+
+ saveRow(bean);
+
+ // clear modified flag on the monitor
+ rowMonitor.clearModified();
+ }
+ } else {
+
+ // row is not valid can not save it
+
+ AccidentalBatch catchBean = bean.toBean();
+
+ if (!TuttiEntities.isNew(catchBean)) {
+
+ // remove this
+ persistenceService.deleteAccidentalBatch(catchBean.getId());
+ }
+ }
+ }
+ }
+
+ protected void saveRow(AccidentalBatchRowModel row) {
+
+ AccidentalBatch catchBean = row.toBean();
+
+ FishingOperation fishingOperation = getModel().getFishingOperation();
+ catchBean.setFishingOperation(fishingOperation);
+ if (log.isInfoEnabled()) {
+ log.info("Selected fishingOperation: " + fishingOperation.getId());
+ }
+
+ if (TuttiEntities.isNew(catchBean)) {
+
+ catchBean = persistenceService.createAccidentalBatch(catchBean);
+ row.setId(catchBean.getId());
+ } else {
+ persistenceService.saveAccidentalBatch(catchBean);
+ }
+ }
+}
\ No newline at end of file
Property changes on: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/accidental/AccidentalBatchUIHandler.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Copied: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/accidental/AccidentalBatchUIModel.java (from rev 48, trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/accidental/AccidentelTabUIModel.java)
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/accidental/AccidentalBatchUIModel.java (rev 0)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/accidental/AccidentalBatchUIModel.java 2012-12-13 01:57:28 UTC (rev 55)
@@ -0,0 +1,73 @@
+package fr.ifremer.tutti.ui.swing.content.operation.accidental;
+
+/*
+ * #%L
+ * Tutti :: UI
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 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.entities.data.FishingOperation;
+import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableUIModel;
+import org.nuiton.util.beans.Binder;
+import org.nuiton.util.beans.BinderModelBuilder;
+
+/**
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 0.2
+ */
+public class AccidentalBatchUIModel extends AbstractTuttiTableUIModel<FishingOperation, AccidentalBatchRowModel, AccidentalBatchUIModel> {
+
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * Editing fishing operation.
+ *
+ * @since 0.2
+ */
+ protected FishingOperation fishingOperation;
+
+
+ protected static final Binder<FishingOperation, AccidentalBatchUIModel> fromBeanBinder = BinderModelBuilder.newEmptyBuilder(FishingOperation.class, AccidentalBatchUIModel.class)
+ .addProperty(FishingOperation.PROPERTY_ID, PROPERTY_ID)
+ .toBinder();
+
+ protected static final Binder<AccidentalBatchUIModel, FishingOperation> toBeanBinder = BinderModelBuilder.newEmptyBuilder(AccidentalBatchUIModel.class, FishingOperation.class)
+ .toBinder();
+
+
+ public AccidentalBatchUIModel() {
+ super(FishingOperation.class, fromBeanBinder, toBeanBinder);
+ }
+
+ public FishingOperation getFishingOperation() {
+ return fishingOperation;
+ }
+
+ public void setFishingOperation(FishingOperation fishingOperation) {
+ this.fishingOperation = fishingOperation;
+ }
+
+
+ @Override
+ protected FishingOperation newEntity() {
+ return fishingOperation;
+ }
+}
\ No newline at end of file
Property changes on: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/accidental/AccidentalBatchUIModel.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Deleted: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/accidental/AccidentelTabUI.css
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/accidental/AccidentelTabUI.css 2012-12-12 22:50:50 UTC (rev 54)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/accidental/AccidentelTabUI.css 2012-12-13 01:57:28 UTC (rev 55)
@@ -1,59 +0,0 @@
-/*
- * #%L
- * Tutti :: UI
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2012 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%
- */
-
-NumberEditor {
- autoPopup: {handler.getConfig().isAutoPopupNumberEditor()};
- showPopupButton: {handler.getConfig().isShowNumberEditorButton()};
- bean: {model};
- showReset: true;
-}
-
-#totalWeightLabel {
- text: "tutti.label.captureAccidentel.totalWeight";
- labelFor: {totalWeightField};
-}
-
-#totalWeightField {
- property: "totalWeight";
- model: {model.getTotalWeight()};
- useFloat: false;
- numberPattern: {INT_6_DIGITS_PATTERN};
-}
-
-#sampleTotalWeightLabel {
- text: "tutti.label.captureAccidentel.sampleTotalWeight";
- labelFor: {totalWeightField};
-}
-
-#sampleTotalWeightField {
- property: "sampleTotalWeight";
- model: {model.getSampleTotalWeight()};
- useFloat: false;
- numberPattern: {INT_6_DIGITS_PATTERN};
-}
-
-#table {
- model: {getContextValue(TableModel.class)};
- columnModel: {getContextValue(TableColumnModel.class)};
-}
Deleted: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/accidental/AccidentelTabUI.jaxx
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/accidental/AccidentelTabUI.jaxx 2012-12-12 22:50:50 UTC (rev 54)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/accidental/AccidentelTabUI.jaxx 2012-12-13 01:57:28 UTC (rev 55)
@@ -1,98 +0,0 @@
-<!--
- #%L
- Tutti :: UI
- $Id$
- $HeadURL$
- %%
- Copyright (C) 2012 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%
- -->
-<JPanel id='homePanel' layout='{new BorderLayout()}'
- implements='fr.ifremer.tutti.ui.swing.TuttiUI<AccidentelTabUIModel, AccidentelTabUIHandler>'>
-
- <import>
- fr.ifremer.tutti.persistence.entities.data.FishingOperation
-
- fr.ifremer.tutti.ui.swing.TuttiUIContext
- fr.ifremer.tutti.ui.swing.content.operation.FishingOperationsUI
-
- jaxx.runtime.swing.editor.NumberEditor
-
- jaxx.runtime.validator.swing.SwingValidatorUtil
- jaxx.runtime.validator.swing.SwingValidatorMessageTableModel
-
- javax.swing.table.TableModel
- javax.swing.table.TableColumnModel
-
- static org.nuiton.i18n.I18n._
- </import>
-
- <script><![CDATA[
-
-public AccidentelTabUI(FishingOperationsUI parentUI) {
- AccidentelTabUIHandler handler = new AccidentelTabUIHandler(parentUI, this);
- setContextValue(handler);
- handler.beforeInitUI();
-}
-
-public void selectFishingOperation(FishingOperation fishingOperation) { handler.selectFishingOperation(fishingOperation); }
-
-protected void $afterCompleteSetup() { handler.afterInitUI(); }
- ]]></script>
-
- <AccidentelTabUIHandler id='handler'
- initializer='getContextValue(AccidentelTabUIHandler.class)'/>
-
- <AccidentelTabUIModel id='model'
- initializer='getContextValue(AccidentelTabUIModel.class)'/>
-
- <SwingValidatorMessageTableModel id='errorTableModel'/>
-
- <BeanValidator id='validator' bean='model' errorTableModel='errorTableModel'
- uiClass='jaxx.runtime.validator.swing.ui.ImageValidationUI'>
- <field name='totalWeight' component='totalWeightField'/>
- <field name='sampleTotalWeight' component='sampleTotalWeightField'/>
- </BeanValidator>
-
- <Table id='form' fill='both' constraints='BorderLayout.NORTH'>
-
- <!-- Poids total -->
- <row>
- <cell anchor='west'>
- <JLabel id='totalWeightLabel'/>
- </cell>
- <cell weightx='1.0'>
- <NumberEditor id='totalWeightField' constructorParams='this'/>
- </cell>
- </row>
-
- <!-- Poids total échantillonné -->
- <row>
- <cell>
- <JLabel id='sampleTotalWeightLabel'/>
- </cell>
- <cell>
- <NumberEditor id='sampleTotalWeightField' constructorParams='this'/>
- </cell>
- </row>
- </Table>
-
- <JScrollPane id='tableScrollPane' constraints='BorderLayout.CENTER'>
- <JTable id='table'/>
- </JScrollPane>
-
-</JPanel>
\ No newline at end of file
Deleted: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/accidental/AccidentelTabUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/accidental/AccidentelTabUIHandler.java 2012-12-12 22:50:50 UTC (rev 54)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/accidental/AccidentelTabUIHandler.java 2012-12-13 01:57:28 UTC (rev 55)
@@ -1,182 +0,0 @@
-package fr.ifremer.tutti.ui.swing.content.operation.accidental;
-
-/*
- * #%L
- * Tutti :: UI
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2012 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.entities.data.AccidentelBatch;
-import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
-import fr.ifremer.tutti.persistence.entities.data.SpeciesBatch;
-import fr.ifremer.tutti.persistence.entities.referential.Species;
-import fr.ifremer.tutti.service.PersistenceService;
-import fr.ifremer.tutti.ui.swing.AbstractTuttiUIHandler;
-import fr.ifremer.tutti.ui.swing.content.operation.FishingOperationsUI;
-import jaxx.runtime.SwingUtil;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import javax.swing.JComboBox;
-import javax.swing.JTable;
-import javax.swing.table.DefaultTableColumnModel;
-import javax.swing.table.TableCellEditor;
-import javax.swing.table.TableCellRenderer;
-import javax.swing.table.TableColumn;
-import javax.swing.table.TableColumnModel;
-import java.beans.PropertyChangeEvent;
-import java.beans.PropertyChangeListener;
-import java.util.List;
-
-import static org.nuiton.i18n.I18n._;
-
-/**
- * @author tchemit <chemit(a)codelutin.com>
- * @since 0.2
- */
-public class AccidentelTabUIHandler extends AbstractTuttiUIHandler<AccidentelTabUIModel> {
-
- /** Logger. */
- private static final Log log = LogFactory.getLog(AccidentelTabUIHandler.class);
-
- private final AccidentelTabUI ui;
-
- private final FishingOperationsUI parentUi;
-
- private final PersistenceService persistenceService;
-
- public AccidentelTabUIHandler(FishingOperationsUI parentUi, AccidentelTabUI ui) {
- super(parentUi.getHandler().getContext());
- this.ui = ui;
- this.parentUi = parentUi;
- this.persistenceService = context.getService(PersistenceService.class);
- }
-
- @Override
- public void beforeInitUI() {
-
- AccidentelTabUIModel model = new AccidentelTabUIModel();
- ui.setContextValue(model);
-
- JTable tb = new JTable();
-
- TableCellEditor defaultEditor = tb.getDefaultEditor(String.class);
- TableCellRenderer defaultRenderer = tb.getDefaultRenderer(Object.class);
-
- // prepare the table column model
- TableColumnModel columnModel = new DefaultTableColumnModel();
-
- TableColumn col;
-
- // species (by code) column
-
- col = new TableColumn(0);
-
- JComboBox speciesEditor = new JComboBox();
- List<Species> allSpecies = persistenceService.getAllSpecies();
- SwingUtil.fillComboBox(speciesEditor, allSpecies, null);
-// col.setCellEditor();
-// col.setCellRenderer(newTableCellRender(Species.class));
- col.setHeaderValue(_("tutti.table.captureAccidentel.header.speciesByCode"));
-// col.setHeaderRenderer(SwingUtil.newStringTableCellRenderer(dRender,50, true));
- col.setIdentifier("speciesByCode");
- columnModel.addColumn(col);
-
- // Poids observé
- col = new TableColumn(1);
- col.setCellEditor(defaultEditor);
- col.setCellRenderer(defaultRenderer);
- col.setHeaderValue(_("tutti.table.captureAccidentel.header.weight"));
-// col.setHeaderRenderer(SwingUtil.newStringTableCellRenderer(dRender,50, true));
- col.setIdentifier("weight");
- columnModel.addColumn(col);
-
- // Nombre observé
- col = new TableColumn(2);
- col.setCellEditor(defaultEditor);
- col.setCellRenderer(defaultRenderer);
- col.setHeaderValue(_("tutti.table.captureAccidentel.header.number"));
-// col.setHeaderRenderer(SwingUtil.newStringTableCellRenderer(dRender,50, true));
- col.setIdentifier("computedNumber");
- columnModel.addColumn(col);
-
- ui.setContextValue(columnModel);
-
- final AccidentelTableModel tableModel = new AccidentelTableModel(columnModel);
- ui.setContextValue(tableModel);
-
- model.addPropertyChangeListener(AccidentelTabUIModel.PROPERTY_CATCHES, new PropertyChangeListener() {
- @Override
- public void propertyChange(PropertyChangeEvent evt) {
- tableModel.setData((List<SpeciesBatch>) evt.getNewValue());
- }
- });
-
- }
-
- @Override
- public void afterInitUI() {
- AccidentelTabUIModel model = ui.getModel();
-
- initUI(ui);
- }
-
- @Override
- public void onCloseUI() {
- }
-
- @Override
- protected AccidentelTabUIModel getModel() {
- return ui.getModel();
- }
-
- public void selectFishingOperation(FishingOperation bean) {
-
- boolean empty = bean == null;
-
- AccidentelTabUIModel model = ui.getModel();
-
- List<AccidentelBatch> catches;
-
- if (empty) {
- catches = null;
- bean = new FishingOperation();
- } else {
- catches = persistenceService.getAllAccidentelBatch(bean.getId());
- }
-
- model.fromBean(bean);
- model.setCatches(catches);
- }
-
- public void cancel() {
-
- if (log.isInfoEnabled()) {
- log.info("Cancel edition");
- }
- }
-
- public void save() {
- if (log.isInfoEnabled()) {
- log.info("Will save");
- }
- }
-}
\ No newline at end of file
Deleted: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/accidental/AccidentelTabUIModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/accidental/AccidentelTabUIModel.java 2012-12-12 22:50:50 UTC (rev 54)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/accidental/AccidentelTabUIModel.java 2012-12-13 01:57:28 UTC (rev 55)
@@ -1,95 +0,0 @@
-package fr.ifremer.tutti.ui.swing.content.operation.accidental;
-
-/*
- * #%L
- * Tutti :: UI
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2012 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.entities.data.AccidentelBatch;
-import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
-import org.jdesktop.beans.AbstractSerializableBean;
-import org.nuiton.util.beans.BinderFactory;
-
-import java.util.List;
-
-/**
- * @author tchemit <chemit(a)codelutin.com>
- * @since 0.2
- */
-public class AccidentelTabUIModel extends AbstractSerializableBean {
-
- private static final long serialVersionUID = 1L;
-
- public static final String PROPERTY_TOTAL_WEIGHT = "totalWeight";
-
- public static final String PROPERTY_SAMPLE_TOTAL_WEIGHT = "sampleTotalWeight";
-
- public static final String PROPERTY_CATCHES = "catches";
-
- protected Float totalWeight;
-
- protected Float sampleTotalWeight;
-
- protected List<AccidentelBatch> catches;
-
- public Float getTotalWeight() {
- return totalWeight;
- }
-
- public void setTotalWeight(Float totalWeight) {
- Object oldValue = getTotalWeight();
- this.totalWeight = totalWeight;
- firePropertyChange(PROPERTY_TOTAL_WEIGHT, oldValue, totalWeight);
- }
-
- public Float getSampleTotalWeight() {
- return sampleTotalWeight;
- }
-
- public void setSampleTotalWeight(Float sampleTotalWeight) {
- Object oldValue = getSampleTotalWeight();
- this.sampleTotalWeight = sampleTotalWeight;
- firePropertyChange(PROPERTY_SAMPLE_TOTAL_WEIGHT, oldValue, sampleTotalWeight);
- }
-
- public List<AccidentelBatch> getCatches() {
- return catches;
- }
-
- public void setCatches(List<AccidentelBatch> catches) {
- Object oldValue = getCatches();
- this.catches = catches;
- firePropertyChange(PROPERTY_CATCHES, oldValue, catches);
- }
-
- public void fromBean(FishingOperation bean) {
- BinderFactory.newBinder(FishingOperation.class,
- AccidentelTabUIModel.class).copy(bean, this);
- }
-
- public FishingOperation toBean() {
- FishingOperation result = new FishingOperation();
- BinderFactory.newBinder(AccidentelTabUIModel.class,
- FishingOperation.class).copy(this, result);
- return result;
- }
-}
\ No newline at end of file
Deleted: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/accidental/AccidentelTableModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/accidental/AccidentelTableModel.java 2012-12-12 22:50:50 UTC (rev 54)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/accidental/AccidentelTableModel.java 2012-12-13 01:57:28 UTC (rev 55)
@@ -1,78 +0,0 @@
-package fr.ifremer.tutti.ui.swing.content.operation.accidental;
-
-/*
- * #%L
- * Tutti :: UI
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2012 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.collect.Lists;
-import fr.ifremer.tutti.persistence.entities.data.SpeciesBatch;
-
-import javax.swing.table.AbstractTableModel;
-import javax.swing.table.TableColumnModel;
-import java.util.List;
-
-/**
- * @author tchemit <chemit(a)codelutin.com>
- * @since 0.2
- */
-public class AccidentelTableModel extends AbstractTableModel {
-
- private static final long serialVersionUID = 1L;
-
- protected List<SpeciesBatch> data;
-
- protected final TableColumnModel columnModel;
-
- public AccidentelTableModel(TableColumnModel columnModel) {
- this.columnModel = columnModel;
- }
-
- public void setData(List<SpeciesBatch> data) {
- if (data == null) {
- data = Lists.newArrayList();
- data.add(new SpeciesBatch());
- }
- this.data = data;
- fireTableDataChanged();
- }
-
- @Override
- public int getRowCount() {
- return data == null ? 0 : data.size();
- }
-
- @Override
- public int getColumnCount() {
- return columnModel.getColumnCount();
- }
-
- @Override
- public Object getValueAt(int rowIndex, int columnIndex) {
- return null;
- }
-
- @Override
- public boolean isCellEditable(int rowIndex, int columnIndex) {
- return true;
- }
-}
\ No newline at end of file
Added: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/benthos/BenthosBatchRowModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/benthos/BenthosBatchRowModel.java (rev 0)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/benthos/BenthosBatchRowModel.java 2012-12-13 01:57:28 UTC (rev 55)
@@ -0,0 +1,173 @@
+package fr.ifremer.tutti.ui.swing.content.operation.benthos;
+
+/*
+ * #%L
+ * Tutti :: UI
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 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.entities.data.BenthosBatch;
+import fr.ifremer.tutti.persistence.entities.referential.Species;
+import fr.ifremer.tutti.ui.swing.AbstractTuttiBeanUIModel;
+import org.nuiton.util.beans.Binder;
+import org.nuiton.util.beans.BinderFactory;
+
+/**
+ * Define a benthos batch row.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 0.2
+ */
+public class BenthosBatchRowModel extends AbstractTuttiBeanUIModel<BenthosBatch, BenthosBatchRowModel> {
+
+ private static final long serialVersionUID = 1L;
+
+ public static final String PROPERTY_SPECIES = "species";
+
+ public static final String PROPERTY_SPECIES_TO_CONFIRM = "speciesToConfirm";
+
+ public static final String PROPERTY_WEIGHT = "weight";
+
+ public static final String PROPERTY_SAMPLE_WEIGHT = "sampleWeight";
+
+ public static final String PROPERTY_SAMPLING_RATIO = "samplingRatio";
+
+ public static final String PROPERTY_COMMENT = "comment";
+
+ /**
+ * Species observed.
+ *
+ * @since 0.2
+ */
+ protected Species species;
+
+ /**
+ * Is the species need to be confirmed?.
+ *
+ * @since 0.2
+ */
+ protected boolean speciesToConfirm;
+
+ /**
+ * Observed weight.
+ *
+ * @since 0.2
+ */
+ protected Float weight;
+
+ /**
+ * Sample weight.
+ *
+ * @since 0.2
+ */
+ protected Float sampleWeight;
+
+ /**
+ * Sampling ratio.
+ *
+ * @since 0.2
+ */
+ protected Float samplingRatio;
+
+ /**
+ * Comment on this catches.
+ *
+ * @since 0.2
+ */
+ protected String comment;
+
+ protected static final Binder<BenthosBatch, BenthosBatchRowModel> fromBeanBinder =
+ BinderFactory.newBinder(BenthosBatch.class,
+ BenthosBatchRowModel.class);
+
+ protected static final Binder<BenthosBatchRowModel, BenthosBatch> toBeanBinder =
+ BinderFactory.newBinder(BenthosBatchRowModel.class,
+ BenthosBatch.class);
+
+ public BenthosBatchRowModel() {
+ super(BenthosBatch.class, fromBeanBinder, toBeanBinder);
+ }
+
+ public BenthosBatchRowModel(BenthosBatch aBatch) {
+ this();
+ fromBean(aBatch);
+ }
+
+ public Species getSpecies() {
+ return species;
+ }
+
+ public void setSpecies(Species species) {
+ Object oldValue = getSpecies();
+ this.species = species;
+ firePropertyChange(PROPERTY_SPECIES, oldValue, species);
+ }
+
+ public Boolean getSpeciesToConfirm() {
+ return speciesToConfirm;
+ }
+
+ public void setSpeciesToConfirm(Boolean speciesToConfirm) {
+ Object oldValue = getSpeciesToConfirm();
+ this.speciesToConfirm = speciesToConfirm;
+ firePropertyChange(PROPERTY_SPECIES_TO_CONFIRM, oldValue, speciesToConfirm);
+ }
+
+ public Float getWeight() {
+ return weight;
+ }
+
+ public void setWeight(Float weight) {
+ Object oldValue = getWeight();
+ this.weight = weight;
+ firePropertyChange(PROPERTY_WEIGHT, oldValue, weight);
+ }
+
+ public Float getSampleWeight() {
+ return sampleWeight;
+ }
+
+ public void setSampleWeight(Float sampleWeight) {
+ Object oldValue = getSampleWeight();
+ this.sampleWeight = sampleWeight;
+ firePropertyChange(PROPERTY_SAMPLE_WEIGHT, oldValue, sampleWeight);
+ }
+
+ public Float getSamplingRatio() {
+ return samplingRatio;
+ }
+
+ public void setSamplingRatio(Float samplingRatio) {
+ Object oldValue = getSamplingRatio();
+ this.samplingRatio = samplingRatio;
+ firePropertyChange(PROPERTY_SAMPLING_RATIO, oldValue, samplingRatio);
+ }
+
+ public String getComment() {
+ return comment;
+ }
+
+ public void setComment(String comment) {
+ Object oldValue = getComment();
+ this.comment = comment;
+ firePropertyChange(PROPERTY_COMMENT, oldValue, comment);
+ }
+}
Property changes on: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/benthos/BenthosBatchRowModel.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Copied: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/benthos/BenthosBatchTableModel.java (from rev 48, trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/benthos/BenthosTableModel.java)
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/benthos/BenthosBatchTableModel.java (rev 0)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/benthos/BenthosBatchTableModel.java 2012-12-13 01:57:28 UTC (rev 55)
@@ -0,0 +1,147 @@
+package fr.ifremer.tutti.ui.swing.content.operation.benthos;
+
+/*
+ * #%L
+ * Tutti :: UI
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 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.util.table.AbstractTuttiTableModel;
+import fr.ifremer.tutti.ui.swing.util.table.ColumnIdentifier;
+
+import javax.swing.table.TableColumnModel;
+import java.util.Set;
+
+import static org.nuiton.i18n.I18n.n_;
+
+/**
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 0.1
+ */
+public class BenthosBatchTableModel extends AbstractTuttiTableModel<BenthosBatchRowModel> {
+
+ private static final long serialVersionUID = 1L;
+
+ public static final ColumnIdentifier<BenthosBatchRowModel> SPECIES_TO_CONFIRM = ColumnIdentifier.newId(
+ BenthosBatchRowModel.PROPERTY_SPECIES_TO_CONFIRM,
+ n_("tutti.table.benthos.batch.header.toConfirm"),
+ n_("tutti.table.benthos.batch.header.toConfirm"));
+
+ public static final ColumnIdentifier<BenthosBatchRowModel> SPECIES_BY_CODE = ColumnIdentifier.newId(
+ BenthosBatchRowModel.PROPERTY_SPECIES,
+ n_("tutti.table.benthos.batch.header.speciesByCode"),
+ n_("tutti.table.benthos.batch.header.speciesByCode"));
+
+ public static final ColumnIdentifier<BenthosBatchRowModel> SPECIES_BY_GENUS_CODE = ColumnIdentifier.newId(
+ BenthosBatchRowModel.PROPERTY_SPECIES,
+ n_("tutti.table.benthos.batch.header.speciesByGenusCode"),
+ n_("tutti.table.benthos.batch.header.speciesByGenusCode"));
+
+ public static final ColumnIdentifier<BenthosBatchRowModel> WEIGHT = ColumnIdentifier.newId(
+ BenthosBatchRowModel.PROPERTY_WEIGHT,
+ n_("tutti.table.benthos.batch.header.weight"),
+ n_("tutti.table.benthos.batch.header.weight"));
+
+ public static final ColumnIdentifier<BenthosBatchRowModel> SAMPLE_WEIGHT = ColumnIdentifier.newId(
+ BenthosBatchRowModel.PROPERTY_SAMPLE_WEIGHT,
+ n_("tutti.table.benthos.batch.header.sampleWeight"),
+ n_("tutti.table.benthos.batch.header.sampleWeight"));
+
+ public static final ColumnIdentifier<BenthosBatchRowModel> SAMPLING_RATIO = ColumnIdentifier.newId(
+ BenthosBatchRowModel.PROPERTY_SAMPLING_RATIO,
+ n_("tutti.table.benthos.batch.header.elevationRate"),
+ n_("tutti.table.benthos.batch.header.elevationRate"));
+
+ public static final ColumnIdentifier<BenthosBatchRowModel> COMMENT = ColumnIdentifier.newId(
+ BenthosBatchRowModel.PROPERTY_COMMENT,
+ n_("tutti.table.benthos.batch.header.comment"),
+ n_("tutti.table.benthos.batch.header.comment"));
+
+ public static final ColumnIdentifier<BenthosBatchRowModel> FILE = ColumnIdentifier.newId(
+ null,
+ n_("tutti.table.benthos.batch.header.file"),
+ n_("tutti.table.benthos.batch.header.file"));
+
+
+ public BenthosBatchTableModel(TableColumnModel columnModel) {
+ super(columnModel);
+
+ setNoneEditableCols(
+ SAMPLE_WEIGHT,
+ SAMPLING_RATIO,
+ FILE
+ );
+ }
+
+ @Override
+ protected BenthosBatchRowModel createNewRow() {
+ BenthosBatchRowModel result = new BenthosBatchRowModel();
+
+ // by default empty row is not valid
+ result.setValid(false);
+ return result;
+ }
+
+ @Override
+ public void setValueAt(Object aValue,
+ int rowIndex,
+ int columnIndex,
+ ColumnIdentifier<BenthosBatchRowModel> propertyName,
+ BenthosBatchRowModel entry) {
+ super.setValueAt(aValue, rowIndex, columnIndex, propertyName, entry);
+
+ if (propertyName == SPECIES_BY_CODE) {
+
+ // update also other columns
+ fireTableCellUpdated(rowIndex,
+ SPECIES_BY_GENUS_CODE);
+
+ } else if (propertyName == SPECIES_BY_GENUS_CODE) {
+
+ // update also other columns
+ fireTableCellUpdated(rowIndex,
+ SPECIES_BY_CODE);
+ }
+ }
+
+ public void updateSamplingRatio(Set<BenthosBatchRowModel> rows) {
+ for (BenthosBatchRowModel row : rows) {
+ int rowIndex = getRows().indexOf(row);
+ fireTableCellUpdated(rowIndex,
+ SAMPLE_WEIGHT,
+ SAMPLING_RATIO);
+ }
+
+
+ }
+
+ @Override
+ protected boolean isCellEditable(int rowIndex,
+ int columnIndex,
+ ColumnIdentifier<BenthosBatchRowModel> propertyName) {
+
+ boolean result = super.isCellEditable(rowIndex,
+ columnIndex,
+ propertyName);
+
+ return result;
+ }
+}
\ No newline at end of file
Property changes on: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/benthos/BenthosBatchTableModel.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Copied: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/benthos/BenthosBatchUI.css (from rev 48, trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/benthos/BenthosTabUI.css)
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/benthos/BenthosBatchUI.css (rev 0)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/benthos/BenthosBatchUI.css 2012-12-13 01:57:28 UTC (rev 55)
@@ -0,0 +1,61 @@
+/*
+ * #%L
+ * Tutti :: UI
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 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%
+ */
+
+NumberEditor {
+ autoPopup: {handler.getConfig().isAutoPopupNumberEditor()};
+ showPopupButton: {handler.getConfig().isShowNumberEditorButton()};
+ bean: {model};
+ showReset: true;
+}
+
+#totalWeightLabel {
+ text: "tutti.label.benthos.totalWeight";
+ labelFor: {totalWeightField};
+}
+
+#totalWeightField {
+ property: "totalWeight";
+ model: {model.getTotalWeight()};
+ useFloat: false;
+ numberPattern: {INT_6_DIGITS_PATTERN};
+}
+
+#sampleTotalWeightLabel {
+ text: "tutti.label.benthos.sampleTotalWeight";
+ labelFor: {totalWeightField};
+}
+
+#sampleTotalWeightField {
+ property: "sampleTotalWeight";
+ model: {model.getSampleTotalWeight()};
+ useFloat: false;
+ numberPattern: {INT_6_DIGITS_PATTERN};
+}
+
+#table {
+ selectionMode: {ListSelectionModel.SINGLE_SELECTION};
+ selectionBackground: {null};
+ selectionForeground: {Color.BLACK};
+ sortable: false;
+}
Property changes on: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/benthos/BenthosBatchUI.css
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Copied: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/benthos/BenthosBatchUI.jaxx (from rev 48, trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/benthos/BenthosTabUI.jaxx)
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/benthos/BenthosBatchUI.jaxx (rev 0)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/benthos/BenthosBatchUI.jaxx 2012-12-13 01:57:28 UTC (rev 55)
@@ -0,0 +1,101 @@
+<!--
+ #%L
+ Tutti :: UI
+ $Id$
+ $HeadURL$
+ %%
+ Copyright (C) 2012 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%
+ -->
+<JPanel id='homePanel' layout='{new BorderLayout()}'
+ implements='fr.ifremer.tutti.ui.swing.TuttiUI<BenthosBatchUIModel, BenthosBatchUIHandler>'>
+
+ <import>
+ fr.ifremer.tutti.persistence.entities.data.FishingOperation
+
+ fr.ifremer.tutti.ui.swing.TuttiUIContext
+ fr.ifremer.tutti.ui.swing.content.operation.FishingOperationsUI
+
+ jaxx.runtime.swing.editor.NumberEditor
+
+ jaxx.runtime.validator.swing.SwingValidatorUtil
+ jaxx.runtime.validator.swing.SwingValidatorMessageTableModel
+
+ org.jdesktop.swingx.JXTable
+
+ javax.swing.ListSelectionModel
+
+ java.awt.Color
+
+ static org.nuiton.i18n.I18n._
+ </import>
+
+ <script><![CDATA[
+
+public BenthosBatchUI(FishingOperationsUI parentUI) {
+ BenthosBatchUIHandler handler = new BenthosBatchUIHandler(parentUI, this);
+ setContextValue(handler);
+ handler.beforeInitUI();
+}
+
+public void selectFishingOperation(FishingOperation fishingOperation) { handler.selectFishingOperation(fishingOperation); }
+
+protected void $afterCompleteSetup() { handler.afterInitUI(); }
+ ]]></script>
+
+ <BenthosBatchUIHandler id='handler'
+ initializer='getContextValue(BenthosBatchUIHandler.class)'/>
+
+ <BenthosBatchUIModel id='model'
+ initializer='getContextValue(BenthosBatchUIModel.class)'/>
+
+ <SwingValidatorMessageTableModel id='errorTableModel'/>
+
+ <BeanValidator id='validator' bean='model' errorTableModel='errorTableModel'
+ uiClass='jaxx.runtime.validator.swing.ui.ImageValidationUI'>
+ <field name='totalWeight' component='totalWeightField'/>
+ <field name='sampleTotalWeight' component='sampleTotalWeightField'/>
+ </BeanValidator>
+
+ <Table id='form' fill='both' constraints='BorderLayout.NORTH'>
+
+ <!-- Poids total -->
+ <row>
+ <cell anchor='west'>
+ <JLabel id='totalWeightLabel'/>
+ </cell>
+ <cell weightx='1.0'>
+ <NumberEditor id='totalWeightField' constructorParams='this'/>
+ </cell>
+ </row>
+
+ <!-- Poids total échantillonné -->
+ <row>
+ <cell>
+ <JLabel id='sampleTotalWeightLabel'/>
+ </cell>
+ <cell>
+ <NumberEditor id='sampleTotalWeightField' constructorParams='this'/>
+ </cell>
+ </row>
+ </Table>
+
+ <JScrollPane id='tableScrollPane' constraints='BorderLayout.CENTER'>
+ <JXTable id='table' onFocusLost='handler.saveSelectedRowIfRequired(event);'/>
+ </JScrollPane>
+
+</JPanel>
Property changes on: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/benthos/BenthosBatchUI.jaxx
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Copied: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/benthos/BenthosBatchUIHandler.java (from rev 48, trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/benthos/BenthosTabUIHandler.java)
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/benthos/BenthosBatchUIHandler.java (rev 0)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/benthos/BenthosBatchUIHandler.java 2012-12-13 01:57:28 UTC (rev 55)
@@ -0,0 +1,496 @@
+package fr.ifremer.tutti.ui.swing.content.operation.benthos;
+
+/*
+ * #%L
+ * Tutti :: UI
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 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.collect.Lists;
+import fr.ifremer.tutti.persistence.entities.TuttiEntities;
+import fr.ifremer.tutti.persistence.entities.data.BenthosBatch;
+import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
+import fr.ifremer.tutti.persistence.entities.referential.Species;
+import fr.ifremer.tutti.service.DecoratorService;
+import fr.ifremer.tutti.service.PersistenceService;
+import fr.ifremer.tutti.ui.swing.TuttiUI;
+import fr.ifremer.tutti.ui.swing.content.operation.FishingOperationsUI;
+import fr.ifremer.tutti.ui.swing.util.TuttiBeanMonitor;
+import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil;
+import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableUIHandler;
+import fr.ifremer.tutti.ui.swing.util.table.TableRowModificationListener;
+import jaxx.runtime.SwingUtil;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.jdesktop.swingx.JXTable;
+import org.jdesktop.swingx.decorator.ComponentAdapter;
+import org.jdesktop.swingx.decorator.HighlightPredicate;
+import org.jdesktop.swingx.decorator.Highlighter;
+import org.jdesktop.swingx.table.DefaultTableColumnModelExt;
+import org.nuiton.util.decorator.Decorator;
+
+import javax.swing.event.ListSelectionListener;
+import javax.swing.table.TableColumnModel;
+import java.awt.Color;
+import java.awt.Component;
+import java.awt.event.FocusEvent;
+import java.util.List;
+
+/**
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 0.1
+ */
+public class BenthosBatchUIHandler extends AbstractTuttiTableUIHandler<BenthosBatchRowModel, BenthosBatchUIModel> {
+
+ /** Logger. */
+ private static final Log log = LogFactory.getLog(BenthosBatchUIHandler.class);
+
+ /**
+ * UI.
+ *
+ * @since 0.2
+ */
+ private final BenthosBatchUI ui;
+
+ /**
+ * Persistence service.
+ *
+ * @since 0.2
+ */
+ private final PersistenceService persistenceService;
+
+ /**
+ * To monitor changes on the fishing operation.
+ *
+ * @since 0.2
+ */
+ private final TuttiBeanMonitor<BenthosBatchUIModel> fishingOperationMonitor;
+
+ public BenthosBatchUIHandler(FishingOperationsUI parentUi, BenthosBatchUI ui) {
+ super(parentUi.getHandler().getContext(),
+ BenthosBatchRowModel.PROPERTY_SPECIES_TO_CONFIRM,
+ BenthosBatchRowModel.PROPERTY_SPECIES,
+ BenthosBatchRowModel.PROPERTY_WEIGHT,
+ BenthosBatchRowModel.PROPERTY_COMMENT);
+ this.ui = ui;
+ this.persistenceService = context.getService(PersistenceService.class);
+ this.fishingOperationMonitor = new TuttiBeanMonitor<BenthosBatchUIModel>(
+ BenthosBatchUIModel.PROPERTY_TOTAL_WEIGHT,
+ BenthosBatchUIModel.PROPERTY_SAMPLE_TOTAL_WEIGHT
+ );
+ }
+
+ //------------------------------------------------------------------------//
+ //-- AbstractTuttiTableUIHandler methods --//
+ //------------------------------------------------------------------------//
+
+ @Override
+ protected BenthosBatchUIModel getModel() {
+ return ui.getModel();
+ }
+
+ @Override
+ protected BenthosBatchTableModel getTableModel() {
+ return (BenthosBatchTableModel) getTable().getModel();
+ }
+
+ @Override
+ protected JXTable getTable() {
+ return ui.getTable();
+ }
+
+ @Override
+ protected String[] getRowPropertiesToIgnore() {
+ return new String[]{
+ BenthosBatchRowModel.PROPERTY_SAMPLE_WEIGHT,
+ BenthosBatchRowModel.PROPERTY_SAMPLING_RATIO
+ };
+ }
+
+ @Override
+ protected TableColumnModel createTableColumnModel() {
+
+ DefaultTableColumnModelExt columnModel =
+ new DefaultTableColumnModelExt();
+
+ {
+ // Species to confirm column
+
+ addBooleanColumnToModel(columnModel,
+ BenthosBatchTableModel.SPECIES_TO_CONFIRM,
+ getTable());
+ }
+
+ List<Species> allSpecies = persistenceService.getAllSpecies();
+
+ {
+ // Species (by code) column
+
+ Decorator<Species> decorator = getDecorator(
+ Species.class, DecoratorService.SPECIES_BY_CODE);
+
+ addComboDataColumnToModel(columnModel,
+ BenthosBatchTableModel.SPECIES_BY_CODE,
+ decorator, allSpecies);
+ }
+
+ {
+ // Species (by genusCode) column
+
+ Decorator<Species> decorator = getDecorator(
+ Species.class, DecoratorService.SPECIES_BY_GENUS);
+
+ addComboDataColumnToModel(columnModel,
+ BenthosBatchTableModel.SPECIES_BY_GENUS_CODE,
+ decorator, allSpecies);
+
+ }
+
+ { // Weight column
+
+ addFloatColumnToModel(columnModel,
+ BenthosBatchTableModel.WEIGHT,
+ TuttiUI.DECIMAL3_PATTERN);
+ }
+
+ { // Sample weight column
+
+ addColumnToModel(columnModel,
+ BenthosBatchTableModel.SAMPLE_WEIGHT);
+ }
+
+ { // SamplingRatio column
+
+ addColumnToModel(columnModel,
+ BenthosBatchTableModel.SAMPLING_RATIO);
+ }
+
+ { // Comment column
+
+ addColumnToModel(columnModel,
+ BenthosBatchTableModel.COMMENT);
+ }
+
+ { // File column
+
+ addColumnToModel(columnModel,
+ BenthosBatchTableModel.FILE);
+ }
+ return columnModel;
+ }
+
+ @Override
+ protected void onRowModified(BenthosBatchRowModel row,
+ String propertyName,
+ Object oldValue,
+ Object newValue) {
+
+ boolean wasValid = row.isValid();
+
+ boolean valid = isRowValid(row);
+
+ if (log.isInfoEnabled()) {
+ log.info("Was valid / Is valid: " + wasValid + " / " + valid);
+ }
+ row.setValid(valid);
+ }
+
+ @Override
+ protected void onRowValidStateChanged(BenthosBatchRowModel row,
+ Boolean oldValue,
+ Boolean newValue) {
+ int rowIndex = getTableModel().getRowIndex(row);
+
+ if (rowIndex > -1) {
+ getTableModel().fireTableRowsUpdated(rowIndex, rowIndex);
+ }
+ }
+
+ @Override
+ protected void onRowModifyStateChanged(BenthosBatchRowModel row,
+ Boolean oldValue,
+ Boolean newValue) {
+ }
+
+ @Override
+ protected void onModelRowsChanged(List<BenthosBatchRowModel> rows) {
+ super.onModelRowsChanged(rows);
+
+ // set valid flag
+ for (BenthosBatchRowModel row : rows) {
+ boolean valid = isRowValid(row);
+ row.setValid(valid);
+ }
+ }
+
+ //------------------------------------------------------------------------//
+ //-- AbstractTuttiUIHandler methods --//
+ //------------------------------------------------------------------------//
+
+ @Override
+ public void beforeInitUI() {
+
+ if (log.isInfoEnabled()) {
+ log.info("beforeInit: " + ui);
+ }
+
+ BenthosBatchUIModel model = new BenthosBatchUIModel();
+ ui.setContextValue(model);
+
+ fishingOperationMonitor.setBean(model);
+ }
+
+ @Override
+ public void afterInitUI() {
+
+ if (log.isInfoEnabled()) {
+ log.info("afterInit: " + ui);
+ }
+
+ initUI(ui);
+
+ JXTable table = getTable();
+
+ // create table column model
+ TableColumnModel columnModel = createTableColumnModel();
+
+ // create table model
+ BenthosBatchTableModel tableModel =
+ new BenthosBatchTableModel(columnModel);
+
+ table.setModel(tableModel);
+ table.setColumnModel(columnModel);
+ installTableKeyListener(columnModel, table);
+
+ table.getTableHeader().setReorderingAllowed(false);
+
+
+ Highlighter readOnlyHighlighter = TuttiUIUtil.newBackgroundColorHighlighter(
+ HighlightPredicate.READ_ONLY, Color.LIGHT_GRAY);
+
+ table.addHighlighter(readOnlyHighlighter);
+ Highlighter validHighlighter = TuttiUIUtil.newBackgroundColorHighlighter(
+ new HighlightPredicate.AndHighlightPredicate(HighlightPredicate.EDITABLE, new HighlightPredicate() {
+ @Override
+ public boolean isHighlighted(Component renderer, ComponentAdapter adapter) {
+
+ boolean result = false;
+ if (adapter.isEditable()) {
+ int rowIndex = adapter.convertRowIndexToModel(adapter.row);
+ BenthosBatchRowModel row = getTableModel().getEntry(rowIndex);
+ result = !row.isValid();
+ }
+ return result;
+ }
+ }), Color.RED);
+ table.addHighlighter(validHighlighter);
+
+ // when model datas change let's propagate it table model
+ listenRowsFromModel();
+
+ // save when row chaged and was modified
+ ListSelectionListener listener = new TableRowModificationListener<BenthosBatchRowModel>(
+ getTableModel(), getRowMonitor()) {
+ @Override
+ protected void saveSelectedRow() {
+ saveSelectedRowIfRequired();
+ }
+ };
+ table.getSelectionModel().addListSelectionListener(listener);
+
+ // always scroll to selected row
+ SwingUtil.scrollToTableSelection(getTable());
+ }
+
+ @Override
+ public void onCloseUI() {
+ if (log.isInfoEnabled()) {
+ log.info("closing: " + ui);
+ }
+ }
+
+ //------------------------------------------------------------------------//
+ //-- Public methods --//
+ //------------------------------------------------------------------------//
+
+ public void saveSelectedRowIfRequired(FocusEvent event) {
+
+ Component oppositeComponent = event.getOppositeComponent();
+
+ JXTable parentContainer = null;
+
+ if (oppositeComponent != null) {
+
+ // check out if still on table
+ parentContainer = SwingUtil.getParentContainer(
+ oppositeComponent, JXTable.class);
+ }
+
+ if (parentContainer == null) {
+
+ // out of the table can save
+ if (getModel().getFishingOperation() != null) {
+ saveSelectedRowIfRequired();
+ }
+ }
+ }
+
+ public void selectFishingOperation(FishingOperation bean) {
+
+ JXTable table = getTable();
+
+ if (table.isEditing()) {
+
+ // make sure to stop editor
+ table.editingCanceled(null);
+ }
+
+ if (fishingOperationMonitor.wasModified()) {
+
+ // previous fishingOperation was modified, let's save it
+ BenthosBatchUIModel beanToSave = fishingOperationMonitor.getBean();
+
+ FishingOperation fishingOperation = beanToSave.toBean();
+
+ if (log.isInfoEnabled()) {
+ log.info("FishingOperation " + fishingOperation.getId() +
+ " was modified, will save it.");
+ }
+
+ persistenceService.saveFishingOperation(fishingOperation);
+ }
+
+ // make sure selection is empty (will remove bean from monitor)
+ table.clearSelection();
+
+ boolean empty = bean == null;
+
+ BenthosBatchUIModel model = getModel();
+
+ List<BenthosBatchRowModel> rows;
+
+ if (empty) {
+ rows = null;
+ bean = new FishingOperation();
+ model.setFishingOperation(null);
+ } else {
+
+ if (log.isInfoEnabled()) {
+ log.info("Get species batch for fishingOperation: " + bean.getId());
+ }
+ rows = Lists.newArrayList();
+
+ if (!TuttiEntities.isNew(bean)) {
+ List<BenthosBatch> catches =
+ persistenceService.getAllBenthosBatch(bean.getId());
+ for (BenthosBatch aBatch : catches) {
+ BenthosBatchRowModel entry =
+ new BenthosBatchRowModel(aBatch);
+ rows.add(entry);
+ }
+ }
+ model.setFishingOperation(bean);
+ }
+
+ model.fromBean(bean);
+ model.setRows(rows);
+
+ fishingOperationMonitor.clearModified();
+ }
+
+ public void cancel() {
+
+ if (log.isInfoEnabled()) {
+ log.info("Cancel edition");
+ }
+ }
+
+ public void save() {
+ if (log.isInfoEnabled()) {
+ log.info("Will save");
+ }
+ }
+
+ //------------------------------------------------------------------------//
+ //-- Internal methods --//
+ //------------------------------------------------------------------------//
+
+ protected boolean isRowValid(BenthosBatchRowModel row) {
+ boolean result = row.getSpecies() != null && row.getWeight() != null;
+ return result;
+ }
+
+ protected void saveSelectedRowIfRequired() {
+
+ TuttiBeanMonitor<BenthosBatchRowModel> rowMonitor = getRowMonitor();
+
+ BenthosBatchRowModel bean = rowMonitor.getBean();
+ if (bean != null) {
+
+ if (bean.isValid()) {
+ // there is a valid bean attached to the monitor
+
+ if (rowMonitor.wasModified()) {
+
+ // monitored bean was modified, save it
+ if (log.isInfoEnabled()) {
+ log.info("Row " + bean + " was modified, will save it");
+ }
+
+ saveRow(bean);
+
+ // clear modified flag on the monitor
+ rowMonitor.clearModified();
+ }
+ } else {
+
+ // row is not valid can not save it
+
+ BenthosBatch catchBean = bean.toBean();
+
+ if (!TuttiEntities.isNew(catchBean)) {
+
+ // remove this
+ persistenceService.deleteBenthosBatch(catchBean.getId());
+ }
+ }
+ }
+ }
+
+ protected void saveRow(BenthosBatchRowModel row) {
+
+ BenthosBatch catchBean = row.toBean();
+
+ FishingOperation fishingOperation = getModel().getFishingOperation();
+ catchBean.setFishingOperation(fishingOperation);
+ if (log.isInfoEnabled()) {
+ log.info("Selected fishingOperation: " + fishingOperation.getId());
+ }
+
+ if (TuttiEntities.isNew(catchBean)) {
+
+ catchBean = persistenceService.createBenthosBatch(catchBean);
+ row.setId(catchBean.getId());
+ } else {
+ persistenceService.saveBenthosBatch(catchBean);
+ }
+ }
+}
\ No newline at end of file
Property changes on: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/benthos/BenthosBatchUIHandler.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Copied: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/benthos/BenthosBatchUIModel.java (from rev 48, trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/benthos/BenthosTabUIModel.java)
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/benthos/BenthosBatchUIModel.java (rev 0)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/benthos/BenthosBatchUIModel.java 2012-12-13 01:57:28 UTC (rev 55)
@@ -0,0 +1,113 @@
+package fr.ifremer.tutti.ui.swing.content.operation.benthos;
+
+/*
+ * #%L
+ * Tutti :: UI
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 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.entities.data.FishingOperation;
+import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableUIModel;
+import org.nuiton.util.beans.Binder;
+import org.nuiton.util.beans.BinderModelBuilder;
+
+/**
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 0.1
+ */
+public class BenthosBatchUIModel extends AbstractTuttiTableUIModel<FishingOperation, BenthosBatchRowModel, BenthosBatchUIModel> {
+
+ private static final long serialVersionUID = 1L;
+
+ public static final String PROPERTY_TOTAL_WEIGHT = "totalWeight";
+
+ public static final String PROPERTY_SAMPLE_TOTAL_WEIGHT = "sampleTotalWeight";
+
+ /**
+ * Editing fishing operation.
+ *
+ * @since 0.2
+ */
+ protected FishingOperation fishingOperation;
+
+ /**
+ * Total Weight filled in screen.
+ *
+ * @since 0.2
+ */
+ protected Float totalWeight;
+
+ /**
+ * Total Sample Weight filled in screen.
+ *
+ * @since 0.2
+ */
+ protected Float sampleTotalWeight;
+
+ protected static final Binder<FishingOperation, BenthosBatchUIModel> fromBeanBinder = BinderModelBuilder.newEmptyBuilder(FishingOperation.class, BenthosBatchUIModel.class)
+ .addProperty(FishingOperation.PROPERTY_BENTHOS_TOTAL_WEIGHT, PROPERTY_TOTAL_WEIGHT)
+ .addProperty(FishingOperation.PROPERTY_BENTHOS_SAMPLE_TOTAL_WEIGHT, PROPERTY_SAMPLE_TOTAL_WEIGHT)
+ .addProperty(FishingOperation.PROPERTY_ID, PROPERTY_ID)
+ .toBinder();
+
+ protected static final Binder<BenthosBatchUIModel, FishingOperation> toBeanBinder = BinderModelBuilder.newEmptyBuilder(BenthosBatchUIModel.class, FishingOperation.class)
+ .addProperty(PROPERTY_TOTAL_WEIGHT, FishingOperation.PROPERTY_BENTHOS_TOTAL_WEIGHT)
+ .addProperty(PROPERTY_SAMPLE_TOTAL_WEIGHT, FishingOperation.PROPERTY_BENTHOS_SAMPLE_TOTAL_WEIGHT)
+ .toBinder();
+
+
+ public BenthosBatchUIModel() {
+ super(FishingOperation.class, fromBeanBinder, toBeanBinder);
+ }
+
+ public FishingOperation getFishingOperation() {
+ return fishingOperation;
+ }
+
+ public void setFishingOperation(FishingOperation fishingOperation) {
+ this.fishingOperation = fishingOperation;
+ }
+
+ public Float getTotalWeight() {
+ return totalWeight;
+ }
+
+ public void setTotalWeight(Float totalWeight) {
+ Object oldValue = getTotalWeight();
+ this.totalWeight = totalWeight;
+ firePropertyChange(PROPERTY_TOTAL_WEIGHT, oldValue, totalWeight);
+ }
+
+ public Float getSampleTotalWeight() {
+ return sampleTotalWeight;
+ }
+
+ public void setSampleTotalWeight(Float sampleTotalWeight) {
+ Object oldValue = getSampleTotalWeight();
+ this.sampleTotalWeight = sampleTotalWeight;
+ firePropertyChange(PROPERTY_SAMPLE_TOTAL_WEIGHT, oldValue, sampleTotalWeight);
+ }
+
+ @Override
+ protected FishingOperation newEntity() {
+ return fishingOperation;
+ }
+}
\ No newline at end of file
Property changes on: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/benthos/BenthosBatchUIModel.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Deleted: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/benthos/BenthosTabUI.css
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/benthos/BenthosTabUI.css 2012-12-12 22:50:50 UTC (rev 54)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/benthos/BenthosTabUI.css 2012-12-13 01:57:28 UTC (rev 55)
@@ -1,59 +0,0 @@
-/*
- * #%L
- * Tutti :: UI
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2012 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%
- */
-
-NumberEditor {
- autoPopup:{handler.getConfig().isAutoPopupNumberEditor()};
- showPopupButton:{handler.getConfig().isShowNumberEditorButton()};
- bean:{model};
- showReset:true;
-}
-
-#totalWeightLabel {
- text:"tutti.label.benthos.totalWeight";
- labelFor:{totalWeightField};
-}
-
-#totalWeightField {
- property:"totalWeight";
- model:{model.getTotalWeight()};
- useFloat:false;
- numberPattern:{INT_6_DIGITS_PATTERN};
-}
-
-#sampleTotalWeightLabel {
- text:"tutti.label.benthos.sampleTotalWeight";
- labelFor:{totalWeightField};
-}
-
-#sampleTotalWeightField {
- property:"sampleTotalWeight";
- model:{model.getSampleTotalWeight()};
- useFloat:false;
- numberPattern:{INT_6_DIGITS_PATTERN};
-}
-
-#table {
- model:{getContextValue(TableModel.class)};
- columnModel:{getContextValue(TableColumnModel.class)};
-}
Deleted: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/benthos/BenthosTabUI.jaxx
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/benthos/BenthosTabUI.jaxx 2012-12-12 22:50:50 UTC (rev 54)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/benthos/BenthosTabUI.jaxx 2012-12-13 01:57:28 UTC (rev 55)
@@ -1,98 +0,0 @@
-<!--
- #%L
- Tutti :: UI
- $Id$
- $HeadURL$
- %%
- Copyright (C) 2012 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%
- -->
-<JPanel id='homePanel' layout='{new BorderLayout()}'
- implements='fr.ifremer.tutti.ui.swing.TuttiUI<BenthosTabUIModel, BenthosTabUIHandler>'>
-
- <import>
- fr.ifremer.tutti.persistence.entities.data.FishingOperation
-
- fr.ifremer.tutti.ui.swing.TuttiUIContext
- fr.ifremer.tutti.ui.swing.content.operation.FishingOperationsUI
-
- jaxx.runtime.swing.editor.NumberEditor
-
- jaxx.runtime.validator.swing.SwingValidatorUtil
- jaxx.runtime.validator.swing.SwingValidatorMessageTableModel
-
- javax.swing.table.TableModel
- javax.swing.table.TableColumnModel
-
- static org.nuiton.i18n.I18n._
- </import>
-
- <script><![CDATA[
-
-public BenthosTabUI(FishingOperationsUI parentUI) {
- BenthosTabUIHandler handler = new BenthosTabUIHandler(parentUI, this);
- setContextValue(handler);
- handler.beforeInitUI();
-}
-
-public void selectFishingOperation(FishingOperation fishingOperation) { handler.selectFishingOperation(fishingOperation); }
-
-protected void $afterCompleteSetup() { handler.afterInitUI(); }
- ]]></script>
-
- <BenthosTabUIHandler id='handler'
- initializer='getContextValue(BenthosTabUIHandler.class)'/>
-
- <BenthosTabUIModel id='model'
- initializer='getContextValue(BenthosTabUIModel.class)'/>
-
- <SwingValidatorMessageTableModel id='errorTableModel'/>
-
- <BeanValidator id='validator' bean='model' errorTableModel='errorTableModel'
- uiClass='jaxx.runtime.validator.swing.ui.ImageValidationUI'>
- <field name='totalWeight' component='totalWeightField'/>
- <field name='sampleTotalWeight' component='sampleTotalWeightField'/>
- </BeanValidator>
-
- <Table id='form' fill='both' constraints='BorderLayout.NORTH'>
-
- <!-- Poids total -->
- <row>
- <cell anchor='west'>
- <JLabel id='totalWeightLabel'/>
- </cell>
- <cell weightx='1.0'>
- <NumberEditor id='totalWeightField' constructorParams='this'/>
- </cell>
- </row>
-
- <!-- Poids total échantillonné -->
- <row>
- <cell>
- <JLabel id='sampleTotalWeightLabel'/>
- </cell>
- <cell>
- <NumberEditor id='sampleTotalWeightField' constructorParams='this'/>
- </cell>
- </row>
- </Table>
-
- <JScrollPane id='tableScrollPane' constraints='BorderLayout.CENTER'>
- <JTable id='table'/>
- </JScrollPane>
-
-</JPanel>
Deleted: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/benthos/BenthosTabUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/benthos/BenthosTabUIHandler.java 2012-12-12 22:50:50 UTC (rev 54)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/benthos/BenthosTabUIHandler.java 2012-12-13 01:57:28 UTC (rev 55)
@@ -1,182 +0,0 @@
-package fr.ifremer.tutti.ui.swing.content.operation.benthos;
-
-/*
- * #%L
- * Tutti :: UI
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2012 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.entities.data.BenthosBatch;
-import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
-import fr.ifremer.tutti.persistence.entities.data.SpeciesBatch;
-import fr.ifremer.tutti.persistence.entities.referential.Species;
-import fr.ifremer.tutti.service.PersistenceService;
-import fr.ifremer.tutti.ui.swing.AbstractTuttiUIHandler;
-import fr.ifremer.tutti.ui.swing.content.operation.FishingOperationsUI;
-import jaxx.runtime.SwingUtil;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import javax.swing.JComboBox;
-import javax.swing.JTable;
-import javax.swing.table.DefaultTableColumnModel;
-import javax.swing.table.TableCellEditor;
-import javax.swing.table.TableCellRenderer;
-import javax.swing.table.TableColumn;
-import javax.swing.table.TableColumnModel;
-import java.beans.PropertyChangeEvent;
-import java.beans.PropertyChangeListener;
-import java.util.List;
-
-import static org.nuiton.i18n.I18n._;
-
-/**
- * @author tchemit <chemit(a)codelutin.com>
- * @since 0.1
- */
-public class BenthosTabUIHandler extends AbstractTuttiUIHandler<BenthosTabUIModel> {
-
- /** Logger. */
- private static final Log log = LogFactory.getLog(BenthosTabUIHandler.class);
-
- private final BenthosTabUI ui;
-
- private final FishingOperationsUI parentUi;
-
- private final PersistenceService persistenceService;
-
- public BenthosTabUIHandler(FishingOperationsUI parentUi, BenthosTabUI ui) {
- super(parentUi.getHandler().getContext());
- this.ui = ui;
- this.parentUi = parentUi;
- this.persistenceService = context.getService(PersistenceService.class);
- }
-
- @Override
- public void beforeInitUI() {
-
- BenthosTabUIModel model = new BenthosTabUIModel();
- ui.setContextValue(model);
-
- JTable tb = new JTable();
-
- TableCellEditor defaultEditor = tb.getDefaultEditor(String.class);
- TableCellRenderer defaultRenderer = tb.getDefaultRenderer(Object.class);
-
- // prepare the table column model
- TableColumnModel columnModel = new DefaultTableColumnModel();
-
- TableColumn col;
-
- // species (by code) column
-
- col = new TableColumn(0);
-
- JComboBox speciesEditor = new JComboBox();
- List<Species> allSpecies = persistenceService.getAllSpecies();
- SwingUtil.fillComboBox(speciesEditor, allSpecies, null);
-// col.setCellEditor();
-// col.setCellRenderer(newTableCellRender(Species.class));
- col.setHeaderValue(_("tutti.table.benthos.header.speciesByCode"));
-// col.setHeaderRenderer(SwingUtil.newStringTableCellRenderer(dRender,50, true));
- col.setIdentifier("speciesByCode");
- columnModel.addColumn(col);
-
- // Poids observé
- col = new TableColumn(1);
- col.setCellEditor(defaultEditor);
- col.setCellRenderer(defaultRenderer);
- col.setHeaderValue(_("tutti.table.benthos.header.weight"));
-// col.setHeaderRenderer(SwingUtil.newStringTableCellRenderer(dRender,50, true));
- col.setIdentifier("weight");
- columnModel.addColumn(col);
-
- // Nombre observé
- col = new TableColumn(2);
- col.setCellEditor(defaultEditor);
- col.setCellRenderer(defaultRenderer);
- col.setHeaderValue(_("tutti.table.benthos.header.number"));
-// col.setHeaderRenderer(SwingUtil.newStringTableCellRenderer(dRender,50, true));
- col.setIdentifier("computedNumber");
- columnModel.addColumn(col);
-
- ui.setContextValue(columnModel);
-
- final BenthosTableModel tableModel = new BenthosTableModel(columnModel);
- ui.setContextValue(tableModel);
-
- model.addPropertyChangeListener(BenthosTabUIModel.PROPERTY_CATCHES, new PropertyChangeListener() {
- @Override
- public void propertyChange(PropertyChangeEvent evt) {
- tableModel.setData((List<SpeciesBatch>) evt.getNewValue());
- }
- });
-
- }
-
- @Override
- public void afterInitUI() {
- BenthosTabUIModel model = ui.getModel();
-
- initUI(ui);
- }
-
- @Override
- public void onCloseUI() {
- }
-
- @Override
- protected BenthosTabUIModel getModel() {
- return ui.getModel();
- }
-
- public void selectFishingOperation(FishingOperation bean) {
-
- boolean empty = bean == null;
-
- BenthosTabUIModel model = ui.getModel();
-
- List<BenthosBatch> catches;
-
- if (empty) {
- catches = null;
- bean = new FishingOperation();
- } else {
- catches = persistenceService.getAllBenthosBatch(bean.getId());
- }
-
- model.fromBean(bean);
- model.setCatches(catches);
- }
-
- public void cancel() {
-
- if (log.isInfoEnabled()) {
- log.info("Cancel edition");
- }
- }
-
- public void save() {
- if (log.isInfoEnabled()) {
- log.info("Will save");
- }
- }
-}
\ No newline at end of file
Deleted: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/benthos/BenthosTabUIModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/benthos/BenthosTabUIModel.java 2012-12-12 22:50:50 UTC (rev 54)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/benthos/BenthosTabUIModel.java 2012-12-13 01:57:28 UTC (rev 55)
@@ -1,95 +0,0 @@
-package fr.ifremer.tutti.ui.swing.content.operation.benthos;
-
-/*
- * #%L
- * Tutti :: UI
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2012 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.entities.data.BenthosBatch;
-import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
-import org.jdesktop.beans.AbstractSerializableBean;
-import org.nuiton.util.beans.BinderFactory;
-
-import java.util.List;
-
-/**
- * @author tchemit <chemit(a)codelutin.com>
- * @since 0.1
- */
-public class BenthosTabUIModel extends AbstractSerializableBean {
-
- private static final long serialVersionUID = 1L;
-
- public static final String PROPERTY_TOTAL_WEIGHT = "totalWeight";
-
- public static final String PROPERTY_SAMPLE_TOTAL_WEIGHT = "sampleTotalWeight";
-
- public static final String PROPERTY_CATCHES = "catches";
-
- protected Float totalWeight;
-
- protected Float sampleTotalWeight;
-
- protected List<BenthosBatch> catches;
-
- public Float getTotalWeight() {
- return totalWeight;
- }
-
- public void setTotalWeight(Float totalWeight) {
- Object oldValue = getTotalWeight();
- this.totalWeight = totalWeight;
- firePropertyChange(PROPERTY_TOTAL_WEIGHT, oldValue, totalWeight);
- }
-
- public Float getSampleTotalWeight() {
- return sampleTotalWeight;
- }
-
- public void setSampleTotalWeight(Float sampleTotalWeight) {
- Object oldValue = getSampleTotalWeight();
- this.sampleTotalWeight = sampleTotalWeight;
- firePropertyChange(PROPERTY_SAMPLE_TOTAL_WEIGHT, oldValue, sampleTotalWeight);
- }
-
- public List<BenthosBatch> getCatches() {
- return catches;
- }
-
- public void setCatches(List<BenthosBatch> catches) {
- Object oldValue = getCatches();
- this.catches = catches;
- firePropertyChange(PROPERTY_CATCHES, oldValue, catches);
- }
-
- public void fromBean(FishingOperation bean) {
- BinderFactory.newBinder(FishingOperation.class,
- BenthosTabUIModel.class).copy(bean, this);
- }
-
- public FishingOperation toBean() {
- FishingOperation result = new FishingOperation();
- BinderFactory.newBinder(BenthosTabUIModel.class,
- FishingOperation.class).copy(this, result);
- return result;
- }
-}
\ No newline at end of file
Deleted: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/benthos/BenthosTableModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/benthos/BenthosTableModel.java 2012-12-12 22:50:50 UTC (rev 54)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/benthos/BenthosTableModel.java 2012-12-13 01:57:28 UTC (rev 55)
@@ -1,78 +0,0 @@
-package fr.ifremer.tutti.ui.swing.content.operation.benthos;
-
-/*
- * #%L
- * Tutti :: UI
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2012 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.collect.Lists;
-import fr.ifremer.tutti.persistence.entities.data.SpeciesBatch;
-
-import javax.swing.table.AbstractTableModel;
-import javax.swing.table.TableColumnModel;
-import java.util.List;
-
-/**
- * @author tchemit <chemit(a)codelutin.com>
- * @since 0.1
- */
-public class BenthosTableModel extends AbstractTableModel {
-
- private static final long serialVersionUID = 1L;
-
- protected List<SpeciesBatch> data;
-
- protected final TableColumnModel columnModel;
-
- public BenthosTableModel(TableColumnModel columnModel) {
- this.columnModel = columnModel;
- }
-
- public void setData(List<SpeciesBatch> data) {
- if (data == null) {
- data = Lists.newArrayList();
- data.add(new SpeciesBatch());
- }
- this.data = data;
- fireTableDataChanged();
- }
-
- @Override
- public int getRowCount() {
- return data == null ? 0 : data.size();
- }
-
- @Override
- public int getColumnCount() {
- return columnModel.getColumnCount();
- }
-
- @Override
- public Object getValueAt(int rowIndex, int columnIndex) {
- return null;
- }
-
- @Override
- public boolean isCellEditable(int rowIndex, int columnIndex) {
- return true;
- }
-}
\ No newline at end of file
Deleted: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/macrowaste/MacroDechetTabUI.css
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/macrowaste/MacroDechetTabUI.css 2012-12-12 22:50:50 UTC (rev 54)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/macrowaste/MacroDechetTabUI.css 2012-12-13 01:57:28 UTC (rev 55)
@@ -1,59 +0,0 @@
-/*
- * #%L
- * Tutti :: UI
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2012 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%
- */
-
-NumberEditor {
- autoPopup:{handler.getConfig().isAutoPopupNumberEditor()};
- showPopupButton:{handler.getConfig().isShowNumberEditorButton()};
- bean:{model};
- showReset:true;
-}
-
-#totalWeightLabel {
- text:"tutti.label.macroDechet.totalWeight";
- labelFor:{totalWeightField};
-}
-
-#totalWeightField {
- property:"totalWeight";
- model:{model.getTotalWeight()};
- useFloat:false;
- numberPattern:{INT_6_DIGITS_PATTERN};
-}
-
-#sampleTotalWeightLabel {
- text:"tutti.label.macroDechet.sampleTotalWeight";
- labelFor:{totalWeightField};
-}
-
-#sampleTotalWeightField {
- property:"sampleTotalWeight";
- model:{model.getSampleTotalWeight()};
- useFloat:false;
- numberPattern:{INT_6_DIGITS_PATTERN};
-}
-
-#table {
- model:{getContextValue(TableModel.class)};
- columnModel:{getContextValue(TableColumnModel.class)};
-}
Deleted: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/macrowaste/MacroDechetTabUI.jaxx
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/macrowaste/MacroDechetTabUI.jaxx 2012-12-12 22:50:50 UTC (rev 54)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/macrowaste/MacroDechetTabUI.jaxx 2012-12-13 01:57:28 UTC (rev 55)
@@ -1,98 +0,0 @@
-<!--
- #%L
- Tutti :: UI
- $Id$
- $HeadURL$
- %%
- Copyright (C) 2012 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%
- -->
-<JPanel id='homePanel' layout='{new BorderLayout()}'
- implements='fr.ifremer.tutti.ui.swing.TuttiUI<MacroDechetTabUIModel, MacroDechetTabUIHandler>'>
-
- <import>
- fr.ifremer.tutti.persistence.entities.data.FishingOperation
-
- fr.ifremer.tutti.ui.swing.TuttiUIContext
- fr.ifremer.tutti.ui.swing.content.operation.FishingOperationsUI
-
- jaxx.runtime.swing.editor.NumberEditor
-
- jaxx.runtime.validator.swing.SwingValidatorUtil
- jaxx.runtime.validator.swing.SwingValidatorMessageTableModel
-
- javax.swing.table.TableModel
- javax.swing.table.TableColumnModel
-
- static org.nuiton.i18n.I18n._
- </import>
-
- <script><![CDATA[
-
-public MacroDechetTabUI(FishingOperationsUI parentUI) {
- MacroDechetTabUIHandler handler = new MacroDechetTabUIHandler(parentUI, this);
- setContextValue(handler);
- handler.beforeInitUI();
-}
-
-public void selectFishingOperation(FishingOperation fishingOperation) { handler.selectFishingOperation(fishingOperation); }
-
-protected void $afterCompleteSetup() { handler.afterInitUI(); }
- ]]></script>
-
- <MacroDechetTabUIHandler id='handler'
- initializer='getContextValue(MacroDechetTabUIHandler.class)'/>
-
- <MacroDechetTabUIModel id='model'
- initializer='getContextValue(MacroDechetTabUIModel.class)'/>
-
- <SwingValidatorMessageTableModel id='errorTableModel'/>
-
- <BeanValidator id='validator' bean='model' errorTableModel='errorTableModel'
- uiClass='jaxx.runtime.validator.swing.ui.ImageValidationUI'>
- <field name='totalWeight' component='totalWeightField'/>
- <field name='sampleTotalWeight' component='sampleTotalWeightField'/>
- </BeanValidator>
-
- <Table id='form' fill='both' constraints='BorderLayout.NORTH'>
-
- <!-- Poids total -->
- <row>
- <cell anchor='west'>
- <JLabel id='totalWeightLabel'/>
- </cell>
- <cell weightx='1.0'>
- <NumberEditor id='totalWeightField' constructorParams='this'/>
- </cell>
- </row>
-
- <!-- Poids total échantillonné -->
- <row>
- <cell>
- <JLabel id='sampleTotalWeightLabel'/>
- </cell>
- <cell>
- <NumberEditor id='sampleTotalWeightField' constructorParams='this'/>
- </cell>
- </row>
- </Table>
-
- <JScrollPane id='tableScrollPane' constraints='BorderLayout.CENTER'>
- <JTable id='table'/>
- </JScrollPane>
-
-</JPanel>
\ No newline at end of file
Deleted: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/macrowaste/MacroDechetTabUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/macrowaste/MacroDechetTabUIHandler.java 2012-12-12 22:50:50 UTC (rev 54)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/macrowaste/MacroDechetTabUIHandler.java 2012-12-13 01:57:28 UTC (rev 55)
@@ -1,182 +0,0 @@
-package fr.ifremer.tutti.ui.swing.content.operation.macrowaste;
-
-/*
- * #%L
- * Tutti :: UI
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2012 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.entities.data.FishingOperation;
-import fr.ifremer.tutti.persistence.entities.data.MacroDechetBatch;
-import fr.ifremer.tutti.persistence.entities.data.SpeciesBatch;
-import fr.ifremer.tutti.persistence.entities.referential.Species;
-import fr.ifremer.tutti.service.PersistenceService;
-import fr.ifremer.tutti.ui.swing.AbstractTuttiUIHandler;
-import fr.ifremer.tutti.ui.swing.content.operation.FishingOperationsUI;
-import jaxx.runtime.SwingUtil;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import javax.swing.JComboBox;
-import javax.swing.JTable;
-import javax.swing.table.DefaultTableColumnModel;
-import javax.swing.table.TableCellEditor;
-import javax.swing.table.TableCellRenderer;
-import javax.swing.table.TableColumn;
-import javax.swing.table.TableColumnModel;
-import java.beans.PropertyChangeEvent;
-import java.beans.PropertyChangeListener;
-import java.util.List;
-
-import static org.nuiton.i18n.I18n._;
-
-/**
- * @author tchemit <chemit(a)codelutin.com>
- * @since 0.2
- */
-public class MacroDechetTabUIHandler extends AbstractTuttiUIHandler<MacroDechetTabUIModel> {
-
- /** Logger. */
- private static final Log log = LogFactory.getLog(MacroDechetTabUIHandler.class);
-
- private final MacroDechetTabUI ui;
-
- private final FishingOperationsUI parentUi;
-
- private final PersistenceService persistenceService;
-
- public MacroDechetTabUIHandler(FishingOperationsUI parentUi, MacroDechetTabUI ui) {
- super(parentUi.getHandler().getContext());
- this.ui = ui;
- this.parentUi = parentUi;
- this.persistenceService = context.getService(PersistenceService.class);
- }
-
- @Override
- public void beforeInitUI() {
-
- MacroDechetTabUIModel model = new MacroDechetTabUIModel();
- ui.setContextValue(model);
-
- JTable tb = new JTable();
-
- TableCellEditor defaultEditor = tb.getDefaultEditor(String.class);
- TableCellRenderer defaultRenderer = tb.getDefaultRenderer(Object.class);
-
- // prepare the table column model
- TableColumnModel columnModel = new DefaultTableColumnModel();
-
- TableColumn col;
-
- // species (by code) column
-
- col = new TableColumn(0);
-
- JComboBox speciesEditor = new JComboBox();
- List<Species> allSpecies = persistenceService.getAllSpecies();
- SwingUtil.fillComboBox(speciesEditor, allSpecies, null);
-// col.setCellEditor();
-// col.setCellRenderer(newTableCellRender(Species.class));
- col.setHeaderValue(_("tutti.table.macroDechet.header.speciesByCode"));
-// col.setHeaderRenderer(SwingUtil.newStringTableCellRenderer(dRender,50, true));
- col.setIdentifier("speciesByCode");
- columnModel.addColumn(col);
-
- // Poids observé
- col = new TableColumn(1);
- col.setCellEditor(defaultEditor);
- col.setCellRenderer(defaultRenderer);
- col.setHeaderValue(_("tutti.table.macroDechet.header.weight"));
-// col.setHeaderRenderer(SwingUtil.newStringTableCellRenderer(dRender,50, true));
- col.setIdentifier("weight");
- columnModel.addColumn(col);
-
- // Nombre observé
- col = new TableColumn(2);
- col.setCellEditor(defaultEditor);
- col.setCellRenderer(defaultRenderer);
- col.setHeaderValue(_("tutti.table.macroDechet.header.number"));
-// col.setHeaderRenderer(SwingUtil.newStringTableCellRenderer(dRender,50, true));
- col.setIdentifier("computedNumber");
- columnModel.addColumn(col);
-
- ui.setContextValue(columnModel);
-
- final MacroDechetTableModel tableModel = new MacroDechetTableModel(columnModel);
- ui.setContextValue(tableModel);
-
- model.addPropertyChangeListener(MacroDechetTabUIModel.PROPERTY_CATCHES, new PropertyChangeListener() {
- @Override
- public void propertyChange(PropertyChangeEvent evt) {
- tableModel.setData((List<SpeciesBatch>) evt.getNewValue());
- }
- });
-
- }
-
- @Override
- public void afterInitUI() {
- MacroDechetTabUIModel model = ui.getModel();
-
- initUI(ui);
- }
-
- @Override
- public void onCloseUI() {
- }
-
- @Override
- protected MacroDechetTabUIModel getModel() {
- return ui.getModel();
- }
-
- public void selectFishingOperation(FishingOperation bean) {
-
- boolean empty = bean == null;
-
- MacroDechetTabUIModel model = ui.getModel();
-
- List<MacroDechetBatch> catches;
-
- if (empty) {
- catches = null;
- bean = new FishingOperation();
- } else {
- catches = persistenceService.getAllMacroDechetBatch(bean.getId());
- }
-
- model.fromBean(bean);
- model.setCatches(catches);
- }
-
- public void cancel() {
-
- if (log.isInfoEnabled()) {
- log.info("Cancel edition");
- }
- }
-
- public void save() {
- if (log.isInfoEnabled()) {
- log.info("Will save");
- }
- }
-}
\ No newline at end of file
Deleted: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/macrowaste/MacroDechetTabUIModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/macrowaste/MacroDechetTabUIModel.java 2012-12-12 22:50:50 UTC (rev 54)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/macrowaste/MacroDechetTabUIModel.java 2012-12-13 01:57:28 UTC (rev 55)
@@ -1,95 +0,0 @@
-package fr.ifremer.tutti.ui.swing.content.operation.macrowaste;
-
-/*
- * #%L
- * Tutti :: UI
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2012 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.entities.data.FishingOperation;
-import fr.ifremer.tutti.persistence.entities.data.MacroDechetBatch;
-import org.jdesktop.beans.AbstractSerializableBean;
-import org.nuiton.util.beans.BinderFactory;
-
-import java.util.List;
-
-/**
- * @author tchemit <chemit(a)codelutin.com>
- * @since 0.2
- */
-public class MacroDechetTabUIModel extends AbstractSerializableBean {
-
- private static final long serialVersionUID = 1L;
-
- public static final String PROPERTY_TOTAL_WEIGHT = "totalWeight";
-
- public static final String PROPERTY_SAMPLE_TOTAL_WEIGHT = "sampleTotalWeight";
-
- public static final String PROPERTY_CATCHES = "catches";
-
- protected Float totalWeight;
-
- protected Float sampleTotalWeight;
-
- protected List<MacroDechetBatch> catches;
-
- public Float getTotalWeight() {
- return totalWeight;
- }
-
- public void setTotalWeight(Float totalWeight) {
- Object oldValue = getTotalWeight();
- this.totalWeight = totalWeight;
- firePropertyChange(PROPERTY_TOTAL_WEIGHT, oldValue, totalWeight);
- }
-
- public Float getSampleTotalWeight() {
- return sampleTotalWeight;
- }
-
- public void setSampleTotalWeight(Float sampleTotalWeight) {
- Object oldValue = getSampleTotalWeight();
- this.sampleTotalWeight = sampleTotalWeight;
- firePropertyChange(PROPERTY_SAMPLE_TOTAL_WEIGHT, oldValue, sampleTotalWeight);
- }
-
- public List<MacroDechetBatch> getCatches() {
- return catches;
- }
-
- public void setCatches(List<MacroDechetBatch> catches) {
- Object oldValue = getCatches();
- this.catches = catches;
- firePropertyChange(PROPERTY_CATCHES, oldValue, catches);
- }
-
- public void fromBean(FishingOperation bean) {
- BinderFactory.newBinder(FishingOperation.class,
- MacroDechetTabUIModel.class).copy(bean, this);
- }
-
- public FishingOperation toBean() {
- FishingOperation result = new FishingOperation();
- BinderFactory.newBinder(MacroDechetTabUIModel.class,
- FishingOperation.class).copy(this, result);
- return result;
- }
-}
\ No newline at end of file
Deleted: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/macrowaste/MacroDechetTableModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/macrowaste/MacroDechetTableModel.java 2012-12-12 22:50:50 UTC (rev 54)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/macrowaste/MacroDechetTableModel.java 2012-12-13 01:57:28 UTC (rev 55)
@@ -1,78 +0,0 @@
-package fr.ifremer.tutti.ui.swing.content.operation.macrowaste;
-
-/*
- * #%L
- * Tutti :: UI
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2012 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.collect.Lists;
-import fr.ifremer.tutti.persistence.entities.data.SpeciesBatch;
-
-import javax.swing.table.AbstractTableModel;
-import javax.swing.table.TableColumnModel;
-import java.util.List;
-
-/**
- * @author tchemit <chemit(a)codelutin.com>
- * @since 0.2
- */
-public class MacroDechetTableModel extends AbstractTableModel {
-
- private static final long serialVersionUID = 1L;
-
- protected List<SpeciesBatch> data;
-
- protected final TableColumnModel columnModel;
-
- public MacroDechetTableModel(TableColumnModel columnModel) {
- this.columnModel = columnModel;
- }
-
- public void setData(List<SpeciesBatch> data) {
- if (data == null) {
- data = Lists.newArrayList();
- data.add(new SpeciesBatch());
- }
- this.data = data;
- fireTableDataChanged();
- }
-
- @Override
- public int getRowCount() {
- return data == null ? 0 : data.size();
- }
-
- @Override
- public int getColumnCount() {
- return columnModel.getColumnCount();
- }
-
- @Override
- public Object getValueAt(int rowIndex, int columnIndex) {
- return null;
- }
-
- @Override
- public boolean isCellEditable(int rowIndex, int columnIndex) {
- return true;
- }
-}
\ No newline at end of file
Added: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/macrowaste/MacroWasteBatchRowModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/macrowaste/MacroWasteBatchRowModel.java (rev 0)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/macrowaste/MacroWasteBatchRowModel.java 2012-12-13 01:57:28 UTC (rev 55)
@@ -0,0 +1,116 @@
+package fr.ifremer.tutti.ui.swing.content.operation.macrowaste;
+
+/*
+ * #%L
+ * Tutti :: UI
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 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.entities.data.MacroWasteBatch;
+import fr.ifremer.tutti.persistence.entities.referential.Species;
+import fr.ifremer.tutti.ui.swing.AbstractTuttiBeanUIModel;
+import org.nuiton.util.beans.Binder;
+import org.nuiton.util.beans.BinderFactory;
+
+/**
+ * Define a benthos batch row.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 0.2
+ */
+public class MacroWasteBatchRowModel extends AbstractTuttiBeanUIModel<MacroWasteBatch, MacroWasteBatchRowModel> {
+
+ private static final long serialVersionUID = 1L;
+
+ public static final String PROPERTY_SPECIES = "species";
+
+ public static final String PROPERTY_WEIGHT = "weight";
+
+ public static final String PROPERTY_COMMENT = "comment";
+
+ /**
+ * Species observed.
+ *
+ * @since 0.2
+ */
+ protected Species species;
+
+ /**
+ * Observed weight.
+ *
+ * @since 0.2
+ */
+ protected Float weight;
+
+ /**
+ * Comment on this catches.
+ *
+ * @since 0.2
+ */
+ protected String comment;
+
+ protected static final Binder<MacroWasteBatch, MacroWasteBatchRowModel> fromBeanBinder =
+ BinderFactory.newBinder(MacroWasteBatch.class,
+ MacroWasteBatchRowModel.class);
+
+ protected static final Binder<MacroWasteBatchRowModel, MacroWasteBatch> toBeanBinder =
+ BinderFactory.newBinder(MacroWasteBatchRowModel.class,
+ MacroWasteBatch.class);
+
+ public MacroWasteBatchRowModel() {
+ super(MacroWasteBatch.class, fromBeanBinder, toBeanBinder);
+ }
+
+ public MacroWasteBatchRowModel(MacroWasteBatch aBatch) {
+ this();
+ fromBean(aBatch);
+ }
+
+ public Species getSpecies() {
+ return species;
+ }
+
+ public void setSpecies(Species species) {
+ Object oldValue = getSpecies();
+ this.species = species;
+ firePropertyChange(PROPERTY_SPECIES, oldValue, species);
+ }
+
+ public Float getWeight() {
+ return weight;
+ }
+
+ public void setWeight(Float weight) {
+ Object oldValue = getWeight();
+ this.weight = weight;
+ firePropertyChange(PROPERTY_WEIGHT, oldValue, weight);
+ }
+
+ public String getComment() {
+ return comment;
+ }
+
+ public void setComment(String comment) {
+ Object oldValue = getComment();
+ this.comment = comment;
+ firePropertyChange(PROPERTY_COMMENT, oldValue, comment);
+ }
+}
Property changes on: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/macrowaste/MacroWasteBatchRowModel.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Copied: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/macrowaste/MacroWasteBatchTableModel.java (from rev 48, trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/macrowaste/MacroDechetTableModel.java)
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/macrowaste/MacroWasteBatchTableModel.java (rev 0)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/macrowaste/MacroWasteBatchTableModel.java 2012-12-13 01:57:28 UTC (rev 55)
@@ -0,0 +1,104 @@
+package fr.ifremer.tutti.ui.swing.content.operation.macrowaste;
+
+/*
+ * #%L
+ * Tutti :: UI
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 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.util.table.AbstractTuttiTableModel;
+import fr.ifremer.tutti.ui.swing.util.table.ColumnIdentifier;
+
+import javax.swing.table.TableColumnModel;
+
+import static org.nuiton.i18n.I18n.n_;
+
+/**
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 0.2
+ */
+public class MacroWasteBatchTableModel extends AbstractTuttiTableModel<MacroWasteBatchRowModel> {
+
+ private static final long serialVersionUID = 1L;
+
+ public static final ColumnIdentifier<MacroWasteBatchRowModel> SPECIES_BY_CODE = ColumnIdentifier.newId(
+ MacroWasteBatchRowModel.PROPERTY_SPECIES,
+ n_("tutti.table.macrowaste.batch.header.speciesByCode"),
+ n_("tutti.table.macrowaste.batch.header.speciesByCode"));
+
+ public static final ColumnIdentifier<MacroWasteBatchRowModel> SPECIES_BY_GENUS_CODE = ColumnIdentifier.newId(
+ MacroWasteBatchRowModel.PROPERTY_SPECIES,
+ n_("tutti.table.macrowaste.batch.header.speciesByGenusCode"),
+ n_("tutti.table.macrowaste.batch.header.speciesByGenusCode"));
+
+ public static final ColumnIdentifier<MacroWasteBatchRowModel> WEIGHT = ColumnIdentifier.newId(
+ MacroWasteBatchRowModel.PROPERTY_WEIGHT,
+ n_("tutti.table.macrowaste.batch.header.weight"),
+ n_("tutti.table.macrowaste.batch.header.weight"));
+
+ public static final ColumnIdentifier<MacroWasteBatchRowModel> COMMENT = ColumnIdentifier.newId(
+ MacroWasteBatchRowModel.PROPERTY_COMMENT,
+ n_("tutti.table.macrowaste.batch.header.comment"),
+ n_("tutti.table.macrowaste.batch.header.comment"));
+
+ public static final ColumnIdentifier<MacroWasteBatchRowModel> FILE = ColumnIdentifier.newId(
+ null,
+ n_("tutti.table.macrowaste.batch.header.file"),
+ n_("tutti.table.macrowaste.batch.header.file"));
+
+
+ public MacroWasteBatchTableModel(TableColumnModel columnModel) {
+ super(columnModel);
+
+ setNoneEditableCols(FILE);
+ }
+
+ @Override
+ protected MacroWasteBatchRowModel createNewRow() {
+ MacroWasteBatchRowModel result = new MacroWasteBatchRowModel();
+
+ // by default empty row is not valid
+ result.setValid(false);
+ return result;
+ }
+
+ @Override
+ public void setValueAt(Object aValue,
+ int rowIndex,
+ int columnIndex,
+ ColumnIdentifier<MacroWasteBatchRowModel> propertyName,
+ MacroWasteBatchRowModel entry) {
+ super.setValueAt(aValue, rowIndex, columnIndex, propertyName, entry);
+
+ if (propertyName == SPECIES_BY_CODE) {
+
+ // update also other columns
+ fireTableCellUpdated(rowIndex,
+ SPECIES_BY_GENUS_CODE);
+
+ } else if (propertyName == SPECIES_BY_GENUS_CODE) {
+
+ // update also other columns
+ fireTableCellUpdated(rowIndex,
+ SPECIES_BY_CODE);
+ }
+ }
+}
\ No newline at end of file
Property changes on: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/macrowaste/MacroWasteBatchTableModel.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Copied: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/macrowaste/MacroWasteBatchUI.css (from rev 48, trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/macrowaste/MacroDechetTabUI.css)
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/macrowaste/MacroWasteBatchUI.css (rev 0)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/macrowaste/MacroWasteBatchUI.css 2012-12-13 01:57:28 UTC (rev 55)
@@ -0,0 +1,49 @@
+/*
+ * #%L
+ * Tutti :: UI
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 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%
+ */
+
+NumberEditor {
+ autoPopup: {handler.getConfig().isAutoPopupNumberEditor()};
+ showPopupButton: {handler.getConfig().isShowNumberEditorButton()};
+ bean: {model};
+ showReset: true;
+}
+
+#totalWeightLabel {
+ text: "tutti.label.macroWaste.totalWeight";
+ labelFor: {totalWeightField};
+}
+
+#totalWeightField {
+ property: "totalWeight";
+ model: {model.getTotalWeight()};
+ useFloat: false;
+ numberPattern: {INT_6_DIGITS_PATTERN};
+}
+
+#table {
+ selectionMode: {ListSelectionModel.SINGLE_SELECTION};
+ selectionBackground: {null};
+ selectionForeground: {Color.BLACK};
+ sortable: false;
+}
Property changes on: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/macrowaste/MacroWasteBatchUI.css
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Copied: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/macrowaste/MacroWasteBatchUI.jaxx (from rev 48, trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/macrowaste/MacroDechetTabUI.jaxx)
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/macrowaste/MacroWasteBatchUI.jaxx (rev 0)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/macrowaste/MacroWasteBatchUI.jaxx 2012-12-13 01:57:28 UTC (rev 55)
@@ -0,0 +1,90 @@
+<!--
+ #%L
+ Tutti :: UI
+ $Id$
+ $HeadURL$
+ %%
+ Copyright (C) 2012 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%
+ -->
+<JPanel id='homePanel' layout='{new BorderLayout()}'
+ implements='fr.ifremer.tutti.ui.swing.TuttiUI<MacroWasteBatchUIModel, MacroWasteBatchUIHandler>'>
+
+ <import>
+ fr.ifremer.tutti.persistence.entities.data.FishingOperation
+
+ fr.ifremer.tutti.ui.swing.TuttiUIContext
+ fr.ifremer.tutti.ui.swing.content.operation.FishingOperationsUI
+
+ jaxx.runtime.swing.editor.NumberEditor
+
+ jaxx.runtime.validator.swing.SwingValidatorUtil
+ jaxx.runtime.validator.swing.SwingValidatorMessageTableModel
+
+ org.jdesktop.swingx.JXTable
+
+ javax.swing.ListSelectionModel
+
+ java.awt.Color
+
+ static org.nuiton.i18n.I18n._
+ </import>
+
+ <script><![CDATA[
+
+public MacroWasteBatchUI(FishingOperationsUI parentUI) {
+ MacroWasteBatchUIHandler handler = new MacroWasteBatchUIHandler(parentUI, this);
+ setContextValue(handler);
+ handler.beforeInitUI();
+}
+
+public void selectFishingOperation(FishingOperation fishingOperation) { handler.selectFishingOperation(fishingOperation); }
+
+protected void $afterCompleteSetup() { handler.afterInitUI(); }
+ ]]></script>
+
+ <MacroWasteBatchUIHandler id='handler'
+ initializer='getContextValue(MacroWasteBatchUIHandler.class)'/>
+
+ <MacroWasteBatchUIModel id='model'
+ initializer='getContextValue(MacroWasteBatchUIModel.class)'/>
+
+ <SwingValidatorMessageTableModel id='errorTableModel'/>
+
+ <BeanValidator id='validator' bean='model' errorTableModel='errorTableModel'
+ uiClass='jaxx.runtime.validator.swing.ui.ImageValidationUI'>
+ <field name='totalWeight' component='totalWeightField'/>
+ </BeanValidator>
+
+ <Table id='form' fill='both' constraints='BorderLayout.NORTH'>
+
+ <!-- Poids total -->
+ <row>
+ <cell anchor='west'>
+ <JLabel id='totalWeightLabel'/>
+ </cell>
+ <cell weightx='1.0'>
+ <NumberEditor id='totalWeightField' constructorParams='this'/>
+ </cell>
+ </row>
+ </Table>
+
+ <JScrollPane id='tableScrollPane' constraints='BorderLayout.CENTER'>
+ <JXTable id='table' onFocusLost='handler.saveSelectedRowIfRequired(event);'/>
+ </JScrollPane>
+
+</JPanel>
\ No newline at end of file
Property changes on: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/macrowaste/MacroWasteBatchUI.jaxx
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Copied: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/macrowaste/MacroWasteBatchUIHandler.java (from rev 48, trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/macrowaste/MacroDechetTabUIHandler.java)
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/macrowaste/MacroWasteBatchUIHandler.java (rev 0)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/macrowaste/MacroWasteBatchUIHandler.java 2012-12-13 01:57:28 UTC (rev 55)
@@ -0,0 +1,467 @@
+package fr.ifremer.tutti.ui.swing.content.operation.macrowaste;
+
+/*
+ * #%L
+ * Tutti :: UI
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 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.collect.Lists;
+import fr.ifremer.tutti.persistence.entities.TuttiEntities;
+import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
+import fr.ifremer.tutti.persistence.entities.data.MacroWasteBatch;
+import fr.ifremer.tutti.persistence.entities.referential.Species;
+import fr.ifremer.tutti.service.DecoratorService;
+import fr.ifremer.tutti.service.PersistenceService;
+import fr.ifremer.tutti.ui.swing.TuttiUI;
+import fr.ifremer.tutti.ui.swing.content.operation.FishingOperationsUI;
+import fr.ifremer.tutti.ui.swing.util.TuttiBeanMonitor;
+import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil;
+import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableUIHandler;
+import fr.ifremer.tutti.ui.swing.util.table.TableRowModificationListener;
+import jaxx.runtime.SwingUtil;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.jdesktop.swingx.JXTable;
+import org.jdesktop.swingx.decorator.ComponentAdapter;
+import org.jdesktop.swingx.decorator.HighlightPredicate;
+import org.jdesktop.swingx.decorator.Highlighter;
+import org.jdesktop.swingx.table.DefaultTableColumnModelExt;
+import org.nuiton.util.decorator.Decorator;
+
+import javax.swing.event.ListSelectionListener;
+import javax.swing.table.TableColumnModel;
+import java.awt.Color;
+import java.awt.Component;
+import java.awt.event.FocusEvent;
+import java.util.List;
+
+/**
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 0.2
+ */
+public class MacroWasteBatchUIHandler extends AbstractTuttiTableUIHandler<MacroWasteBatchRowModel, MacroWasteBatchUIModel> {
+
+ /** Logger. */
+ private static final Log log = LogFactory.getLog(MacroWasteBatchUIHandler.class);
+
+ /**
+ * UI.
+ *
+ * @since 0.2
+ */
+ private final MacroWasteBatchUI ui;
+
+ /**
+ * Persistence service.
+ *
+ * @since 0.2
+ */
+ private final PersistenceService persistenceService;
+
+ /**
+ * To monitor changes on the fishing operation.
+ *
+ * @since 0.2
+ */
+ private final TuttiBeanMonitor<MacroWasteBatchUIModel> fishingOperationMonitor;
+
+
+ public MacroWasteBatchUIHandler(FishingOperationsUI parentUi, MacroWasteBatchUI ui) {
+ super(parentUi.getHandler().getContext(),
+ MacroWasteBatchRowModel.PROPERTY_SPECIES,
+ MacroWasteBatchRowModel.PROPERTY_WEIGHT,
+ MacroWasteBatchRowModel.PROPERTY_COMMENT);
+ this.ui = ui;
+ this.persistenceService = context.getService(PersistenceService.class);
+ this.fishingOperationMonitor = new TuttiBeanMonitor<MacroWasteBatchUIModel>(
+ MacroWasteBatchUIModel.PROPERTY_TOTAL_WEIGHT
+ );
+ }
+
+ //------------------------------------------------------------------------//
+ //-- AbstractTuttiTableUIHandler methods --//
+ //------------------------------------------------------------------------//
+
+ @Override
+ protected MacroWasteBatchUIModel getModel() {
+ return ui.getModel();
+ }
+
+ @Override
+ protected MacroWasteBatchTableModel getTableModel() {
+ return (MacroWasteBatchTableModel) getTable().getModel();
+ }
+
+ @Override
+ protected JXTable getTable() {
+ return ui.getTable();
+ }
+
+ @Override
+ protected TableColumnModel createTableColumnModel() {
+
+ DefaultTableColumnModelExt columnModel =
+ new DefaultTableColumnModelExt();
+
+ List<Species> allSpecies = persistenceService.getAllSpecies();
+
+ {
+ // Species (by code) column
+
+ Decorator<Species> decorator = getDecorator(
+ Species.class, DecoratorService.SPECIES_BY_CODE);
+
+ addComboDataColumnToModel(columnModel,
+ MacroWasteBatchTableModel.SPECIES_BY_CODE,
+ decorator, allSpecies);
+ }
+
+ {
+ // Species (by genusCode) column
+
+ Decorator<Species> decorator = getDecorator(
+ Species.class, DecoratorService.SPECIES_BY_GENUS);
+
+ addComboDataColumnToModel(columnModel,
+ MacroWasteBatchTableModel.SPECIES_BY_GENUS_CODE,
+ decorator, allSpecies);
+
+ }
+
+ { // Weight column
+
+ addFloatColumnToModel(columnModel,
+ MacroWasteBatchTableModel.WEIGHT,
+ TuttiUI.DECIMAL3_PATTERN);
+ }
+
+ { // Comment column
+
+ addColumnToModel(columnModel,
+ MacroWasteBatchTableModel.COMMENT);
+ }
+
+ { // File column
+
+ addColumnToModel(columnModel,
+ MacroWasteBatchTableModel.FILE);
+ }
+ return columnModel;
+ }
+
+ @Override
+ protected void onRowModified(MacroWasteBatchRowModel row,
+ String propertyName,
+ Object oldValue,
+ Object newValue) {
+
+ boolean wasValid = row.isValid();
+
+ boolean valid = isRowValid(row);
+
+ if (log.isInfoEnabled()) {
+ log.info("Was valid / Is valid: " + wasValid + " / " + valid);
+ }
+ row.setValid(valid);
+ }
+
+ @Override
+ protected void onRowValidStateChanged(MacroWasteBatchRowModel row,
+ Boolean oldValue,
+ Boolean newValue) {
+ int rowIndex = getTableModel().getRowIndex(row);
+
+ if (rowIndex > -1) {
+ getTableModel().fireTableRowsUpdated(rowIndex, rowIndex);
+ }
+ }
+
+ @Override
+ protected void onRowModifyStateChanged(MacroWasteBatchRowModel row,
+ Boolean oldValue,
+ Boolean newValue) {
+ }
+
+ @Override
+ protected void onModelRowsChanged(List<MacroWasteBatchRowModel> rows) {
+ super.onModelRowsChanged(rows);
+
+ // set valid flag
+ for (MacroWasteBatchRowModel row : rows) {
+ boolean valid = isRowValid(row);
+ row.setValid(valid);
+ }
+ }
+
+ //------------------------------------------------------------------------//
+ //-- AbstractTuttiUIHandler methods --//
+ //------------------------------------------------------------------------//
+
+ @Override
+ public void beforeInitUI() {
+
+ if (log.isInfoEnabled()) {
+ log.info("beforeInit: " + ui);
+ }
+
+ MacroWasteBatchUIModel model = new MacroWasteBatchUIModel();
+ ui.setContextValue(model);
+
+ fishingOperationMonitor.setBean(model);
+ }
+
+ @Override
+ public void afterInitUI() {
+
+ if (log.isInfoEnabled()) {
+ log.info("afterInit: " + ui);
+ }
+
+ initUI(ui);
+
+ JXTable table = getTable();
+
+ // create table column model
+ TableColumnModel columnModel = createTableColumnModel();
+
+ // create table model
+ MacroWasteBatchTableModel tableModel =
+ new MacroWasteBatchTableModel(columnModel);
+
+ table.setModel(tableModel);
+ table.setColumnModel(columnModel);
+ installTableKeyListener(columnModel, table);
+
+ table.getTableHeader().setReorderingAllowed(false);
+
+
+ Highlighter readOnlyHighlighter = TuttiUIUtil.newBackgroundColorHighlighter(
+ HighlightPredicate.READ_ONLY, Color.LIGHT_GRAY);
+
+ table.addHighlighter(readOnlyHighlighter);
+ Highlighter validHighlighter = TuttiUIUtil.newBackgroundColorHighlighter(
+ new HighlightPredicate.AndHighlightPredicate(HighlightPredicate.EDITABLE, new HighlightPredicate() {
+ @Override
+ public boolean isHighlighted(Component renderer, ComponentAdapter adapter) {
+
+ boolean result = false;
+ if (adapter.isEditable()) {
+ int rowIndex = adapter.convertRowIndexToModel(adapter.row);
+ MacroWasteBatchRowModel row = getTableModel().getEntry(rowIndex);
+ result = !row.isValid();
+ }
+ return result;
+ }
+ }), Color.RED);
+ table.addHighlighter(validHighlighter);
+
+ // when model datas change let's propagate it table model
+ listenRowsFromModel();
+
+ // save when row chaged and was modified
+ ListSelectionListener listener = new TableRowModificationListener<MacroWasteBatchRowModel>(
+ getTableModel(), getRowMonitor()) {
+ @Override
+ protected void saveSelectedRow() {
+ saveSelectedRowIfRequired();
+ }
+ };
+ table.getSelectionModel().addListSelectionListener(listener);
+
+ // always scroll to selected row
+ SwingUtil.scrollToTableSelection(getTable());
+ }
+
+ @Override
+ public void onCloseUI() {
+ if (log.isInfoEnabled()) {
+ log.info("closing: " + ui);
+ }
+ }
+
+ //------------------------------------------------------------------------//
+ //-- Public methods --//
+ //------------------------------------------------------------------------//
+
+ public void saveSelectedRowIfRequired(FocusEvent event) {
+
+ Component oppositeComponent = event.getOppositeComponent();
+
+ JXTable parentContainer = null;
+
+ if (oppositeComponent != null) {
+
+ // check out if still on table
+ parentContainer = SwingUtil.getParentContainer(
+ oppositeComponent, JXTable.class);
+ }
+
+ if (parentContainer == null) {
+
+ // out of the table can save
+ if (getModel().getFishingOperation() != null) {
+ saveSelectedRowIfRequired();
+ }
+ }
+ }
+
+ public void selectFishingOperation(FishingOperation bean) {
+
+ JXTable table = getTable();
+
+ if (table.isEditing()) {
+
+ // make sure to stop editor
+ table.editingCanceled(null);
+ }
+
+ if (fishingOperationMonitor.wasModified()) {
+
+ // previous fishingOperation was modified, let's save it
+ MacroWasteBatchUIModel beanToSave = fishingOperationMonitor.getBean();
+
+ FishingOperation fishingOperation = beanToSave.toBean();
+
+ if (log.isInfoEnabled()) {
+ log.info("FishingOperation " + fishingOperation.getId() +
+ " was modified, will save it.");
+ }
+
+ persistenceService.saveFishingOperation(fishingOperation);
+ }
+
+ // make sure selection is empty (will remove bean from monitor)
+ table.clearSelection();
+
+ boolean empty = bean == null;
+
+ MacroWasteBatchUIModel model = getModel();
+
+ List<MacroWasteBatchRowModel> rows;
+
+ if (empty) {
+ rows = null;
+ bean = new FishingOperation();
+ model.setFishingOperation(null);
+ } else {
+
+ if (log.isInfoEnabled()) {
+ log.info("Get species batch for fishingOperation: " + bean.getId());
+ }
+ rows = Lists.newArrayList();
+
+ if (!TuttiEntities.isNew(bean)) {
+ List<MacroWasteBatch> catches =
+ persistenceService.getAllMacroWasteBatch(bean.getId());
+ for (MacroWasteBatch aBatch : catches) {
+ MacroWasteBatchRowModel entry =
+ new MacroWasteBatchRowModel(aBatch);
+ rows.add(entry);
+ }
+ }
+ model.setFishingOperation(bean);
+ }
+
+ model.fromBean(bean);
+ model.setRows(rows);
+
+ fishingOperationMonitor.clearModified();
+ }
+
+ public void cancel() {
+
+ if (log.isInfoEnabled()) {
+ log.info("Cancel edition");
+ }
+ }
+
+ public void save() {
+ if (log.isInfoEnabled()) {
+ log.info("Will save");
+ }
+ }
+
+ //------------------------------------------------------------------------//
+ //-- Internal methods --//
+ //------------------------------------------------------------------------//
+
+ protected boolean isRowValid(MacroWasteBatchRowModel row) {
+ boolean result = row.getSpecies() != null && row.getWeight() != null;
+ return result;
+ }
+
+ protected void saveSelectedRowIfRequired() {
+
+ TuttiBeanMonitor<MacroWasteBatchRowModel> rowMonitor = getRowMonitor();
+
+ MacroWasteBatchRowModel bean = rowMonitor.getBean();
+ if (bean != null) {
+
+ if (bean.isValid()) {
+ // there is a valid bean attached to the monitor
+
+ if (rowMonitor.wasModified()) {
+
+ // monitored bean was modified, save it
+ if (log.isInfoEnabled()) {
+ log.info("Row " + bean + " was modified, will save it");
+ }
+
+ saveRow(bean);
+
+ // clear modified flag on the monitor
+ rowMonitor.clearModified();
+ }
+ } else {
+
+ // row is not valid can not save it
+
+ MacroWasteBatch catchBean = bean.toBean();
+
+ if (!TuttiEntities.isNew(catchBean)) {
+
+ // remove this
+ persistenceService.deleteMacroWasteBatch(catchBean.getId());
+ }
+ }
+ }
+ }
+
+ protected void saveRow(MacroWasteBatchRowModel row) {
+
+ MacroWasteBatch catchBean = row.toBean();
+
+ FishingOperation fishingOperation = getModel().getFishingOperation();
+ catchBean.setFishingOperation(fishingOperation);
+ if (log.isInfoEnabled()) {
+ log.info("Selected fishingOperation: " + fishingOperation.getId());
+ }
+
+ if (TuttiEntities.isNew(catchBean)) {
+
+ catchBean = persistenceService.createMacroWasteBatch(catchBean);
+ row.setId(catchBean.getId());
+ } else {
+ persistenceService.saveMacroWasteBatch(catchBean);
+ }
+ }
+}
\ No newline at end of file
Property changes on: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/macrowaste/MacroWasteBatchUIHandler.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Copied: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/macrowaste/MacroWasteBatchUIModel.java (from rev 48, trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/macrowaste/MacroDechetTabUIModel.java)
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/macrowaste/MacroWasteBatchUIModel.java (rev 0)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/macrowaste/MacroWasteBatchUIModel.java 2012-12-13 01:57:28 UTC (rev 55)
@@ -0,0 +1,94 @@
+package fr.ifremer.tutti.ui.swing.content.operation.macrowaste;
+
+/*
+ * #%L
+ * Tutti :: UI
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 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.entities.data.FishingOperation;
+import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableUIModel;
+import org.nuiton.util.beans.Binder;
+import org.nuiton.util.beans.BinderModelBuilder;
+
+/**
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 0.2
+ */
+public class MacroWasteBatchUIModel extends AbstractTuttiTableUIModel<FishingOperation, MacroWasteBatchRowModel, MacroWasteBatchUIModel> {
+
+ private static final long serialVersionUID = 1L;
+
+ public static final String PROPERTY_TOTAL_WEIGHT = "totalWeight";
+
+ /**
+ * Editing fishing operation.
+ *
+ * @since 0.2
+ */
+ protected FishingOperation fishingOperation;
+
+ /**
+ * Total Weight filled in screen.
+ *
+ * @since 0.2
+ */
+ protected Float totalWeight;
+
+
+ protected static final Binder<FishingOperation, MacroWasteBatchUIModel> fromBeanBinder = BinderModelBuilder.newEmptyBuilder(FishingOperation.class, MacroWasteBatchUIModel.class)
+ .addProperty(FishingOperation.PROPERTY_MACRO_WASTE_TOTAL_WEIGHT, PROPERTY_TOTAL_WEIGHT)
+ .addProperty(FishingOperation.PROPERTY_ID, PROPERTY_ID)
+ .toBinder();
+
+ protected static final Binder<MacroWasteBatchUIModel, FishingOperation> toBeanBinder = BinderModelBuilder.newEmptyBuilder(MacroWasteBatchUIModel.class, FishingOperation.class)
+ .addProperty(PROPERTY_TOTAL_WEIGHT, FishingOperation.PROPERTY_MACRO_WASTE_TOTAL_WEIGHT)
+ .toBinder();
+
+
+ public MacroWasteBatchUIModel() {
+ super(FishingOperation.class, fromBeanBinder, toBeanBinder);
+ }
+
+ public FishingOperation getFishingOperation() {
+ return fishingOperation;
+ }
+
+ public void setFishingOperation(FishingOperation fishingOperation) {
+ this.fishingOperation = fishingOperation;
+ }
+
+
+ public Float getTotalWeight() {
+ return totalWeight;
+ }
+
+ public void setTotalWeight(Float totalWeight) {
+ Object oldValue = getTotalWeight();
+ this.totalWeight = totalWeight;
+ firePropertyChange(PROPERTY_TOTAL_WEIGHT, oldValue, totalWeight);
+ }
+
+ @Override
+ protected FishingOperation newEntity() {
+ return fishingOperation;
+ }
+}
\ No newline at end of file
Property changes on: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/macrowaste/MacroWasteBatchUIModel.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Deleted: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/plankton/PlanctonTabUI.css
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/plankton/PlanctonTabUI.css 2012-12-12 22:50:50 UTC (rev 54)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/plankton/PlanctonTabUI.css 2012-12-13 01:57:28 UTC (rev 55)
@@ -1,59 +0,0 @@
-/*
- * #%L
- * Tutti :: UI
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2012 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%
- */
-
-NumberEditor {
- autoPopup:{handler.getConfig().isAutoPopupNumberEditor()};
- showPopupButton:{handler.getConfig().isShowNumberEditorButton()};
- bean:{model};
- showReset:true;
-}
-
-#totalWeightLabel {
- text:"tutti.label.plancton.totalWeight";
- labelFor:{totalWeightField};
-}
-
-#totalWeightField {
- property:"totalWeight";
- model:{model.getTotalWeight()};
- useFloat:false;
- numberPattern:{INT_6_DIGITS_PATTERN};
-}
-
-#sampleTotalWeightLabel {
- text:"tutti.label.plancton.sampleTotalWeight";
- labelFor:{totalWeightField};
-}
-
-#sampleTotalWeightField {
- property:"sampleTotalWeight";
- model:{model.getSampleTotalWeight()};
- useFloat:false;
- numberPattern:{INT_6_DIGITS_PATTERN};
-}
-
-#table {
- model:{getContextValue(TableModel.class)};
- columnModel:{getContextValue(TableColumnModel.class)};
-}
Deleted: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/plankton/PlanctonTabUI.jaxx
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/plankton/PlanctonTabUI.jaxx 2012-12-12 22:50:50 UTC (rev 54)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/plankton/PlanctonTabUI.jaxx 2012-12-13 01:57:28 UTC (rev 55)
@@ -1,98 +0,0 @@
-<!--
- #%L
- Tutti :: UI
- $Id$
- $HeadURL$
- %%
- Copyright (C) 2012 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%
- -->
-<JPanel id='homePanel' layout='{new BorderLayout()}'
- implements='fr.ifremer.tutti.ui.swing.TuttiUI<PlanctonTabUIModel, PlanctonTabUIHandler>'>
-
- <import>
- fr.ifremer.tutti.persistence.entities.data.FishingOperation
-
- fr.ifremer.tutti.ui.swing.TuttiUIContext
- fr.ifremer.tutti.ui.swing.content.operation.FishingOperationsUI
-
- jaxx.runtime.swing.editor.NumberEditor
-
- jaxx.runtime.validator.swing.SwingValidatorUtil
- jaxx.runtime.validator.swing.SwingValidatorMessageTableModel
-
- javax.swing.table.TableModel
- javax.swing.table.TableColumnModel
-
- static org.nuiton.i18n.I18n._
- </import>
-
- <script><![CDATA[
-
-public PlanctonTabUI(FishingOperationsUI parentUI) {
- PlanctonTabUIHandler handler = new PlanctonTabUIHandler(parentUI, this);
- setContextValue(handler);
- handler.beforeInitUI();
-}
-
-public void selectFishingOperation(FishingOperation fishingOperation) { handler.selectFishingOperation(fishingOperation); }
-
-protected void $afterCompleteSetup() { handler.afterInitUI(); }
- ]]></script>
-
- <PlanctonTabUIHandler id='handler'
- initializer='getContextValue(PlanctonTabUIHandler.class)'/>
-
- <PlanctonTabUIModel id='model'
- initializer='getContextValue(PlanctonTabUIModel.class)'/>
-
- <SwingValidatorMessageTableModel id='errorTableModel'/>
-
- <BeanValidator id='validator' bean='model' errorTableModel='errorTableModel'
- uiClass='jaxx.runtime.validator.swing.ui.ImageValidationUI'>
- <field name='totalWeight' component='totalWeightField'/>
- <field name='sampleTotalWeight' component='sampleTotalWeightField'/>
- </BeanValidator>
-
- <Table id='form' fill='both' constraints='BorderLayout.NORTH'>
-
- <!-- Poids total -->
- <row>
- <cell anchor='west'>
- <JLabel id='totalWeightLabel'/>
- </cell>
- <cell weightx='1.0'>
- <NumberEditor id='totalWeightField' constructorParams='this'/>
- </cell>
- </row>
-
- <!-- Poids total échantillonné -->
- <row>
- <cell>
- <JLabel id='sampleTotalWeightLabel'/>
- </cell>
- <cell>
- <NumberEditor id='sampleTotalWeightField' constructorParams='this'/>
- </cell>
- </row>
- </Table>
-
- <JScrollPane id='tableScrollPane' constraints='BorderLayout.CENTER'>
- <JTable id='table'/>
- </JScrollPane>
-
-</JPanel>
\ No newline at end of file
Deleted: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/plankton/PlanctonTabUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/plankton/PlanctonTabUIHandler.java 2012-12-12 22:50:50 UTC (rev 54)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/plankton/PlanctonTabUIHandler.java 2012-12-13 01:57:28 UTC (rev 55)
@@ -1,182 +0,0 @@
-package fr.ifremer.tutti.ui.swing.content.operation.plankton;
-
-/*
- * #%L
- * Tutti :: UI
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2012 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.entities.data.SpeciesBatch;
-import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
-import fr.ifremer.tutti.persistence.entities.data.PlanctonBatch;
-import fr.ifremer.tutti.persistence.entities.referential.Species;
-import fr.ifremer.tutti.service.PersistenceService;
-import fr.ifremer.tutti.ui.swing.AbstractTuttiUIHandler;
-import fr.ifremer.tutti.ui.swing.content.operation.FishingOperationsUI;
-import jaxx.runtime.SwingUtil;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import javax.swing.JComboBox;
-import javax.swing.JTable;
-import javax.swing.table.DefaultTableColumnModel;
-import javax.swing.table.TableCellEditor;
-import javax.swing.table.TableCellRenderer;
-import javax.swing.table.TableColumn;
-import javax.swing.table.TableColumnModel;
-import java.beans.PropertyChangeEvent;
-import java.beans.PropertyChangeListener;
-import java.util.List;
-
-import static org.nuiton.i18n.I18n._;
-
-/**
- * @author tchemit <chemit(a)codelutin.com>
- * @since 0.2
- */
-public class PlanctonTabUIHandler extends AbstractTuttiUIHandler<PlanctonTabUIModel> {
-
- /** Logger. */
- private static final Log log = LogFactory.getLog(PlanctonTabUIHandler.class);
-
- private final PlanctonTabUI ui;
-
- private final FishingOperationsUI parentUi;
-
- private final PersistenceService persistenceService;
-
- public PlanctonTabUIHandler(FishingOperationsUI parentUi, PlanctonTabUI ui) {
- super(parentUi.getHandler().getContext());
- this.ui = ui;
- this.parentUi = parentUi;
- this.persistenceService = context.getService(PersistenceService.class);
- }
-
- @Override
- public void beforeInitUI() {
-
- PlanctonTabUIModel model = new PlanctonTabUIModel();
- ui.setContextValue(model);
-
- JTable tb = new JTable();
-
- TableCellEditor defaultEditor = tb.getDefaultEditor(String.class);
- TableCellRenderer defaultRenderer = tb.getDefaultRenderer(Object.class);
-
- // prepare the table column model
- TableColumnModel columnModel = new DefaultTableColumnModel();
-
- TableColumn col;
-
- // species (by code) column
-
- col = new TableColumn(0);
-
- JComboBox speciesEditor = new JComboBox();
- List<Species> allSpecies = persistenceService.getAllSpecies();
- SwingUtil.fillComboBox(speciesEditor, allSpecies, null);
-// col.setCellEditor();
-// col.setCellRenderer(newTableCellRender(Species.class));
- col.setHeaderValue(_("tutti.table.plancton.header.speciesByCode"));
-// col.setHeaderRenderer(SwingUtil.newStringTableCellRenderer(dRender,50, true));
- col.setIdentifier("speciesByCode");
- columnModel.addColumn(col);
-
- // Poids observé
- col = new TableColumn(1);
- col.setCellEditor(defaultEditor);
- col.setCellRenderer(defaultRenderer);
- col.setHeaderValue(_("tutti.table.plancton.header.weight"));
-// col.setHeaderRenderer(SwingUtil.newStringTableCellRenderer(dRender,50, true));
- col.setIdentifier("weight");
- columnModel.addColumn(col);
-
- // Nombre observé
- col = new TableColumn(2);
- col.setCellEditor(defaultEditor);
- col.setCellRenderer(defaultRenderer);
- col.setHeaderValue(_("tutti.table.plancton.header.number"));
-// col.setHeaderRenderer(SwingUtil.newStringTableCellRenderer(dRender,50, true));
- col.setIdentifier("computedNumber");
- columnModel.addColumn(col);
-
- ui.setContextValue(columnModel);
-
- final PlanctonTableModel tableModel = new PlanctonTableModel(columnModel);
- ui.setContextValue(tableModel);
-
- model.addPropertyChangeListener(PlanctonTabUIModel.PROPERTY_CATCHES, new PropertyChangeListener() {
- @Override
- public void propertyChange(PropertyChangeEvent evt) {
- tableModel.setData((List<SpeciesBatch>) evt.getNewValue());
- }
- });
-
- }
-
- @Override
- public void afterInitUI() {
- PlanctonTabUIModel model = ui.getModel();
-
- initUI(ui);
- }
-
- @Override
- public void onCloseUI() {
- }
-
- @Override
- protected PlanctonTabUIModel getModel() {
- return ui.getModel();
- }
-
- public void selectFishingOperation(FishingOperation bean) {
-
- boolean empty = bean == null;
-
- PlanctonTabUIModel model = ui.getModel();
-
- List<PlanctonBatch> catches;
-
- if (empty) {
- catches = null;
- bean = new FishingOperation();
- } else {
- catches = persistenceService.getAllPlanctonBatch(bean.getId());
- }
-
- model.fromBean(bean);
- model.setCatches(catches);
- }
-
- public void cancel() {
-
- if (log.isInfoEnabled()) {
- log.info("Cancel edition");
- }
- }
-
- public void save() {
- if (log.isInfoEnabled()) {
- log.info("Will save");
- }
- }
-}
\ No newline at end of file
Deleted: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/plankton/PlanctonTabUIModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/plankton/PlanctonTabUIModel.java 2012-12-12 22:50:50 UTC (rev 54)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/plankton/PlanctonTabUIModel.java 2012-12-13 01:57:28 UTC (rev 55)
@@ -1,95 +0,0 @@
-package fr.ifremer.tutti.ui.swing.content.operation.plankton;
-
-/*
- * #%L
- * Tutti :: UI
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2012 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.entities.data.FishingOperation;
-import fr.ifremer.tutti.persistence.entities.data.PlanctonBatch;
-import org.jdesktop.beans.AbstractSerializableBean;
-import org.nuiton.util.beans.BinderFactory;
-
-import java.util.List;
-
-/**
- * @author tchemit <chemit(a)codelutin.com>
- * @since 0.2
- */
-public class PlanctonTabUIModel extends AbstractSerializableBean {
-
- private static final long serialVersionUID = 1L;
-
- public static final String PROPERTY_TOTAL_WEIGHT = "totalWeight";
-
- public static final String PROPERTY_SAMPLE_TOTAL_WEIGHT = "sampleTotalWeight";
-
- public static final String PROPERTY_CATCHES = "catches";
-
- protected Float totalWeight;
-
- protected Float sampleTotalWeight;
-
- protected List<PlanctonBatch> catches;
-
- public Float getTotalWeight() {
- return totalWeight;
- }
-
- public void setTotalWeight(Float totalWeight) {
- Object oldValue = getTotalWeight();
- this.totalWeight = totalWeight;
- firePropertyChange(PROPERTY_TOTAL_WEIGHT, oldValue, totalWeight);
- }
-
- public Float getSampleTotalWeight() {
- return sampleTotalWeight;
- }
-
- public void setSampleTotalWeight(Float sampleTotalWeight) {
- Object oldValue = getSampleTotalWeight();
- this.sampleTotalWeight = sampleTotalWeight;
- firePropertyChange(PROPERTY_SAMPLE_TOTAL_WEIGHT, oldValue, sampleTotalWeight);
- }
-
- public List<PlanctonBatch> getCatches() {
- return catches;
- }
-
- public void setCatches(List<PlanctonBatch> catches) {
- Object oldValue = getCatches();
- this.catches = catches;
- firePropertyChange(PROPERTY_CATCHES, oldValue, catches);
- }
-
- public void fromBean(FishingOperation bean) {
- BinderFactory.newBinder(FishingOperation.class,
- PlanctonTabUIModel.class).copy(bean, this);
- }
-
- public FishingOperation toBean() {
- FishingOperation result = new FishingOperation();
- BinderFactory.newBinder(PlanctonTabUIModel.class,
- FishingOperation.class).copy(this, result);
- return result;
- }
-}
\ No newline at end of file
Deleted: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/plankton/PlanctonTableModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/plankton/PlanctonTableModel.java 2012-12-12 22:50:50 UTC (rev 54)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/plankton/PlanctonTableModel.java 2012-12-13 01:57:28 UTC (rev 55)
@@ -1,78 +0,0 @@
-package fr.ifremer.tutti.ui.swing.content.operation.plankton;
-
-/*
- * #%L
- * Tutti :: UI
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2012 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.collect.Lists;
-import fr.ifremer.tutti.persistence.entities.data.SpeciesBatch;
-
-import javax.swing.table.AbstractTableModel;
-import javax.swing.table.TableColumnModel;
-import java.util.List;
-
-/**
- * @author tchemit <chemit(a)codelutin.com>
- * @since 0.2
- */
-public class PlanctonTableModel extends AbstractTableModel {
-
- private static final long serialVersionUID = 1L;
-
- protected List<SpeciesBatch> data;
-
- protected final TableColumnModel columnModel;
-
- public PlanctonTableModel(TableColumnModel columnModel) {
- this.columnModel = columnModel;
- }
-
- public void setData(List<SpeciesBatch> data) {
- if (data == null) {
- data = Lists.newArrayList();
- data.add(new SpeciesBatch());
- }
- this.data = data;
- fireTableDataChanged();
- }
-
- @Override
- public int getRowCount() {
- return data == null ? 0 : data.size();
- }
-
- @Override
- public int getColumnCount() {
- return columnModel.getColumnCount();
- }
-
- @Override
- public Object getValueAt(int rowIndex, int columnIndex) {
- return null;
- }
-
- @Override
- public boolean isCellEditable(int rowIndex, int columnIndex) {
- return true;
- }
-}
\ No newline at end of file
Added: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/plankton/PlanktonBatchRowModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/plankton/PlanktonBatchRowModel.java (rev 0)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/plankton/PlanktonBatchRowModel.java 2012-12-13 01:57:28 UTC (rev 55)
@@ -0,0 +1,173 @@
+package fr.ifremer.tutti.ui.swing.content.operation.plankton;
+
+/*
+ * #%L
+ * Tutti :: UI
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 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.entities.data.PlanktonBatch;
+import fr.ifremer.tutti.persistence.entities.referential.Species;
+import fr.ifremer.tutti.ui.swing.AbstractTuttiBeanUIModel;
+import org.nuiton.util.beans.Binder;
+import org.nuiton.util.beans.BinderFactory;
+
+/**
+ * Define a benthos batch row.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 0.2
+ */
+public class PlanktonBatchRowModel extends AbstractTuttiBeanUIModel<PlanktonBatch, PlanktonBatchRowModel> {
+
+ private static final long serialVersionUID = 1L;
+
+ public static final String PROPERTY_SPECIES = "species";
+
+ public static final String PROPERTY_SPECIES_TO_CONFIRM = "speciesToConfirm";
+
+ public static final String PROPERTY_WEIGHT = "weight";
+
+ public static final String PROPERTY_SAMPLE_WEIGHT = "sampleWeight";
+
+ public static final String PROPERTY_SAMPLING_RATIO = "samplingRatio";
+
+ public static final String PROPERTY_COMMENT = "comment";
+
+ /**
+ * Species observed.
+ *
+ * @since 0.2
+ */
+ protected Species species;
+
+ /**
+ * Is the species need to be confirmed?.
+ *
+ * @since 0.2
+ */
+ protected boolean speciesToConfirm;
+
+ /**
+ * Observed weight.
+ *
+ * @since 0.2
+ */
+ protected Float weight;
+
+ /**
+ * Sample weight.
+ *
+ * @since 0.2
+ */
+ protected Float sampleWeight;
+
+ /**
+ * Sampling ratio.
+ *
+ * @since 0.2
+ */
+ protected Float samplingRatio;
+
+ /**
+ * Comment on this catches.
+ *
+ * @since 0.2
+ */
+ protected String comment;
+
+ protected static final Binder<PlanktonBatch, PlanktonBatchRowModel> fromBeanBinder =
+ BinderFactory.newBinder(PlanktonBatch.class,
+ PlanktonBatchRowModel.class);
+
+ protected static final Binder<PlanktonBatchRowModel, PlanktonBatch> toBeanBinder =
+ BinderFactory.newBinder(PlanktonBatchRowModel.class,
+ PlanktonBatch.class);
+
+ public PlanktonBatchRowModel() {
+ super(PlanktonBatch.class, fromBeanBinder, toBeanBinder);
+ }
+
+ public PlanktonBatchRowModel(PlanktonBatch aBatch) {
+ this();
+ fromBean(aBatch);
+ }
+
+ public Species getSpecies() {
+ return species;
+ }
+
+ public void setSpecies(Species species) {
+ Object oldValue = getSpecies();
+ this.species = species;
+ firePropertyChange(PROPERTY_SPECIES, oldValue, species);
+ }
+
+ public Boolean getSpeciesToConfirm() {
+ return speciesToConfirm;
+ }
+
+ public void setSpeciesToConfirm(Boolean speciesToConfirm) {
+ Object oldValue = getSpeciesToConfirm();
+ this.speciesToConfirm = speciesToConfirm;
+ firePropertyChange(PROPERTY_SPECIES_TO_CONFIRM, oldValue, speciesToConfirm);
+ }
+
+ public Float getWeight() {
+ return weight;
+ }
+
+ public void setWeight(Float weight) {
+ Object oldValue = getWeight();
+ this.weight = weight;
+ firePropertyChange(PROPERTY_WEIGHT, oldValue, weight);
+ }
+
+ public Float getSampleWeight() {
+ return sampleWeight;
+ }
+
+ public void setSampleWeight(Float sampleWeight) {
+ Object oldValue = getSampleWeight();
+ this.sampleWeight = sampleWeight;
+ firePropertyChange(PROPERTY_SAMPLE_WEIGHT, oldValue, sampleWeight);
+ }
+
+ public Float getSamplingRatio() {
+ return samplingRatio;
+ }
+
+ public void setSamplingRatio(Float samplingRatio) {
+ Object oldValue = getSamplingRatio();
+ this.samplingRatio = samplingRatio;
+ firePropertyChange(PROPERTY_SAMPLING_RATIO, oldValue, samplingRatio);
+ }
+
+ public String getComment() {
+ return comment;
+ }
+
+ public void setComment(String comment) {
+ Object oldValue = getComment();
+ this.comment = comment;
+ firePropertyChange(PROPERTY_COMMENT, oldValue, comment);
+ }
+}
Property changes on: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/plankton/PlanktonBatchRowModel.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Copied: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/plankton/PlanktonBatchTableModel.java (from rev 48, trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/plankton/PlanctonTableModel.java)
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/plankton/PlanktonBatchTableModel.java (rev 0)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/plankton/PlanktonBatchTableModel.java 2012-12-13 01:57:28 UTC (rev 55)
@@ -0,0 +1,124 @@
+package fr.ifremer.tutti.ui.swing.content.operation.plankton;
+
+/*
+ * #%L
+ * Tutti :: UI
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 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.util.table.AbstractTuttiTableModel;
+import fr.ifremer.tutti.ui.swing.util.table.ColumnIdentifier;
+
+import javax.swing.table.TableColumnModel;
+
+import static org.nuiton.i18n.I18n.n_;
+
+/**
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 0.2
+ */
+public class PlanktonBatchTableModel extends AbstractTuttiTableModel<PlanktonBatchRowModel> {
+
+ private static final long serialVersionUID = 1L;
+
+ public static final ColumnIdentifier<PlanktonBatchRowModel> SPECIES_TO_CONFIRM = ColumnIdentifier.newId(
+ PlanktonBatchRowModel.PROPERTY_SPECIES_TO_CONFIRM,
+ n_("tutti.table.plankton.batch.header.toConfirm"),
+ n_("tutti.table.plankton.batch.header.toConfirm"));
+
+ public static final ColumnIdentifier<PlanktonBatchRowModel> SPECIES_BY_CODE = ColumnIdentifier.newId(
+ PlanktonBatchRowModel.PROPERTY_SPECIES,
+ n_("tutti.table.plankton.batch.header.speciesByCode"),
+ n_("tutti.table.plankton.batch.header.speciesByCode"));
+
+ public static final ColumnIdentifier<PlanktonBatchRowModel> SPECIES_BY_GENUS_CODE = ColumnIdentifier.newId(
+ PlanktonBatchRowModel.PROPERTY_SPECIES,
+ n_("tutti.table.plankton.batch.header.speciesByGenusCode"),
+ n_("tutti.table.plankton.batch.header.speciesByGenusCode"));
+
+ public static final ColumnIdentifier<PlanktonBatchRowModel> WEIGHT = ColumnIdentifier.newId(
+ PlanktonBatchRowModel.PROPERTY_WEIGHT,
+ n_("tutti.table.plankton.batch.header.weight"),
+ n_("tutti.table.plankton.batch.header.weight"));
+
+ public static final ColumnIdentifier<PlanktonBatchRowModel> SAMPLE_WEIGHT = ColumnIdentifier.newId(
+ PlanktonBatchRowModel.PROPERTY_SAMPLE_WEIGHT,
+ n_("tutti.table.plankton.batch.header.sampleWeight"),
+ n_("tutti.table.plankton.batch.header.sampleWeight"));
+
+ public static final ColumnIdentifier<PlanktonBatchRowModel> SAMPLING_RATIO = ColumnIdentifier.newId(
+ PlanktonBatchRowModel.PROPERTY_SAMPLING_RATIO,
+ n_("tutti.table.plankton.batch.header.elevationRate"),
+ n_("tutti.table.plankton.batch.header.elevationRate"));
+
+ public static final ColumnIdentifier<PlanktonBatchRowModel> COMMENT = ColumnIdentifier.newId(
+ PlanktonBatchRowModel.PROPERTY_COMMENT,
+ n_("tutti.table.plankton.batch.header.comment"),
+ n_("tutti.table.plankton.batch.header.comment"));
+
+ public static final ColumnIdentifier<PlanktonBatchRowModel> FILE = ColumnIdentifier.newId(
+ null,
+ n_("tutti.table.plankton.batch.header.file"),
+ n_("tutti.table.plankton.batch.header.file"));
+
+
+ public PlanktonBatchTableModel(TableColumnModel columnModel) {
+ super(columnModel);
+
+ setNoneEditableCols(
+ SAMPLE_WEIGHT,
+ SAMPLING_RATIO,
+ FILE
+ );
+ }
+
+ @Override
+ protected PlanktonBatchRowModel createNewRow() {
+ PlanktonBatchRowModel result = new PlanktonBatchRowModel();
+
+ // by default empty row is not valid
+ result.setValid(false);
+ return result;
+ }
+
+ @Override
+ public void setValueAt(Object aValue,
+ int rowIndex,
+ int columnIndex,
+ ColumnIdentifier<PlanktonBatchRowModel> propertyName,
+ PlanktonBatchRowModel entry) {
+ super.setValueAt(aValue, rowIndex, columnIndex, propertyName, entry);
+
+ if (propertyName == SPECIES_BY_CODE) {
+
+ // update also other columns
+ fireTableCellUpdated(rowIndex,
+ SPECIES_BY_GENUS_CODE);
+
+ } else if (propertyName == SPECIES_BY_GENUS_CODE) {
+
+ // update also other columns
+ fireTableCellUpdated(rowIndex,
+ SPECIES_BY_CODE);
+ }
+ }
+
+}
\ No newline at end of file
Property changes on: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/plankton/PlanktonBatchTableModel.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Copied: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/plankton/PlanktonBatchUI.css (from rev 48, trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/plankton/PlanctonTabUI.css)
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/plankton/PlanktonBatchUI.css (rev 0)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/plankton/PlanktonBatchUI.css 2012-12-13 01:57:28 UTC (rev 55)
@@ -0,0 +1,61 @@
+/*
+ * #%L
+ * Tutti :: UI
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 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%
+ */
+
+NumberEditor {
+ autoPopup: {handler.getConfig().isAutoPopupNumberEditor()};
+ showPopupButton: {handler.getConfig().isShowNumberEditorButton()};
+ bean: {model};
+ showReset: true;
+}
+
+#totalWeightLabel {
+ text: "tutti.label.plankton.totalWeight";
+ labelFor: {totalWeightField};
+}
+
+#totalWeightField {
+ property: "totalWeight";
+ model: {model.getTotalWeight()};
+ useFloat: false;
+ numberPattern: {INT_6_DIGITS_PATTERN};
+}
+
+#sampleTotalWeightLabel {
+ text: "tutti.label.plankton.sampleTotalWeight";
+ labelFor: {totalWeightField};
+}
+
+#sampleTotalWeightField {
+ property: "sampleTotalWeight";
+ model: {model.getSampleTotalWeight()};
+ useFloat: false;
+ numberPattern: {INT_6_DIGITS_PATTERN};
+}
+
+#table {
+ selectionMode: {ListSelectionModel.SINGLE_SELECTION};
+ selectionBackground: {null};
+ selectionForeground: {Color.BLACK};
+ sortable: false;
+}
Property changes on: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/plankton/PlanktonBatchUI.css
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Copied: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/plankton/PlanktonBatchUI.jaxx (from rev 48, trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/plankton/PlanctonTabUI.jaxx)
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/plankton/PlanktonBatchUI.jaxx (rev 0)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/plankton/PlanktonBatchUI.jaxx 2012-12-13 01:57:28 UTC (rev 55)
@@ -0,0 +1,101 @@
+<!--
+ #%L
+ Tutti :: UI
+ $Id$
+ $HeadURL$
+ %%
+ Copyright (C) 2012 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%
+ -->
+<JPanel id='homePanel' layout='{new BorderLayout()}'
+ implements='fr.ifremer.tutti.ui.swing.TuttiUI<PlanktonBatchUIModel, PlanktonBatchUIHandler>'>
+
+ <import>
+ fr.ifremer.tutti.persistence.entities.data.FishingOperation
+
+ fr.ifremer.tutti.ui.swing.TuttiUIContext
+ fr.ifremer.tutti.ui.swing.content.operation.FishingOperationsUI
+
+ jaxx.runtime.swing.editor.NumberEditor
+
+ jaxx.runtime.validator.swing.SwingValidatorUtil
+ jaxx.runtime.validator.swing.SwingValidatorMessageTableModel
+
+ org.jdesktop.swingx.JXTable
+
+ javax.swing.ListSelectionModel
+
+ java.awt.Color
+
+ static org.nuiton.i18n.I18n._
+ </import>
+
+ <script><![CDATA[
+
+public PlanktonBatchUI(FishingOperationsUI parentUI) {
+ PlanktonBatchUIHandler handler = new PlanktonBatchUIHandler(parentUI, this);
+ setContextValue(handler);
+ handler.beforeInitUI();
+}
+
+public void selectFishingOperation(FishingOperation fishingOperation) { handler.selectFishingOperation(fishingOperation); }
+
+protected void $afterCompleteSetup() { handler.afterInitUI(); }
+ ]]></script>
+
+ <PlanktonBatchUIHandler id='handler'
+ initializer='getContextValue(PlanktonBatchUIHandler.class)'/>
+
+ <PlanktonBatchUIModel id='model'
+ initializer='getContextValue(PlanktonBatchUIModel.class)'/>
+
+ <SwingValidatorMessageTableModel id='errorTableModel'/>
+
+ <BeanValidator id='validator' bean='model' errorTableModel='errorTableModel'
+ uiClass='jaxx.runtime.validator.swing.ui.ImageValidationUI'>
+ <field name='totalWeight' component='totalWeightField'/>
+ <field name='sampleTotalWeight' component='sampleTotalWeightField'/>
+ </BeanValidator>
+
+ <Table id='form' fill='both' constraints='BorderLayout.NORTH'>
+
+ <!-- Poids total -->
+ <row>
+ <cell anchor='west'>
+ <JLabel id='totalWeightLabel'/>
+ </cell>
+ <cell weightx='1.0'>
+ <NumberEditor id='totalWeightField' constructorParams='this'/>
+ </cell>
+ </row>
+
+ <!-- Poids total échantillonné -->
+ <row>
+ <cell>
+ <JLabel id='sampleTotalWeightLabel'/>
+ </cell>
+ <cell>
+ <NumberEditor id='sampleTotalWeightField' constructorParams='this'/>
+ </cell>
+ </row>
+ </Table>
+
+ <JScrollPane id='tableScrollPane' constraints='BorderLayout.CENTER'>
+ <JXTable id='table' onFocusLost='handler.saveSelectedRowIfRequired(event);'/>
+ </JScrollPane>
+
+</JPanel>
\ No newline at end of file
Property changes on: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/plankton/PlanktonBatchUI.jaxx
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Copied: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/plankton/PlanktonBatchUIHandler.java (from rev 48, trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/plankton/PlanctonTabUIHandler.java)
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/plankton/PlanktonBatchUIHandler.java (rev 0)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/plankton/PlanktonBatchUIHandler.java 2012-12-13 01:57:28 UTC (rev 55)
@@ -0,0 +1,496 @@
+package fr.ifremer.tutti.ui.swing.content.operation.plankton;
+
+/*
+ * #%L
+ * Tutti :: UI
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 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.collect.Lists;
+import fr.ifremer.tutti.persistence.entities.TuttiEntities;
+import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
+import fr.ifremer.tutti.persistence.entities.data.PlanktonBatch;
+import fr.ifremer.tutti.persistence.entities.referential.Species;
+import fr.ifremer.tutti.service.DecoratorService;
+import fr.ifremer.tutti.service.PersistenceService;
+import fr.ifremer.tutti.ui.swing.TuttiUI;
+import fr.ifremer.tutti.ui.swing.content.operation.FishingOperationsUI;
+import fr.ifremer.tutti.ui.swing.util.TuttiBeanMonitor;
+import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil;
+import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableUIHandler;
+import fr.ifremer.tutti.ui.swing.util.table.TableRowModificationListener;
+import jaxx.runtime.SwingUtil;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.jdesktop.swingx.JXTable;
+import org.jdesktop.swingx.decorator.ComponentAdapter;
+import org.jdesktop.swingx.decorator.HighlightPredicate;
+import org.jdesktop.swingx.decorator.Highlighter;
+import org.jdesktop.swingx.table.DefaultTableColumnModelExt;
+import org.nuiton.util.decorator.Decorator;
+
+import javax.swing.event.ListSelectionListener;
+import javax.swing.table.TableColumnModel;
+import java.awt.Color;
+import java.awt.Component;
+import java.awt.event.FocusEvent;
+import java.util.List;
+
+/**
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 0.2
+ */
+public class PlanktonBatchUIHandler extends AbstractTuttiTableUIHandler<PlanktonBatchRowModel, PlanktonBatchUIModel> {
+
+ /** Logger. */
+ private static final Log log = LogFactory.getLog(PlanktonBatchUIHandler.class);
+
+ /**
+ * UI.
+ *
+ * @since 0.2
+ */
+ private final PlanktonBatchUI ui;
+
+ /**
+ * Persistence service.
+ *
+ * @since 0.2
+ */
+ private final PersistenceService persistenceService;
+
+ /**
+ * To monitor changes on the fishing operation.
+ *
+ * @since 0.2
+ */
+ private final TuttiBeanMonitor<PlanktonBatchUIModel> fishingOperationMonitor;
+
+ public PlanktonBatchUIHandler(FishingOperationsUI parentUi, PlanktonBatchUI ui) {
+ super(parentUi.getHandler().getContext(),
+ PlanktonBatchRowModel.PROPERTY_SPECIES_TO_CONFIRM,
+ PlanktonBatchRowModel.PROPERTY_SPECIES,
+ PlanktonBatchRowModel.PROPERTY_WEIGHT,
+ PlanktonBatchRowModel.PROPERTY_COMMENT);
+ this.ui = ui;
+ this.persistenceService = context.getService(PersistenceService.class);
+ this.fishingOperationMonitor = new TuttiBeanMonitor<PlanktonBatchUIModel>(
+ PlanktonBatchUIModel.PROPERTY_TOTAL_WEIGHT,
+ PlanktonBatchUIModel.PROPERTY_SAMPLE_TOTAL_WEIGHT
+ );
+ }
+
+ //------------------------------------------------------------------------//
+ //-- AbstractTuttiTableUIHandler methods --//
+ //------------------------------------------------------------------------//
+
+ @Override
+ protected PlanktonBatchUIModel getModel() {
+ return ui.getModel();
+ }
+
+ @Override
+ protected PlanktonBatchTableModel getTableModel() {
+ return (PlanktonBatchTableModel) getTable().getModel();
+ }
+
+ @Override
+ protected JXTable getTable() {
+ return ui.getTable();
+ }
+
+ @Override
+ protected String[] getRowPropertiesToIgnore() {
+ return new String[]{
+ PlanktonBatchRowModel.PROPERTY_SAMPLE_WEIGHT,
+ PlanktonBatchRowModel.PROPERTY_SAMPLING_RATIO
+ };
+ }
+
+ @Override
+ protected TableColumnModel createTableColumnModel() {
+
+ DefaultTableColumnModelExt columnModel =
+ new DefaultTableColumnModelExt();
+
+ {
+ // Species to confirm column
+
+ addBooleanColumnToModel(columnModel,
+ PlanktonBatchTableModel.SPECIES_TO_CONFIRM,
+ getTable());
+ }
+
+ List<Species> allSpecies = persistenceService.getAllSpecies();
+
+ {
+ // Species (by code) column
+
+ Decorator<Species> decorator = getDecorator(
+ Species.class, DecoratorService.SPECIES_BY_CODE);
+
+ addComboDataColumnToModel(columnModel,
+ PlanktonBatchTableModel.SPECIES_BY_CODE,
+ decorator, allSpecies);
+ }
+
+ {
+ // Species (by genusCode) column
+
+ Decorator<Species> decorator = getDecorator(
+ Species.class, DecoratorService.SPECIES_BY_GENUS);
+
+ addComboDataColumnToModel(columnModel,
+ PlanktonBatchTableModel.SPECIES_BY_GENUS_CODE,
+ decorator, allSpecies);
+
+ }
+
+ { // Weight column
+
+ addFloatColumnToModel(columnModel,
+ PlanktonBatchTableModel.WEIGHT,
+ TuttiUI.DECIMAL3_PATTERN);
+ }
+
+ { // Sample weight column
+
+ addColumnToModel(columnModel,
+ PlanktonBatchTableModel.SAMPLE_WEIGHT);
+ }
+
+ { // SamplingRatio column
+
+ addColumnToModel(columnModel,
+ PlanktonBatchTableModel.SAMPLING_RATIO);
+ }
+
+ { // Comment column
+
+ addColumnToModel(columnModel,
+ PlanktonBatchTableModel.COMMENT);
+ }
+
+ { // File column
+
+ addColumnToModel(columnModel,
+ PlanktonBatchTableModel.FILE);
+ }
+ return columnModel;
+ }
+
+ @Override
+ protected void onRowModified(PlanktonBatchRowModel row,
+ String propertyName,
+ Object oldValue,
+ Object newValue) {
+
+ boolean wasValid = row.isValid();
+
+ boolean valid = isRowValid(row);
+
+ if (log.isInfoEnabled()) {
+ log.info("Was valid / Is valid: " + wasValid + " / " + valid);
+ }
+ row.setValid(valid);
+ }
+
+ @Override
+ protected void onRowValidStateChanged(PlanktonBatchRowModel row,
+ Boolean oldValue,
+ Boolean newValue) {
+ int rowIndex = getTableModel().getRowIndex(row);
+
+ if (rowIndex > -1) {
+ getTableModel().fireTableRowsUpdated(rowIndex, rowIndex);
+ }
+ }
+
+ @Override
+ protected void onRowModifyStateChanged(PlanktonBatchRowModel row,
+ Boolean oldValue,
+ Boolean newValue) {
+ }
+
+ @Override
+ protected void onModelRowsChanged(List<PlanktonBatchRowModel> rows) {
+ super.onModelRowsChanged(rows);
+
+ // set valid flag
+ for (PlanktonBatchRowModel row : rows) {
+ boolean valid = isRowValid(row);
+ row.setValid(valid);
+ }
+ }
+
+ //------------------------------------------------------------------------//
+ //-- AbstractTuttiUIHandler methods --//
+ //------------------------------------------------------------------------//
+
+ @Override
+ public void beforeInitUI() {
+
+ if (log.isInfoEnabled()) {
+ log.info("beforeInit: " + ui);
+ }
+
+ PlanktonBatchUIModel model = new PlanktonBatchUIModel();
+ ui.setContextValue(model);
+
+ fishingOperationMonitor.setBean(model);
+ }
+
+ @Override
+ public void afterInitUI() {
+
+ if (log.isInfoEnabled()) {
+ log.info("afterInit: " + ui);
+ }
+
+ initUI(ui);
+
+ JXTable table = getTable();
+
+ // create table column model
+ TableColumnModel columnModel = createTableColumnModel();
+
+ // create table model
+ PlanktonBatchTableModel tableModel =
+ new PlanktonBatchTableModel(columnModel);
+
+ table.setModel(tableModel);
+ table.setColumnModel(columnModel);
+ installTableKeyListener(columnModel, table);
+
+ table.getTableHeader().setReorderingAllowed(false);
+
+
+ Highlighter readOnlyHighlighter = TuttiUIUtil.newBackgroundColorHighlighter(
+ HighlightPredicate.READ_ONLY, Color.LIGHT_GRAY);
+
+ table.addHighlighter(readOnlyHighlighter);
+ Highlighter validHighlighter = TuttiUIUtil.newBackgroundColorHighlighter(
+ new HighlightPredicate.AndHighlightPredicate(HighlightPredicate.EDITABLE, new HighlightPredicate() {
+ @Override
+ public boolean isHighlighted(Component renderer, ComponentAdapter adapter) {
+
+ boolean result = false;
+ if (adapter.isEditable()) {
+ int rowIndex = adapter.convertRowIndexToModel(adapter.row);
+ PlanktonBatchRowModel row = getTableModel().getEntry(rowIndex);
+ result = !row.isValid();
+ }
+ return result;
+ }
+ }), Color.RED);
+ table.addHighlighter(validHighlighter);
+
+ // when model datas change let's propagate it table model
+ listenRowsFromModel();
+
+ // save when row chaged and was modified
+ ListSelectionListener listener = new TableRowModificationListener<PlanktonBatchRowModel>(
+ getTableModel(), getRowMonitor()) {
+ @Override
+ protected void saveSelectedRow() {
+ saveSelectedRowIfRequired();
+ }
+ };
+ table.getSelectionModel().addListSelectionListener(listener);
+
+ // always scroll to selected row
+ SwingUtil.scrollToTableSelection(getTable());
+ }
+
+ @Override
+ public void onCloseUI() {
+ if (log.isInfoEnabled()) {
+ log.info("closing: " + ui);
+ }
+ }
+
+ //------------------------------------------------------------------------//
+ //-- Public methods --//
+ //------------------------------------------------------------------------//
+
+ public void saveSelectedRowIfRequired(FocusEvent event) {
+
+ Component oppositeComponent = event.getOppositeComponent();
+
+ JXTable parentContainer = null;
+
+ if (oppositeComponent != null) {
+
+ // check out if still on table
+ parentContainer = SwingUtil.getParentContainer(
+ oppositeComponent, JXTable.class);
+ }
+
+ if (parentContainer == null) {
+
+ // out of the table can save
+ if (getModel().getFishingOperation() != null) {
+ saveSelectedRowIfRequired();
+ }
+ }
+ }
+
+ public void selectFishingOperation(FishingOperation bean) {
+
+ JXTable table = getTable();
+
+ if (table.isEditing()) {
+
+ // make sure to stop editor
+ table.editingCanceled(null);
+ }
+
+ if (fishingOperationMonitor.wasModified()) {
+
+ // previous fishingOperation was modified, let's save it
+ PlanktonBatchUIModel beanToSave = fishingOperationMonitor.getBean();
+
+ FishingOperation fishingOperation = beanToSave.toBean();
+
+ if (log.isInfoEnabled()) {
+ log.info("FishingOperation " + fishingOperation.getId() +
+ " was modified, will save it.");
+ }
+
+ persistenceService.saveFishingOperation(fishingOperation);
+ }
+
+ // make sure selection is empty (will remove bean from monitor)
+ table.clearSelection();
+
+ boolean empty = bean == null;
+
+ PlanktonBatchUIModel model = getModel();
+
+ List<PlanktonBatchRowModel> rows;
+
+ if (empty) {
+ rows = null;
+ bean = new FishingOperation();
+ model.setFishingOperation(null);
+ } else {
+
+ if (log.isInfoEnabled()) {
+ log.info("Get species batch for fishingOperation: " + bean.getId());
+ }
+ rows = Lists.newArrayList();
+
+ if (!TuttiEntities.isNew(bean)) {
+ List<PlanktonBatch> catches =
+ persistenceService.getAllPlanktonBatch(bean.getId());
+ for (PlanktonBatch aBatch : catches) {
+ PlanktonBatchRowModel entry =
+ new PlanktonBatchRowModel(aBatch);
+ rows.add(entry);
+ }
+ }
+ model.setFishingOperation(bean);
+ }
+
+ model.fromBean(bean);
+ model.setRows(rows);
+
+ fishingOperationMonitor.clearModified();
+ }
+
+ public void cancel() {
+
+ if (log.isInfoEnabled()) {
+ log.info("Cancel edition");
+ }
+ }
+
+ public void save() {
+ if (log.isInfoEnabled()) {
+ log.info("Will save");
+ }
+ }
+
+ //------------------------------------------------------------------------//
+ //-- Internal methods --//
+ //------------------------------------------------------------------------//
+
+ protected boolean isRowValid(PlanktonBatchRowModel row) {
+ boolean result = row.getSpecies() != null && row.getWeight() != null;
+ return result;
+ }
+
+ protected void saveSelectedRowIfRequired() {
+
+ TuttiBeanMonitor<PlanktonBatchRowModel> rowMonitor = getRowMonitor();
+
+ PlanktonBatchRowModel bean = rowMonitor.getBean();
+ if (bean != null) {
+
+ if (bean.isValid()) {
+ // there is a valid bean attached to the monitor
+
+ if (rowMonitor.wasModified()) {
+
+ // monitored bean was modified, save it
+ if (log.isInfoEnabled()) {
+ log.info("Row " + bean + " was modified, will save it");
+ }
+
+ saveRow(bean);
+
+ // clear modified flag on the monitor
+ rowMonitor.clearModified();
+ }
+ } else {
+
+ // row is not valid can not save it
+
+ PlanktonBatch catchBean = bean.toBean();
+
+ if (!TuttiEntities.isNew(catchBean)) {
+
+ // remove this
+ persistenceService.deletePlanktonBatch(catchBean.getId());
+ }
+ }
+ }
+ }
+
+ protected void saveRow(PlanktonBatchRowModel row) {
+
+ PlanktonBatch catchBean = row.toBean();
+
+ FishingOperation fishingOperation = getModel().getFishingOperation();
+ catchBean.setFishingOperation(fishingOperation);
+ if (log.isInfoEnabled()) {
+ log.info("Selected fishingOperation: " + fishingOperation.getId());
+ }
+
+ if (TuttiEntities.isNew(catchBean)) {
+
+ catchBean = persistenceService.createPlanktonBatch(catchBean);
+ row.setId(catchBean.getId());
+ } else {
+ persistenceService.savePlanktonBatch(catchBean);
+ }
+ }
+}
\ No newline at end of file
Property changes on: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/plankton/PlanktonBatchUIHandler.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Copied: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/plankton/PlanktonBatchUIModel.java (from rev 48, trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/plankton/PlanctonTabUIModel.java)
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/plankton/PlanktonBatchUIModel.java (rev 0)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/plankton/PlanktonBatchUIModel.java 2012-12-13 01:57:28 UTC (rev 55)
@@ -0,0 +1,113 @@
+package fr.ifremer.tutti.ui.swing.content.operation.plankton;
+
+/*
+ * #%L
+ * Tutti :: UI
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 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.entities.data.FishingOperation;
+import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableUIModel;
+import org.nuiton.util.beans.Binder;
+import org.nuiton.util.beans.BinderModelBuilder;
+
+/**
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 0.2
+ */
+public class PlanktonBatchUIModel extends AbstractTuttiTableUIModel<FishingOperation, PlanktonBatchRowModel, PlanktonBatchUIModel> {
+
+ private static final long serialVersionUID = 1L;
+
+ public static final String PROPERTY_TOTAL_WEIGHT = "totalWeight";
+
+ public static final String PROPERTY_SAMPLE_TOTAL_WEIGHT = "sampleTotalWeight";
+
+ /**
+ * Editing fishing operation.
+ *
+ * @since 0.2
+ */
+ protected FishingOperation fishingOperation;
+
+ /**
+ * Total Weight filled in screen.
+ *
+ * @since 0.2
+ */
+ protected Float totalWeight;
+
+ /**
+ * Total Sample Weight filled in screen.
+ *
+ * @since 0.2
+ */
+ protected Float sampleTotalWeight;
+
+ protected static final Binder<FishingOperation, PlanktonBatchUIModel> fromBeanBinder = BinderModelBuilder.newEmptyBuilder(FishingOperation.class, PlanktonBatchUIModel.class)
+ .addProperty(FishingOperation.PROPERTY_PLANKTON_TOTAL_WEIGHT, PROPERTY_TOTAL_WEIGHT)
+ .addProperty(FishingOperation.PROPERTY_PLANKTON_SAMPLE_TOTAL_WEIGHT, PROPERTY_SAMPLE_TOTAL_WEIGHT)
+ .addProperty(FishingOperation.PROPERTY_ID, PROPERTY_ID)
+ .toBinder();
+
+ protected static final Binder<PlanktonBatchUIModel, FishingOperation> toBeanBinder = BinderModelBuilder.newEmptyBuilder(PlanktonBatchUIModel.class, FishingOperation.class)
+ .addProperty(PROPERTY_TOTAL_WEIGHT, FishingOperation.PROPERTY_PLANKTON_TOTAL_WEIGHT)
+ .addProperty(PROPERTY_SAMPLE_TOTAL_WEIGHT, FishingOperation.PROPERTY_PLANKTON_SAMPLE_TOTAL_WEIGHT)
+ .toBinder();
+
+
+ public PlanktonBatchUIModel() {
+ super(FishingOperation.class, fromBeanBinder, toBeanBinder);
+ }
+
+ public FishingOperation getFishingOperation() {
+ return fishingOperation;
+ }
+
+ public void setFishingOperation(FishingOperation fishingOperation) {
+ this.fishingOperation = fishingOperation;
+ }
+
+ public Float getTotalWeight() {
+ return totalWeight;
+ }
+
+ public void setTotalWeight(Float totalWeight) {
+ Object oldValue = getTotalWeight();
+ this.totalWeight = totalWeight;
+ firePropertyChange(PROPERTY_TOTAL_WEIGHT, oldValue, totalWeight);
+ }
+
+ public Float getSampleTotalWeight() {
+ return sampleTotalWeight;
+ }
+
+ public void setSampleTotalWeight(Float sampleTotalWeight) {
+ Object oldValue = getSampleTotalWeight();
+ this.sampleTotalWeight = sampleTotalWeight;
+ firePropertyChange(PROPERTY_SAMPLE_TOTAL_WEIGHT, oldValue, sampleTotalWeight);
+ }
+
+ @Override
+ protected FishingOperation newEntity() {
+ return fishingOperation;
+ }
+}
\ No newline at end of file
Property changes on: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/plankton/PlanktonBatchUIModel.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/species/SpeciesBatchRowModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/species/SpeciesBatchRowModel.java 2012-12-12 22:50:50 UTC (rev 54)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/species/SpeciesBatchRowModel.java 2012-12-13 01:57:28 UTC (rev 55)
@@ -155,7 +155,7 @@
protected Float sampleWeight;
/**
- * Elevation ratio.
+ * Sampling ratio.
*
* @since 0.2
*/
Copied: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/species/SpeciesBatchUI.css (from rev 48, trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/species/SpeciesTabUI.css)
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/species/SpeciesBatchUI.css (rev 0)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/species/SpeciesBatchUI.css 2012-12-13 01:57:28 UTC (rev 55)
@@ -0,0 +1,83 @@
+/*
+ * #%L
+ * Tutti :: UI
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 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%
+ */
+
+NumberEditor {
+ autoPopup: {handler.getConfig().isAutoPopupNumberEditor()};
+ showPopupButton: {handler.getConfig().isShowNumberEditorButton()};
+ bean: {model};
+ showReset: true;
+}
+
+#totalWeightLabel {
+ text: "tutti.label.species.totalWeight";
+ labelFor: {totalWeightField};
+}
+
+#totalWeightField {
+ property: "totalWeight";
+ model: {model.getTotalWeight()};
+ useFloat: false;
+ numberPattern: {INT_6_DIGITS_PATTERN};
+}
+
+#totalVracWeightLabel {
+ text: "tutti.label.species.totalVracWeight";
+ labelFor: {totalVracWeightField};
+}
+
+#totalVracWeightField {
+ property: "totalVracWeight";
+ model: {model.getTotalVracWeight()};
+ useFloat: false;
+ numberPattern: {INT_6_DIGITS_PATTERN};
+}
+
+#sampleVracWeightLabel {
+ text: "tutti.label.species.sampleVracWeight";
+ labelFor: {sampleVracWeightField};
+}
+
+#sampleVracWeightField {
+ property: "sampleVracWeight";
+ model: {model.getSampleVracWeight()};
+ useFloat: false;
+ numberPattern: {INT_6_DIGITS_PATTERN};
+}
+
+#totalHorsVracWeightLabel {
+ text: "tutti.label.species.totalHorsVracWeight";
+ labelFor: {totalHorsVracWeightField};
+}
+
+#totalHorsVracWeightField {
+ text: {getStringValue(model.getTotalHorsVracWeight())};
+ editable: false;
+}
+
+#table {
+ selectionMode: {ListSelectionModel.SINGLE_SELECTION};
+ selectionBackground: {null};
+ selectionForeground: {Color.BLACK};
+ sortable: false;
+}
Property changes on: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/species/SpeciesBatchUI.css
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Copied: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/species/SpeciesBatchUI.jaxx (from rev 48, trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/species/SpeciesTabUI.jaxx)
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/species/SpeciesBatchUI.jaxx (rev 0)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/species/SpeciesBatchUI.jaxx 2012-12-13 01:57:28 UTC (rev 55)
@@ -0,0 +1,119 @@
+<!--
+ #%L
+ Tutti :: UI
+ $Id$
+ $HeadURL$
+ %%
+ Copyright (C) 2012 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%
+ -->
+<JPanel id='homePanel' layout='{new BorderLayout()}'
+ implements='fr.ifremer.tutti.ui.swing.TuttiUI<SpeciesBatchUIModel, SpeciesBatchUIHandler>'>
+
+ <import>
+ fr.ifremer.tutti.persistence.entities.data.FishingOperation
+
+ fr.ifremer.tutti.ui.swing.TuttiUIContext
+ fr.ifremer.tutti.ui.swing.content.operation.FishingOperationsUI
+ fr.ifremer.tutti.ui.swing.content.operation.species.SpeciesFrequencyUI
+
+ org.jdesktop.swingx.JXTable
+
+ jaxx.runtime.swing.editor.NumberEditor
+
+ jaxx.runtime.validator.swing.SwingValidatorUtil
+ jaxx.runtime.validator.swing.SwingValidatorMessageTableModel
+
+ javax.swing.ListSelectionModel
+
+ java.awt.Color
+
+ static org.nuiton.i18n.I18n._
+ static jaxx.runtime.SwingUtil.getStringValue
+ </import>
+
+ <script><![CDATA[
+
+public SpeciesBatchUI(FishingOperationsUI parentUI) {
+ SpeciesBatchUIHandler handler = new SpeciesBatchUIHandler(parentUI, this);
+ setContextValue(handler);
+ handler.beforeInitUI();
+}
+
+public void selectFishingOperation(FishingOperation fishingOperation) { handler.selectFishingOperation(fishingOperation); }
+
+protected void $afterCompleteSetup() { handler.afterInitUI(); }
+ ]]></script>
+
+ <SpeciesBatchUIHandler id='handler'
+ initializer='getContextValue(SpeciesBatchUIHandler.class)'/>
+
+ <SpeciesBatchUIModel id='model'
+ initializer='getContextValue(SpeciesBatchUIModel.class)'/>
+
+ <SwingValidatorMessageTableModel id='errorTableModel'/>
+
+ <BeanValidator id='validator' bean='model' errorTableModel='errorTableModel'
+ uiClass='jaxx.runtime.validator.swing.ui.ImageValidationUI'>
+ <field name='totalWeight' component='totalWeightField'/>
+ <field name='totalVracWeight' component='totalVracWeightField'/>
+ <field name='sampleVracWeight' component='sampleVracWeightField'/>
+ <field name='totalHorsVracWeight' component='totalHorsVracWeightField'/>
+ </BeanValidator>
+
+ <SpeciesFrequencyUI id='frequencyUI' constructorParams='handler.getContext()'/>
+
+ <Table id='form' fill='both' constraints='BorderLayout.NORTH'>
+
+ <!-- Poids total / Poids total vrac -->
+ <row>
+ <cell anchor='west'>
+ <JLabel id='totalWeightLabel'/>
+ </cell>
+ <cell weightx='1.0'>
+ <NumberEditor id='totalWeightField' constructorParams='this'/>
+ </cell>
+ <cell anchor='west'>
+ <JLabel id='totalVracWeightLabel'/>
+ </cell>
+ <cell weightx='1.0'>
+ <NumberEditor id='totalVracWeightField' constructorParams='this'/>
+ </cell>
+ </row>
+
+ <!-- Poids échantillonné vrac / Poids total hors vrac -->
+ <row>
+ <cell>
+ <JLabel id='sampleVracWeightLabel'/>
+ </cell>
+ <cell>
+ <NumberEditor id='sampleVracWeightField' constructorParams='this'/>
+ </cell>
+ <cell>
+ <JLabel id='totalHorsVracWeightLabel'/>
+ </cell>
+ <cell>
+ <JTextField id='totalHorsVracWeightField'/>
+ </cell>
+ </row>
+ </Table>
+
+ <JScrollPane id='tableScrollPane' constraints='BorderLayout.CENTER'>
+ <JXTable id='table' onFocusLost='handler.saveSelectedRowIfRequired(event);'/>
+ </JScrollPane>
+
+</JPanel>
Property changes on: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/species/SpeciesBatchUI.jaxx
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Copied: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/species/SpeciesBatchUIHandler.java (from rev 54, trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/species/SpeciesTabUIHandler.java)
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/species/SpeciesBatchUIHandler.java (rev 0)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/species/SpeciesBatchUIHandler.java 2012-12-13 01:57:28 UTC (rev 55)
@@ -0,0 +1,756 @@
+package fr.ifremer.tutti.ui.swing.content.operation.species;
+
+/*
+ * #%L
+ * Tutti :: UI
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 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.Lists;
+import com.google.common.collect.Sets;
+import fr.ifremer.tutti.persistence.entities.TuttiEntities;
+import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
+import fr.ifremer.tutti.persistence.entities.data.SpeciesBatch;
+import fr.ifremer.tutti.persistence.entities.data.SpeciesBatchFrequency;
+import fr.ifremer.tutti.persistence.entities.data.VracHorsVracEnum;
+import fr.ifremer.tutti.persistence.entities.referential.Sex;
+import fr.ifremer.tutti.persistence.entities.referential.Species;
+import fr.ifremer.tutti.persistence.entities.referential.WeightCategory;
+import fr.ifremer.tutti.service.DecoratorService;
+import fr.ifremer.tutti.service.PersistenceService;
+import fr.ifremer.tutti.ui.swing.TuttiUI;
+import fr.ifremer.tutti.ui.swing.content.operation.FishingOperationsUI;
+import fr.ifremer.tutti.ui.swing.util.TuttiBeanMonitor;
+import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil;
+import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableUIHandler;
+import fr.ifremer.tutti.ui.swing.util.table.TableRowModificationListener;
+import jaxx.runtime.SwingUtil;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.jdesktop.swingx.JXTable;
+import org.jdesktop.swingx.decorator.ComponentAdapter;
+import org.jdesktop.swingx.decorator.HighlightPredicate;
+import org.jdesktop.swingx.decorator.Highlighter;
+import org.jdesktop.swingx.table.DefaultTableColumnModelExt;
+import org.nuiton.util.decorator.Decorator;
+
+import javax.swing.event.ListSelectionListener;
+import javax.swing.table.TableColumnModel;
+import java.awt.Color;
+import java.awt.Component;
+import java.awt.event.FocusEvent;
+import java.util.List;
+import java.util.Set;
+
+/**
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 0.1
+ */
+public class SpeciesBatchUIHandler extends AbstractTuttiTableUIHandler<SpeciesBatchRowModel, SpeciesBatchUIModel> {
+
+ /** Logger. */
+ private static final Log log = LogFactory.getLog(SpeciesBatchUIHandler.class);
+
+ public static final Set<String> RECOMPUTE_TOTAL_WEIGHT = Sets.newHashSet(
+ SpeciesBatchRowModel.PROPERTY_VRAC_HORS_VRAC,
+ SpeciesBatchRowModel.PROPERTY_WEIGHT
+ );
+
+ public static final Set<String> SAMPLING_PROPERTIES = Sets.newHashSet(
+ SpeciesBatchRowModel.PROPERTY_SPECIES,
+ SpeciesBatchRowModel.PROPERTY_VRAC_HORS_VRAC,
+ SpeciesBatchRowModel.PROPERTY_WEIGHT_CATEGORY,
+ SpeciesBatchRowModel.PROPERTY_SEX,
+ SpeciesBatchRowModel.PROPERTY_MATURITY,
+ SpeciesBatchRowModel.PROPERTY_AGE
+ );
+
+ /**
+ * UI.
+ *
+ * @since 0.2
+ */
+ private final SpeciesBatchUI ui;
+
+ /**
+ * Persistence service.
+ *
+ * @since 0.2
+ */
+ private final PersistenceService persistenceService;
+
+ /**
+ * To monitor changes on the fishing operation.
+ *
+ * @since 0.2
+ */
+ private final TuttiBeanMonitor<SpeciesBatchUIModel> fishingOperationMonitor;
+
+ public SpeciesBatchUIHandler(FishingOperationsUI parentUi, SpeciesBatchUI ui) {
+ super(parentUi.getHandler().getContext(),
+ SpeciesBatchRowModel.PROPERTY_SPECIES_TO_CONFIRM,
+ SpeciesBatchRowModel.PROPERTY_SPECIES,
+ SpeciesBatchRowModel.PROPERTY_VRAC_HORS_VRAC,
+ SpeciesBatchRowModel.PROPERTY_WEIGHT_CATEGORY,
+ SpeciesBatchRowModel.PROPERTY_SEX,
+ SpeciesBatchRowModel.PROPERTY_MATURITY,
+ SpeciesBatchRowModel.PROPERTY_AGE,
+ SpeciesBatchRowModel.PROPERTY_WEIGHT,
+ SpeciesBatchRowModel.PROPERTY_COMMENT,
+ SpeciesBatchRowModel.PROPERTY_FREQUENCY);
+ this.ui = ui;
+ this.persistenceService = context.getService(PersistenceService.class);
+ this.fishingOperationMonitor = new TuttiBeanMonitor<SpeciesBatchUIModel>(
+ SpeciesBatchUIModel.PROPERTY_SAMPLE_VRAC_WEIGHT,
+ SpeciesBatchUIModel.PROPERTY_TOTAL_HORS_VRAC_WEIGHT,
+ SpeciesBatchUIModel.PROPERTY_TOTAL_VRAC_WEIGHT,
+ SpeciesBatchUIModel.PROPERTY_TOTAL_WEIGHT
+ );
+ }
+
+ //------------------------------------------------------------------------//
+ //-- AbstractTuttiTableUIHandler methods --//
+ //------------------------------------------------------------------------//
+
+ @Override
+ protected SpeciesBatchUIModel getModel() {
+ return ui.getModel();
+ }
+
+ @Override
+ protected SpeciesBatchTableModel getTableModel() {
+ return (SpeciesBatchTableModel) getTable().getModel();
+ }
+
+ @Override
+ protected JXTable getTable() {
+ return ui.getTable();
+ }
+
+ @Override
+ protected void onModelRowsChanged(List<SpeciesBatchRowModel> rows) {
+ super.onModelRowsChanged(rows);
+
+ // build the new sampling tree from the new rows to edit
+ getModel().getSamplingTreeModel().populate(rows);
+ }
+
+ @Override
+ protected String[] getRowPropertiesToIgnore() {
+ return new String[]{
+ SpeciesBatchRowModel.PROPERTY_SAMPLE_WEIGHT,
+ SpeciesBatchRowModel.PROPERTY_SAMPLING_RATIO,
+ SpeciesBatchRowModel.PROPERTY_FREQUENCY
+ };
+ }
+
+ @Override
+ protected TableColumnModel createTableColumnModel() {
+
+ List<String> samplingOrder = getModel().getSamplingOrder();
+
+ DefaultTableColumnModelExt columnModel =
+ new DefaultTableColumnModelExt();
+
+ {
+ // Species to confirm column
+
+ addBooleanColumnToModel(columnModel,
+ SpeciesBatchTableModel.SPECIES_TO_CONFIRM,
+ getTable());
+ }
+
+ List<Species> allSpecies = persistenceService.getAllSpecies();
+
+ {
+ // Species (by code) column
+
+ Decorator<Species> decorator = getDecorator(
+ Species.class, DecoratorService.SPECIES_BY_CODE);
+
+ addComboDataColumnToModel(columnModel,
+ SpeciesBatchTableModel.SPECIES_BY_CODE,
+ decorator, allSpecies);
+ }
+
+ {
+ // Species (by genusCode) column
+
+ Decorator<Species> decorator = getDecorator(
+ Species.class, DecoratorService.SPECIES_BY_GENUS);
+
+ addComboDataColumnToModel(columnModel,
+ SpeciesBatchTableModel.SPECIES_BY_GENUS_CODE,
+ decorator, allSpecies);
+
+ }
+
+ if (samplingOrder.contains(SpeciesBatchRowModel.PROPERTY_VRAC_HORS_VRAC)) {
+
+ // Vrac / Hors vrac column
+
+ addComboEnumColumnToModel(columnModel,
+ SpeciesBatchTableModel.VRAC_HORS_VRAC,
+ VracHorsVracEnum.values());
+ }
+
+ if (samplingOrder.contains(SpeciesBatchRowModel.PROPERTY_WEIGHT_CATEGORY)) {
+
+ // WeightCategory column
+
+ Decorator<WeightCategory> decorator =
+ getDecorator(WeightCategory.class,
+ DecoratorService.BY_NAME);
+
+ List<WeightCategory> data =
+ persistenceService.getAllWeightCategory();
+
+ addComboDataColumnToModel(columnModel,
+ SpeciesBatchTableModel.WEIGHT_CATEGORY,
+ decorator, data);
+ }
+
+ if (samplingOrder.contains(SpeciesBatchRowModel.PROPERTY_SEX)) {
+
+ // Sex column
+
+ Decorator<Sex> decorator =
+ getDecorator(Sex.class, DecoratorService.BY_NAME);
+
+ List<Sex> data = persistenceService.getAllSex();
+
+ addComboDataColumnToModel(columnModel,
+ SpeciesBatchTableModel.SEX,
+ decorator, data);
+ }
+
+ if (samplingOrder.contains(SpeciesBatchRowModel.PROPERTY_MATURITY)) {
+
+ // Maturity column
+
+ addFloatColumnToModel(columnModel,
+ SpeciesBatchTableModel.MATURITY,
+ TuttiUI.DECIMAL3_PATTERN);
+ }
+
+ if (samplingOrder.contains(SpeciesBatchRowModel.PROPERTY_AGE)) {
+
+ // Age column
+
+ addFloatColumnToModel(columnModel,
+ SpeciesBatchTableModel.AGE,
+ TuttiUI.DECIMAL3_PATTERN);
+ }
+
+ { // Weight column
+
+ addFloatColumnToModel(columnModel,
+ SpeciesBatchTableModel.WEIGHT,
+ TuttiUI.DECIMAL3_PATTERN);
+ }
+
+ { // Computed weight column (from frequencies)
+
+ addColumnToModel(columnModel,
+ FrequencyCellComponent.newEditor(ui.getFrequencyUI()),
+ FrequencyCellComponent.newRender(),
+ SpeciesBatchTableModel.COMPUTED_WEIGHT);
+ }
+
+ { // Computed number column (from frequencies)
+
+ addColumnToModel(columnModel,
+ FrequencyCellComponent.newEditor(ui.getFrequencyUI()),
+ FrequencyCellComponent.newRender(),
+ SpeciesBatchTableModel.COMPUTED_NUMBER);
+ }
+
+ { // Sample weight column
+
+ addColumnToModel(columnModel,
+ SpeciesBatchTableModel.SAMPLE_WEIGHT);
+ }
+
+ { // SamplingRatio column
+
+ addColumnToModel(columnModel,
+ SpeciesBatchTableModel.SAMPLING_RATIO);
+ }
+
+ { // Comment column
+
+ addColumnToModel(columnModel,
+ SpeciesBatchTableModel.COMMENT);
+ }
+
+ { // File column
+
+ addColumnToModel(columnModel,
+ SpeciesBatchTableModel.FILE);
+ }
+ return columnModel;
+ }
+
+ @Override
+ protected void onRowModified(SpeciesBatchRowModel row,
+ String propertyName,
+ Object oldValue,
+ Object newValue) {
+
+ if (RECOMPUTE_TOTAL_WEIGHT.contains(propertyName)) {
+
+ // Need to recompute totalHorsVracWeight
+ recomputeTotalHorsVrac();
+ }
+
+ SpeciesBatchUIModel model = getModel();
+
+ SpeciesBatchTreeModel samplingTreeModel = model.getSamplingTreeModel();
+
+ if (SAMPLING_PROPERTIES.contains(propertyName)) {
+
+ // Need to rebuilt this row sampling tree path (and then recompute
+ // old super - samplingRatio and new super - samplingRatio)
+
+ // old node of the previous sampling def for this row
+ // and remove it from any cache
+ SpeciesBatchTreeNode oldNode = samplingTreeModel.removeNodeFromCache(row);
+
+ boolean rowWasValid = row.isValid();
+ if (oldNode != null && rowWasValid) {
+
+ // remove this row from his super sampling
+ recomputeSuperSamplingRatio(samplingTreeModel, oldNode);
+ }
+
+ // get new sampling node
+ SpeciesBatchTreeNode newNode = samplingTreeModel.getSamplingNode(row);
+
+ // check this row is valid
+ boolean rowValid = samplingTreeModel.isValid(row, newNode);
+
+ // push this state back to the row
+ row.setValid(rowValid);
+
+ if (rowValid) {
+
+ // can add it to his super-sampling
+ recomputeSuperSamplingRatio(samplingTreeModel, newNode);
+ } else {
+
+ if (rowWasValid) {
+
+ row.setSampleWeight(null);
+ row.setSamplingRatio(null);
+
+ getTableModel().updateSamplingRatio(Sets.newHashSet(row));
+ }
+ }
+ }
+
+ if (SpeciesBatchRowModel.PROPERTY_WEIGHT.equals(propertyName)) {
+
+ // Need to recompute the super - samplingRatio
+
+ SpeciesBatchTreeNode node = samplingTreeModel.getSamplingNode(row);
+
+ boolean rowWasValid = row.isValid();
+
+ // check this row is valid
+ boolean rowValid = samplingTreeModel.isValid(row, node);
+
+ // push this state back to the row
+ row.setValid(rowValid);
+
+ if (rowValid) {
+ recomputeSuperSamplingRatio(samplingTreeModel, node);
+ } else {
+ if (rowWasValid) {
+
+ // must remove this row from his super-sampling
+ recomputeSuperSamplingRatio(samplingTreeModel, node);
+
+ row.setSampleWeight(null);
+ row.setSamplingRatio(null);
+
+ getTableModel().updateSamplingRatio(Sets.newHashSet(row));
+ }
+ }
+ }
+ }
+
+ @Override
+ protected void onRowValidStateChanged(SpeciesBatchRowModel row,
+ Boolean oldValue,
+ Boolean newValue) {
+ int rowIndex = getTableModel().getRowIndex(row);
+
+ if (rowIndex > -1) {
+ getTableModel().fireTableRowsUpdated(rowIndex, rowIndex);
+ }
+ }
+
+ @Override
+ protected void onRowModifyStateChanged(SpeciesBatchRowModel row,
+ Boolean oldValue,
+ Boolean newValue) {
+ }
+
+ //------------------------------------------------------------------------//
+ //-- AbstractTuttiUIHandler methods --//
+ //------------------------------------------------------------------------//
+
+ @Override
+ public void beforeInitUI() {
+
+ if (log.isInfoEnabled()) {
+ log.info("beforeInit: " + ui);
+ }
+
+ SpeciesBatchUIModel model = new SpeciesBatchUIModel();
+ ui.setContextValue(model);
+
+ fishingOperationMonitor.setBean(model);
+ }
+
+ @Override
+ public void afterInitUI() {
+
+ if (log.isInfoEnabled()) {
+ log.info("afterInit: " + ui);
+ }
+
+ initUI(ui);
+
+ //TODO Will come from protocol
+ List<String> samplingOrder = Lists.newArrayList(
+ SpeciesBatchRowModel.PROPERTY_SPECIES,
+ SpeciesBatchRowModel.PROPERTY_VRAC_HORS_VRAC,
+ SpeciesBatchRowModel.PROPERTY_WEIGHT_CATEGORY,
+ SpeciesBatchRowModel.PROPERTY_SEX
+ );
+
+ getModel().setSamplingOrder(samplingOrder);
+
+ JXTable table = getTable();
+
+ // create table column model
+ TableColumnModel columnModel = createTableColumnModel();
+
+ // create table model
+ SpeciesBatchTableModel tableModel =
+ new SpeciesBatchTableModel(columnModel);
+
+ table.setModel(tableModel);
+ table.setColumnModel(columnModel);
+ installTableKeyListener(columnModel, table);
+
+ table.getTableHeader().setReorderingAllowed(false);
+
+
+ Highlighter readOnlyHighlighter = TuttiUIUtil.newBackgroundColorHighlighter(
+ HighlightPredicate.READ_ONLY, Color.LIGHT_GRAY);
+
+ table.addHighlighter(readOnlyHighlighter);
+ Highlighter validHighlighter = TuttiUIUtil.newBackgroundColorHighlighter(
+ new HighlightPredicate.AndHighlightPredicate(HighlightPredicate.EDITABLE, new HighlightPredicate() {
+ @Override
+ public boolean isHighlighted(Component renderer, ComponentAdapter adapter) {
+
+ boolean result = false;
+ if (adapter.isEditable()) {
+ int rowIndex = adapter.convertRowIndexToModel(adapter.row);
+ SpeciesBatchRowModel row = getTableModel().getEntry(rowIndex);
+ result = !row.isValid();
+ }
+ return result;
+ }
+ }), Color.RED);
+ table.addHighlighter(validHighlighter);
+
+ // when model datas change let's propagate it table model
+ listenRowsFromModel();
+
+ // save when row chaged and was modified
+ ListSelectionListener listener = new TableRowModificationListener<SpeciesBatchRowModel>(
+ getTableModel(), getRowMonitor()) {
+ @Override
+ protected void saveSelectedRow() {
+ saveSelectedRowIfRequired();
+ }
+ };
+ table.getSelectionModel().addListSelectionListener(listener);
+
+ // always scroll to selected row
+ SwingUtil.scrollToTableSelection(getTable());
+ }
+
+ @Override
+ public void onCloseUI() {
+ if (log.isInfoEnabled()) {
+ log.info("closing: " + ui);
+ }
+ }
+
+ //------------------------------------------------------------------------//
+ //-- Public methods --//
+ //------------------------------------------------------------------------//
+
+ public void saveSelectedRowIfRequired(FocusEvent event) {
+
+ Component oppositeComponent = event.getOppositeComponent();
+
+ JXTable parentContainer = null;
+
+ if (oppositeComponent != null) {
+
+ // check out if still on table
+ parentContainer = SwingUtil.getParentContainer(
+ oppositeComponent, JXTable.class);
+ }
+
+ if (parentContainer == null) {
+
+ // out of the table can save
+ if (getModel().getFishingOperation() != null) {
+ saveSelectedRowIfRequired();
+ }
+ }
+ }
+
+ public void selectFishingOperation(FishingOperation bean) {
+
+ JXTable table = ui.getTable();
+
+ if (table.isEditing()) {
+
+ // make sure to stop editor
+ table.editingCanceled(null);
+ }
+
+ if (fishingOperationMonitor.wasModified()) {
+
+ // previous fishingOperation was modified, let's save it
+ SpeciesBatchUIModel beanToSave = fishingOperationMonitor.getBean();
+
+ FishingOperation fishingOperation = beanToSave.toBean();
+
+ if (log.isInfoEnabled()) {
+ log.info("FishingOperation " + fishingOperation.getId() +
+ " was modified, will save it.");
+ }
+
+ persistenceService.saveFishingOperation(fishingOperation);
+ }
+
+ // make sure selection is empty (will remove bean from monitor)
+ table.clearSelection();
+
+ boolean empty = bean == null;
+
+ SpeciesBatchUIModel model = getModel();
+
+ List<SpeciesBatchRowModel> rows;
+
+ if (empty) {
+ rows = null;
+ bean = new FishingOperation();
+ model.setFishingOperation(null);
+ } else {
+
+ if (log.isInfoEnabled()) {
+ log.info("Get species batch for fishingOperation: " + bean.getId());
+ }
+ rows = Lists.newArrayList();
+
+ if (!TuttiEntities.isNew(bean)) {
+ List<SpeciesBatch> catches =
+ persistenceService.getAllSpeciesBatch(bean.getId());
+ for (SpeciesBatch aBatch : catches) {
+ List<SpeciesBatchFrequency> frequencies =
+ persistenceService.getAllSpeciesBatchFrequency(aBatch.getId());
+ SpeciesBatchRowModel entry =
+ new SpeciesBatchRowModel(aBatch, frequencies);
+ rows.add(entry);
+ }
+ }
+ model.setFishingOperation(bean);
+ }
+
+ model.fromBean(bean);
+ model.setRows(rows);
+
+ fishingOperationMonitor.clearModified();
+ }
+
+ //------------------------------------------------------------------------//
+ //-- Internal methods --//
+ //------------------------------------------------------------------------//
+
+ protected void recomputeSuperSamplingRatio(SpeciesBatchTreeModel samplingTreeModel,
+ SpeciesBatchTreeNode node) {
+
+ SpeciesBatchTreeNode superSamplingNode = node.getParent();
+
+ Preconditions.checkNotNull(superSamplingNode,
+ "Super sampling node can't be null");
+
+ SpeciesBatchTreeModel.SamplingContext samplingContext =
+ samplingTreeModel.createSamplingContext(superSamplingNode);
+
+ float samplingTotalWeight = samplingContext.getTotalWeight();
+ Float superSamplingTotalWeight;
+ SpeciesBatchRowModel superSamplingRow =
+ samplingContext.getSuperSamplingRow();
+ if (superSamplingRow == null) {
+
+ // Use directly the batch total weight (means no super-sampling)
+
+ superSamplingTotalWeight = getModel().getTotalWeight();
+ } else {
+ superSamplingTotalWeight = superSamplingRow.getWeight();
+ }
+
+ if (log.isInfoEnabled()) {
+ log.info("Super sampling total weight: " +
+ superSamplingTotalWeight);
+ }
+
+ Float samplingRatio = null;
+ if (superSamplingTotalWeight != null) {
+ samplingRatio = samplingTotalWeight / superSamplingTotalWeight;
+ }
+
+ if (log.isInfoEnabled()) {
+ log.info("Sampling ratio: " + samplingRatio);
+ }
+
+ samplingContext.applyNewSampleValues(samplingTotalWeight,
+ samplingRatio);
+
+ getTableModel().updateSamplingRatio(samplingContext.getSamplingRows());
+ }
+
+
+ protected void recomputeTotalHorsVrac() {
+
+ // recompute total hors vrac
+ Float totalHorsVrac = 0f;
+ Float totalVrac = 0f;
+
+ for (SpeciesBatchRowModel batch : getModel().getRows()) {
+ VracHorsVracEnum vracHorsVrac = batch.getVracHorsVrac();
+ if (vracHorsVrac == null) {
+
+ // can't sum anything
+ } else if (vracHorsVrac == VracHorsVracEnum.HORS_VRAC) {
+ Float weight = batch.getWeight();
+ if (weight != null) {
+ totalHorsVrac += weight;
+ }
+ } else if (vracHorsVrac == VracHorsVracEnum.VRAC) {
+ Float weight = batch.getWeight();
+ if (weight != null) {
+ totalVrac += weight;
+ }
+ }
+ }
+ if (log.isInfoEnabled()) {
+ log.info("New total vrac / hors vrac: " +
+ totalVrac + " / " + totalHorsVrac);
+ }
+ getModel().setTotalHorsVracWeight(totalHorsVrac);
+ //TODO Should we also set the total vrac weight ?
+// getModel().setTotalVracWeight(totalVrac);
+ }
+
+ protected void saveSelectedRowIfRequired() {
+
+ TuttiBeanMonitor<SpeciesBatchRowModel> rowMonitor = getRowMonitor();
+
+ SpeciesBatchRowModel bean = rowMonitor.getBean();
+ if (bean != null) {
+
+ if (bean.isValid()) {
+ // there is a valid bean attached to the monitor
+
+ if (rowMonitor.wasModified()) {
+
+ // monitored bean was modified, save it
+ if (log.isInfoEnabled()) {
+ log.info("Row " + bean + " was modified, will save it");
+ }
+
+ saveRow(bean);
+
+ // clear modified flag on the monitor
+ rowMonitor.clearModified();
+ }
+ } else {
+
+ // row is not valid can not save it
+
+ SpeciesBatch catchBean = bean.toBean();
+
+ if (!TuttiEntities.isNew(catchBean)) {
+
+ // remove this
+ persistenceService.deleteSpeciesBatch(catchBean.getId());
+ }
+ }
+ }
+ }
+
+ protected void saveRow(SpeciesBatchRowModel row) {
+
+ SpeciesBatch catchBean = row.toBean();
+
+ FishingOperation fishingOperation = getModel().getFishingOperation();
+ catchBean.setFishingOperation(fishingOperation);
+ if (log.isInfoEnabled()) {
+ log.info("Selected fishingOperation: " + fishingOperation.getId());
+ }
+
+ if (TuttiEntities.isNew(catchBean)) {
+
+ catchBean = persistenceService.createSpeciesBatch(catchBean);
+ row.setId(catchBean.getId());
+ } else {
+ persistenceService.saveSpeciesBatch(catchBean);
+ }
+
+ List<SpeciesFrequencyRowModel> frequencyRows = row.getFrequency();
+
+ List<SpeciesBatchFrequency> frequency =
+ SpeciesFrequencyRowModel.toBeans(frequencyRows, catchBean);
+
+ if (log.isInfoEnabled()) {
+ log.info("Will save " + frequency.size() + " frequencies.");
+ }
+ frequency = persistenceService.saveSpeciesBatchFrequency(
+ catchBean.getId(), frequency);
+
+ // push it back to row model
+ frequencyRows = SpeciesFrequencyRowModel.fromBeans(frequency);
+ row.setFrequency(frequencyRows);
+ }
+}
Property changes on: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/species/SpeciesBatchUIHandler.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Copied: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/species/SpeciesBatchUIModel.java (from rev 48, trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/species/SpeciesTabUIModel.java)
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/species/SpeciesBatchUIModel.java (rev 0)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/species/SpeciesBatchUIModel.java 2012-12-13 01:57:28 UTC (rev 55)
@@ -0,0 +1,184 @@
+package fr.ifremer.tutti.ui.swing.content.operation.species;
+
+/*
+ * #%L
+ * Tutti :: UI
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 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.entities.data.FishingOperation;
+import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableUIModel;
+import org.nuiton.util.beans.Binder;
+import org.nuiton.util.beans.BinderModelBuilder;
+
+import java.util.List;
+
+/**
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 0.1
+ */
+public class SpeciesBatchUIModel extends AbstractTuttiTableUIModel<FishingOperation, SpeciesBatchRowModel, SpeciesBatchUIModel> {
+
+ private static final long serialVersionUID = 1L;
+
+ public static final String PROPERTY_TOTAL_WEIGHT = "totalWeight";
+
+ public static final String PROPERTY_TOTAL_VRAC_WEIGHT = "totalVracWeight";
+
+ public static final String PROPERTY_SAMPLE_VRAC_WEIGHT = "sampleVracWeight";
+
+ public static final String PROPERTY_TOTAL_HORS_VRAC_WEIGHT = "totalHorsVracWeight";
+
+ /**
+ * Editing fishing operation.
+ *
+ * @since 0.2
+ */
+ protected FishingOperation fishingOperation;
+
+ /**
+ * Total Weight filled in screen.
+ *
+ * @since 0.2
+ */
+ protected Float totalWeight;
+
+ /**
+ * Total vrac Weight filled in screen.
+ *
+ * @since 0.2
+ */
+ protected Float totalVracWeight;
+
+ /**
+ * Total sample vrac Weight filled in screen.
+ *
+ * @since 0.2
+ */
+ protected Float sampleVracWeight;
+
+ /**
+ * Total hors vrac Weight computed by hros vrac rows.
+ *
+ * @since 0.2
+ */
+ protected Float totalHorsVracWeight;
+
+ /**
+ * Sampling order (sets by protocol).
+ *
+ * @since 0.2
+ */
+ protected List<String> samplingOrder;
+
+ /**
+ * Tree of sampling for batch rows.
+ *
+ * @since 0.2
+ */
+ protected final SpeciesBatchTreeModel samplingTreeModel;
+
+ protected static final Binder<FishingOperation, SpeciesBatchUIModel> fromBeanBinder = BinderModelBuilder.newEmptyBuilder(FishingOperation.class, SpeciesBatchUIModel.class)
+ .addProperty(FishingOperation.PROPERTY_SPECIES_TOTAL_WEIGHT, PROPERTY_TOTAL_WEIGHT)
+ .addProperty(FishingOperation.PROPERTY_SPECIES_TOTAL_HORS_VRAC_WEIGHT, PROPERTY_TOTAL_HORS_VRAC_WEIGHT)
+ .addProperty(FishingOperation.PROPERTY_SPECIES_TOTAL_VRAC_WEIGHT, PROPERTY_TOTAL_VRAC_WEIGHT)
+ .addProperty(FishingOperation.PROPERTY_SPECIES_SAMPLE_VRAC_WEIGHT, PROPERTY_SAMPLE_VRAC_WEIGHT)
+ .addProperty(FishingOperation.PROPERTY_ID, PROPERTY_ID)
+ .toBinder();
+
+ protected static final Binder<SpeciesBatchUIModel, FishingOperation> toBeanBinder = BinderModelBuilder.newEmptyBuilder(SpeciesBatchUIModel.class, FishingOperation.class)
+ .addProperty(PROPERTY_TOTAL_WEIGHT, FishingOperation.PROPERTY_SPECIES_TOTAL_WEIGHT)
+ .addProperty(PROPERTY_TOTAL_HORS_VRAC_WEIGHT, FishingOperation.PROPERTY_SPECIES_TOTAL_HORS_VRAC_WEIGHT)
+ .addProperty(PROPERTY_TOTAL_VRAC_WEIGHT, FishingOperation.PROPERTY_SPECIES_TOTAL_VRAC_WEIGHT)
+ .addProperty(PROPERTY_SAMPLE_VRAC_WEIGHT, FishingOperation.PROPERTY_SPECIES_SAMPLE_VRAC_WEIGHT)
+ .toBinder();
+
+ public SpeciesBatchUIModel() {
+ super(FishingOperation.class, fromBeanBinder, toBeanBinder);
+ this.samplingTreeModel = new SpeciesBatchTreeModel();
+ }
+
+ public FishingOperation getFishingOperation() {
+ return fishingOperation;
+ }
+
+ public void setFishingOperation(FishingOperation fishingOperation) {
+ this.fishingOperation = fishingOperation;
+ }
+
+ public SpeciesBatchTreeModel getSamplingTreeModel() {
+ return samplingTreeModel;
+ }
+
+ public Float getTotalWeight() {
+ return totalWeight;
+ }
+
+ public void setTotalWeight(Float totalWeight) {
+ Object oldValue = getTotalWeight();
+ this.totalWeight = totalWeight;
+ firePropertyChange(PROPERTY_TOTAL_WEIGHT, oldValue, totalWeight);
+ }
+
+ public Float getTotalVracWeight() {
+ return totalVracWeight;
+ }
+
+ public void setTotalVracWeight(Float totalVracWeight) {
+ Object oldValue = getTotalVracWeight();
+ this.totalVracWeight = totalVracWeight;
+ firePropertyChange(PROPERTY_TOTAL_VRAC_WEIGHT, oldValue, totalVracWeight);
+ }
+
+ public Float getSampleVracWeight() {
+ return sampleVracWeight;
+ }
+
+ public void setSampleVracWeight(Float sampleVracWeight) {
+ Object oldValue = getSampleVracWeight();
+ this.sampleVracWeight = sampleVracWeight;
+ firePropertyChange(PROPERTY_SAMPLE_VRAC_WEIGHT, oldValue, sampleVracWeight);
+ }
+
+ public Float getTotalHorsVracWeight() {
+ return totalHorsVracWeight;
+ }
+
+ public void setTotalHorsVracWeight(Float totalHorsVracWeight) {
+ Object oldValue = getTotalHorsVracWeight();
+ this.totalHorsVracWeight = totalHorsVracWeight;
+ firePropertyChange(PROPERTY_TOTAL_HORS_VRAC_WEIGHT, oldValue, totalHorsVracWeight);
+ }
+
+ public List<String> getSamplingOrder() {
+ return samplingOrder;
+ }
+
+ public void setSamplingOrder(List<String> samplingOrder) {
+ this.samplingOrder = samplingOrder;
+ samplingTreeModel.setSamplingOrder(samplingOrder.toArray(new String[samplingOrder.size()]));
+ }
+
+ @Override
+ protected FishingOperation newEntity() {
+ return fishingOperation;
+ }
+}
Property changes on: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/species/SpeciesBatchUIModel.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Deleted: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/species/SpeciesTabUI.css
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/species/SpeciesTabUI.css 2012-12-12 22:50:50 UTC (rev 54)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/species/SpeciesTabUI.css 2012-12-13 01:57:28 UTC (rev 55)
@@ -1,83 +0,0 @@
-/*
- * #%L
- * Tutti :: UI
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2012 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%
- */
-
-NumberEditor {
- autoPopup: {handler.getConfig().isAutoPopupNumberEditor()};
- showPopupButton: {handler.getConfig().isShowNumberEditorButton()};
- bean: {model};
- showReset: true;
-}
-
-#totalWeightLabel {
- text: "tutti.label.species.totalWeight";
- labelFor: {totalWeightField};
-}
-
-#totalWeightField {
- property: "totalWeight";
- model: {model.getTotalWeight()};
- useFloat: false;
- numberPattern: {INT_6_DIGITS_PATTERN};
-}
-
-#totalVracWeightLabel {
- text: "tutti.label.species.totalVracWeight";
- labelFor: {totalVracWeightField};
-}
-
-#totalVracWeightField {
- property: "totalVracWeight";
- model: {model.getTotalVracWeight()};
- useFloat: false;
- numberPattern: {INT_6_DIGITS_PATTERN};
-}
-
-#sampleVracWeightLabel {
- text: "tutti.label.species.sampleVracWeight";
- labelFor: {sampleVracWeightField};
-}
-
-#sampleVracWeightField {
- property: "sampleVracWeight";
- model: {model.getSampleVracWeight()};
- useFloat: false;
- numberPattern: {INT_6_DIGITS_PATTERN};
-}
-
-#totalHorsVracWeightLabel {
- text: "tutti.label.species.totalHorsVracWeight";
- labelFor: {totalHorsVracWeightField};
-}
-
-#totalHorsVracWeightField {
- text: {getStringValue(model.getTotalHorsVracWeight())};
- editable: false;
-}
-
-#table {
- selectionMode: {ListSelectionModel.SINGLE_SELECTION};
- selectionBackground: {null};
- selectionForeground: {Color.BLACK};
- sortable: false;
-}
Deleted: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/species/SpeciesTabUI.jaxx
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/species/SpeciesTabUI.jaxx 2012-12-12 22:50:50 UTC (rev 54)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/species/SpeciesTabUI.jaxx 2012-12-13 01:57:28 UTC (rev 55)
@@ -1,119 +0,0 @@
-<!--
- #%L
- Tutti :: UI
- $Id$
- $HeadURL$
- %%
- Copyright (C) 2012 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%
- -->
-<JPanel id='homePanel' layout='{new BorderLayout()}'
- implements='fr.ifremer.tutti.ui.swing.TuttiUI<SpeciesTabUIModel, SpeciesTabUIHandler>'>
-
- <import>
- fr.ifremer.tutti.persistence.entities.data.FishingOperation
-
- fr.ifremer.tutti.ui.swing.TuttiUIContext
- fr.ifremer.tutti.ui.swing.content.operation.FishingOperationsUI
- fr.ifremer.tutti.ui.swing.content.operation.species.SpeciesFrequencyUI
-
- org.jdesktop.swingx.JXTable
-
- jaxx.runtime.swing.editor.NumberEditor
-
- jaxx.runtime.validator.swing.SwingValidatorUtil
- jaxx.runtime.validator.swing.SwingValidatorMessageTableModel
-
- javax.swing.ListSelectionModel
-
- java.awt.Color
-
- static org.nuiton.i18n.I18n._
- static jaxx.runtime.SwingUtil.getStringValue
- </import>
-
- <script><![CDATA[
-
-public SpeciesTabUI(FishingOperationsUI parentUI) {
- SpeciesTabUIHandler handler = new SpeciesTabUIHandler(parentUI, this);
- setContextValue(handler);
- handler.beforeInitUI();
-}
-
-public void selectFishingOperation(FishingOperation fishingOperation) { handler.selectFishingOperation(fishingOperation); }
-
-protected void $afterCompleteSetup() { handler.afterInitUI(); }
- ]]></script>
-
- <SpeciesTabUIHandler id='handler'
- initializer='getContextValue(SpeciesTabUIHandler.class)'/>
-
- <SpeciesTabUIModel id='model'
- initializer='getContextValue(SpeciesTabUIModel.class)'/>
-
- <SwingValidatorMessageTableModel id='errorTableModel'/>
-
- <BeanValidator id='validator' bean='model' errorTableModel='errorTableModel'
- uiClass='jaxx.runtime.validator.swing.ui.ImageValidationUI'>
- <field name='totalWeight' component='totalWeightField'/>
- <field name='totalVracWeight' component='totalVracWeightField'/>
- <field name='sampleVracWeight' component='sampleVracWeightField'/>
- <field name='totalHorsVracWeight' component='totalHorsVracWeightField'/>
- </BeanValidator>
-
- <SpeciesFrequencyUI id='frequencyUI' constructorParams='handler.getContext()'/>
-
- <Table id='form' fill='both' constraints='BorderLayout.NORTH'>
-
- <!-- Poids total / Poids total vrac -->
- <row>
- <cell anchor='west'>
- <JLabel id='totalWeightLabel'/>
- </cell>
- <cell weightx='1.0'>
- <NumberEditor id='totalWeightField' constructorParams='this'/>
- </cell>
- <cell anchor='west'>
- <JLabel id='totalVracWeightLabel'/>
- </cell>
- <cell weightx='1.0'>
- <NumberEditor id='totalVracWeightField' constructorParams='this'/>
- </cell>
- </row>
-
- <!-- Poids échantillonné vrac / Poids total hors vrac -->
- <row>
- <cell>
- <JLabel id='sampleVracWeightLabel'/>
- </cell>
- <cell>
- <NumberEditor id='sampleVracWeightField' constructorParams='this'/>
- </cell>
- <cell>
- <JLabel id='totalHorsVracWeightLabel'/>
- </cell>
- <cell>
- <JTextField id='totalHorsVracWeightField'/>
- </cell>
- </row>
- </Table>
-
- <JScrollPane id='tableScrollPane' constraints='BorderLayout.CENTER'>
- <JXTable id='table' onFocusLost='handler.saveSelectedRowIfRequired(event);'/>
- </JScrollPane>
-
-</JPanel>
Deleted: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/species/SpeciesTabUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/species/SpeciesTabUIHandler.java 2012-12-12 22:50:50 UTC (rev 54)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/species/SpeciesTabUIHandler.java 2012-12-13 01:57:28 UTC (rev 55)
@@ -1,762 +0,0 @@
-package fr.ifremer.tutti.ui.swing.content.operation.species;
-
-/*
- * #%L
- * Tutti :: UI
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2012 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.Lists;
-import com.google.common.collect.Sets;
-import fr.ifremer.tutti.persistence.entities.TuttiEntities;
-import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
-import fr.ifremer.tutti.persistence.entities.data.SpeciesBatch;
-import fr.ifremer.tutti.persistence.entities.data.SpeciesBatchFrequency;
-import fr.ifremer.tutti.persistence.entities.data.VracHorsVracEnum;
-import fr.ifremer.tutti.persistence.entities.referential.Sex;
-import fr.ifremer.tutti.persistence.entities.referential.Species;
-import fr.ifremer.tutti.persistence.entities.referential.WeightCategory;
-import fr.ifremer.tutti.service.DecoratorService;
-import fr.ifremer.tutti.service.PersistenceService;
-import fr.ifremer.tutti.ui.swing.TuttiUI;
-import fr.ifremer.tutti.ui.swing.content.operation.FishingOperationsUI;
-import fr.ifremer.tutti.ui.swing.util.TuttiBeanMonitor;
-import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil;
-import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableUIHandler;
-import fr.ifremer.tutti.ui.swing.util.table.TableRowModificationListener;
-import jaxx.runtime.SwingUtil;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.jdesktop.swingx.JXTable;
-import org.jdesktop.swingx.decorator.ComponentAdapter;
-import org.jdesktop.swingx.decorator.HighlightPredicate;
-import org.jdesktop.swingx.decorator.Highlighter;
-import org.jdesktop.swingx.table.DefaultTableColumnModelExt;
-import org.nuiton.util.beans.BeanMonitor;
-import org.nuiton.util.decorator.Decorator;
-
-import javax.swing.event.ListSelectionListener;
-import javax.swing.table.TableColumnModel;
-import java.awt.Color;
-import java.awt.Component;
-import java.awt.event.FocusEvent;
-import java.util.List;
-import java.util.Set;
-
-/**
- * @author tchemit <chemit(a)codelutin.com>
- * @since 0.1
- */
-public class SpeciesTabUIHandler extends AbstractTuttiTableUIHandler<SpeciesBatchRowModel, SpeciesTabUIModel> {
-
- /** Logger. */
- private static final Log log = LogFactory.getLog(SpeciesTabUIHandler.class);
-
- public static final Set<String> RECOMPUTE_TOTAL_WEIGHT = Sets.newHashSet(
- SpeciesBatchRowModel.PROPERTY_VRAC_HORS_VRAC,
- SpeciesBatchRowModel.PROPERTY_WEIGHT
- );
-
- public static final Set<String> SAMPLING_PROPERTIES = Sets.newHashSet(
- SpeciesBatchRowModel.PROPERTY_SPECIES,
- SpeciesBatchRowModel.PROPERTY_VRAC_HORS_VRAC,
- SpeciesBatchRowModel.PROPERTY_WEIGHT_CATEGORY,
- SpeciesBatchRowModel.PROPERTY_SEX,
- SpeciesBatchRowModel.PROPERTY_MATURITY,
- SpeciesBatchRowModel.PROPERTY_AGE
- );
-
- /**
- * UI.
- *
- * @since 0.2
- */
- private final SpeciesTabUI ui;
-
- /**
- * Persistence service.
- *
- * @since 0.2
- */
- private final PersistenceService persistenceService;
-
- /**
- * To monitor changes on the fishing operation.
- *
- * @since 0.2
- */
- private final BeanMonitor fishingOperationMonitor;
-
- public SpeciesTabUIHandler(FishingOperationsUI parentUi, SpeciesTabUI ui) {
- super(parentUi.getHandler().getContext(),
- SpeciesBatchRowModel.PROPERTY_SPECIES_TO_CONFIRM,
- SpeciesBatchRowModel.PROPERTY_SPECIES,
- SpeciesBatchRowModel.PROPERTY_VRAC_HORS_VRAC,
- SpeciesBatchRowModel.PROPERTY_WEIGHT_CATEGORY,
- SpeciesBatchRowModel.PROPERTY_SEX,
- SpeciesBatchRowModel.PROPERTY_MATURITY,
- SpeciesBatchRowModel.PROPERTY_AGE,
- SpeciesBatchRowModel.PROPERTY_WEIGHT,
-// SpeciesBatchRowModel.PROPERTY_SAMPLE_WEIGHT,
-// SpeciesBatchRowModel.PROPERTY_SAMPLING_RATIO,
- SpeciesBatchRowModel.PROPERTY_COMMENT,
- SpeciesBatchRowModel.PROPERTY_FREQUENCY);
- this.ui = ui;
- this.persistenceService = context.getService(PersistenceService.class);
- this.fishingOperationMonitor = new BeanMonitor(
- SpeciesTabUIModel.PROPERTY_SAMPLE_VRAC_WEIGHT,
- SpeciesTabUIModel.PROPERTY_TOTAL_HORS_VRAC_WEIGHT,
- SpeciesTabUIModel.PROPERTY_TOTAL_VRAC_WEIGHT,
- SpeciesTabUIModel.PROPERTY_TOTAL_WEIGHT
- );
- }
-
- //------------------------------------------------------------------------//
- //-- AbstractTuttiTableUIHandler methods --//
- //------------------------------------------------------------------------//
-
- @Override
- protected SpeciesTabUIModel getModel() {
- return ui.getModel();
- }
-
- @Override
- protected SpeciesBatchTableModel getTableModel() {
- return (SpeciesBatchTableModel) getTable().getModel();
- }
-
- @Override
- protected JXTable getTable() {
- return ui.getTable();
- }
-
- @Override
- protected void onModelRowsChanged(List<SpeciesBatchRowModel> rows) {
- super.onModelRowsChanged(rows);
-
- // build the new sampling tree from the new rows to edit
- getModel().getSamplingTreeModel().populate(rows);
- }
-
- @Override
- protected String[] getRowPropertiesToIgnore() {
- return new String[]{
- SpeciesBatchRowModel.PROPERTY_SAMPLE_WEIGHT,
- SpeciesBatchRowModel.PROPERTY_SAMPLING_RATIO,
- SpeciesBatchRowModel.PROPERTY_FREQUENCY
- };
- }
-
- @Override
- protected TableColumnModel createTableColumnModel() {
-
- List<String> samplingOrder = getModel().getSamplingOrder();
-
- DefaultTableColumnModelExt columnModel =
- new DefaultTableColumnModelExt();
-
- {
- // Species to confirm column
-
- addBooleanColumnToModel(columnModel,
- SpeciesBatchTableModel.SPECIES_TO_CONFIRM,
- getTable());
- }
-
- List<Species> allSpecies = persistenceService.getAllSpecies();
-
- {
- // Species (by code) column
-
- Decorator<Species> decorator = getDecorator(
- Species.class, DecoratorService.SPECIES_BY_CODE);
-
- addComboDataColumnToModel(columnModel,
- SpeciesBatchTableModel.SPECIES_BY_CODE,
- decorator, allSpecies);
- }
-
- {
- // Species (by genusCode) column
-
- Decorator<Species> decorator = getDecorator(
- Species.class, DecoratorService.SPECIES_BY_GENUS);
-
- addComboDataColumnToModel(columnModel,
- SpeciesBatchTableModel.SPECIES_BY_GENUS_CODE,
- decorator, allSpecies);
-
- }
-
- if (samplingOrder.contains(SpeciesBatchRowModel.PROPERTY_VRAC_HORS_VRAC)) {
-
- // Vrac / Hors vrac column
-
- addComboEnumColumnToModel(columnModel,
- SpeciesBatchTableModel.VRAC_HORS_VRAC,
- VracHorsVracEnum.values());
- }
-
- if (samplingOrder.contains(SpeciesBatchRowModel.PROPERTY_WEIGHT_CATEGORY)) {
-
- // WeightCategory column
-
- Decorator<WeightCategory> decorator =
- getDecorator(WeightCategory.class,
- DecoratorService.BY_NAME);
-
- List<WeightCategory> data =
- persistenceService.getAllWeightCategory();
-
- addComboDataColumnToModel(columnModel,
- SpeciesBatchTableModel.WEIGHT_CATEGORY,
- decorator, data);
- }
-
- if (samplingOrder.contains(SpeciesBatchRowModel.PROPERTY_SEX)) {
-
- // Sex column
-
- Decorator<Sex> decorator =
- getDecorator(Sex.class, DecoratorService.BY_NAME);
-
- List<Sex> data = persistenceService.getAllSex();
-
- addComboDataColumnToModel(columnModel,
- SpeciesBatchTableModel.SEX,
- decorator, data);
- }
-
- if (samplingOrder.contains(SpeciesBatchRowModel.PROPERTY_MATURITY)) {
-
- // Maturity column
-
- addFloatColumnToModel(columnModel,
- SpeciesBatchTableModel.MATURITY,
- TuttiUI.DECIMAL3_PATTERN);
- }
-
- if (samplingOrder.contains(SpeciesBatchRowModel.PROPERTY_AGE)) {
-
- // Age column
-
- addFloatColumnToModel(columnModel,
- SpeciesBatchTableModel.AGE,
- TuttiUI.DECIMAL3_PATTERN);
- }
-
- { // Weight column
-
- addFloatColumnToModel(columnModel,
- SpeciesBatchTableModel.WEIGHT,
- TuttiUI.DECIMAL3_PATTERN);
- }
-
- { // Computed weight column (from frequencies)
-
- addColumnToModel(columnModel,
- FrequencyCellComponent.newEditor(ui.getFrequencyUI()),
- FrequencyCellComponent.newRender(),
- SpeciesBatchTableModel.COMPUTED_WEIGHT);
- }
-
- { // Computed number column (from frequencies)
-
- addColumnToModel(columnModel,
- FrequencyCellComponent.newEditor(ui.getFrequencyUI()),
- FrequencyCellComponent.newRender(),
- SpeciesBatchTableModel.COMPUTED_NUMBER);
- }
-
- { // Sample weight column
-
- addColumnToModel(columnModel,
- SpeciesBatchTableModel.SAMPLE_WEIGHT);
- }
-
- { // SamplingRatio column
-
- addColumnToModel(columnModel,
- SpeciesBatchTableModel.SAMPLING_RATIO);
- }
-
- { // Comment column
-
- addColumnToModel(columnModel,
- SpeciesBatchTableModel.COMMENT);
- }
-
- { // File column
-
- addColumnToModel(columnModel,
- SpeciesBatchTableModel.FILE);
- }
- return columnModel;
- }
-
- @Override
- protected void onRowModified(SpeciesBatchRowModel row,
- String propertyName,
- Object oldValue,
- Object newValue) {
-
- if (RECOMPUTE_TOTAL_WEIGHT.contains(propertyName)) {
-
- // Need to recompute totalHorsVracWeight
- recomputeTotalHorsVrac();
- }
-
- SpeciesTabUIModel model = getModel();
-
- SpeciesBatchTreeModel samplingTreeModel = model.getSamplingTreeModel();
-
- if (SAMPLING_PROPERTIES.contains(propertyName)) {
-
- // Need to rebuilt this row sampling tree path (and then recompute
- // old super - samplingRatio and new super - samplingRatio)
-
- // old node of the previous sampling def for this row
- // and remove it from any cache
- SpeciesBatchTreeNode oldNode = samplingTreeModel.removeNodeFromCache(row);
-
- boolean rowWasValid = row.isValid();
- if (oldNode != null && rowWasValid) {
-
- // remove this row from his super sampling
- recomputeSuperSamplingRatio(samplingTreeModel, oldNode);
- }
-
- // get new sampling node
- SpeciesBatchTreeNode newNode = samplingTreeModel.getSamplingNode(row);
-
- // check this row is valid
- boolean rowValid = samplingTreeModel.isValid(row, newNode);
-
- // push this state back to the row
- row.setValid(rowValid);
-
- if (rowValid) {
-
- // can add it to his super-sampling
- recomputeSuperSamplingRatio(samplingTreeModel, newNode);
- } else {
-
- if (rowWasValid) {
-
- row.setSampleWeight(null);
- row.setSamplingRatio(null);
-
- getTableModel().updateSamplingRatio(Sets.newHashSet(row));
- }
- }
- }
-
- if (SpeciesBatchRowModel.PROPERTY_WEIGHT.equals(propertyName)) {
-
- // Need to recompute the super - samplingRatio
-
- SpeciesBatchTreeNode node = samplingTreeModel.getSamplingNode(row);
-
- boolean rowWasValid = row.isValid();
-
- // check this row is valid
- boolean rowValid = samplingTreeModel.isValid(row, node);
-
- // push this state back to the row
- row.setValid(rowValid);
-
- if (rowValid) {
- recomputeSuperSamplingRatio(samplingTreeModel, node);
- } else {
- if (rowWasValid) {
-
- // must remove this row from his super-sampling
- recomputeSuperSamplingRatio(samplingTreeModel, node);
-
- row.setSampleWeight(null);
- row.setSamplingRatio(null);
-
- getTableModel().updateSamplingRatio(Sets.newHashSet(row));
- }
- }
- }
- }
-
- @Override
- protected void onRowValidStateChanged(SpeciesBatchRowModel row,
- Boolean oldValue,
- Boolean newValue) {
- int rowIndex = getTableModel().getRowIndex(row);
-
- if (rowIndex > -1) {
- getTableModel().fireTableRowsUpdated(rowIndex, rowIndex);
- }
- }
-
- @Override
- protected void onRowModifyStateChanged(SpeciesBatchRowModel row,
- Boolean oldValue,
- Boolean newValue) {
- }
-
- //------------------------------------------------------------------------//
- //-- AbstractTuttiUIHandler methods --//
- //------------------------------------------------------------------------//
-
- @Override
- public void beforeInitUI() {
-
- if (log.isInfoEnabled()) {
- log.info("beforeInit: " + ui);
- }
-
- SpeciesTabUIModel model = new SpeciesTabUIModel();
- ui.setContextValue(model);
-
- fishingOperationMonitor.setBean(model);
- }
-
- @Override
- public void afterInitUI() {
-
- if (log.isInfoEnabled()) {
- log.info("afterInit: " + ui);
- }
-
- initUI(ui);
-
- //TODO Will come from protocol
- List<String> samplingOrder = Lists.newArrayList(
- SpeciesBatchRowModel.PROPERTY_SPECIES,
- SpeciesBatchRowModel.PROPERTY_VRAC_HORS_VRAC,
- SpeciesBatchRowModel.PROPERTY_WEIGHT_CATEGORY,
- SpeciesBatchRowModel.PROPERTY_SEX
- );
-
- getModel().setSamplingOrder(samplingOrder);
-
- JXTable table = getTable();
-
- // create table column model
- TableColumnModel columnModel = createTableColumnModel();
-
- // create table model
- SpeciesBatchTableModel tableModel =
- new SpeciesBatchTableModel(columnModel);
-
- table.setModel(tableModel);
- table.setColumnModel(columnModel);
- installTableKeyListener(columnModel, table);
-
- table.getTableHeader().setReorderingAllowed(false);
-
-
- Highlighter readOnlyHighlighter = TuttiUIUtil.newBackgroundColorHighlighter(
- HighlightPredicate.READ_ONLY, Color.LIGHT_GRAY);
-
- table.addHighlighter(readOnlyHighlighter);
- Highlighter validHighlighter = TuttiUIUtil.newBackgroundColorHighlighter(
- new HighlightPredicate.AndHighlightPredicate(HighlightPredicate.EDITABLE, new HighlightPredicate() {
- @Override
- public boolean isHighlighted(Component renderer, ComponentAdapter adapter) {
-
- boolean result = false;
- if (adapter.isEditable()) {
- int rowIndex = adapter.convertRowIndexToModel(adapter.row);
- SpeciesBatchRowModel row = getTableModel().getEntry(rowIndex);
- result = !row.isValid();
- }
- return result;
- }
- }), Color.RED);
- table.addHighlighter(validHighlighter);
-
- // when model datas change let's propagate it table model
- listenRowsFromModel();
-
- // save when row chaged and was modified
- ListSelectionListener listener = new TableRowModificationListener<SpeciesBatchRowModel>(
- getTableModel(), getRowMonitor()) {
- @Override
- protected void saveSelectedRow() {
- saveSelectedRowIfRequired();
- }
- };
- table.getSelectionModel().addListSelectionListener(listener);
-
- // always scroll to selected row
- SwingUtil.scrollToTableSelection(getTable());
- }
-
- @Override
- public void onCloseUI() {
- if (log.isInfoEnabled()) {
- log.info("closing: " + ui);
- }
- }
-
- //------------------------------------------------------------------------//
- //-- Public methods --//
- //------------------------------------------------------------------------//
-
- public void saveSelectedRowIfRequired(FocusEvent event) {
-
- Component oppositeComponent = event.getOppositeComponent();
-
- JXTable parentContainer = null;
-
- if (oppositeComponent != null) {
-
- // check out if still on table
- parentContainer = SwingUtil.getParentContainer(
- oppositeComponent, JXTable.class);
- }
-
- if (parentContainer == null) {
-
- // out of the table can save
- if (getModel().getFishingOperation()!=null) {
- saveSelectedRowIfRequired();
- }
- }
- }
-
- public void selectFishingOperation(FishingOperation bean) {
-
- JXTable table = ui.getTable();
-
- if (table.isEditing()) {
-
- // make sure to stop editor
- table.editingCanceled(null);
- }
-
- if (fishingOperationMonitor.wasModified()) {
-
- // previous fishingOperation was modified, let's save it
- SpeciesTabUIModel traitMonitorBean =
- (SpeciesTabUIModel) fishingOperationMonitor.getBean();
-
- FishingOperation fishingOperation = traitMonitorBean.toBean();
-
- if (log.isInfoEnabled()) {
- log.info("FishingOperation " + fishingOperation.getId() +
- " was modified, will save it.");
- }
-
- persistenceService.saveFishingOperation(fishingOperation);
- }
-
- // make sure selection is empty (will remove bean from monitor)
- table.clearSelection();
-
- boolean empty = bean == null;
-
- SpeciesTabUIModel model = getModel();
-
- List<SpeciesBatchRowModel> rows;
-
- if (empty) {
- rows = null;
- bean = new FishingOperation();
- model.setFishingOperation(null);
- } else {
-
- if (log.isInfoEnabled()) {
- log.info("Get species batch for fishingOperation: " + bean.getId());
- }
- rows = Lists.newArrayList();
-
- if (!TuttiEntities.isNew(bean)) {
- List<SpeciesBatch> catches =
- persistenceService.getAllSpeciesBatch(bean.getId());
- for (SpeciesBatch aBatch : catches) {
- List<SpeciesBatchFrequency> frequencies =
- persistenceService.getAllSpeciesBatchFrequency(aBatch.getId());
- SpeciesBatchRowModel entry =
- new SpeciesBatchRowModel(aBatch, frequencies);
- rows.add(entry);
- }
- }
- model.setFishingOperation(bean);
- }
-
- model.fromBean(bean);
- model.setRows(rows);
-
- fishingOperationMonitor.clearModified();
- }
-
- //------------------------------------------------------------------------//
- //-- Internal methods --//
- //------------------------------------------------------------------------//
-
- protected void recomputeSuperSamplingRatio(SpeciesBatchTreeModel samplingTreeModel,
- SpeciesBatchTreeNode node) {
-
- SpeciesBatchTreeNode superSamplingNode = node.getParent();
-
- Preconditions.checkNotNull(superSamplingNode,
- "Super sampling node can't be null");
-
- SpeciesBatchTreeModel.SamplingContext samplingContext =
- samplingTreeModel.createSamplingContext(superSamplingNode);
-
- float samplingTotalWeight = samplingContext.getTotalWeight();
- Float superSamplingTotalWeight;
- SpeciesBatchRowModel superSamplingRow =
- samplingContext.getSuperSamplingRow();
- if (superSamplingRow == null) {
-
- // Use directly the batch total weight (means no super-sampling)
-
- superSamplingTotalWeight = getModel().getTotalWeight();
- } else {
- superSamplingTotalWeight = superSamplingRow.getWeight();
- }
-
- if (log.isInfoEnabled()) {
- log.info("Super sampling total weight: " +
- superSamplingTotalWeight);
- }
-
- Float samplingRatio = null;
- if (superSamplingTotalWeight != null) {
- samplingRatio = samplingTotalWeight / superSamplingTotalWeight;
- }
-
- if (log.isInfoEnabled()) {
- log.info("Sampling ratio: " + samplingRatio);
- }
-
- samplingContext.applyNewSampleValues(samplingTotalWeight,
- samplingRatio);
-
- getTableModel().updateSamplingRatio(samplingContext.getSamplingRows());
- }
-
-
- protected void recomputeTotalHorsVrac() {
-
- // recompute total hors vrac
- Float totalHorsVrac = 0f;
- Float totalVrac = 0f;
-
- for (SpeciesBatchRowModel batch : getModel().getRows()) {
- VracHorsVracEnum vracHorsVrac = batch.getVracHorsVrac();
- if (vracHorsVrac == null) {
-
- // can't sum anything
- } else if (vracHorsVrac == VracHorsVracEnum.HORS_VRAC) {
- Float weight = batch.getWeight();
- if (weight != null) {
- totalHorsVrac += weight;
- }
- } else if (vracHorsVrac == VracHorsVracEnum.VRAC) {
- Float weight = batch.getWeight();
- if (weight != null) {
- totalVrac += weight;
- }
- }
- }
- if (log.isInfoEnabled()) {
- log.info("New total vrac / hors vrac: " +
- totalVrac + " / " + totalHorsVrac);
- }
- getModel().setTotalHorsVracWeight(totalHorsVrac);
- //TODO Should we also set the total vrac weight ?
-// getModel().setTotalVracWeight(totalVrac);
- }
-
- protected void saveSelectedRowIfRequired() {
-
- TuttiBeanMonitor<SpeciesBatchRowModel> rowMonitor = getRowMonitor();
-
- SpeciesBatchRowModel bean = rowMonitor.getBean();
- if (bean != null) {
-
- if (bean.isValid()) {
- // there is a valid bean attached to the monitor
-
- if (rowMonitor.wasModified()) {
-
- // monitored bean was modified, save it
- if (log.isInfoEnabled()) {
- log.info("Row " + bean + " was modified, will save it");
- }
-
- saveRow(bean);
-
- // clear modified flag on the monitor
- rowMonitor.clearModified();
- }
- } else {
-
- // row is not valid can not save it
-
- SpeciesBatch catchBean = bean.toBean();
-
- FishingOperation fishingOperation = getModel().getFishingOperation();
-
- if (!TuttiEntities.isNew(catchBean)) {
-
- // remove this
- persistenceService.deleteSpeciesBatch(catchBean.getId());
- }
- }
- }
- }
-
- protected void saveRow(SpeciesBatchRowModel row) {
-
- SpeciesBatch catchBean = row.toBean();
-
- FishingOperation fishingOperation = getModel().getFishingOperation();
- catchBean.setFishingOperation(fishingOperation);
- if (log.isInfoEnabled()) {
- log.info("Selected fishingOperation: " + fishingOperation.getId());
- }
-
- if (TuttiEntities.isNew(catchBean)) {
-
- catchBean = persistenceService.createSpeciesBatch(catchBean);
- row.setId(catchBean.getId());
- } else {
- persistenceService.saveSpeciesBatch(catchBean);
- }
-
- List<SpeciesFrequencyRowModel> frequencyRows = row.getFrequency();
-
- List<SpeciesBatchFrequency> frequency =
- SpeciesFrequencyRowModel.toBeans(frequencyRows, catchBean);
-
- if (log.isInfoEnabled()) {
- log.info("Will save " + frequency.size() + " frequencies.");
- }
- frequency = persistenceService.saveSpeciesBatchFrequency(
- catchBean.getId(), frequency);
-
- // push it back to row model
- frequencyRows = SpeciesFrequencyRowModel.fromBeans(frequency);
- row.setFrequency(frequencyRows);
- }
-}
Deleted: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/species/SpeciesTabUIModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/species/SpeciesTabUIModel.java 2012-12-12 22:50:50 UTC (rev 54)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/species/SpeciesTabUIModel.java 2012-12-13 01:57:28 UTC (rev 55)
@@ -1,184 +0,0 @@
-package fr.ifremer.tutti.ui.swing.content.operation.species;
-
-/*
- * #%L
- * Tutti :: UI
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2012 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.entities.data.FishingOperation;
-import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableUIModel;
-import org.nuiton.util.beans.Binder;
-import org.nuiton.util.beans.BinderModelBuilder;
-
-import java.util.List;
-
-/**
- * @author tchemit <chemit(a)codelutin.com>
- * @since 0.1
- */
-public class SpeciesTabUIModel extends AbstractTuttiTableUIModel<FishingOperation, SpeciesBatchRowModel, SpeciesTabUIModel> {
-
- private static final long serialVersionUID = 1L;
-
- public static final String PROPERTY_TOTAL_WEIGHT = "totalWeight";
-
- public static final String PROPERTY_TOTAL_VRAC_WEIGHT = "totalVracWeight";
-
- public static final String PROPERTY_SAMPLE_VRAC_WEIGHT = "sampleVracWeight";
-
- public static final String PROPERTY_TOTAL_HORS_VRAC_WEIGHT = "totalHorsVracWeight";
-
- /**
- * Editing fishing operation.
- *
- * @since 0.2
- */
- protected FishingOperation fishingOperation;
-
- /**
- * Total Weight filled in screen.
- *
- * @since 0.2
- */
- protected Float totalWeight;
-
- /**
- * Total vrac Weight filled in screen.
- *
- * @since 0.2
- */
- protected Float totalVracWeight;
-
- /**
- * Total sample vrac Weight filled in screen.
- *
- * @since 0.2
- */
- protected Float sampleVracWeight;
-
- /**
- * Total hors vrac Weight computed by hros vrac rows.
- *
- * @since 0.2
- */
- protected Float totalHorsVracWeight;
-
- /**
- * Sampling order (sets by protocol).
- *
- * @since 0.2
- */
- protected List<String> samplingOrder;
-
- /**
- * Tree of sampling for batch rows.
- *
- * @since 0.2
- */
- protected final SpeciesBatchTreeModel samplingTreeModel;
-
- protected static final Binder<FishingOperation, SpeciesTabUIModel> fromBeanBinder = BinderModelBuilder.newEmptyBuilder(FishingOperation.class, SpeciesTabUIModel.class)
- .addProperty("speciesTotalWeight", PROPERTY_TOTAL_WEIGHT)
- .addProperty("speciesTotalHorsVracWeight", PROPERTY_TOTAL_HORS_VRAC_WEIGHT)
- .addProperty("speciesTotalVracWeight", PROPERTY_TOTAL_VRAC_WEIGHT)
- .addProperty("speciesSampleVracWeight", PROPERTY_SAMPLE_VRAC_WEIGHT)
- .addProperty("id", PROPERTY_ID)
- .toBinder();
-
- protected static final Binder<SpeciesTabUIModel, FishingOperation> toBeanBinder = BinderModelBuilder.newEmptyBuilder(SpeciesTabUIModel.class, FishingOperation.class)
- .addProperty(PROPERTY_TOTAL_WEIGHT, "speciesTotalWeight")
- .addProperty(PROPERTY_TOTAL_HORS_VRAC_WEIGHT, "speciesTotalHorsVracWeight")
- .addProperty(PROPERTY_TOTAL_VRAC_WEIGHT, "speciesTotalVracWeight")
- .addProperty(PROPERTY_SAMPLE_VRAC_WEIGHT, "speciesSampleVracWeight")
- .toBinder();
-
- public SpeciesTabUIModel() {
- super(FishingOperation.class, fromBeanBinder, toBeanBinder);
- this.samplingTreeModel = new SpeciesBatchTreeModel();
- }
-
- public FishingOperation getFishingOperation() {
- return fishingOperation;
- }
-
- public void setFishingOperation(FishingOperation fishingOperation) {
- this.fishingOperation = fishingOperation;
- }
-
- public SpeciesBatchTreeModel getSamplingTreeModel() {
- return samplingTreeModel;
- }
-
- public Float getTotalWeight() {
- return totalWeight;
- }
-
- public void setTotalWeight(Float totalWeight) {
- Object oldValue = getTotalWeight();
- this.totalWeight = totalWeight;
- firePropertyChange(PROPERTY_TOTAL_WEIGHT, oldValue, totalWeight);
- }
-
- public Float getTotalVracWeight() {
- return totalVracWeight;
- }
-
- public void setTotalVracWeight(Float totalVracWeight) {
- Object oldValue = getTotalVracWeight();
- this.totalVracWeight = totalVracWeight;
- firePropertyChange(PROPERTY_TOTAL_VRAC_WEIGHT, oldValue, totalVracWeight);
- }
-
- public Float getSampleVracWeight() {
- return sampleVracWeight;
- }
-
- public void setSampleVracWeight(Float sampleVracWeight) {
- Object oldValue = getSampleVracWeight();
- this.sampleVracWeight = sampleVracWeight;
- firePropertyChange(PROPERTY_SAMPLE_VRAC_WEIGHT, oldValue, sampleVracWeight);
- }
-
- public Float getTotalHorsVracWeight() {
- return totalHorsVracWeight;
- }
-
- public void setTotalHorsVracWeight(Float totalHorsVracWeight) {
- Object oldValue = getTotalHorsVracWeight();
- this.totalHorsVracWeight = totalHorsVracWeight;
- firePropertyChange(PROPERTY_TOTAL_HORS_VRAC_WEIGHT, oldValue, totalHorsVracWeight);
- }
-
- public List<String> getSamplingOrder() {
- return samplingOrder;
- }
-
- public void setSamplingOrder(List<String> samplingOrder) {
- this.samplingOrder = samplingOrder;
- samplingTreeModel.setSamplingOrder(samplingOrder.toArray(new String[samplingOrder.size()]));
- }
-
- @Override
- protected FishingOperation newEntity() {
- return fishingOperation;
- }
-}
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 2012-12-12 22:50:50 UTC (rev 54)
+++ trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties 2012-12-13 01:57:28 UTC (rev 55)
@@ -43,8 +43,6 @@
tutti.config.ui.showNumberEditorButton=Afficher le pavé numérique de saisie
tutti.label.benthos.sampleTotalWeight=Poids total échantillonné
tutti.label.benthos.totalWeight=Poids total
-tutti.label.captureAccidentel.sampleTotalWeight=Poids total échantillonné
-tutti.label.captureAccidentel.totalWeight=Poids total
tutti.label.comment=Commentaire
tutti.label.cruise=Campagne
tutti.label.cruise.beginDate=Date de début
@@ -68,25 +66,18 @@
tutti.label.fishingOperation.gearDate=Date
tutti.label.fishingOperation.gearLatitude=Latitude
tutti.label.fishingOperation.gearLongitude=Longitude
-tutti.label.fishingOperation.gearShootingDate=Date
tutti.label.fishingOperation.gearShootingEnd=Fin de traine
tutti.label.fishingOperation.gearShootingEndBottomSalinity=Salinité de fond fin de traine
tutti.label.fishingOperation.gearShootingEndBottomTemperature=Température de fond fin de traine
tutti.label.fishingOperation.gearShootingEndDepth=Profondeur fin de traine
tutti.label.fishingOperation.gearShootingEndSurfaceSalinity=Salinité de surface fin de traine
tutti.label.fishingOperation.gearShootingEndSurfaceTemperature=Temperature de surface fin de traine
-tutti.label.fishingOperation.gearShootingLatitude=Latitude
-tutti.label.fishingOperation.gearShootingLongitude=Longitude
tutti.label.fishingOperation.gearShootingStart=Début de traine
tutti.label.fishingOperation.gearShootingStartBottomSalinity=Salinité de fond début de traine
tutti.label.fishingOperation.gearShootingStartBottomTemperature=Température de fond début de traine
tutti.label.fishingOperation.gearShootingStartDepth=Profondeur début de traine
-tutti.label.fishingOperation.gearShootingStartLatitude=Latitude début de traine
-tutti.label.fishingOperation.gearShootingStartLongitude=Longitude début de traine
tutti.label.fishingOperation.gearShootingStartSurfaceSalinity=Salinité de surface début de traine
tutti.label.fishingOperation.gearShootingStartSurfaceTemperature=Temperature de surface début de traine
-tutti.label.fishingOperation.gearShootingStartTime=Début de traine
-tutti.label.fishingOperation.gearShootingTime=Heure
tutti.label.fishingOperation.gearTime=Heure
tutti.label.fishingOperation.geometrieMesuree=Géométrie mesurée
tutti.label.fishingOperation.localite=Localité
@@ -102,7 +93,6 @@
tutti.label.fishingOperation.windDirection=Direction du vent
tutti.label.frequencyConfiguration.maxStep=Classe max
tutti.label.frequencyConfiguration.minStep=Classe min
-tutti.label.frequencyConfiguration.mode=Mode de saisie
tutti.label.frequencyConfiguration.mode.autoGen=Génération des classes
tutti.label.frequencyConfiguration.mode.autoGen.tip=Mode où toutes les classes de taille sont générées
tutti.label.frequencyConfiguration.mode.rafale=Mode "rafale"
@@ -115,13 +105,11 @@
tutti.label.list.gear=Engin(s)
tutti.label.list.headOfMission=Chef(s) de mission
tutti.label.list.headOfSortRoom=Reponsable(s) de salle de tri
-tutti.label.list.saisisseur=Nom des saisisseurs
tutti.label.list.vessel=Navire(s)
-tutti.label.macroDechet.sampleTotalWeight=Poids total échantillonné
-tutti.label.macroDechet.totalWeight=Poids total
+tutti.label.macroWaste.totalWeight=Poids total
tutti.label.no.fishingOperation.selected=< Aucun trait sélectionné >
-tutti.label.plancton.sampleTotalWeight=Poids total échantillonné
-tutti.label.plancton.totalWeight=Poids total
+tutti.label.plankton.sampleTotalWeight=Poids total échantillonné
+tutti.label.plankton.totalWeight=Poids total
tutti.label.program=Série de campagne
tutti.label.program.name=Nom
tutti.label.program.zone=Zone
@@ -155,26 +143,35 @@
tutti.menu.synchronisationImport.tip=Effectuer des imports
tutti.menu.synchronisations=Synchronisation
tutti.menu.synchronisations.tip=Import/Export
-tutti.table.benthos.header.number=Nombre observé
-tutti.table.benthos.header.speciesByCode=Espèce
-tutti.table.benthos.header.weight=Poids observé
-tutti.table.captureAccidentel.header.number=Nombre observé
-tutti.table.captureAccidentel.header.speciesByCode=Espèce
-tutti.table.captureAccidentel.header.weight=Poids observé
-tutti.table.macroDechet.header.number=Nombre observé
-tutti.table.macroDechet.header.speciesByCode=Espèce
-tutti.table.macroDechet.header.weight=Poids observé
-tutti.table.plancton.header.number=Nombre observé
-tutti.table.plancton.header.speciesByCode=Espèce
-tutti.table.plancton.header.weight=Poids observé
+tutti.table.benthos.batch.header.comment=Commentaire
+tutti.table.benthos.batch.header.elevationRate=Fraction d'élévation
+tutti.table.benthos.batch.header.file=Pièces jointes
+tutti.table.benthos.batch.header.sampleWeight=Poids échantillonné
+tutti.table.benthos.batch.header.speciesByCode=Espèce
+tutti.table.benthos.batch.header.speciesByGenusCode=Espèce
+tutti.table.benthos.batch.header.toConfirm=A Confirmer
+tutti.table.benthos.batch.header.weight=Poids
+tutti.table.macrowaste.batch.header.comment=Commentaire
+tutti.table.macrowaste.batch.header.file=Pièces jointes
+tutti.table.macrowaste.batch.header.speciesByCode=Espèce
+tutti.table.macrowaste.batch.header.speciesByGenusCode=Espèce
+tutti.table.macrowaste.batch.header.weight=Poids
+tutti.table.plankton.batch.header.comment=Commentaire
+tutti.table.plankton.batch.header.elevationRate=Fraction d'élévation
+tutti.table.plankton.batch.header.file=Pièces jointes
+tutti.table.plankton.batch.header.sampleWeight=Poids échantillonné
+tutti.table.plankton.batch.header.speciesByCode=Espèce
+tutti.table.plankton.batch.header.speciesByGenusCode=Espèce
+tutti.table.plankton.batch.header.toConfirm=A Confirmer
+tutti.table.plankton.batch.header.weight=Poids
tutti.table.species.batch.header.age=Age
tutti.table.species.batch.header.comment=Commentaire
tutti.table.species.batch.header.computedNumber=Nombre calculé
tutti.table.species.batch.header.computedWeight=Poids calculé
-tutti.table.species.batch.header.elevationRate=Fraction d'él
+tutti.table.species.batch.header.elevationRate=Fraction d'élévation
tutti.table.species.batch.header.file=Pièces jointes
tutti.table.species.batch.header.maturity=Maturité
-tutti.table.species.batch.header.sampleWeight=Poids échan
+tutti.table.species.batch.header.sampleWeight=Poids échantillonné
tutti.table.species.batch.header.sex=Sexe
tutti.table.species.batch.header.speciesByCode=Espèce
tutti.table.species.batch.header.speciesByGenusCode=Espèce
@@ -191,8 +188,8 @@
tutti.title.create.cruise=Créer une nouvelle campagne
tutti.title.create.program=Créer une nouvelle série de campagne
tutti.title.edit.cruise=Editer une campagne existante
+tutti.title.edit.operations=Saisie des opérations de pêches (%s)
tutti.title.edit.program=Editer une série de campagne existante
-tutti.title.fill.catches=Saisie des captures
tutti.title.frequency=Saisie des mensurations
tutti.title.home=Sélection de la campagne
tutti.title.noSelectedCruise=Pas de campagne sélectionné
1
0
r54 - trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/species
by tchemit@users.forge.codelutin.com 12 Dec '12
by tchemit@users.forge.codelutin.com 12 Dec '12
12 Dec '12
Author: tchemit
Date: 2012-12-12 23:50:50 +0100 (Wed, 12 Dec 2012)
New Revision: 54
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/54
Log:
continue species batch screen
Modified:
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/species/SpeciesBatchRowModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/species/SpeciesBatchTableModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/species/SpeciesBatchTreeModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/species/SpeciesBatchTreeNode.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/species/SpeciesFrequencyTableModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/species/SpeciesFrequencyUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/species/SpeciesTabUIHandler.java
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/species/SpeciesBatchRowModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/species/SpeciesBatchRowModel.java 2012-12-12 22:50:16 UTC (rev 53)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/species/SpeciesBatchRowModel.java 2012-12-12 22:50:50 UTC (rev 54)
@@ -366,12 +366,6 @@
computedNumber);
}
- //TODO Use validator
- @Override
- public boolean isValid() {
- return species != null && weight != null;
- }
-
public int getRowCount() {
return frequency == null ? 0 : frequency.size();
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/species/SpeciesBatchTableModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/species/SpeciesBatchTableModel.java 2012-12-12 22:50:16 UTC (rev 53)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/species/SpeciesBatchTableModel.java 2012-12-12 22:50:50 UTC (rev 54)
@@ -134,7 +134,11 @@
@Override
protected SpeciesBatchRowModel createNewRow() {
- return new SpeciesBatchRowModel();
+ SpeciesBatchRowModel result = new SpeciesBatchRowModel();
+
+ // by default empty row is not valid
+ result.setValid(false);
+ return result;
}
@Override
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/species/SpeciesBatchTreeModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/species/SpeciesBatchTreeModel.java 2012-12-12 22:50:16 UTC (rev 53)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/species/SpeciesBatchTreeModel.java 2012-12-12 22:50:50 UTC (rev 54)
@@ -24,11 +24,16 @@
* #L%
*/
+import com.google.common.collect.HashMultimap;
import com.google.common.collect.Maps;
+import com.google.common.collect.Multimap;
import com.google.common.collect.Sets;
+import fr.ifremer.tutti.persistence.entities.data.VracHorsVracEnum;
import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil;
+import org.apache.commons.collections.CollectionUtils;
import java.io.Serializable;
+import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -67,14 +72,13 @@
*
* @since 0.2
*/
- protected final Map<SpeciesBatchTreeNode, SpeciesBatchRowModel> nodeToRow;
+ protected final Multimap<SpeciesBatchTreeNode, SpeciesBatchRowModel> nodeToRow;
-
public SpeciesBatchTreeModel(String... samplingOrder) {
this.samplingOrder = samplingOrder;
root = new SpeciesBatchTreeNode();
rowToNode = Maps.newHashMap();
- nodeToRow = Maps.newHashMap();
+ nodeToRow = HashMultimap.create();
}
public void populate(List<SpeciesBatchRowModel> rows) {
@@ -85,7 +89,11 @@
SpeciesBatchTreeNode node = getSamplingNode(row);
- nodeToRow.put(node, row);
+ // check if row is valid
+ boolean rowIsValid = isValid(row, node);
+
+ // set it in row
+ row.setValid(rowIsValid);
}
}
@@ -107,12 +115,11 @@
nodeToRow.clear();
}
-
public SpeciesBatchTreeNode removeNodeFromCache(SpeciesBatchRowModel row) {
SpeciesBatchTreeNode result = rowToNode.remove(row);
if (result != null) {
- nodeToRow.remove(result);
+ nodeToRow.remove(result, row);
}
return result;
}
@@ -127,8 +134,17 @@
// not in cache must build the path
result = getSamplingNode(root, 0, row);
- // and add it in cache
- rowToNode.put(row, result);
+ if (result == root) {
+
+ // this means an empty row, so no node for it
+ result = null;
+
+ } else {
+
+ // found a row with a sampling, add it in cache
+ rowToNode.put(row, result);
+ nodeToRow.put(result, row);
+ }
}
return result;
}
@@ -173,16 +189,26 @@
Set<SpeciesBatchRowModel> childRows = Sets.newHashSet();
- SpeciesBatchRowModel superSamplingRow = nodeToRow.get(rootNode);
+ SpeciesBatchRowModel superSamplingRow = getNodeToRow(rootNode);
+
float totalWeight = 0f;
for (int i = 0, nbChildren = rootNode.getChildCount(); i < nbChildren; i++) {
SpeciesBatchTreeNode node = rootNode.getChildAt(i);
- SpeciesBatchRowModel row = nodeToRow.get(node);
+
+ SpeciesBatchRowModel row = getNodeToRow(node);
if (row != null) {
- childRows.add(row);
- Float weight = row.getWeight();
- if (weight != null) {
- totalWeight += weight;
+ VracHorsVracEnum vracHorsVrac = row.getVracHorsVrac();
+ if (VracHorsVracEnum.HORS_VRAC.equals(vracHorsVrac)) {
+
+ // never take account of a such child
+
+ } else {
+
+ childRows.add(row);
+ Float weight = row.getWeight();
+ if (weight != null) {
+ totalWeight += weight;
+ }
}
}
}
@@ -193,6 +219,34 @@
return result;
}
+ public SpeciesBatchRowModel getNodeToRow(SpeciesBatchTreeNode node) {
+ Collection<SpeciesBatchRowModel> rows = nodeToRow.get(node);
+
+ SpeciesBatchRowModel result = null;
+ if (CollectionUtils.isNotEmpty(rows)) {
+ for (SpeciesBatchRowModel next : rows) {
+ if (next.isValid()) {
+ result = next;
+ break;
+ }
+ }
+ }
+ return result;
+ }
+
+ public boolean isValid(SpeciesBatchRowModel row, SpeciesBatchTreeNode newNode) {
+
+ // row must be on a sampling and having a weight
+ boolean result = row.getWeight() != null && newNode != null;
+
+ // make sure there is not already another row for this node
+ if (result && CollectionUtils.size(nodeToRow.get(newNode)) > 1) {
+ result = false;
+ }
+
+ return result;
+ }
+
public static class SamplingContext {
private final SpeciesBatchTreeNode rootNode;
@@ -228,5 +282,14 @@
public float getTotalWeight() {
return totalWeight;
}
+
+ public void applyNewSampleValues(float samplingWeight,
+ Float samplingRatio) {
+
+ for (SpeciesBatchRowModel row : samplingRows) {
+ row.setSampleWeight(samplingWeight);
+ row.setSamplingRatio(samplingRatio);
+ }
+ }
}
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/species/SpeciesBatchTreeNode.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/species/SpeciesBatchTreeNode.java 2012-12-12 22:50:16 UTC (rev 53)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/species/SpeciesBatchTreeNode.java 2012-12-12 22:50:50 UTC (rev 54)
@@ -29,6 +29,7 @@
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.TreeNode;
import java.io.Serializable;
+import java.util.Arrays;
/**
* Defines a node of a species catches sampling.
@@ -159,4 +160,16 @@
return (SpeciesBatchTreeNode) super.getPreviousLeaf();
}
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (!(o instanceof SpeciesBatchTreeNode)) return false;
+
+ SpeciesBatchTreeNode that = (SpeciesBatchTreeNode) o;
+
+ Object[] path = getUserObjectPath();
+ Object[] path2 = that.getUserObjectPath();
+ return Arrays.equals(path, path2);
+ }
+
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/species/SpeciesFrequencyTableModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/species/SpeciesFrequencyTableModel.java 2012-12-12 22:50:16 UTC (rev 53)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/species/SpeciesFrequencyTableModel.java 2012-12-12 22:50:50 UTC (rev 54)
@@ -93,6 +93,7 @@
}
SpeciesFrequencyRowModel result = new SpeciesFrequencyRowModel();
result.setLengthStep(defaultStep);
+ result.setValid(false);
return result;
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/species/SpeciesFrequencyUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/species/SpeciesFrequencyUIHandler.java 2012-12-12 22:50:16 UTC (rev 53)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/species/SpeciesFrequencyUIHandler.java 2012-12-12 22:50:50 UTC (rev 54)
@@ -134,6 +134,18 @@
}
}
+ @Override
+ protected void onRowValidStateChanged(SpeciesFrequencyRowModel row,
+ Boolean oldValue,
+ Boolean newValue) {
+ }
+
+ @Override
+ protected void onRowModifyStateChanged(SpeciesFrequencyRowModel row,
+ Boolean oldValue,
+ Boolean newValue) {
+ }
+
//------------------------------------------------------------------------//
//-- AbstractTuttiUIHandler methods --//
//------------------------------------------------------------------------//
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/species/SpeciesTabUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/species/SpeciesTabUIHandler.java 2012-12-12 22:50:16 UTC (rev 53)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/species/SpeciesTabUIHandler.java 2012-12-12 22:50:50 UTC (rev 54)
@@ -47,7 +47,9 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jdesktop.swingx.JXTable;
+import org.jdesktop.swingx.decorator.ComponentAdapter;
import org.jdesktop.swingx.decorator.HighlightPredicate;
+import org.jdesktop.swingx.decorator.Highlighter;
import org.jdesktop.swingx.table.DefaultTableColumnModelExt;
import org.nuiton.util.beans.BeanMonitor;
import org.nuiton.util.decorator.Decorator;
@@ -114,8 +116,8 @@
SpeciesBatchRowModel.PROPERTY_MATURITY,
SpeciesBatchRowModel.PROPERTY_AGE,
SpeciesBatchRowModel.PROPERTY_WEIGHT,
- SpeciesBatchRowModel.PROPERTY_SAMPLE_WEIGHT,
- SpeciesBatchRowModel.PROPERTY_SAMPLING_RATIO,
+// SpeciesBatchRowModel.PROPERTY_SAMPLE_WEIGHT,
+// SpeciesBatchRowModel.PROPERTY_SAMPLING_RATIO,
SpeciesBatchRowModel.PROPERTY_COMMENT,
SpeciesBatchRowModel.PROPERTY_FREQUENCY);
this.ui = ui;
@@ -156,6 +158,15 @@
}
@Override
+ protected String[] getRowPropertiesToIgnore() {
+ return new String[]{
+ SpeciesBatchRowModel.PROPERTY_SAMPLE_WEIGHT,
+ SpeciesBatchRowModel.PROPERTY_SAMPLING_RATIO,
+ SpeciesBatchRowModel.PROPERTY_FREQUENCY
+ };
+ }
+
+ @Override
protected TableColumnModel createTableColumnModel() {
List<String> samplingOrder = getModel().getSamplingOrder();
@@ -318,9 +329,8 @@
SpeciesBatchTreeModel samplingTreeModel = model.getSamplingTreeModel();
- if (SAMPLING_PROPERTIES.contains(propertyName) && row.isValid()) {
+ if (SAMPLING_PROPERTIES.contains(propertyName)) {
-
// Need to rebuilt this row sampling tree path (and then recompute
// old super - samplingRatio and new super - samplingRatio)
@@ -328,23 +338,86 @@
// and remove it from any cache
SpeciesBatchTreeNode oldNode = samplingTreeModel.removeNodeFromCache(row);
+ boolean rowWasValid = row.isValid();
+ if (oldNode != null && rowWasValid) {
+
+ // remove this row from his super sampling
+ recomputeSuperSamplingRatio(samplingTreeModel, oldNode);
+ }
+
// get new sampling node
SpeciesBatchTreeNode newNode = samplingTreeModel.getSamplingNode(row);
- moveSamplingNode(samplingTreeModel, row, oldNode, newNode);
+ // check this row is valid
+ boolean rowValid = samplingTreeModel.isValid(row, newNode);
+
+ // push this state back to the row
+ row.setValid(rowValid);
+
+ if (rowValid) {
+
+ // can add it to his super-sampling
+ recomputeSuperSamplingRatio(samplingTreeModel, newNode);
+ } else {
+
+ if (rowWasValid) {
+
+ row.setSampleWeight(null);
+ row.setSamplingRatio(null);
+
+ getTableModel().updateSamplingRatio(Sets.newHashSet(row));
+ }
+ }
}
- if (SpeciesBatchRowModel.PROPERTY_WEIGHT.equals(propertyName) &&
- row.isValid()) {
+ if (SpeciesBatchRowModel.PROPERTY_WEIGHT.equals(propertyName)) {
// Need to recompute the super - samplingRatio
SpeciesBatchTreeNode node = samplingTreeModel.getSamplingNode(row);
- recomputeSuperSamplingRatio(samplingTreeModel, row, node);
+ boolean rowWasValid = row.isValid();
+
+ // check this row is valid
+ boolean rowValid = samplingTreeModel.isValid(row, node);
+
+ // push this state back to the row
+ row.setValid(rowValid);
+
+ if (rowValid) {
+ recomputeSuperSamplingRatio(samplingTreeModel, node);
+ } else {
+ if (rowWasValid) {
+
+ // must remove this row from his super-sampling
+ recomputeSuperSamplingRatio(samplingTreeModel, node);
+
+ row.setSampleWeight(null);
+ row.setSamplingRatio(null);
+
+ getTableModel().updateSamplingRatio(Sets.newHashSet(row));
+ }
+ }
}
}
+ @Override
+ protected void onRowValidStateChanged(SpeciesBatchRowModel row,
+ Boolean oldValue,
+ Boolean newValue) {
+ int rowIndex = getTableModel().getRowIndex(row);
+
+ if (rowIndex > -1) {
+ getTableModel().fireTableRowsUpdated(rowIndex, rowIndex);
+ }
+ }
+
+ @Override
+ protected void onRowModifyStateChanged(SpeciesBatchRowModel row,
+ Boolean oldValue,
+ Boolean newValue) {
+ }
+
//------------------------------------------------------------------------//
//-- AbstractTuttiUIHandler methods --//
//------------------------------------------------------------------------//
@@ -396,9 +469,27 @@
table.getTableHeader().setReorderingAllowed(false);
- table.addHighlighter(TuttiUIUtil.newBackgroundColorHighlighter(
- HighlightPredicate.READ_ONLY, Color.LIGHT_GRAY));
+ Highlighter readOnlyHighlighter = TuttiUIUtil.newBackgroundColorHighlighter(
+ HighlightPredicate.READ_ONLY, Color.LIGHT_GRAY);
+
+ table.addHighlighter(readOnlyHighlighter);
+ Highlighter validHighlighter = TuttiUIUtil.newBackgroundColorHighlighter(
+ new HighlightPredicate.AndHighlightPredicate(HighlightPredicate.EDITABLE, new HighlightPredicate() {
+ @Override
+ public boolean isHighlighted(Component renderer, ComponentAdapter adapter) {
+
+ boolean result = false;
+ if (adapter.isEditable()) {
+ int rowIndex = adapter.convertRowIndexToModel(adapter.row);
+ SpeciesBatchRowModel row = getTableModel().getEntry(rowIndex);
+ result = !row.isValid();
+ }
+ return result;
+ }
+ }), Color.RED);
+ table.addHighlighter(validHighlighter);
+
// when model datas change let's propagate it table model
listenRowsFromModel();
@@ -443,7 +534,9 @@
if (parentContainer == null) {
// out of the table can save
- saveSelectedRowIfRequired();
+ if (getModel().getFishingOperation()!=null) {
+ saveSelectedRowIfRequired();
+ }
}
}
@@ -517,23 +610,7 @@
//-- Internal methods --//
//------------------------------------------------------------------------//
- protected void moveSamplingNode(SpeciesBatchTreeModel samplingTreeModel,
- SpeciesBatchRowModel row,
- SpeciesBatchTreeNode oldNode,
- SpeciesBatchTreeNode newNode) {
-
- if (oldNode != null) {
-
- recomputeSuperSamplingRatio(samplingTreeModel, row, oldNode);
-
- }
-
- recomputeSuperSamplingRatio(samplingTreeModel, row, newNode);
-
- }
-
protected void recomputeSuperSamplingRatio(SpeciesBatchTreeModel samplingTreeModel,
- SpeciesBatchRowModel row,
SpeciesBatchTreeNode node) {
SpeciesBatchTreeNode superSamplingNode = node.getParent();
@@ -571,8 +648,10 @@
log.info("Sampling ratio: " + samplingRatio);
}
+ samplingContext.applyNewSampleValues(samplingTotalWeight,
+ samplingRatio);
+
getTableModel().updateSamplingRatio(samplingContext.getSamplingRows());
-
}
@@ -613,21 +692,36 @@
TuttiBeanMonitor<SpeciesBatchRowModel> rowMonitor = getRowMonitor();
SpeciesBatchRowModel bean = rowMonitor.getBean();
- if (bean != null && bean.isValid()) {
+ if (bean != null) {
- // there is a valid bean attached to the monitor
+ if (bean.isValid()) {
+ // there is a valid bean attached to the monitor
- if (rowMonitor.wasModified()) {
+ if (rowMonitor.wasModified()) {
- // monitored bean was modified, save it
- if (log.isInfoEnabled()) {
- log.info("Row " + bean + " was modified, will save it");
+ // monitored bean was modified, save it
+ if (log.isInfoEnabled()) {
+ log.info("Row " + bean + " was modified, will save it");
+ }
+
+ saveRow(bean);
+
+ // clear modified flag on the monitor
+ rowMonitor.clearModified();
}
+ } else {
- saveRow(bean);
+ // row is not valid can not save it
- // clear modified flag on the monitor
- rowMonitor.clearModified();
+ SpeciesBatch catchBean = bean.toBean();
+
+ FishingOperation fishingOperation = getModel().getFishingOperation();
+
+ if (!TuttiEntities.isNew(catchBean)) {
+
+ // remove this
+ persistenceService.deleteSpeciesBatch(catchBean.getId());
+ }
}
}
}
1
0
r53 - trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table
by tchemit@users.forge.codelutin.com 12 Dec '12
by tchemit@users.forge.codelutin.com 12 Dec '12
12 Dec '12
Author: tchemit
Date: 2012-12-12 23:50:16 +0100 (Wed, 12 Dec 2012)
New Revision: 53
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/53
Log:
improve row modification cinematic
Modified:
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/AbstractTuttiTableUIHandler.java
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/AbstractTuttiTableUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/AbstractTuttiTableUIHandler.java 2012-12-12 22:43:46 UTC (rev 52)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/AbstractTuttiTableUIHandler.java 2012-12-12 22:50:16 UTC (rev 53)
@@ -25,6 +25,7 @@
*/
import com.google.common.base.Preconditions;
+import com.google.common.collect.Sets;
import fr.ifremer.tutti.ui.swing.AbstractTuttiBeanUIModel;
import fr.ifremer.tutti.ui.swing.AbstractTuttiUIHandler;
import fr.ifremer.tutti.ui.swing.TuttiUIContext;
@@ -35,6 +36,7 @@
import jaxx.runtime.swing.editor.bean.BeanUIUtil;
import jaxx.runtime.swing.editor.cell.NumberCellEditor;
import jaxx.runtime.swing.renderer.DecoratorTableCellRenderer;
+import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jdesktop.swingx.autocomplete.ComboBoxCellEditor;
@@ -57,6 +59,7 @@
import java.beans.PropertyChangeListener;
import java.util.Enumeration;
import java.util.List;
+import java.util.Set;
import static org.nuiton.i18n.I18n._;
@@ -90,21 +93,55 @@
Object oldValue,
Object newValue);
+ protected abstract void onRowValidStateChanged(R row,
+ Boolean oldValue,
+ Boolean newValue);
+
+ protected abstract void onRowModifyStateChanged(R row,
+ Boolean oldValue,
+ Boolean newValue);
+
+ protected String[] getRowPropertiesToIgnore() {
+ return ArrayUtils.EMPTY_STRING_ARRAY;
+ }
+
protected AbstractTuttiTableUIHandler(TuttiUIContext context,
String... properties) {
super(context);
+
rowMonitor = new TuttiBeanMonitor<R>(properties);
// listen when bean is changed
rowMonitor.addPropertyChangeListener(TuttiBeanMonitor.PROPERTY_BEAN, new PropertyChangeListener() {
+
+ final Set<String> propertiesToSkip =
+ Sets.newHashSet(getRowPropertiesToIgnore());
+
final PropertyChangeListener l = new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
+ String propertyName = evt.getPropertyName();
+
R row = (R) evt.getSource();
- onRowModified(row,
- evt.getPropertyName(),
- evt.getOldValue(),
- evt.getNewValue());
+
+ Object oldValue = evt.getOldValue();
+ Object newValue = evt.getNewValue();
+
+ if (AbstractTuttiBeanUIModel.PROPERTY_VALID.equals(propertyName)) {
+ onRowValidStateChanged(row,
+ (Boolean) oldValue,
+ (Boolean) newValue);
+ } else if (AbstractTuttiBeanUIModel.PROPERTY_MODIFY.equals(propertyName)) {
+ onRowModifyStateChanged(row,
+ (Boolean) oldValue,
+ (Boolean) newValue);
+ } else if (!propertiesToSkip.contains(propertyName)) {
+
+ onRowModified(row,
+ propertyName,
+ oldValue,
+ newValue);
+ }
}
};
1
0
r52 - trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table
by tchemit@users.forge.codelutin.com 12 Dec '12
by tchemit@users.forge.codelutin.com 12 Dec '12
12 Dec '12
Author: tchemit
Date: 2012-12-12 23:43:46 +0100 (Wed, 12 Dec 2012)
New Revision: 52
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/52
Log:
add method to get index of a row
Modified:
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/AbstractTuttiTableModel.java
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/AbstractTuttiTableModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/AbstractTuttiTableModel.java 2012-12-12 22:43:03 UTC (rev 51)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/AbstractTuttiTableModel.java 2012-12-12 22:43:46 UTC (rev 52)
@@ -132,7 +132,7 @@
fireTableRowsInserted(rowIndex, rowIndex);
}
- public int updateRow(R row) {
+ public final int updateRow(R row) {
Preconditions.checkNotNull(row, "Row can not be null.");
List<R> data = getRows();
@@ -157,6 +157,11 @@
return (ColumnIdentifier<R>) column.getIdentifier();
}
+ public final int getRowIndex(R row) {
+ int result = rows == null ? -1 : rows.indexOf(row);
+ return result;
+ }
+
public final R getEntry(int rowIndex) {
SwingUtil.ensureRowIndex(this, rowIndex);
List<R> data = getRows();
1
0