r137 - in trunk/tutti-ui-swing/src/main: java/fr/ifremer/tutti/ui/swing java/fr/ifremer/tutti/ui/swing/content/operation/catches/species java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split java/fr/ifremer/tutti/ui/swing/util resources/i18n
Author: tchemit Date: 2013-01-02 00:04:02 +0100 (Wed, 02 Jan 2013) New Revision: 137 Url: http://forge.codelutin.com/projects/tutti/repository/revisions/137 Log: refs #1805: [Onglet Poisson] Assistance ?\195?\160 la saisie des lots de poissons (ajout creation lot esp?\195?\168ce) + am?\195?\169lioration des dialog Added: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/Cancelable.java Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/AbstractTuttiUIHandler.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchRowModel.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIHandler.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/FrequencyCellComponent.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUI.css trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUIHandler.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/CreateSpeciesBatchUI.css trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/CreateSpeciesBatchUI.jaxx trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/CreateSpeciesBatchUIHandler.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchUI.css trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchUIHandler.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/TuttiUIUtil.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/AbstractTuttiUIHandler.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/AbstractTuttiUIHandler.java 2013-01-01 18:27:33 UTC (rev 136) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/AbstractTuttiUIHandler.java 2013-01-01 23:04:02 UTC (rev 137) @@ -30,9 +30,12 @@ import fr.ifremer.tutti.persistence.entities.IdAware; import fr.ifremer.tutti.service.DecoratorService; import fr.ifremer.tutti.ui.swing.config.TuttiConfig; +import fr.ifremer.tutti.ui.swing.util.Cancelable; import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil; import fr.ifremer.tutti.ui.swing.util.UIMessageNotifier; import fr.ifremer.tutti.ui.swing.util.editor.SimpleTimeEditor; +import jaxx.runtime.JAXXUtil; +import jaxx.runtime.SwingUtil; import jaxx.runtime.swing.editor.NumberEditor; import jaxx.runtime.swing.editor.bean.BeanComboBox; import jaxx.runtime.swing.editor.bean.BeanDoubleList; @@ -45,14 +48,24 @@ import org.nuiton.util.decorator.JXPathDecorator; import org.nuiton.validator.bean.simple.SimpleBeanValidator; +import javax.swing.AbstractAction; +import javax.swing.JComponent; +import javax.swing.JDialog; import javax.swing.JList; +import javax.swing.JRootPane; +import javax.swing.KeyStroke; import javax.swing.ListCellRenderer; import javax.swing.ListSelectionModel; import javax.swing.event.ListSelectionEvent; import javax.swing.text.JTextComponent; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.Frame; import java.awt.event.ActionEvent; import java.awt.event.ItemEvent; import java.awt.event.KeyEvent; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import java.io.Serializable; @@ -87,6 +100,10 @@ this.context = context; } + //------------------------------------------------------------------------// + //-- Public methods --// + //------------------------------------------------------------------------// + @Override public void showInformationMessage(String message) { context.showInformationMessage(message); @@ -137,6 +154,62 @@ } } + public void openDialog(TuttiUI ui, + TuttiUI dialogContent, + String title, Dimension dim) { + Frame frame = SwingUtil.getParentContainer(ui, Frame.class); + + JDialog result = new JDialog(frame, true); + result.setTitle(title); + result.add((Component) dialogContent); + result.setResizable(true); + + result.setSize(dim); + + final AbstractTuttiUIHandler handler = dialogContent.getHandler(); + + if (handler instanceof Cancelable) { + + // add a auto-close action + JRootPane rootPane = result.getRootPane(); + + KeyStroke shortcutClosePopup = getConfig().getShortcutClosePopup(); + + rootPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put( + shortcutClosePopup, "close"); + rootPane.getActionMap().put("close", new AbstractAction() { + private static final long serialVersionUID = 1L; + + @Override + public void actionPerformed(ActionEvent e) { + ((Cancelable) handler).cancel(); + } + }); + } + + result.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); + } + }); + SwingUtil.center(frame, result); + result.setVisible(true); + } + + public void closeDialog(TuttiUI ui) { + SwingUtil.getParentContainer(ui, JDialog.class).setVisible(false); + } + + //------------------------------------------------------------------------// + //-- Internal methods --// + //------------------------------------------------------------------------// + protected void initUI(TuttiUI ui) { for (Map.Entry<String, Object> entry : ui.get$objectMap().entrySet()) { Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchRowModel.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchRowModel.java 2013-01-01 18:27:33 UTC (rev 136) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchRowModel.java 2013-01-01 23:04:02 UTC (rev 137) @@ -97,6 +97,14 @@ public static final String PROPERTY_ATTACHMENTS = "attachments"; + public static final String PROPERTY_BATCH_PARENT = "batchParent"; + + public static final String PROPERTY_BATCH_CHILD = "batchChild"; + + public static final String PROPERTY_BATCH_LEAF = "batchLeaf"; + + public static final String PROPERTY_BATCH_ROOT = "batchRoot"; + /** * Is catch is vrac or horsVrac?. * @@ -195,6 +203,22 @@ */ protected List<SpeciesFrequencyRowModel> frequency; + /** + * Parent of this batch (can be null if batch is root). + * + * @see #isBatchRoot() + * @since 0.3 + */ + protected SpeciesBatchRowModel batchParent; + + /** + * List of child batches (can be null or empty if batch is a leaf). + * + * @see #isBatchLeaf() + * @since 0.3 + */ + protected List<SpeciesBatchRowModel> batchChild; + protected static final Binder<SpeciesBatch, SpeciesBatchRowModel> fromBeanBinder = BinderFactory.newBinder(SpeciesBatch.class, SpeciesBatchRowModel.class); @@ -419,6 +443,36 @@ firePropertyChange(PROPERTY_FREQUENCY, null, frequency); } + public SpeciesBatchRowModel getBatchParent() { + return batchParent; + } + + public void setBatchParent(SpeciesBatchRowModel batchParent) { + Object oldValue = getBatchParent(); + this.batchParent = batchParent; + firePropertyChange(PROPERTY_BATCH_PARENT, oldValue, batchParent); + firePropertyChange(PROPERTY_BATCH_ROOT, null, isBatchRoot()); + } + + public List<SpeciesBatchRowModel> getBatchChild() { + return batchChild; + } + + public void setChilds(List<SpeciesBatchRowModel> batchChild) { + this.batchChild = batchChild; + // force to propagate child changes + firePropertyChange(PROPERTY_BATCH_CHILD, null, batchChild); + firePropertyChange(PROPERTY_BATCH_LEAF, null, isBatchLeaf()); + } + + public boolean isBatchLeaf() { + return CollectionUtils.isEmpty(batchChild); + } + + public boolean isBatchRoot() { + return batchParent == null; + } + public Float getComputedWeight() { return computedWeight; } Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIHandler.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIHandler.java 2013-01-01 18:27:33 UTC (rev 136) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIHandler.java 2013-01-01 23:04:02 UTC (rev 137) @@ -45,16 +45,15 @@ import fr.ifremer.tutti.ui.swing.content.operation.catches.EditCatchesUIModel; import fr.ifremer.tutti.ui.swing.content.operation.catches.species.frequency.FrequencyCellComponent; import fr.ifremer.tutti.ui.swing.content.operation.catches.species.frequency.SpeciesFrequencyRowModel; +import fr.ifremer.tutti.ui.swing.content.operation.catches.species.split.CreateSpeciesBatchUI; +import fr.ifremer.tutti.ui.swing.content.operation.catches.species.split.CreateSpeciesBatchUIModel; import fr.ifremer.tutti.ui.swing.content.operation.catches.species.split.SplitSpeciesBatchRowModel; import fr.ifremer.tutti.ui.swing.content.operation.catches.species.split.SplitSpeciesBatchUI; import fr.ifremer.tutti.ui.swing.content.operation.catches.species.split.SplitSpeciesBatchUIModel; 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.AbstractSelectTableAction; import fr.ifremer.tutti.ui.swing.util.table.ColumnIdentifier; -import jaxx.runtime.SwingUtil; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -65,7 +64,6 @@ import javax.swing.SwingUtilities; import javax.swing.table.TableCellRenderer; import javax.swing.table.TableColumnModel; -import java.awt.Frame; import java.awt.Point; import java.awt.event.MouseEvent; import java.io.Serializable; @@ -236,82 +234,6 @@ // when row valid state has changed, recompute action enabled states recomputeBatchActionEnable(); - - -// 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 @@ -354,7 +276,6 @@ @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); } @@ -478,7 +399,8 @@ JXTable table = getTable(); // create table column model - TableCellRenderer defaultRenderer = table.getDefaultRenderer(Object.class); + TableCellRenderer defaultRenderer = + table.getDefaultRenderer(Object.class); DefaultTableColumnModelExt columnModel = new DefaultTableColumnModelExt(); @@ -556,7 +478,7 @@ { // Computed weight column (from frequencies) addColumnToModel(columnModel, - FrequencyCellComponent.newEditor(ui.getFrequencyEditor()), + FrequencyCellComponent.newEditor(ui), FrequencyCellComponent.newRender(), SpeciesBatchTableModel.COMPUTED_WEIGHT); } @@ -564,7 +486,7 @@ { // Computed number column (from frequencies) addColumnToModel(columnModel, - FrequencyCellComponent.newEditor(ui.getFrequencyEditor()), + FrequencyCellComponent.newEditor(ui), FrequencyCellComponent.newRender(), SpeciesBatchTableModel.COMPUTED_NUMBER); } @@ -650,6 +572,41 @@ public void createSpeciesBatch() { + CreateSpeciesBatchUI createBatchEditor = + ui.getCreateSpeciesBatchUI(); + + createBatchEditor.getHandler().openUI(getModel()); + + openDialog(ui, + createBatchEditor, + _("tutti.title.createBatch"), + ui.getPreferredSize()); + + CreateSpeciesBatchUIModel createModel = createBatchEditor.getModel(); + + if (createModel.isValid()) { + + SpeciesBatchTableModel tableModel = getTableModel(); + + SpeciesBatchRowModel newRow = tableModel.createNewRow(); + newRow.setSpecies(createModel.getSpecies()); + newRow.setWeight(createModel.getBatchWeight()); + + recomputeRowValidState(newRow); + + tableModel.addNewRow(newRow); + + saveRow(newRow); + + // update available species list + getModel().getAvailableSpecies().remove(newRow.getSpecies()); + + } + + // reset create ui + createBatchEditor.getHandler().openUI(null); + + recomputeBatchActionEnable(); } public void splitSpeciesBatch() { @@ -658,104 +615,145 @@ // get selected row int rowIndex = table.getSelectedRow(); - SpeciesBatchRowModel selectedRow = getTableModel().getEntry(rowIndex); + Preconditions.checkState(rowIndex != -1, + "Cant split batch if no batch selected"); + + SpeciesBatchTableModel tableModel = getTableModel(); + + SpeciesBatchRowModel parentBatch = tableModel.getEntry(rowIndex); + if (log.isInfoEnabled()) { - log.info("Open split batch for row [" + rowIndex + "]"); + log.info("Open split batch ui for row [" + rowIndex + "]"); } - SplitSpeciesBatchUI sampleCategoryEditor = ui.getSplitSpeciesBatchUI(); - sampleCategoryEditor.getHandler().editBatch(selectedRow); + SplitSpeciesBatchUI splitBatchEditor = ui.getSplitSpeciesBatchUI(); + splitBatchEditor.getHandler().editBatch(parentBatch); - Frame frame = SwingUtil.getParentContainer(ui, Frame.class); + openDialog(ui, + splitBatchEditor, + _("tutti.title.splitBatch"), + ui.getPreferredSize()); - // open split batch dialog - TuttiUIUtil.openInDialog(sampleCategoryEditor, - frame, - _("tutti.title.splitBatch"), true, null); - // at close, synch back batches ? - SplitSpeciesBatchUIModel splitModel = sampleCategoryEditor.getModel(); + SplitSpeciesBatchUIModel splitModel = splitBatchEditor.getModel(); if (splitModel.isValid()) { // create batch rows - SpeciesBatchTableModel batchTableModel = getTableModel(); - int insertRow = rowIndex; SampleCategoryType selectedCategory = splitModel.getSelectedCategory(); // Create rows in batch table model - List<SpeciesBatchRowModel> newBatchRows = Lists.newArrayList(); + List<SpeciesBatchRowModel> newBatches = Lists.newArrayList(); for (SplitSpeciesBatchRowModel row : splitModel.getRows()) { if (row.isValid()) { // can keep this row - SpeciesBatchRowModel batchNewRow = batchTableModel.createNewRow(); - batchNewRow.setSpecies(selectedRow.getSpecies()); - batchNewRow.setSpeciesToConfirm(selectedRow.getSpeciesToConfirm()); + SpeciesBatchRowModel newBatch = tableModel.createNewRow(); + newBatch.setSpecies(parentBatch.getSpecies()); + newBatch.setSpeciesToConfirm(parentBatch.getSpeciesToConfirm()); if (selectedCategory == SampleCategoryType.sortedUnsorted) { - batchNewRow.setSortedUnsortedCategory((CaracteristicQualitativeValue) row.getCategoryValue()); - batchNewRow.setSortedUnsortedCategoryWeight(row.getWeight()); + newBatch.setSortedUnsortedCategory((CaracteristicQualitativeValue) row.getCategoryValue()); + newBatch.setSortedUnsortedCategoryWeight(row.getWeight()); } else { - batchNewRow.setSortedUnsortedCategory(selectedRow.getSortedUnsortedCategory()); - batchNewRow.setSortedUnsortedCategoryWeight(selectedRow.getSortedUnsortedCategoryWeight()); + newBatch.setSortedUnsortedCategory(parentBatch.getSortedUnsortedCategory()); + newBatch.setSortedUnsortedCategoryWeight(parentBatch.getSortedUnsortedCategoryWeight()); } if (selectedCategory == SampleCategoryType.size) { - batchNewRow.setSizeCategory((CaracteristicQualitativeValue) row.getCategoryValue()); - batchNewRow.setSizeCategoryWeight(row.getWeight()); + newBatch.setSizeCategory((CaracteristicQualitativeValue) row.getCategoryValue()); + newBatch.setSizeCategoryWeight(row.getWeight()); } else { - batchNewRow.setSizeCategory(selectedRow.getSizeCategory()); - batchNewRow.setSizeCategoryWeight(selectedRow.getSizeCategoryWeight()); + newBatch.setSizeCategory(parentBatch.getSizeCategory()); + newBatch.setSizeCategoryWeight(parentBatch.getSizeCategoryWeight()); } if (selectedCategory == SampleCategoryType.sex) { - batchNewRow.setSexCategory((CaracteristicQualitativeValue) row.getCategoryValue()); - batchNewRow.setSexCategoryWeight(row.getWeight()); + newBatch.setSexCategory((CaracteristicQualitativeValue) row.getCategoryValue()); + newBatch.setSexCategoryWeight(row.getWeight()); } else { - batchNewRow.setSexCategory(selectedRow.getSexCategory()); - batchNewRow.setSexCategoryWeight(selectedRow.getSexCategoryWeight()); + newBatch.setSexCategory(parentBatch.getSexCategory()); + newBatch.setSexCategoryWeight(parentBatch.getSexCategoryWeight()); } if (selectedCategory == SampleCategoryType.maturity) { - batchNewRow.setMaturityCategory((CaracteristicQualitativeValue) row.getCategoryValue()); - batchNewRow.setMaturityCategoryWeight(row.getWeight()); + newBatch.setMaturityCategory((CaracteristicQualitativeValue) row.getCategoryValue()); + newBatch.setMaturityCategoryWeight(row.getWeight()); } else { - batchNewRow.setMaturityCategory(selectedRow.getMaturityCategory()); - batchNewRow.setMaturityCategoryWeight(selectedRow.getMaturityCategoryWeight()); + newBatch.setMaturityCategory(parentBatch.getMaturityCategory()); + newBatch.setMaturityCategoryWeight(parentBatch.getMaturityCategoryWeight()); } if (selectedCategory == SampleCategoryType.age) { - batchNewRow.setAgeCategory((Float) row.getCategoryValue()); - batchNewRow.setAgeCategoryWeight(row.getWeight()); + newBatch.setAgeCategory((Float) row.getCategoryValue()); + newBatch.setAgeCategoryWeight(row.getWeight()); } else { - batchNewRow.setAgeCategory(selectedRow.getAgeCategory()); - batchNewRow.setAgeCategoryWeight(selectedRow.getAgeCategoryWeight()); + newBatch.setAgeCategory(parentBatch.getAgeCategory()); + newBatch.setAgeCategoryWeight(parentBatch.getAgeCategoryWeight()); } - batchTableModel.addNewRow(++insertRow, batchNewRow); - boolean rowValid = isRowValid(batchNewRow); - batchNewRow.setValid(rowValid); - saveRow(batchNewRow); + tableModel.addNewRow(++insertRow, newBatch); + boolean rowValid = isRowValid(newBatch); + newBatch.setValid(rowValid); + newBatch.setBatchParent(parentBatch); + newBatches.add(newBatch); } } + // add new batches to his parent + parentBatch.setChilds(newBatches); + + //TODO Should only save parentBatch (will persist all his childs) + //saveRow(parentBatch); + + // save new batches + saveRows(newBatches); } // reset split ui - sampleCategoryEditor.getHandler().editBatch(null); + splitBatchEditor.getHandler().editBatch(null); + recomputeBatchActionEnable(); - // reselect this cell - AbstractSelectTableAction.doSelectCell(table, rowIndex, 0); - table.requestFocus(); +// // reselect this cell +// AbstractSelectTableAction.doSelectCell(table, rowIndex, 0); +// table.requestFocus(); } public void removeSpeciesSubBatch() { //TODO + int rowIndex = getTable().getSelectedRow(); + + Preconditions.checkState(rowIndex != -1, + "Cant remove sub batch if no batch selected"); + + SpeciesBatchRowModel parentBatch = getTableModel().getEntry(rowIndex); + + // collect of rows to remove from model + Set<SpeciesBatchRowModel> rowToRemove = Sets.newHashSet(); + collectChilds(parentBatch, rowToRemove); + + // remove all rows from the model + getModel().getRows().removeAll(rowToRemove); + + // remove childs from parent batch + parentBatch.setChilds(null); + + // save parent batch (will destroy all his childs from db) + saveRow(parentBatch); + + // refresh table from parent batch row index to the end + getTableModel().fireTableRowsUpdated(rowIndex, + getTableModel().getRowCount() - 1); } //------------------------------------------------------------------------// //-- Internal methods --// //------------------------------------------------------------------------// + protected void saveRows(Iterable<SpeciesBatchRowModel> rows) { + for (SpeciesBatchRowModel row : rows) { + saveRow(row); + } + } + protected void saveRow(SpeciesBatchRowModel row) { SpeciesBatch catchBean = row.toBean(); @@ -792,50 +790,6 @@ row.setFrequency(frequencyRows); } -// 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().getSpeciesTotalWeight(); -// } 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 @@ -873,6 +827,7 @@ // getModel().setTotalVracWeight(totalVrac); } + protected void recomputeBatchActionEnable() { int rowIndex = getTable().getSelectedRow(); @@ -903,13 +858,15 @@ if (enableSplit) { - // the select batch can not have any batch child + // can split if selected batch is a leaf + enableSplit = row.isBatchLeaf(); } if (enableRemove) { - // the selected batch must have some batch child + // can remove sub batch if selected batch is not a leaf + enableRemove = !row.isBatchLeaf(); } } getModel().setCreateSpeciesBatchEnabled(enableAdd); @@ -918,6 +875,18 @@ } + protected void collectChilds(SpeciesBatchRowModel row, + Set<SpeciesBatchRowModel> collectedRows) { + + if (!row.isBatchLeaf()) { + + for (SpeciesBatchRowModel batchChild : row.getBatchChild()) { + collectedRows.add(batchChild); + collectChilds(batchChild, collectedRows); + } + } + } + protected <C extends Serializable> void addSampleCategoryColumnToModel(TableColumnModel columnModel, ColumnIdentifier<SpeciesBatchRowModel> columnIdentifier, Decorator<C> decorator, @@ -927,4 +896,49 @@ SampleCategoryComponent.newRender(defaultRenderer, decorator), columnIdentifier); } + + +// 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().getSpeciesTotalWeight(); +// } 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()); +// } } Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/FrequencyCellComponent.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/FrequencyCellComponent.java 2013-01-01 18:27:33 UTC (rev 136) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/FrequencyCellComponent.java 2013-01-01 23:04:02 UTC (rev 137) @@ -25,9 +25,10 @@ */ import com.google.common.base.Preconditions; +import com.google.common.collect.Lists; import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SpeciesBatchRowModel; import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SpeciesBatchTableModel; -import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil; +import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SpeciesBatchUI; import fr.ifremer.tutti.ui.swing.util.table.AbstractSelectTableAction; import fr.ifremer.tutti.ui.swing.util.table.ColumnIdentifier; import jaxx.runtime.SwingUtil; @@ -42,11 +43,11 @@ import javax.swing.table.TableCellRenderer; 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.util.List; import static org.nuiton.i18n.I18n._; @@ -76,7 +77,7 @@ return new FrequencyCellRenderer(); } - public static TableCellEditor newEditor(SpeciesFrequencyUI ui) { + public static TableCellEditor newEditor(SpeciesBatchUI ui) { return new FrequencyCellEditor(ui); } @@ -86,10 +87,8 @@ protected final FrequencyCellComponent component; - protected final SpeciesFrequencyUI ui; + protected final SpeciesBatchUI ui; - protected Frame frame; - protected JTable table; protected SpeciesBatchTableModel tableModel; @@ -102,7 +101,7 @@ protected Integer columnIndex; - public FrequencyCellEditor(SpeciesFrequencyUI ui) { + public FrequencyCellEditor(SpeciesBatchUI ui) { this.ui = ui; component = new FrequencyCellComponent(); component.setBorder(new LineBorder(Color.BLACK)); @@ -138,20 +137,44 @@ log.info("Will edit frequencies for row: " + rowIndex); } - if (frame == null) { - frame = SwingUtil.getParentContainer(ui, Frame.class); - } + SpeciesFrequencyUI frequencyEditor = ui.getFrequencyEditor(); + frequencyEditor.editBatch(editRow); - ui.editBatch(editRow); - // open frequency dialog - TuttiUIUtil.openInDialog( - ui, frame, _("tutti.title.frequency"), true, null); + ui.getHandler().openDialog(ui, + frequencyEditor, + _("tutti.title.frequency"), + ui.getPreferredSize()); - // at close, synch back frequencies + SpeciesFrequencyUIModel frequencyModel = frequencyEditor.getModel(); - editRow.updateTotalFromFrequencies(); + if (frequencyModel.isValid()) { + // at close, synch back frequencies + + // transfer rows to editor + List<SpeciesFrequencyRowModel> frequency = Lists.newArrayList(); + for (SpeciesFrequencyRowModel row : frequencyModel.getRows()) { + if (row.isValid()) { + + // can keep this row + frequency.add(row); + } + } + + if (log.isInfoEnabled()) { + log.info("Push back " + frequency.size() + + " frequency to batch " + frequencyModel.getBatch()); + } + + // push back to batch + editRow.setFrequency(frequency); + + editRow.updateTotalFromFrequencies(); + } + + frequencyEditor.editBatch(null); + int r = rowIndex; int c = columnIndex; Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUI.css =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUI.css 2013-01-01 18:27:33 UTC (rev 136) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUI.css 2013-01-01 23:04:02 UTC (rev 137) @@ -35,7 +35,7 @@ #splitPane { orientation: {JSplitPane.VERTICAL_SPLIT}; - resizeWeight: 0.8; + resizeWeight: 0.2; oneTouchExpandable: true; continuousLayout: true; } Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUIHandler.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUIHandler.java 2013-01-01 18:27:33 UTC (rev 136) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUIHandler.java 2013-01-01 23:04:02 UTC (rev 137) @@ -31,17 +31,17 @@ import fr.ifremer.tutti.ui.swing.TuttiUIContext; import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SpeciesBatchRowModel; import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SpeciesBatchUIHandler; +import fr.ifremer.tutti.ui.swing.util.Cancelable; import fr.ifremer.tutti.ui.swing.util.TuttiBeanMonitor; import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableUIHandler; -import jaxx.runtime.SwingUtil; import jaxx.runtime.validator.swing.SwingValidatorMessageTableRenderer; import jaxx.runtime.validator.swing.SwingValidatorUtil; +import org.apache.commons.collections.CollectionUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.jdesktop.swingx.JXTable; import org.jdesktop.swingx.table.DefaultTableColumnModelExt; -import javax.swing.JDialog; import java.awt.event.KeyAdapter; import java.awt.event.KeyEvent; import java.beans.PropertyChangeEvent; @@ -54,7 +54,7 @@ * @author tchemit <chemit@codelutin.com> * @since 0.2 */ -public class SpeciesFrequencyUIHandler extends AbstractTuttiTableUIHandler<SpeciesFrequencyRowModel, SpeciesFrequencyUIModel> { +public class SpeciesFrequencyUIHandler extends AbstractTuttiTableUIHandler<SpeciesFrequencyRowModel, SpeciesFrequencyUIModel> implements Cancelable { /** Logger. */ private static final Log log = @@ -253,6 +253,27 @@ } //------------------------------------------------------------------------// + //-- Cancelable methods --// + //------------------------------------------------------------------------// + + @Override + public void cancel() { + + if (log.isInfoEnabled()) { + log.info("Cancel UI " + ui); + } + + // evict model from validator + ui.getValidator().setBean(null); + + // when canceling always invalid model (in that way) + getModel().setValid(false); + + // close dialog + closeDialog(ui); + } + + //------------------------------------------------------------------------// //-- Public methods --// //------------------------------------------------------------------------// @@ -352,8 +373,11 @@ newRow.setComputedWeight(rowModel.getComputedWeight()); editFrequency.add(newRow); } - lengthStepCaracteristic = - frequency.get(0).getLengthStepCaracteristic(); + + if (CollectionUtils.isNotEmpty(frequency)) { + lengthStepCaracteristic = + frequency.get(0).getLengthStepCaracteristic(); + } } if (log.isInfoEnabled()) { @@ -363,6 +387,9 @@ SpeciesFrequencyUIModel model = getModel(); + // connect model to validator + ui.getValidator().setBean(model); + model.setRows(editFrequency); if (lengthStepCaracteristic == null) { @@ -387,49 +414,13 @@ model.setBatch(speciesBatch); } - public void cancel() { - - if (log.isInfoEnabled()) { - log.info("Cancel UI " + ui); - } - - // when canceling always invalid model (in that way) - getModel().setValid(false); - - ui.editBatch(null); - - SwingUtil.getParentContainer(ui, JDialog.class).setVisible(false); - } - public void save() { if (log.isInfoEnabled()) { - log.info("Will Save and close UI " + ui); + log.info("Save UI " + ui); } - SpeciesFrequencyUIModel model = getModel(); - - // transfer rows to editor - List<SpeciesFrequencyRowModel> frequency = Lists.newArrayList(); - for (SpeciesFrequencyRowModel row : model.getRows()) { - if (row.isValid()) { - - // can keep this row - frequency.add(row); - } - } - - if (log.isInfoEnabled()) { - log.info("Push back " + frequency.size() + - " frequency to batch " + model.getBatch()); - } - - // push back to batch - model.getBatch().setFrequency(frequency); - - ui.editBatch(null); - - SwingUtil.getParentContainer(ui, JDialog.class).setVisible(false); + closeDialog(ui); } //------------------------------------------------------------------------// Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/CreateSpeciesBatchUI.css =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/CreateSpeciesBatchUI.css 2013-01-01 18:27:33 UTC (rev 136) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/CreateSpeciesBatchUI.css 2013-01-01 23:04:02 UTC (rev 137) @@ -36,7 +36,7 @@ #splitPane { orientation: {JSplitPane.VERTICAL_SPLIT}; - resizeWeight: 0.8; + resizeWeight: 0.2; oneTouchExpandable: true; continuousLayout: true; } Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/CreateSpeciesBatchUI.jaxx =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/CreateSpeciesBatchUI.jaxx 2013-01-01 18:27:33 UTC (rev 136) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/CreateSpeciesBatchUI.jaxx 2013-01-01 23:04:02 UTC (rev 137) @@ -75,7 +75,7 @@ <field name='batchWeight' component='batchWeightField'/> </BeanValidator> - <JSplitPane id='splitPane' constraints='BorderLayout.CENTER'> + <JSplitPane id='splitPane' constraints='BorderLayout.NORTH'> <Table id='configurationPanel' fill='both'> @@ -113,7 +113,8 @@ <!-- Messages report --> <JPanel id='messagePanel' layout='{new GridLayout()}'> - <JScrollPane columnHeaderView='{errorTable.getTableHeader()}'> + <JScrollPane id='errorTableScrollPane' + columnHeaderView='{errorTable.getTableHeader()}'> <JTable id='errorTable'/> </JScrollPane> </JPanel> Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/CreateSpeciesBatchUIHandler.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/CreateSpeciesBatchUIHandler.java 2013-01-01 18:27:33 UTC (rev 136) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/CreateSpeciesBatchUIHandler.java 2013-01-01 23:04:02 UTC (rev 137) @@ -29,13 +29,12 @@ import fr.ifremer.tutti.ui.swing.AbstractTuttiUIHandler; import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SpeciesBatchUI; import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SpeciesBatchUIModel; -import jaxx.runtime.SwingUtil; +import fr.ifremer.tutti.ui.swing.util.Cancelable; import jaxx.runtime.validator.swing.SwingValidatorMessageTableRenderer; import jaxx.runtime.validator.swing.SwingValidatorUtil; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import javax.swing.JDialog; import java.util.List; /** @@ -44,7 +43,7 @@ * @author tchemit <chemit@codelutin.com> * @since 0.3 */ -public class CreateSpeciesBatchUIHandler extends AbstractTuttiUIHandler<CreateSpeciesBatchUIModel> { +public class CreateSpeciesBatchUIHandler extends AbstractTuttiUIHandler<CreateSpeciesBatchUIModel> implements Cancelable { /** Logger. */ private static final Log log = @@ -104,15 +103,42 @@ } //------------------------------------------------------------------------// + //-- Cancelable methods --// + //------------------------------------------------------------------------// + + @Override + public void cancel() { + + if (log.isInfoEnabled()) { + log.info("Cancel UI " + ui); + } + + // evict model from validator + ui.getValidator().setBean(null); + + // when canceling always invalid model + getModel().setValid(false); + + // close dialog + closeDialog(ui); + } + + //------------------------------------------------------------------------// //-- Public methods --// //------------------------------------------------------------------------// - public void editBatch(SpeciesBatchUIModel batchModel) { + public void openUI(SpeciesBatchUIModel batchModel) { - getModel().setSpecies(null); - getModel().setBatchWeight(null); + CreateSpeciesBatchUIModel model = getModel(); + // connect model to validator + ui.getValidator().setBean(model); + + model.setSpecies(null); + model.setBatchWeight(null); + List<Species> speciesToUse = Lists.newArrayList(); + if (batchModel != null) { speciesToUse.addAll(batchModel.getAvailableSpecies()); @@ -121,26 +147,13 @@ ui.getSpeciesComboBox().setData(speciesToUse); } - public void cancel() { - - - if (log.isInfoEnabled()) { - log.info("Cancel UI " + ui); - } - - // wehn canceling always invalid model - getModel().setValid(false); - - SwingUtil.getParentContainer(ui, JDialog.class).setVisible(false); - } - public void save() { - if (log.isInfoEnabled()) { log.info("Save UI " + ui); } - SwingUtil.getParentContainer(ui, JDialog.class).setVisible(false); + // close dialog + closeDialog(ui); } } Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchUI.css =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchUI.css 2013-01-01 18:27:33 UTC (rev 136) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchUI.css 2013-01-01 23:04:02 UTC (rev 137) @@ -30,7 +30,7 @@ #splitPane { orientation: {JSplitPane.VERTICAL_SPLIT}; - resizeWeight: 0.8; + resizeWeight: 0.2; oneTouchExpandable: true; continuousLayout: true; } Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchUIHandler.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchUIHandler.java 2013-01-01 18:27:33 UTC (rev 136) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchUIHandler.java 2013-01-01 23:04:02 UTC (rev 137) @@ -33,18 +33,16 @@ import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SampleCategoryType; import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SpeciesBatchRowModel; import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SpeciesBatchUI; +import fr.ifremer.tutti.ui.swing.util.Cancelable; import fr.ifremer.tutti.ui.swing.util.TuttiBeanMonitor; import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableUIHandler; -import jaxx.runtime.SwingUtil; import jaxx.runtime.validator.swing.SwingValidatorMessageTableRenderer; import jaxx.runtime.validator.swing.SwingValidatorUtil; -import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.jdesktop.swingx.JXTable; import org.jdesktop.swingx.table.DefaultTableColumnModelExt; -import javax.swing.JDialog; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import java.util.List; @@ -56,7 +54,7 @@ * @since 0.3 */ public class SplitSpeciesBatchUIHandler - extends AbstractTuttiTableUIHandler<SplitSpeciesBatchRowModel, SplitSpeciesBatchUIModel> { + extends AbstractTuttiTableUIHandler<SplitSpeciesBatchRowModel, SplitSpeciesBatchUIModel> implements Cancelable { /** Logger. */ private static final Log log = @@ -198,15 +196,6 @@ } }); - // when sample weight changed, revalidate model - model.addPropertyChangeListener(SplitSpeciesBatchUIModel.PROPERTY_SAMPLE_WEIGHT, new PropertyChangeListener() { - @Override - public void propertyChange(PropertyChangeEvent evt) { - - validateModel(); - } - }); - generateTableModel(null); initTable(getTable()); @@ -222,6 +211,27 @@ } //------------------------------------------------------------------------// + //-- Cancelable methods --// + //------------------------------------------------------------------------// + + @Override + public void cancel() { + + if (log.isInfoEnabled()) { + log.info("Cancel UI " + ui); + } + + // evict model from validator + ui.getValidator().setBean(null); + + // when canceling always invalid model + getModel().setValid(false); + + // close dialog + closeDialog(ui); + } + + //------------------------------------------------------------------------// //-- Public methods --// //------------------------------------------------------------------------// @@ -285,6 +295,9 @@ SplitSpeciesBatchUIModel model = getModel(); + // connect model to validator + ui.getValidator().setBean(model); + model.setSampleWeight(null); model.setCategory(categories); model.setBatchWeight(batchWeight); @@ -293,24 +306,13 @@ model.setBatch(batch); } - public void cancel() { - - if (log.isInfoEnabled()) { - log.info("Cancel UI " + ui); - } - - editBatch(null); - - SwingUtil.getParentContainer(ui, JDialog.class).setVisible(false); - } - public void save() { if (log.isInfoEnabled()) { log.info("Save UI " + ui); } - SwingUtil.getParentContainer(ui, JDialog.class).setVisible(false); + closeDialog(ui); } //------------------------------------------------------------------------// @@ -334,25 +336,6 @@ getModel().setSampleWeight(result); } - protected void validateModel() { - - SplitSpeciesBatchUIModel model = getModel(); - - int rowCount = model.getRowCount(); - - // at least one row - boolean valid = rowCount > 0; - - if (valid && !model.isSample()) { - - // sample Weight = batch weight - valid = ObjectUtils.equals(model.getBatchWeight(), - model.getSampleWeight()); - } - - model.setValid(valid); - } - protected void generateTableModel(SampleCategoryType category) { // when generate a new table model, then reset previous rows from model Added: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/Cancelable.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/Cancelable.java (rev 0) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/Cancelable.java 2013-01-01 23:04:02 UTC (rev 137) @@ -0,0 +1,36 @@ +package fr.ifremer.tutti.ui.swing.util; + +/* + * #%L + * Tutti :: UI + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2012 - 2013 Ifremer + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ + +/** + * To cancel contract. + * + * @author tchemit <chemit@codelutin.com> + * @since 0.3 + */ +public interface Cancelable { + + void cancel(); +} Property changes on: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/Cancelable.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/util/TuttiUIUtil.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/TuttiUIUtil.java 2013-01-01 18:27:33 UTC (rev 136) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/TuttiUIUtil.java 2013-01-01 23:04:02 UTC (rev 137) @@ -26,8 +26,6 @@ import com.google.common.base.Preconditions; import fr.ifremer.tutti.service.TuttiServiceTechnicalException; -import jaxx.runtime.JAXXUtil; -import jaxx.runtime.SwingUtil; import org.apache.commons.beanutils.PropertyUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -35,20 +33,11 @@ import org.jdesktop.swingx.decorator.Highlighter; import org.nuiton.util.FileUtil; -import javax.swing.Action; -import javax.swing.JComponent; -import javax.swing.JDialog; import javax.swing.JOptionPane; -import javax.swing.JRootPane; -import javax.swing.KeyStroke; import javax.swing.UIManager; import java.awt.Color; import java.awt.Component; import java.awt.Cursor; -import java.awt.Dimension; -import java.awt.Frame; -import java.awt.event.WindowAdapter; -import java.awt.event.WindowEvent; import java.io.File; /** @@ -66,51 +55,51 @@ // never instanciate util class } - public static JDialog openInDialog(JComponent ui, - Frame frame, - String title, - boolean modal, - Action closeAction) { - return openInDialog(ui, frame, title, modal, closeAction, null); - } + // public static JDialog openInDialog(JComponent ui, +// Frame frame, +// String title, +// boolean modal, +// Action closeAction) { +// return openInDialog(ui, frame, title, modal, closeAction, null); +// } +// +// public static JDialog openInDialog(JComponent ui, +// Frame frame, +// String title, +// boolean modal, +// Action closeAction, +// Dimension dim) { +// +// JDialog result = new JDialog(frame, modal); +// result.setTitle(title); +// result.add(ui); +// result.setResizable(true); +// if (dim == null) { +// result.setSize(550, 450); +// } else { +// result.setSize(dim); +// } +// if (closeAction != null) { +// JRootPane rootPane = result.getRootPane(); +// rootPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("ESCAPE"), "close"); +// rootPane.getActionMap().put("close", closeAction); +// } +// result.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); +// } +// }); +// SwingUtil.center(frame, result); +// result.setVisible(true); +// return result; +// } - public static JDialog openInDialog(JComponent ui, - Frame frame, - String title, - boolean modal, - Action closeAction, - Dimension dim) { - - JDialog result = new JDialog(frame, modal); - result.setTitle(title); - result.add(ui); - result.setResizable(true); - if (dim == null) { - result.setSize(550, 450); - } else { - result.setSize(dim); - } - if (closeAction != null) { - JRootPane rootPane = result.getRootPane(); - rootPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("ESCAPE"), "close"); - rootPane.getActionMap().put("close", closeAction); - } - result.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); - } - }); - SwingUtil.center(frame, result); - result.setVisible(true); - return result; - } - /** * Choisir un fichier via un sélecteur graphique de fichiers. * Modified: trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties =================================================================== --- trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties 2013-01-01 18:27:33 UTC (rev 136) +++ trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties 2013-01-01 23:04:02 UTC (rev 137) @@ -240,6 +240,7 @@ tutti.title.create.cruise=Créer une nouvelle campagne tutti.title.create.program=Créer une nouvelle série de campagne tutti.title.create.protocol=Créer un nouveau protocol de saisie +tutti.title.createBatch=Créer un lot pour une nouvelle espèce tutti.title.edit.cruise=Éditer une campagne existante tutti.title.edit.operations=Saisie des opérations de pêches (%s) tutti.title.edit.program=Éditer une série de campagne existante
participants (1)
-
tchemit@users.forge.codelutin.com