Subversion Repositories svn.mios

Compare Revisions

Regard whitespace Rev 873 → Rev 874

/trunk/java/MIOSStudio.java
19,6 → 19,7
*/
 
import java.awt.Dimension;
import java.awt.Rectangle;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
27,12 → 28,14
import java.awt.event.KeyEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
import java.io.File;
 
import javax.swing.JApplet;
import javax.swing.JFrame;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
 
import org.midibox.apps.miosstudio.gui.MIOSStudioGUI;
41,7 → 44,8
import org.midibox.utils.gui.ImageLoader;
import org.midibox.utils.gui.SplashScreen;
 
import sun.awt.WindowClosingListener;
import com.apple.mrj.MRJApplicationUtils;
import com.apple.mrj.MRJQuitHandler;
 
/**
* Driver class for launching MIOS Studio application. MIOS Studio can be
190,11 → 194,14
 
frame.setIconImage(ImageLoader.getImageIcon("ucIcon.png").getImage());
 
frame.setBounds(50, 50, (screenSize.width - 100),
(screenSize.height - 100));
frame.setBounds(new Rectangle(0, 0, 0, 0));
 
frame.setVisible(true);
 
final MIOSStudio miosStudio = new MIOSStudio();
 
frame.setContentPane(miosStudio);
 
if (System.getProperty("mrj.version") == null) {
 
JMenuItem exitMenuItem = new JMenuItem("Exit");
210,10 → 217,14
}
});
miosStudio.setJMenuBar(miosStudio.miosStudioGUI.createMenuBar());
JMenuBar menuBar = miosStudio.miosStudioGUI.createMenuBar();
miosStudio.miosStudioGUI.getFileMenu().add(exitMenuItem);
JMenu fileMenu = (JMenu) menuBar.getComponent(0);
fileMenu.add(exitMenuItem);
 
miosStudio.setJMenuBar(menuBar);
 
frame.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent we) {
 
227,13 → 238,19
 
frame.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
Runtime.getRuntime().addShutdownHook(new Thread() {
 
MRJApplicationUtils.registerQuitHandler(new MRJQuitHandler() {
public void handleQuit() {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
miosStudio.destroy();
 
System.exit(0);
}
 
});
throw new IllegalStateException(
"Stop Pending User Confirmation");
}
});
if (UIManager.getLookAndFeel().getClass().getName().toString() == UIManager
.getSystemLookAndFeelClassName()) {
248,8 → 265,12
}
}
frame.setContentPane(miosStudio);
if (frame.getBounds() == new Rectangle(0, 0, 0, 0)) {
 
frame.setBounds(50, 50, (screenSize.width - 100),
(screenSize.height - 100));
}
 
if (!miosStudio.miosStudioGUI.isMDI()) {
 
frame.setResizable(false);
274,12 → 295,14
}
});
 
} else {
 
frame.validate();
}
 
frame.setVisible(true);
 
splashScreen.setVisible(false);
 
frame.requestFocus();
}
 
}
/trunk/java/MIOSStudioSID.java
201,7 → 201,7
}
});
 
miosStudioSID.miosStudioSIDGUI.getFileMenu().add(exitMenuItem);
// miosStudioSID.miosStudioSIDGUI.getFileMenu().add(exitMenuItem);
 
miosStudioSID.setJMenuBar(miosStudioSID.miosStudioSIDGUI
.createMenuBar());
/trunk/java/org/midibox/apps/miosstudio/gui/MIOSStudioGUI.java
102,7 → 102,7
import org.midibox.utils.gui.SplitButton;
 
public class MIOSStudioGUI extends JPanel implements ActionListener,
MouseListener, PropertyChangeListener, MenuListener, Observer {
MouseListener, PropertyChangeListener, Observer {
 
protected MIOSStudio miosStudio;
 
168,28 → 168,8
 
private Vector externalCommands = new Vector();
 
protected JMenu fileMenu;
 
protected JMenu midiMenu;
 
protected JMenu miosMenu;
 
protected JMenu optionsMenu;
 
protected WindowMenu windowMenu;
 
protected JMenu helpMenu;
 
private JMenuItem midiThruMenuItem;
 
private JCheckBoxMenuItem showInternalMenuItem;
 
private JMenu lookAndFeelMenu;
 
private String lookAndFeel;
 
private JCheckBoxMenuItem MDIMenuItem;
 
private boolean MDI;
 
private boolean MDIflag;
196,8 → 176,6
 
private JLabel commentLabel;
 
private JMenu MRUMenu;
 
private JPopupMenu MRUPopupMenu;
 
private SplitButton openMRUButton;
496,28 → 474,22
}
 
public JMenuBar createMenuBar() {
 
JMenuBar menuBar = new JMenuBar();
 
createFileMenu();
createMIDIMenu();
createMIOSMenu();
createOptionsMenu();
createWindowMenu();
createHelpMenu();
menuBar.add(createFileMenu());
menuBar.add(createMIDIMenu());
menuBar.add(createMIOSMenu());
menuBar.add(createOptionsMenu());
menuBar.add(createWindowMenu());
menuBar.add(createHelpMenu());
 
menuBar.add(fileMenu);
menuBar.add(midiMenu);
menuBar.add(miosMenu);
menuBar.add(optionsMenu);
menuBar.add(windowMenu);
menuBar.add(helpMenu);
 
return menuBar;
}
 
protected void createFileMenu() {
protected JMenu createFileMenu() {
 
fileMenu = new JMenu("File");
JMenu fileMenu = new JMenu("File");
 
JMenuItem menuItem = new JMenuItem("Open Workspace");
menuItem.setActionCommand("open_workspace");
524,8 → 496,24
menuItem.addActionListener(this);
fileMenu.add(menuItem);
 
MRUMenu = new JMenu("Open Recent Workspace");
MRUMenu.addMenuListener(this);
final JMenu MRUMenu = new JMenu("Open Recent Workspace");
 
MRUMenu.addMenuListener(new MenuListener() {
 
public void menuCanceled(MenuEvent e) {
}
 
public void menuDeselected(MenuEvent e) {
 
}
 
public void menuSelected(MenuEvent e) {
 
buildMRUMenu(MRUMenu);
}
 
});
 
fileMenu.add(MRUMenu);
 
menuItem = new JMenuItem("Save Workspace");
532,11 → 520,14
menuItem.setActionCommand("save_workspace");
menuItem.addActionListener(this);
fileMenu.add(menuItem);
 
return fileMenu;
}
 
protected void createMIDIMenu() {
midiMenu = new JMenu("MIDI");
protected JMenu createMIDIMenu() {
 
JMenu midiMenu = new JMenu("MIDI");
 
JMenuItem menuItem = new JMenuItem("MIDI Devices");
menuItem.setActionCommand("midi_devices");
menuItem.addActionListener(this);
566,11 → 557,13
menuItem.setActionCommand("sysex");
menuItem.addActionListener(this);
midiMenu.add(menuItem);
 
return midiMenu;
}
 
protected void createMIOSMenu() {
protected JMenu createMIOSMenu() {
 
miosMenu = new JMenu("MIOS");
JMenu miosMenu = new JMenu("MIOS");
 
JMenuItem menuItem = new JMenuItem("MIOS Hex File Upload");
menuItem.setActionCommand("open_hex_file");
591,11 → 584,13
menuItem.setActionCommand("mios_terminal");
menuItem.addActionListener(this);
miosMenu.add(menuItem);
 
return miosMenu;
}
 
protected void createOptionsMenu() {
protected JMenu createOptionsMenu() {
 
optionsMenu = new JMenu("Options");
JMenu optionsMenu = new JMenu("Options");
 
JMenuItem menuItem = new JMenuItem("MIDI Device Routing");
menuItem.setActionCommand("midi_routing");
602,8 → 597,8
menuItem.addActionListener(this);
optionsMenu.add(menuItem);
 
showInternalMenuItem = new JCheckBoxMenuItem("Show Internal Routing",
miosStudio.isRouteIndividualDevices());
final JCheckBoxMenuItem showInternalMenuItem = new JCheckBoxMenuItem(
"Show Internal Routing", miosStudio.isRouteIndividualDevices());
showInternalMenuItem.setActionCommand("route_internal");
showInternalMenuItem.addActionListener(this);
optionsMenu.add(showInternalMenuItem);
616,8 → 611,8
optionsMenu.addSeparator();
JMenu thruMenu = new JMenu("MIDI Thru");
 
midiThruMenuItem = new JCheckBoxMenuItem("Send MIDI Thru via Out Port",
miosStudio.isMidiThruOutPort());
final JMenuItem midiThruMenuItem = new JCheckBoxMenuItem(
"Send MIDI Thru via Out Port", miosStudio.isMidiThruOutPort());
midiThruMenuItem.setActionCommand("midi_thru");
midiThruMenuItem.addActionListener(this);
thruMenu.add(midiThruMenuItem);
635,25 → 630,68
 
optionsMenu.add(thruMenu);
optionsMenu.addSeparator();
lookAndFeelMenu = new JMenu("Look & Feel");
lookAndFeelMenu.addMenuListener(this);
 
final JMenu lookAndFeelMenu = new JMenu("Look & Feel");
 
lookAndFeelMenu.addMenuListener(new MenuListener() {
 
public void menuCanceled(MenuEvent e) {
}
 
public void menuDeselected(MenuEvent e) {
 
lookAndFeelMenu.removeAll();
}
 
public void menuSelected(MenuEvent e) {
 
buildLookAndFeel(lookAndFeelMenu);
}
 
});
 
optionsMenu.add(lookAndFeelMenu);
 
MDIMenuItem = new JCheckBoxMenuItem("MDI", MDIflag);
final JMenuItem MDIMenuItem = new JCheckBoxMenuItem("MDI", MDIflag);
MDIMenuItem.addActionListener(this);
MDIMenuItem.setActionCommand("MDI");
optionsMenu.add(MDIMenuItem);
 
optionsMenu.addMenuListener(new MenuListener() {
 
public void menuCanceled(MenuEvent e) {
 
}
 
protected void createWindowMenu() {
public void menuDeselected(MenuEvent e) {
 
windowMenu = new WindowMenu(this);
}
 
public void menuSelected(MenuEvent e) {
 
showInternalMenuItem.setSelected(miosStudio
.isRouteIndividualDevices());
 
midiThruMenuItem.setSelected(miosStudio.isMidiThruOutPort());
 
MDIMenuItem.setSelected(isMDIflag());
}
});
 
return optionsMenu;
}
 
protected JMenu createWindowMenu() {
 
JMenu windowMenu = new WindowMenu(this);
windowMenu.setMnemonic(KeyEvent.VK_W);
 
return windowMenu;
}
 
protected void createHelpMenu() {
protected JMenu createHelpMenu() {
 
helpMenu = new JMenu("Help");
JMenu helpMenu = new JMenu("Help");
helpMenu.setMnemonic(KeyEvent.VK_H);
 
JMenuItem menuItem = new JMenuItem("MIOS Studio Help");
669,6 → 707,8
menuItem.setActionCommand("mios_fun");
menuItem.addActionListener(this);
helpMenu.add(menuItem);
 
return helpMenu;
}
 
public void addExternalCommandButton(String commandName, String command) {
1049,6 → 1089,7
System.out.println(e.toString());
}
} else {
 
JFrame frame = (JFrame) container;
 
if (!frame.isVisible()) {
1153,7 → 1194,7
}
}
 
private void buildLookAndFeel() {
private void buildLookAndFeel(JMenu lookAndFeelMenu) {
 
JCheckBoxMenuItem item;
 
1161,7 → 1202,9
final int l = i;
item = new JCheckBoxMenuItem(
UIManager.getInstalledLookAndFeels()[i].getName());
 
lookAndFeelMenu.add(item);
 
if (UIManager.getInstalledLookAndFeels()[i].getClassName().equals(
lookAndFeel)) {
item.setSelected(true);
1181,10 → 1224,6
}
}
 
public JMenu getFileMenu() {
return fileMenu;
}
 
public MIOSStudio getMiosStudio() {
return miosStudio;
}
1428,44 → 1467,10
showFrame(helpWindow);
}
 
public void menuCanceled(MenuEvent e) {
}
 
public void menuDeselected(MenuEvent e) {
Object source = e.getSource();
 
if (source == windowMenu) {
windowMenu.removeAll();
} else if (source == lookAndFeelMenu) {
lookAndFeelMenu.removeAll();
}
}
 
public void menuSelected(MenuEvent e) {
Object source = e.getSource();
 
if (source == windowMenu) {
windowMenu.buildChildMenus();
} else if (source == lookAndFeelMenu) {
buildLookAndFeel();
} else if (source == MRUMenu) {
buildMRUMenu(MRUMenu);
}
}
 
public void update(Observable observable, Object object) {
 
if (object == MIOSStudio.ROUTE_INDIVIDUAL_DEVICES) {
if (observable == miosStudio.getSysexSendReceiveManager()) {
 
showInternalMenuItem.setSelected(miosStudio
.isRouteIndividualDevices());
 
} else if (object == MIOSStudio.MIDI_THRU_OUT_PORT) {
 
midiThruMenuItem.setSelected(miosStudio.isMidiThruOutPort());
 
} else if (observable == miosStudio.getSysexSendReceiveManager()) {
 
Dimension size = sysexSendReceiveDeviceManagerWindow.getSize();
 
Dimension preferred = sysexSendReceiveDeviceManagerWindow
1528,9 → 1533,12
showFrame(miosTerminalWindow);
 
} else if (ae.getActionCommand().equals("route_internal")) {
 
JCheckBoxMenuItem menuItem = (JCheckBoxMenuItem) ae.getSource();
 
miosStudio.setRouteIndividualDevices(menuItem.isSelected());
 
showFrame(midiDeviceRoutingWindow);
miosStudio.setRouteIndividualDevices(showInternalMenuItem
.isSelected());
 
} else if (ae.getActionCommand().equals("restore_default")) {
miosStudio.connectDevices();
1539,8 → 1547,11
showMidiThruFilter();
 
} else if (ae.getActionCommand().equals("midi_thru")) {
miosStudio.setMidiThruOutPort(midiThruMenuItem.isSelected());
 
JCheckBoxMenuItem menuItem = (JCheckBoxMenuItem) ae.getSource();
 
miosStudio.setMidiThruOutPort(menuItem.isSelected());
 
} else if (ae.getActionCommand().equals("help_window")) {
showFrame(helpWindow);
 
1564,7 → 1575,9
 
} else if (ae.getActionCommand().equals("MDI")) {
 
setMDIflag(MDIMenuItem.isSelected());
JCheckBoxMenuItem menuItem = (JCheckBoxMenuItem) ae.getSource();
 
setMDIflag(menuItem.isSelected());
}
}
 
1768,21 → 1781,69
private JMenuItem cascadeMenuItem;
 
public WindowMenu(MIOSStudioGUI miosStudio) {
 
this.miosStudio = miosStudio;
this.desktop = miosStudio.desktop;
setText("Window");
addMenuListener(MIOSStudioGUI.this);
 
addMenuListener(new MenuListener() {
 
public void menuCanceled(MenuEvent e) {
}
 
private JInternalFrame[] getFrames() {
return desktop.getAllFrames();
public void menuDeselected(MenuEvent e) {
 
removeAll();
 
}
 
public void menuSelected(MenuEvent e) {
 
buildChildMenus();
}
 
});
}
 
private Vector getFrames() {
 
Vector v = new Vector();
 
if (MDI) {
 
JInternalFrame[] internalFramesArray = desktop.getAllFrames();
 
for (int i = 0; i < internalFramesArray.length; i++) {
 
v.add(internalFramesArray[i]);
}
 
return v;
 
} else {
 
for (int i = 0; i < internalFrames.size(); i++) {
 
JFrame frame = (JFrame) internalFrames.elementAt(i);
 
if (frame.isVisible()) {
 
v.add(frame);
}
}
 
return v;
}
}
 
private void buildChildMenus() {
 
int i;
 
ChildMenuItem menuItem;
JInternalFrame[] frames = getFrames();
 
Vector frames = getFrames();
 
cascadeMenuItem = new JMenuItem("Cascade Windows");
 
cascadeMenuItem.addActionListener(new ActionListener() {
1789,45 → 1850,67
 
public void actionPerformed(ActionEvent ae) {
 
JInternalFrame[] frames = getFrames();
Vector frames = getFrames();
 
for (int x = 0; x < frames.length; x++) {
frames[frames.length - 1 - x].setLocation(x * 20,
x * 20);
for (int x = 0; x < frames.size(); x++) {
 
Container c = (Container) frames.get(x);
 
c.setLocation(x * 20, x * 20);
}
}
});
 
cascadeMenuItem.setEnabled(frames.length > 0);
cascadeMenuItem.setEnabled(frames.size() > 0);
 
add(cascadeMenuItem);
 
addSeparator();
 
for (i = 0; i < frames.length; i++) {
menuItem = new ChildMenuItem(frames[i]);
for (i = 0; i < frames.size(); i++) {
 
Container c = (Container) frames.get(i);
 
menuItem = new ChildMenuItem(c);
menuItem.setState(i == 0);
menuItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae) {
JInternalFrame frame = ((ChildMenuItem) ae.getSource())
Container frame = ((ChildMenuItem) ae.getSource())
.getFrame();
miosStudio.showFrame(frame);
}
});
menuItem.setIcon(frames[i].getFrameIcon());
 
if (MDI) {
menuItem.setIcon(((JInternalFrame) c).getFrameIcon());
} else {
menuItem
.setIcon(new ImageIcon(((JFrame) c).getIconImage()));
}
add(menuItem);
}
}
 
public class ChildMenuItem extends JCheckBoxMenuItem {
private JInternalFrame frame;
 
public ChildMenuItem(JInternalFrame frame) {
super(frame.getTitle());
private Container frame;
 
public ChildMenuItem(Container frame) {
 
super();
 
if (MDI) {
setText((((JInternalFrame) frame).getTitle()));
 
} else {
 
setText((((JFrame) frame).getTitle()));
}
this.frame = frame;
}
 
public JInternalFrame getFrame() {
public Container getFrame() {
 
return frame;
}
}
/trunk/java/org/midibox/apps/miosstudiosid/gui/MIOSStudioSIDGUI.java
7,6 → 7,7
 
import javax.swing.Icon;
import javax.swing.JButton;
import javax.swing.JMenu;
import javax.swing.JMenuItem;
 
import org.midibox.apps.miosstudio.gui.MIOSStudioGUI;
57,14 → 58,16
.getSidv2librarian().getSysExController(), icon);
}
 
protected void createMIOSMenu() {
protected JMenu createMIOSMenu() {
 
super.createMIOSMenu();
JMenu miosMenu = super.createMIOSMenu();
 
JMenuItem menuItem = new JMenuItem("SID V2 Editor");
menuItem.setActionCommand("sidv2_librarian");
menuItem.addActionListener(this);
miosMenu.add(menuItem);
 
return miosMenu;
}
 
protected void createMIOSButtons() {