Search in sources :

Example 16 with Config

use of com.github.mob41.osumer.Config in project osumer by mob41.

the class Main method runUi.

private static void runUi(Configuration config, String[] args, ArgParser ap, IDaemon d) {
    IUI ui = null;
    try {
        // Contact the ui via RMI
        ui = (IUI) Naming.lookup("rmi://localhost:46727/ui");
    } catch (Exception e) {
    }
    if (ui == null) {
        try {
            Runtime.getRuntime().exec("\"" + OsumerNative.getProgramFiles() + "\\osumer2\\osumer-ui.exe\"");
        } catch (IOException e) {
            e.printStackTrace();
            DumpManager.addDump(new DebugDump(null, "Check if \"ui\" is null", "Execute osumer-ui.exe", "Initialize \"c\" as 0", "Could not start UI. Terminating", false, e));
            DumpManager.forceMetricsReport();
            JOptionPane.showMessageDialog(null, "Could not start UI. For more details, check dump. Terminating:\n" + e, "osumer launcher Error", JOptionPane.ERROR_MESSAGE);
            System.exit(-1);
            return;
        }
        int c = 0;
        while (c < 20) {
            try {
                // Contact the ui via RMI
                ui = (IUI) Naming.lookup("rmi://localhost:46727/ui");
            } catch (Exception e) {
            }
            try {
                Thread.sleep(50);
            } catch (InterruptedException e) {
                break;
            }
            c++;
        }
    }
    if (ui == null) {
        DumpManager.addDump(new DebugDump(null, "(While-loop) Look up UI RMI", "Check if \\\"ui\\\" is null", "Try to wake up UI", false, "Could not connect to UI. Terminating"));
        DumpManager.forceMetricsReport();
        JOptionPane.showMessageDialog(null, "Could not connect to UI. For more details, check dump. Terminating", "osumer launcher Error", JOptionPane.ERROR_MESSAGE);
        System.exit(-1);
        return;
    }
    try {
        ui.wake();
    } catch (RemoteException e) {
        e.printStackTrace();
        DumpManager.addDump(new DebugDump(null, "Check if \\\\\\\"ui\\\\\\\" is null", "Try to wake up UI", "End of runUi()", "Could not connect or wake UI", false, e));
        DumpManager.forceMetricsReport();
        JOptionPane.showMessageDialog(null, "Could not connect or wake UI. For more details, check dump:\n" + e, "osumer launcher Error", JOptionPane.ERROR_MESSAGE);
        System.exit(-1);
        return;
    }
}
Also used : IOException(java.io.IOException) IUI(com.github.mob41.osumer.rmi.IUI) RemoteException(java.rmi.RemoteException) DebugDump(com.github.mob41.osumer.debug.DebugDump) IOException(java.io.IOException) RemoteException(java.rmi.RemoteException)

Aggregations

IOException (java.io.IOException)14 DebugDump (com.github.mob41.osumer.debug.DebugDump)5 MalformedURLException (java.net.MalformedURLException)5 RemoteException (java.rmi.RemoteException)5 DebuggableException (com.github.mob41.organdebug.exceptions.DebuggableException)4 Configuration (com.github.mob41.osumer.Configuration)4 File (java.io.File)4 URL (java.net.URL)4 Alert (javafx.scene.control.Alert)4 WithDumpException (com.github.mob41.osumer.debug.WithDumpException)3 FXMLLoader (javafx.fxml.FXMLLoader)3 Config (com.github.mob41.osumer.Config)2 Installer (com.github.mob41.osumer.installer.Installer)2 Queue (com.github.mob41.osumer.io.queue.Queue)2 QueueAction (com.github.mob41.osumer.io.queue.QueueAction)2 AfterSoundAction (com.github.mob41.osumer.io.queue.actions.AfterSoundAction)2 BeatmapImportAction (com.github.mob41.osumer.io.queue.actions.BeatmapImportAction)2 BeforeSoundAction (com.github.mob41.osumer.io.queue.actions.BeforeSoundAction)2 CustomImportAction (com.github.mob41.osumer.io.queue.actions.CustomImportAction)2 IDaemon (com.github.mob41.osumer.rmi.IDaemon)2