Subversion Repositories svn.mios

Compare Revisions

Ignore whitespace Rev 756 → Rev 757

/trunk/java/org/midibox/utils/xml/XMLUtils.java
127,6 → 127,44
node.appendChild(rootElement);
}
 
public static boolean containsTag(File file, String tag) {
 
DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory
.newInstance();
 
try {
 
DocumentBuilder documentBuilder = documentBuilderFactory
.newDocumentBuilder();
 
Document document = documentBuilder.parse(file);
 
return containsTag(document, tag);
 
} catch (Exception e) {
e.printStackTrace();
return false;
}
}
 
public static boolean containsTag(Node node, String tag) {
 
if (node.getNodeName().equals(tag)) {
return true;
}
 
NodeList children = node.getChildNodes();
 
for (int n = 0; n < children.getLength(); n++) {
 
if (containsTag(children.item(n), tag)) {
return true;
}
}
 
return false;
}
 
protected String intToString(int i) {
 
return "" + i;
146,9 → 184,9
 
return Boolean.parseBoolean(string);
}
 
protected void addTag(String tag) {
 
tags.add(tag);
}
}
/trunk/java/org/midibox/apps/miosstudio/gui/xml/MIOSStudioGUIXML.java
87,25 → 87,35
 
protected boolean includeGUI;
 
protected boolean includeExternalCommands;
 
protected boolean includeLookAndFeel;
 
protected boolean includeMRU;
 
public MIOSStudioGUIXML(MIOSStudio miosStudio, String rootElementTag,
boolean includeModel, boolean includeGUI, boolean includeMRU) {
boolean includeModel, boolean includeGUI,
boolean includeExternalCommands, boolean includeLookAndFeel,
boolean includeMRU) {
 
this(null, miosStudio, rootElementTag, includeModel, includeGUI,
includeMRU);
includeExternalCommands, includeLookAndFeel, includeMRU);
}
 
public MIOSStudioGUIXML(MIOSStudioGUI miosStudioGUI, String rootElementTag,
boolean includeModel, boolean includeGUI, boolean includeMRU) {
boolean includeModel, boolean includeGUI,
boolean includeExternalCommands, boolean includeLookAndFeel,
boolean includeMRU) {
 
this(miosStudioGUI, miosStudioGUI.getMiosStudio(), rootElementTag,
includeModel, includeGUI, includeMRU);
includeModel, includeGUI, includeExternalCommands,
includeLookAndFeel, includeMRU);
}
 
