Subversion Repositories svn.mios

Compare Revisions

Ignore whitespace Rev 752 → Rev 753

/trunk/java/org/midibox/utils/xml/XMLUtils.java
34,7 → 34,7
 
tags = new Vector();
 
tags.add(rootElementTag);
addTag(rootElementTag);
}
 
public void loadXML(File file) {
146,4 → 146,9
 
return Boolean.parseBoolean(string);
}
protected void addTag(String tag) {
tags.add(tag);
}
}
/trunk/java/org/midibox/utils/gui/SplitButton.java
25,10 → 25,8
splitButton.setIcon(icon);
splitButton.addActionListener(this);
splitButton.setFocusPainted(false);
splitButton.setPreferredSize(new Dimension(icon.getIconWidth(),
splitButton.getPreferredSize().height));
splitButton.setMargin(new Insets(2, 0, 2, 0));
setMargin(new Insets(-1, -2, -3, -2));
setOpaque(false);
add(button);
add(splitButton);
}
/trunk/java/org/midibox/midi/gui/MidiFilterGUI.java
29,8 → 29,10
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
import java.util.Iterator;
import java.util.Observable;
import java.util.Observer;
import java.util.Vector;
 
import javax.sound.midi.ShortMessage;
import javax.swing.AbstractCellEditor;
38,11 → 40,17
import javax.swing.Box;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JComponent;
import javax.swing.JFileChooser;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JPopupMenu;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JToolBar;
import javax.swing.event.PopupMenuEvent;
import javax.swing.event.PopupMenuListener;
import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableCellEditor;
50,8 → 58,10
import org.midibox.midi.MidiFilter;
import org.midibox.midi.MidiUtils;
import org.midibox.midi.xml.MidiFilterXML;
import org.midibox.mios.gui.HexFileUploadGUI;
import org.midibox.utils.gui.ImageLoader;
import org.midibox.utils.gui.SimpleFileChooserFilter;
import org.midibox.utils.gui.SplitButton;
 
public class MidiFilterGUI extends JPanel implements Observer, ActionListener {
 
108,8 → 118,16
private JTable channelsTable;
 
private DefaultTableModel channelsModel;
private JPopupMenu MRUPopupMenu;
private SplitButton openMRUButton;
 
private static int maxMRU = 10;
 
private static String currentDirectory = "";
private static Vector MRU = new Vector();
 
private static JFileChooser fc = null;
 
381,8 → 399,29
 
button.setActionCommand("load");
 
toolBar.add(button);
MRUPopupMenu = new JPopupMenu();
MRUPopupMenu.addPopupMenuListener(new PopupMenuListener() {
 
public void popupMenuCanceled(PopupMenuEvent e) {
 
}
 
public void popupMenuWillBecomeInvisible(PopupMenuEvent e) {
 
}
 
public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
 
MidiFilterGUI.this.buildMRUMenu(MRUPopupMenu);
 
}
});
 
openMRUButton = new SplitButton(button, MRUPopupMenu);
openMRUButton.setRollover(true);
toolBar.add(openMRUButton);
 
button = new JButton(ImageLoader.getImageIcon("save.png"));
 
button.setToolTipText("Save MIDI filter definition");
418,17 → 457,72
if (nRetVal == JFileChooser.APPROVE_OPTION) {
File file = fc.getSelectedFile();
 
loadFilterDefinition(file);
 
setButtonStates();
 
currentDirectory = fc.getCurrentDirectory().toString();
}
}
protected void loadFilterDefinition(File file) {
if (file.exists()) {
MidiFilterXML midiFilterXML = new MidiFilterXML(midiFilter,
MidiFilterXML.TAG_ROOT_ELEMENT);
 
midiFilterXML.loadXML(file);
saveMRU(file.getPath());
} else {
JOptionPane.showMessageDialog(this,
"MIDI filter definition no longer exists",
"File does not exist", JOptionPane.ERROR_MESSAGE);
}
}
private void buildMRUMenu(JComponent menu) {
 
setButtonStates();
menu.removeAll();
 
currentDirectory = fc.getCurrentDirectory().toString();
Iterator it = MRU.iterator();
 
while (it.hasNext()) {
 
final JMenuItem menuItem = new JMenuItem((String) it.next());
 
menuItem.addActionListener(new ActionListener() {
 
public void actionPerformed(ActionEvent ae) {
 
File file = new File(menuItem.getText());
 
loadFilterDefinition(file);
}
});
 
menu.add(menuItem, 0);
}
}
public static void saveMRU(String file) {
 
MRU.remove(file);
 
MRU.add(file);
 
for (int i = MRU.size() - maxMRU; i > 0; i--) {
 
MRU.removeElementAt(i - 1);
}
}
public static Vector getMRU() {
return MRU;
}
 
