~tapaal-contributor/tapaal/disappearing-tokens-1940098

« back to all changes in this revision

Viewing changes to src/net/tapaal/TAPAAL.java

  • Committer: Kenneth Yrke Jørgensen
  • Date: 2011-04-12 09:50:16 UTC
  • mfrom: (329.1.188 tapaal-1.5)
  • Revision ID: mail@yrke.dk-20110412095016-e4hqdgab5596ja09
Merged with branch addning support for new 1.5 features

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
package net.tapaal;
2
2
 
3
3
import java.io.File;
4
 
import java.util.List;
5
4
 
6
5
import org.apache.commons.cli.CommandLine;
7
6
import org.apache.commons.cli.CommandLineParser;
12
11
import pipe.gui.CreateGui;
13
12
import dk.aau.cs.debug.Logger;
14
13
 
15
 
 
16
14
public class TAPAAL {
17
15
 
18
16
        /**
19
17
         * Main class for lunching TAPAAL
 
18
         * 
20
19
         * @author Kenneth Yrke Joergensen (kenneth@yrke.dk)
21
20
         */
22
21
        public static void main(String[] args) {
23
 
                
24
22
                // Create a CommandLineParser using Posix Style
25
23
                CommandLineParser parser = new PosixParser();
26
24
 
27
25
                // Create possible commandline options
28
26
                Options options = new Options();
29
 
                options.addOption( "d", "debug", false, "enable debug output ." );
 
27
                options.addOption("d", "debug", false, "enable debug output .");
30
28
 
31
29
                CommandLine commandline = null;
32
 
                
 
30
 
33
31
                // Parse command line arguments
34
32
                try {
35
 
                        commandline = parser.parse( options, args );
36
 
                }
37
 
                catch( ParseException exp ) {
 
33
                        commandline = parser.parse(options, args);
 
34
                } catch (ParseException exp) {
38
35
                        System.err.println("There where an error parsing the specifyed arguments");
39
 
                    System.err.println( "Unexpected exception:" + exp.getMessage() );
 
36
                        System.err.println("Unexpected exception:" + exp.getMessage());
40
37
                }
41
 
                
42
 
                //Create the TAPAAL GUI
 
38
 
 
39
                // Create the TAPAAL GUI
43
40
                CreateGui.init();
44
41
 
45
 
                //Enable debug
46
 
            if( commandline.hasOption("debug") ) {
47
 
                Logger.enableLogging(true);
48
 
            }
49
 
            
50
 
            //Open files
51
 
            List<String> files = commandline.getArgList();
52
 
            for (String f : files){
53
 
                File file = new File(f);
54
 
                
55
 
                if (file.exists()) { //Open the file
56
 
                        if (file.canRead()){
57
 
                                CreateGui.appGui.createNewTabFromFile(file);
58
 
                        }else if (file.exists()) {
59
 
                                System.err.println("Can not read file " + file.toString());
60
 
                        }
61
 
                } else { 
62
 
                        //XXX: Can we create the file? what would the default file type be?
63
 
                        //XXX: Can we check if we can write to the directory?
64
 
                        System.err.println("Can not find file " + file.toString());
65
 
                        
66
 
                }
67
 
            }
68
 
                
 
42
                // Enable debug
 
43
                if (commandline.hasOption("debug")) {
 
44
                        Logger.enableLogging(true);
 
45
                }
 
46
 
 
47
                // Open files
 
48
                String[] files = commandline.getArgs();
 
49
                for (String f : files) {
 
50
                        File file = new File(f);
 
51
 
 
52
                        if (file.exists()) { // Open the file
 
53
                                if (file.canRead()) {
 
54
                                        CreateGui.appGui.createNewTabFromFile(file);
 
55
                                } else if (file.exists()) {
 
56
                                        System.err.println("Can not read file " + file.toString());
 
57
                                }
 
58
                        } else {
 
59
                                // XXX: Can we create the file? what would the default file type
 
60
                                // be?
 
61
                                // XXX: Can we check if we can write to the directory?
 
62
                                System.err.println("Can not find file " + file.toString());
 
63
 
 
64
                        }
 
65
                }
 
66
 
69
67
        }
70
68
 
71
69
}