public MIOSStudioGUIXML(MIOSStudioGUI miosStudioGUI, MIOSStudio miosStudio,
String rootElementTag, boolean includeModel, boolean includeGUI,
boolean includeMRU) {
protected MIOSStudioGUIXML(MIOSStudioGUI miosStudioGUI,
MIOSStudio miosStudio, String rootElementTag, boolean includeModel,
boolean includeGUI, boolean includeExternalCommands,
boolean includeLookAndFeel, boolean includeMRU) {
 
super(rootElementTag);
 
117,6 → 127,10
 
this.includeGUI = includeGUI;
 
this.includeExternalCommands = includeExternalCommands;
 
this.includeLookAndFeel = includeLookAndFeel;
 
this.includeMRU = includeMRU;
 
if (includeModel) {
126,14 → 140,22
 
if (includeGUI) {
 
addTag(TAG_LOOK_AND_FEEL);
addTag(TAG_MAIN_WINDOW);
addTag(TAG_INTERNAL_FRAMES);
addTag(TAG_HEX_FILE_UPLOAD_DEVICE_MANAGER_GUI);
}
 
if (includeExternalCommands) {
 
addTag(TAG_EXTERNAL_COMMANDS);
addTag(TAG_EXTERNAL_COMMAND);
addTag(TAG_HEX_FILE_UPLOAD_DEVICE_MANAGER_GUI);
}
 
if (includeLookAndFeel) {
 
addTag(TAG_LOOK_AND_FEEL);
}
 
if (includeMRU) {
 
addTag(TAG_WORKSPACE_CURRENT_DIRECTORY);
351,6 → 373,8
 
super.saveXML(node);
 
Element hexFileUploadDeviceManagerGUIelement = null;
 
if (includeModel) {
 
MIOSStudioXML miosStudioXML = new MIOSStudioXML(miosStudio,
359,6 → 383,16
miosStudioXML.saveXML(rootElement);
}
 
if (includeLookAndFeel) {
 
Element lookAndFeelElement = document
.createElement(TAG_LOOK_AND_FEEL);
 
rootElement.appendChild(lookAndFeelElement);
 
lookAndFeelElement.setTextContent(miosStudioGUI.getLookAndFeel());
}
 
if (includeGUI) {
 
JFrame mainWindow = DialogOwner.getFrame();
383,13 → 417,6
intToString(mainWindow.getHeight()));
}
 
Element lookAndFeelElement = document
.createElement(TAG_LOOK_AND_FEEL);
 
rootElement.appendChild(lookAndFeelElement);
 
lookAndFeelElement.setTextContent(miosStudioGUI.getLookAndFeel());
 
Element internalFramesElement = document
.createElement(TAG_INTERNAL_FRAMES);
 
429,12 → 456,26
saveInternalFrame(internalFrame, internalFrameElement);
}
 
hexFileUploadDeviceManagerGUIelement = document
.createElement(TAG_HEX_FILE_UPLOAD_DEVICE_MANAGER_GUI);
 
rootElement.appendChild(hexFileUploadDeviceManagerGUIelement);
 
hexFileUploadDeviceManagerGUIelement.setAttribute(
ATTR_SELECTED_TAB, intToString(miosStudioGUI
.getHexFileUploadDeviceManagerGUI().getTabbedPane()
.getSelectedIndex()));
 
}
 
if (includeExternalCommands) {
 
Element externalCommandsElement = document
.createElement(TAG_EXTERNAL_COMMANDS);
 
rootElement.appendChild(externalCommandsElement);
 
it = miosStudioGUI.getExternalCommands().iterator();
Iterator it = miosStudioGUI.getExternalCommands().iterator();
 
while (it.hasNext()) {
 
452,104 → 493,94
externalCommandElement.setAttribute(ATTR_EXTERNAL_COMMAND,
externalCommandButton.externalCommand);
}
}
 
if (includeMRU) {
if (includeMRU) {
 
Element workSpaceCurrentDirectory = document
.createElement(TAG_WORKSPACE_CURRENT_DIRECTORY);
Element hexFileCurrentDirectoryElement = document
.createElement(TAG_HEX_FILE_UPLOAD_GUI_CURRENT_DIRECTORY);
 
rootElement.appendChild(workSpaceCurrentDirectory);
if (hexFileUploadDeviceManagerGUIelement == null) {
hexFileUploadDeviceManagerGUIelement = document
.createElement(TAG_HEX_FILE_UPLOAD_DEVICE_MANAGER_GUI);
 
workSpaceCurrentDirectory.setTextContent(MIOSStudioGUI
.getCurrentDirectory());
rootElement.appendChild(hexFileUploadDeviceManagerGUIelement);
}
 
Element mruListElement = document
.createElement(TAG_WORKSPACE_MRU_LIST);
hexFileUploadDeviceManagerGUIelement
.appendChild(hexFileCurrentDirectoryElement);
 
rootElement.appendChild(mruListElement);
hexFileCurrentDirectoryElement.setTextContent(HexFileUploadGUI
.getCurrentDirectory());
 
it = miosStudioGUI.getMRU().iterator();
Element mruListElement = document
.createElement(TAG_HEX_FILE_UPLOAD_GUI_MRU_LIST);
 
while (it.hasNext()) {
hexFileUploadDeviceManagerGUIelement.appendChild(mruListElement);
 
Element mru = document.createElement(TAG_WORKSPACE_MRU);
Iterator it = HexFileUploadGUI.getMRU().iterator();
 
mruListElement.appendChild(mru);
while (it.hasNext()) {
 
mru.setTextContent((String) it.next());
}
Element mru = document
.createElement(TAG_HEX_FILE_UPLOAD_GUI_MRU);
 
Element midiFilterDeviceManagerGUIelement = document
.createElement(TAG_MIDI_FILTER_DEVICE_MANAGER_GUI);
mruListElement.appendChild(mru);
 
rootElement.appendChild(midiFilterDeviceManagerGUIelement);
mru.setTextContent((String) it.next());
}
 
Element midiFilterCurrentDirectory = document
.createElement(TAG_MIDI_FILTER_GUI_CURRENT_DIRECTORY);
Element workSpaceCurrentDirectory = document
.createElement(TAG_WORKSPACE_CURRENT_DIRECTORY);
 
midiFilterDeviceManagerGUIelement
.appendChild(midiFilterCurrentDirectory);
rootElement.appendChild(workSpaceCurrentDirectory);
 
midiFilterCurrentDirectory.setTextContent(MidiFilterGUI
.getCurrentDirectory());
mruListElement = document
.createElement(TAG_MIDI_FILTER_GUI_MRU_LIST);
workSpaceCurrentDirectory.setTextContent(MIOSStudioGUI
.getCurrentDirectory());
 
midiFilterDeviceManagerGUIelement.appendChild(mruListElement);
mruListElement = document.createElement(TAG_WORKSPACE_MRU_LIST);
 
it = MidiFilterGUI.getMRU().iterator();
rootElement.appendChild(mruListElement);
 
while (it.hasNext()) {
it = miosStudioGUI.getMRU().iterator();
 
Element mru = document
.createElement(TAG_MIDI_FILTER_GUI_MRU);
while (it.hasNext()) {
 
mruListElement.appendChild(mru);
Element mru = document.createElement(TAG_WORKSPACE_MRU);
 
mru.setTextContent((String) it.next());
}
mruListElement.appendChild(mru);
 
mru.setTextContent((String) it.next());
}
 
Element hexFileUploadDeviceManagerGUIelement = document
.createElement(TAG_HEX_FILE_UPLOAD_DEVICE_MANAGER_GUI);
Element midiFilterDeviceManagerGUIelement = document
.createElement(TAG_MIDI_FILTER_DEVICE_MANAGER_GUI);
 
rootElement.appendChild(hexFileUploadDeviceManagerGUIelement);
rootElement.appendChild(midiFilterDeviceManagerGUIelement);
 
hexFileUploadDeviceManagerGUIelement.setAttribute(
ATTR_SELECTED_TAB, intToString(miosStudioGUI
.getHexFileUploadDeviceManagerGUI().getTabbedPane()
.getSelectedIndex()));
Element midiFilterCurrentDirectory = document
.createElement(TAG_MIDI_FILTER_GUI_CURRENT_DIRECTORY);
 
if (includeMRU) {
midiFilterDeviceManagerGUIelement
.appendChild(midiFilterCurrentDirectory);
 
midiFilterCurrentDirectory.setTextContent(MidiFilterGUI
.getCurrentDirectory());
 
Element hexFileCurrentDirectoryElement = document
.createElement(TAG_HEX_FILE_UPLOAD_GUI_CURRENT_DIRECTORY);
mruListElement = document
.createElement(TAG_MIDI_FILTER_GUI_MRU_LIST);
 
hexFileUploadDeviceManagerGUIelement
.appendChild(hexFileCurrentDirectoryElement);
midiFilterDeviceManagerGUIelement.appendChild(mruListElement);
 
hexFileCurrentDirectoryElement.setTextContent(HexFileUploadGUI
.getCurrentDirectory());
Element mruListElement = document
.createElement(TAG_HEX_FILE_UPLOAD_GUI_MRU_LIST);
it = MidiFilterGUI.getMRU().iterator();
 
hexFileUploadDeviceManagerGUIelement
.appendChild(mruListElement);
while (it.hasNext()) {
 
it = HexFileUploadGUI.getMRU().iterator();
Element mru = document.createElement(TAG_MIDI_FILTER_GUI_MRU);
 
while (it.hasNext()) {
mruListElement.appendChild(mru);
 
Element mru = document
.createElement(TAG_HEX_FILE_UPLOAD_GUI_MRU);
 
mruListElement.appendChild(mru);
 
mru.setTextContent((String) it.next());
}
mru.setTextContent((String) it.next());
}
}
}
/trunk/java/org/midibox/apps/miosstudio/gui/MIOSStudioGUI.java
50,6 → 50,7
import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JCheckBoxMenuItem;
import javax.swing.JComponent;
import javax.swing.JDesktopPane;
76,6 → 77,7
 
import org.midibox.apps.miosstudio.MIOSStudio;
import org.midibox.apps.miosstudio.gui.xml.MIOSStudioGUIXML;
import org.midibox.apps.miosstudio.xml.MIOSStudioXML;
import org.midibox.midi.MidiFilterDevice;
import org.midibox.midi.MidiKeyboardControllerDevice;
import org.midibox.midi.MidiRouterDevice;
196,7 → 198,7
private JMenu MRUMenu;
 
private JPopupMenu MRUPopupMenu;
 
private SplitButton openMRUButton;
 
private static int maxMRU = 10;
816,7 → 818,7
 
openMRUButton = new SplitButton(button, MRUPopupMenu);
openMRUButton.setRollover(true);
 
toolBar.add(openMRUButton);
 
button = new JButton(ImageLoader.getImageIcon("save.png"));
1121,7 → 1123,8
* midiMapManagerDialog.addWindowListener(new WindowAdapter() { public void
* windowClosing(WindowEvent we) {
* midiDeviceRouting.getMidiMapManager().deleteObserver( midiMapManagerGUI);
* midiMapManagerDialog = null; } }); } midiMapManagerDialog.requestFocus(); }
* midiMapManagerDialog = null; } }); } midiMapManagerDialog.requestFocus();
* }
*/
 
