summaryrefslogtreecommitdiffstats
path: root/dozentenmodul/src/main/java/org/openslx/dozmod/App.java
diff options
context:
space:
mode:
authorSimon Rettberg2015-07-10 15:48:26 +0200
committerSimon Rettberg2015-07-10 15:48:26 +0200
commit2ab01861e771592c238d22f623f01ce0967887e6 (patch)
treeaba296455b078f55cb0f248492f4869e8de92533 /dozentenmodul/src/main/java/org/openslx/dozmod/App.java
parentMerge branch 'v1.1' of git.openslx.org:openslx-ng/tutor-module into v1.1 (diff)
downloadtutor-module-2ab01861e771592c238d22f623f01ce0967887e6.tar.gz
tutor-module-2ab01861e771592c238d22f623f01ce0967887e6.tar.xz
tutor-module-2ab01861e771592c238d22f623f01ce0967887e6.zip
[client] Use AWT to show an error message in case initializing SWT fails
Diffstat (limited to 'dozentenmodul/src/main/java/org/openslx/dozmod/App.java')
-rw-r--r--dozentenmodul/src/main/java/org/openslx/dozmod/App.java40
1 files changed, 29 insertions, 11 deletions
diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/App.java b/dozentenmodul/src/main/java/org/openslx/dozmod/App.java
index 37e93434..93f58edf 100644
--- a/dozentenmodul/src/main/java/org/openslx/dozmod/App.java
+++ b/dozentenmodul/src/main/java/org/openslx/dozmod/App.java
@@ -1,10 +1,11 @@
package org.openslx.dozmod;
+
import java.io.File;
import java.io.IOException;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
-import org.apache.commons.io.FileUtils;
+import org.apache.commons.lang3.exception.ExceptionUtils;
import org.apache.log4j.AppenderSkeleton;
import org.apache.log4j.BasicConfigurator;
import org.apache.log4j.FileAppender;
@@ -12,6 +13,8 @@ import org.apache.log4j.Logger;
import org.apache.log4j.PatternLayout;
import org.apache.log4j.spi.LoggingEvent;
import org.openslx.dozmod.gui.MainWindow;
+import org.openslx.dozmod.gui.helper.Gui;
+import org.openslx.dozmod.gui.helper.MessageType;
import org.openslx.dozmod.util.ProxyConfigurator;
import org.openslx.thrifthelper.ThriftManager;
@@ -32,9 +35,9 @@ public class App {
LOGGER.info("renaming old log file");
try {
File oldFile = new File(logFilePath + ".old");
- FileUtils.forceDelete(oldFile);
+ oldFile.delete();
logFile.renameTo(oldFile);
- FileUtils.forceDelete(logFile);
+ logFile.delete();
} catch (Exception e) {
LOGGER.error("Could not move '" + logFilePath + "' to '" + logFilePath + ".old'", e);
}
@@ -91,12 +94,20 @@ public class App {
}
public static void main(final String[] args) {
-
- // Pruefe und Erzeuge gegebenfalls Config
try {
Config.init();
- } catch (IOException e) {
- e.printStackTrace();
+ } catch (Exception e) {
+ showAwtMessage("Error loading configuration", e);
+ return;
+ }
+
+ setupLogger();
+
+ // Check if we can load SWT by calling some library function
+ try {
+ Gui.display.getActiveShell();
+ } catch (NoClassDefFoundError e) {
+ showAwtMessage("Error loading SWT libraries", e);
return;
}
@@ -104,17 +115,24 @@ public class App {
// Set master server to use (TODO: make configurable via command line)
ThriftManager.setMasterServerAddress("bwlp-masterserver.ruf.uni-freiburg.de");
- setupLogger();
-
- // initialise the proxy settings
+ // Initialize the proxy settings
try {
ProxyConfigurator.init();
} catch (IOException e) {
- LOGGER.error("IOException when trying to initialise the proxy, see trace: ", e);
+ MainWindow.showMessageBox(
+ "Could not detect proxy server automatically. No proxy server will be used",
+ MessageType.WARNING, LOGGER, e);
}
// start the main window
MainWindow.mainloop();
+ }
+ private static void showAwtMessage(String message, Throwable e) {
+ LOGGER.error(message, e);
+ if (e != null) {
+ message += "\n\n" + ExceptionUtils.getStackTrace(e);
+ }
+ new AwtBox(null, message);
}
}