Ignore:
Timestamp:
2017-08-29T00:16:25+02:00 (7 years ago)
Author:
Don-vip
Message:

see #15182 - refactor PlatformHookOsx so that all GUI actions are performed in MainApplication and only macOS-specific stuff remains in platform hook

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/tools/PlatformHookOsx.java

    r12670 r12695  
    1717import java.util.Collections;
    1818import java.util.List;
    19 import java.util.concurrent.Executors;
     19import java.util.Objects;
    2020
    2121import javax.swing.UIManager;
    2222
    2323import org.openstreetmap.josm.Main;
    24 import org.openstreetmap.josm.actions.OpenFileAction.OpenFileTask;
    25 import org.openstreetmap.josm.gui.MainApplication;
    26 import org.openstreetmap.josm.io.OsmTransferException;
    27 import org.xml.sax.SAXException;
    2824
    2925/**
     
    3632
    3733    private String oSBuildNumber;
     34
     35    private NativeOsCallback osCallback;
    3836
    3937    @Override
     
    138136    }
    139137
     138    @Override
     139    public void setNativeOsCallback(NativeOsCallback callback) {
     140        osCallback = Objects.requireNonNull(callback);
     141    }
     142
    140143    @SuppressWarnings("unchecked")
    141144    @Override
     
    150153                    Object oFiles = args[0].getClass().getMethod("getFiles").invoke(args[0]);
    151154                    if (oFiles instanceof List) {
    152                         Executors.newSingleThreadExecutor(Utils.newThreadFactory("openFiles-%d", Thread.NORM_PRIORITY)).submit(
    153                                 new OpenFileTask((List<File>) oFiles, null) {
    154                             @Override
    155                             protected void realRun() throws SAXException, IOException, OsmTransferException {
    156                                 // Wait for JOSM startup is advanced enough to load a file
    157                                 while (Main.parent == null || !Main.parent.isVisible()) {
    158                                     try {
    159                                         Thread.sleep(25);
    160                                     } catch (InterruptedException e) {
    161                                         Logging.warn(e);
    162                                         Thread.currentThread().interrupt();
    163                                     }
    164                                 }
    165                                 super.realRun();
    166                             }
    167                         });
     155                        osCallback.openFiles((List<File>) oFiles);
    168156                    }
    169157                } catch (ReflectiveOperationException | SecurityException | IllegalArgumentException ex) {
     
    173161            break;
    174162        case "handleQuitRequestWith":
    175             boolean closed = MainApplication.exitJosm(false, 0, null);
     163            boolean closed = osCallback.handleQuitRequest();
    176164            if (args[1] != null) {
    177165                try {
     
    185173            break;
    186174        case "handleAbout":
    187             MainApplication.getMenu().about.actionPerformed(null);
     175            osCallback.handleAbout();
    188176            break;
    189177        case "handlePreferences":
    190             MainApplication.getMenu().preferences.actionPerformed(null);
     178            osCallback.handlePreferences();
    191179            break;
    192180        default:
Note: See TracChangeset for help on using the changeset viewer.