private void buildMRUMenu(JComponent menu) {
1254,9 → 1257,8
final File file = fc.getSelectedFile();
 
openWorkspace(file);
currentDirectory = fc.getCurrentDirectory()
.toString();
 
currentDirectory = fc.getCurrentDirectory().toString();
}
}
 
1268,6 → 1270,26
 
final WorkspaceOptionDialog workspaceOptionDialog = new WorkspaceOptionDialog();
 
Boolean bool = MIOSStudioGUIXML.containsTag(file,
MIOSStudioXML.TAG_ROOT_ELEMENT);
workspaceOptionDialog.modelCheckBox.setEnabled(bool);
workspaceOptionDialog.modelCheckBox.setSelected(bool);
 
bool = MIOSStudioGUIXML.containsTag(file,
MIOSStudioGUIXML.TAG_INTERNAL_FRAMES);
workspaceOptionDialog.guiCheckBox.setEnabled(bool);
workspaceOptionDialog.guiCheckBox.setSelected(bool);
 
bool = MIOSStudioGUIXML.containsTag(file,
MIOSStudioGUIXML.TAG_EXTERNAL_COMMANDS);
workspaceOptionDialog.externalCommandsCheckBox.setEnabled(bool);
workspaceOptionDialog.externalCommandsCheckBox.setSelected(bool);
 
