Subversion Repositories svn.mios

Rev

Rev 733 | Rev 741 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 733 Rev 738
Line 45... Line 45...
45
import org.midibox.utils.gui.DialogOwner;
45
import org.midibox.utils.gui.DialogOwner;
46
import org.midibox.utils.gui.ImageLoader;
46
import org.midibox.utils.gui.ImageLoader;
47
import org.midibox.utils.gui.SplashScreen;
47
import org.midibox.utils.gui.SplashScreen;
48
48
49
/**
49
/**
50
 * Driver class for launching MIOS Studio + SID V2 application. MIOS Studio can be
50
 * Driver class for launching MIOS Studio + SID V2 application. MIOS Studio can
51
 * launched as an application or embedded in a a web page as an applet. When
51
 * be launched as an application or embedded in a a web page as an applet. When
52
 * launched as an application, the app shows a splash screen and is launched
52
 * launched as an application, the app shows a splash screen and is launched
53
 * within its own frame. Preferences are saved and restored from this class.
53
 * within its own frame. Preferences are saved and restored from this class.
54
 *
54
 *
55
 * @author Adam King (adamjking@optusnet.com.au)
55
 * @author Adam King (adamjking@optusnet.com.au)
56
 */
56
 */
57
57
58
public class MIOSStudioSID extends JApplet {
58
public class MIOSStudioSID extends JApplet {
-
 
59
-
 
60
    protected static Preferences preferences = Preferences.userRoot().node(
-
 
61
            "org/midibox/miostudiosid/gui");
-
 
62
-
 
63
    protected static String configFileName = ".miosstudiosid";
59
64
60
    protected static String frameTitle = "MIOS Studio + SID V2 Editor";
65
    protected static String frameTitle = "MIOS Studio + SID V2 Editor";
61
   
66
62
    protected static String splashTitle = "MIOS Studio beta 9 + SID V2 Editor";
67
    protected static String splashTitle = "MIOS Studio beta 9 + SID V2 Editor";
63
68
Line 74... Line 79...
74
    public MIOSStudioSID() {
79
    public MIOSStudioSID() {
75
       
80
76
        this.miosStudioSID = new org.midibox.apps.miosstudiosid.MIOSStudioSID();
81
        this.miosStudioSID = new org.midibox.apps.miosstudiosid.MIOSStudioSID();
77
       
82
78
        loadConfigFile();
83
        loadConfigFile();
79
-
 
80
        Preferences preferences = getPreferences();
-
 
81
84
82
        try {
85
        try {
83
            UIManager.setLookAndFeel(preferences.get("lookAndFeel", UIManager
86
            UIManager.setLookAndFeel(preferences.get("lookAndFeel", UIManager
84
                    .getCrossPlatformLookAndFeelClassName()));
87
                    .getCrossPlatformLookAndFeelClassName()));
85
        } catch (Exception e) {
88
        } catch (Exception e) {
Line 96... Line 99...
96
        setContentPane(miosStudioSIDGUI);
99
        setContentPane(miosStudioSIDGUI);
97
        setJMenuBar(miosStudioSIDGUI.createMenuBar());
100
        setJMenuBar(miosStudioSIDGUI.createMenuBar());
98
    }
101
    }
99
102
100
    public void init() {
103
    public void init() {
101
-
 
102
        Preferences preferences = getPreferences();
-
 
103
104
104
        HexFileUploadGUI.setCurrentDirectory(preferences.get(
105
        HexFileUploadGUI.setCurrentDirectory(preferences.get(
105
                "uploadCurrentDirectory", HexFileUploadGUI
106
                "uploadCurrentDirectory", HexFileUploadGUI
106
                        .getCurrentDirectory()));
107
                        .getCurrentDirectory()));
107
108
Line 172... Line 173...
172
    }
173
    }
173
174
174
    public void destroy() {
175
    public void destroy() {
175
176
176
        saveConfigFile();
177
        saveConfigFile();
177
-
 
178
        Preferences preferences = getPreferences();
-
 
179
178
180
        preferences.put("lookAndFeel", miosStudioSIDGUI.getLookAndFeel());
179
        preferences.put("lookAndFeel", miosStudioSIDGUI.getLookAndFeel());
181
        preferences.putBoolean("defaultDecoratedFrames", miosStudioSIDGUI
180
        preferences.putBoolean("defaultDecoratedFrames", miosStudioSIDGUI
182
                .isDefaultDecoratedFrames());
181
                .isDefaultDecoratedFrames());
183
182
Line 237... Line 236...
237
        }
236
        }
238
        preferences.put("externalCommands", externalCommandsString);
237
        preferences.put("externalCommands", externalCommandsString);
239
    }
238
    }
240
239
241
    public void exit(JFrame frame) {
240
    public void exit(JFrame frame) {
242
-
 
243
        Preferences preferences = getPreferences();
-
 
244
241
245
        preferences.putInt("mainWindowX", frame.getX());
242
        preferences.putInt("mainWindowX", frame.getX());
246
        preferences.putInt("mainWindowY", frame.getY());
243
        preferences.putInt("mainWindowY", frame.getY());
247
        preferences.putInt("mainWindowWidth", frame.getWidth());
244
        preferences.putInt("mainWindowWidth", frame.getWidth());
248
        preferences.putInt("mainWindowHeight", frame.getHeight());
245
        preferences.putInt("mainWindowHeight", frame.getHeight());
249
246
250
        System.exit(0);
247
        System.exit(0);
251
    }
-
 
252
-
 
253
    protected Preferences getPreferences() {
-
 
254
-
 
255
        return Preferences.userRoot().node("org/midibox/miostudiosid/gui");
-
 
256
    }
-
 
257
-
 
258
    protected String getConfigFileName() {
-
 
259
-
 
260
        return ".miosstudiosid";
-
 
261
    }
248
    }
262
249
263
    protected void saveConfigFile() {
250
    protected void saveConfigFile() {
264
251
265
        File configFile = new File(System.getProperty("user.home"),
252
        File configFile = new File(System.getProperty("user.home"),
266
                getConfigFileName());
253
                configFileName);
267
254
268
        if (!configFile.exists()) {
255
        if (!configFile.exists()) {
269
            try {
256
            try {
270
                configFile.createNewFile();
257
                configFile.createNewFile();
271
            } catch (Exception e) {
258
            } catch (Exception e) {
Line 283... Line 270...
283
    }
270
    }
284
271
285
    protected void loadConfigFile() {
272
    protected void loadConfigFile() {
286
       
273
287
        File configFile = new File(System.getProperty("user.home"),
274
        File configFile = new File(System.getProperty("user.home"),
288
                getConfigFileName());
275
                configFileName);
289
276
290
        if (configFile.exists()) {
277
        if (configFile.exists()) {
291
278
292
            MIOSStudioXML miosStudioXML = new MIOSStudioXML(miosStudioSID,
279
            MIOSStudioXML miosStudioXML = new MIOSStudioXML(miosStudioSID,
293
                    MIOSStudioXML.TAG_ROOT_ELEMENT);
280
                    MIOSStudioXML.TAG_ROOT_ELEMENT);
294
281
295
            miosStudioXML.loadXML(configFile);
282
            miosStudioXML.loadXML(configFile);
296
283
297
        } else {
284
        } else {
298
285
299
            miosStudioSID.getHexFileUploadDeviceManager().newHexFileUploadDevice();
286
            miosStudioSID.getHexFileUploadDeviceManager()
-
 
287
                    .newHexFileUploadDevice();
300
        }
288
        }
301
    }
289
    }
302
290
303
    protected void createWindowsHashtable() {
291
    protected void createWindowsHashtable() {
304
292
Line 317... Line 305...
317
305
318
        windows.put("uploadWindow", miosStudioSIDGUI
306
        windows.put("uploadWindow", miosStudioSIDGUI
319
                .getHexFileUploadDeviceManagerWindow());
307
                .getHexFileUploadDeviceManagerWindow());
320
        windows.put("lcdWindow", miosStudioSIDGUI.getLcdMessageWindow());
308
        windows.put("lcdWindow", miosStudioSIDGUI.getLcdMessageWindow());
321
        windows.put("debugWindow", miosStudioSIDGUI.getDebugFunctionWindow());
309
        windows.put("debugWindow", miosStudioSIDGUI.getDebugFunctionWindow());
322
        windows
-
 
323
                .put("miosTerminalWindow", miosStudioSIDGUI
310
        windows.put("miosTerminalWindow", miosStudioSIDGUI
324
                        .getMIOSTerminalWindow());
311
                .getMIOSTerminalWindow());
-
 
312
        windows
-
 
313
                .put("sidv2librarianWindow",
325
        windows.put("sidv2librarianWindow", ((MIOSStudioSIDGUI) miosStudioSIDGUI)
314
                        ((MIOSStudioSIDGUI) miosStudioSIDGUI)
326
                .getSidv2librarianWindow());
315
                                .getSidv2librarianWindow());
327
       
316
328
        windows.put("helpWindow", miosStudioSIDGUI.getHelpWindow());
317
        windows.put("helpWindow", miosStudioSIDGUI.getHelpWindow());
329
318
330
    }
319
    }
Line 338... Line 327...
338
        splashScreen.setLocation(
327
        splashScreen.setLocation(
339
                (screenSize.width - splashScreen.getWidth()) / 2,
328
                (screenSize.width - splashScreen.getWidth()) / 2,
340
                (screenSize.height - splashScreen.getHeight()) / 2);
329
                (screenSize.height - splashScreen.getHeight()) / 2);
341
330
342
        splashScreen.setVisible(true);
331
        splashScreen.setVisible(true);
343
-
 
344
        Preferences preferences = Preferences.userRoot().node(
-
 
345
                "org/midibox/miostudiosid/gui");
-
 
346
332
347
        try {
333
        try {
348
            UIManager.setLookAndFeel(preferences.get("lookAndFeel", UIManager
334
            UIManager.setLookAndFeel(preferences.get("lookAndFeel", UIManager
349
                    .getCrossPlatformLookAndFeelClassName()));
335
                    .getCrossPlatformLookAndFeelClassName()));
350
        } catch (Exception e) {
336
        } catch (Exception e) {