Changeset 2243 in josm for trunk


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
Files:
1 added
3 deleted
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/osm/history/HistoryNode.java

    r2242 r2243  
    44import java.util.Date;
    55
     6import org.openstreetmap.josm.data.coor.LatLon;
    67import org.openstreetmap.josm.data.osm.OsmPrimitiveType;
    7 import org.openstreetmap.josm.data.coor.LatLon;
    88
    99
     
    1414 */
    1515public class HistoryNode extends HistoryOsmPrimitive {
    16     private LatLon coor;
    17     public HistoryNode(long id, long version, boolean visible, String user, long uid, long changesetId, Date timestamp,
    18     double lat, double lon) {
     16    /** the coordinates */
     17
     18    private LatLon coords;
     19
     20    public HistoryNode(long id, long version, boolean visible, String user, long uid, long changesetId, Date timestamp, LatLon coords) {
    1921        super(id, version, visible, user, uid, changesetId, timestamp);
    20         coor = new LatLon(lat, lon);
     22        setCoords(coords);
    2123    }
    2224
     
    2628    }
    2729
    28     public LatLon getCoordinate() {
    29         return coor;
     30    public LatLon getCoords() {
     31        return coords;
     32    }
     33
     34    public void setCoords(LatLon coords) {
     35        this.coords = coords;
    3036    }
    3137}
  • trunk/src/org/openstreetmap/josm/gui/dialogs/HistoryDialog.java

    r2239 r2243  
    110110            }
    111111        });
     112        historyTable.addMouseListener(new ShowHistoryMouseAdapter());
    112113
    113114        JScrollPane pane = new JScrollPane(historyTable);
     
    138139        model.refresh();
    139140    }
    140 
    141     /**
    142      * shows the {@see HistoryBrowserDialog} for a given {@see History}
    143      *
    144      * @param h the history. Must not be null.
    145      * @exception IllegalArgumentException thrown, if h is null
    146      */
    147     protected void showHistory(History h) throws IllegalArgumentException {
    148         if (h == null)
    149             throw new IllegalArgumentException(tr("Parameter ''{0}'' must not be null.", "h"));
    150         if (HistoryBrowserDialogManager.getInstance().existsDialog(h.getId())) {
    151             HistoryBrowserDialogManager.getInstance().show(h.getId());
    152         } else {
    153             HistoryBrowserDialog dialog = new HistoryBrowserDialog(h);
    154             HistoryBrowserDialogManager.getInstance().show(h.getId(), dialog);
    155         }
    156     }
    157 
    158141
    159142    /**
     
    233216            }
    234217            return ret;
     218        }
     219
     220        public OsmPrimitive getPrimitive(int row) {
     221            return data.get(row);
    235222        }
    236223    }
     
    286273    }
    287274
     275    class ShowHistoryMouseAdapter extends MouseAdapter {
     276        @Override
     277        public void mouseClicked(MouseEvent e) {
     278            if (e.getClickCount() == 2 && e.getButton() == MouseEvent.BUTTON1) {
     279                int row = historyTable.rowAtPoint(e.getPoint());
     280                new ShowHistoryAction().showHistory(Collections.singletonList(model.getPrimitive(row)));
     281            }
     282        }
     283    }
     284
    288285    /**
    289286     * The action for showing history information of the current history item.
     
    307304        }
    308305
    309         public void actionPerformed(ActionEvent e) {
    310             int [] rows = historyTable.getSelectedRows();
    311             if (rows == null || rows.length == 0) return;
    312 
    313             final List<OsmPrimitive> selectedItems = model.getPrimitives(rows);
    314             List<OsmPrimitive> toLoad = filterPrimitivesWithUnloadedHistory(selectedItems);
     306        /**
     307         * shows the {@see HistoryBrowserDialog} for a given {@see History}
     308         *
     309         * @param h the history. Must not be null.
     310         * @exception IllegalArgumentException thrown, if h is null
     311         */
     312        protected void showHistory(History h) throws IllegalArgumentException {
     313            if (h == null)
     314                throw new IllegalArgumentException(tr("Parameter ''{0}'' must not be null.", "h"));
     315            if (HistoryBrowserDialogManager.getInstance().existsDialog(h.getId())) {
     316                HistoryBrowserDialogManager.getInstance().show(h.getId());
     317            } else {
     318                HistoryBrowserDialog dialog = new HistoryBrowserDialog(h);
     319                HistoryBrowserDialogManager.getInstance().show(h.getId(), dialog);
     320            }
     321        }
     322
     323        public void showHistory(final List<OsmPrimitive> primitives) {
     324            List<OsmPrimitive> toLoad = filterPrimitivesWithUnloadedHistory(primitives);
    315325            if (!toLoad.isEmpty()) {
    316326                HistoryLoadTask task = new HistoryLoadTask();
    317                 task.add(selectedItems);
     327                task.add(primitives);
    318328                Main.worker.submit(task);
    319329            }
     
    321331            Runnable r = new Runnable() {
    322332                public void run() {
    323                     for (OsmPrimitive p : selectedItems) {
     333                    for (OsmPrimitive p : primitives) {
    324334                        History h = HistoryDataSet.getInstance().getHistory(p.getId());
    325335                        if (h == null) {
     
    333343        }
    334344
     345        public void actionPerformed(ActionEvent e) {
     346            int [] rows = historyTable.getSelectedRows();
     347            if (rows == null || rows.length == 0) return;
     348            showHistory(model.getPrimitives(rows));
     349        }
     350
    335351        protected void updateEnabledState() {
    336352            setEnabled(historyTable.getSelectedRowCount() > 0);
  • trunk/src/org/openstreetmap/josm/gui/dialogs/SelectionListDialog.java

    r2224 r2243  
    138138        });
    139139
    140         buttonPanel.add(new SideButton(marktr("Reload"), "refresh", "SelectionList", tr("Refresh the selection list."),
    141                 new ActionListener() {
    142             public void actionPerformed(ActionEvent e) {
    143                 selectionChanged(Main.main.getCurrentDataSet().getSelected());
    144             }
    145         }));
    146 
    147140        searchButton = new SideButton(marktr("Search"), "search", "SelectionList", tr("Search for objects."),
    148141                Main.main.menu.search);
  • 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}
  • trunk/src/org/openstreetmap/josm/io/OsmHistoryReader.java

    r2242 r2243  
    1212import javax.xml.parsers.SAXParserFactory;
    1313
     14import org.openstreetmap.josm.data.coor.LatLon;
    1415import org.openstreetmap.josm.data.osm.OsmPrimitiveType;
    1516import org.openstreetmap.josm.data.osm.history.HistoryDataSet;
     
    8081        }
    8182
    82         protected long getAttributeLong(Attributes attr, String name, long defaultValue) throws SAXException{
    83             String v = attr.getValue(name);
    84             if (v == null) {
    85                 return defaultValue;
    86             }
    87             Long l = 0l;
    88             try {
    89                 l = Long.parseLong(v);
    90             } catch(NumberFormatException e) {
    91                 throwException(tr("Illegal value for mandatory attribute ''{0}'' of type long. Got ''{1}''.", name, v));
    92             }
    93             if (l < 0) {
    94                 throwException(tr("Illegal value for mandatory attribute ''{0}'' of type long (>=0). Got ''{1}''.", name, v));
    95             }
    96             return l;
    97         }
    98 
    99         protected int getMandatoryAttributeInt(Attributes attr, String name) throws SAXException{
    100             String v = attr.getValue(name);
    101             if (v == null) {
    102                 throwException(tr("Missing mandatory attribute ''{0}''.", name));
    103             }
    104             Integer i = 0;
    105             try {
    106                 i = Integer.parseInt(v);
    107             } catch(NumberFormatException e) {
    108                 throwException(tr("Illegal value for mandatory attribute ''{0}'' of type int. Got ''{1}''.", name, v));
    109             }
    110             if (i < 0) {
    111                 throwException(tr("Illegal value for mandatory attribute ''{0}'' of type int (>=0). Got ''{1}''.", name, v));
    112             }
    113             return i;
    114         }
    115 
    116         protected double getMandatoryAttributeDouble(Attributes attr, String name) throws SAXException{
    117             String v = attr.getValue(name);
    118             if (v == null) {
    119                 throwException(tr("Missing mandatory attribute ''{0}''.", name));
    120             }
    121             double d = 0.0;
     83        protected Double getMandatoryAttributeDouble(Attributes attr, String name) throws SAXException{
     84            String v = attr.getValue(name);
     85            if (v == null) {
     86                throwException(tr("Missing mandatory attribute ''{0}''.", name));
     87            }
     88            double d = 0;
    12289            try {
    12390                d = Double.parseDouble(v);
     
    12592                throwException(tr("Illegal value for mandatory attribute ''{0}'' of type double. Got ''{1}''.", name, v));
    12693            }
     94            if (d < 0) {
     95                throwException(tr("Illegal value for mandatory attribute ''{0}'' of type double (>=0). Got ''{1}''.", name, v));
     96            }
    12797            return d;
    12898        }
     
    133103                throwException(tr("Missing mandatory attribute ''{0}''.", name));
    134104            }
    135             return v;
    136         }
    137 
    138         protected String getAttributeString(Attributes attr, String name, String defaultValue) {
    139             String v = attr.getValue(name);
    140             if (v == null)
    141                 v = defaultValue;
    142105            return v;
    143106        }
     
    157120        protected  HistoryOsmPrimitive createPrimitive(Attributes atts, OsmPrimitiveType type) throws SAXException {
    158121            long id = getMandatoryAttributeLong(atts,"id");
    159             long version = getMandatoryAttributeLong(atts, "version");
    160             long changesetId = getMandatoryAttributeLong(atts, "changeset");
    161             boolean visible = getMandatoryAttributeBoolean(atts, "visible");
    162             long uid = getAttributeLong(atts, "uid", -1);
    163             String user = getAttributeString(atts, "user", tr("<anonymous>"));
     122            long version = getMandatoryAttributeLong(atts,"version");
     123            long changesetId = getMandatoryAttributeLong(atts,"changeset");
     124            boolean visible= getMandatoryAttributeBoolean(atts, "visible");
     125            long uid = getMandatoryAttributeLong(atts, "uid");
     126            String user = getMandatoryAttributeString(atts, "user");
    164127            String v = getMandatoryAttributeString(atts, "timestamp");
    165128            Date timestamp = DateUtils.fromString(v);
     
    169132                double lon = getMandatoryAttributeDouble(atts, "lon");
    170133                primitive = new HistoryNode(
    171                         id,version,visible,user,uid,changesetId,timestamp,lat,lon
     134                        id,version,visible,user,uid,changesetId,timestamp, new LatLon(lat,lon)
    172135                );
     136
    173137            } else if (type.equals(OsmPrimitiveType.WAY)) {
    174138                primitive = new HistoryWay(
  • trunk/src/org/openstreetmap/josm/tools/UrlLabel.java

    r1169 r2243  
    1212public class UrlLabel extends JEditorPane implements HyperlinkListener {
    1313
    14     private final String url;
     14    private String url = "";
     15    private String description = "";
     16
     17    public UrlLabel() {
     18        addHyperlinkListener(this);
     19        setEditable(false);
     20        setOpaque(false);
     21    }
    1522
    1623    public UrlLabel(String url) {
     
    1926
    2027    public UrlLabel(String url, String description) {
    21         this.url = url;
     28        this();
     29        setUrl(url);
     30        setDescription(description);
     31        refresh();
     32    }
     33
     34    protected void refresh() {
    2235        setContentType("text/html");
    2336        setText("<html><a href=\""+url+"\">"+description+"</a></html>");
    2437        setToolTipText(url);
    25         setEditable(false);
    26         setOpaque(false);
    27         addHyperlinkListener(this);
    2838    }
    2939
     
    3343        }
    3444    }
     45
     46    public void setUrl(String url) {
     47        this.url = url == null ? "" : url;
     48        refresh();
     49    }
     50
     51    public void setDescription(String description) {
     52        this.description = description == null? "" : description;
     53        refresh();
     54    }
    3555}
Note: See TracChangeset for help on using the changeset viewer.