/[svn]/jsampler/trunk/src/org/jsampler/view/fantasia/MainFrame.java
ViewVC logotype

Diff of /jsampler/trunk/src/org/jsampler/view/fantasia/MainFrame.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1866 by iliev, Sun Mar 15 19:40:29 2009 UTC revision 1872 by iliev, Mon Mar 23 15:34:50 2009 UTC
# Line 53  import java.util.Vector; Line 53  import java.util.Vector;
53  import javax.swing.BorderFactory;  import javax.swing.BorderFactory;
54  import javax.swing.BoxLayout;  import javax.swing.BoxLayout;
55  import javax.swing.JCheckBoxMenuItem;  import javax.swing.JCheckBoxMenuItem;
 import javax.swing.JFileChooser;  
56  import javax.swing.JMenu;  import javax.swing.JMenu;
57  import javax.swing.JMenuBar;  import javax.swing.JMenuBar;
58  import javax.swing.JMenuItem;  import javax.swing.JMenuItem;
# Line 72  import org.jsampler.LSConsoleModel; Line 71  import org.jsampler.LSConsoleModel;
71  import org.jsampler.Server;  import org.jsampler.Server;
72    
73  import org.jsampler.view.JSChannelsPane;  import org.jsampler.view.JSChannelsPane;
 import org.jsampler.view.LscpFileFilter;  
74  import org.jsampler.view.SessionViewConfig;  import org.jsampler.view.SessionViewConfig;
75    
76  import org.jsampler.view.fantasia.basic.FantasiaPainter;  import org.jsampler.view.fantasia.basic.FantasiaPainter;
# Line 98  import static org.jsampler.view.std.StdP Line 96  import static org.jsampler.view.std.StdP
96   * @author Grigor Iliev   * @author Grigor Iliev
97   */   */
98  public class MainFrame extends StdMainFrame {  public class MainFrame extends StdMainFrame {
99            public final static int MAX_CHANNEL_LANE_NUMBER = 8;
100    
101          private final StandardBar standardBar = new StandardBar();          private final StandardBar standardBar = new StandardBar();
102          private final FantasiaMenuBar menuBar = new FantasiaMenuBar();          private final FantasiaMenuBar menuBar = new FantasiaMenuBar();
103          private final JPanel rootPane = new RootPane();          private final JPanel rootPane = new RootPane();
# Line 167  public class MainFrame extends StdMainFr Line 167  public class MainFrame extends StdMainFr
167                          addChannelsPane(mainPane.getChannelsPane(i));                          addChannelsPane(mainPane.getChannelsPane(i));
168                          getChannelsPane(i).addListSelectionListener(pianoKeyboardPane);                          getChannelsPane(i).addListSelectionListener(pianoKeyboardPane);
169                  }                  }
170                    
171                    PropertyChangeListener l = new PropertyChangeListener() {
172                            public void
173                            propertyChange(PropertyChangeEvent e) {
174                                    onChangeChannelLaneCount();
175                            }
176                    };
177    
178                    preferences().addPropertyChangeListener("channelLanes.count", l);
179                                    
180                  int h = preferences().getIntProperty("midiKeyboard.height");                  int h = preferences().getIntProperty("midiKeyboard.height");
181                  setMidiKeyboardHeight(h);                  setMidiKeyboardHeight(h);
182                                    
183                  PropertyChangeListener l = new PropertyChangeListener() {                  l = new PropertyChangeListener() {
184                          public void                          public void
185                          propertyChange(PropertyChangeEvent e) {                          propertyChange(PropertyChangeEvent e) {
186                                  int h = preferences().getIntProperty("midiKeyboard.height");                                  int h = preferences().getIntProperty("midiKeyboard.height");
# Line 304  public class MainFrame extends StdMainFr Line 312  public class MainFrame extends StdMainFr
312                                    
313                  super.onWindowClose();                  super.onWindowClose();
314          }          }
315    
316            private void
317            onChangeChannelLaneCount() {
318                    int newCount = preferences().getIntProperty("channelLanes.count");
319                    if(newCount < 1 || newCount > MAX_CHANNEL_LANE_NUMBER) return;
320                    if(newCount == getChannelsPaneCount()) return;
321                    int current = getChannelsPaneIndex(getSelectedChannelsPane());
322    
323                    if(newCount > getChannelsPaneCount()) {
324                            int d = newCount - getChannelsPaneCount();
325                            for(int i = 0; i < d; i++) {
326                                    JSChannelsPane p = mainPane.addChannelsPane();
327                                    addChannelsPane(p);
328                                    p.addListSelectionListener(pianoKeyboardPane);
329                            }
330                    } else {
331                            int d = getChannelsPaneCount() - newCount;
332                            for(int i = 0; i < d; i++) {
333                                    int idx = getChannelsPaneCount() - 1 - i;
334                                    if(getChannelsPane(idx).getChannelCount() > 0) {
335                                            String s;
336                                            s = i18n.getError("MainFrame.notEmptyChannelLane!", idx + 1);
337                                            HF.showErrorMessage(s);
338                                            return;
339                                    }
340                            }
341    
342                            for(int i = 0; i < d; i++) {
343                                    int idx = getChannelsPaneCount() - 1;
344                                    JSChannelsPane p = getChannelsPane(idx);
345                                    removeChannelsPane(p);
346                                    p.removeListSelectionListener(pianoKeyboardPane);
347                                    mainPane.removeChannelsPane(idx);
348                            }
349                    }
350    
351                    if(newCount == 1) {
352                            mainPane.getButtonsPanel().setVisible(false);
353                    } else if(!mainPane.getButtonsPanel().isVisible()) {
354                            mainPane.getButtonsPanel().setVisible(true);
355                    }
356                    mainPane.getButtonsPanel().setButtonNumber(newCount);
357                    if(current < 0 || current >= getChannelsPaneCount()) current = 0;
358                    setSelectedChannelsPane(getChannelsPane(current));
359            }
360                    
361          @Override          @Override
362          public void          public void
# Line 714  public class MainFrame extends StdMainFr Line 767  public class MainFrame extends StdMainFr
767                    
768          protected boolean          protected boolean
769          runScript() {          runScript() {
770                  String s = preferences().getStringProperty("lastScriptLocation");                  File f = StdUtils.showOpenLscpFileChooser();
771                  JFileChooser fc = new JFileChooser(s);                  if(f == null) return false;
772                  fc.setFileFilter(new LscpFileFilter());                  runScript(f);
                 int result = fc.showOpenDialog(this);  
                 if(result != JFileChooser.APPROVE_OPTION) return false;  
                   
                 String path = fc.getCurrentDirectory().getAbsolutePath();  
                 preferences().setStringProperty("lastScriptLocation", path);  
                                           
                 runScript(fc.getSelectedFile());  
773                                    
774                  return true;                  return true;
775          }          }
# Line 737  public class MainFrame extends StdMainFr Line 783  public class MainFrame extends StdMainFr
783                  FileReader fr;                  FileReader fr;
784                  try { fr = new FileReader(script); }                  try { fr = new FileReader(script); }
785                  catch(FileNotFoundException e) {                  catch(FileNotFoundException e) {
786                          HF.showErrorMessage(i18n.getMessage("FileNotFound!"));                          HF.showErrorMessage(i18n.getError("fileNotFound!"));
787                          return;                          return;
788                  }                  }
789                                    

Legend:
Removed from v.1866  
changed lines
  Added in v.1872

  ViewVC Help
Powered by ViewVC