protected void saveFilterDefinition() {
 
if (fc == null) {
454,6 → 548,8
 
midiFilterXML.saveXML(file);
 
saveMRU(file.getPath());
currentDirectory = fc.getCurrentDirectory().toString();
}
}
/trunk/java/org/midibox/midi/xml/MidiParameterControlManagerXML.java
26,7 → 26,7
 
super(rootElementTag);
 
tags.add(TAG_MIDI_PARAMETER_CONTROLS);
addTag(TAG_MIDI_PARAMETER_CONTROLS);
 
this.midiParameterControlManager = midiParameterControlManager;
}
/trunk/java/org/midibox/midi/xml/MidiFilterDeviceManagerXML.java
25,8 → 25,8
 
this.midiFilterDeviceManager = midiFilterDeviceManager;
 
tags.add(TAG_MIDI_FILTER_DEVICES);
tags.add(MidiFilterDeviceXML.TAG_ROOT_ELEMENT);
addTag(TAG_MIDI_FILTER_DEVICES);
addTag(MidiFilterDeviceXML.TAG_ROOT_ELEMENT);
}
 
protected void parseElement(Element element) {
/trunk/java/org/midibox/midi/xml/MidiKeyboardControllerDeviceXML.java
16,7 → 16,7
 
super(midiKeyboardControllerDevice, rootElementTag);
 
tags.add(MidiKeyboardControllerXML.TAG_ROOT_ELEMENT);
addTag(MidiKeyboardControllerXML.TAG_ROOT_ELEMENT);
 
this.midiKeyboardControllerDevice = midiKeyboardControllerDevice;
}
/trunk/java/org/midibox/midi/xml/MidiFilterDeviceXML.java
17,7 → 17,7
 
this.midiFilterDevice = midiFilterDevice;
 
tags.add(MidiFilterXML.TAG_ROOT_ELEMENT);
addTag(MidiFilterXML.TAG_ROOT_ELEMENT);
}
 
protected void parseElement(Element element) {
/trunk/java/org/midibox/midi/xml/MidiFilterXML.java
45,18 → 45,18
 
this.midiFilter = midiFilter;
 
tags.add(TAG_VOICE_MESSAGES);
tags.add(TAG_VOICE_MESSAGE);
tags.add(TAG_CHANNELS);
tags.add(TAG_CHANNEL);
tags.add(TAG_CONTROL_CHANGE_MESSAGES);
tags.add(TAG_CONTROL_CHANGE_MESSAGE);
tags.add(TAG_SYSTEM_COMMON_MESSAGES);
tags.add(TAG_SYSTEM_COMMON_MESSAGE);
tags.add(TAG_SYSTEM_REALTIME_MESSAGES);
tags.add(TAG_SYSTEM_REALTIME_MESSAGE);
tags.add(TAG_SYSEX_MESSAGES);
tags.add(TAG_META_MESSAGES);
addTag(TAG_VOICE_MESSAGES);
addTag(TAG_VOICE_MESSAGE);
addTag(TAG_CHANNELS);
addTag(TAG_CHANNEL);
addTag(TAG_CONTROL_CHANGE_MESSAGES);
addTag(TAG_CONTROL_CHANGE_MESSAGE);
addTag(TAG_SYSTEM_COMMON_MESSAGES);
addTag(TAG_SYSTEM_COMMON_MESSAGE);
addTag(TAG_SYSTEM_REALTIME_MESSAGES);
addTag(TAG_SYSTEM_REALTIME_MESSAGE);
addTag(TAG_SYSEX_MESSAGES);
addTag(TAG_META_MESSAGES);
}
 
protected void parseElement(Element element) {
/trunk/java/org/midibox/midi/xml/MidiMonitorFilteredDeviceXML.java
18,7 → 18,7
 
this.midiMonitorFilteredDevice = midiMonitorFilteredDevice;
 
tags.add(MidiMonitorFilteredXML.TAG_ROOT_ELEMENT);
addTag(MidiMonitorFilteredXML.TAG_ROOT_ELEMENT);
}
 
protected void parseElement(Element element) {
/trunk/java/org/midibox/midi/xml/MidiMonitorFilteredXML.java
18,7 → 18,7
 
this.midiMonitorFiltered = midiMonitorFiltered;
 
tags.add(MidiFilterXML.TAG_ROOT_ELEMENT);
addTag(MidiFilterXML.TAG_ROOT_ELEMENT);
}
 
protected void parseElement(Element element) {
/trunk/java/org/midibox/midi/xml/MidiDeviceRoutingXML.java
33,8 → 33,8
 
this.midiDeviceRouting = midiDeviceRouting;
 
tags.add(TAG_LOGICAL_CONNECTIONS);
tags.add(TAG_LOGICAL_CONNECTION);
addTag(TAG_LOGICAL_CONNECTIONS);
addTag(TAG_LOGICAL_CONNECTION);
}
 