bool = MIOSStudioGUIXML.containsTag(file,
MIOSStudioGUIXML.TAG_LOOK_AND_FEEL);
workspaceOptionDialog.lookAndFeelCheckBox.setEnabled(bool);
workspaceOptionDialog.lookAndFeelCheckBox.setSelected(bool);
 
workspaceOptionDialog.pack();
 
workspaceOptionDialog.okButton
1277,35 → 1299,20
 
workspaceOptionDialog.setVisible(false);
 
boolean gui;
 
boolean model;
 
if (workspaceOptionDialog.guiRadioButton
.isSelected()) {
 
gui = true;
model = false;
 
} else if (workspaceOptionDialog.modelRadioButton
.isSelected()) {
 
gui = false;
model = true;
 
} else {
 
gui = true;
model = true;
}
 
MIOSStudioGUIXML miosStudioGUIXML = new MIOSStudioGUIXML(
MIOSStudioGUI.this,
MIOSStudioGUIXML.TAG_ROOT_ELEMENT, model,
gui, false);
MIOSStudioGUIXML.TAG_ROOT_ELEMENT,
workspaceOptionDialog.modelCheckBox
.isSelected(),
workspaceOptionDialog.guiCheckBox
.isSelected(),
workspaceOptionDialog.externalCommandsCheckBox
.isSelected(),
workspaceOptionDialog.lookAndFeelCheckBox
.isSelected(), false);
 
miosStudioGUIXML.loadXML(file);
 
}
});
 
1367,32 → 1374,17
 
workspaceOptionDialog.setVisible(false);
 
boolean gui;
 
boolean model;
 
if (workspaceOptionDialog.guiRadioButton
.isSelected()) {
 
gui = true;
model = false;
 
} else if (workspaceOptionDialog.modelRadioButton
.isSelected()) {
 
gui = false;
model = true;
 
} else {
 
gui = true;
model = true;
}
 
MIOSStudioGUIXML miosStudioGUIXML = new MIOSStudioGUIXML(
MIOSStudioGUI.this,
MIOSStudioGUIXML.TAG_ROOT_ELEMENT, model,
gui, false);
MIOSStudioGUIXML.TAG_ROOT_ELEMENT,
workspaceOptionDialog.modelCheckBox
.isSelected(),
workspaceOptionDialog.guiCheckBox
.isSelected(),
workspaceOptionDialog.externalCommandsCheckBox
.isSelected(),
workspaceOptionDialog.lookAndFeelCheckBox
.isSelected(), false);
 
