Author: tchemit Date: 2013-04-04 13:29:07 +0200 (Thu, 04 Apr 2013) New Revision: 734 Url: http://forge.codelutin.com/projects/tutti/repository/revisions/734 Log: fixes #2244: [CAPTURES] Benthos - La cellule des commentaires et pi?\195?\168ces-jointes n'ont pas un fond vert si il y a des donn?\195?\169es dedans refs #1865: [MACRODECHET] - Gestion de la saisie des Macrod?\195?\169chets continue ?\195?\160 r?\195?\169usiner les mod?\195?\168les d'ui (SpeciesBatch) 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/marinelitter/MarineLitterBatchRowModel.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/MarineLitterBatchTableModel.java 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/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/util/table/AbstractTuttiTableUIHandler.java 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-04-04 11:05:45 UTC (rev 733) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUIHandler.java 2013-04-04 11:29:07 UTC (rev 734) @@ -66,6 +66,7 @@ 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; @@ -86,6 +87,7 @@ 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.Map; @@ -354,6 +356,79 @@ recomputeBatchActionEnable(); } + @Override + protected void addHighlighters(JXTable table) { + + super.addHighlighters(table); + + Color toConfirmColor = getConfig().getColorRowToConfirm(); + + // paint the cell in orange if the row is to confirm + Highlighter confirmHighlighter = TuttiUIUtil.newBackgroundColorHighlighter( + new HighlightPredicate() { + + public boolean isHighlighted(Component renderer, ComponentAdapter adapter) { + BenthosBatchRowModel row = getTableModel().getEntry(adapter.row); + return row.isSpeciesToConfirm(); + } + + }, toConfirmColor); + table.addHighlighter(confirmHighlighter); + + // highlight only the species column if the row is selected + Highlighter selectedHighlighter = TuttiUIUtil.newBackgroundColorHighlighter( + new HighlightPredicate.AndHighlightPredicate( + HighlightPredicate.IS_SELECTED, + new HighlightPredicate.IdentifierHighlightPredicate(BenthosBatchTableModel.SPECIES)), + UIManager.getColor("Table[Enabled+Selected].textBackground")); + + table.addHighlighter(selectedHighlighter); + + // paint the cell in dark orange if the row is to confirm and the cell is not editable + Highlighter confirmNotEditableHighlighter = TuttiUIUtil.newBackgroundColorHighlighter( + new HighlightPredicate() { + + public boolean isHighlighted(Component renderer, ComponentAdapter adapter) { + BenthosBatchRowModel row = getTableModel().getEntry(adapter.row); + return row.isSpeciesToConfirm() && !adapter.isEditable(); + } + + }, 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); + } + //------------------------------------------------------------------------// //-- AbstractTuttiUIHandler methods --// //------------------------------------------------------------------------// @@ -559,48 +634,6 @@ ui.getBenthosBatchAttachmentsButton().onCloseUI(); } - @Override - protected void addHighlighters(JXTable table) { - - super.addHighlighters(table); - - Color toConfirmColor = getConfig().getColorRowToConfirm(); - - // paint the cell in orange if the row is to confirm - Highlighter confirmHighlighter = TuttiUIUtil.newBackgroundColorHighlighter( - new HighlightPredicate() { - - public boolean isHighlighted(Component renderer, ComponentAdapter adapter) { - BenthosBatchRowModel row = getTableModel().getEntry(adapter.row); - return row.isSpeciesToConfirm(); - } - - }, toConfirmColor); - table.addHighlighter(confirmHighlighter); - - // highlight only the species column if the row is selected - Highlighter selectedHighlighter = TuttiUIUtil.newBackgroundColorHighlighter( - new HighlightPredicate.AndHighlightPredicate( - HighlightPredicate.IS_SELECTED, - new HighlightPredicate.IdentifierHighlightPredicate(BenthosBatchTableModel.SPECIES)), - UIManager.getColor("Table[Enabled+Selected].textBackground")); - - table.addHighlighter(selectedHighlighter); - - // paint the cell in dark orange if the row is to confirm and the cell is not editable - Highlighter confirmNotEditableHighlighter = TuttiUIUtil.newBackgroundColorHighlighter( - new HighlightPredicate() { - - public boolean isHighlighted(Component renderer, ComponentAdapter adapter) { - BenthosBatchRowModel row = getTableModel().getEntry(adapter.row); - return row.isSpeciesToConfirm() && !adapter.isEditable(); - } - - }, toConfirmColor.darker()); - table.addHighlighter(confirmNotEditableHighlighter); - - } - //------------------------------------------------------------------------// //-- Public methods --// //------------------------------------------------------------------------// Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/MarineLitterBatchRowModel.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/MarineLitterBatchRowModel.java 2013-04-04 11:05:45 UTC (rev 733) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/MarineLitterBatchRowModel.java 2013-04-04 11:29:07 UTC (rev 734) @@ -76,9 +76,11 @@ super(MarineLitterBatch.class, fromBeanBinder, toBeanBinder); } - public MarineLitterBatchRowModel(MarineLitterBatch aBatch) { + public MarineLitterBatchRowModel(MarineLitterBatch aBatch, + List<Attachment> attachments) { this(); fromBean(aBatch); + this.attachment.addAll(attachments); } @Override Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/MarineLitterBatchTableModel.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/MarineLitterBatchTableModel.java 2013-04-04 11:05:45 UTC (rev 733) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/MarineLitterBatchTableModel.java 2013-04-04 11:29:07 UTC (rev 734) @@ -83,4 +83,19 @@ return result; } + @Override + protected boolean isCellEditable(int rowIndex, + int columnIndex, + ColumnIdentifier<MarineLitterBatchRowModel> propertyName) { + boolean cellEditable = super.isCellEditable(rowIndex, + columnIndex, + propertyName); + if (ATTACHMENT == propertyName) { + + // only editable if row exists + MarineLitterBatchRowModel entry = getEntry(rowIndex); + cellEditable = entry.getObjectId() != null; + } + return cellEditable; + } } \ No newline at end of file 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-04-04 11:05:45 UTC (rev 733) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/MarineLitterBatchUIHandler.java 2013-04-04 11:29:07 UTC (rev 734) @@ -34,19 +34,29 @@ import fr.ifremer.tutti.persistence.entities.referential.CaracteristicQualitativeValue; import fr.ifremer.tutti.ui.swing.content.operation.AbstractTuttiBatchTableUIHandler; import fr.ifremer.tutti.ui.swing.content.operation.catches.EditCatchesUIModel; +import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SpeciesBatchTableModel; 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 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.util.decorator.Decorator; +import java.awt.Color; +import java.awt.Component; +import java.util.Collection; import java.util.List; /** @@ -108,8 +118,7 @@ } for (MarineLitterBatch aBatch : batchContainer.getChildren()) { - MarineLitterBatchRowModel entry = - new MarineLitterBatchRowModel(aBatch); + MarineLitterBatchRowModel entry = loadBatch(aBatch); rows.add(entry); } } @@ -118,6 +127,19 @@ recomputeBatchActionEnable(); } + protected MarineLitterBatchRowModel loadBatch(MarineLitterBatch aBatch) { + + Integer id = aBatch.getIdAsInt(); + + List<Attachment> attachments = + persistenceService.getAllAttachments(id); + + MarineLitterBatchRowModel newRow = + new MarineLitterBatchRowModel(aBatch, attachments); + + return newRow; + } + //------------------------------------------------------------------------// //-- AbstractTuttiTableUIHandler methods --// //------------------------------------------------------------------------// @@ -210,6 +232,43 @@ 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 --// //------------------------------------------------------------------------// 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-04-04 11:05:45 UTC (rev 733) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchRowModel.java 2013-04-04 11:29:07 UTC (rev 734) @@ -58,10 +58,6 @@ private static final long serialVersionUID = 1L; - public static final String PROPERTY_SPECIES_TO_CONFIRM = "speciesToConfirm"; - - public static final String PROPERTY_SPECIES = "species"; - public static final String PROPERTY_SORTED_UNSORTED_CATEGORY = "sortedUnsortedCategory"; public static final String PROPERTY_SORTED_UNSORTED_CATEGORY_VALUE = "sortedUnsortedCategoryValue"; @@ -102,18 +98,12 @@ public static final String PROPERTY_AGE_CATEGORY_WEIGHT = "ageCategoryWeight"; - public static final String PROPERTY_WEIGHT = "weight"; - - public static final String PROPERTY_NUMBER = "number"; - public static final String PROPERTY_FREQUENCY = "frequency"; public static final String PROPERTY_COMPUTED_NUMBER = "computedOrNotNumber"; public static final String PROPERTY_COMPUTED_WEIGHT = "computedOrNotWeight"; - public static final String PROPERTY_PARENT_BATCH = "parentBatch"; - public static final String PROPERTY_CHILD_BATCH = "childBatch"; public static final String PROPERTY_BATCH_LEAF = "batchLeaf"; @@ -130,7 +120,7 @@ protected final SpeciesBatch editObject = TuttiBeanFactory.newSpeciesBatch(); /** - * Sorted - Unsroted category (can not be null). + * Sorted - Unsorted category (can not be null). * * @since 0.2 */ @@ -144,21 +134,21 @@ protected SampleCategory<CaracteristicQualitativeValue> sizeCategory; /** - * Sex (can be null). + * Sex category (can be null). * * @since 0.2 */ protected SampleCategory<CaracteristicQualitativeValue> sexCategory; /** - * Maturity (can be null). + * Maturity category (can be null). * * @since 0.2 */ protected SampleCategory<CaracteristicQualitativeValue> maturityCategory; /** - * Age (can be null). + * Age category (can be null). * * @since 0.2 */ 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-04-04 11:05:45 UTC (rev 733) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIHandler.java 2013-04-04 11:29:07 UTC (rev 734) @@ -58,6 +58,7 @@ 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; @@ -74,6 +75,7 @@ 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.Map; @@ -364,6 +366,79 @@ recomputeBatchActionEnable(); } + @Override + protected void addHighlighters(JXTable table) { + + super.addHighlighters(table); + + Color toConfirmColor = getConfig().getColorRowToConfirm(); + + // paint the cell in orange if the row is to confirm + Highlighter confirmHighlighter = TuttiUIUtil.newBackgroundColorHighlighter( + new HighlightPredicate() { + + public boolean isHighlighted(Component renderer, ComponentAdapter adapter) { + SpeciesBatchRowModel row = getTableModel().getEntry(adapter.row); + return row.isSpeciesToConfirm(); + } + + }, toConfirmColor); + table.addHighlighter(confirmHighlighter); + + // highlight only the species column if the row is selected + Highlighter selectedHighlighter = TuttiUIUtil.newBackgroundColorHighlighter( + new HighlightPredicate.AndHighlightPredicate( + HighlightPredicate.IS_SELECTED, + new HighlightPredicate.IdentifierHighlightPredicate(SpeciesBatchTableModel.SPECIES)), + UIManager.getColor("Table[Enabled+Selected].textBackground")); + + table.addHighlighter(selectedHighlighter); + + // paint the cell in dark orange if the row is to confirm and the cell is not editable + Highlighter confirmNotEditableHighlighter = TuttiUIUtil.newBackgroundColorHighlighter( + new HighlightPredicate() { + + public boolean isHighlighted(Component renderer, ComponentAdapter adapter) { + SpeciesBatchRowModel row = getTableModel().getEntry(adapter.row); + return row.isSpeciesToConfirm() && !adapter.isEditable(); + } + + }, 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); + } + //------------------------------------------------------------------------// //-- AbstractTuttiUIHandler methods --// //------------------------------------------------------------------------// @@ -578,48 +653,6 @@ ui.getSpeciesBatchAttachmentsButton().onCloseUI(); } - @Override - protected void addHighlighters(JXTable table) { - - super.addHighlighters(table); - - Color toConfirmColor = getConfig().getColorRowToConfirm(); - - // paint the cell in orange if the row is to confirm - Highlighter confirmHighlighter = TuttiUIUtil.newBackgroundColorHighlighter( - new HighlightPredicate() { - - public boolean isHighlighted(Component renderer, ComponentAdapter adapter) { - SpeciesBatchRowModel row = getTableModel().getEntry(adapter.row); - return row.isSpeciesToConfirm(); - } - - }, toConfirmColor); - table.addHighlighter(confirmHighlighter); - - // highlight only the species column if the row is selected - Highlighter selectedHighlighter = TuttiUIUtil.newBackgroundColorHighlighter( - new HighlightPredicate.AndHighlightPredicate( - HighlightPredicate.IS_SELECTED, - new HighlightPredicate.IdentifierHighlightPredicate(SpeciesBatchTableModel.SPECIES)), - UIManager.getColor("Table[Enabled+Selected].textBackground")); - - table.addHighlighter(selectedHighlighter); - - // paint the cell in dark orange if the row is to confirm and the cell is not editable - Highlighter confirmNotEditableHighlighter = TuttiUIUtil.newBackgroundColorHighlighter( - new HighlightPredicate() { - - public boolean isHighlighted(Component renderer, ComponentAdapter adapter) { - SpeciesBatchRowModel row = getTableModel().getEntry(adapter.row); - return row.isSpeciesToConfirm() && !adapter.isEditable(); - } - - }, toConfirmColor.darker()); - table.addHighlighter(confirmNotEditableHighlighter); - - } - //------------------------------------------------------------------------// //-- Public methods --// //------------------------------------------------------------------------// 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-04-04 11:05:45 UTC (rev 733) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/AbstractTuttiTableUIHandler.java 2013-04-04 11:29:07 UTC (rev 734) @@ -297,43 +297,12 @@ } protected void addHighlighters(JXTable table) { + // paint in a special color for read only cells Highlighter readOnlyHighlighter = TuttiUIUtil.newBackgroundColorHighlighter( HighlightPredicate.READ_ONLY, getConfig().getColorRowReadOnly()); table.addHighlighter(readOnlyHighlighter); - // 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); - // paint in a special color inValid rows Highlighter validHighlighter = TuttiUIUtil.newBackgroundColorHighlighter( new HighlightPredicate.AndHighlightPredicate(HighlightPredicate.EDITABLE, new HighlightPredicate() { @@ -351,110 +320,6 @@ table.addHighlighter(validHighlighter); } -// protected void addColumnToModel(TableColumnModel model, -// TableCellEditor editor, -// TableCellRenderer renderer, -// ColumnIdentifier<R> identifier) { -// -// TableColumnExt col = new TableColumnExt(model.getColumnCount()); -// col.setCellEditor(editor); -// col.setCellRenderer(renderer); -// col.setHeaderValue(_(identifier.getHeaderI18nKey())); -// col.setToolTipText(_(identifier.getHeaderTipI18nKey())); -// -// col.setIdentifier(identifier); -// model.addColumn(col); -// } - -// protected void addColumnToModel(TableColumnModel model, -// ColumnIdentifier<R> identifier) { -// -// addColumnToModel(model, null, null, identifier); -// } -// -// protected void addFloatColumnToModel(TableColumnModel model, -// ColumnIdentifier<R> identifier, -// String numberPattern) { -// -// NumberCellEditor<Float> editor = -// JAXXWidgetUtil.newNumberTableCellEditor(Float.class, false); -// editor.getNumberEditor().setSelectAllTextOnError(true); -// editor.getNumberEditor().getTextField().setBorder(new LineBorder(Color.GRAY, 2)); -// editor.getNumberEditor().setNumberPattern(numberPattern); -// -// addColumnToModel(model, editor, null, identifier); -// -// } - -// protected void addIntegerColumnToModel(TableColumnModel model, -// ColumnIdentifier<R> identifier, -// String numberPattern) { -// -// NumberCellEditor<Integer> editor = -// JAXXWidgetUtil.newNumberTableCellEditor(Integer.class, false); -// editor.getNumberEditor().setSelectAllTextOnError(true); -// editor.getNumberEditor().getTextField().setBorder(new LineBorder(Color.GRAY, 2)); -// editor.getNumberEditor().setNumberPattern(numberPattern); -// -// addColumnToModel(model, editor, null, identifier); -// } - -// protected void addBooleanColumnToModel(TableColumnModel model, -// ColumnIdentifier<R> identifier, -// JTable table) { -// -// addColumnToModel(model, -// table.getDefaultEditor(Boolean.class), -// table.getDefaultRenderer(Boolean.class), -// identifier); -// } - -// protected <B> void addComboDataColumnToModel(TableColumnModel model, -// ColumnIdentifier<R> identifier, -// Decorator<B> decorator, -// List<B> data) { -// JComboBox comboBox = new JComboBox(); -// comboBox.setRenderer(newListCellRender(decorator)); -// -// List<B> dataToList = Lists.newArrayList(data); -// -// // add a null value at first position -// if (!dataToList.isEmpty() && dataToList.get(0) != null) { -// dataToList.add(0, null); -// } -// SwingUtil.fillComboBox(comboBox, dataToList, null); -// -// ObjectToStringConverter converter = BeanUIUtil.newDecoratedObjectToStringConverter(decorator); -// BeanUIUtil.decorate(comboBox, converter); -// ComboBoxCellEditor editor = new ComboBoxCellEditor(comboBox); -// -// addColumnToModel(model, -// editor, -// newTableCellRender(decorator), -// identifier); -// } -// -// protected <O> TableCellRenderer newTableCellRender(Class<O> type) { -// -// return newTableCellRender(type, null); -// } -// -// protected <O> TableCellRenderer newTableCellRender(Class<O> type, String name) { -// -// Decorator<O> decorator = getDecorator(type, name); -// -// TableCellRenderer result = newTableCellRender(decorator); -// return result; -// } -// -// protected <O> TableCellRenderer newTableCellRender(Decorator<O> decorator) { -// -// Preconditions.checkNotNull(decorator); -// -// DecoratorTableCellRenderer result = new DecoratorTableCellRenderer(decorator, true); -// return result; -// } - //------------------------------------------------------------------------// //-- Internal methods (listener methods) --// //------------------------------------------------------------------------//