protected void parseElement(Element element) {
/trunk/java/org/midibox/midi/xml/MidiDeviceManagerXML.java
31,10 → 31,10
 
this.midiDeviceManager = midiDeviceManager;
 
tags.add(TAG_DESELECTED_MIDI_READ_DEVICES);
tags.add(TAG_DESELECTED_MIDI_WRITE_DEVICES);
tags.add(TAG_DESELECTED_MIDI_READ_DEVICE);
tags.add(TAG_DESELECTED_MIDI_WRITE_DEVICE);
addTag(TAG_DESELECTED_MIDI_READ_DEVICES);
addTag(TAG_DESELECTED_MIDI_WRITE_DEVICES);
addTag(TAG_DESELECTED_MIDI_READ_DEVICE);
addTag(TAG_DESELECTED_MIDI_WRITE_DEVICE);
}
 
protected void parseElement(Element element) {
/trunk/java/org/midibox/apps/miosstudio/xml/MIOSStudioXML.java
52,17 → 52,17
 
this.miosStudio = miosStudio;
 
tags.add(TAG_MIDI_THRU_FILTER_DEVICE);
tags.add(TAG_MIDI_DEVICE_MANAGER);
tags.add(TAG_MIDI_FILTER_DEVICE_MANAGER);
tags.add(TAG_OUT_PORT_MIDI_MONITOR_FILTERED_DEVICE);
tags.add(TAG_IN_PORT_MIDI_MONITOR_FILTERED_DEVICE);
tags.add(TAG_MIDI_KEYBOARD_CONTROLLER_DEVICE);
tags.add(TAG_HEX_FILE_UPLOAD_DEVICE_MANAGER);
tags.add(TAG_LCD_MESSAGE_DEVICE);
tags.add(TAG_DEBUG_FUNCTION_DEVICE);
tags.add(TAG_MIOS_TERMINAL_MIDI_MONITOR_FILTERED_DEVICE);
tags.add(TAG_MIDI_DEVICE_ROUTING);
addTag(TAG_MIDI_THRU_FILTER_DEVICE);
addTag(TAG_MIDI_DEVICE_MANAGER);
addTag(TAG_MIDI_FILTER_DEVICE_MANAGER);
addTag(TAG_OUT_PORT_MIDI_MONITOR_FILTERED_DEVICE);
addTag(TAG_IN_PORT_MIDI_MONITOR_FILTERED_DEVICE);
addTag(TAG_MIDI_KEYBOARD_CONTROLLER_DEVICE);
addTag(TAG_HEX_FILE_UPLOAD_DEVICE_MANAGER);
addTag(TAG_LCD_MESSAGE_DEVICE);
addTag(TAG_DEBUG_FUNCTION_DEVICE);
addTag(TAG_MIOS_TERMINAL_MIDI_MONITOR_FILTERED_DEVICE);
addTag(TAG_MIDI_DEVICE_ROUTING);
}
 
protected void parseElement(Element element) {
/trunk/java/org/midibox/apps/miosstudio/gui/xml/MIOSStudioGUIXML.java
43,7 → 43,19
 
public final static String TAG_HEX_FILE_UPLOAD_DEVICE_MANAGER_GUI = "hexFileUploadDeviceManagerGUI";
 
public final static String TAG_HEX_FILE_GUI_CURRENT_DIRECTORY = "hexFileGUICurrentDirectory";
public final static String TAG_HEX_FILE_UPLOAD_GUI_CURRENT_DIRECTORY = "hexFileUploadGUICurrentDirectory";
public final static String TAG_WORKSPACE_MRU_LIST = "workspaceMRUList";
public final static String TAG_WORKSPACE_MRU = "workspaceMRU";
public final static String TAG_MIDI_FILTER_GUI_MRU_LIST = "midiFilterGUIMRUList";
public final static String TAG_MIDI_FILTER_GUI_MRU = "midiFilterGUIMRU";
public final static String TAG_HEX_FILE_UPLOAD_GUI_MRU_LIST = "hexFileUploadGUIMRUList";
public final static String TAG_HEX_FILE_UPLOAD_GUI_MRU = "hexFileUploadGUIMRU";
 
public final static String ATTR_TITLE = "title";
 
74,22 → 86,24
protected boolean includeModel;
 
protected boolean includeGUI;
protected boolean includeMRU;
 
public MIOSStudioGUIXML(MIOSStudio miosStudio, String rootElementTag,
boolean includeModel, boolean includeGUI) {
boolean includeModel, boolean includeGUI, boolean includeMRU) {
 
this(null, miosStudio, rootElementTag, includeModel, includeGUI);
this(null, miosStudio, rootElementTag, includeModel, includeGUI, includeMRU);
}
 
public MIOSStudioGUIXML(MIOSStudioGUI miosStudioGUI, String rootElementTag,
boolean includeModel, boolean includeGUI) {
boolean includeModel, boolean includeGUI, boolean includeMRU) {
 
this(miosStudioGUI, miosStudioGUI.getMiosStudio(), rootElementTag,
includeModel, includeGUI);
includeModel, includeGUI, includeMRU);
}
 