miosStudioGUIXML.saveXML(file);
 
1779,12 → 1771,16
 
class WorkspaceOptionDialog extends JDialog {
 
ButtonGroup buttonGroup;
File file;
 
JRadioButton modelRadioButton;
JCheckBox modelCheckBox;
 
JRadioButton guiRadioButton;
JCheckBox guiCheckBox;
 
JCheckBox externalCommandsCheckBox;
 
JCheckBox lookAndFeelCheckBox;
 
JButton okButton;
 
public WorkspaceOptionDialog() {
1806,22 → 1802,21
panel.add(label, gbc);
gbc.gridy++;
 
buttonGroup = new ButtonGroup();
modelCheckBox = new JCheckBox("MIOS Studio setup", true);
panel.add(modelCheckBox, gbc);
gbc.gridy++;
 
JRadioButton radioButton = new JRadioButton(
"Graphical layout and MIOS Studio setup", true);
panel.add(radioButton, gbc);
buttonGroup.add(radioButton);
guiCheckBox = new JCheckBox("Graphical layout", true);
panel.add(guiCheckBox, gbc);
gbc.gridy++;
 
guiRadioButton = new JRadioButton("Graphical layout only", false);
panel.add(guiRadioButton, gbc);
buttonGroup.add(guiRadioButton);
externalCommandsCheckBox = new JCheckBox(
"External Command buttons", true);
panel.add(externalCommandsCheckBox, gbc);
gbc.gridy++;
 
modelRadioButton = new JRadioButton("MIOS Studio setup only", false);
panel.add(modelRadioButton, gbc);
buttonGroup.add(modelRadioButton);
lookAndFeelCheckBox = new JCheckBox("Look & Feel", true);
panel.add(lookAndFeelCheckBox, gbc);
gbc.gridy++;
 
gbc.anchor = (GridBagConstraints.CENTER);
/trunk/java/org/midibox/apps/miosstudiosid/gui/xml/MIOSStudioSIDGUIXML.java
6,24 → 6,34
 
public class MIOSStudioSIDGUIXML extends MIOSStudioGUIXML {
 
public MIOSStudioSIDGUIXML(MIOSStudioSID miosStudioSID, String rootElementTag,
boolean includeModel, boolean includeGUI, boolean includeMRU) {
super(miosStudioSID, rootElementTag, includeModel, includeGUI, includeMRU);
public MIOSStudioSIDGUIXML(MIOSStudioSID miosStudioSID,
String rootElementTag, boolean includeModel, boolean includeGUI,
boolean includeExternalCommands, boolean includeLookAndFeel,
boolean includeMRU) {
super(miosStudioSID, rootElementTag, includeModel, includeGUI,
includeExternalCommands, includeLookAndFeel, includeMRU);
}
 
public MIOSStudioSIDGUIXML(MIOSStudioSIDGUI miosStudioSIDGUI,
String rootElementTag, boolean includeModel, boolean includeGUI, boolean includeMRU) {
super(miosStudioSIDGUI, rootElementTag, includeModel, includeGUI, includeMRU);
String rootElementTag, boolean includeModel, boolean includeGUI,
boolean includeExternalCommands, boolean includeLookAndFeel,
boolean includeMRU) {
super(miosStudioSIDGUI, rootElementTag, includeModel, includeGUI,
includeExternalCommands, includeLookAndFeel, includeMRU);
}
 
public MIOSStudioSIDGUIXML(MIOSStudioSIDGUI miosStudioSIDGUI,
MIOSStudioSID miosStudioSID, String rootElementTag, boolean includeModel,
boolean includeGUI, boolean includeMRU) {
super(miosStudioSIDGUI, miosStudioSID, rootElementTag, includeModel, includeGUI, includeMRU);
protected MIOSStudioSIDGUIXML(MIOSStudioSIDGUI miosStudioSIDGUI,
MIOSStudioSID miosStudioSID, String rootElementTag,
boolean includeModel, boolean includeGUI,
boolean includeExternalCommands, boolean includeLookAndFeel,
boolean includeMRU) {
super(miosStudioSIDGUI, miosStudioSID, rootElementTag, includeModel,
includeGUI, includeExternalCommands, includeLookAndFeel,
includeMRU);
}
 
protected void createGUI() {
 
this.miosStudioGUI = new MIOSStudioSIDGUI((MIOSStudioSID) miosStudio);
}
}
}