X-Git-Url: https://ruin.nu/git/?a=blobdiff_plain;f=MooMenu.java;h=8d1caeaa11ec4a2e5a5b8413841401b0b60c5f7d;hb=9d5d6dc48ef1650f70db268b2606c5d15a7a4093;hp=141fd93f87320054204ea2f486efdebab9542ed0;hpb=c83e74facf762222fe4578f175408cc50d360518;p=moosique.git diff --git a/MooMenu.java b/MooMenu.java index 141fd93..8d1caea 100644 --- a/MooMenu.java +++ b/MooMenu.java @@ -3,6 +3,7 @@ import javax.swing.*; import javax.swing.filechooser.*; import java.awt.event.*; import java.io.*; +import java.awt.*; /** * Moosiques GUI representing a menubar, menus and menuitems @@ -12,6 +13,8 @@ import java.io.*; public class MooMenu extends JMenuBar implements ActionListener { private JMenu file, edit, playback, music, help; + private JFileChooser chooser; + private File directory; /** * Creates the menu bar. @@ -106,6 +109,14 @@ public class MooMenu extends JMenuBar implements ActionListener { return item; } + /** + * creates a JDialog popupmenu, containing diffrent choices + * @param title the title of the dialog + * @return trackframe the JDialog....ffaaaaaaaaaaaaaaaan! + */ + //private JDialog makeDialog(String title){ + // + //} /** * checks if the fileformat is compatible with our program * @param f the file to check @@ -126,20 +137,38 @@ public class MooMenu extends JMenuBar implements ActionListener { if(command == "New") { Moosique.clearSequence(); } else if (command == "Open...") { - JFileChooser chooser = new JFileChooser(); + // 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.showOpenDialog(this); - if(returnVal == JFileChooser.APPROVE_OPTION && isMidiFile(chooser.getSelectedFile())) { + + // Stores the current directory and loads the selected file. + File file = chooser.getSelectedFile(); + if(returnVal == JFileChooser.APPROVE_OPTION && isMidiFile(file)) { + directory = chooser.getSelectedFile().getParentFile(); Moosique.load(chooser.getSelectedFile().getAbsolutePath()); } } else if (command == "Save") { Moosique.save(); } else if (command == "Save as...") { - JFileChooser chooser = new JFileChooser(); + // 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); - if(returnVal == JFileChooser.APPROVE_OPTION && isMidiFile(chooser.getSelectedFile())) { - Moosique.saveAs(chooser.getSelectedFile().getAbsolutePath()); + + // 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()); } } else if (command == "Exit") { Moosique.quit(); @@ -164,16 +193,27 @@ public class MooMenu extends JMenuBar implements ActionListener { } else if (command == "Jump...") { } else if (command == "Add track...") { + + MooDialog what = new MooDialog(MooDialog.ADD_TRACK); + Moosique.getSequence().createTrack(); + } else if (command == "Delete track...") { + + MooDialog what = 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); + } else if (command == "Move track...") { + MooDialog what = new MooDialog(MooDialog.MOVE_TRACK); + } else if (command == "Insert measure...") { } else if (command == "Delete measure...") { @@ -216,4 +256,6 @@ public class MooMenu extends JMenuBar implements ActionListener { return "MIDI files"; } } -} \ No newline at end of file + + +}