public MIOSStudioGUIXML(MIOSStudioGUI miosStudioGUI, MIOSStudio miosStudio,
String rootElementTag, boolean includeModel, boolean includeGUI) {
String rootElementTag, boolean includeModel, boolean includeGUI, boolean includeMRU) {
 
super(rootElementTag);
 
100,25 → 114,37
this.includeModel = includeModel;
 
this.includeGUI = includeGUI;
this.includeMRU = includeMRU;
 
if (includeModel) {
 
tags.add(MIOSStudioXML.TAG_ROOT_ELEMENT);
addTag(MIOSStudioXML.TAG_ROOT_ELEMENT);
}
 
if (includeGUI) {
 
tags.add(TAG_LOOK_AND_FEEL);
tags.add(TAG_MAIN_WINDOW);
tags.add(TAG_INTERNAL_FRAMES);
tags.add(TAG_EXTERNAL_COMMANDS);
tags.add(TAG_EXTERNAL_COMMAND);
tags.add(TAG_WORKSPACE_CURRENT_DIRECTORY);
tags.add(TAG_MIDI_FILTER_DEVICE_MANAGER_GUI);
tags.add(TAG_MIDI_FILTER_GUI_CURRENT_DIRECTORY);
tags.add(TAG_HEX_FILE_UPLOAD_DEVICE_MANAGER_GUI);
tags.add(TAG_HEX_FILE_GUI_CURRENT_DIRECTORY);
addTag(TAG_LOOK_AND_FEEL);
addTag(TAG_MAIN_WINDOW);
addTag(TAG_INTERNAL_FRAMES);
addTag(TAG_EXTERNAL_COMMANDS);
addTag(TAG_EXTERNAL_COMMAND);
addTag(TAG_WORKSPACE_CURRENT_DIRECTORY);
addTag(TAG_MIDI_FILTER_DEVICE_MANAGER_GUI);
addTag(TAG_MIDI_FILTER_GUI_CURRENT_DIRECTORY);
addTag(TAG_HEX_FILE_UPLOAD_DEVICE_MANAGER_GUI);
addTag(TAG_HEX_FILE_UPLOAD_GUI_CURRENT_DIRECTORY);
}
if (includeMRU) {
addTag(TAG_WORKSPACE_MRU_LIST);
addTag(TAG_WORKSPACE_MRU);
addTag(TAG_MIDI_FILTER_GUI_MRU_LIST);
addTag(TAG_MIDI_FILTER_GUI_MRU);
addTag(TAG_HEX_FILE_UPLOAD_GUI_MRU_LIST);
addTag(TAG_HEX_FILE_UPLOAD_GUI_MRU);
}
}
 
protected void createGUI() {
289,9 → 315,33
 
}
 
} else if (name == TAG_HEX_FILE_GUI_CURRENT_DIRECTORY) {
} else if (name == TAG_HEX_FILE_UPLOAD_GUI_CURRENT_DIRECTORY) {
 
HexFileUploadGUI.setCurrentDirectory(element.getTextContent());
} else if (name == TAG_WORKSPACE_MRU_LIST) {
miosStudioGUI.getMRU().removeAllElements();
} else if (name == TAG_WORKSPACE_MRU) {
miosStudioGUI.saveMRU(element.getTextContent());
} else if (name == TAG_MIDI_FILTER_GUI_MRU_LIST) {
MidiFilterGUI.getMRU().removeAllElements();
} else if (name == TAG_MIDI_FILTER_GUI_MRU) {
MidiFilterGUI.saveMRU(element.getTextContent());
} else if (name == TAG_HEX_FILE_UPLOAD_GUI_MRU_LIST) {
HexFileUploadGUI.getMRU().removeAllElements();
} else if (name == TAG_HEX_FILE_UPLOAD_GUI_MRU) {
HexFileUploadGUI.saveMRU(element.getTextContent());
}
}
 
408,6 → 458,24
 
workSpaceCurrentDirectory.setTextContent(MIOSStudioGUI
.getCurrentDirectory());
if (includeMRU) {
Element mruListElement = document.createElement(TAG_WORKSPACE_MRU_LIST);
rootElement.appendChild(mruListElement);
it = miosStudioGUI.getMRU().iterator();
while (it.hasNext()) {
Element mru = document.createElement(TAG_WORKSPACE_MRU);
mruListElement.appendChild(mru);
mru.setTextContent((String) it.next());
}
}
 
Element midiFilterDeviceManagerGUIelement = document
.createElement(TAG_MIDI_FILTER_DEVICE_MANAGER_GUI);
422,6 → 490,24
 
