source: josm/trunk/src/org/openstreetmap/josm/gui/history/TagTableColumnModel.java@ 19013

Last change on this file since 19013 was 19013, checked in by GerdP, 3 months ago

see #23482: optimize the space in the history view (column width) and consider adding line wrapping

  • use TableHelper.adjustColumnWidth to adjust column widths each time when the displayed tag data changes
  • set maximum width for the "Since" column
  • Property svn:eol-style set to native
File size: 1.5 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.gui.history;
3
4import static org.openstreetmap.josm.tools.I18n.tr;
5
6import javax.swing.JLabel;
7import javax.swing.table.DefaultTableColumnModel;
8import javax.swing.table.TableColumn;
9
10/**
11 * The {@link javax.swing.table.TableColumnModel} for the table with the list of tags
12 * @since 1709
13 */
14public class TagTableColumnModel extends DefaultTableColumnModel {
15 protected static final int COLUMN_KEY = 0;
16 protected static final int COLUMN_VALUE = 1;
17 protected static final int COLUMN_VERSION = 2;
18
19 /**
20 * Constructs a new {@code TagTableColumnModel}.
21 */
22 public TagTableColumnModel() {
23 createColumns();
24 }
25
26 protected void createColumns() {
27 TagTableCellRenderer renderer = new TagTableCellRenderer();
28
29 TableColumn col = new TableColumn(COLUMN_KEY);
30 col.setHeaderValue(tr("Key"));
31 col.setCellRenderer(renderer);
32 col.setPreferredWidth(100);
33 addColumn(col);
34
35 col = new TableColumn(COLUMN_VALUE);
36 col.setHeaderValue(tr("Value"));
37 col.setCellRenderer(renderer);
38 col.setPreferredWidth(100);
39 addColumn(col);
40
41 col = new TableColumn(COLUMN_VERSION);
42 col.setHeaderValue(tr("Since"));
43 col.setCellRenderer(renderer);
44 col.setPreferredWidth(10);
45 col.setMaxWidth(new JLabel("v" + Long.MAX_VALUE).getMinimumSize().width); // See #23482
46 addColumn(col);
47 }
48}
Note: See TracBrowser for help on using the repository browser.