Changeset 6207 in josm for trunk/src/org
- Timestamp:
- 2013-08-29T01:04:44+02:00 (11 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/gui/history
- Files:
-
- 1 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/history/RelationMemberListViewer.java
r6147 r6207 2 2 package org.openstreetmap.josm.gui.history; 3 3 4 import java.awt.GridBagConstraints;5 import java.awt.GridBagLayout;6 import java.awt.Insets;7 4 import java.awt.Rectangle; 8 5 9 import javax.swing.JPanel;10 import javax.swing.JScrollPane;11 6 import javax.swing.JTable; 12 7 import javax.swing.ListSelectionModel; 13 8 import javax.swing.event.TableModelEvent; 14 9 import javax.swing.event.TableModelListener; 15 16 import org.openstreetmap.josm.gui.util.AdjustmentSynchronizer;17 10 18 11 /** … … 26 19 * 27 20 */ 28 29 public class RelationMemberListViewer extends JPanel{ 30 31 private HistoryBrowserModel model; 32 private VersionInfoPanel referenceInfoPanel; 33 private VersionInfoPanel currentInfoPanel; 34 private AdjustmentSynchronizer adjustmentSynchronizer; 35 private SelectionSynchronizer selectionSynchronizer; 36 37 protected JScrollPane embeddInScrollPane(JTable table) { 38 JScrollPane pane = new JScrollPane(table); 39 pane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); 40 pane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); 41 adjustmentSynchronizer.participateInSynchronizedScrolling(pane.getVerticalScrollBar()); 42 return pane; 43 } 21 public class RelationMemberListViewer extends HistoryViewerPanel { 44 22 45 23 protected class MemberModelChanged implements TableModelListener { … … 57 35 } 58 36 59 protected JTable buildReference MemberListTable() {37 protected JTable buildReferenceTable() { 60 38 JTable table = new JTable( 61 39 model.getRelationMemberTableModel(PointInTimeType.REFERENCE_POINT_IN_TIME), … … 69 47 } 70 48 71 protected JTable buildCurrent MemberListTable() {49 protected JTable buildCurrentTable() { 72 50 JTable table = new JTable( 73 51 model.getRelationMemberTableModel(PointInTimeType.CURRENT_POINT_IN_TIME), … … 81 59 } 82 60 83 protected void build() { 84 setLayout(new GridBagLayout()); 85 GridBagConstraints gc = new GridBagConstraints(); 86 87 // --------------------------- 88 gc.gridx = 0; 89 gc.gridy = 0; 90 gc.gridwidth = 1; 91 gc.gridheight = 1; 92 gc.weightx = 0.5; 93 gc.weighty = 0.0; 94 gc.insets = new Insets(5,5,5,0); 95 gc.fill = GridBagConstraints.HORIZONTAL; 96 gc.anchor = GridBagConstraints.FIRST_LINE_START; 97 referenceInfoPanel = new VersionInfoPanel(model, PointInTimeType.REFERENCE_POINT_IN_TIME); 98 add(referenceInfoPanel,gc); 99 100 gc.gridx = 1; 101 gc.gridy = 0; 102 gc.gridwidth = 1; 103 gc.gridheight = 1; 104 gc.fill = GridBagConstraints.HORIZONTAL; 105 gc.weightx = 0.5; 106 gc.weighty = 0.0; 107 gc.anchor = GridBagConstraints.FIRST_LINE_START; 108 currentInfoPanel = new VersionInfoPanel(model, PointInTimeType.CURRENT_POINT_IN_TIME); 109 add(currentInfoPanel,gc); 110 111 adjustmentSynchronizer = new AdjustmentSynchronizer(); 112 selectionSynchronizer = new SelectionSynchronizer(); 113 114 // --------------------------- 115 gc.gridx = 0; 116 gc.gridy = 1; 117 gc.gridwidth = 1; 118 gc.gridheight = 1; 119 gc.weightx = 0.5; 120 gc.weighty = 1.0; 121 gc.fill = GridBagConstraints.BOTH; 122 gc.anchor = GridBagConstraints.NORTHWEST; 123 add(embeddInScrollPane(buildReferenceMemberListTable()),gc); 124 125 gc.gridx = 1; 126 gc.gridy = 1; 127 gc.gridwidth = 1; 128 gc.gridheight = 1; 129 gc.weightx = 0.5; 130 gc.weighty = 1.0; 131 gc.fill = GridBagConstraints.BOTH; 132 gc.anchor = GridBagConstraints.NORTHWEST; 133 add(embeddInScrollPane(buildCurrentMemberListTable()),gc); 134 } 135 61 /** 62 * Constructs a new {@code RelationMemberListViewer}. 63 * @param model The history browsing model 64 */ 136 65 public RelationMemberListViewer(HistoryBrowserModel model) { 137 setModel(model); 138 build(); 139 } 140 141 protected void unregisterAsObserver(HistoryBrowserModel model) { 142 if (currentInfoPanel != null) { 143 model.deleteObserver(currentInfoPanel); 144 } 145 if (referenceInfoPanel != null) { 146 model.deleteObserver(referenceInfoPanel); 147 } 148 } 149 protected void registerAsObserver(HistoryBrowserModel model) { 150 if (currentInfoPanel != null) { 151 model.addObserver(currentInfoPanel); 152 } 153 if (referenceInfoPanel != null) { 154 model.addObserver(referenceInfoPanel); 155 } 156 } 157 158 public void setModel(HistoryBrowserModel model) { 159 if (this.model != null) { 160 unregisterAsObserver(model); 161 } 162 this.model = model; 163 if (this.model != null) { 164 registerAsObserver(model); 165 } 66 super(model); 166 67 } 167 68 } -
trunk/src/org/openstreetmap/josm/gui/history/TagInfoViewer.java
r6147 r6207 2 2 package org.openstreetmap.josm.gui.history; 3 3 4 import java.awt.GridBagConstraints;5 import java.awt.GridBagLayout;6 import java.awt.Insets;7 8 import javax.swing.JPanel;9 import javax.swing.JScrollPane;10 4 import javax.swing.JTable; 11 5 import javax.swing.ListSelectionModel; 12 13 import org.openstreetmap.josm.gui.util.AdjustmentSynchronizer;14 6 15 7 /** … … 23 15 * 24 16 */ 25 public class TagInfoViewer extends JPanel{17 public class TagInfoViewer extends HistoryViewerPanel { 26 18 27 private HistoryBrowserModel model; 28 private VersionInfoPanel referenceInfoPanel; 29 private VersionInfoPanel currentInfoPanel; 30 private AdjustmentSynchronizer adjustmentSynchronizer; 31 private SelectionSynchronizer selectionSynchronizer; 32 33 protected JScrollPane embeddInScrollPane(JTable table) { 34 JScrollPane pane = new JScrollPane(table); 35 pane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); 36 pane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); 37 adjustmentSynchronizer.participateInSynchronizedScrolling(pane.getVerticalScrollBar()); 38 return pane; 39 } 40 41 protected JTable buildReferenceTagTable() { 19 protected JTable buildReferenceTable() { 42 20 JTable table = new JTable( 43 21 model.getTagTableModel(PointInTimeType.REFERENCE_POINT_IN_TIME), … … 50 28 } 51 29 52 protected JTable buildCurrentTa gTable() {30 protected JTable buildCurrentTable() { 53 31 JTable table = new JTable( 54 32 model.getTagTableModel(PointInTimeType.CURRENT_POINT_IN_TIME), … … 61 39 } 62 40 63 protected void build() { 64 setLayout(new GridBagLayout()); 65 GridBagConstraints gc = new GridBagConstraints(); 66 67 // --------------------------- 68 gc.gridx = 0; 69 gc.gridy = 0; 70 gc.gridwidth = 1; 71 gc.gridheight = 1; 72 gc.weightx = 0.5; 73 gc.weighty = 0.0; 74 gc.insets = new Insets(5,5,5,0); 75 gc.fill = GridBagConstraints.HORIZONTAL; 76 gc.anchor = GridBagConstraints.FIRST_LINE_START; 77 referenceInfoPanel = new VersionInfoPanel(model, PointInTimeType.REFERENCE_POINT_IN_TIME); 78 add(referenceInfoPanel,gc); 79 80 gc.gridx = 1; 81 gc.gridy = 0; 82 gc.gridwidth = 1; 83 gc.gridheight = 1; 84 gc.fill = GridBagConstraints.HORIZONTAL; 85 gc.weightx = 0.5; 86 gc.weighty = 0.0; 87 gc.anchor = GridBagConstraints.FIRST_LINE_START; 88 currentInfoPanel = new VersionInfoPanel(model, PointInTimeType.CURRENT_POINT_IN_TIME); 89 add(currentInfoPanel,gc); 90 91 adjustmentSynchronizer = new AdjustmentSynchronizer(); 92 selectionSynchronizer = new SelectionSynchronizer(); 93 94 // --------------------------- 95 gc.gridx = 0; 96 gc.gridy = 1; 97 gc.gridwidth = 1; 98 gc.gridheight = 1; 99 gc.weightx = 0.5; 100 gc.weighty = 1.0; 101 gc.fill = GridBagConstraints.BOTH; 102 gc.anchor = GridBagConstraints.NORTHWEST; 103 add(embeddInScrollPane(buildReferenceTagTable()),gc); 104 105 gc.gridx = 1; 106 gc.gridy = 1; 107 gc.gridwidth = 1; 108 gc.gridheight = 1; 109 gc.weightx = 0.5; 110 gc.weighty = 1.0; 111 gc.fill = GridBagConstraints.BOTH; 112 gc.anchor = GridBagConstraints.NORTHWEST; 113 add(embeddInScrollPane(buildCurrentTagTable()),gc); 114 } 115 41 /** 42 * Constructs a new {@code TagInfoViewer}. 43 * @param model The history browsing model 44 */ 116 45 public TagInfoViewer(HistoryBrowserModel model) { 117 setModel(model); 118 build(); 119 } 120 121 protected void unregisterAsObserver(HistoryBrowserModel model) { 122 if (currentInfoPanel != null) { 123 model.deleteObserver(currentInfoPanel); 124 } 125 if (referenceInfoPanel != null) { 126 model.deleteObserver(referenceInfoPanel); 127 } 128 } 129 protected void registerAsObserver(HistoryBrowserModel model) { 130 if (currentInfoPanel != null) { 131 model.addObserver(currentInfoPanel); 132 } 133 if (referenceInfoPanel != null) { 134 model.addObserver(referenceInfoPanel); 135 } 136 } 137 138 public void setModel(HistoryBrowserModel model) { 139 if (this.model != null) { 140 unregisterAsObserver(model); 141 } 142 this.model = model; 143 if (this.model != null) { 144 registerAsObserver(model); 145 } 46 super(model); 146 47 } 147 48 }
Note:
See TracChangeset
for help on using the changeset viewer.