Subversion Repositories svn.mios

Rev

Rev 800 | Rev 850 | 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());
741 adamjking 398
        }
399
    }
400
 
401
    public void saveXML(Node node) {
402
 
403
        super.saveXML(node);
404
 
800 adamjking 405
        Element sysexSendReceiveDeviceManagerGUIelement = null;
406
 
757 adamjking 407
        Element hexFileUploadDeviceManagerGUIelement = null;
408
 
741 adamjking 409
        if (includeModel) {
410
 
411
            MIOSStudioXML miosStudioXML = new MIOSStudioXML(miosStudio,
412
                    MIOSStudioXML.TAG_ROOT_ELEMENT);
413
 
414
            miosStudioXML.saveXML(rootElement);
415
        }
416
 
757 adamjking 417
        if (includeLookAndFeel) {
418
 
419
            Element lookAndFeelElement = document
420
                    .createElement(TAG_LOOK_AND_FEEL);
421
 
422
            rootElement.appendChild(lookAndFeelElement);
423
 
424
            lookAndFeelElement.setTextContent(miosStudioGUI.getLookAndFeel());
425
        }
426
 
741 adamjking 427
        if (includeGUI) {
428
 
429
            JFrame mainWindow = DialogOwner.getFrame();
430
 
431
            if (mainWindow != null) {
432
 
433
                Element mainWindowElement = document
434
                        .createElement(TAG_MAIN_WINDOW);
435
 
436
                rootElement.appendChild(mainWindowElement);
437
 
438
                mainWindowElement.setAttribute(ATTR_POS_X,
439
                        intToString(mainWindow.getX()));
440
 
441
                mainWindowElement.setAttribute(ATTR_POS_Y,
442
                        intToString(mainWindow.getY()));
443
 
444
                mainWindowElement.setAttribute(ATTR_WIDTH,
445
                        intToString(mainWindow.getWidth()));
446
 
447
                mainWindowElement.setAttribute(ATTR_HEIGHT,
448
                        intToString(mainWindow.getHeight()));
449
            }
450
 
451
            Element internalFramesElement = document
452
                    .createElement(TAG_INTERNAL_FRAMES);
453
 
454
            rootElement.appendChild(internalFramesElement);
455
 
456
            Vector internalFrames = (Vector) miosStudioGUI.getInternalFrames()
457
                    .clone();
458
 
459
            JInternalFrame[] visibleInternalFrames = miosStudioGUI.getDesktop()
460
                    .getAllFrames();
461
 
462
            for (int i = 0; i < visibleInternalFrames.length; i++) {
463
 
464
                JInternalFrame internalFrame = visibleInternalFrames[i];
465
 
466
                Element internalFrameElement = document
467
                        .createElement(TAG_INTERNAL_FRAME);
468
 
469
                internalFramesElement.appendChild(internalFrameElement);
470
 
471
                saveInternalFrame(internalFrame, internalFrameElement);
472
 
473
                internalFrames.remove(internalFrame);
474
            }
475
 
476
            Iterator it = internalFrames.iterator();
477
 
478
            while (it.hasNext()) {
479
 
480
                JInternalFrame internalFrame = (JInternalFrame) it.next();
481
 
482
                Element internalFrameElement = document
483
                        .createElement(TAG_INTERNAL_FRAME);
484
 
485
                internalFramesElement.appendChild(internalFrameElement);
486
 
487
                saveInternalFrame(internalFrame, internalFrameElement);
488
            }
489
 
800 adamjking 490
            sysexSendReceiveDeviceManagerGUIelement = document
808 adamjking 491
                    .createElement(TAG_SYSEX_SEND_RECEIVE_MANAGER_GUI);
800 adamjking 492
 
493
            rootElement.appendChild(sysexSendReceiveDeviceManagerGUIelement);
494
 
495
            sysexSendReceiveDeviceManagerGUIelement.setAttribute(
496
                    ATTR_SELECTED_TAB, intToString(miosStudioGUI
497
                            .getSysexSendReceiveDeviceManagerGUI()
498
                            .getTabbedPane().getSelectedIndex()));
499
 
757 adamjking 500
            hexFileUploadDeviceManagerGUIelement = document
808 adamjking 501
                    .createElement(TAG_HEX_FILE_UPLOAD_MANAGER_GUI);
757 adamjking 502
 
503
            rootElement.appendChild(hexFileUploadDeviceManagerGUIelement);
504
 
505
            hexFileUploadDeviceManagerGUIelement.setAttribute(
506
                    ATTR_SELECTED_TAB, intToString(miosStudioGUI
507
                            .getHexFileUploadDeviceManagerGUI().getTabbedPane()
508
                            .getSelectedIndex()));
509
 
510
        }
511
 
512
        if (includeExternalCommands) {
513
 
741 adamjking 514
            Element externalCommandsElement = document
515
                    .createElement(TAG_EXTERNAL_COMMANDS);
516
 
517
            rootElement.appendChild(externalCommandsElement);
518
 
757 adamjking 519
            Iterator it = miosStudioGUI.getExternalCommands().iterator();
741 adamjking 520
 
521
            while (it.hasNext()) {
522
 
523
                ExternalCommandButton externalCommandButton = (ExternalCommandButton) it
524
                        .next();
525
 
526
                Element externalCommandElement = document
527
                        .createElement(TAG_EXTERNAL_COMMAND);
528
 
529
                externalCommandsElement.appendChild(externalCommandElement);
530
 
531
                externalCommandElement.setAttribute(ATTR_COMMAND_NAME,
532
                        externalCommandButton.commandName);
533
 
534
                externalCommandElement.setAttribute(ATTR_EXTERNAL_COMMAND,
535
                        externalCommandButton.externalCommand);
536
            }
757 adamjking 537
        }
741 adamjking 538
 
757 adamjking 539
        if (includeMRU) {
741 adamjking 540
 
800 adamjking 541
            Element sysexSendReceiveCurrentDirectoryElement = document
542
                    .createElement(TAG_SYSEX_SEND_RECEIVE_GUI_CURRENT_DIRECTORY);
543
 
544
            if (sysexSendReceiveDeviceManagerGUIelement == null) {
545
                sysexSendReceiveDeviceManagerGUIelement = document
808 adamjking 546
                        .createElement(TAG_SYSEX_SEND_RECEIVE_MANAGER_GUI);
800 adamjking 547
 
548
                rootElement
549
                        .appendChild(sysexSendReceiveDeviceManagerGUIelement);
550
            }
551
 
552
            sysexSendReceiveDeviceManagerGUIelement
553
                    .appendChild(sysexSendReceiveCurrentDirectoryElement);
554
 
555
            sysexSendReceiveCurrentDirectoryElement
556
                    .setTextContent(SysexSendReceiveGUI.getCurrentDirectory());
557
 
757 adamjking 558
            Element hexFileCurrentDirectoryElement = document
559
                    .createElement(TAG_HEX_FILE_UPLOAD_GUI_CURRENT_DIRECTORY);
741 adamjking 560
 
757 adamjking 561
            if (hexFileUploadDeviceManagerGUIelement == null) {
562
                hexFileUploadDeviceManagerGUIelement = document
808 adamjking 563
                        .createElement(TAG_HEX_FILE_UPLOAD_MANAGER_GUI);
756 adamjking 564
 
757 adamjking 565
                rootElement.appendChild(hexFileUploadDeviceManagerGUIelement);
566
            }
756 adamjking 567
 
757 adamjking 568
            hexFileUploadDeviceManagerGUIelement
569
                    .appendChild(hexFileCurrentDirectoryElement);
756 adamjking 570
 
757 adamjking 571
            hexFileCurrentDirectoryElement.setTextContent(HexFileUploadGUI
572
                    .getCurrentDirectory());
756 adamjking 573
 
757 adamjking 574
            Element mruListElement = document
575
                    .createElement(TAG_HEX_FILE_UPLOAD_GUI_MRU_LIST);
756 adamjking 576
 
757 adamjking 577
            hexFileUploadDeviceManagerGUIelement.appendChild(mruListElement);
756 adamjking 578
 
757 adamjking 579
            Iterator it = HexFileUploadGUI.getMRU().iterator();
756 adamjking 580
 
757 adamjking 581
            while (it.hasNext()) {
756 adamjking 582
 
757 adamjking 583
                Element mru = document
584
                        .createElement(TAG_HEX_FILE_UPLOAD_GUI_MRU);
741 adamjking 585
 
757 adamjking 586
                mruListElement.appendChild(mru);
741 adamjking 587
 
757 adamjking 588
                mru.setTextContent((String) it.next());
589
            }
741 adamjking 590
 
757 adamjking 591
            Element workSpaceCurrentDirectory = document
592
                    .createElement(TAG_WORKSPACE_CURRENT_DIRECTORY);
741 adamjking 593
 
757 adamjking 594
            rootElement.appendChild(workSpaceCurrentDirectory);
741 adamjking 595
 
757 adamjking 596
            workSpaceCurrentDirectory.setTextContent(MIOSStudioGUI
597
                    .getCurrentDirectory());
756 adamjking 598
 
757 adamjking 599
            mruListElement = document.createElement(TAG_WORKSPACE_MRU_LIST);
756 adamjking 600
 
757 adamjking 601
            rootElement.appendChild(mruListElement);
756 adamjking 602
 
757 adamjking 603
            it = miosStudioGUI.getMRU().iterator();
756 adamjking 604
 
757 adamjking 605
            while (it.hasNext()) {
756 adamjking 606
 
757 adamjking 607
                Element mru = document.createElement(TAG_WORKSPACE_MRU);
756 adamjking 608
 
757 adamjking 609
                mruListElement.appendChild(mru);
610
 
611
                mru.setTextContent((String) it.next());
753 adamjking 612
            }
741 adamjking 613
 
757 adamjking 614
            Element midiFilterDeviceManagerGUIelement = document
808 adamjking 615
                    .createElement(TAG_MIDI_FILTER_MANAGER_GUI);
741 adamjking 616
 
757 adamjking 617
            rootElement.appendChild(midiFilterDeviceManagerGUIelement);
741 adamjking 618
 
757 adamjking 619
            Element midiFilterCurrentDirectory = document
620
                    .createElement(TAG_MIDI_FILTER_GUI_CURRENT_DIRECTORY);
741 adamjking 621
 
757 adamjking 622
            midiFilterDeviceManagerGUIelement
623
                    .appendChild(midiFilterCurrentDirectory);
741 adamjking 624
 
757 adamjking 625
            midiFilterCurrentDirectory.setTextContent(MidiFilterGUI
626
                    .getCurrentDirectory());
741 adamjking 627
 
757 adamjking 628
            mruListElement = document
629
                    .createElement(TAG_MIDI_FILTER_GUI_MRU_LIST);
756 adamjking 630
 
757 adamjking 631
            midiFilterDeviceManagerGUIelement.appendChild(mruListElement);
756 adamjking 632
 
757 adamjking 633
            it = MidiFilterGUI.getMRU().iterator();
756 adamjking 634
 
757 adamjking 635
            while (it.hasNext()) {
756 adamjking 636
 
757 adamjking 637
                Element mru = document.createElement(TAG_MIDI_FILTER_GUI_MRU);
756 adamjking 638
 
757 adamjking 639
                mruListElement.appendChild(mru);
756 adamjking 640
 
757 adamjking 641
                mru.setTextContent((String) it.next());
753 adamjking 642
            }
741 adamjking 643
        }
644
    }