midiFilterCurrentDirectory.setTextContent(MidiFilterGUI
.getCurrentDirectory());
if (includeMRU) {
Element mruListElement = document.createElement(TAG_MIDI_FILTER_GUI_MRU_LIST);
midiFilterDeviceManagerGUIelement.appendChild(mruListElement);
it = MidiFilterGUI.getMRU().iterator();
while (it.hasNext()) {
Element mru = document.createElement(TAG_MIDI_FILTER_GUI_MRU);
mruListElement.appendChild(mru);
mru.setTextContent((String) it.next());
}
}
 
Element hexFileUploadDeviceManagerGUIelement = document
.createElement(TAG_HEX_FILE_UPLOAD_DEVICE_MANAGER_GUI);
434,7 → 520,7
.getSelectedIndex()));
 
Element hexFileCurrentDirectoryElement = document
.createElement(TAG_HEX_FILE_GUI_CURRENT_DIRECTORY);
.createElement(TAG_HEX_FILE_UPLOAD_GUI_CURRENT_DIRECTORY);
 
hexFileUploadDeviceManagerGUIelement
.appendChild(hexFileCurrentDirectoryElement);
441,6 → 527,24
 
hexFileCurrentDirectoryElement.setTextContent(HexFileUploadGUI
.getCurrentDirectory());
if (includeMRU) {
Element mruListElement = document.createElement(TAG_HEX_FILE_UPLOAD_GUI_MRU_LIST);
hexFileUploadDeviceManagerGUIelement.appendChild(mruListElement);
it = HexFileUploadGUI.getMRU().iterator();
while (it.hasNext()) {
Element mru = document.createElement(TAG_HEX_FILE_UPLOAD_GUI_MRU);
mruListElement.appendChild(mru);
mru.setTextContent((String) it.next());
}
}
}
}
 
/trunk/java/org/midibox/apps/miosstudio/gui/MIOSStudioGUI.java
40,6 → 40,7
import java.beans.PropertyChangeListener;
import java.io.File;
import java.net.URL;
import java.util.Iterator;
import java.util.Observable;
import java.util.Observer;
import java.util.Vector;
70,6 → 71,8
import javax.swing.UIManager;
import javax.swing.event.MenuEvent;
import javax.swing.event.MenuListener;
import javax.swing.event.PopupMenuEvent;
import javax.swing.event.PopupMenuListener;
 
import org.midibox.apps.miosstudio.MIOSStudio;
import org.midibox.apps.miosstudio.gui.xml.MIOSStudioGUIXML;
93,6 → 96,7
import org.midibox.utils.gui.HelpPane;
import org.midibox.utils.gui.ImageLoader;
import org.midibox.utils.gui.SimpleFileChooserFilter;
import org.midibox.utils.gui.SplitButton;
 
public class MIOSStudioGUI extends JPanel implements ActionListener,
MouseListener, PropertyChangeListener, MenuListener, Observer {
189,8 → 193,18
 
private JLabel commentLabel;
 
private JMenu MRUMenu;
 
private JPopupMenu MRUPopupMenu;
private SplitButton openMRUButton;
 
private static int maxMRU = 10;
 
private static String currentDirectory = "";
 
private static Vector MRU = new Vector();
 
private static JFileChooser fc = null;
 
public MIOSStudioGUI(MIOSStudio miosStudio) {
494,6 → 508,10
menuItem.addActionListener(this);
fileMenu.add(menuItem);
 
MRUMenu = new JMenu("Open Recent Workspace");
MRUMenu.addMenuListener(this);
fileMenu.add(MRUMenu);
 
menuItem = new JMenuItem("Save Workspace");
menuItem.setActionCommand("save_workspace");
menuItem.addActionListener(this);
712,6 → 730,10
}
}
 
public static Vector getMRU() {
return MRU;
}
 
public void removeExternalCommandButton(ExternalCommandButton button) {
externalCommands.remove(button);
toolBar.remove(button);
730,9 → 752,13
protected JToolBar createToolBar() {
 
toolBar = new JToolBar("Tool Bar", JToolBar.HORIZONTAL);
toolBar.setFloatable(true);
toolBar.setFloatable(false);
toolBar.setRollover(true);
 
createWorkspaceButtons();
 
toolBar.addSeparator();
 
createMIDIButtons();
 
toolBar.addSeparator();
760,6 → 786,48
return toolBar;
}
 
protected void createWorkspaceButtons() {
 
Insets insets = new Insets(2, 2, 2, 2);
 
JButton button = new JButton(ImageLoader.getImageIcon("open.png"));
button.setToolTipText("Open Workspace");
button.setActionCommand("open_workspace");
button.addActionListener(this);
button.setMargin(insets);
 
MRUPopupMenu = new JPopupMenu();
MRUPopupMenu.addPopupMenuListener(new PopupMenuListener() {
 
public void popupMenuCanceled(PopupMenuEvent e) {
 
}
 
public void popupMenuWillBecomeInvisible(PopupMenuEvent e) {
 
}
 
public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
 
MIOSStudioGUI.this.buildMRUMenu(MRUPopupMenu);
 
}
});
 
openMRUButton = new SplitButton(button, MRUPopupMenu);
openMRUButton.setRollover(true);
toolBar.add(openMRUButton);
 
button = new JButton(ImageLoader.getImageIcon("save.png"));
button.setToolTipText("Save Workspace");
button.setActionCommand("save_workspace");
button.addActionListener(this);
button.setMargin(insets);
toolBar.add(button);
 
}
 
