summaryrefslogtreecommitdiff
path: root/src/main/java/com/c2kernel/gui/Main.java
blob: 6e8f73ddc506c1e71f9a3c6981d87a4bd0891473 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
package com.c2kernel.gui;


import java.io.File;
import java.util.Arrays;

import javax.swing.JFileChooser;

import com.c2kernel.process.Gateway;
import com.c2kernel.process.StandardClient;
import com.c2kernel.utils.Logger;


/**
 *
 * @version $Revision: 1.15 $ $Date: 2004/10/26 11:33:56 $
 * @author  $Author: abranson $
 */
public class Main extends StandardClient
{
    static public void main(String[] args)
    {
        try
        {
        	if (args[args.length-1].equals("-connect")) { // prompt for connect file
        		    JFileChooser clcChooser = new JFileChooser();
        		    clcChooser.setDialogTitle("Please choose a CRISTAL connect file.");
        		    clcChooser.addChoosableFileFilter(
        	            new javax.swing.filechooser.FileFilter() {
        	                @Override
        					public String getDescription() {
        	                    return "CRISTAL Connect Files";
        	                }
        	                @Override
        					public boolean accept(File f) {
        	                    if (f.isDirectory() || (f.isFile() && f.getName().endsWith(".clc"))) {
        	                        return true;
        	                    }
        	                    return false;
        	                }
        	            });
        		    int returnVal = clcChooser.showOpenDialog(null);
        	        if (returnVal == JFileChooser.APPROVE_OPTION) {
        	            File targetFile = clcChooser.getSelectedFile();
        	            args = Arrays.copyOf(args, args.length+1);
        	            args[args.length-1] = targetFile.getCanonicalPath();
        	        }
        	            
        	}
        	Gateway.init(readC2KArgs(args));
            Logger.initConsole("GUI");
            MainFrame client = new MainFrame();
            client.showLogin();

        }
        catch( Exception ex )
        {
            ex.printStackTrace();

            try
            {
                Gateway.close();
            }
            catch(Exception ex1)
            {
            	ex1.printStackTrace();
            }
        }
    }
}