Ignore:
Timestamp:
2011-11-21T22:16:25+01:00 (14 years ago)
Author:
jttt
Message:

Multikey action improvements (see #5515):

  • show text in status bar after shortcut is pressed
  • number layers from 1
  • do not allow Repeat for last layer if layer index conflicts with shortcut
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/MapStatus.java

    r3783 r4604  
    9595    }
    9696
    97     ImageLabel lonText = new ImageLabel("lon", tr("The geographic longitude at the mouse pointer."), 11);
    98     ImageLabel nameText = new ImageLabel("name", tr("The name of the object at the mouse pointer."), 20);
    99     JTextField helpText = new JTextField();
    100     ImageLabel latText = new ImageLabel("lat", tr("The geographic latitude at the mouse pointer."), 11);
    101     ImageLabel angleText = new ImageLabel("angle", tr("The angle between the previous and the current way segment."), 6);
    102     ImageLabel headingText = new ImageLabel("heading", tr("The (compass) heading of the line segment being drawn."), 6);
    103     ImageLabel distText = new ImageLabel("dist", tr("The length of the new way segment being drawn."), 10);
     97    final ImageLabel lonText = new ImageLabel("lon", tr("The geographic longitude at the mouse pointer."), 11);
     98    final ImageLabel nameText = new ImageLabel("name", tr("The name of the object at the mouse pointer."), 20);
     99    final JTextField helpText = new JTextField();
     100    final ImageLabel latText = new ImageLabel("lat", tr("The geographic latitude at the mouse pointer."), 11);
     101    final ImageLabel angleText = new ImageLabel("angle", tr("The angle between the previous and the current way segment."), 6);
     102    final ImageLabel headingText = new ImageLabel("heading", tr("The (compass) heading of the line segment being drawn."), 6);
     103    final ImageLabel distText = new ImageLabel("dist", tr("The length of the new way segment being drawn."), 10);
    104104
    105105    /**
     
    108108     */
    109109    public Thread thread;
     110
     111    private final List<StatusTextHistory> statusText = new ArrayList<StatusTextHistory>();
     112
     113    private static class StatusTextHistory {
     114        final Object id;
     115        final String text;
     116
     117        public StatusTextHistory(Object id, String text) {
     118            this.id = id;
     119            this.text = text;
     120        }
     121
     122        @Override
     123        public boolean equals(Object obj) {
     124            return obj instanceof StatusTextHistory && ((StatusTextHistory)obj).id == id;
     125        }
     126
     127        @Override
     128        public int hashCode() {
     129            return System.identityHashCode(id);
     130        }
     131    }
    110132
    111133    /**
     
    218240                                        final JLabel lbl = new JLabel(
    219241                                                "<html>"+tr("Middle click again to cycle through.<br>"+
    220                                                 "Hold CTRL to select directly from this list with the mouse.<hr>")+"</html>",
    221                                                 null,
    222                                                 JLabel.HORIZONTAL
    223                                         );
     242                                                        "Hold CTRL to select directly from this list with the mouse.<hr>")+"</html>",
     243                                                        null,
     244                                                        JLabel.HORIZONTAL
     245                                                );
    224246                                        lbl.setHorizontalAlignment(JLabel.LEFT);
    225247                                        c.add(lbl, GBC.eol().insets(2, 0, 2, 0));
     
    472494                    ImageProvider.get(OsmPrimitiveType.from(osm)),
    473495                    JLabel.HORIZONTAL
    474             ) {
     496                    ) {
    475497                // This is necessary so the label updates its colors when the
    476498                // selection is changed from the outside
     
    656678
    657679    public void setHelpText(String t) {
    658         helpText.setText(t);
    659         helpText.setToolTipText(t);
     680        setHelpText(null, t);
     681    }
     682    public void setHelpText(Object id, String text)  {
     683
     684        StatusTextHistory entry = new StatusTextHistory(id, text);
     685
     686        statusText.remove(entry);
     687        statusText.add(entry);
     688
     689        helpText.setText(text);
     690        helpText.setToolTipText(text);
     691    }
     692    public void resetHelpText(Object id) {
     693        if (statusText.isEmpty())
     694            return;
     695
     696        StatusTextHistory entry = new StatusTextHistory(id, null);
     697        if (statusText.get(statusText.size() - 1).equals(entry)) {
     698            if (statusText.size() == 1) {
     699                setHelpText("");
     700            } else {
     701                StatusTextHistory history = statusText.get(statusText.size() - 2);
     702                setHelpText(history.id, history.text);
     703            }
     704        }
     705        statusText.remove(entry);
    660706    }
    661707    public void setAngle(double a) {
Note: See TracChangeset for help on using the changeset viewer.