Changeset 7933 in josm for trunk


Ignore:
Timestamp:
2015-01-07T01:45:32+01:00 (10 years ago)
Author:
Don-vip
Message:

fix #10927 - simple UI improvement for History dialog

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/history/VersionTable.java

    r7771 r7933  
    4242 * VersionTable shows a list of version in a {@link org.openstreetmap.josm.data.osm.history.History}
    4343 * of an {@link org.openstreetmap.josm.data.osm.OsmPrimitive}.
    44  *
     44 * @since 1709
    4545 */
    4646public class VersionTable extends JTable implements Observer{
     
    9393    }
    9494
     95    /**
     96     * Constructs a new {@code VersionTable}.
     97     * @param model model used by the history browser
     98     */
    9599    public VersionTable(HistoryBrowserModel model) {
    96100        super(model.getVersionTableModel(), new VersionTableColumnModel());
     
    117121
    118122    class MouseListener extends PopupMenuLauncher {
    119         public MouseListener() {
     123        private MouseListener() {
    120124            super(popupMenu);
    121125        }
     
    126130                int row = rowAtPoint(e.getPoint());
    127131                int col = columnAtPoint(e.getPoint());
    128                 if (row > 0 && (col == VersionTableColumnModel.COL_DATE || col == VersionTableColumnModel.COL_USER)) {
     132                if (row >= 0 && (col == VersionTableColumnModel.COL_DATE || col == VersionTableColumnModel.COL_USER)) {
    129133                    model.getVersionTableModel().setCurrentPointInTime(row);
    130                     model.getVersionTableModel().setReferencePointInTime(row - 1);
     134                    model.getVersionTableModel().setReferencePointInTime(Math.max(0, row - 1));
    131135                }
    132136            }
     
    231235
    232236        @Override
    233         public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus,int row,int column) {
     237        public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus,
     238                int row, int column) {
    234239            setSelected(value != null && (Boolean)value);
    235240            setHorizontalAlignment(SwingConstants.CENTER);
     
    242247        private JRadioButton btn;
    243248
     249        /**
     250         * Constructs a new {@code RadioButtonEditor}.
     251         */
    244252        public RadioButtonEditor() {
    245253            super(new JCheckBox());
     
    270278
    271279    public static class AlignedRenderer extends JLabel implements TableCellRenderer {
     280
     281        /**
     282         * Constructs a new {@code AlignedRenderer}.
     283         * @param hAlignment Horizontal alignement. One of the following constants defined in SwingConstants:
     284         *        LEFT, CENTER (the default for image-only labels), RIGHT, LEADING (the default for text-only labels) or TRAILING
     285         */
    272286        public AlignedRenderer(int hAlignment) {
    273287            setHorizontalAlignment(hAlignment);
    274288        }
    275         @Override
    276         public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus,int row,int column) {
     289
     290        @Override
     291        public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus,
     292                int row, int column) {
    277293            String v = value.toString();
    278294            setText(v);
     
    298314        tbl.getColumnModel().getColumn(col).setPreferredWidth(maxwidth + spacing);
    299315    }
    300 
    301316}
Note: See TracChangeset for help on using the changeset viewer.