]> ruin.nu Git - moosique.git/blobdiff - MooMenu.java
font settings..
[moosique.git] / MooMenu.java
index c4a01c1a42dd8a934e93fad4281124a43923f065..f4090bdc5d70ef1fabffafbe71c45a8dba24357a 100644 (file)
@@ -136,7 +136,7 @@ public class MooMenu extends JMenuBar implements ActionListener {
        }
        /**
        * Gets the users command of takes and properiate action
-       * @param e      the action perfomed
+       * @param e      The action perfomed.
        */
        public void actionPerformed(ActionEvent e) {
                String command = e.getActionCommand();
@@ -161,23 +161,9 @@ public class MooMenu extends JMenuBar implements ActionListener {
                                Moosique.load(chooser.getSelectedFile().getAbsolutePath());
                        }
                } else if (command == "Save") {
-                       Moosique.save();
+                       if (!Moosique.save()) showSaveAsDialog();
                } else if (command == "Save as...") {
-                       // Shows a file chooser. If shown previously, starts in the current directory.
-                       if (directory != null) {
-                               chooser = new JFileChooser(directory);
-                       } else {
-                               chooser = new JFileChooser();
-                       }
-                       chooser.addChoosableFileFilter(new MidiFileFilter());
-                       int returnVal = chooser.showSaveDialog(this);
-
-                       // Stores the current directory and loads the selected file.
-                       File file = chooser.getSelectedFile();
-                       if(returnVal == JFileChooser.APPROVE_OPTION && isMidiFile(file)) {
-                               directory = file.getParentFile();
-                               Moosique.saveAs(file.getAbsolutePath());
-                       }
+                       showSaveAsDialog();
                } else if (command == "Exit") {
                        Moosique.quit();
                } else if (command == "Copy") {
@@ -199,27 +185,27 @@ public class MooMenu extends JMenuBar implements ActionListener {
                } else if (command == "Stop") {
                        Moosique.stop();
                } else if (command == "Jump...") {
-                       MooDialog what = new MooDialog(MooDialog.JUMP);
+                       MooDialog newDialog = new MooDialog(MooDialog.JUMP);
                        // Moosique.setPosition(???); Räkna ut från msr, beats, ticks, time sig.
                } else if (command == "Add track...") {
-                       MooDialog what = new MooDialog(MooDialog.ADD_TRACK);
+                       MooDialog newDialog = new MooDialog(MooDialog.ADD_TRACK);
                        Moosique.getSequence().createTrack();
                } else if (command == "Delete track...") {
                
-                       MooDialog what = new MooDialog(MooDialog.DELETE_TRACK);
+                       MooDialog newDialog = new MooDialog(MooDialog.DELETE_TRACK);
                        
                        /* Let the user select a track from a list.
                        seq = Moosique.getSequence();
                        seq.deleteTrack(seq.getTracks()[NUMBER]);
                        */
                } else if (command == "Copy track...") {
-                       MooDialog what = new MooDialog(MooDialog.COPY_TRACK);
+                       MooDialog newDialog = new MooDialog(MooDialog.COPY_TRACK);
                } else if (command == "Move track...") {
-                       MooDialog what = new MooDialog(MooDialog.MOVE_TRACK);
+                       MooDialog newDialog = new MooDialog(MooDialog.MOVE_TRACK);
                } else if (command == "Insert measure...") {
-               
+                       MooDialog newDialog = new MooDialog(MooDialog.INSERT_MEASURE);
                } else if (command == "Delete measure...") {
-               
+                       MooDialog newDialog = new MooDialog(MooDialog.DELETE_MEASURE);
                } else if (command == "Set time signature...") {
                
                } else if (command == "Set tempo...") {
@@ -240,6 +226,24 @@ public class MooMenu extends JMenuBar implements ActionListener {
                }
        }
 
+       private void showSaveAsDialog() {
+                       // Shows a file chooser. If shown previously, starts in the current directory.
+                       if (directory != null) {
+                               chooser = new JFileChooser(directory);
+                       } else {
+                               chooser = new JFileChooser();
+                       }
+                       chooser.addChoosableFileFilter(new MidiFileFilter());
+                       int returnVal = chooser.showSaveDialog(this);
+
+                       // Stores the current directory and loads the selected file.
+                       File file = chooser.getSelectedFile();
+                       if(returnVal == JFileChooser.APPROVE_OPTION && isMidiFile(file)) {
+                               directory = file.getParentFile();
+                               Moosique.saveAs(file.getAbsolutePath());
+                       }
+       }
+
        class MidiFileFilter extends javax.swing.filechooser.FileFilter {
                public boolean accept(File f) {
                        if(f != null) {
@@ -248,7 +252,7 @@ public class MooMenu extends JMenuBar implements ActionListener {
                        return false;
                }
                
-               /*
+               /**
                 * gets the description of the filetype
                 * @return "Midifiles   the only filetyp compatibel with the program
                 */