Changeset 1842 in josm for trunk/src/org


Ignore:
Timestamp:
2009-07-25T18:17:36+02:00 (15 years ago)
Author:
Gubaer
Message:

removed global static variable
replaced usage of JOptionPane by OptionPaneUtil

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

Legend:

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

    r1838 r1842  
    5050import org.openstreetmap.josm.gui.MapFrame;
    5151import org.openstreetmap.josm.gui.MapView;
     52import org.openstreetmap.josm.gui.OptionPaneUtil;
    5253import org.openstreetmap.josm.gui.layer.Layer;
    5354import org.openstreetmap.josm.gui.layer.MapViewPaintable;
     
    338339            n = new Node(Main.map.mapView.getLatLon(e.getX(), e.getY()));
    339340            if (n.getCoor().isOutSideWorld()) {
    340                 JOptionPane.showMessageDialog(Main.parent,
    341                         tr("Cannot add a node outside of the world."));
     341                OptionPaneUtil.showMessageDialog(
     342                        Main.parent,
     343                        tr("Cannot add a node outside of the world."),
     344                        tr("Warning"),
     345                        JOptionPane.WARNING_MESSAGE
     346                );
    342347                return;
    343348            }
  • trunk/src/org/openstreetmap/josm/actions/mapmode/SelectAction.java

    r1814 r1842  
    4545import org.openstreetmap.josm.gui.layer.OsmDataLayer;
    4646import org.openstreetmap.josm.tools.ImageProvider;
     47import org.openstreetmap.josm.tools.PlatformHookOsx;
    4748import org.openstreetmap.josm.tools.Shortcut;
    4849
     
    5859 */
    5960public class SelectAction extends MapMode implements SelectionEnded {
    60     public static boolean needMouseMove = false;
     61
     62    /**
     63     * Replies true if we are currently running on OSX
     64     *
     65     * @return true if we are currently running on OSX
     66     */
     67    public static boolean isPlatformOsx() {
     68        return Main.platform != null
     69        && Main.platform instanceof PlatformHookOsx;
     70    }
     71
    6172    enum Mode { move, rotate, select }
    6273    private Mode mode = null;
     
    254265    }
    255266
    256     /**
    257      * Mac OSX simulates with  ctrl + mouse 1  the second mouse button hence no dragging events get fired.
    258      *
    259      */
     267
    260268    @Override public void mouseMoved(MouseEvent e) {
    261         if (needMouseMove && mode == Mode.rotate) {
     269        // Mac OSX simulates with  ctrl + mouse 1  the second mouse button hence no dragging events get fired.
     270        //
     271        if (isPlatformOsx() && mode == Mode.rotate) {
    262272            mouseDragged(e);
    263273        }
  • trunk/src/org/openstreetmap/josm/tools/PlatformHookOsx.java

    r1643 r1842  
    1414
    1515/**
    16   * see PlatformHook.java
    17   */
     16 * see PlatformHook.java
     17 */
    1818public class PlatformHookOsx extends PlatformHookUnixoid implements PlatformHook, InvocationHandler {
    1919    private static PlatformHookOsx ivhandler = new PlatformHookOsx();
     20    @Override
    2021    public void preStartupHook(){
    2122        // This will merge our MenuBar into the system menu.
     
    2526        System.setProperty("apple.laf.useScreenMenuBar", "true");
    2627    }
     28    @Override
    2729    public void startupHook() {
    2830        // Here we register callbacks for the menu entries in the system menu
     
    4244            System.out.println("Failed to register with OSX: " + ex);
    4345        }
    44 
    45         // Ctrl + mouse 1 is suppressing mouseDragged events
    46         SelectAction.needMouseMove = true;
    4746    }
    4847    public Object invoke (Object proxy, Method method, Object[] args) throws Throwable {
     
    5554        } else if (method.getName().equals("handlePreferences")) {
    5655            Main.main.menu.preferences.actionPerformed(null);
    57         } else {
     56        } else
    5857            return null;
    59         }
    6058        if (args[0] != null) {
    6159            try {
     
    6765        return null;
    6866    }
     67    @Override
    6968    public void openUrl(String url) throws IOException {
    7069        // Ain't that KISS?
    7170        Runtime.getRuntime().exec("open " + url);
    7271    }
     72    @Override
    7373    public void initShortcutGroups() {
    7474        // Everything but Shortcut.GROUPS_DEFAULT+Shortcut.GROUP_MENU is guesswork.
     
    9797        Main.pref.put("shortcut.groups."+(Shortcut.GROUPS_ALT2+Shortcut.GROUP_MNEMONIC),   Integer.toString(KeyEvent.ALT_DOWN_MASK));
    9898    }
     99    @Override
    99100    public void initSystemShortcuts() {
    100101        // Yeah, it's a long, long list. And people always complain that OSX has no shortcuts.
     
    235236
    236237    }
     238    @Override
    237239    public String makeTooltip(String name, Shortcut sc) {
    238240        String lafid = UIManager.getLookAndFeel().getID();
     
    243245        }
    244246        String result = "";
    245         if (canHtml) result += "<html>";
     247        if (canHtml) {
     248            result += "<html>";
     249        }
    246250        result += name;
    247251        if (sc != null && sc.getKeyText().length() != 0) {
    248252            result += " ";
    249             if (canHtml) result += "<font size='-2'>";
     253            if (canHtml) {
     254                result += "<font size='-2'>";
     255            }
    250256            result += "("+sc.getKeyText()+")";
    251             if (canHtml) result += "</font>";
    252         }
    253         if (canHtml) result += "&nbsp;</html>";
     257            if (canHtml) {
     258                result += "</font>";
     259            }
     260        }
     261        if (canHtml) {
     262            result += "&nbsp;</html>";
     263        }
    254264        return result;
    255265    }
Note: See TracChangeset for help on using the changeset viewer.