645
 
646
    public MIOSStudioGUI getMiosStudioGUI() {
647
        return miosStudioGUI;
648
    }
649
 
650
    protected void saveInternalFrame(JInternalFrame internalFrame,
651
            Element internalFrameElement) {
652
 
653
        internalFrameElement.setAttribute(ATTR_TITLE, internalFrame.getTitle());
654
 
655
        internalFrameElement.setAttribute(ATTR_POS_X, intToString(internalFrame
656
                .getX()));
657
 
658
        internalFrameElement.setAttribute(ATTR_POS_Y, intToString(internalFrame
659
                .getY()));
660
 
661
        internalFrameElement.setAttribute(ATTR_WIDTH, intToString(internalFrame
662
                .getWidth()));
663
 
664
        internalFrameElement.setAttribute(ATTR_HEIGHT,
665
                intToString(internalFrame.getHeight()));
666
 
667
        internalFrameElement.setAttribute(ATTR_VISIBLE,
668
                booleanToString(internalFrame.isVisible()));
669
 
670
        internalFrameElement.setAttribute(ATTR_ICONIFIED,
671
                booleanToString(internalFrame.isIcon()));
672
 
673
        internalFrameElement.setAttribute(ATTR_MAXIMIZED,
674
                booleanToString(internalFrame.isMaximum()));
675
    }
676
 
677
    protected JInternalFrame findInternalFrame(String name) {
678
 
679
        Iterator it = miosStudioGUI.getInternalFrames().iterator();
680
 
681
        while (it.hasNext()) {
682
 
683
            JInternalFrame internalFrame = (JInternalFrame) it.next();
684
 
685
            if (internalFrame.getTitle().equals(name)) {
686
 
687
                return internalFrame;
688
            }
689
        }
690
 
691
        return null;
692
    }
693
}