- Timestamp:
- 10/06/11 18:06:22 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/EventBenchConsole/src/de/ugoe/cs/eventbench/Runner.java
r207 r247 1 1 package de.ugoe.cs.eventbench; 2 2 3 import java.io.IOException; 4 import java.util.List; 5 6 import joptsimple.OptionException; 7 import joptsimple.OptionParser; 8 import joptsimple.OptionSet; 9 import joptsimple.OptionSpec; 3 10 import de.ugoe.cs.eventbench.log4j.Log4JLogger; 4 11 import de.ugoe.cs.eventbench.swt.MainWindow; … … 19 26 */ 20 27 public class Runner { 28 29 public enum UITYPE { 30 text, swt 31 }; 21 32 22 33 /** … … 39 50 CommandExecuter.getInstance().addCommandPackage( 40 51 "de.ugoe.cs.eventbench.efg.commands"); 41 TextConsole textConsole = new TextConsole();42 52 new Log4JLogger(); 43 boolean swtGuiRunning = false; 44 if (args.length >= 1) { 45 if( args[0].equals("-swt") ) { 46 MainWindow mainWindow = new MainWindow(); 47 mainWindow.open(); 48 swtGuiRunning = true; 49 } else { 50 for (String command : args) { 51 CommandExecuter.getInstance().exec(command); 52 } 53 54 OptionParser parser = new OptionParser(); 55 OptionSpec<UITYPE> ui = parser.accepts("ui", "Allowed values: text, swt").withRequiredArg() 56 .ofType(UITYPE.class).defaultsTo(UITYPE.text); 57 OptionSet options = parser.parse(args); 58 59 List<String> startupCommands = options.nonOptionArguments(); 60 try { 61 switch (options.valueOf(ui)) { 62 case text: 63 TextConsole textConsole = new TextConsole(); 64 for (String command : startupCommands) { 65 CommandExecuter.getInstance().exec(command); 53 66 } 67 textConsole.run(true); 68 break; 69 case swt: 70 MainWindow mainWindow = new MainWindow(startupCommands); 71 mainWindow.open(); 72 break; 54 73 } 55 if( !swtGuiRunning ) { 56 textConsole.run(true); 74 } catch (OptionException e) { 75 System.err.println("Invalid Parameters: " + e.getMessage()); 76 try { 77 parser.printHelpOn(System.out); 78 } catch (IOException e1) { 79 // ignore exception. 80 } 57 81 } 58 82 }
Note: See TracChangeset
for help on using the changeset viewer.