Ticket #23482: 23482-2.patch
| File 23482-2.patch, 5.2 KB (added by , 2 years ago) |
|---|
-
src/org/openstreetmap/josm/gui/history/HistoryBrowser.java
11 11 import javax.swing.JScrollPane; 12 12 import javax.swing.JSplitPane; 13 13 import javax.swing.JTabbedPane; 14 import javax.swing.event.ChangeEvent; 15 import javax.swing.event.ChangeListener; 14 16 15 17 import org.openstreetmap.josm.data.osm.OsmPrimitive; 16 18 import org.openstreetmap.josm.data.osm.OsmPrimitiveType; … … 22 24 * 23 25 * @since 1709 24 26 */ 25 public class HistoryBrowser extends JPanel implements Destroyable {27 public class HistoryBrowser extends JPanel implements Destroyable, ChangeListener { 26 28 27 29 /** the model */ 28 30 private transient HistoryBrowserModel model; … … 115 117 public void populate(History history) { 116 118 boolean samePrimitive = model.isSamePrimitive(history); // needs to be before setHistory 117 119 model.setHistory(history); 120 model.addChangeListener(this); 118 121 if (samePrimitive) { 119 122 // no need to rebuild the UI 120 123 return; … … 159 162 public void destroy() { 160 163 if (model != null) { 161 164 model.unlinkAsListener(); 165 model.removeChangeListener(this); 162 166 model = null; 163 167 } 164 168 Stream.of(tagInfoViewer, nodeListViewer, relationMemberListViewer, coordinateInfoViewer) … … 168 172 relationMemberListViewer = null; 169 173 coordinateInfoViewer = null; 170 174 } 175 176 @Override 177 public void stateChanged(ChangeEvent e) { 178 tagInfoViewer.adjustWidths(); 179 } 171 180 } -
src/org/openstreetmap/josm/gui/history/HistoryBrowserDialogManager.java
18 18 19 19 import javax.swing.JOptionPane; 20 20 import javax.swing.SwingUtilities; 21 import javax.swing.event.ChangeEvent; 21 22 22 23 import org.openstreetmap.josm.data.osm.PrimitiveId; 23 24 import org.openstreetmap.josm.data.osm.history.History; … … 147 148 HistoryBrowserDialog dialog = new HistoryBrowserDialog(h); 148 149 placeOnScreen(dialog); 149 150 dialog.setVisible(true); 151 dialog.getHistoryBrowser().stateChanged(new ChangeEvent(this)); 150 152 dialogs.put(h.getId(), dialog); 151 153 } 152 154 } -
src/org/openstreetmap/josm/gui/history/TagInfoViewer.java
35 35 * @since 1709 36 36 */ 37 37 public class TagInfoViewer extends HistoryViewerPanel { 38 private JTable reference; 39 private JTable current; 38 40 private static final class RepaintOnFocusChange implements FocusListener { 39 41 @Override 40 42 public void focusLost(FocusEvent e) { … … 62 64 63 65 @Override 64 66 protected JTable buildReferenceTable() { 65 return buildTable(PointInTimeType.REFERENCE_POINT_IN_TIME); 67 reference = buildTable(PointInTimeType.REFERENCE_POINT_IN_TIME); 68 return reference; 66 69 } 67 70 68 71 @Override 69 72 protected JTable buildCurrentTable() { 70 return buildTable(PointInTimeType.CURRENT_POINT_IN_TIME); 73 current = buildTable(PointInTimeType.CURRENT_POINT_IN_TIME); 74 return current; 71 75 } 72 76 73 77 private JTable buildTable(PointInTimeType pointInTime) { … … 105 109 table.addMouseListener(new PopupMenuLauncher(tagMenu)); 106 110 return table; 107 111 } 112 113 /** 114 * Use current data to adjust preferredWidth for both tables. 115 */ 116 public void adjustWidths() { 117 // We have two tables with 3 columns each. no column should get more than 1/4 of the size 118 int maxWidth = this.getWidth() / 4; 119 if (maxWidth == 0) 120 maxWidth = Integer.MAX_VALUE; 121 adjustWidths(reference, maxWidth); 122 adjustWidths(current, maxWidth); 123 } 124 125 private static void adjustWidths(JTable table, int maxWidth) { 126 for (int column = 0; column < table.getColumnCount(); column++) { 127 TableHelper.adjustColumnWidth(table, column, maxWidth); 128 } 129 } 130 108 131 } -
src/org/openstreetmap/josm/gui/history/TagTableColumnModel.java
3 3 4 4 import static org.openstreetmap.josm.tools.I18n.tr; 5 5 6 import javax.swing.JLabel; 6 7 import javax.swing.table.DefaultTableColumnModel; 7 8 import javax.swing.table.TableColumn; 8 9 … … 41 42 col.setHeaderValue(tr("Since")); 42 43 col.setCellRenderer(renderer); 43 44 col.setPreferredWidth(10); 45 col.setMaxWidth(new JLabel("v" + Long.MAX_VALUE).getMinimumSize().width); // See #23482 44 46 addColumn(col); 45 47 } 46 48 }
