Ignore:
Timestamp:
2009-10-04T12:07:16+02:00 (15 years ago)
Author:
Gubaer
Message:

fixed #3650: Double-click on items in history dialog should open history
fixed #3649: History dialog does not show moved nodes
fixed #3383: changeset tags in history dialog (partial fix, there's now a link to the server page for browsing changesets)

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  
    1313import javax.swing.JTable;
    1414
     15import org.openstreetmap.josm.data.osm.OsmPrimitiveType;
    1516import org.openstreetmap.josm.data.osm.history.History;
    16 import org.openstreetmap.josm.data.osm.OsmPrimitiveType;
    1717
    1818/**
    1919 * HistoryBrowser is an UI component which displays history information about an {@see OsmPrimitive}.
    20  *
     20 * 
    2121 *
    2222 */
     
    2525    /** the model */
    2626    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
    2833
    2934    /**
    3035     * embedds table in a {@see JScrollPane}
    31      *
     36     * 
    3237     * @param table the table
    3338     * @return the {@see JScrollPane} with the embedded table
     
    4247    /**
    4348     * creates the table which shows the list of versions
    44      *
     49     * 
    4550     * @return  the panel with the version table
    4651     */
     
    5762     * creates the panel which shows information about two different versions
    5863     * of the same {@see OsmPrimitive}.
    59      *
     64     * 
    6065     * @return the panel
    6166     */
     67    protected JPanel createVersionComparePanel() {
     68        tpViewers = new JTabbedPane();
    6269
    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);
    7777        JPanel pnl = new JPanel();
    7878        pnl.setLayout(new BorderLayout());
    79         pnl.add(dataPane, BorderLayout.CENTER);
     79        pnl.add(tpViewers, BorderLayout.CENTER);
    8080        return pnl;
    8181    }
     
    122122    /**
    123123     * populates the browser with the history of a specific {@see OsmPrimitive}
    124      *
     124     * 
    125125     * @param history the history
    126126     */
    127127    public void populate(History history) {
    128128        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"));
    146142        }
     143        revalidate();
    147144    }
    148145
    149146    /**
    150147     * replies the {@see History} currently displayed by this browser
    151      *
     148     * 
    152149     * @return the current history
    153150     */
  • trunk/src/org/openstreetmap/josm/gui/history/HistoryBrowserModel.java

    r2242 r2243  
    6262    private RelationMemberTableModel currentRelationMemberTableModel;
    6363    private RelationMemberTableModel referenceRelationMemberTableModel;
    64     private CoordinateTableModel currentCoordinateTableModel;
    65     private CoordinateTableModel referenceCoordinateTableModel;
    6664
    6765    public HistoryBrowserModel() {
     
    7371        currentRelationMemberTableModel = new RelationMemberTableModel(PointInTimeType.CURRENT_POINT_IN_TIME);
    7472        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);
    7773    }
    7874
     
    136132        currentRelationMemberTableModel.fireTableDataChanged();
    137133        referenceRelationMemberTableModel.fireTableDataChanged();
    138     }
    139 
    140     protected void initCoordinateTableModels() {
    141         currentCoordinateTableModel.fireTableDataChanged();
    142         referenceCoordinateTableModel.fireTableDataChanged();
    143134    }
    144135
     
    181172        else if (pointInTimeType.equals(PointInTimeType.REFERENCE_POINT_IN_TIME))
    182173            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;
    195174
    196175        // should not happen
     
    213192        initNodeListTabeModels();
    214193        initMemberListTableModels();
    215         initCoordinateTableModels();
    216194        setChanged();
    217195        notifyObservers();
     
    232210        initNodeListTabeModels();
    233211        initMemberListTableModels();
    234         initCoordinateTableModels();
    235212        setChanged();
    236213        notifyObservers();
     
    610587        }
    611588    }
    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     }
    676589}
  • trunk/src/org/openstreetmap/josm/gui/history/NodeListViewer.java

    r1709 r2243  
    143143        }
    144144    }
    145 
    146145}
  • trunk/src/org/openstreetmap/josm/gui/history/VersionInfoPanel.java

    r2242 r2243  
    44import static org.openstreetmap.josm.tools.I18n.tr;
    55
    6 import java.awt.BorderLayout;
    7 import java.awt.event.ActionEvent;
    8 import java.awt.event.MouseEvent;
     6import java.awt.FlowLayout;
     7import java.awt.GridBagConstraints;
     8import java.awt.GridBagLayout;
    99import java.text.SimpleDateFormat;
    1010import java.util.Observable;
     
    1616import org.openstreetmap.josm.actions.AbstractInfoAction;
    1717import org.openstreetmap.josm.data.osm.history.HistoryOsmPrimitive;
    18 import org.openstreetmap.josm.tools.ImageProvider;
     18import org.openstreetmap.josm.tools.UrlLabel;
    1919
    2020/**
    2121 * VersionInfoPanel is an UI component which displays the basic properties of a version
    2222 * of a {@see OsmPrimitive}.
    23  *
     23 * 
    2424 */
    2525public class VersionInfoPanel extends JPanel implements Observer{
     
    2828    private HistoryBrowserModel model;
    2929    private JLabel lblInfo;
     30    private UrlLabel lblUser;
     31    private UrlLabel lblChangeset;
    3032
    3133    protected void build() {
    32         setLayout(new BorderLayout());
     34        JPanel pnl1 = new JPanel();
     35        pnl1.setLayout(new FlowLayout(FlowLayout.LEFT));
    3336        lblInfo = new JLabel();
    3437        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);
    3658    }
    3759
     
    4668        if (primitive == null)
    4769            return "";
    48         String url = AbstractInfoAction.getBaseBrowseUrl() + "/changeset/" + primitive.getChangesetId();
    4970        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>",
    5172                Long.toString(primitive.getVersion()),
    52                 new SimpleDateFormat().format(primitive.getTimestamp()),
    53                 primitive.getUser().replace("<", "&lt;").replace(">", "&gt;"),
    54                 primitive.getChangesetId()
     73                new SimpleDateFormat().format(primitive.getTimestamp())
    5574        );
    5675        return text;
     
    6584    /**
    6685     * constructor
    67      *
     86     * 
    6887     * @param model  the model (must not be null)
    6988     * @param pointInTimeType the point in time this panel visualizes (must not be null)
     
    86105    public void update(Observable o, Object arg) {
    87106        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()));
    88115    }
    89116}
Note: See TracChangeset for help on using the changeset viewer.