1 /*
2  *  CVS: $Id: Main.java,v 1.15 2004/07/25 21:40:56 marcus Exp $
3  * 
4  *  This file is part of zuul.
5  *
6  *  zuul is free software; you can redistribute it and/or modify
7  *  it under the terms of the GNU General Public License as published by
8  *  the Free Software Foundation; either version 2 of the License, or
9  *  (at your option) any later version.
10 *
11 *  zuul is distributed in the hope that it will be useful,
12 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 *  GNU General Public License for more details.
15 *
16 *  You should have received a copy of the GNU General Public License
17 *  along with zuul; if not, write to the Free Software
18 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19 * 
20 *  Copyrigth 2004 by marcus, leh
21 * 
22 */
23
24package org.jzuul.gdk;
25
26import org.eclipse.swt.SWT;
27import org.eclipse.swt.widgets.Display;
28import org.eclipse.swt.widgets.MessageBox;
29import org.eclipse.swt.widgets.Shell;
30import org.jzuul.gdk.swt.GDKMainWindow;
31import org.jzuul.gdk.swt.Messages;
32import org.jzuul.gdk.swt.Splash;
33
34/**
35 * 
36 * 
37 *  
38 */
39public class Main {
40
41    public static void main(String[] args) {
42        String filename = null;
43        if (args.length > 0) {
44            filename = args[0];
45        }
46        Main main = new Main(filename);
47    }
48
49    private Main(String filename) {
50        Display display = new Display();
51        Splash s = new Splash(display);
52        int steps = 3;
53        if (filename != null) steps++;
54        s.show(steps, Messages.getString("SPLASH_STARTING")); //$NON-NLS-1$
55
56        GDKMainWindow main = new GDKMainWindow();
57
58        try {
59            s.nextTask(Messages.getString("SPLASH_CREATING_GUI")); //$NON-NLS-1$
60            main.createGui(display);
61
62            if (filename != null) {
63                s.nextTask(Messages.getString("SPLASH_LOADING")); //$NON-NLS-1$
64                main.openFile(filename);
65            }
66
67            s.nextTask(Messages.getString("SPLASH_FINISHED")); //$NON-NLS-1$
68            s.close();
69
70            main.open(display);
71
72        } catch (Exception e) {
73            main.saveFile();
74            
75            MessageBox mb = new MessageBox(new Shell(display), SWT.ICON_ERROR);
76            mb.setText(Messages.getString("FATAL_ERROR")); //$NON-NLS-1$
77            mb.setMessage(Messages.getString("FATAL_ERROR_OCCURED") + e.getMessage() + Messages.getString("FATAL_ERROR_DATA")); //$NON-NLS-1$ //$NON-NLS-2$
78            
79            mb.open();
80            e.printStackTrace();
81        }
82    }
83}