protected void createMIDIButtons() {
 
Insets insets = new Insets(2, 2, 2, 2);
779,6 → 847,8
button.setMargin(insets);
toolBar.add(button);
 
toolBar.addSeparator();
 
button = new JButton(ImageLoader.getImageIcon("midiOut.png"));
button.setToolTipText("MIDI Monitor: OUT");
button.setActionCommand("midi_out_port_monitor");
1051,10 → 1121,33
* 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) {
 
menu.removeAll();
 
Iterator it = MRU.iterator();
 
while (it.hasNext()) {
 
final JMenuItem menuItem = new JMenuItem((String) it.next());
 
menuItem.addActionListener(new ActionListener() {
 
public void actionPerformed(ActionEvent ae) {
 
File file = new File(menuItem.getText());
 
openWorkspace(file);
}
});
 
menu.add(menuItem, 0);
}
}
 
private void buildLookAndFeel() {
 
JCheckBoxMenuItem item;
1160,6 → 1253,19
 
final File file = fc.getSelectedFile();
 
openWorkspace(file);
currentDirectory = fc.getCurrentDirectory()
.toString();
}
}
 
protected void openWorkspace(File workspaceFile) {
 
final File file = workspaceFile;
 
if (file.exists()) {
 
final WorkspaceOptionDialog workspaceOptionDialog = new WorkspaceOptionDialog();
 
workspaceOptionDialog.pack();
1196,12 → 1302,10
MIOSStudioGUIXML miosStudioGUIXML = new MIOSStudioGUIXML(
MIOSStudioGUI.this,
MIOSStudioGUIXML.TAG_ROOT_ELEMENT, model,
gui);
gui, false);
 
miosStudioGUIXML.loadXML(file);
 
currentDirectory = fc.getCurrentDirectory()
.toString();
}
});
 
1208,9 → 1312,29
workspaceOptionDialog.setLocationRelativeTo(this);
 
workspaceOptionDialog.setVisible(true);
 
saveMRU(file.getPath());
 
} else {
 
JOptionPane.showMessageDialog(this,
"Workspace configuration file no longer exists",
"File does not exist", JOptionPane.ERROR_MESSAGE);
}
}
 
public void saveMRU(String file) {
 
MRU.remove(file);
 
MRU.add(file);
 
for (int i = MRU.size() - maxMRU; i > 0; i--) {
 
MRU.removeElementAt(i - 1);
}
}
 
protected void saveWorkspace() {
 
if (fc == null) {
1268,7 → 1392,7
MIOSStudioGUIXML miosStudioGUIXML = new MIOSStudioGUIXML(
MIOSStudioGUI.this,
MIOSStudioGUIXML.TAG_ROOT_ELEMENT, model,
gui);
gui, false);
 
miosStudioGUIXML.saveXML(file);
 
1280,6 → 1404,8
workspaceOptionDialog.setLocationRelativeTo(this);
 
workspaceOptionDialog.setVisible(true);
 
saveMRU(file.getPath());
}
}
 
1342,6 → 1468,8
windowMenu.buildChildMenus();
} else if (source == lookAndFeelMenu) {
buildLookAndFeel();
} else if (source == MRUMenu) {
buildMRUMenu(MRUMenu);
}
}
 
