Changeset 2243 in josm for trunk/src/org/openstreetmap/josm/gui/history
- Timestamp:
- 2009-10-04T12:07:16+02:00 (14 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/gui/history
- Files:
-
- 1 added
- 3 deleted
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/history/HistoryBrowser.java
r2242 r2243 13 13 import javax.swing.JTable; 14 14 15 import org.openstreetmap.josm.data.osm.OsmPrimitiveType; 15 16 import org.openstreetmap.josm.data.osm.history.History; 16 import org.openstreetmap.josm.data.osm.OsmPrimitiveType;17 17 18 18 /** 19 19 * HistoryBrowser is an UI component which displays history information about an {@see OsmPrimitive}. 20 * 20 * 21 21 * 22 22 */ … … 25 25 /** the model */ 26 26 private HistoryBrowserModel model; 27 private JTabbedPane dataPane; 27 private TagInfoViewer tagInfoViewer; 28 private NodeListViewer nodeListViewer; 29 private RelationMemberListViewer relationMemberListViewer; 30 private CoordinateInfoViewer coordinateInfoViewer; 31 private JTabbedPane tpViewers; 32 28 33 29 34 /** 30 35 * embedds table in a {@see JScrollPane} 31 * 36 * 32 37 * @param table the table 33 38 * @return the {@see JScrollPane} with the embedded table … … 42 47 /** 43 48 * creates the table which shows the list of versions 44 * 49 * 45 50 * @return the panel with the version table 46 51 */ … … 57 62 * creates the panel which shows information about two different versions 58 63 * of the same {@see OsmPrimitive}. 59 * 64 * 60 65 * @return the panel 61 66 */ 67 protected JPanel createVersionComparePanel() { 68 tpViewers = new JTabbedPane(); 62 69 63 protected JPanel createVersionComparePanel() { 64 dataPane = new JTabbedPane(); 65 dataPane.add(new TagInfoViewer(model)); 66 dataPane.setTitleAt(0, tr("Tags")); 67 68 dataPane.add(new NodeListViewer(model)); 69 dataPane.setTitleAt(1, tr("Nodes")); 70 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")); 76 70 // create the viewers, but don't add them yet. 71 // see populate() 72 // 73 tagInfoViewer = new TagInfoViewer(model); 74 nodeListViewer = new NodeListViewer(model); 75 relationMemberListViewer = new RelationMemberListViewer(model); 76 coordinateInfoViewer = new CoordinateInfoViewer(model); 77 77 JPanel pnl = new JPanel(); 78 78 pnl.setLayout(new BorderLayout()); 79 pnl.add( dataPane, BorderLayout.CENTER);79 pnl.add(tpViewers, BorderLayout.CENTER); 80 80 return pnl; 81 81 } … … 122 122 /** 123 123 * populates the browser with the history of a specific {@see OsmPrimitive} 124 * 124 * 125 125 * @param history the history 126 126 */ 127 127 public void populate(History history) { 128 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 } 129 130 tpViewers.add(tagInfoViewer); 131 tpViewers.setTitleAt(0, tr("Tags")); 132 133 if (history.getEarliest().getType().equals(OsmPrimitiveType.NODE)) { 134 tpViewers.add(coordinateInfoViewer); 135 tpViewers.setTitleAt(1, tr("Coordinates")); 136 } else if (history.getEarliest().getType().equals(OsmPrimitiveType.WAY)) { 137 tpViewers.add(nodeListViewer); 138 tpViewers.setTitleAt(1, tr("Nodes")); 139 } else if (history.getEarliest().getType().equals(OsmPrimitiveType.RELATION)) { 140 tpViewers.add(relationMemberListViewer); 141 tpViewers.setTitleAt(2, tr("Members")); 146 142 } 143 revalidate(); 147 144 } 148 145 149 146 /** 150 147 * replies the {@see History} currently displayed by this browser 151 * 148 * 152 149 * @return the current history 153 150 */ -
trunk/src/org/openstreetmap/josm/gui/history/HistoryBrowserModel.java
r2242 r2243 62 62 private RelationMemberTableModel currentRelationMemberTableModel; 63 63 private RelationMemberTableModel referenceRelationMemberTableModel; 64 private CoordinateTableModel currentCoordinateTableModel;65 private CoordinateTableModel referenceCoordinateTableModel;66 64 67 65 public HistoryBrowserModel() { … … 73 71 currentRelationMemberTableModel = new RelationMemberTableModel(PointInTimeType.CURRENT_POINT_IN_TIME); 74 72 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);77 73 } 78 74 … … 136 132 currentRelationMemberTableModel.fireTableDataChanged(); 137 133 referenceRelationMemberTableModel.fireTableDataChanged(); 138 }139 140 protected void initCoordinateTableModels() {141 currentCoordinateTableModel.fireTableDataChanged();142 referenceCoordinateTableModel.fireTableDataChanged();143 134 } 144 135 … … 181 172 else if (pointInTimeType.equals(PointInTimeType.REFERENCE_POINT_IN_TIME)) 182 173 return referenceRelationMemberTableModel; 183 184 // should not happen185 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;195 174 196 175 // should not happen … … 213 192 initNodeListTabeModels(); 214 193 initMemberListTableModels(); 215 initCoordinateTableModels();216 194 setChanged(); 217 195 notifyObservers(); … … 232 210 initNodeListTabeModels(); 233 211 initMemberListTableModels(); 234 initCoordinateTableModels();235 212 setChanged(); 236 213 notifyObservers(); … … 610 587 } 611 588 } 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 @Override629 public int getRowCount() {630 if (current != null && current instanceof HistoryNode)631 currentCoor = ((HistoryNode)current).getCoordinate();632 else633 return 0;634 if (reference != null && reference instanceof HistoryNode)635 referenceCoor = ((HistoryNode)reference).getCoordinate();636 return 2;637 }638 639 @Override640 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 else647 return row == 0 ? referenceCoor.latToString(CoordinateFormat.getDefaultFormat())648 : referenceCoor.lonToString(CoordinateFormat.getDefaultFormat());649 }650 651 @Override652 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 }676 589 } -
trunk/src/org/openstreetmap/josm/gui/history/NodeListViewer.java
r1709 r2243 143 143 } 144 144 } 145 146 145 } -
trunk/src/org/openstreetmap/josm/gui/history/VersionInfoPanel.java
r2242 r2243 4 4 import static org.openstreetmap.josm.tools.I18n.tr; 5 5 6 import java.awt. BorderLayout;7 import java.awt. event.ActionEvent;8 import java.awt. event.MouseEvent;6 import java.awt.FlowLayout; 7 import java.awt.GridBagConstraints; 8 import java.awt.GridBagLayout; 9 9 import java.text.SimpleDateFormat; 10 10 import java.util.Observable; … … 16 16 import org.openstreetmap.josm.actions.AbstractInfoAction; 17 17 import org.openstreetmap.josm.data.osm.history.HistoryOsmPrimitive; 18 import org.openstreetmap.josm.tools. ImageProvider;18 import org.openstreetmap.josm.tools.UrlLabel; 19 19 20 20 /** 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{ … … 28 28 private HistoryBrowserModel model; 29 29 private JLabel lblInfo; 30 private UrlLabel lblUser; 31 private UrlLabel lblChangeset; 30 32 31 33 protected void build() { 32 setLayout(new BorderLayout()); 34 JPanel pnl1 = new JPanel(); 35 pnl1.setLayout(new FlowLayout(FlowLayout.LEFT)); 33 36 lblInfo = new JLabel(); 34 37 lblInfo.setHorizontalAlignment(JLabel.LEFT); 35 add(lblInfo, BorderLayout.CENTER); 38 pnl1.add(lblInfo); 39 40 JPanel pnl2 = new JPanel(); 41 pnl2.setLayout(new FlowLayout(FlowLayout.LEFT)); 42 lblUser = new UrlLabel(); 43 pnl2.add(new JLabel(tr("User"))); 44 pnl2.add(lblUser); 45 pnl2.add(new JLabel(tr("Changeset"))); 46 lblChangeset = new UrlLabel(); 47 pnl2.add(lblChangeset); 48 49 setLayout(new GridBagLayout()); 50 GridBagConstraints gc = new GridBagConstraints(); 51 gc.anchor = GridBagConstraints.NORTHWEST; 52 gc.fill = GridBagConstraints.HORIZONTAL; 53 gc.weightx = 1.0; 54 gc.weighty = 0.0; 55 add(pnl1, gc); 56 gc.gridy = 1; 57 add(pnl2, gc); 36 58 } 37 59 … … 46 68 if (primitive == null) 47 69 return ""; 48 String url = AbstractInfoAction.getBaseBrowseUrl() + "/changeset/" + primitive.getChangesetId();49 70 String text = tr( 50 "<html>Version <strong>{0}</strong> created on <strong>{1}</strong> by <strong>{2}</strong> in changeset <strong>{3}</strong></html>",71 "<html>Version <strong>{0}</strong> created on <strong>{1}</strong>", 51 72 Long.toString(primitive.getVersion()), 52 new SimpleDateFormat().format(primitive.getTimestamp()), 53 primitive.getUser().replace("<", "<").replace(">", ">"), 54 primitive.getChangesetId() 73 new SimpleDateFormat().format(primitive.getTimestamp()) 55 74 ); 56 75 return text; … … 65 84 /** 66 85 * constructor 67 * 86 * 68 87 * @param model the model (must not be null) 69 88 * @param pointInTimeType the point in time this panel visualizes (must not be null) … … 86 105 public void update(Observable o, Object arg) { 87 106 lblInfo.setText(getInfoText()); 107 108 String url = AbstractInfoAction.getBaseBrowseUrl() + "/changeset/" + getPrimitive().getChangesetId(); 109 lblChangeset.setUrl(url); 110 lblChangeset.setDescription(tr("{0}", getPrimitive().getChangesetId())); 111 112 url = AbstractInfoAction.getBaseUserUrl() + "/" + getPrimitive().getUser(); 113 lblUser.setUrl(url); 114 lblUser.setDescription(tr("{0}", getPrimitive().getUser())); 88 115 } 89 116 }
Note:
See TracChangeset
for help on using the changeset viewer.