r1274 - in trunk/tutti-ui-swing/src/main: java/fr/ifremer/tutti/ui/swing/content java/fr/ifremer/tutti/ui/swing/content/config java/fr/ifremer/tutti/ui/swing/content/home java/fr/ifremer/tutti/ui/swing/content/operation java/fr/ifremer/tutti/ui/swing/content/operation/catches/accidental java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos java/fr/ifremer/tutti/ui/swing/content/operation/catches/individualobservation java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinel
Author: tchemit Date: 2013-10-04 09:14:17 +0200 (Fri, 04 Oct 2013) New Revision: 1274 Url: http://forge.codelutin.com/projects/tutti/repository/revisions/1274 Log: fixes #3424: [TECH] Am?\195?\169liorer le temps d'ouverture de l'?\195?\169cran protocole fixes #3331: [ERGO] - Lisibilit?\195?\169 des tableaux (captures, protocole) Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/EditSelectedProtocolAction.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/config/TuttiConfigUIHandler.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/CloneProtocolAction.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/EditProtocolAction.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/ImportProtocolAction.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/NewProtocolAction.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/AbstractTuttiBatchTableUIHandler.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/accidental/AccidentalBatchUI.css trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/accidental/AccidentalBatchUIHandler.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUIHandler.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/individualobservation/IndividualObservationBatchRowModel.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/individualobservation/IndividualObservationBatchTableModel.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/individualobservation/IndividualObservationBatchUIHandler.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/MarineLitterBatchUI.css trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/MarineLitterBatchUIHandler.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/protocol/EditProtocolUIHandler.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUIModel.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/AbstractTuttiUIHandler.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/action/AbstractTuttiAction.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/action/TuttiUIAction.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/AbstractTuttiTableUIHandler.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/EditSelectedProtocolAction.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/EditSelectedProtocolAction.java 2013-10-04 07:09:12 UTC (rev 1273) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/EditSelectedProtocolAction.java 2013-10-04 07:14:17 UTC (rev 1274) @@ -38,7 +38,8 @@ public class EditSelectedProtocolAction extends AbstractChangeScreenAction { /** Logger. */ - private static final Log log = LogFactory.getLog(EditSelectedProtocolAction.class); + private static final Log log = + LogFactory.getLog(EditSelectedProtocolAction.class); public EditSelectedProtocolAction(MainUIHandler handler) { super(handler, true, TuttiScreen.EDIT_PROTOCOL); @@ -47,9 +48,10 @@ @Override public void doAction() throws Exception { Preconditions.checkState(getContext().isProtocolFilled()); - if (log.isInfoEnabled()) { - log.info("Edit protocol: " + getContext().getProtocolId()); + if (log.isDebugEnabled()) { + log.debug("Edit protocol: " + getContext().getProtocolId()); } + createProgressionModelIfRequired(4); super.doAction(); } Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/config/TuttiConfigUIHandler.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/config/TuttiConfigUIHandler.java 2013-10-04 07:09:12 UTC (rev 1273) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/config/TuttiConfigUIHandler.java 2013-10-04 07:14:17 UTC (rev 1274) @@ -150,8 +150,8 @@ helper.addCategory(n_("tutti.config.category.ui"), n_("tutti.config.category.ui.description"), CALLBACK_UI) + .addOption(TuttiApplicationConfigOption.COLOR_ALTERNATE_ROW) .addOption(TuttiApplicationConfigOption.COLOR_SELECTED_ROW) - .addOption(TuttiApplicationConfigOption.COLOR_ALTERNATE_ROW) .addOption(TuttiApplicationConfigOption.COLOR_ROW_INVALID) .addOption(TuttiApplicationConfigOption.COLOR_ROW_READ_ONLY) .addOption(TuttiApplicationConfigOption.COLOR_CELL_WITH_VALUE) Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/CloneProtocolAction.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/CloneProtocolAction.java 2013-10-04 07:09:12 UTC (rev 1273) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/CloneProtocolAction.java 2013-10-04 07:14:17 UTC (rev 1274) @@ -151,6 +151,8 @@ CLONE_PROTOCOL_ENTRY.setContextValue(getContext().getMainUI(), protocol); protocol = null; + createProgressionModelIfRequired(4); + // removed selected protocol getContext().setProtocolId(null); Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/EditProtocolAction.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/EditProtocolAction.java 2013-10-04 07:09:12 UTC (rev 1273) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/EditProtocolAction.java 2013-10-04 07:14:17 UTC (rev 1274) @@ -148,8 +148,8 @@ if (log.isInfoEnabled()) { log.info("Edit protocol: " + getContext().getProtocolId()); } + createProgressionModelIfRequired(4); super.doAction(); } - } Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/ImportProtocolAction.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/ImportProtocolAction.java 2013-10-04 07:09:12 UTC (rev 1273) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/ImportProtocolAction.java 2013-10-04 07:14:17 UTC (rev 1274) @@ -172,6 +172,7 @@ // store protocol in context IMPORT_PROTOCOL_ENTRY.setContextValue(getContext().getMainUI(), protocol); protocol = null; + createProgressionModelIfRequired(4); // removed selected protocol getContext().setProtocolId(null); Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/NewProtocolAction.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/NewProtocolAction.java 2013-10-04 07:09:12 UTC (rev 1273) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/NewProtocolAction.java 2013-10-04 07:14:17 UTC (rev 1274) @@ -43,6 +43,7 @@ @Override public void doAction() throws Exception { getContext().setProtocolId(null); + createProgressionModelIfRequired(4); super.doAction(); } } Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/AbstractTuttiBatchTableUIHandler.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/AbstractTuttiBatchTableUIHandler.java 2013-10-04 07:09:12 UTC (rev 1273) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/AbstractTuttiBatchTableUIHandler.java 2013-10-04 07:14:17 UTC (rev 1274) @@ -27,13 +27,23 @@ import fr.ifremer.tutti.persistence.entities.data.FishingOperation; import fr.ifremer.tutti.ui.swing.util.AbstractTuttiBeanUIModel; import fr.ifremer.tutti.ui.swing.util.TuttiUI; +import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil; import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableModel; import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableUIHandler; +import fr.ifremer.tutti.ui.swing.util.table.ColumnIdentifier; +import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.lang3.StringUtils; 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.sort.TableSortController; import javax.swing.table.TableColumnModel; import javax.swing.table.TableModel; +import java.awt.Color; +import java.awt.Component; +import java.util.Collection; /** * Abstract ui handler forbatch ui. @@ -43,6 +53,10 @@ */ public abstract class AbstractTuttiBatchTableUIHandler<R extends AbstractTuttiBeanUIModel, M extends AbstractTuttiBatchUIModel<R, M>, UI extends TuttiUI<M, ?>> extends AbstractTuttiTableUIHandler<R, M, UI> { + protected abstract ColumnIdentifier<R> getCommentIdentifier(); + + protected abstract ColumnIdentifier<R> getAttachementIdentifier(); + public abstract void selectFishingOperation(FishingOperation bean); protected AbstractTuttiBatchTableUIHandler(TuttiUI<?, ?> parentUi, @@ -72,6 +86,17 @@ table.clearSelection(); } + @Override + protected void onRowModified(int rowIndex, + R row, + String propertyName, + Object oldValue, + Object newValue) { + recomputeRowValidState(row); + + saveSelectedRowIfNeeded(); + } + protected void initBatchTable(JXTable table, TableColumnModel columnModel, AbstractTuttiTableModel<R> tableModel) { @@ -84,4 +109,46 @@ initTable(table); } + + @Override + protected void addHighlighters(final JXTable table) { + super.addHighlighters(table); + addCommentHighlighter(table, getCommentIdentifier()); + addAttachementHighlighter(table, getAttachementIdentifier()); + } + + protected void addCommentHighlighter(JXTable table, ColumnIdentifier identifier) { + Color cellWithValueColor = getConfig().getColorCellWithValue(); + + Highlighter commentHighlighter = TuttiUIUtil.newBackgroundColorHighlighter( + new HighlightPredicate.AndHighlightPredicate( + new HighlightPredicate.IdentifierHighlightPredicate(identifier), + // for not null value + new HighlightPredicate() { + @Override + public boolean isHighlighted(Component renderer, ComponentAdapter adapter) { + String value = (String) adapter.getValue(); + return StringUtils.isNotBlank(value); + } + }), cellWithValueColor); + table.addHighlighter(commentHighlighter); + } + + protected void addAttachementHighlighter(JXTable table, ColumnIdentifier identifier) { + Color cellWithValueColor = getConfig().getColorCellWithValue(); + + Highlighter attachmentHighlighter = TuttiUIUtil.newBackgroundColorHighlighter( + new HighlightPredicate.AndHighlightPredicate( + new HighlightPredicate.IdentifierHighlightPredicate(identifier), + // for not null value + new HighlightPredicate() { + @Override + public boolean isHighlighted(Component renderer, ComponentAdapter adapter) { + Collection attachments = (Collection) adapter.getValue(); + return CollectionUtils.isNotEmpty(attachments); + } + } + ), cellWithValueColor); + table.addHighlighter(attachmentHighlighter); + } } Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/accidental/AccidentalBatchUI.css =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/accidental/AccidentalBatchUI.css 2013-10-04 07:09:12 UTC (rev 1273) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/accidental/AccidentalBatchUI.css 2013-10-04 07:14:17 UTC (rev 1274) @@ -45,7 +45,6 @@ #table { selectionMode: {ListSelectionModel.SINGLE_SELECTION}; - selectionBackground: {null}; selectionForeground: {Color.BLACK}; sortable: false; } Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/accidental/AccidentalBatchUIHandler.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/accidental/AccidentalBatchUIHandler.java 2013-10-04 07:09:12 UTC (rev 1273) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/accidental/AccidentalBatchUIHandler.java 2013-10-04 07:14:17 UTC (rev 1274) @@ -45,7 +45,6 @@ import fr.ifremer.tutti.ui.swing.content.operation.catches.individualobservation.IndividualObservationBatchTableModel; import fr.ifremer.tutti.ui.swing.util.TuttiBeanMonitor; import fr.ifremer.tutti.ui.swing.util.TuttiUI; -import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil; import fr.ifremer.tutti.ui.swing.util.attachment.AttachmentCellEditor; import fr.ifremer.tutti.ui.swing.util.attachment.AttachmentCellRenderer; import fr.ifremer.tutti.ui.swing.util.caracteristics.CaracteristicMapCellComponent; @@ -54,24 +53,17 @@ import fr.ifremer.tutti.ui.swing.util.comment.CommentCellEditor; import fr.ifremer.tutti.ui.swing.util.comment.CommentCellRenderer; import fr.ifremer.tutti.ui.swing.util.table.AbstractSelectTableAction; +import fr.ifremer.tutti.ui.swing.util.table.ColumnIdentifier; import jaxx.runtime.SwingUtil; import jaxx.runtime.validator.swing.SwingValidator; -import org.apache.commons.collections.CollectionUtils; -import org.apache.commons.lang3.StringUtils; 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.decorator.Decorator; import org.nuiton.validator.NuitonValidatorResult; import javax.swing.JComponent; -import java.awt.Color; -import java.awt.Component; -import java.util.Collection; import java.util.List; /** @@ -116,6 +108,16 @@ //------------------------------------------------------------------------// @Override + protected ColumnIdentifier<AccidentalBatchRowModel> getCommentIdentifier() { + return AccidentalBatchTableModel.COMMENT; + } + + @Override + protected ColumnIdentifier<AccidentalBatchRowModel> getAttachementIdentifier() { + return AccidentalBatchTableModel.ATTACHMENT; + } + + @Override public void selectFishingOperation(FishingOperation bean) { boolean empty = bean == null; @@ -149,20 +151,6 @@ model.setRows(rows); } - protected AccidentalBatchRowModel loadBatch(AccidentalBatch aBatch) { - - AccidentalBatchRowModel newRow = - new AccidentalBatchRowModel(weightUnit, aBatch); - - List<Attachment> attachments = - persistenceService.getAllAttachments(newRow.getObjectType(), - newRow.getObjectId()); - - newRow.addAllAttachment(attachments); - - return newRow; - } - //------------------------------------------------------------------------// //-- AbstractTuttiTableUIHandler methods --// //------------------------------------------------------------------------// @@ -201,16 +189,6 @@ } @Override - protected void onRowModified(int rowIndex, - AccidentalBatchRowModel row, - String propertyName, - Object oldValue, - Object newValue) { - recomputeRowValidState(row); - saveSelectedRowIfNeeded(); - } - - @Override protected void saveSelectedRowIfRequired(TuttiBeanMonitor<AccidentalBatchRowModel> rowMonitor, AccidentalBatchRowModel row) { @@ -237,42 +215,6 @@ } } - @Override - protected void addHighlighters(JXTable table) { - super.addHighlighters(table); - - // paint in a special color for comment cell (with not null value) - Color cellWithValueColor = getConfig().getColorCellWithValue(); - - Highlighter commentHighlighter = TuttiUIUtil.newBackgroundColorHighlighter( - new HighlightPredicate.AndHighlightPredicate( - new HighlightPredicate.IdentifierHighlightPredicate(AccidentalBatchTableModel.COMMENT), - // for not null value - new HighlightPredicate() { - @Override - public boolean isHighlighted(Component renderer, ComponentAdapter adapter) { - String value = (String) adapter.getValue(); - return StringUtils.isNotBlank(value); - } - }), cellWithValueColor); - table.addHighlighter(commentHighlighter); - - // paint in a special color for attachment cell (when some attachments) - Highlighter attachmentHighlighter = TuttiUIUtil.newBackgroundColorHighlighter( - new HighlightPredicate.AndHighlightPredicate( - new HighlightPredicate.IdentifierHighlightPredicate(AccidentalBatchTableModel.ATTACHMENT), - // for not null value - new HighlightPredicate() { - @Override - public boolean isHighlighted(Component renderer, ComponentAdapter adapter) { - Collection attachments = (Collection) adapter.getValue(); - return CollectionUtils.isNotEmpty(attachments); - } - } - ), cellWithValueColor); - table.addHighlighter(attachmentHighlighter); - } - //------------------------------------------------------------------------// //-- AbstractTuttiUIHandler methods --// //------------------------------------------------------------------------// @@ -473,6 +415,20 @@ //-- Internal methods --// //------------------------------------------------------------------------// + protected AccidentalBatchRowModel loadBatch(AccidentalBatch aBatch) { + + AccidentalBatchRowModel newRow = + new AccidentalBatchRowModel(weightUnit, aBatch); + + List<Attachment> attachments = + persistenceService.getAllAttachments(newRow.getObjectType(), + newRow.getObjectId()); + + newRow.addAllAttachment(attachments); + + return newRow; + } + protected void saveRow(AccidentalBatchRowModel row) { AccidentalBatch entityToSave = row.toEntity(); Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUIHandler.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUIHandler.java 2013-10-04 07:09:12 UTC (rev 1273) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUIHandler.java 2013-10-04 07:14:17 UTC (rev 1274) @@ -75,7 +75,6 @@ import jaxx.runtime.validator.swing.SwingValidator; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.lang3.ObjectUtils; -import org.apache.commons.lang3.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.jdesktop.swingx.JXTable; @@ -99,7 +98,6 @@ import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import java.io.Serializable; -import java.util.Collection; import java.util.EnumMap; import java.util.List; import java.util.Set; @@ -208,6 +206,16 @@ //------------------------------------------------------------------------// @Override + protected ColumnIdentifier<BenthosBatchRowModel> getCommentIdentifier() { + return BenthosBatchTableModel.COMMENT; + } + + @Override + protected ColumnIdentifier<BenthosBatchRowModel> getAttachementIdentifier() { + return BenthosBatchTableModel.ATTACHMENT; + } + + @Override public void selectFishingOperation(FishingOperation bean) { boolean empty = bean == null; @@ -306,6 +314,8 @@ recomputeRowValidState(row); + BenthosBatchTableModel tableModel = getTableModel(); + if (BenthosBatchRowModel.PROPERTY_SAMPLE_CATEGORY_WEIGHT.equals(propertyName)) { // sampling category weight has changed, must then save the top @@ -315,7 +325,6 @@ SampleCategory<?> sampleCategory = (SampleCategory<?>) newValue; Integer sampleCategoryId = sampleCategory.getCategoryId(); - BenthosBatchTableModel tableModel = getTableModel(); BenthosBatchRowModel firstAncestorRow = row.getFirstAncestor(sampleCategory); int firstAncestorIndex = tableModel.getRowIndex(firstAncestorRow); @@ -347,12 +356,11 @@ boolean newVal = newValue == null ? false : (Boolean) newValue; - for (BenthosBatchRowModel sampleCategories : shell) { - sampleCategories.setSpeciesToConfirm(newVal); + for (BenthosBatchRowModel rowToUpdate : shell) { + rowToUpdate.setSpeciesToConfirm(newVal); } - getTableModel().fireTableRowUpdatedShell(shell); - + tableModel.fireTableRowUpdatedShell(shell); } saveSelectedRowIfNeeded(); @@ -400,19 +408,20 @@ addToSpeciesUsed(row); } } + getTable().clearSelection(); } - @Override - protected void onAfterSelectedRowChanged(int oldRowIndex, BenthosBatchRowModel oldRow, int newRowIndex, BenthosBatchRowModel newRow) { - super.onAfterSelectedRowChanged(oldRowIndex, oldRow, newRowIndex, newRow); +// @Override +// protected void onAfterSelectedRowChanged(int oldRowIndex, BenthosBatchRowModel oldRow, int newRowIndex, BenthosBatchRowModel newRow) { +// super.onAfterSelectedRowChanged(oldRowIndex, oldRow, newRowIndex, newRow); +// +// if (log.isInfoEnabled()) { +// log.info("After select row: " + newRowIndex); +// } +// +// saveSelectedRowIfNeeded(); +// } - if (log.isInfoEnabled()) { - log.info("After select row: " + newRowIndex); - } - - saveSelectedRowIfNeeded(); - } - @Override protected void addHighlighters(JXTable table) { @@ -445,37 +454,6 @@ }, toConfirmColor.darker()); table.addHighlighter(confirmNotEditableHighlighter); - - // paint in a special color for comment cell (with not null value) - Color cellWithValueColor = getConfig().getColorCellWithValue(); - - Highlighter commentHighlighter = TuttiUIUtil.newBackgroundColorHighlighter( - new HighlightPredicate.AndHighlightPredicate( - new HighlightPredicate.IdentifierHighlightPredicate(BenthosBatchTableModel.COMMENT), - // for not null value - new HighlightPredicate() { - @Override - public boolean isHighlighted(Component renderer, ComponentAdapter adapter) { - String value = (String) adapter.getValue(); - return StringUtils.isNotBlank(value); - } - }), cellWithValueColor); - table.addHighlighter(commentHighlighter); - - // paint in a special color for attachment cell (when some attachments) - Highlighter attachmentHighlighter = TuttiUIUtil.newBackgroundColorHighlighter( - new HighlightPredicate.AndHighlightPredicate( - new HighlightPredicate.IdentifierHighlightPredicate(BenthosBatchTableModel.ATTACHMENT), - // for not null value - new HighlightPredicate() { - @Override - public boolean isHighlighted(Component renderer, ComponentAdapter adapter) { - Collection attachments = (Collection) adapter.getValue(); - return CollectionUtils.isNotEmpty(attachments); - } - } - ), cellWithValueColor); - table.addHighlighter(attachmentHighlighter); } @Override Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/individualobservation/IndividualObservationBatchRowModel.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/individualobservation/IndividualObservationBatchRowModel.java 2013-10-04 07:09:12 UTC (rev 1273) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/individualobservation/IndividualObservationBatchRowModel.java 2013-10-04 07:14:17 UTC (rev 1274) @@ -232,30 +232,6 @@ firePropertyChange(PROPERTY_CARACTERISTICS, oldValue, caracteristics); } -// @Override -// public String getSamplingCode() { -// return editObject.getSamplingCode(); -// } -// -// @Override -// public void setSamplingCode(String samplingCode) { -// Object oldValue = getSamplingCode(); -// editObject.setSamplingCode(samplingCode); -// firePropertyChange(PROPERTY_SAMPLING_CODE, oldValue, samplingCode); -// } -// -// @Override -// public String getCalcifiedPieceSamplingCode() { -// return editObject.getCalcifiedPieceSamplingCode(); -// } -// -// @Override -// public void setCalcifiedPieceSamplingCode(String calcifiedPieceSamplingCode) { -// Object oldValue = getCalcifiedPieceSamplingCode(); -// editObject.setCalcifiedPieceSamplingCode(calcifiedPieceSamplingCode); -// firePropertyChange(PROPERTY_CALCIFIED_PIECE_SAMPLING_CODE, oldValue, calcifiedPieceSamplingCode); -// } - @Override public String getComment() { return editObject.getComment(); Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/individualobservation/IndividualObservationBatchTableModel.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/individualobservation/IndividualObservationBatchTableModel.java 2013-10-04 07:09:12 UTC (rev 1273) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/individualobservation/IndividualObservationBatchTableModel.java 2013-10-04 07:14:17 UTC (rev 1274) @@ -62,16 +62,6 @@ n_("tutti.editIndividualObservationBatch.table.header.otherCaracteristics"), n_("tutti.editIndividualObservationBatch.table.header.otherCaracteristics.tip")); -// public static final ColumnIdentifier<IndividualObservationBatchRowModel> CALCIFIED_PIECE_SAMPLING_CODE = ColumnIdentifier.newId( -// IndividualObservationBatchRowModel.PROPERTY_CALCIFIED_PIECE_SAMPLING_CODE, -// ("tutti.editIndividualObservationBatch.table.header.calcifiedPieceSamplingCode"), -// ("tutti.editIndividualObservationBatch.table.header.calcifiedPieceSamplingCode.tip")); -// -// public static final ColumnIdentifier<IndividualObservationBatchRowModel> SAMPLING_CODE = ColumnIdentifier.newId( -// IndividualObservationBatchRowModel.PROPERTY_SAMPLING_CODE, -// ("tutti.editIndividualObservationBatch.table.header.samplingCode"), -// ("tutti.editIndividualObservationBatch.table.header.samplingCode.tip")); - public static final ColumnIdentifier<IndividualObservationBatchRowModel> COMMENT = ColumnIdentifier.newId( IndividualObservationBatchRowModel.PROPERTY_COMMENT, n_("tutti.editIndividualObservationBatch.table.header.comment"), Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/individualobservation/IndividualObservationBatchUIHandler.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/individualobservation/IndividualObservationBatchUIHandler.java 2013-10-04 07:09:12 UTC (rev 1273) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/individualobservation/IndividualObservationBatchUIHandler.java 2013-10-04 07:14:17 UTC (rev 1274) @@ -47,7 +47,6 @@ import fr.ifremer.tutti.ui.swing.content.operation.catches.species.frequency.SpeciesFrequencyRowModel; import fr.ifremer.tutti.ui.swing.util.TuttiBeanMonitor; import fr.ifremer.tutti.ui.swing.util.TuttiUI; -import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil; import fr.ifremer.tutti.ui.swing.util.attachment.AttachmentCellEditor; import fr.ifremer.tutti.ui.swing.util.attachment.AttachmentCellRenderer; import fr.ifremer.tutti.ui.swing.util.caracteristics.CaracteristicMapCellComponent; @@ -57,26 +56,20 @@ import fr.ifremer.tutti.ui.swing.util.comment.CommentCellRenderer; import fr.ifremer.tutti.ui.swing.util.table.AbstractSelectTableAction; import fr.ifremer.tutti.ui.swing.util.table.CaracteristicColumnIdentifier; +import fr.ifremer.tutti.ui.swing.util.table.ColumnIdentifier; import jaxx.runtime.SwingUtil; import jaxx.runtime.validator.swing.SwingValidator; import org.apache.commons.collections.CollectionUtils; -import org.apache.commons.lang3.StringUtils; 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.decorator.Decorator; import org.nuiton.validator.NuitonValidatorResult; import javax.swing.JComponent; import javax.swing.JOptionPane; -import java.awt.Color; -import java.awt.Component; import java.io.Serializable; -import java.util.Collection; import java.util.Collections; import java.util.List; import java.util.Map; @@ -128,6 +121,16 @@ //------------------------------------------------------------------------// @Override + protected ColumnIdentifier<IndividualObservationBatchRowModel> getCommentIdentifier() { + return IndividualObservationBatchTableModel.COMMENT; + } + + @Override + protected ColumnIdentifier<IndividualObservationBatchRowModel> getAttachementIdentifier() { + return IndividualObservationBatchTableModel.ATTACHMENT; + } + + @Override public void selectFishingOperation(FishingOperation bean) { boolean empty = bean == null; @@ -203,20 +206,6 @@ } @Override - protected void onRowModified(int rowIndex, - IndividualObservationBatchRowModel row, - String propertyName, - Object oldValue, - Object newValue) { - recomputeRowValidState(row); - - saveSelectedRowIfNeeded(); - -// // when row valid state has changed, recompute action enabled states -// recomputeBatchActionEnable(); - } - - @Override protected void saveSelectedRowIfRequired(TuttiBeanMonitor<IndividualObservationBatchRowModel> rowMonitor, IndividualObservationBatchRowModel row) { @@ -243,65 +232,6 @@ } } -// @Override -// protected void onRowValidStateChanged(int rowIndex, -// IndividualObservationBatchRowModel row, -// Boolean oldValue, -// Boolean newValue) { -// super.onRowValidStateChanged(rowIndex, row, oldValue, newValue); -// -// // when row valid state has changed, recompute action enabled states -// recomputeBatchActionEnable(); -// } - -// @Override -// protected void onAfterSelectedRowChanged(int oldRowIndex, -// IndividualObservationBatchRowModel oldRow, -// int newRowIndex, -// IndividualObservationBatchRowModel newRow) { -// super.onAfterSelectedRowChanged(oldRowIndex, oldRow, newRowIndex, newRow); -// -// // when selected row has changed, recompute action enabled states -// recomputeBatchActionEnable(); -// } - - @Override - protected void addHighlighters(JXTable table) { - super.addHighlighters(table); - - // paint in a special color for comment cell (with not null value) - Color cellWithValueColor = getConfig().getColorCellWithValue(); - - Highlighter commentHighlighter = TuttiUIUtil.newBackgroundColorHighlighter( - new HighlightPredicate.AndHighlightPredicate( - new HighlightPredicate.IdentifierHighlightPredicate(IndividualObservationBatchTableModel.COMMENT), - // for not null value - new HighlightPredicate() { - @Override - public boolean isHighlighted(Component renderer, ComponentAdapter adapter) { - String value = (String) adapter.getValue(); - return StringUtils.isNotBlank(value); - } - }), cellWithValueColor); - table.addHighlighter(commentHighlighter); - - // paint in a special color for attachment cell (when some attachments) - - Highlighter attachmentHighlighter = TuttiUIUtil.newBackgroundColorHighlighter( - new HighlightPredicate.AndHighlightPredicate( - new HighlightPredicate.IdentifierHighlightPredicate(IndividualObservationBatchTableModel.ATTACHMENT), - // for not null value - new HighlightPredicate() { - @Override - public boolean isHighlighted(Component renderer, ComponentAdapter adapter) { - Collection attachments = (Collection) adapter.getValue(); - return CollectionUtils.isNotEmpty(attachments); - } - } - ), cellWithValueColor); - table.addHighlighter(attachmentHighlighter); - } - //------------------------------------------------------------------------// //-- AbstractTuttiUIHandler methods --// //------------------------------------------------------------------------// @@ -596,8 +526,6 @@ newRow.setLengthStepCaracteristic(model.getLengthStepCaracteristic()); rowsToCreate.add(newRow); - - } } else { Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/MarineLitterBatchUI.css =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/MarineLitterBatchUI.css 2013-10-04 07:09:12 UTC (rev 1273) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/MarineLitterBatchUI.css 2013-10-04 07:14:17 UTC (rev 1274) @@ -61,7 +61,7 @@ #table { selectionMode: {ListSelectionModel.SINGLE_SELECTION}; - selectionBackground: {null}; + /*selectionBackground: {null};*/ selectionForeground: {Color.BLACK}; sortable: false; } Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/MarineLitterBatchUIHandler.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/MarineLitterBatchUIHandler.java 2013-10-04 07:09:12 UTC (rev 1273) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/MarineLitterBatchUIHandler.java 2013-10-04 07:14:17 UTC (rev 1274) @@ -43,29 +43,21 @@ import fr.ifremer.tutti.ui.swing.content.operation.catches.marinelitter.create.CreateMarineLitterBatchUIModel; import fr.ifremer.tutti.ui.swing.util.TuttiBeanMonitor; import fr.ifremer.tutti.ui.swing.util.TuttiUI; -import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil; import fr.ifremer.tutti.ui.swing.util.attachment.AttachmentCellEditor; import fr.ifremer.tutti.ui.swing.util.attachment.AttachmentCellRenderer; import fr.ifremer.tutti.ui.swing.util.comment.CommentCellEditor; import fr.ifremer.tutti.ui.swing.util.comment.CommentCellRenderer; import fr.ifremer.tutti.ui.swing.util.table.AbstractSelectTableAction; +import fr.ifremer.tutti.ui.swing.util.table.ColumnIdentifier; import jaxx.runtime.SwingUtil; import jaxx.runtime.validator.swing.SwingValidator; -import org.apache.commons.collections.CollectionUtils; -import org.apache.commons.lang3.StringUtils; 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.validator.NuitonValidatorResult; import javax.swing.JComponent; -import java.awt.Color; -import java.awt.Component; -import java.util.Collection; import java.util.List; /** @@ -102,6 +94,16 @@ //------------------------------------------------------------------------// @Override + protected ColumnIdentifier<MarineLitterBatchRowModel> getCommentIdentifier() { + return MarineLitterBatchTableModel.COMMENT; + } + + @Override + protected ColumnIdentifier<MarineLitterBatchRowModel> getAttachementIdentifier() { + return MarineLitterBatchTableModel.ATTACHMENT; + } + + @Override public void selectFishingOperation(FishingOperation bean) { boolean empty = bean == null; @@ -133,22 +135,8 @@ } } model.setRows(rows); - recomputeBatchActionEnable(); } - protected MarineLitterBatchRowModel loadBatch(MarineLitterBatch aBatch) { - - MarineLitterBatchRowModel newRow = - new MarineLitterBatchRowModel(weightUnit, aBatch); - - List<Attachment> attachments = - persistenceService.getAllAttachments(newRow.getObjectType(), - newRow.getObjectId()); - - newRow.addAllAttachment(attachments); - return newRow; - } - //------------------------------------------------------------------------// //-- AbstractTuttiTableUIHandler methods --// //------------------------------------------------------------------------// @@ -171,20 +159,17 @@ return result; } - @Override - protected void onRowModified(int rowIndex, - MarineLitterBatchRowModel row, - String propertyName, - Object oldValue, - Object newValue) { - recomputeRowValidState(row); +// @Override +// protected void onRowModified(int rowIndex, +// MarineLitterBatchRowModel row, +// String propertyName, +// Object oldValue, +// Object newValue) { +// recomputeRowValidState(row); +// +// saveSelectedRowIfNeeded(); +// } - saveSelectedRowIfNeeded(); - - // when row valid state has changed, recompute action enabled states - recomputeBatchActionEnable(); - } - @Override protected void saveSelectedRowIfRequired(TuttiBeanMonitor<MarineLitterBatchRowModel> rowMonitor, MarineLitterBatchRowModel row) { @@ -199,7 +184,7 @@ String title = buildReminderLabelTitle(decorate(row.getMarineLitterCategory()) + " - " + decorate(row.getMarineLitterSizeCategory()), null, "Sauvegarde du lot Macro déchet : ", - "Ligne :" + getTableModel().getRowIndex(row) + 1); + "Ligne :" + (getTableModel().getRowIndex(row) + 1)); showInformationMessage(title); @@ -222,65 +207,6 @@ } } - @Override - protected void onRowValidStateChanged(int rowIndex, - MarineLitterBatchRowModel row, - Boolean oldValue, - Boolean newValue) { - super.onRowValidStateChanged(rowIndex, row, oldValue, newValue); - - // when row valid state has changed, recompute action enabled states - recomputeBatchActionEnable(); - } - - @Override - protected void onAfterSelectedRowChanged(int oldRowIndex, - MarineLitterBatchRowModel oldRow, - int newRowIndex, - MarineLitterBatchRowModel newRow) { - super.onAfterSelectedRowChanged(oldRowIndex, oldRow, newRowIndex, newRow); - - // when selected row has changed, recompute action enabled states - recomputeBatchActionEnable(); - } - - @Override - protected void addHighlighters(JXTable table) { - super.addHighlighters(table); - - // paint in a special color for comment cell (with not null value) - Color cellWithValueColor = getConfig().getColorCellWithValue(); - - Highlighter commentHighlighter = TuttiUIUtil.newBackgroundColorHighlighter( - new HighlightPredicate.AndHighlightPredicate( - new HighlightPredicate.IdentifierHighlightPredicate(MarineLitterBatchTableModel.COMMENT), - // for not null value - new HighlightPredicate() { - @Override - public boolean isHighlighted(Component renderer, ComponentAdapter adapter) { - String value = (String) adapter.getValue(); - return StringUtils.isNotBlank(value); - } - }), cellWithValueColor); - table.addHighlighter(commentHighlighter); - - // paint in a special color for attachment cell (when some attachments) - - Highlighter attachmentHighlighter = TuttiUIUtil.newBackgroundColorHighlighter( - new HighlightPredicate.AndHighlightPredicate( - new HighlightPredicate.IdentifierHighlightPredicate(MarineLitterBatchTableModel.ATTACHMENT), - // for not null value - new HighlightPredicate() { - @Override - public boolean isHighlighted(Component renderer, ComponentAdapter adapter) { - Collection attachments = (Collection) adapter.getValue(); - return CollectionUtils.isNotEmpty(attachments); - } - } - ), cellWithValueColor); - table.addHighlighter(attachmentHighlighter); - } - //------------------------------------------------------------------------// //-- AbstractTuttiUIHandler methods --// //------------------------------------------------------------------------// @@ -382,7 +308,6 @@ table.setColumnModel(columnModel); initBatchTable(table, columnModel, tableModel); - recomputeBatchActionEnable(); } @Override @@ -397,6 +322,21 @@ } } + @Override + protected void beforeOpenPopup(int rowIndex, int columnIndex) { + super.beforeOpenPopup(rowIndex, columnIndex); + + boolean enableRemove = false; + + if (rowIndex != -1) { + + // there is a selected row + enableRemove = true; + } + MarineLitterBatchUIModel model = getModel(); + model.setRemoveBatchEnabled(enableRemove); + } + //------------------------------------------------------------------------// //-- Public methods --// //------------------------------------------------------------------------// @@ -431,27 +371,23 @@ //update categories used addToMarineLitterCategoriesUsed(newRow); } - - recomputeBatchActionEnable(); } //------------------------------------------------------------------------// //-- Internal methods --// //------------------------------------------------------------------------// - protected void recomputeBatchActionEnable() { + protected MarineLitterBatchRowModel loadBatch(MarineLitterBatch aBatch) { - int rowIndex = getTable().getSelectedRow(); + MarineLitterBatchRowModel newRow = + new MarineLitterBatchRowModel(weightUnit, aBatch); - boolean enableRemove = false; + List<Attachment> attachments = + persistenceService.getAllAttachments(newRow.getObjectType(), + newRow.getObjectId()); - if (rowIndex != -1) { - - // there is a selected row - enableRemove = true; - } - MarineLitterBatchUIModel model = getModel(); - model.setRemoveBatchEnabled(enableRemove); + newRow.addAllAttachment(attachments); + return newRow; } protected void saveRow(MarineLitterBatchRowModel row) { 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-10-04 07:09:12 UTC (rev 1273) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIHandler.java 2013-10-04 07:14:17 UTC (rev 1274) @@ -74,7 +74,6 @@ import jaxx.runtime.validator.swing.SwingValidator; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.lang3.ObjectUtils; -import org.apache.commons.lang3.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.jdesktop.swingx.JXTable; @@ -98,7 +97,6 @@ import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import java.io.Serializable; -import java.util.Collection; import java.util.EnumMap; import java.util.List; import java.util.Set; @@ -214,6 +212,16 @@ //------------------------------------------------------------------------// @Override + protected ColumnIdentifier<SpeciesBatchRowModel> getCommentIdentifier() { + return SpeciesBatchTableModel.COMMENT; + } + + @Override + protected ColumnIdentifier<SpeciesBatchRowModel> getAttachementIdentifier() { + return SpeciesBatchTableModel.ATTACHMENT; + } + + @Override public void selectFishingOperation(FishingOperation bean) { boolean empty = bean == null; @@ -314,6 +322,8 @@ recomputeRowValidState(row); + SpeciesBatchTableModel tableModel = getTableModel(); + if (SpeciesBatchRowModel.PROPERTY_SAMPLE_CATEGORY_WEIGHT.equals(propertyName)) { // sampling category weight has changed, must then save the top @@ -323,8 +333,6 @@ SampleCategory<?> sampleCategory = (SampleCategory<?>) newValue; Integer sampleCategoryId = sampleCategory.getCategoryId(); - SpeciesBatchTableModel tableModel = getTableModel(); - SpeciesBatchRowModel firstAncestorRow = row.getFirstAncestor(sampleCategory); int firstAncestorIndex = tableModel.getRowIndex(firstAncestorRow); if (rowIndex != firstAncestorIndex) { @@ -355,12 +363,11 @@ boolean newVal = newValue == null ? false : (Boolean) newValue; - for (SpeciesBatchRowModel sampleCategories : shell) { - sampleCategories.setSpeciesToConfirm(newVal); + for (SpeciesBatchRowModel rowToupdate : shell) { + rowToupdate.setSpeciesToConfirm(newVal); } - getTableModel().fireTableRowUpdatedShell(shell); - + tableModel.fireTableRowUpdatedShell(shell); } saveSelectedRowIfNeeded(); @@ -408,19 +415,21 @@ addToSpeciesUsed(row); } } - } - @Override - protected void onAfterSelectedRowChanged(int oldRowIndex, SpeciesBatchRowModel oldRow, int newRowIndex, SpeciesBatchRowModel newRow) { - super.onAfterSelectedRowChanged(oldRowIndex, oldRow, newRowIndex, newRow); - - if (log.isInfoEnabled()) { - log.info("After select row: " + newRowIndex); - } - - saveSelectedRowIfNeeded(); + getTable().clearSelection(); } +// @Override +// protected void onAfterSelectedRowChanged(int oldRowIndex, SpeciesBatchRowModel oldRow, int newRowIndex, SpeciesBatchRowModel newRow) { +// super.onAfterSelectedRowChanged(oldRowIndex, oldRow, newRowIndex, newRow); +// +// if (log.isInfoEnabled()) { +// log.info("After select row: " + newRowIndex); +// } +// +// saveSelectedRowIfNeeded(); +// } + @Override protected void addHighlighters(JXTable table) { @@ -453,38 +462,6 @@ }, toConfirmColor.darker()); table.addHighlighter(confirmNotEditableHighlighter); - - // paint in a special color for comment cell (with not null value) - Color cellWithValueColor = getConfig().getColorCellWithValue(); - - Highlighter commentHighlighter = TuttiUIUtil.newBackgroundColorHighlighter( - new HighlightPredicate.AndHighlightPredicate( - new HighlightPredicate.IdentifierHighlightPredicate(SpeciesBatchTableModel.COMMENT), - // for not null value - new HighlightPredicate() { - @Override - public boolean isHighlighted(Component renderer, ComponentAdapter adapter) { - String value = (String) adapter.getValue(); - return StringUtils.isNotBlank(value); - } - }), cellWithValueColor); - table.addHighlighter(commentHighlighter); - - // paint in a special color for attachment cell (when some attachments) - - Highlighter attachmentHighlighter = TuttiUIUtil.newBackgroundColorHighlighter( - new HighlightPredicate.AndHighlightPredicate( - new HighlightPredicate.IdentifierHighlightPredicate(SpeciesBatchTableModel.ATTACHMENT), - // for not null value - new HighlightPredicate() { - @Override - public boolean isHighlighted(Component renderer, ComponentAdapter adapter) { - Collection attachments = (Collection) adapter.getValue(); - return CollectionUtils.isNotEmpty(attachments); - } - } - ), cellWithValueColor); - table.addHighlighter(attachmentHighlighter); } @Override Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUIHandler.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUIHandler.java 2013-10-04 07:09:12 UTC (rev 1273) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUIHandler.java 2013-10-04 07:14:17 UTC (rev 1274) @@ -28,6 +28,7 @@ import com.google.common.base.Predicate; import com.google.common.collect.Lists; import com.google.common.collect.Multimap; +import com.google.common.collect.Sets; import fr.ifremer.tutti.persistence.entities.TuttiEntities; import fr.ifremer.tutti.persistence.entities.data.SampleCategoryModel; import fr.ifremer.tutti.persistence.entities.data.SampleCategoryModelEntry; @@ -76,6 +77,7 @@ import java.util.Collection; import java.util.List; import java.util.Map; +import java.util.Set; import static org.nuiton.i18n.I18n._; @@ -148,6 +150,8 @@ @Override public void beforeInitUI() { + incrementsMessage("Chargement des réferentiels"); + getDataContext().resetValidationDataContext(); EditProtocolUIModel model = new EditProtocolUIModel(); @@ -193,6 +197,8 @@ // load existing protocol + incrementsMessage("Chargement du protocole"); + protocol = getDataContext().getProtocol(); if (EditProtocolAction.CLEAN_PROTOCOL_ENTRY.getContextValue(ui) != null) { @@ -209,6 +215,8 @@ } else if ((protocol = ImportProtocolAction.IMPORT_PROTOCOL_ENTRY.getContextValue(ui)) != null) { + incrementsMessage("Import du protocole"); + // import protocol ImportProtocolAction.IMPORT_PROTOCOL_ENTRY.removeContextValue(ui); @@ -219,6 +227,8 @@ } else if ((protocol = CloneProtocolAction.CLONE_PROTOCOL_ENTRY.getContextValue(ui)) != null) { + incrementsMessage("Clone du protocole"); + // clone protocol CloneProtocolAction.CLONE_PROTOCOL_ENTRY.removeContextValue(ui); @@ -229,6 +239,8 @@ } else { + incrementsMessage("Création d'un nouveau protocol"); + // create new protocol if (log.isDebugEnabled()) { @@ -256,6 +268,8 @@ List<EditProtocolSpeciesRowModel> speciesRows; List<EditProtocolSpeciesRowModel> benthosRows; + incrementsMessage("Préparation des interfaces graphiques"); + // build species and benthos rows if (protocol == null) { speciesRows = Lists.newArrayList(); @@ -484,6 +498,7 @@ List<Caracteristic> lengthClassesPmfmId = Lists.newArrayList(); + Set<Species> speciesSet = Sets.newHashSet(); List<EditProtocolSpeciesRowModel> result = Lists.newArrayList(); if (CollectionUtils.isNotEmpty(speciesProtocols)) { for (SpeciesProtocol speciesProtocol : speciesProtocols) { @@ -497,9 +512,7 @@ // get species referent taxon Species species = allReferentSpeciesByTaxonId.get(taxonIdStr); - // remove it from the combo box - speciesComboBox.removeItem(species); - benthosComboBox.removeItem(species); + speciesSet.add(species); EditProtocolSpeciesRowModel row = EditProtocolSpeciesTableModel.newRow(sampleCategoryModel); row.setSpecies(species); @@ -521,6 +534,10 @@ row.setMandatorySampleCategoryId(Lists.newArrayList(speciesProtocol.getMandatorySampleCategoryId())); result.add(row); } + + // remove once for all in comboboxes + speciesComboBox.removeItems(speciesSet); + benthosComboBox.removeItems(speciesSet); } if (CollectionUtils.isNotEmpty(lengthClassesPmfmId)) { Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUIModel.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUIModel.java 2013-10-04 07:09:12 UTC (rev 1273) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUIModel.java 2013-10-04 07:14:17 UTC (rev 1274) @@ -260,7 +260,10 @@ this.allReferentSpeciesByTaxonId = allReferentSpeciesByTaxonId; if (allReferentSpeciesByTaxonId != null && allSpecies != null) { allSynonyms = Lists.newArrayList(allSpecies); - allSynonyms.removeAll(allReferentSpeciesByTaxonId.values()); + // tchemit-2013-10-04 Do not do a removeAll (bad performance) + for (Species species : allReferentSpeciesByTaxonId.values()) { + allSynonyms.remove(species); + } } } Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/AbstractTuttiUIHandler.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/AbstractTuttiUIHandler.java 2013-10-04 07:09:12 UTC (rev 1273) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/AbstractTuttiUIHandler.java 2013-10-04 07:14:17 UTC (rev 1274) @@ -28,6 +28,7 @@ import com.google.common.collect.Lists; import com.google.common.collect.Sets; import fr.ifremer.tutti.LabelAware; +import fr.ifremer.tutti.persistence.ProgressionModel; import fr.ifremer.tutti.persistence.entities.TuttiEntity; import fr.ifremer.tutti.persistence.entities.data.SampleCategory; import fr.ifremer.tutti.persistence.entities.referential.Species; @@ -1275,4 +1276,15 @@ title.append(" - ").append(suffix); return title.toString(); } + + protected void incrementsMessage(String message) { + + TuttiActionUI actionUI = context.getActionUI(); + if (actionUI != null) { + ProgressionModel progressionModel = actionUI.getModel().getProgressionModel(); + if (progressionModel != null) + + progressionModel.increments(message); + } + } } Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/action/AbstractTuttiAction.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/action/AbstractTuttiAction.java 2013-10-04 07:09:12 UTC (rev 1273) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/action/AbstractTuttiAction.java 2013-10-04 07:14:17 UTC (rev 1274) @@ -346,4 +346,16 @@ JOptionPane.WARNING_MESSAGE); } + protected void createProgressionModelIfRequired(int total) { + ProgressionModel progressionModel = getProgressionModel(); + if (progressionModel==null) { + progressionModel = new ProgressionModel(); + progressionModel.setTotal(total); + progressionModel.setMessage(""); + progressionModel.setCurrent(0); + setProgressionModel(progressionModel); + } else { + progressionModel.adaptTotal(total); + } + } } Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/action/TuttiUIAction.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/action/TuttiUIAction.java 2013-10-04 07:09:12 UTC (rev 1273) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/action/TuttiUIAction.java 2013-10-04 07:14:17 UTC (rev 1274) @@ -26,6 +26,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.nuiton.util.TimeLog; import javax.swing.AbstractAction; import javax.swing.AbstractButton; @@ -50,6 +51,8 @@ /** Logger. */ private static final Log log = LogFactory.getLog(TuttiUIAction.class); + private static final TimeLog TIME_LOG = new TimeLog(TuttiUIAction.class); + public static final ExecutorService waitingThread = Executors.newSingleThreadExecutor(); @@ -59,6 +62,8 @@ private boolean wait; + private long t0; + public TuttiUIAction(AbstractButton button, A action) { putValue(LOGIC_ACTION, action); @@ -83,6 +88,8 @@ @Override public final void actionPerformed(final ActionEvent event) { + t0 = TimeLog.getTime(); + if (log.isInfoEnabled()) { log.info("Task [" + getLogicAction().getClass().getSimpleName() + "] starting"); } @@ -211,6 +218,7 @@ } protected void unlock() { + TIME_LOG.log(t0, "Task [" + getLogicAction().getClass().getSimpleName() + "] End"); if (wait) { synchronized (lock) { lock.notifyAll(); 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 2013-10-04 07:09:12 UTC (rev 1273) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/AbstractTuttiTableUIHandler.java 2013-10-04 07:14:17 UTC (rev 1274) @@ -330,16 +330,10 @@ int oldRowIndex = selectedRowIndex; int newRowIndex = source.getLeadSelectionIndex(); - if (e.getValueIsAdjusting()) { + R oldRow = rowMonitor.getBean(); + if (oldRow == null || oldRowIndex != newRowIndex) { - boolean skip = oldRowIndex == newRowIndex; - if (skip) { - return; - } - - R oldRow = rowMonitor.getBean(); - R newRow; if (source.isSelectionEmpty()) { @@ -349,9 +343,6 @@ newRow = getTableModel().getEntry(newRowIndex); } - // save selected entry if required -// saveSelectedRowIfNeeded(); - if (log.isInfoEnabled()) { log.info("Will monitor entry: " + newRowIndex); } @@ -363,11 +354,7 @@ oldRow, selectedRowIndex, rowMonitor.getBean()); - } - else { -// getTableModel().fireTableRowsUpdated(selectedRowIndex, selectedRowIndex); - } } }; 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-10-04 07:09:12 UTC (rev 1273) +++ trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties 2013-10-04 07:14:17 UTC (rev 1274) @@ -117,14 +117,14 @@ tutti.config.option.tremieCarousselVessel.description=Navire ayant un carrousel et une trémie (ex. Thalassa) tutti.config.option.ui.adminPassword.description=MD5 du mot de passe des zones sensibles tutti.config.option.ui.autoPopupNumberEditor.description=Toujours afficher le pavé numérique lors de l'édition d'un nombre -tutti.config.option.ui.color.alternateRow.description= +tutti.config.option.ui.color.alternateRow.description=Couleur de fond des lignes paires (non sélectionnée) dans un tableau tutti.config.option.ui.color.blockingLayer.description=Couleur utilisée pour bloquer l'interface lors d'une action longue tutti.config.option.ui.color.cellWithValue.description=Couleur d'une cellule avec des données tutti.config.option.ui.color.computedWeights.description=Couleur des données calculées tutti.config.option.ui.color.rowInvalid.description=Ligne invalide tutti.config.option.ui.color.rowReadOnly.description=Cellule non éditable tutti.config.option.ui.color.rowToConfirm.description=Ligne à confirmer -tutti.config.option.ui.color.selectedRow.description= +tutti.config.option.ui.color.selectedRow.description=Couleur de fond d'une ligne sélectionnée dans un tableau tutti.config.option.ui.config.file.description=Chemin du fichier de configuration des interfaces graphiques tutti.config.option.ui.coordinateEditorType.description=Type de l'éditeur de coordonnées tutti.config.option.ui.dateFormat.description=Format de dates
participants (1)
-
tchemit@users.forge.codelutin.com