Changeset 2242 in josm for trunk/src/org/openstreetmap/josm/gui/history
- Timestamp:
- 2009-10-04T00:37:05+02:00 (14 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/gui/history
- Files:
-
- 3 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/history/HistoryBrowser.java
r1709 r2242 14 14 15 15 import org.openstreetmap.josm.data.osm.history.History; 16 import org.openstreetmap.josm.data.osm.OsmPrimitiveType; 16 17 17 18 /** 18 19 * HistoryBrowser is an UI component which displays history information about an {@see OsmPrimitive}. 19 * 20 * 20 21 * 21 22 */ … … 24 25 /** the model */ 25 26 private HistoryBrowserModel model; 27 private JTabbedPane dataPane; 26 28 27 29 /** 28 30 * embedds table in a {@see JScrollPane} 29 * 31 * 30 32 * @param table the table 31 33 * @return the {@see JScrollPane} with the embedded table … … 40 42 /** 41 43 * creates the table which shows the list of versions 42 * 44 * 43 45 * @return the panel with the version table 44 46 */ … … 55 57 * creates the panel which shows information about two different versions 56 58 * of the same {@see OsmPrimitive}. 57 * 59 * 58 60 * @return the panel 59 61 */ 62 60 63 protected JPanel createVersionComparePanel() { 61 JTabbedPane pane = new JTabbedPane();62 pane.add(new TagInfoViewer(model));63 pane.setTitleAt(0, tr("Tags"));64 dataPane = new JTabbedPane(); 65 dataPane.add(new TagInfoViewer(model)); 66 dataPane.setTitleAt(0, tr("Tags")); 64 67 65 pane.add(new NodeListViewer(model));66 pane.setTitleAt(1, tr("Nodes"));68 dataPane.add(new NodeListViewer(model)); 69 dataPane.setTitleAt(1, tr("Nodes")); 67 70 68 pane.add(new RelationMemberListViewer(model)); 69 pane.setTitleAt(2, tr("Members")); 71 dataPane.add(new RelationMemberListViewer(model)); 72 dataPane.setTitleAt(2, tr("Members")); 73 74 dataPane.add(new CoordinateViewer(model)); 75 dataPane.setTitleAt(3, tr("Coordinate")); 70 76 71 77 JPanel pnl = new JPanel(); 72 78 pnl.setLayout(new BorderLayout()); 73 pnl.add( pane, BorderLayout.CENTER);79 pnl.add(dataPane, BorderLayout.CENTER); 74 80 return pnl; 75 81 } … … 116 122 /** 117 123 * populates the browser with the history of a specific {@see OsmPrimitive} 118 * 124 * 119 125 * @param history the history 120 126 */ 121 127 public void populate(History history) { 122 128 model.setHistory(history); 129 OsmPrimitiveType type = history.getType(); 130 if(type != null) 131 { 132 if(type == OsmPrimitiveType.NODE) 133 { 134 dataPane.setEnabledAt(1, false); 135 dataPane.setEnabledAt(2, false); 136 } 137 else if(type == OsmPrimitiveType.WAY) 138 { 139 dataPane.setEnabledAt(2, false); 140 dataPane.setEnabledAt(3, false); 141 } 142 else 143 { 144 dataPane.setEnabledAt(3, false); 145 } 146 } 123 147 } 124 148 125 149 /** 126 150 * replies the {@see History} currently displayed by this browser 127 * 151 * 128 152 * @return the current history 129 153 */ -
trunk/src/org/openstreetmap/josm/gui/history/HistoryBrowserModel.java
r2182 r2242 12 12 import javax.swing.table.DefaultTableModel; 13 13 14 import org.openstreetmap.josm.data.coor.CoordinateFormat; 15 import org.openstreetmap.josm.data.coor.LatLon; 14 16 import org.openstreetmap.josm.data.osm.OsmPrimitiveType; 15 17 import org.openstreetmap.josm.data.osm.history.History; 18 import org.openstreetmap.josm.data.osm.history.HistoryNode; 16 19 import org.openstreetmap.josm.data.osm.history.HistoryOsmPrimitive; 17 20 import org.openstreetmap.josm.data.osm.history.HistoryRelation; … … 20 23 /** 21 24 * This is the model used by the history browser. 22 * 25 * 23 26 * The state this model manages consists of the following elements: 24 27 * <ul> … … 40 43 * members of the two selected versions (if the current history provides information about a {@see Relation}</li> 41 44 * </ul> 42 * 45 * 43 46 * @see HistoryBrowser 44 47 */ … … 59 62 private RelationMemberTableModel currentRelationMemberTableModel; 60 63 private RelationMemberTableModel referenceRelationMemberTableModel; 64 private CoordinateTableModel currentCoordinateTableModel; 65 private CoordinateTableModel referenceCoordinateTableModel; 61 66 62 67 public HistoryBrowserModel() { … … 68 73 currentRelationMemberTableModel = new RelationMemberTableModel(PointInTimeType.CURRENT_POINT_IN_TIME); 69 74 referenceRelationMemberTableModel = new RelationMemberTableModel(PointInTimeType.REFERENCE_POINT_IN_TIME); 75 currentCoordinateTableModel = new CoordinateTableModel(PointInTimeType.CURRENT_POINT_IN_TIME); 76 referenceCoordinateTableModel = new CoordinateTableModel(PointInTimeType.REFERENCE_POINT_IN_TIME); 70 77 } 71 78 … … 85 92 /** 86 93 * sets the history to be managed by this model 87 * 94 * 88 95 * @param history the history 89 * 96 * 90 97 */ 91 98 public void setHistory(History history) { … … 109 116 * Replies the table model to be used in a {@see JTable} which 110 117 * shows the list of versions in this history. 111 * 118 * 112 119 * @return the table model 113 120 */ … … 121 128 } 122 129 123 protected void initNodeListTabeModel () {130 protected void initNodeListTabeModels() { 124 131 currentNodeListTableModel.fireTableDataChanged(); 125 132 referenceNodeListTableModel.fireTableDataChanged(); 126 133 } 127 134 128 protected void initMemberListTableModel () {135 protected void initMemberListTableModels() { 129 136 currentRelationMemberTableModel.fireTableDataChanged(); 130 137 referenceRelationMemberTableModel.fireTableDataChanged(); 131 138 } 132 139 140 protected void initCoordinateTableModels() { 141 currentCoordinateTableModel.fireTableDataChanged(); 142 referenceCoordinateTableModel.fireTableDataChanged(); 143 } 144 133 145 /** 134 146 * replies the tag table model for the respective point in time 135 * 147 * 136 148 * @param pointInTimeType the type of the point in time (must not be null) 137 149 * @return the tag table model … … 169 181 else if (pointInTimeType.equals(PointInTimeType.REFERENCE_POINT_IN_TIME)) 170 182 return referenceRelationMemberTableModel; 183 184 // should not happen 185 return null; 186 } 187 188 public CoordinateTableModel getCoordinateTableModel(PointInTimeType pointInTimeType) throws IllegalArgumentException { 189 if (pointInTimeType == null) 190 throw new IllegalArgumentException(tr("Parameter ''{0}'' must not be null.", "pointInTimeType")); 191 if (pointInTimeType.equals(PointInTimeType.CURRENT_POINT_IN_TIME)) 192 return currentCoordinateTableModel; 193 else if (pointInTimeType.equals(PointInTimeType.REFERENCE_POINT_IN_TIME)) 194 return referenceCoordinateTableModel; 171 195 172 196 // should not happen … … 187 211 this.reference = reference; 188 212 initTagTableModels(); 189 initNodeListTabeModel(); 190 initMemberListTableModel(); 213 initNodeListTabeModels(); 214 initMemberListTableModels(); 215 initCoordinateTableModels(); 191 216 setChanged(); 192 217 notifyObservers(); … … 205 230 this.current = current; 206 231 initTagTableModels(); 207 initNodeListTabeModel(); 208 initMemberListTableModel(); 232 initNodeListTabeModels(); 233 initMemberListTableModels(); 234 initCoordinateTableModels(); 209 235 setChanged(); 210 236 notifyObservers(); … … 213 239 /** 214 240 * Replies the history OSM primitive for the {@see PointInTimeType#CURRENT_POINT_IN_TIME} 215 * 241 * 216 242 * @return the history OSM primitive for the {@see PointInTimeType#CURRENT_POINT_IN_TIME} (may be null) 217 243 */ … … 222 248 /** 223 249 * Replies the history OSM primitive for the {@see PointInTimeType#REFERENCE_POINT_IN_TIME} 224 * 250 * 225 251 * @return the history OSM primitive for the {@see PointInTimeType#REFERENCE_POINT_IN_TIME} (may be null) 226 252 */ … … 231 257 /** 232 258 * replies the history OSM primitive for a given point in time 233 * 259 * 234 260 * @param type the type of the point in time (must not be null) 235 261 * @return the respective primitive. Can be null. … … 306 332 * The table model for the tags of the version at {@see PointInTimeType#REFERENCE_POINT_IN_TIME} 307 333 * or {@see PointInTimeType#CURRENT_POINT_IN_TIME} 308 * 334 * 309 335 */ 310 336 public class TagTableModel extends DefaultTableModel { … … 401 427 * The table model for the nodes of the version at {@see PointInTimeType#REFERENCE_POINT_IN_TIME} 402 428 * or {@see PointInTimeType#CURRENT_POINT_IN_TIME} 403 * 429 * 404 430 */ 405 431 public class NodeListTableModel extends DefaultTableModel { … … 493 519 * The table model for the relation members of the version at {@see PointInTimeType#REFERENCE_POINT_IN_TIME} 494 520 * or {@see PointInTimeType#CURRENT_POINT_IN_TIME} 495 * 521 * 496 522 */ 497 523 … … 584 610 } 585 611 } 612 613 /** 614 * The table model for the coordinates of the version at {@see PointInTimeType#REFERENCE_POINT_IN_TIME} 615 * or {@see PointInTimeType#CURRENT_POINT_IN_TIME} 616 * 617 */ 618 public class CoordinateTableModel extends DefaultTableModel { 619 620 private LatLon currentCoor = null; 621 private LatLon referenceCoor = null; 622 private PointInTimeType pointInTimeType; 623 624 protected CoordinateTableModel(PointInTimeType type) { 625 pointInTimeType = type; 626 } 627 628 @Override 629 public int getRowCount() { 630 if (current != null && current instanceof HistoryNode) 631 currentCoor = ((HistoryNode)current).getCoordinate(); 632 else 633 return 0; 634 if (reference != null && reference instanceof HistoryNode) 635 referenceCoor = ((HistoryNode)reference).getCoordinate(); 636 return 2; 637 } 638 639 @Override 640 public Object getValueAt(int row, int column) { 641 if(currentCoor == null) 642 return null; 643 else if (pointInTimeType.equals(PointInTimeType.CURRENT_POINT_IN_TIME)) 644 return row == 0 ? currentCoor.latToString(CoordinateFormat.getDefaultFormat()) 645 : currentCoor.lonToString(CoordinateFormat.getDefaultFormat()); 646 else 647 return row == 0 ? referenceCoor.latToString(CoordinateFormat.getDefaultFormat()) 648 : referenceCoor.lonToString(CoordinateFormat.getDefaultFormat()); 649 } 650 651 @Override 652 public boolean isCellEditable(int row, int column) { 653 return false; 654 } 655 656 public boolean hasSameValueAsOpposite(int row) { 657 if(currentCoor == null) 658 return false; 659 else if(row == 0) 660 return currentCoor.lat() == referenceCoor.lat(); 661 return currentCoor.lon() == referenceCoor.lon(); 662 } 663 664 public PointInTimeType getPointInTimeType() { 665 return pointInTimeType; 666 } 667 668 public boolean isCurrentPointInTime() { 669 return pointInTimeType.equals(PointInTimeType.CURRENT_POINT_IN_TIME); 670 } 671 672 public boolean isReferencePointInTime() { 673 return pointInTimeType.equals(PointInTimeType.REFERENCE_POINT_IN_TIME); 674 } 675 } 586 676 } -
trunk/src/org/openstreetmap/josm/gui/history/TagInfoViewer.java
r2017 r2242 12 12 13 13 /** 14 * TagInfoViewer is a UI component which displays the 14 * TagInfoViewer is a UI component which displays the list of tags of two 15 15 * version of a {@see OsmPrimitive} in a {@see History}. 16 * 16 * 17 17 * <ul> 18 18 * <li>on the left, it displays the list of tags for the version at {@see PointInTimeType#REFERENCE_POINT_IN_TIME}</li> -
trunk/src/org/openstreetmap/josm/gui/history/VersionInfoPanel.java
r2181 r2242 21 21 * VersionInfoPanel is an UI component which displays the basic properties of a version 22 22 * of a {@see OsmPrimitive}. 23 * 23 * 24 24 */ 25 25 public class VersionInfoPanel extends JPanel implements Observer{ … … 51 51 Long.toString(primitive.getVersion()), 52 52 new SimpleDateFormat().format(primitive.getTimestamp()), 53 primitive.getUser() ,53 primitive.getUser().replace("<", "<").replace(">", ">"), 54 54 primitive.getChangesetId() 55 55 ); … … 65 65 /** 66 66 * constructor 67 * 67 * 68 68 * @param model the model (must not be null) 69 69 * @param pointInTimeType the point in time this panel visualizes (must not be null)
Note:
See TracChangeset
for help on using the changeset viewer.