Author: tchemit Date: 2013-03-13 20:39:30 +0100 (Wed, 13 Mar 2013) New Revision: 610 Url: http://forge.codelutin.com/projects/tutti/repository/revisions/610 Log: fixes #2025: [CAPTURE] - Tableau Esp?\195?\168ce - Probl?\195?\168me lorsqu'on masque une colonne Removed: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/MyIdentifierHighlightPredicate.java Modified: trunk/tutti-ui-swing/pom.xml 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/benthos/BenthosBatchTableModel.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/util/TuttiColorHighlighter.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/attachment/AttachmentCellRenderer.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/comment/CommentCellRenderer.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/AbstractTuttiTableModel.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/AbstractTuttiTableUIHandler.java Modified: trunk/tutti-ui-swing/pom.xml =================================================================== --- trunk/tutti-ui-swing/pom.xml 2013-03-13 15:44:23 UTC (rev 609) +++ trunk/tutti-ui-swing/pom.xml 2013-03-13 19:39:30 UTC (rev 610) @@ -249,11 +249,11 @@ <version>${project.version}</version> </dependency> - <!--dependency> + <dependency> <groupId>org.nuiton</groupId> <artifactId>nuiton-profiling</artifactId> <version>2.7-SNAPSHOT</version> - </dependency--> + </dependency> <dependency> <groupId>org.nuiton</groupId> 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-03-13 15:44:23 UTC (rev 609) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/AbstractTuttiBatchTableUIHandler.java 2013-03-13 19:39:30 UTC (rev 610) @@ -30,8 +30,6 @@ import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableModel; import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableUIHandler; import jaxx.runtime.SwingUtil; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import org.jdesktop.swingx.JXTable; import org.jdesktop.swingx.sort.TableSortController; @@ -48,10 +46,6 @@ */ public abstract class AbstractTuttiBatchTableUIHandler<R extends AbstractTuttiBeanUIModel, M extends AbstractTuttiBatchUIModel<R, M>, UI extends TuttiUI<M, ?>> extends AbstractTuttiTableUIHandler<R, M, UI> { - /** Logger. */ - private static final Log log = - LogFactory.getLog(AbstractTuttiBatchTableUIHandler.class); - public abstract void selectFishingOperation(FishingOperation bean); protected AbstractTuttiBatchTableUIHandler(TuttiUI<?, ?> parentUi, @@ -110,28 +104,6 @@ installTableKeyListener(columnModel, table); -// JTableFilter tableFilter = new JTableFilter(table); -// TableRowFilterSupport.forFilter(tableFilter).searchable(true).useTableRenderers(true).actions(true).apply(); -// -// tableFilter.addChangeListener(new IFilterChangeListener() { -// @Override -// public void filterChanged(ITableFilter<?> filter) { -// if (log.isInfoEnabled()) { -// log.info("Filter changed " + filter); -// } -// TableModel model = filter.getTable().getModel(); -// int columnCount = model.getColumnCount(); -// for (int i = 0; i < columnCount; i++) { -// if (filter.isFiltered(i)) { -// Collection<DistinctColumnItem> filterState = filter.getFilterState(i); -// if (log.isInfoEnabled()) { -// log.info("Column " + i + " is filtered: " + filterState); -// } -// } -// } -// } -// }); - TableSortController<TableModel> sorter = new TableSortController<TableModel>(tableModel); sorter.setSortable(false); table.setRowSorter(sorter); Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchTableModel.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchTableModel.java 2013-03-13 15:44:23 UTC (rev 609) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchTableModel.java 2013-03-13 19:39:30 UTC (rev 610) @@ -93,23 +93,4 @@ return result; } - @Override - public void setValueAt(Object aValue, - int rowIndex, - int columnIndex, - ColumnIdentifier<BenthosBatchRowModel> propertyName, - BenthosBatchRowModel entry) { - super.setValueAt(aValue, rowIndex, columnIndex, propertyName, entry); - - if (propertyName == SPECIES_BY_CODE) { - - // update also other columns - fireTableCellUpdated(rowIndex, SPECIES_BY_GENUS_CODE); - - } else if (propertyName == SPECIES_BY_GENUS_CODE) { - - // update also other columns - fireTableCellUpdated(rowIndex, SPECIES_BY_CODE); - } - } } \ No newline at end of file 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-03-13 15:44:23 UTC (rev 609) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIHandler.java 2013-03-13 19:39:30 UTC (rev 610) @@ -645,9 +645,44 @@ table.setModel(tableModel); table.setColumnModel(columnModel); + initBatchTable(table, columnModel, tableModel); + + getModel().addPropertyChangeListener(SpeciesBatchUIModel.PROPERTY_TABLE_VIEW_MODE, new PropertyChangeListener() { + @Override + public void propertyChange(PropertyChangeEvent evt) { + TableViewMode tableViewMode = (TableViewMode) evt.getNewValue(); + + if (tableViewMode == null) { + tableViewMode = TableViewMode.ALL; + } + + if (log.isDebugEnabled()) { + log.debug("Will use rowfilter for viewMode: " + tableViewMode); + } + RowFilter<SpeciesBatchTableModel, Integer> filter = tableFilters.get(tableViewMode); + getTable().setRowFilter(filter); + } + }); + + } + + @Override + public void onCloseUI() { + if (log.isDebugEnabled()) { + log.debug("Closing: " + ui); + } + 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 attachmentHighlighter = TuttiUIUtil.newBackgroundColorHighlighter( + Highlighter confirmHighlighter = TuttiUIUtil.newBackgroundColorHighlighter( new HighlightPredicate() { public boolean isHighlighted(Component renderer, ComponentAdapter adapter) { @@ -656,10 +691,8 @@ } }, toConfirmColor); - table.addHighlighter(attachmentHighlighter); + table.addHighlighter(confirmHighlighter); - initBatchTable(table, columnModel, tableModel); - // highlight only the species column if the row is selected Highlighter selectedHighlighter = TuttiUIUtil.newBackgroundColorHighlighter( new HighlightPredicate.AndHighlightPredicate( @@ -670,7 +703,7 @@ table.addHighlighter(selectedHighlighter); // paint the cell in dark orange if the row is to confirm and the cell is not editable - attachmentHighlighter = TuttiUIUtil.newBackgroundColorHighlighter( + Highlighter confirmNotEditableHighlighter = TuttiUIUtil.newBackgroundColorHighlighter( new HighlightPredicate() { public boolean isHighlighted(Component renderer, ComponentAdapter adapter) { @@ -679,35 +712,10 @@ } }, toConfirmColor.darker()); - table.addHighlighter(attachmentHighlighter); + table.addHighlighter(confirmNotEditableHighlighter); - getModel().addPropertyChangeListener(SpeciesBatchUIModel.PROPERTY_TABLE_VIEW_MODE, new PropertyChangeListener() { - @Override - public void propertyChange(PropertyChangeEvent evt) { - TableViewMode tableViewMode = (TableViewMode) evt.getNewValue(); - - if (tableViewMode == null) { - tableViewMode = TableViewMode.ALL; - } - - if (log.isDebugEnabled()) { - log.debug("Will use rowfilter for viewMode: " + tableViewMode); - } - RowFilter<SpeciesBatchTableModel, Integer> filter = tableFilters.get(tableViewMode); - getTable().setRowFilter(filter); - } - }); - } - @Override - public void onCloseUI() { - if (log.isDebugEnabled()) { - log.debug("Closing: " + ui); - } - ui.getSpeciesBatchAttachmentsButton().onCloseUI(); - } - //------------------------------------------------------------------------// //-- Public methods --// //------------------------------------------------------------------------// 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-03-13 15:44:23 UTC (rev 609) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/FrequencyCellComponent.java 2013-03-13 19:39:30 UTC (rev 610) @@ -222,9 +222,9 @@ int column) { tableModel = (SpeciesBatchTableModel) table.getModel(); this.table = table; - columnIdentifier = tableModel.getPropertyName(column); - if (log.isInfoEnabled()) { - log.info("Set columnIdentifier (" + column + ") :: " + columnIdentifier.getPropertyName()); + columnIdentifier = SpeciesBatchTableModel.COMPUTED_NUMBER; + if (log.isDebugEnabled()) { + log.debug("Set columnIdentifier (" + column + ") :: " + columnIdentifier.getPropertyName()); } TuttiComputedOrNotData<Integer> data = (TuttiComputedOrNotData<Integer>) value; component.setComputedOrNotText(data); @@ -246,8 +246,8 @@ if (columnIdentifier == SpeciesBatchTableModel.COMPUTED_NUMBER) { result = editRow.getComputedOrNotNumber(); } - if (log.isInfoEnabled()) { - log.info("editor value (" + columnIdentifier + "): " + result); + if (log.isDebugEnabled()) { + log.debug("editor value (" + columnIdentifier + "): " + result); } return result; Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/TuttiColorHighlighter.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/TuttiColorHighlighter.java 2013-03-13 15:44:23 UTC (rev 609) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/TuttiColorHighlighter.java 2013-03-13 19:39:30 UTC (rev 610) @@ -29,7 +29,6 @@ import org.jdesktop.swingx.decorator.HighlightPredicate; import org.jdesktop.swingx.util.PaintUtils; -import javax.swing.JButton; import java.awt.Color; import java.awt.Component; @@ -51,20 +50,17 @@ @Override protected Component doHighlight(Component component, ComponentAdapter adapter) { - if (component instanceof JButton) { - // do nothing - } else { - if (foreground) { - component.setForeground(color); + if (foreground) { + component.setForeground(color); - } else { - component.setBackground(color); - if (adapter.isSelected()) { - component.setForeground(PaintUtils.computeForeground(color)); - } + } else { + component.setBackground(color); + if (adapter.isSelected()) { + component.setForeground(PaintUtils.computeForeground(color)); } } + return component; } } Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/attachment/AttachmentCellRenderer.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/attachment/AttachmentCellRenderer.java 2013-03-13 15:44:23 UTC (rev 609) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/attachment/AttachmentCellRenderer.java 2013-03-13 19:39:30 UTC (rev 610) @@ -103,6 +103,7 @@ setEnabled(editable); setText(textValue); setToolTipText(toolTipTextValue); + setBackground(null); return this; } Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/comment/CommentCellRenderer.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/comment/CommentCellRenderer.java 2013-03-13 15:44:23 UTC (rev 609) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/comment/CommentCellRenderer.java 2013-03-13 19:39:30 UTC (rev 610) @@ -91,6 +91,7 @@ toolTipTextValue = String.format(TEXT_PATTERN, toolTipTextValue); setEnabled(editable); setToolTipText(toolTipTextValue); + setBackground(null); return this; } Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/AbstractTuttiTableModel.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/AbstractTuttiTableModel.java 2013-03-13 15:44:23 UTC (rev 609) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/AbstractTuttiTableModel.java 2013-03-13 19:39:30 UTC (rev 610) @@ -25,20 +25,15 @@ */ import com.google.common.base.Preconditions; +import com.google.common.collect.Lists; import com.google.common.collect.Sets; import jaxx.runtime.SwingUtil; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.jdesktop.swingx.event.TableColumnModelExtListener; -import org.jdesktop.swingx.table.TableColumnExt; import org.jdesktop.swingx.table.TableColumnModelExt; -import javax.swing.event.ChangeEvent; -import javax.swing.event.ListSelectionEvent; -import javax.swing.event.TableColumnModelEvent; import javax.swing.table.AbstractTableModel; import javax.swing.table.TableColumn; -import java.beans.PropertyChangeEvent; import java.io.Serializable; import java.util.List; import java.util.Set; @@ -57,13 +52,6 @@ LogFactory.getLog(AbstractTuttiTableModel.class); /** - * Column model. - * - * @since 1.0.2 - */ - protected final TableColumnModelExt columnModel; - - /** * Data in the model. * * @since 0.2 @@ -91,49 +79,24 @@ */ protected final boolean createEmptyRowIsEmpty; + /** + * Identifiers of columns (in initial order). + * + * @since 1.1 + */ + protected final List<ColumnIdentifier<R>> identifiers; + public abstract R createNewRow(); protected AbstractTuttiTableModel(TableColumnModelExt columnModel, boolean createNewRow, boolean createEmptyRowIsEmpty) { - this.columnModel = columnModel; + this.identifiers = Lists.newArrayListWithCapacity(columnModel.getColumnCount()); + for (TableColumn tc : columnModel.getColumns(true)) { + this.identifiers.add((ColumnIdentifier<R>) tc.getIdentifier()); + } this.createNewRow = createNewRow; this.createEmptyRowIsEmpty = createEmptyRowIsEmpty; - columnModel.addColumnModelListener(new TableColumnModelExtListener() { - @Override - public void columnPropertyChange(PropertyChangeEvent event) { - TableColumnExt column = (TableColumnExt) event.getSource(); - if (log.isInfoEnabled()) { - log.info("Property [" + event.getPropertyName() + "] changed on coloumn [" + column.getTitle() + "] :: " + event.getNewValue()); - } - } - - @Override - public void columnAdded(TableColumnModelEvent e) { - if (log.isInfoEnabled()) { - log.info("Column added [" + e.getFromIndex() + "] :: " + e.getToIndex()); - } - } - - @Override - public void columnRemoved(TableColumnModelEvent e) { - if (log.isInfoEnabled()) { - log.info("Column removed [" + e.getFromIndex() + "] :: " + e.getToIndex()); - } - } - - @Override - public void columnMoved(TableColumnModelEvent e) { - } - - @Override - public void columnMarginChanged(ChangeEvent e) { - } - - @Override - public void columnSelectionChanged(ListSelectionEvent e) { - } - }); } public final List<R> getRows() { @@ -224,11 +187,6 @@ // by default do nothing } - public final ColumnIdentifier<R> getPropertyName(int columnIndex) { - TableColumn column = getColumn(columnIndex); - return (ColumnIdentifier<R>) column.getIdentifier(); - } - public final int getRowIndex(R row) { int result = rows == null ? -1 : rows.indexOf(row); return result; @@ -252,18 +210,17 @@ @Override public final int getColumnCount() { -// return columns.length; - return columnModel.getColumnCount(); + return identifiers.size(); } @Override public final Object getValueAt(int rowIndex, int columnIndex) { R entry = getEntry(rowIndex); - ColumnIdentifier<R> propertyName = getPropertyName(columnIndex); + ColumnIdentifier<R> identifier = getIdentifier(columnIndex); if (log.isInfoEnabled()) { - log.info("columnIndex: " + columnIndex + " :: " + propertyName.getPropertyName()); + log.info("columnIndex: " + columnIndex + " :: " + identifier.getPropertyName()); } - Object result = getValueAt(rowIndex, columnIndex, propertyName, entry); + Object result = identifier.getValue(entry); return result; } @@ -273,25 +230,17 @@ log.debug("setValueAt " + aValue); } R entry = getEntry(rowIndex); - ColumnIdentifier<R> propertyName = getPropertyName(columnIndex); - setValueAt(aValue, rowIndex, columnIndex, propertyName, entry); + ColumnIdentifier<R> identifier = getIdentifier(columnIndex); + setValueAt(aValue, rowIndex, columnIndex, identifier, entry); } @Override public final boolean isCellEditable(int rowIndex, int columnIndex) { - ColumnIdentifier<R> identifier = getPropertyName(columnIndex); + ColumnIdentifier<R> identifier = getIdentifier(columnIndex); boolean result = isCellEditable(rowIndex, columnIndex, identifier); return result; } - protected Object getValueAt(int rowIndex, - int columnIndex, - ColumnIdentifier<R> propertyName, - R entry) { - Object result = propertyName.getValue(entry); - return result; - } - protected void setValueAt(Object aValue, int rowIndex, int columnIndex, @@ -311,21 +260,15 @@ } protected final void fireTableCellUpdated(int rowIndex, - ColumnIdentifier... identifiers) { - for (ColumnIdentifier<?> identifier : identifiers) { - int columnIndex = getColumnIndex(identifier); + ColumnIdentifier<R>... identifiers) { + for (ColumnIdentifier<R> identifier : identifiers) { + int columnIndex = this.identifiers.indexOf(identifier); fireTableCellUpdated(rowIndex, columnIndex); } } - protected final TableColumn getColumn(int columnIndex) { -// SwingUtil.ensureColumnIndex(this, columnIndex); -// return columns[columnIndex]; - return columnModel.getColumns(true).get(columnIndex); + protected ColumnIdentifier<R> getIdentifier(int columnIndex) { + ColumnIdentifier<R> identifier = identifiers.get(columnIndex); + return identifier; } - - protected final int getColumnIndex(ColumnIdentifier<?> property) { - int result = columnModel.getColumnIndex(property); - return result; - } } 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-03-13 15:44:23 UTC (rev 609) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/AbstractTuttiTableUIHandler.java 2013-03-13 19:39:30 UTC (rev 610) @@ -293,6 +293,27 @@ // by default do not authorize to change column orders table.getTableHeader().setReorderingAllowed(false); + addHighlighters(table); + + // when model data change let's propagate it table model + getModel().addPropertyChangeListener(AbstractTuttiTableUIModel.PROPERTY_ROWS, new PropertyChangeListener() { + @Override + public void propertyChange(PropertyChangeEvent evt) { + onModelRowsChanged((List<R>) evt.getNewValue()); + } + }); + + // always scroll to selected row + SwingUtil.scrollToTableSelection(getTable()); + + // always force to uninstall listener + uninstallTableSaveOnRowChangedSelectionListener(); + + // save when row chaged and was modified + installTableSaveOnRowChangedSelectionListener(); + } + + protected void addHighlighters(JXTable table){ // paint in a special color for read only cells Highlighter readOnlyHighlighter = TuttiUIUtil.newBackgroundColorHighlighter( HighlightPredicate.READ_ONLY, getConfig().getColorRowReadOnly()); @@ -300,9 +321,10 @@ // paint in a special color for comment cell (with not null value) Color cellWithValueColor = getConfig().getColorCellWithValue(); + Highlighter commentHighlighter = TuttiUIUtil.newBackgroundColorHighlighter( new HighlightPredicate.AndHighlightPredicate( - new MyIdentifierHighlightPredicate(SpeciesBatchTableModel.COMMENT), + new HighlightPredicate.IdentifierHighlightPredicate(SpeciesBatchTableModel.COMMENT), // for not null value new HighlightPredicate() { @Override @@ -314,9 +336,10 @@ table.addHighlighter(commentHighlighter); // paint in a special color for attachment cell (when some attachments) + Highlighter attachmentHighlighter = TuttiUIUtil.newBackgroundColorHighlighter( new HighlightPredicate.AndHighlightPredicate( - new MyIdentifierHighlightPredicate(SpeciesBatchTableModel.ATTACHMENT), + new HighlightPredicate.IdentifierHighlightPredicate(SpeciesBatchTableModel.ATTACHMENT), // for not null value new HighlightPredicate() { @Override @@ -343,23 +366,6 @@ } }), getConfig().getColorRowInvalid()); table.addHighlighter(validHighlighter); - - // when model data change let's propagate it table model - getModel().addPropertyChangeListener(AbstractTuttiTableUIModel.PROPERTY_ROWS, new PropertyChangeListener() { - @Override - public void propertyChange(PropertyChangeEvent evt) { - onModelRowsChanged((List<R>) evt.getNewValue()); - } - }); - - // always scroll to selected row - SwingUtil.scrollToTableSelection(getTable()); - - // always force to uninstall listener - uninstallTableSaveOnRowChangedSelectionListener(); - - // save when row chaged and was modified - installTableSaveOnRowChangedSelectionListener(); } protected void addColumnToModel(TableColumnModel model, Deleted: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/MyIdentifierHighlightPredicate.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/MyIdentifierHighlightPredicate.java 2013-03-13 15:44:23 UTC (rev 609) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/MyIdentifierHighlightPredicate.java 2013-03-13 19:39:30 UTC (rev 610) @@ -1,77 +0,0 @@ -package fr.ifremer.tutti.ui.swing.util.table; - -/* - * #%L - * Tutti :: UI - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2012 - 2013 Ifremer - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/gpl-3.0.html>. - * #L% - */ - -import org.jdesktop.swingx.decorator.ComponentAdapter; -import org.jdesktop.swingx.decorator.HighlightPredicate; - -import java.awt.Component; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -/** - * While using the swingX HighlightPredicate.IdentifierHighlightPredicate, it does not works very well with - * - * @author tchemit <chemit@codelutin.com> - * @since 1.0.2 - */ -public class MyIdentifierHighlightPredicate implements HighlightPredicate { - protected List<Object> columnList; - - /** - * Instantiates a predicate which returns true for the - * given column identifiers. - * - * @param columns the identitiers of the columns to highlight. - */ - public MyIdentifierHighlightPredicate(Object... columns) { - columnList = new ArrayList<Object>(); - Collections.addAll(columnList, columns); - } - - /** - * {@inheritDoc} - * <p/> - * This implementation returns true if the adapter's column - * is contained in this predicates list. - */ - @Override - public boolean isHighlighted(Component renderer, ComponentAdapter adapter) { -// int modelIndex = adapter.convertColumnIndexToModel(adapter.column); - Object identifier = adapter.getColumnIdentifierAt(adapter.column); - return identifier != null && columnList.contains(identifier); - } - - /** @return the identifiers */ - public Object[] getIdentifiers() { - if (columnList.isEmpty()) { - return EMPTY_OBJECT_ARRAY; - } else { - return columnList.toArray(new Object[0]); - } - } - -} \ No newline at end of file