Changeset 10125 in josm for trunk/src/org/openstreetmap/josm/gui/correction
- Timestamp:
- 2016-04-09T17:07:54+02:00 (9 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/gui/correction
- Files:
-
- 2 added
- 6 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/correction/CorrectionTable.java
r10113 r10125 1 1 // License: GPL. For details, see LICENSE file. 2 package org.openstreetmap.josm.correct or;2 package org.openstreetmap.josm.gui.correction; 3 3 4 4 import java.awt.Component; … … 10 10 import javax.swing.table.TableCellRenderer; 11 11 12 public abstract class CorrectionTable<T extends CorrectionTableModel<?>> 13 extends JTable { 12 /** 13 * Abstract correction table. 14 * @param <T> type of table model 15 */ 16 public abstract class CorrectionTable<T extends CorrectionTableModel<?>> extends JTable { 14 17 15 18 private static final int MAX_VISIBLE_LINES = 10; 16 19 17 public static class BoldRenderer extends JLabel implements 18 TableCellRenderer { 20 /** 21 * Renders text in bold. 22 */ 23 public static class BoldRenderer extends JLabel implements TableCellRenderer { 19 24 20 25 @Override 21 26 public Component getTableCellRendererComponent(JTable table, 22 Object value, boolean isSelected, boolean hasFocus, int row, 23 int column) { 24 27 Object value, boolean isSelected, boolean hasFocus, int row, int column) { 25 28 Font f = getFont(); 26 29 setFont(new Font(f.getName(), f.getStyle() | Font.BOLD, f.getSize())); 27 28 30 setText((String) value); 29 30 31 return this; 31 32 } … … 38 39 39 40 final int correctionsSize = correctionTableModel.getCorrections().size(); 40 final int lines = correctionsSize > MAX_VISIBLE_LINES ? MAX_VISIBLE_LINES 41 : correctionsSize; 42 setPreferredScrollableViewportSize(new Dimension(400, lines 43 * getRowHeight())); 44 getColumnModel().getColumn(correctionTableModel.getApplyColumn()) 45 .setPreferredWidth(40); 41 final int lines = correctionsSize > MAX_VISIBLE_LINES ? MAX_VISIBLE_LINES : correctionsSize; 42 setPreferredScrollableViewportSize(new Dimension(400, lines * getRowHeight())); 43 getColumnModel().getColumn(correctionTableModel.getApplyColumn()).setPreferredWidth(40); 46 44 setRowSelectionAllowed(false); 47 45 } … … 57 55 } 58 56 57 /** 58 * Returns correction table model. 59 * @return correction table model 60 */ 59 61 @SuppressWarnings("unchecked") 60 62 public T getCorrectionTableModel() { -
trunk/src/org/openstreetmap/josm/gui/correction/CorrectionTableModel.java
r10113 r10125 1 1 // License: GPL. For details, see LICENSE file. 2 package org.openstreetmap.josm.correct or;2 package org.openstreetmap.josm.gui.correction; 3 3 4 4 import static org.openstreetmap.josm.tools.I18n.tr; … … 9 9 import javax.swing.table.AbstractTableModel; 10 10 11 import org.openstreetmap.josm.data.correction.Correction; 12 13 /** 14 * Abstract correction table model. 15 * @param <C> type of correction 16 */ 11 17 public abstract class CorrectionTableModel<C extends Correction> extends AbstractTableModel { 12 18 … … 15 21 private final int applyColumn; 16 22 23 /** 24 * Constructs a new {@code CorrectionTableModel}. 25 * @param corrections list of corrections 26 */ 17 27 public CorrectionTableModel(List<C> corrections) { 18 28 this.corrections = corrections; … … 27 37 protected abstract boolean isBoldCell(int row, int column); 28 38 39 /** 40 * Returns the column name for columns other than "Apply". 41 * @param colIndex column index 42 * @return the translated column name for given index 43 * @see #getApplyColumn 44 */ 29 45 public abstract String getCorrectionColumnName(int colIndex); 30 46 47 /** 48 * Returns the correction value at given position. 49 * @param rowIndex row index 50 * @param colIndex column index 51 * @return the correction value at given position 52 */ 31 53 public abstract Object getCorrectionValueAt(int rowIndex, int colIndex); 32 54 55 /** 56 * Returns the list of corrections. 57 * @return the list of corrections 58 */ 33 59 public List<C> getCorrections() { 34 60 return corrections; 35 61 } 36 62 63 /** 64 * Returns the index of the "Apply" column. 65 * @return the index of the "Apply" column 66 */ 37 67 public int getApplyColumn() { 38 68 return applyColumn; 39 69 } 40 70 71 /** 72 * Returns the "Apply" flag for given index. 73 * @param i index 74 * @return the "Apply" flag for given index 75 */ 41 76 public boolean getApply(int i) { 42 77 return apply[i]; -
trunk/src/org/openstreetmap/josm/gui/correction/RoleCorrectionTable.java
r10113 r10125 1 1 // License: GPL. For details, see LICENSE file. 2 package org.openstreetmap.josm.correct or;2 package org.openstreetmap.josm.gui.correction; 3 3 4 4 import java.util.List; 5 5 6 public class RoleCorrectionTable extends 7 CorrectionTable<RoleCorrectionTableModel> { 6 import org.openstreetmap.josm.data.correction.RoleCorrection; 8 7 8 /** 9 * Role correction table. 10 * @since 1001 11 */ 12 public class RoleCorrectionTable extends CorrectionTable<RoleCorrectionTableModel> { 13 14 /** 15 * Constructs a new {@code RoleCorrectionTable}. 16 * @param roleCorrections role corrections 17 */ 9 18 public RoleCorrectionTable(List<RoleCorrection> roleCorrections) { 10 19 super(new RoleCorrectionTableModel(roleCorrections)); 11 20 } 12 13 21 } -
trunk/src/org/openstreetmap/josm/gui/correction/RoleCorrectionTableModel.java
r10113 r10125 1 1 // License: GPL. For details, see LICENSE file. 2 package org.openstreetmap.josm.correct or;2 package org.openstreetmap.josm.gui.correction; 3 3 4 4 import static org.openstreetmap.josm.tools.I18n.tr; … … 6 6 import java.util.List; 7 7 8 import org.openstreetmap.josm.data.correction.RoleCorrection; 8 9 import org.openstreetmap.josm.gui.DefaultNameFormatter; 9 10 10 public class RoleCorrectionTableModel extends 11 CorrectionTableModel<RoleCorrection> { 11 /** 12 * Role correction table model. 13 * @since 1001 14 */ 15 public class RoleCorrectionTableModel extends CorrectionTableModel<RoleCorrection> { 12 16 17 /** 18 * Constructs a new {@code RoleCorrectionTableModel}. 19 * @param roleCorrections list of role corrections 20 */ 13 21 public RoleCorrectionTableModel(List<RoleCorrection> roleCorrections) { 14 22 super(roleCorrections); … … 29 37 case 2: 30 38 return tr("New role"); 39 default: 40 return null; 31 41 } 32 return null;33 42 } 34 43 … … 44 53 case 2: 45 54 return roleCorrection.newRole; 55 default: 56 return null; 46 57 } 47 return null;48 58 } 49 59 … … 52 62 return column == 2; 53 63 } 54 55 64 } -
trunk/src/org/openstreetmap/josm/gui/correction/TagCorrectionTable.java
r10113 r10125 1 1 // License: GPL. For details, see LICENSE file. 2 package org.openstreetmap.josm.correct or;2 package org.openstreetmap.josm.gui.correction; 3 3 4 4 import java.util.List; 5 5 6 public class TagCorrectionTable extends 7 CorrectionTable<TagCorrectionTableModel> { 6 import org.openstreetmap.josm.data.correction.TagCorrection; 8 7 8 /** 9 * Tag correction table. 10 * @since 729 11 */ 12 public class TagCorrectionTable extends CorrectionTable<TagCorrectionTableModel> { 13 14 /** 15 * Constructs a new {@code TagCorrectionTable}. 16 * @param tagCorrections tag corrections 17 */ 9 18 public TagCorrectionTable(List<TagCorrection> tagCorrections) { 10 19 super(new TagCorrectionTableModel(tagCorrections)); 11 20 } 12 13 21 } -
trunk/src/org/openstreetmap/josm/gui/correction/TagCorrectionTableModel.java
r10113 r10125 1 1 // License: GPL. For details, see LICENSE file. 2 package org.openstreetmap.josm.correct or;2 package org.openstreetmap.josm.gui.correction; 3 3 4 4 import static org.openstreetmap.josm.tools.I18n.tr; … … 6 6 import java.util.List; 7 7 8 import org.openstreetmap.josm.data.correction.TagCorrection; 9 10 /** 11 * Tag correction table model. 12 * @since 729 13 */ 8 14 public class TagCorrectionTableModel extends CorrectionTableModel<TagCorrection> { 9 15 16 /** 17 * Constructs a new {@code TagCorrectionTableModel}. 18 * @param tagCorrections list of tag corrections 19 */ 10 20 public TagCorrectionTableModel(List<TagCorrection> tagCorrections) { 11 21 super(tagCorrections); … … 28 38 case 3: 29 39 return tr("New value"); 40 default: 41 return null; 30 42 } 31 return null;32 43 } 33 44 … … 45 56 case 3: 46 57 return tagCorrection.newValue; 58 default: 59 return null; 47 60 } 48 return null;49 61 } 50 62 … … 53 65 TagCorrection tagCorrection = getCorrections().get(row); 54 66 return (column == 2 && tagCorrection.isKeyChanged()) 55 67 || (column == 3 && tagCorrection.isValueChanged()); 56 68 } 57 58 69 }
Note:
See TracChangeset
for help on using the changeset viewer.