source: josm/trunk/src/org/openstreetmap/josm/gui/history/HistoryViewerPanel.java@ 14463

Last change on this file since 14463 was 14463, checked in by Don-vip, 5 years ago

fix #17040 - fix memory leaks when calling history dialog

  • Property svn:eol-style set to native
File size: 2.7 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.gui.history;
3
4import java.awt.GridBagConstraints;
5import java.awt.Insets;
6
7import javax.swing.JScrollPane;
8import javax.swing.JTable;
9
10import org.openstreetmap.josm.gui.util.AdjustmentSynchronizer;
11
12/**
13 * Base class of {@link TagInfoViewer} and {@link RelationMemberListViewer}.
14 * @since 6207
15 */
16public abstract class HistoryViewerPanel extends HistoryBrowserPanel {
17
18 protected transient AdjustmentSynchronizer adjustmentSynchronizer;
19 protected transient SelectionSynchronizer selectionSynchronizer;
20
21 protected HistoryViewerPanel(HistoryBrowserModel model) {
22 setModel(model);
23 build();
24 }
25
26 private JScrollPane embedInScrollPane(JTable table) {
27 JScrollPane pane = new JScrollPane(table);
28 adjustmentSynchronizer.participateInSynchronizedScrolling(pane.getVerticalScrollBar());
29 return pane;
30 }
31
32 protected abstract JTable buildReferenceTable();
33
34 protected abstract JTable buildCurrentTable();
35
36 private void build() {
37 GridBagConstraints gc = new GridBagConstraints();
38
39 // ---------------------------
40 gc.gridx = 0;
41 gc.gridy = 0;
42 gc.gridwidth = 1;
43 gc.gridheight = 1;
44 gc.weightx = 0.5;
45 gc.weighty = 0.0;
46 gc.insets = new Insets(5, 5, 5, 0);
47 gc.fill = GridBagConstraints.HORIZONTAL;
48 gc.anchor = GridBagConstraints.FIRST_LINE_START;
49 referenceInfoPanel = new VersionInfoPanel(model, PointInTimeType.REFERENCE_POINT_IN_TIME);
50 add(referenceInfoPanel, gc);
51
52 gc.gridx = 1;
53 gc.gridy = 0;
54 gc.gridwidth = 1;
55 gc.gridheight = 1;
56 gc.fill = GridBagConstraints.HORIZONTAL;
57 gc.weightx = 0.5;
58 gc.weighty = 0.0;
59 gc.anchor = GridBagConstraints.FIRST_LINE_START;
60 currentInfoPanel = new VersionInfoPanel(model, PointInTimeType.CURRENT_POINT_IN_TIME);
61 add(currentInfoPanel, gc);
62
63 adjustmentSynchronizer = new AdjustmentSynchronizer();
64 selectionSynchronizer = new SelectionSynchronizer();
65
66 // ---------------------------
67 gc.gridx = 0;
68 gc.gridy = 1;
69 gc.gridwidth = 1;
70 gc.gridheight = 1;
71 gc.weightx = 0.5;
72 gc.weighty = 1.0;
73 gc.fill = GridBagConstraints.BOTH;
74 gc.anchor = GridBagConstraints.NORTHWEST;
75 add(embedInScrollPane(buildReferenceTable()), gc);
76
77 gc.gridx = 1;
78 gc.gridy = 1;
79 gc.gridwidth = 1;
80 gc.gridheight = 1;
81 gc.weightx = 0.5;
82 gc.weighty = 1.0;
83 gc.fill = GridBagConstraints.BOTH;
84 gc.anchor = GridBagConstraints.NORTHWEST;
85 add(embedInScrollPane(buildCurrentTable()), gc);
86 }
87}
Note: See TracBrowser for help on using the repository browser.