/trunk/java/org/midibox/apps/miosstudiosid/gui/xml/MIOSStudioSIDGUIXML.java
7,19 → 7,19
public class MIOSStudioSIDGUIXML extends MIOSStudioGUIXML {
 
public MIOSStudioSIDGUIXML(MIOSStudioSID miosStudioSID, String rootElementTag,
boolean includeModel, boolean includeGUI) {
super(miosStudioSID, rootElementTag, includeModel, includeGUI);
boolean includeModel, boolean includeGUI, boolean includeMRU) {
super(miosStudioSID, rootElementTag, includeModel, includeGUI, includeMRU);
}
 
public MIOSStudioSIDGUIXML(MIOSStudioSIDGUI miosStudioSIDGUI,
String rootElementTag, boolean includeModel, boolean includeGUI) {
super(miosStudioSIDGUI, rootElementTag, includeModel, includeGUI);
String rootElementTag, boolean includeModel, boolean includeGUI, boolean includeMRU) {
super(miosStudioSIDGUI, rootElementTag, includeModel, includeGUI, includeMRU);
}
 
public MIOSStudioSIDGUIXML(MIOSStudioSIDGUI miosStudioSIDGUI,
MIOSStudioSID miosStudioSID, String rootElementTag, boolean includeModel,
boolean includeGUI) {
super(miosStudioSIDGUI, miosStudioSID, rootElementTag, includeModel, includeGUI);
boolean includeGUI, boolean includeMRU) {
super(miosStudioSIDGUI, miosStudioSID, rootElementTag, includeModel, includeGUI, includeMRU);
}
protected void createGUI() {
/trunk/java/org/midibox/apps/virtualkeyboard/xml/VirtualKeyboardXML.java
20,8 → 20,8
 
this.virtualKeyboard = virtualKeyboard;
 
tags.add(MidiDeviceRoutingXML.TAG_ROOT_ELEMENT);
tags.add(MidiKeyboardControllerDeviceXML.TAG_ROOT_ELEMENT);
addTag(MidiDeviceRoutingXML.TAG_ROOT_ELEMENT);
addTag(MidiKeyboardControllerDeviceXML.TAG_ROOT_ELEMENT);
}
 
protected void parseElement(Element element) {
/trunk/java/org/midibox/apps/virtualkeyboard/gui/xml/VirtualKeyboardGUIXML.java
61,10 → 61,10
 
this.virtualKeyboardGUI = virtualKeyboardGUI;
 
tags.add(VirtualKeyboardXML.TAG_ROOT_ELEMENT);
tags.add(TAG_LOOK_AND_FEEL);
tags.add(TAG_MAIN_WINDOW);
tags.add(TAG_CONNECTIONS_VISIBLE);
addTag(VirtualKeyboardXML.TAG_ROOT_ELEMENT);
addTag(TAG_LOOK_AND_FEEL);
addTag(TAG_MAIN_WINDOW);
addTag(TAG_CONNECTIONS_VISIBLE);
}
 
protected void parseElement(Element element) {
/trunk/java/org/midibox/mios/gui/HexFileUploadGUI.java
31,8 → 31,10
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
import java.util.Iterator;
import java.util.Observable;
import java.util.Observer;
import java.util.Vector;
 
import javax.swing.BorderFactory;
import javax.swing.Box;
40,11 → 42,14
import javax.swing.ButtonGroup;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JComponent;
import javax.swing.JFileChooser;
import javax.swing.JFormattedTextField;
import javax.swing.JLabel;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JPopupMenu;
import javax.swing.JRadioButton;
import javax.swing.JScrollPane;
import javax.swing.JSpinner;
53,20 → 58,32
import javax.swing.SpinnerNumberModel;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import javax.swing.event.PopupMenuEvent;
import javax.swing.event.PopupMenuListener;
import javax.swing.text.Style;
import javax.swing.text.StyleConstants;
import javax.swing.text.StyleContext;
import javax.swing.text.StyledDocument;
 
import org.midibox.apps.miosstudio.gui.MIOSStudioGUI;
import org.midibox.mios.HexFileUpload;
import org.midibox.utils.gui.HexFormatterFactory;
import org.midibox.utils.gui.ImageLoader;
import org.midibox.utils.gui.SimpleFileChooserFilter;
import org.midibox.utils.gui.SplitButton;
 
public class HexFileUploadGUI extends JPanel implements ActionListener,
ChangeListener, Observer {
 
private JPopupMenu MRUPopupMenu;
private SplitButton openMRUButton;
 
private static int maxMRU = 10;
private static String currentDirectory = "";
private static Vector MRU = new Vector();
 
private static JFileChooser fc = null;
 
110,10 → 127,15
this.hexFileUpload = hexUploadTask;
hexUploadTask.addObserver(this);
 
Insets insets = new Insets(2, 2, 2, 2);
browseButton = new JButton("Hex File", ImageLoader
.getImageIcon("open.png"));
browseButton.setActionCommand("browse");
browseButton.addActionListener(this);
browseButton.setMargin(insets);
browseButton.setToolTipText("Open Hex File");
 
fileName = new JTextField();
fileName.setEditable(false);
144,7 → 166,29
queryButton.setAlignmentX(Component.LEFT_ALIGNMENT);
 
JPanel fileButtonsPanel = new JPanel(new BorderLayout(2, 0));
fileButtonsPanel.add(browseButton, BorderLayout.WEST);
MRUPopupMenu = new JPopupMenu();
MRUPopupMenu.addPopupMenuListener(new PopupMenuListener() {
 
public void popupMenuCanceled(PopupMenuEvent e) {
 
}
 
public void popupMenuWillBecomeInvisible(PopupMenuEvent e) {
 
}
 
public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
 
HexFileUploadGUI.this.buildMRUMenu(MRUPopupMenu);
 
}
});
 
openMRUButton = new SplitButton(browseButton, MRUPopupMenu);
openMRUButton.setRollover(true);
fileButtonsPanel.add(openMRUButton, BorderLayout.WEST);
fileButtonsPanel.add(fileName, BorderLayout.CENTER);
fileButtonsPanel.setBorder(BorderFactory.createEmptyBorder(7, 7, 5, 7));
 
295,7 → 339,43
 
updateUploadControls();
}
private void buildMRUMenu(JComponent menu) {
 
menu.removeAll();
 
Iterator it = MRU.iterator();
 
while (it.hasNext()) {
 
final JMenuItem menuItem = new JMenuItem((String) it.next());
 
menuItem.addActionListener(new ActionListener() {
 
public void actionPerformed(ActionEvent ae) {
 
File file = new File(menuItem.getText());
 
openHexFile(file);
}
});
 
menu.add(menuItem, 0);
}
}
public static void saveMRU(String file) {
 
MRU.remove(file);
 
MRU.add(file);
 
for (int i = MRU.size() - maxMRU; i > 0; i--) {
 
MRU.removeElementAt(i - 1);
}
}
 
public static String getCurrentDirectory() {
return currentDirectory;
}
308,7 → 388,7
return hexFileUpload;
}
 
