Author: fdesbois Date: 2012-08-01 15:38:03 +0200 (Wed, 01 Aug 2012) New Revision: 337 Url: http://forge.codelutin.com/repositories/revision/sammoa/337 Log: fixes #1381 : remove column nbTimes from transect table Added: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/TransectCrossingNumberCellRenderer.java Removed: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/TransectNbTimesCellRenderer.java Modified: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/TransectFlightModel.java trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/TransectTable.java trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/TransectTableModel.java Copied: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/TransectCrossingNumberCellRenderer.java (from rev 336, trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/TransectNbTimesCellRenderer.java) =================================================================== --- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/TransectCrossingNumberCellRenderer.java (rev 0) +++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/TransectCrossingNumberCellRenderer.java 2012-08-01 13:38:03 UTC (rev 337) @@ -0,0 +1,60 @@ +package fr.ulr.sammoa.ui.swing.flight; +/* + * #%L + * SAMMOA :: UI Swing + * $Id:$ + * $HeadURL:$ + * %% + * Copyright (C) 2012 UMS 3462, Code Lutin + * %% + * 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 javax.swing.*; +import javax.swing.table.TableCellRenderer; +import java.awt.*; + +/** + * Created: 18/07/12 + * + * @author fdesbois <desbois@codelutin.com> + */ +public class TransectCrossingNumberCellRenderer implements TableCellRenderer { + + protected TableCellRenderer delegate; + + protected TransectTableModel model; + + public TransectCrossingNumberCellRenderer(TableCellRenderer delegate, + TransectTableModel model) { + this.delegate = delegate; + this.model = model; + } + + @Override + public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { + + TransectFlightModel transectFlight = model.getRow(row); + TransectModel transect = transectFlight.getTransect(); + + int crossingNumber = transectFlight.getCrossingNumber(); + int realNbTimes = transect.getRealNbTimes(); + + String newValue = crossingNumber + " (" + realNbTimes +")"; + + return delegate.getTableCellRendererComponent(table, newValue, isSelected, hasFocus, row, column); + } +} Property changes on: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/TransectCrossingNumberCellRenderer.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Modified: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/TransectFlightModel.java =================================================================== --- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/TransectFlightModel.java 2012-08-01 13:17:43 UTC (rev 336) +++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/TransectFlightModel.java 2012-08-01 13:38:03 UTC (rev 337) @@ -23,23 +23,16 @@ * #L% */ -import com.google.common.base.Function; import com.google.common.base.Preconditions; import com.google.common.base.Predicates; import com.google.common.collect.Iterables; import fr.ulr.sammoa.persistence.Flight; import fr.ulr.sammoa.persistence.Observer; import fr.ulr.sammoa.persistence.ObserverPosition; -import fr.ulr.sammoa.persistence.ObserverPositions; import fr.ulr.sammoa.persistence.Position; -import fr.ulr.sammoa.persistence.Transect; import fr.ulr.sammoa.persistence.TransectFlight; import fr.ulr.sammoa.ui.swing.BaseModel; -import javax.annotation.Nullable; -import java.beans.PropertyChangeListener; -import java.util.Map; - /** * Created: 27/07/12 * @@ -56,6 +49,8 @@ public static final String PROPERTY_DELETED = "deleted"; public static final String PROPERTY_INDEX = "index"; + + public static final String PROPERTY_CROSSING_NUMBER = "crossingNumber"; protected FlightUIModel flightModel; @@ -131,6 +126,24 @@ firePropertyChange(PROPERTY_INDEX, oldValue, index); } + public int getCrossingNumber() { + return getSource().getCrossingNumber(); + } + + public void setCrossingNumber(int crossingNumber) { + int oldValue = getCrossingNumber(); + getSource().setCrossingNumber(crossingNumber); + + // We need to update the manual nbTimes from transect to ensure next crossingNumber value + // only if the nbTimes is inferior to the new value manually set + int nbTimes = getTransect().getSource().getNbTimes(); + if (crossingNumber > nbTimes) { + getTransect().getSource().setNbTimes(crossingNumber); + } + + firePropertyChange(PROPERTY_CROSSING_NUMBER, oldValue, crossingNumber); + } + public ObserverPosition getObserverPositionByPosition(Position position) { return getSource().getObserverPositionByPosition(position); } Deleted: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/TransectNbTimesCellRenderer.java =================================================================== --- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/TransectNbTimesCellRenderer.java 2012-08-01 13:17:43 UTC (rev 336) +++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/TransectNbTimesCellRenderer.java 2012-08-01 13:38:03 UTC (rev 337) @@ -1,63 +0,0 @@ -package fr.ulr.sammoa.ui.swing.flight; -/* - * #%L - * SAMMOA :: UI Swing - * $Id:$ - * $HeadURL:$ - * %% - * Copyright (C) 2012 UMS 3462, Code Lutin - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/gpl-3.0.html>. - * #L% - */ - -import fr.ulr.sammoa.persistence.Transect; -import fr.ulr.sammoa.persistence.TransectFlight; - -import javax.swing.JTable; -import javax.swing.table.TableCellRenderer; -import java.awt.Component; - -/** - * Created: 18/07/12 - * - * @author fdesbois <desbois@codelutin.com> - */ -public class TransectNbTimesCellRenderer implements TableCellRenderer { - - protected TableCellRenderer delegate; - - protected TransectTableModel model; - - public TransectNbTimesCellRenderer(TableCellRenderer delegate, - TransectTableModel model) { - this.delegate = delegate; - this.model = model; - } - - @Override - public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { - - TransectFlightModel transectFlight = model.getRow(row); - TransectModel transect = transectFlight.getTransect(); - - int nbTimes = transect.getSource().getNbTimes(); - int realNbTimes = transect.getRealNbTimes(); - - String newValue = nbTimes + " (" + realNbTimes +")"; - - return delegate.getTableCellRendererComponent(table, newValue, isSelected, hasFocus, row, column); - } -} Modified: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/TransectTable.java =================================================================== --- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/TransectTable.java 2012-08-01 13:17:43 UTC (rev 336) +++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/TransectTable.java 2012-08-01 13:38:03 UTC (rev 337) @@ -31,6 +31,7 @@ import fr.ulr.sammoa.ui.swing.util.SammoaUtil; import jaxx.runtime.swing.JAXXWidgetUtil; import jaxx.runtime.swing.editor.BooleanCellEditor; +import jaxx.runtime.swing.editor.cell.NumberCellEditor; import jaxx.runtime.swing.renderer.DecoratorProviderTableCellRenderer; import org.jdesktop.swingx.JXTable; import org.nuiton.util.decorator.DecoratorProvider; @@ -95,12 +96,15 @@ // Set specific renderer for NbTimes column TableCellRenderer defaultRenderer = getDefaultRenderer(String.class); - TransectNbTimesCellRenderer cellRenderer = new TransectNbTimesCellRenderer(defaultRenderer, getModel()); - getColumnModel().getColumn(TransectTableModel.TransectColumn.NB_TIMES.ordinal()).setCellRenderer(cellRenderer); + TransectCrossingNumberCellRenderer cellRenderer = new TransectCrossingNumberCellRenderer(defaultRenderer, getModel()); + getColumnModel().getColumn(TransectTableModel.TransectColumn.CROSSING_NUMBER.ordinal()).setCellRenderer(cellRenderer); setDefaultEditor(Boolean.class, booleanTableCell); - setDefaultEditor(Integer.class, JAXXWidgetUtil.newNumberTableCellEditor(Integer.class, false)); + NumberCellEditor<Integer> numberCellEditor = JAXXWidgetUtil.newNumberTableCellEditor(Integer.class, false); + setDefaultEditor(Integer.class, numberCellEditor); + setDefaultEditor(int.class, numberCellEditor); + initPositionColumnHeaderColors(); for (int i = 0; i < getModel().getRowCount(); i++) { Modified: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/TransectTableModel.java =================================================================== --- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/TransectTableModel.java 2012-08-01 13:17:43 UTC (rev 336) +++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/TransectTableModel.java 2012-08-01 13:38:03 UTC (rev 337) @@ -25,7 +25,6 @@ package fr.ulr.sammoa.ui.swing.flight; import com.google.common.base.Predicate; -import com.google.common.base.Predicates; import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import fr.ulr.sammoa.persistence.Flight; @@ -37,8 +36,7 @@ import fr.ulr.sammoa.persistence.TransectFlight; import fr.ulr.sammoa.ui.swing.util.SammoaUtil; -import javax.annotation.Nullable; -import javax.swing.SwingUtilities; +import javax.swing.*; import javax.swing.table.AbstractTableModel; import java.util.List; @@ -264,18 +262,17 @@ CROSSING_NUMBER( _("sammoa.flightPanel.table.column.crossingNumber"), true, - Integer.class, - TransectFlightModel.PROPERTY_SOURCE, - TransectFlight.PROPERTY_CROSSING_NUMBER + int.class, + TransectFlightModel.PROPERTY_CROSSING_NUMBER ), - NB_TIMES( - _("sammoa.flightPanel.table.column.nbTimes"), - true, - Integer.class, - TransectFlightModel.PROPERTY_TRANSECT, - TransectModel.PROPERTY_SOURCE, - Transect.PROPERTY_NB_TIMES - ), +// NB_TIMES( +// _("sammoa.flightPanel.table.column.nbTimes"), +// true, +// Integer.class, +// TransectFlightModel.PROPERTY_TRANSECT, +// TransectModel.PROPERTY_SOURCE, +// Transect.PROPERTY_NB_TIMES +// ), DELETED( _("sammoa.flightPanel.table.column.deleted"), true,
participants (1)
-
fdesbois@users.forge.codelutin.com