source: josm/trunk/src/org/openstreetmap/josm/gui/history/TagInfoViewer.java@ 11646

Last change on this file since 11646 was 10637, checked in by Don-vip, 8 years ago

fix #13050 - cannot copy from the object history view (patch by michael2402, modified) - gsoc-core

  • Property svn:eol-style set to native
File size: 2.4 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.gui.history;
3
4import java.awt.event.FocusEvent;
5import java.awt.event.FocusListener;
6
7import javax.swing.JTable;
8import javax.swing.ListSelectionModel;
9
10/**
11 * TagInfoViewer is a UI component which displays the list of tags of two
12 * version of a {@link org.openstreetmap.josm.data.osm.OsmPrimitive} in a {@link org.openstreetmap.josm.data.osm.history.History}.
13 *
14 * <ul>
15 * <li>on the left, it displays the list of tags for the version at {@link PointInTimeType#REFERENCE_POINT_IN_TIME}</li>
16 * <li>on the right, it displays the list of tags for the version at {@link PointInTimeType#CURRENT_POINT_IN_TIME}</li>
17 * </ul>
18 *
19 */
20public class TagInfoViewer extends HistoryViewerPanel {
21 private static final class RepaintOnFocusChange implements FocusListener {
22 @Override
23 public void focusLost(FocusEvent e) {
24 repaintSelected(e);
25 }
26
27 @Override
28 public void focusGained(FocusEvent e) {
29 repaintSelected(e);
30 }
31
32 private static void repaintSelected(FocusEvent e) {
33 // we would only need the selected rows, but this is easier:
34 e.getComponent().repaint();
35 }
36 }
37
38 /**
39 * Constructs a new {@code TagInfoViewer}.
40 * @param model The history browsing model
41 */
42 public TagInfoViewer(HistoryBrowserModel model) {
43 super(model);
44 }
45
46 @Override
47 protected JTable buildReferenceTable() {
48 JTable table = new JTable(
49 model.getTagTableModel(PointInTimeType.REFERENCE_POINT_IN_TIME),
50 new TagTableColumnModel()
51 );
52 table.setName("table.referencetagtable");
53 setUpDataTransfer(table);
54 return table;
55 }
56
57 @Override
58 protected JTable buildCurrentTable() {
59 JTable table = new JTable(
60 model.getTagTableModel(PointInTimeType.CURRENT_POINT_IN_TIME),
61 new TagTableColumnModel()
62 );
63 table.setName("table.currenttagtable");
64 setUpDataTransfer(table);
65 return table;
66 }
67
68 private void setUpDataTransfer(JTable table) {
69 table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
70 selectionSynchronizer.participateInSynchronizedSelection(table.getSelectionModel());
71 table.setTransferHandler(new TagInfoTransferHandler());
72 table.addFocusListener(new RepaintOnFocusChange());
73 }
74}
Note: See TracBrowser for help on using the repository browser.