protected void onOpenHexFile() {
protected void openHexFile() {
 
if (fc == null) {
fc = new JFileChooser(currentDirectory);
327,10 → 407,31
 
if (nRetVal == JFileChooser.APPROVE_OPTION) {
File file = fc.getSelectedFile();
hexFileUpload.setFile(file);
openHexFile(file);
currentDirectory = fc.getCurrentDirectory().toString();
}
}
protected void openHexFile(File file) {
if (file.exists()) {
hexFileUpload.setFile(file);
saveMRU(file.getPath());
} else {
JOptionPane.showMessageDialog(this,
"Hex file no longer exists",
"File does not exist", JOptionPane.ERROR_MESSAGE);
}
}
public static Vector getMRU() {
return MRU;
}
 
public void updateUploadControls() {
 
427,7 → 528,7
hexFileUpload.cancel();
 
} else if (command.equals("browse")) {
onOpenHexFile();
openHexFile();
 
} else if (source == smartModeButton || source == dumbModeButton) {
hexFileUpload
/trunk/java/org/midibox/mios/xml/HexFileUploadDeviceManagerXML.java
27,8 → 27,8
 
this.hexFileUploadDeviceManager = hexFileUploadDeviceManager;
 
tags.add(TAG_HEX_FILE_UPLOAD_DEVICES);
tags.add(HexFileUploadDeviceXML.TAG_ROOT_ELEMENT);
addTag(TAG_HEX_FILE_UPLOAD_DEVICES);
addTag(HexFileUploadDeviceXML.TAG_ROOT_ELEMENT);
}
 
protected void parseElement(Element element) {
/trunk/java/org/midibox/mios/xml/LCDMessageDeviceXML.java
18,7 → 18,7
 
this.lcdMessageDevice = lcdMessageDevice;
 
tags.add(LCDMessageXML.TAG_ROOT_ELEMENT);
addTag(LCDMessageXML.TAG_ROOT_ELEMENT);
}
 
protected void parseElement(Element element) {
/trunk/java/org/midibox/mios/xml/LCDMessageXML.java
30,7 → 30,7
 
this.lcdMessage = lcdMessage;
 
tags.add(TAG_MESSAGE_TEXT);
addTag(TAG_MESSAGE_TEXT);
}
 
protected void parseElement(Element element) {
/trunk/java/org/midibox/mios/xml/HexFileUploadDeviceXML.java
18,7 → 18,7
 
this.hexFileUploadDevice = hexFileUploadDevice;
 
tags.add(HexFileUploadXML.TAG_ROOT_ELEMENT);
addTag(HexFileUploadXML.TAG_ROOT_ELEMENT);
}
 
protected void parseElement(Element element) {
/trunk/java/org/midibox/mios/xml/HexFileUploadXML.java
26,7 → 26,7
 
this.hexFileUpload = hexFileUpload;
 
tags.add(TAG_FILE);
addTag(TAG_FILE);
}
 
protected void parseElement(Element element) {
/trunk/java/org/midibox/mios/xml/DebugFunctionDeviceXML.java
18,7 → 18,7
 
this.debugFunctionDevice = debugFunctionDevice;
 
tags.add(DebugFunctionXML.TAG_ROOT_ELEMENT);
addTag(DebugFunctionXML.TAG_ROOT_ELEMENT);
}
 
protected void parseElement(Element element) {
/trunk/java/org/midibox/mios/xml/DebugFunctionXML.java
34,7 → 34,7
 
this.debugFunction = debugFunction;
 
tags.add(TAG_DEBUG_FUNCTION_PARAMETERS_LIST);
addTag(TAG_DEBUG_FUNCTION_PARAMETERS_LIST);
}
 
protected void parseElement(Element element) {