use of com.github.mob41.osumer.Configuration 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;
}
}
use of com.github.mob41.osumer.Configuration in project osumer by mob41.
the class PreferencesController method applyChanges.
private void applyChanges() {
FXMLLoader loader = new FXMLLoader();
loader.setLocation(AppMain.class.getResource("/view/ProgressDialogLayout.fxml"));
DialogPane progressPane = null;
try {
progressPane = (DialogPane) loader.load();
} catch (IOException e1) {
e1.printStackTrace();
}
ProgressDialogController progressController = loader.getController();
progressController.getHeaderText().setText("Applying Changes");
progressController.getStatusText().setText("Status: Writing configuration...");
progressController.getProgressBar().setProgress(-1);
Alert progressDialog = new Alert(AlertType.NONE);
progressDialog.initStyle(StageStyle.UTILITY);
progressDialog.initModality(Modality.APPLICATION_MODAL);
progressDialog.setTitle("");
progressDialog.setDialogPane(progressPane);
progressDialog.getButtonTypes().add(ButtonType.CANCEL);
Thread thread = new Thread() {
public void run() {
try {
config.write();
} catch (IOException e) {
e.printStackTrace();
Platform.runLater(new Runnable() {
@Override
public void run() {
progressDialog.close();
Alert alert = new Alert(AlertType.ERROR, "Could not write configuration:\n" + e.getMessage(), ButtonType.OK);
alert.showAndWait();
}
});
}
Platform.runLater(new Runnable() {
@Override
public void run() {
progressController.getStatusText().setText("Status: Reloading daemon configuration...");
}
});
try {
d.reloadConfiguration();
} catch (Exception e) {
e.printStackTrace();
Platform.runLater(new Runnable() {
@Override
public void run() {
progressDialog.close();
Alert alert = new Alert(AlertType.ERROR, "Could not reload daemon configuration:\n" + e.getMessage(), ButtonType.OK);
alert.showAndWait();
}
});
}
Platform.runLater(new Runnable() {
@Override
public void run() {
progressDialog.close();
}
});
}
};
thread.start();
progressDialog.showAndWait();
}
Aggregations