Subversion Repositories svn.mios

Rev

Rev 808 | Rev 871 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
741 adamjking 1
package org.midibox.apps.miosstudio.gui.xml;
2
 
744 adamjking 3
import java.awt.Dimension;
741 adamjking 4
import java.util.Iterator;
5
import java.util.Vector;
6
 
7
import javax.swing.JFrame;
8
import javax.swing.JInternalFrame;
9
import javax.swing.UIManager;
10
 
11
import org.midibox.apps.miosstudio.MIOSStudio;
12
import org.midibox.apps.miosstudio.gui.MIOSStudioGUI;
13
import org.midibox.apps.miosstudio.gui.MIOSStudioGUI.ExternalCommandButton;
14
import org.midibox.apps.miosstudio.xml.MIOSStudioXML;
15
import org.midibox.midi.gui.MidiFilterGUI;
800 adamjking 16
import org.midibox.midi.gui.SysexSendReceiveGUI;
741 adamjking 17
import org.midibox.mios.gui.HexFileUploadGUI;
18
import org.midibox.utils.gui.DialogOwner;
19
import org.midibox.utils.xml.XMLUtils;
20
import org.w3c.dom.Element;
21
import org.w3c.dom.Node;
22
 
23
public class MIOSStudioGUIXML extends XMLUtils {
24
 
25
    public final static String TAG_ROOT_ELEMENT = "miosStudioGUI";
26
 
27
    public final static String TAG_LOOK_AND_FEEL = "lookAndFeel";
28
 
29
    public final static String TAG_MAIN_WINDOW = "mainWindow";
30
 
31
    public final static String TAG_INTERNAL_FRAMES = "internalFrames";
32
 
33
    public final static String TAG_INTERNAL_FRAME = "internalFrame";
34
 
35
    public final static String TAG_EXTERNAL_COMMANDS = "externalCommands";
36
 
37
    public final static String TAG_EXTERNAL_COMMAND = "externalCommand";
38
 
39
    public final static String TAG_WORKSPACE_CURRENT_DIRECTORY = "workspaceCurrentDirectory";
40
 
808 adamjking 41
    public final static String TAG_MIDI_FILTER_MANAGER_GUI = "midiFilterManagerGUI";
741 adamjking 42
 
43
    public final static String TAG_MIDI_FILTER_GUI_CURRENT_DIRECTORY = "midiFilterGUICurrentDirectory";
44
 
808 adamjking 45
    public final static String TAG_HEX_FILE_UPLOAD_MANAGER_GUI = "hexFileUploadManagerGUI";
741 adamjking 46
 
753 adamjking 47
    public final static String TAG_HEX_FILE_UPLOAD_GUI_CURRENT_DIRECTORY = "hexFileUploadGUICurrentDirectory";
756 adamjking 48
 
808 adamjking 49
    public final static String TAG_SYSEX_SEND_RECEIVE_MANAGER_GUI = "sysexSendReceiveManagerGUI";
800 adamjking 50
 
51
    public final static String TAG_SYSEX_SEND_RECEIVE_GUI_CURRENT_DIRECTORY = "sysexSendReceiveGUICurrentDirectory";
52
 
753 adamjking 53
    public final static String TAG_WORKSPACE_MRU_LIST = "workspaceMRUList";
756 adamjking 54
 
753 adamjking 55
    public final static String TAG_WORKSPACE_MRU = "workspaceMRU";
756 adamjking 56
 
753 adamjking 57
    public final static String TAG_MIDI_FILTER_GUI_MRU_LIST = "midiFilterGUIMRUList";
756 adamjking 58
 
753 adamjking 59
    public final static String TAG_MIDI_FILTER_GUI_MRU = "midiFilterGUIMRU";
756 adamjking 60
 
800 adamjking 61
    public final static String TAG_SYSEX_SEND_RECEIVE_GUI_MRU_LIST = "sysexSendReceiveGUIMRUList";
62
 
63
    public final static String TAG_SYSEX_SEND_RECEIVE_GUI_MRU = "sysexSendReceiveGUIMRU";
64
 
753 adamjking 65
    public final static String TAG_HEX_FILE_UPLOAD_GUI_MRU_LIST = "hexFileUploadGUIMRUList";
756 adamjking 66
 
753 adamjking 67
    public final static String TAG_HEX_FILE_UPLOAD_GUI_MRU = "hexFileUploadGUIMRU";
741 adamjking 68
 
69
    public final static String ATTR_TITLE = "title";
70
 
71
    public final static String ATTR_POS_X = "posX";
72
 
73
    public final static String ATTR_POS_Y = "posY";
74
 
75
    public final static String ATTR_WIDTH = "width";
76
 
77
    public final static String ATTR_HEIGHT = "height";
78
 
79
    public final static String ATTR_VISIBLE = "visible";
80
 
81
    public final static String ATTR_ICONIFIED = "iconified";
82
 
83
    public final static String ATTR_MAXIMIZED = "maximized";
84
 
85
    public final static String ATTR_COMMAND_NAME = "commandName";
86
 
87
    public final static String ATTR_EXTERNAL_COMMAND = "externalCommand";
88
 
89
    public final static String ATTR_SELECTED_TAB = "selectedTab";
90
 
91
    protected MIOSStudioGUI miosStudioGUI;
92
 
93
    protected MIOSStudio miosStudio;
94
 
95
    protected boolean includeModel;
96
 
97
    protected boolean includeGUI;
756 adamjking 98
 
757 adamjking 99
    protected boolean includeExternalCommands;
100
 
101
    protected boolean includeLookAndFeel;
102
 
753 adamjking 103
    protected boolean includeMRU;
741 adamjking 104
 
105
    public MIOSStudioGUIXML(MIOSStudio miosStudio, String rootElementTag,
757 adamjking 106
            boolean includeModel, boolean includeGUI,
107
            boolean includeExternalCommands, boolean includeLookAndFeel,
108
            boolean includeMRU) {
741 adamjking 109
 
756 adamjking 110
        this(null, miosStudio, rootElementTag, includeModel, includeGUI,
757 adamjking 111
                includeExternalCommands, includeLookAndFeel, includeMRU);
741 adamjking 112
    }
113
 
114
    public MIOSStudioGUIXML(MIOSStudioGUI miosStudioGUI, String rootElementTag,
757 adamjking 115
            boolean includeModel, boolean includeGUI,
116
            boolean includeExternalCommands, boolean includeLookAndFeel,
117
            boolean includeMRU) {
741 adamjking 118
 
119
        this(miosStudioGUI, miosStudioGUI.getMiosStudio(), rootElementTag,
757 adamjking 120
                includeModel, includeGUI, includeExternalCommands,
121
                includeLookAndFeel, includeMRU);
741 adamjking 122
    }
123
 
757 adamjking 124
    protected MIOSStudioGUIXML(MIOSStudioGUI miosStudioGUI,
125
            MIOSStudio miosStudio, String rootElementTag, boolean includeModel,
126
            boolean includeGUI, boolean includeExternalCommands,
127
            boolean includeLookAndFeel, boolean includeMRU) {
741 adamjking 128
 
129
        super(rootElementTag);
130
 
131
        this.miosStudioGUI = miosStudioGUI;
132
 
133
        this.miosStudio = miosStudio;
134
 
135
        this.includeModel = includeModel;
136
 
137
        this.includeGUI = includeGUI;
756 adamjking 138
 
757 adamjking 139
        this.includeExternalCommands = includeExternalCommands;
140
 
141
        this.includeLookAndFeel = includeLookAndFeel;
142
 
753 adamjking 143
        this.includeMRU = includeMRU;
741 adamjking 144
 
145
        if (includeModel) {
146
 
753 adamjking 147
            addTag(MIOSStudioXML.TAG_ROOT_ELEMENT);
741 adamjking 148
        }
149
 
150
        if (includeGUI) {
151
 
753 adamjking 152
            addTag(TAG_MAIN_WINDOW);
153
            addTag(TAG_INTERNAL_FRAMES);
808 adamjking 154
            addTag(TAG_SYSEX_SEND_RECEIVE_MANAGER_GUI);
155
            addTag(TAG_HEX_FILE_UPLOAD_MANAGER_GUI);
757 adamjking 156
        }
157
 
158
        if (includeExternalCommands) {
159
 
753 adamjking 160
            addTag(TAG_EXTERNAL_COMMANDS);
161
            addTag(TAG_EXTERNAL_COMMAND);
741 adamjking 162
        }
756 adamjking 163
 
757 adamjking 164
        if (includeLookAndFeel) {
165
 
166
            addTag(TAG_LOOK_AND_FEEL);
167
        }
168
 
753 adamjking 169
        if (includeMRU) {
756 adamjking 170
 
171
            addTag(TAG_WORKSPACE_CURRENT_DIRECTORY);
753 adamjking 172
            addTag(TAG_WORKSPACE_MRU_LIST);
173
            addTag(TAG_WORKSPACE_MRU);
808 adamjking 174
            addTag(TAG_MIDI_FILTER_MANAGER_GUI);
756 adamjking 175
            addTag(TAG_MIDI_FILTER_GUI_CURRENT_DIRECTORY);
753 adamjking 176
            addTag(TAG_MIDI_FILTER_GUI_MRU_LIST);
177
            addTag(TAG_MIDI_FILTER_GUI_MRU);
800 adamjking 178
            addTag(TAG_SYSEX_SEND_RECEIVE_GUI_CURRENT_DIRECTORY);
179
            addTag(TAG_SYSEX_SEND_RECEIVE_GUI_MRU_LIST);
180
            addTag(TAG_SYSEX_SEND_RECEIVE_GUI_MRU);
756 adamjking 181
            addTag(TAG_HEX_FILE_UPLOAD_GUI_CURRENT_DIRECTORY);
753 adamjking 182
            addTag(TAG_HEX_FILE_UPLOAD_GUI_MRU_LIST);
183
            addTag(TAG_HEX_FILE_UPLOAD_GUI_MRU);
184
        }
741 adamjking 185
    }
186
 
187
    protected void createGUI() {
188
 
189
        miosStudioGUI = new MIOSStudioGUI(miosStudio);
190
    }
191
 
192
    protected void parseElement(Element element) {
193
 
194
        super.parseElement(element);
195
 
196
        String name = element.getNodeName();
197
 
198
        if (name == rootElementTag) {
199
 
200
        } else if (name == MIOSStudioXML.TAG_ROOT_ELEMENT) {
201
 
202
            MIOSStudioXML miosStudioXML = new MIOSStudioXML(miosStudio,
203
                    MIOSStudioXML.TAG_ROOT_ELEMENT);
204
 
205
            miosStudioXML.loadXML(element);
206
 
207
        } else if (name == TAG_MAIN_WINDOW) {
208
 
209
            JFrame mainWindow = DialogOwner.getFrame();
210
 
211
            if (mainWindow != null) {
212
 
213
                mainWindow.setBounds(stringToInt(element
214
                        .getAttribute(ATTR_POS_X)), stringToInt(element
215
                        .getAttribute(ATTR_POS_Y)), stringToInt(element
216
                        .getAttribute(ATTR_WIDTH)), stringToInt(element
217
                        .getAttribute(ATTR_HEIGHT)));
218
            }
219
 
220
        } else if (name == TAG_LOOK_AND_FEEL) {
221
 
222
            String lookAndFeel = element.getTextContent();
223
 
224
            if (miosStudioGUI == null) {
225
 
226
                try {
227
 
228
                    UIManager.setLookAndFeel(lookAndFeel);
229
 
230
                } catch (Exception e) {
231
 
232
                    e.printStackTrace();
233
                }
234
 
235
                createGUI();
236
            }
237
 
238
            miosStudioGUI.setLookAndFeel(lookAndFeel);
239
 
240
        } else if (name == TAG_INTERNAL_FRAMES) {
241
 
242
            Iterator it = miosStudioGUI.getInternalFrames().iterator();
243
 
244
            while (it.hasNext()) {
245
 
246
                JInternalFrame internalFrame = (JInternalFrame) it.next();
247
 
248
                internalFrame.setVisible(false);
249
 
250
                miosStudioGUI.getDesktop().remove(internalFrame);
251
            }
252
 
253
            Node childNode = element.getLastChild();
254
 
255
            while (childNode != null) {
256
 
257
                element = (Element) childNode;
258
 
259
                if (element.getNodeName() == TAG_INTERNAL_FRAME) {
260
 
261
                    JInternalFrame internalFrame = findInternalFrame(element
262
                            .getAttribute(ATTR_TITLE));
263
 
264
                    if (internalFrame != null) {
265
 
744 adamjking 266
                        Dimension d = internalFrame.getPreferredSize();
741 adamjking 267
 
744 adamjking 268
                        if (internalFrame.isResizable()) {
269
 
270
                            internalFrame.setBounds(stringToInt(element
271
                                    .getAttribute(ATTR_POS_X)),
272
                                    stringToInt(element
273
                                            .getAttribute(ATTR_POS_Y)), Math
274
                                            .max(stringToInt(element
275
                                                    .getAttribute(ATTR_WIDTH)),
276
                                                    d.width),
277
                                    Math.max(stringToInt(element
278
                                            .getAttribute(ATTR_HEIGHT)),
279
                                            d.height));
280
 
281
                        } else {
282
 
283
                            internalFrame.setBounds(stringToInt(element
284
                                    .getAttribute(ATTR_POS_X)),
285
                                    stringToInt(element
286
                                            .getAttribute(ATTR_POS_Y)),
287
                                    d.width, d.height);
288
                        }
289
 
290
                        if (stringToBoolean(element.getAttribute(ATTR_VISIBLE))) {
291
 
292
                            miosStudioGUI.showFrame(internalFrame);
293
                        }
294
 
741 adamjking 295
                        try {
296
 
297
                            internalFrame.setMaximum(stringToBoolean(element
298
                                    .getAttribute(ATTR_MAXIMIZED)));
299
 
300
                            internalFrame.setIcon(stringToBoolean(element
301
                                    .getAttribute(ATTR_ICONIFIED)));
302
 
303
                        } catch (Exception e) {
304
 
305
                            e.printStackTrace();
306
                        }
307
                    }
308
 
309
                    childNode = childNode.getPreviousSibling();
310
                }
311
            }
312
 
313
        } else if (name == TAG_EXTERNAL_COMMANDS) {
314
 
315
            Iterator it = ((Vector) miosStudioGUI.getExternalCommands().clone())
316
                    .iterator();
317
 
318
            while (it.hasNext()) {
319
 
320
                ExternalCommandButton externalCommandButton = (ExternalCommandButton) it
321
                        .next();
322
 
323
                miosStudioGUI
324
                        .removeExternalCommandButton(externalCommandButton);
325
            }
326
 
327
        } else if (name == TAG_EXTERNAL_COMMAND) {
328
 
329
            miosStudioGUI.addExternalCommandButton(element
330
                    .getAttribute(ATTR_COMMAND_NAME), element
331
                    .getAttribute(ATTR_EXTERNAL_COMMAND));
332
 
333
        } else if (name == TAG_WORKSPACE_CURRENT_DIRECTORY) {
334
 
335
            MIOSStudioGUI.setCurrentDirectory(element.getTextContent());
336
 
808 adamjking 337
        } else if (name == TAG_MIDI_FILTER_MANAGER_GUI) {
741 adamjking 338
 
339
        } else if (name == TAG_MIDI_FILTER_GUI_CURRENT_DIRECTORY) {
340
 
341
            MidiFilterGUI.setCurrentDirectory(element.getTextContent());
342
 
808 adamjking 343
        } else if (name == TAG_SYSEX_SEND_RECEIVE_MANAGER_GUI) {
344
 
800 adamjking 345
            int tabIndex = stringToInt(element.getAttribute(ATTR_SELECTED_TAB));
346
 
347
            if (tabIndex < miosStudioGUI.getSysexSendReceiveDeviceManagerGUI()
348
                    .getTabbedPane().getTabCount()) {
349
 
350
                miosStudioGUI.getSysexSendReceiveDeviceManagerGUI()
351
                        .getTabbedPane().setSelectedIndex(tabIndex);
352
 
353
            }
354
 
355
        } else if (name == TAG_SYSEX_SEND_RECEIVE_GUI_CURRENT_DIRECTORY) {
356
 
357
            SysexSendReceiveGUI.setCurrentDirectory(element.getTextContent());
358
 
808 adamjking 359
        } else if (name == TAG_HEX_FILE_UPLOAD_MANAGER_GUI) {
741 adamjking 360
 
361
            int tabIndex = stringToInt(element.getAttribute(ATTR_SELECTED_TAB));
362
 
363
            if (tabIndex < miosStudioGUI.getHexFileUploadDeviceManagerGUI()
364
                    .getTabbedPane().getTabCount()) {
365
 
366
                miosStudioGUI.getHexFileUploadDeviceManagerGUI()
367
                        .getTabbedPane().setSelectedIndex(tabIndex);
368
 
369
            }
370
 
753 adamjking 371
        } else if (name == TAG_HEX_FILE_UPLOAD_GUI_CURRENT_DIRECTORY) {
741 adamjking 372
 
373
            HexFileUploadGUI.setCurrentDirectory(element.getTextContent());
756 adamjking 374
 
753 adamjking 375
        } else if (name == TAG_WORKSPACE_MRU_LIST) {
756 adamjking 376
 
753 adamjking 377
            miosStudioGUI.getMRU().removeAllElements();
756 adamjking 378
 
753 adamjking 379
        } else if (name == TAG_WORKSPACE_MRU) {
756 adamjking 380
 
753 adamjking 381
            miosStudioGUI.saveMRU(element.getTextContent());
756 adamjking 382
 
753 adamjking 383
        } else if (name == TAG_MIDI_FILTER_GUI_MRU_LIST) {
756 adamjking 384
 
753 adamjking 385
            MidiFilterGUI.getMRU().removeAllElements();
756 adamjking 386
 
753 adamjking 387
        } else if (name == TAG_MIDI_FILTER_GUI_MRU) {
756 adamjking 388
 
753 adamjking 389
            MidiFilterGUI.saveMRU(element.getTextContent());
756 adamjking 390
 
753 adamjking 391
        } else if (name == TAG_HEX_FILE_UPLOAD_GUI_MRU_LIST) {
756 adamjking 392
 
753 adamjking 393
            HexFileUploadGUI.getMRU().removeAllElements();
756 adamjking 394
 
753 adamjking 395
        } else if (name == TAG_HEX_FILE_UPLOAD_GUI_MRU) {
756 adamjking 396
 
753 adamjking 397
            HexFileUploadGUI.saveMRU(element.getTextContent());
850 adamjking 398
 
399
        } else if (name == TAG_SYSEX_SEND_RECEIVE_GUI_MRU_LIST) {
400
 
401
            HexFileUploadGUI.getMRU().removeAllElements();
402
 
403
        } else if (name == TAG_SYSEX_SEND_RECEIVE_GUI_MRU) {
404
 
405
            SysexSendReceiveGUI.saveMRU(element.getTextContent());
741 adamjking 406
        }
850 adamjking 407
 
741 adamjking 408
    }
409
 
410
    public void saveXML(Node node) {
411
 
412
        super.saveXML(node);
413
 
800 adamjking 414
        Element sysexSendReceiveDeviceManagerGUIelement = null;
415
 
757 adamjking 416
        Element hexFileUploadDeviceManagerGUIelement = null;
417
 
741 adamjking 418
        if (includeModel) {
419
 
420
            MIOSStudioXML miosStudioXML = new MIOSStudioXML(miosStudio,
421
                    MIOSStudioXML.TAG_ROOT_ELEMENT);
422
 
423
            miosStudioXML.saveXML(rootElement);
424
        }
425
 
757 adamjking 426
        if (includeLookAndFeel) {
427
 
428
            Element lookAndFeelElement = document
429
                    .createElement(TAG_LOOK_AND_FEEL);
430
 
431
            rootElement.appendChild(lookAndFeelElement);
432
 
433
            lookAndFeelElement.setTextContent(miosStudioGUI.getLookAndFeel());
434
        }
435
 
741 adamjking 436
        if (includeGUI) {
437
 
438
            JFrame mainWindow = DialogOwner.getFrame();
439
 
440
            if (mainWindow != null) {
441
 
442
                Element mainWindowElement = document
443
                        .createElement(TAG_MAIN_WINDOW);
444
 
445
                rootElement.appendChild(mainWindowElement);
446
 
447
                mainWindowElement.setAttribute(ATTR_POS_X,
448
                        intToString(mainWindow.getX()));
449
 
450
                mainWindowElement.setAttribute(ATTR_POS_Y,
451
                        intToString(mainWindow.getY()));
452
 
453
                mainWindowElement.setAttribute(ATTR_WIDTH,
454
                        intToString(mainWindow.getWidth()));
455
 
456
                mainWindowElement.setAttribute(ATTR_HEIGHT,
457
                        intToString(mainWindow.getHeight()));
458
            }
459
 
460
            Element internalFramesElement = document
461
                    .createElement(TAG_INTERNAL_FRAMES);
462
 
463
            rootElement.appendChild(internalFramesElement);
464
 
465
            Vector internalFrames = (Vector) miosStudioGUI.getInternalFrames()
466
                    .clone();
467
 
468
            JInternalFrame[] visibleInternalFrames = miosStudioGUI.getDesktop()
469
                    .getAllFrames();
470
 
471
            for (int i = 0; i < visibleInternalFrames.length; i++) {
472
 
473
                JInternalFrame internalFrame = visibleInternalFrames[i];
474
 
475
                Element internalFrameElement = document
476
                        .createElement(TAG_INTERNAL_FRAME);
477
 
478
                internalFramesElement.appendChild(internalFrameElement);
479
 
480
                saveInternalFrame(internalFrame, internalFrameElement);
481
 
482
                internalFrames.remove(internalFrame);
483
            }
484
 
485
            Iterator it = internalFrames.iterator();
486
 
487
            while (it.hasNext()) {
488
 
489
                JInternalFrame internalFrame = (JInternalFrame) it.next();
490
 
491
                Element internalFrameElement = document
492
                        .createElement(TAG_INTERNAL_FRAME);
493
 
494
                internalFramesElement.appendChild(internalFrameElement);
495
 
496
                saveInternalFrame(internalFrame, internalFrameElement);
497
            }
498
 
800 adamjking 499
            sysexSendReceiveDeviceManagerGUIelement = document
808 adamjking 500
                    .createElement(TAG_SYSEX_SEND_RECEIVE_MANAGER_GUI);
800 adamjking 501
 
502
            rootElement.appendChild(sysexSendReceiveDeviceManagerGUIelement);
503
 
504
            sysexSendReceiveDeviceManagerGUIelement.setAttribute(
505
                    ATTR_SELECTED_TAB, intToString(miosStudioGUI
506
                            .getSysexSendReceiveDeviceManagerGUI()
507
                            .getTabbedPane().getSelectedIndex()));
508
 
757 adamjking 509
            hexFileUploadDeviceManagerGUIelement = document
808 adamjking 510
                    .createElement(TAG_HEX_FILE_UPLOAD_MANAGER_GUI);
757 adamjking 511
 
512
            rootElement.appendChild(hexFileUploadDeviceManagerGUIelement);
513
 
514
            hexFileUploadDeviceManagerGUIelement.setAttribute(
515
                    ATTR_SELECTED_TAB, intToString(miosStudioGUI
516
                            .getHexFileUploadDeviceManagerGUI().getTabbedPane()
517
                            .getSelectedIndex()));
518
 
519
        }
520
 
521
        if (includeExternalCommands) {
522
 
741 adamjking 523
            Element externalCommandsElement = document
524
                    .createElement(TAG_EXTERNAL_COMMANDS);
525
 
526
            rootElement.appendChild(externalCommandsElement);
527
 
757 adamjking 528
            Iterator it = miosStudioGUI.getExternalCommands().iterator();
741 adamjking 529
 
530
            while (it.hasNext()) {
531
 
532
                ExternalCommandButton externalCommandButton = (ExternalCommandButton) it
533
                        .next();
534
 
535
                Element externalCommandElement = document
536
                        .createElement(TAG_EXTERNAL_COMMAND);
537
 
538
                externalCommandsElement.appendChild(externalCommandElement);
539
 
540
                externalCommandElement.setAttribute(ATTR_COMMAND_NAME,
541
                        externalCommandButton.commandName);
542
 
543
                externalCommandElement.setAttribute(ATTR_EXTERNAL_COMMAND,
544
                        externalCommandButton.externalCommand);
545
            }
757 adamjking 546
        }
741 adamjking 547
 
757 adamjking 548
        if (includeMRU) {
741 adamjking 549
 
800 adamjking 550
            Element sysexSendReceiveCurrentDirectoryElement = document
551
                    .createElement(TAG_SYSEX_SEND_RECEIVE_GUI_CURRENT_DIRECTORY);
552
 
553
            if (sysexSendReceiveDeviceManagerGUIelement == null) {
554
                sysexSendReceiveDeviceManagerGUIelement = document
808 adamjking 555
                        .createElement(TAG_SYSEX_SEND_RECEIVE_MANAGER_GUI);
800 adamjking 556
 
557
                rootElement
558
                        .appendChild(sysexSendReceiveDeviceManagerGUIelement);
559
            }
560
 
561
            sysexSendReceiveDeviceManagerGUIelement
562
                    .appendChild(sysexSendReceiveCurrentDirectoryElement);
563
 
564
            sysexSendReceiveCurrentDirectoryElement
565
                    .setTextContent(SysexSendReceiveGUI.getCurrentDirectory());
566
 
850 adamjking 567
            Element mruListElement = document
568
                    .createElement(TAG_SYSEX_SEND_RECEIVE_GUI_MRU_LIST);
569
 
570
            sysexSendReceiveDeviceManagerGUIelement.appendChild(mruListElement);
571
 
572
            Iterator it = SysexSendReceiveGUI.getMRU().iterator();
573
 
574
            while (it.hasNext()) {
575
 
576
                Element mru = document
577
                        .createElement(TAG_SYSEX_SEND_RECEIVE_GUI_MRU);
578
 
579
                mruListElement.appendChild(mru);
580
 
581
                mru.setTextContent((String) it.next());
582
            }
583
 
757 adamjking 584
            Element hexFileCurrentDirectoryElement = document
585
                    .createElement(TAG_HEX_FILE_UPLOAD_GUI_CURRENT_DIRECTORY);
741 adamjking 586
 
757 adamjking 587
            if (hexFileUploadDeviceManagerGUIelement == null) {
588
                hexFileUploadDeviceManagerGUIelement = document
808 adamjking 589
                        .createElement(TAG_HEX_FILE_UPLOAD_MANAGER_GUI);
756 adamjking 590
 
757 adamjking 591
                rootElement.appendChild(hexFileUploadDeviceManagerGUIelement);
592
            }
756 adamjking 593
 
757 adamjking 594
            hexFileUploadDeviceManagerGUIelement
595
                    .appendChild(hexFileCurrentDirectoryElement);
756 adamjking 596
 
757 adamjking 597
            hexFileCurrentDirectoryElement.setTextContent(HexFileUploadGUI
598
                    .getCurrentDirectory());
756 adamjking 599
 
850 adamjking 600
            mruListElement = document
757 adamjking 601
                    .createElement(TAG_HEX_FILE_UPLOAD_GUI_MRU_LIST);
756 adamjking 602
 
757 adamjking 603
            hexFileUploadDeviceManagerGUIelement.appendChild(mruListElement);
756 adamjking 604
 
850 adamjking 605
            it = HexFileUploadGUI.getMRU().iterator();
756 adamjking 606
 
757 adamjking 607
            while (it.hasNext()) {
756 adamjking 608
 
757 adamjking 609
                Element mru = document
610
                        .createElement(TAG_HEX_FILE_UPLOAD_GUI_MRU);
741 adamjking 611
 
757 adamjking 612
                mruListElement.appendChild(mru);
741 adamjking 613
 
757 adamjking 614
                mru.setTextContent((String) it.next());
615
            }
741 adamjking 616
 
757 adamjking 617
            Element workSpaceCurrentDirectory = document
618
                    .createElement(TAG_WORKSPACE_CURRENT_DIRECTORY);
741 adamjking 619
 
757 adamjking 620
            rootElement.appendChild(workSpaceCurrentDirectory);
741 adamjking 621
 
757 adamjking 622
            workSpaceCurrentDirectory.setTextContent(MIOSStudioGUI
623
                    .getCurrentDirectory());
756 adamjking 624
 
757 adamjking 625
            mruListElement = document.createElement(TAG_WORKSPACE_MRU_LIST);
756 adamjking 626
 
757 adamjking 627
            rootElement.appendChild(mruListElement);
756 adamjking 628
 
757 adamjking 629
            it = miosStudioGUI.getMRU().iterator();
756 adamjking 630
 
757 adamjking 631
            while (it.hasNext()) {
756 adamjking 632
 
757 adamjking 633
                Element mru = document.createElement(TAG_WORKSPACE_MRU);
756 adamjking 634
 
757 adamjking 635
                mruListElement.appendChild(mru);
636
 
637
                mru.setTextContent((String) it.next());
753 adamjking 638
            }
741 adamjking 639
 
757 adamjking 640
            Element midiFilterDeviceManagerGUIelement = document
808 adamjking 641
                    .createElement(TAG_MIDI_FILTER_MANAGER_GUI);
741 adamjking 642
 
757 adamjking 643
            rootElement.appendChild(midiFilterDeviceManagerGUIelement);
741 adamjking 644
 
757 adamjking 645
            Element midiFilterCurrentDirectory = document
646
                    .createElement(TAG_MIDI_FILTER_GUI_CURRENT_DIRECTORY);
741 adamjking 647
 
757 adamjking 648
            midiFilterDeviceManagerGUIelement
649
                    .appendChild(midiFilterCurrentDirectory);
741 adamjking 650
 
757 adamjking 651
            midiFilterCurrentDirectory.setTextContent(MidiFilterGUI
652
                    .getCurrentDirectory());
741 adamjking 653
 
757 adamjking 654
            mruListElement = document
655
                    .createElement(TAG_MIDI_FILTER_GUI_MRU_LIST);
756 adamjking 656
 
757 adamjking 657
            midiFilterDeviceManagerGUIelement.appendChild(mruListElement);
756 adamjking 658
 
757 adamjking 659
            it = MidiFilterGUI.getMRU().iterator();
756 adamjking 660
 
757 adamjking 661
            while (it.hasNext()) {
756 adamjking 662
 
757 adamjking 663
                Element mru = document.createElement(TAG_MIDI_FILTER_GUI_MRU);
756 adamjking 664
 
757 adamjking 665
                mruListElement.appendChild(mru);
756 adamjking 666
 
757 adamjking 667
                mru.setTextContent((String) it.next());
753 adamjking 668
            }
741 adamjking 669
        }
670
    }
671
 
672
    public MIOSStudioGUI getMiosStudioGUI() {
673
        return miosStudioGUI;
674
    }
675
 
676
    protected void saveInternalFrame(JInternalFrame internalFrame,
677
            Element internalFrameElement) {
678
 
679
        internalFrameElement.setAttribute(ATTR_TITLE, internalFrame.getTitle());
680
 
681
        internalFrameElement.setAttribute(ATTR_POS_X, intToString(internalFrame
682
                .getX()));
683
 
684
        internalFrameElement.setAttribute(ATTR_POS_Y, intToString(internalFrame
685
                .getY()));
686
 
687
        internalFrameElement.setAttribute(ATTR_WIDTH, intToString(internalFrame
688
                .getWidth()));
689
 
690
        internalFrameElement.setAttribute(ATTR_HEIGHT,
691
                intToString(internalFrame.getHeight()));
692
 
693
        internalFrameElement.setAttribute(ATTR_VISIBLE,
694
                booleanToString(internalFrame.isVisible()));
695
 
696
        internalFrameElement.setAttribute(ATTR_ICONIFIED,
697
                booleanToString(internalFrame.isIcon()));
698
 
699
        internalFrameElement.setAttribute(ATTR_MAXIMIZED,
700
                booleanToString(internalFrame.isMaximum()));
701
    }
702
 
703
    protected JInternalFrame findInternalFrame(String name) {
704
 
705
        Iterator it = miosStudioGUI.getInternalFrames().iterator();
706
 
707
        while (it.hasNext()) {
708
 
709
            JInternalFrame internalFrame = (JInternalFrame) it.next();
710
 
711
            if (internalFrame.getTitle().equals(name)) {
712
 
713
                return internalFrame;
714
            }
715
        }
716
 
717
        return null;
718
    }
719
}