Changeset 10625 in josm for trunk/src/org/openstreetmap


Ignore:
Timestamp:
2016-07-24T13:42:32+02:00 (8 years ago)
Author:
Don-vip
Message:

see #11390 - Java 8: use more lambdas / method references

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

Legend:

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

    r10616 r10625  
    675675    }
    676676
    677     private final transient AWTEventListener awtListener = new AWTEventListener() {
    678          @Override
    679          public void eventDispatched(AWTEvent event) {
    680             if (event instanceof InputEvent &&
    681                     ((InputEvent) event).getComponent() == mv) {
    682                 synchronized (collector) {
    683                     int modifiers = ((InputEvent) event).getModifiersEx();
    684                     Point mousePos = null;
    685                     if (event instanceof MouseEvent) {
    686                         mousePos = ((MouseEvent) event).getPoint();
    687                     }
    688                     collector.updateMousePosition(mousePos, modifiers);
    689                 }
    690             }
    691         }
    692     };
     677    private final transient AWTEventListener awtListener;
    693678
    694679    private final transient MouseMotionListener mouseMotionListener = new MouseMotionListener() {
     
    719704
    720705    private void registerListeners() {
    721         // Listen to keyboard/mouse events for pressing/releasing alt key and
    722         // inform the collector.
     706        // Listen to keyboard/mouse events for pressing/releasing alt key and inform the collector.
    723707        try {
    724708            Toolkit.getDefaultToolkit().addAWTEventListener(awtListener,
    725709                    AWTEvent.KEY_EVENT_MASK | AWTEvent.MOUSE_EVENT_MASK | AWTEvent.MOUSE_MOTION_EVENT_MASK);
    726710        } catch (SecurityException ex) {
     711            Main.trace(ex);
    727712            mv.addMouseMotionListener(mouseMotionListener);
    728713            mv.addKeyListener(keyAdapter);
     
    735720        } catch (SecurityException e) {
    736721            // Don't care, awtListener probably wasn't registered anyway
    737             if (Main.isTraceEnabled()) {
    738                 Main.trace(e.getMessage());
    739             }
     722            Main.trace(e);
    740723        }
    741724        mv.removeMouseMotionListener(mouseMotionListener);
     
    826809        this.mv = mapFrame.mapView;
    827810        this.collector = new Collector(mapFrame);
     811        this.awtListener = event -> {
     812            if (event instanceof InputEvent &&
     813                    ((InputEvent) event).getComponent() == mv) {
     814                synchronized (collector) {
     815                    int modifiers = ((InputEvent) event).getModifiersEx();
     816                    Point mousePos = null;
     817                    if (event instanceof MouseEvent) {
     818                        mousePos = ((MouseEvent) event).getPoint();
     819                    }
     820                    collector.updateMousePosition(mousePos, modifiers);
     821                }
     822            }
     823        };
    828824
    829825        // Context menu of status bar
  • trunk/src/org/openstreetmap/josm/tools/I18n.java

    r10616 r10625  
    737737
    738738    public static TranslationAdapter getTranslationAdapter() {
    739         return (text, objects) -> I18n.tr(text, objects);
     739        return I18n::tr;
    740740    }
    741741
Note: See TracChangeset for help on using the changeset viewer.