Changeset 5735 in josm


Ignore:
Timestamp:
2013-02-20T21:34:12+01:00 (12 years ago)
Author:
Don-vip
Message:

fix #8116 (forgot the other cases)

Location:
trunk/src/org/openstreetmap/josm
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/actions/mapmode/SelectAction.java

    r5734 r5735  
    1212import java.awt.Toolkit;
    1313import java.awt.event.AWTEventListener;
     14import java.awt.event.ActionEvent;
     15import java.awt.event.ActionListener;
    1416import java.awt.event.InputEvent;
    1517import java.awt.event.KeyEvent;
     
    5052import org.openstreetmap.josm.gui.layer.Layer;
    5153import org.openstreetmap.josm.gui.layer.OsmDataLayer;
     54import org.openstreetmap.josm.gui.util.GuiHelper;
    5255import org.openstreetmap.josm.tools.ImageProvider;
    5356import org.openstreetmap.josm.tools.Pair;
     
    440443            selectPrims(NavigatableComponent.asColl(toSelect), false, false);
    441444            useLastMoveCommandIfPossible();
     445            // Schedule a timer to update status line "initialMoveDelay+1" ms in the future
     446            GuiHelper.scheduleTimer(initialMoveDelay+1, new ActionListener() {
     447                public void actionPerformed(ActionEvent evt) {
     448                    updateStatusLine();
     449                }
     450            }, false);
    442451            break;
    443452        case select:
     
    853862    @Override
    854863    public String getModeHelpText() {
    855         if (mode == Mode.select && mouseDownButton == MouseEvent.BUTTON1 && mouseReleaseTime < mouseDownTime)
    856             return tr("Release the mouse button to select the objects in the rectangle.");
    857         else if (mode == Mode.move) {
    858             final boolean canMerge = getCurrentDataSet()!=null && !getCurrentDataSet().getSelectedNodes().isEmpty();
    859             final String mergeHelp = canMerge ? (" " + tr("Ctrl to merge with nearest node.")) : "";
    860             return tr("Release the mouse button to stop moving.") + mergeHelp;
    861         } else if (mode == Mode.rotate)
    862             return tr("Release the mouse button to stop rotating.");
    863         else if (mode == Mode.scale)
    864             return tr("Release the mouse button to stop scaling.");
    865         else
    866             return tr("Move objects by dragging; Shift to add to selection (Ctrl to toggle); Shift-Ctrl to rotate selected; Alt-Ctrl to scale selected; or change selection");
     864        if (mouseDownButton == MouseEvent.BUTTON1 && mouseReleaseTime < mouseDownTime) {
     865            if (mode == Mode.select)
     866                return tr("Release the mouse button to select the objects in the rectangle.");
     867            else if (mode == Mode.move && (System.currentTimeMillis() - mouseDownTime >= initialMoveDelay)) {
     868                final boolean canMerge = getCurrentDataSet()!=null && !getCurrentDataSet().getSelectedNodes().isEmpty();
     869                final String mergeHelp = canMerge ? (" " + tr("Ctrl to merge with nearest node.")) : "";
     870                return tr("Release the mouse button to stop moving.") + mergeHelp;
     871            } else if (mode == Mode.rotate)
     872                return tr("Release the mouse button to stop rotating.");
     873            else if (mode == Mode.scale)
     874                return tr("Release the mouse button to stop scaling.");
     875        }
     876        return tr("Move objects by dragging; Shift to add to selection (Ctrl to toggle); Shift-Ctrl to rotate selected; Alt-Ctrl to scale selected; or change selection");
    867877    }
    868878
  • trunk/src/org/openstreetmap/josm/gui/util/GuiHelper.java

    r5493 r5735  
    1111import java.awt.Toolkit;
    1212import java.awt.Window;
     13import java.awt.event.ActionEvent;
     14import java.awt.event.ActionListener;
    1315import java.awt.event.HierarchyEvent;
    1416import java.awt.event.HierarchyListener;
     
    2123import javax.swing.JOptionPane;
    2224import javax.swing.SwingUtilities;
     25import javax.swing.Timer;
    2326
    2427import org.openstreetmap.josm.Main;
     
    138141        return pane;
    139142    }
     143   
     144    /**
     145     * Schedules a new Timer to be run in the future (once or several times).
     146     * @param initialDelay milliseconds for the initial and between-event delay if repeatable
     147     * @param actionListener an initial listener; can be null
     148     * @param repeats specify false to make the timer stop after sending its first action event
     149     * @return The (started) timer.
     150     * @since 5735
     151     */
     152    public static final Timer scheduleTimer(int initialDelay, ActionListener actionListener, boolean repeats) {
     153        Timer timer = new Timer(initialDelay, actionListener);
     154        timer.setRepeats(repeats);
     155        timer.start();
     156        return timer;
     157    }
    140158}
Note: See TracChangeset for help on using the changeset viewer.