/[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 1323 by iliev, Tue Sep 4 15:41:13 2007 UTC revision 1786 by iliev, Wed Oct 8 22:38:15 2008 UTC
# Line 1  Line 1 
1  /*  /*
2   *   JSampler - a java front-end for LinuxSampler   *   JSampler - a java front-end for LinuxSampler
3   *   *
4   *   Copyright (C) 2005-2007 Grigor Iliev <grigor@grigoriliev.com>   *   Copyright (C) 2005-2008 Grigor Iliev <grigor@grigoriliev.com>
5   *   *
6   *   This file is part of JSampler.   *   This file is part of JSampler.
7   *   *
# Line 23  Line 23 
23  package org.jsampler.view.fantasia;  package org.jsampler.view.fantasia;
24    
25  import java.awt.BorderLayout;  import java.awt.BorderLayout;
26    import java.awt.Color;
27    import java.awt.Composite;
28  import java.awt.Dialog;  import java.awt.Dialog;
29  import java.awt.Dimension;  import java.awt.Dimension;
30  import java.awt.Frame;  import java.awt.Frame;
31  import java.awt.Graphics;  import java.awt.Graphics;
32    import java.awt.Graphics2D;
33  import java.awt.GridBagConstraints;  import java.awt.GridBagConstraints;
34  import java.awt.GridBagLayout;  import java.awt.GridBagLayout;
35  import java.awt.Insets;  import java.awt.Insets;
36  import java.awt.Point;  import java.awt.Paint;
37    import java.awt.Rectangle;
38    
39  import java.awt.event.ActionEvent;  import java.awt.event.ActionEvent;
40  import java.awt.event.ActionListener;  import java.awt.event.ActionListener;
41  import java.awt.event.KeyEvent;  import java.awt.event.KeyEvent;
42  import java.awt.event.MouseAdapter;  
43  import java.awt.event.MouseEvent;  import java.beans.PropertyChangeEvent;
44    import java.beans.PropertyChangeListener;
45    
46  import java.io.BufferedReader;  import java.io.BufferedReader;
47  import java.io.File;  import java.io.File;
# Line 44  import java.io.FileNotFoundException; Line 49  import java.io.FileNotFoundException;
49  import java.io.FileReader;  import java.io.FileReader;
50    
51  import java.util.Vector;  import java.util.Vector;
 import java.util.logging.Level;  
52    
53  import javax.swing.BorderFactory;  import javax.swing.BorderFactory;
 import javax.swing.Box;  
54  import javax.swing.BoxLayout;  import javax.swing.BoxLayout;
55  import javax.swing.JCheckBoxMenuItem;  import javax.swing.JCheckBoxMenuItem;
 import javax.swing.JComponent;  
 import javax.swing.JDialog;  
56  import javax.swing.JFileChooser;  import javax.swing.JFileChooser;
 import javax.swing.JFrame;  
57  import javax.swing.JMenu;  import javax.swing.JMenu;
58  import javax.swing.JMenuBar;  import javax.swing.JMenuBar;
59  import javax.swing.JMenuItem;  import javax.swing.JMenuItem;
60  import javax.swing.JPanel;  import javax.swing.JPanel;
 import javax.swing.JPopupMenu;  
 import javax.swing.JScrollPane;  
61  import javax.swing.JSplitPane;  import javax.swing.JSplitPane;
 import javax.swing.JToggleButton;  
62  import javax.swing.KeyStroke;  import javax.swing.KeyStroke;
63  import javax.swing.SwingUtilities;  import javax.swing.SwingUtilities;
64  import javax.swing.UIManager;  import javax.swing.Timer;
   
 import net.sf.juife.TitleBar;  
65    
66  import org.jsampler.CC;  import org.jsampler.CC;
67  import org.jsampler.HF;  import org.jsampler.HF;
68  import org.jsampler.LSConsoleModel;  import org.jsampler.LSConsoleModel;
69    import org.jsampler.Server;
70    
 import org.jsampler.view.JSChannel;  
71  import org.jsampler.view.JSChannelsPane;  import org.jsampler.view.JSChannelsPane;
72  import org.jsampler.view.JSMainFrame;  import org.jsampler.view.JSMainFrame;
73  import org.jsampler.view.LscpFileFilter;  import org.jsampler.view.LscpFileFilter;
74    
75    import org.jsampler.view.fantasia.basic.FantasiaPainter;
76    import org.jsampler.view.fantasia.basic.FantasiaPanel;
77    import org.jsampler.view.fantasia.basic.FantasiaSubPanel;
78    
79    import org.jsampler.view.std.JSBackendLogFrame;
80    import org.jsampler.view.std.JSConnectDlg;
81    import org.jsampler.view.std.JSDetailedErrorDlg;
82    import org.jsampler.view.std.JSQuitDlg;
83  import org.jsampler.view.std.JSamplerHomeChooser;  import org.jsampler.view.std.JSamplerHomeChooser;
84    import org.jsampler.view.std.StdUtils;
85    
86  import static org.jsampler.view.fantasia.A4n.a4n;  import static org.jsampler.view.fantasia.A4n.a4n;
87  import static org.jsampler.view.fantasia.FantasiaI18n.i18n;  import static org.jsampler.view.fantasia.FantasiaI18n.i18n;
# Line 92  import static org.jsampler.view.std.StdP Line 96  import static org.jsampler.view.std.StdP
96  public class MainFrame extends JSMainFrame {  public class MainFrame extends JSMainFrame {
97          private final StandardBar standardBar = new StandardBar();          private final StandardBar standardBar = new StandardBar();
98          private final FantasiaMenuBar menuBar = new FantasiaMenuBar();          private final FantasiaMenuBar menuBar = new FantasiaMenuBar();
99          private final JPanel rootPane = new JPanel();          private final JPanel rootPane = new RootPane();
100          private final MainPane mainPane = new MainPane();          private final BottomPane bottomPane;
101          private final DevicesPane devicesPane = new DevicesPane();          private final MainPane mainPane;
102          private final JScrollPane spDevicesPane = new JScrollPane();          private final PianoKeyboardPane pianoKeyboardPane;
103                    
104          private final JMenu recentScriptsMenu =          private final JMenu recentScriptsMenu =
105                  new JMenu(i18n.getMenuLabel("actions.recentScripts"));                  new JMenu(i18n.getMenuLabel("actions.recentScripts"));
106                    
107          private final JSplitPane hSplitPane;          private final JSplitPane hSplitPane;
108                    
109          private final SidePane sidePane = new SidePane();          private final LeftSidePane leftSidePane;
110            private final RightSidePane rightSidePane;
111          private final JPanel rightPane;          private final JPanel rightPane;
112                    
113            //private final StatusBar statusBar = new StatusBar();
114            
115          private final LSConsoleFrame lsConsoleFrame = new LSConsoleFrame();          private final LSConsoleFrame lsConsoleFrame = new LSConsoleFrame();
116          private final Vector<String> recentScripts = new Vector<String>();          private final Vector<String> recentScripts = new Vector<String>();
117            
118            private final JSBackendLogFrame backendLogFrame = new JSBackendLogFrame();
119                                    
120                    
121          private final JCheckBoxMenuItem cbmiToolBarVisible =          private final JCheckBoxMenuItem cbmiToolBarVisible =
122                          new JCheckBoxMenuItem(i18n.getMenuLabel("view.toolBar"));                          new JCheckBoxMenuItem(i18n.getMenuLabel("view.toolBar"));
123                    
124          private final JCheckBoxMenuItem cbmiSidePaneVisible =          private final JCheckBoxMenuItem cbmiLeftSidePaneVisible =
125                          new JCheckBoxMenuItem(i18n.getMenuLabel("view.sidePane"));                          new JCheckBoxMenuItem(i18n.getMenuLabel("view.leftSidePane"));
126            
127            private final JCheckBoxMenuItem cbmiRightSidePaneVisible =
128                            new JCheckBoxMenuItem(i18n.getMenuLabel("view.rightSidePane"));
129                    
130          private final JCheckBoxMenuItem cbmiDevicesPaneVisible =          private final JCheckBoxMenuItem cbmiMidiKeyboardVisible =
131                          new JCheckBoxMenuItem(i18n.getMenuLabel("view.devicesPane"));                          new JCheckBoxMenuItem(i18n.getMenuLabel("view.midiKeyboard"));
132            
133            private final Timer guiTimer = new Timer(1000, null);
134                    
135          /** Creates a new instance of <code>MainFrame</code> */          /** Creates a new instance of <code>MainFrame</code> */
136          public          public
137          MainFrame() {          MainFrame() {
138                  setTitle(i18n.getLabel("MainFrame.title"));                  setTitle(i18n.getLabel("MainFrame.title"));
139                                    //setUndecorated(true);
140                  if(Res.iconAppIcon != null) setIconImage(Res.iconAppIcon.getImage());                  if(Res.iconAppIcon != null) setIconImage(Res.iconAppIcon.getImage());
141                                    
142                    CC.setMainFrame(this); // TODO:
143                    mainPane = new MainPane();
144                    leftSidePane = new LeftSidePane();
145                    rightSidePane = new RightSidePane();
146                    
147                    setSelectedChannelsPane(mainPane.getChannelsPane(0));
148                    
149                  getContentPane().add(standardBar, BorderLayout.NORTH);                  getContentPane().add(standardBar, BorderLayout.NORTH);
150                                    
151                  rightPane = createRightPane();                  rightPane = createRightPane();
# Line 132  public class MainFrame extends JSMainFra Line 153  public class MainFrame extends JSMainFra
153                  hSplitPane = new JSplitPane (                  hSplitPane = new JSplitPane (
154                          JSplitPane.HORIZONTAL_SPLIT,                          JSplitPane.HORIZONTAL_SPLIT,
155                          true,   // continuousLayout                          true,   // continuousLayout
156                          sidePane, rightPane                          leftSidePane, rightPane
157                  );                  );
158                  hSplitPane.setResizeWeight(0.5);                  hSplitPane.setResizeWeight(0.5);
159                                    
160                  rootPane.setLayout(new BorderLayout());                  pianoKeyboardPane = new PianoKeyboardPane();
161                  rootPane.setBorder(BorderFactory.createEmptyBorder(6, 0, 0, 0));                  
162                  rootPane.setOpaque(false);                  for(int i = 0; i < mainPane.getChannelsPaneCount(); i++) {
163                  rootPane.add(hSplitPane);                          addChannelsPane(mainPane.getChannelsPane(i));
164                            getChannelsPane(i).addListSelectionListener(pianoKeyboardPane);
165                    }
166                                    
                 addMenu();  
167                                    
168                  addChannelsPane(mainPane.getChannelsPane());                  int h = preferences().getIntProperty("midiKeyboard.height");
169                    setMidiKeyboardHeight(h);
170                                    
171                  getContentPane().add(rootPane);                  PropertyChangeListener l = new PropertyChangeListener() {
172                            public void
173                            propertyChange(PropertyChangeEvent e) {
174                                    int h = preferences().getIntProperty("midiKeyboard.height");
175                                    setMidiKeyboardHeight(h);
176                            }
177                    };
178                    
179                    CC.preferences().addPropertyChangeListener("midiKeyboard.height", l);
180                    
181                    bottomPane = new BottomPane();
182                    
183                    hSplitPane.setOpaque(false);
184                    rootPane.add(hSplitPane);
185                    rootPane.add(bottomPane, BorderLayout.SOUTH);
186                    add(rootPane);
187                    
188                    addMenu();
189                                    
190                  int i = preferences().getIntProperty("MainFrame.hSplitDividerLocation", 220);                  int i = preferences().getIntProperty("MainFrame.hSplitDividerLocation", 220);
191                  hSplitPane.setDividerLocation(i);                  hSplitPane.setDividerLocation(i);
192                                    
193                  setSavedSize();                  setSavedSize();
194                    
195                    guiTimer.start();
196          }          }
197                    
198          private JPanel          private JPanel
199          createRightPane() {          createRightPane() {
200                  JPanel p = new JPanel();                  JPanel p = new FantasiaPanel();
201                    p.setOpaque(false);
202                    
203                  GridBagLayout gridbag = new GridBagLayout();                  GridBagLayout gridbag = new GridBagLayout();
204                  GridBagConstraints c = new GridBagConstraints();                  GridBagConstraints c = new GridBagConstraints();
205                                    
# Line 163  public class MainFrame extends JSMainFra Line 207  public class MainFrame extends JSMainFra
207                                    
208                  c.fill = GridBagConstraints.BOTH;                  c.fill = GridBagConstraints.BOTH;
209                                    
                 spDevicesPane.setViewportView(devicesPane);  
                 spDevicesPane.setBorder(BorderFactory.createEmptyBorder());  
                 int h = spDevicesPane.getMinimumSize().height;  
                 spDevicesPane.setMinimumSize(new Dimension(200, h));  
                   
210                  c.gridx = 1;                  c.gridx = 1;
211                  c.gridy = 0;                  c.gridy = 0;
212                  c.weightx = 1.0;                  c.weightx = 1.0;
213                  c.weighty = 1.0;                  c.weighty = 1.0;
214                  c.insets = new Insets(0, 3, 3, 0);                  c.insets = new Insets(0, 3, 0, 0);
215                  gridbag.setConstraints(spDevicesPane, c);                  gridbag.setConstraints(rightSidePane, c);
216                  p.add(spDevicesPane);                  p.add(rightSidePane);
217                                    
218                  c.gridx = 0;                  c.gridx = 0;
219                  c.gridy = 0;                  c.gridy = 0;
220                  c.weightx = 0.0;                  c.weightx = 0.0;
221                  c.weighty = 1.0;                  c.weighty = 1.0;
222                  c.insets = new Insets(0, 3, 3, 3);                  c.insets = new Insets(0, 0, 0, 3);
223                  c.fill = GridBagConstraints.VERTICAL;                  c.fill = GridBagConstraints.VERTICAL;
224                  gridbag.setConstraints(mainPane, c);                  gridbag.setConstraints(mainPane, c);
225                  p.add(mainPane);                  p.add(mainPane);
# Line 190  public class MainFrame extends JSMainFra Line 229  public class MainFrame extends JSMainFra
229                    
230          private void          private void
231          setSavedSize() {          setSavedSize() {
232                  String s = preferences().getStringProperty("MainFrame.sizeAndLocation");                  Rectangle r = StdUtils.getWindowBounds("MainFrame");
233                  if(s == null) {                  if(r == null) {
234                          setDefaultSizeAndLocation();                          setDefaultSizeAndLocation();
235                          return;                          return;
236                  }                  }
                 pack();  
                 try {  
                         int i = s.indexOf(',');  
                         int x = Integer.parseInt(s.substring(0, i));  
                           
                         s = s.substring(i + 1);  
                         i = s.indexOf(',');  
                         int y = Integer.parseInt(s.substring(0, i));  
                           
                         s = s.substring(i + 1);  
                         i = s.indexOf(',');  
                         int width = Integer.parseInt(s.substring(0, i));  
                           
                         s = s.substring(i + 1);  
                         int height = Integer.parseInt(s);  
                           
                         setBounds(x, y, width, height);  
                 } catch(Exception x) {  
                         String msg = "Parsing of window size and location string failed";  
                         CC.getLogger().log(Level.INFO, msg, x);  
                         setDefaultSizeAndLocation();  
                 }  
237                                    
238                  if(preferences().getBoolProperty("MainFrame.windowMaximized")) {                  setBounds(r);
                         setExtendedState(getExtendedState() | MAXIMIZED_BOTH);  
                 }  
239          }          }
240                    
241          private void          private void
# Line 232  public class MainFrame extends JSMainFra Line 247  public class MainFrame extends JSMainFra
247                    
248                    
249          /** Invoked when this window is about to close. */          /** Invoked when this window is about to close. */
250            @Override
251          protected void          protected void
252          onWindowClose() {          onWindowClose() {
253                  sidePane.savePreferences();                  boolean b = preferences().getBoolProperty(CONFIRM_APP_QUIT);
254                    if(b && CC.getSamplerModel().isModified()) {
255                            JSQuitDlg dlg = new JSQuitDlg(Res.iconQuestion32);
256                            dlg.setVisible(true);
257                            if(dlg.isCancelled()) return;
258                    }
259                    
260                    leftSidePane.savePreferences();
261                    rightSidePane.savePreferences();
262                                    
263                  int i = hSplitPane.getDividerLocation();                  int i = hSplitPane.getDividerLocation();
264                  preferences().setIntProperty("MainFrame.hSplitDividerLocation", i);                  preferences().setIntProperty("MainFrame.hSplitDividerLocation", i);
# Line 249  public class MainFrame extends JSMainFra Line 273  public class MainFrame extends JSMainFra
273                          return;                          return;
274                  }                  }
275                                    
276                  java.awt.Point p = getLocation();                  StdUtils.saveWindowBounds("MainFrame", getBounds());
                 Dimension d = getSize();  
                 StringBuffer sb = new StringBuffer();  
                 sb.append(p.x).append(',').append(p.y).append(',');  
                 sb.append(d.width).append(',').append(d.height);  
                 preferences().setStringProperty("MainFrame.sizeAndLocation", sb.toString());  
277                                    
278                  String[] list = recentScripts.toArray(new String[recentScripts.size()]);                  String[] list = recentScripts.toArray(new String[recentScripts.size()]);
279                  preferences().setStringListProperty(RECENT_LSCP_SCRIPTS, list);                  preferences().setStringListProperty(RECENT_LSCP_SCRIPTS, list);
# Line 263  public class MainFrame extends JSMainFra Line 282  public class MainFrame extends JSMainFra
282                          if(lsConsoleFrame != null) getLSConsolePane().saveConsoleHistory();                          if(lsConsoleFrame != null) getLSConsolePane().saveConsoleHistory();
283                  }                  }
284                                    
285                    if(getBackendLogFrame() != null) getBackendLogFrame().stopTimer();
286                    if(getLSConsolePane() != null) getLSConsolePane().disconnect();
287                    
288                  super.onWindowClose();                  super.onWindowClose();
289          }          }
290                    
291            @Override
292            public void
293            setVisible(boolean b) {
294                    if(b == isVisible()) return;
295                    
296                    super.setVisible(b);
297                    
298                    if(b && preferences().getBoolProperty("MainFrame.windowMaximized")) {
299                            setExtendedState(getExtendedState() | MAXIMIZED_BOTH);
300                    }
301            }
302            
303          private void          private void
304          addMenu() {          addMenu() {
305                  JMenu m;                  JMenu m;
# Line 276  public class MainFrame extends JSMainFra Line 310  public class MainFrame extends JSMainFra
310                  // Actions                  // Actions
311                  m = new FantasiaMenu(i18n.getMenuLabel("actions"));                  m = new FantasiaMenu(i18n.getMenuLabel("actions"));
312                                    
313                  mi = new JMenuItem(a4n.connect);                  mi = new JMenuItem(a4n.refresh);
314                  mi.setIcon(null);                  mi.setIcon(null);
315                  //mi.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_N, KeyEvent.CTRL_MASK));                  mi.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F5, 0));
316                  m.add(mi);                  m.add(mi);
317                                    
318                  mi = new JMenuItem(a4n.samplerInfo);                  mi = new JMenuItem(a4n.samplerInfo);
319                  mi.setIcon(null);                  mi.setIcon(null);
320                  m.add(mi);                  m.add(mi);
321                                    
322                    mi = new JMenuItem(a4n.resetSampler);
323                    mi.setIcon(null);
324                    m.add(mi);
325                    
326                  m.addSeparator();                  m.addSeparator();
327                                    
328                  JMenu exportMenu = new JMenu(i18n.getMenuLabel("actions.export"));                  JMenu exportMenu = new JMenu(i18n.getMenuLabel("actions.export"));
# Line 303  public class MainFrame extends JSMainFra Line 341  public class MainFrame extends JSMainFra
341                                    
342                  mi = new JMenuItem(a4n.loadScript);                  mi = new JMenuItem(a4n.loadScript);
343                  mi.setIcon(null);                  mi.setIcon(null);
344                    mi.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, KeyEvent.CTRL_MASK));
345                  m.add(mi);                  m.add(mi);
346                                    
347                  String[] list = preferences().getStringListProperty(RECENT_LSCP_SCRIPTS);                  String[] list = preferences().getStringListProperty(RECENT_LSCP_SCRIPTS);
# Line 314  public class MainFrame extends JSMainFra Line 353  public class MainFrame extends JSMainFra
353                                    
354                  m.addSeparator();                  m.addSeparator();
355                                    
356                    mi = new JMenuItem(a4n.changeBackend);
357                    mi.setIcon(null);
358                    mi.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_B, KeyEvent.CTRL_MASK));
359                    m.add(mi);
360                    
361                    m.addSeparator();
362                    
363                  mi = new JMenuItem(i18n.getMenuLabel("actions.exit"));                  mi = new JMenuItem(i18n.getMenuLabel("actions.exit"));
364                  m.add(mi);                  m.add(mi);
365                  mi.addActionListener(new ActionListener() {                  mi.addActionListener(new ActionListener() {
# Line 373  public class MainFrame extends JSMainFra Line 419  public class MainFrame extends JSMainFra
419                  cbmiToolBarVisible.setSelected(b);                  cbmiToolBarVisible.setSelected(b);
420                  showToolBar(b);                  showToolBar(b);
421                                    
422                  cbmiSidePaneVisible.setAccelerator(KeyStroke.getKeyStroke (                  cbmiLeftSidePaneVisible.setAccelerator(KeyStroke.getKeyStroke (
423                          KeyEvent.VK_L, KeyEvent.CTRL_MASK | KeyEvent.SHIFT_MASK                          KeyEvent.VK_L, KeyEvent.CTRL_MASK | KeyEvent.SHIFT_MASK
424                  ));                  ));
425                  m.add(cbmiSidePaneVisible);                  m.add(cbmiLeftSidePaneVisible);
426                                    
427                  cbmiSidePaneVisible.addActionListener(new ActionListener() {                  cbmiLeftSidePaneVisible.addActionListener(new ActionListener() {
428                          public void                          public void
429                          actionPerformed(ActionEvent e) {                          actionPerformed(ActionEvent e) {
430                                  showSidePane(cbmiSidePaneVisible.getState());                                  showSidePane(cbmiLeftSidePaneVisible.getState());
431                          }                          }
432                  });                  });
433                                    
434                  b = preferences().getBoolProperty("sidePane.visible");                  b = preferences().getBoolProperty("leftSidePane.visible");
435                  cbmiSidePaneVisible.setSelected(b);                  cbmiLeftSidePaneVisible.setSelected(b);
436                  showSidePane(b);                  showSidePane(b);
437                                    
438                  cbmiDevicesPaneVisible.setAccelerator(KeyStroke.getKeyStroke (                  cbmiRightSidePaneVisible.setAccelerator(KeyStroke.getKeyStroke (
439                          KeyEvent.VK_R, KeyEvent.CTRL_MASK | KeyEvent.SHIFT_MASK                          KeyEvent.VK_R, KeyEvent.CTRL_MASK | KeyEvent.SHIFT_MASK
440                  ));                  ));
441                  m.add(cbmiDevicesPaneVisible);                  m.add(cbmiRightSidePaneVisible);
442                                    
443                  cbmiDevicesPaneVisible.addActionListener(new ActionListener() {                  cbmiRightSidePaneVisible.addActionListener(new ActionListener() {
444                          public void                          public void
445                          actionPerformed(ActionEvent e) {                          actionPerformed(ActionEvent e) {
446                                  showDevicesPane(cbmiDevicesPaneVisible.getState());                                  showDevicesPane(cbmiRightSidePaneVisible.getState());
447                          }                          }
448                  });                  });
449                                    
450                  b = preferences().getBoolProperty("devicesPane.visible");                  b = preferences().getBoolProperty("rightSidePane.visible");
451                  cbmiDevicesPaneVisible.setSelected(b);                  cbmiRightSidePaneVisible.setSelected(b);
452                  showDevicesPane(b);                  showDevicesPane(b);
453                                    
454                    m.addSeparator();
455                    
456                    m.add(cbmiMidiKeyboardVisible);
457                    
458                    cbmiMidiKeyboardVisible.addActionListener(new ActionListener() {
459                            public void
460                            actionPerformed(ActionEvent e) {
461                                    setMidiKeyboardVisible(cbmiMidiKeyboardVisible.getState());
462                            }
463                    });
464                    
465                    b = preferences().getBoolProperty("midiKeyboard.visible");
466                    cbmiMidiKeyboardVisible.setSelected(b);
467                    setMidiKeyboardVisible(b);
468                    
469                                    
470                  // Window                  // Window
471                  m = new FantasiaMenu(i18n.getMenuLabel("window"));                  m = new FantasiaMenu(i18n.getMenuLabel("window"));
# Line 418  public class MainFrame extends JSMainFra Line 479  public class MainFrame extends JSMainFra
479                  mi.setIcon(null);                  mi.setIcon(null);
480                  m.add(mi);                  m.add(mi);
481                                    
482                    m.addSeparator();
483                    
484                    final JMenuItem mi2 = new JMenuItem(i18n.getMenuLabel("window.backendLog"));
485                    m.add(mi2);
486                    mi2.addActionListener(new ActionListener() {
487                            public void
488                            actionPerformed(ActionEvent e) {
489                                    if(getBackendLogFrame().isVisible()) {
490                                            getBackendLogFrame().setVisible(false);
491                                    }
492                                    
493                                    getBackendLogFrame().setVisible(true);
494                            }
495                    });
496                    
497                    mi2.setEnabled(CC.getBackendProcess() != null);
498                    
499                    CC.addBackendProcessListener(new ActionListener() {
500                            public void
501                            actionPerformed(ActionEvent e) {
502                                    mi2.setEnabled(CC.getBackendProcess() != null);
503                            }
504                    });
505                    
506                                    
507                  // Help                  // Help
508                  m = new FantasiaMenu(i18n.getMenuLabel("help"));                  m = new FantasiaMenu(i18n.getMenuLabel("help"));
509                                    
510                    mi = new JMenuItem(a4n.browseOnlineTutorial);
511                    mi.setIcon(null);
512                    m.add(mi);
513                    
514                    m.addSeparator();
515                    
516                  mi = new JMenuItem(a4n.helpAbout);                  mi = new JMenuItem(a4n.helpAbout);
517                  mi.setIcon(null);                  mi.setIcon(null);
518                  m.add(mi);                  m.add(mi);
# Line 429  public class MainFrame extends JSMainFra Line 520  public class MainFrame extends JSMainFra
520                  menuBar.add(m);                  menuBar.add(m);
521          }          }
522                    
523            public RightSidePane
524            getRightSidePane() { return rightSidePane; }
525            
526          /**          /**
527           * This method does nothing, because <b>Fantasia</b> has exactly           * This method does nothing, because <b>Fantasia</b> has constant
528           * one pane containing sampler channels, which can not be changed.           * number of panes containing sampler channels, which can not be changed.
529           */           */
530            @Override
531          public void          public void
532          insertChannelsPane(JSChannelsPane pane, int idx) {          insertChannelsPane(JSChannelsPane pane, int idx) {
533                                    
534          }          }
535                    
536          /**          @Override
          * This method always returns the <code>JSChannelsPane</code> at index 0,  
          * because the <b>Fantasia</b> view has exactly one pane containing sampler channels.  
          * @return The <code>JSChannelsPane</code> at index 0.  
          */  
537          public JSChannelsPane          public JSChannelsPane
538          getSelectedChannelsPane() { return getChannelsPane(0); }          getSelectedChannelsPane() { return mainPane.getSelectedChannelsPane(); }
539                    
540          /**          @Override
          * This method does nothing because the <b>Fantasia</b> view has  
          * exactly one pane containing sampler channels which is always shown.  
          */  
541          public void          public void
542          setSelectedChannelsPane(JSChannelsPane pane) { }          setSelectedChannelsPane(JSChannelsPane pane) {
543                    mainPane.setSelectedChannelsPane(pane);
544                    fireChannelsPaneSelectionChanged();
545            }
546                    
547            @Override
548          public void          public void
549          installJSamplerHome() {          installJSamplerHome() {
550                  JSamplerHomeChooser chooser = new JSamplerHomeChooser(this);                  JSamplerHomeChooser chooser = new JSamplerHomeChooser(this);
# Line 462  public class MainFrame extends JSMainFra Line 554  public class MainFrame extends JSMainFra
554                  CC.changeJSamplerHome(chooser.getJSamplerHome());                  CC.changeJSamplerHome(chooser.getJSamplerHome());
555          }          }
556                    
557            @Override
558          public void          public void
559          showDetailedErrorMessage(Frame owner, String err, String details) {          showDetailedErrorMessage(Frame owner, String err, String details) {
560                  // TODO:                  JSDetailedErrorDlg dlg = new JSDetailedErrorDlg (
561                            owner, Res.iconWarning32, i18n.getError("error"), err, details
562                    );
563                    dlg.setVisible(true);
564          }          }
565                    
566            @Override
567          public void          public void
568          showDetailedErrorMessage(Dialog owner, String err, String details) {          showDetailedErrorMessage(Dialog owner, String err, String details) {
569                  // TODO:                  JSDetailedErrorDlg dlg = new JSDetailedErrorDlg (
570                            owner, Res.iconWarning32, i18n.getError("error"), err, details
571                    );
572                    dlg.setVisible(true);
573            }
574            
575            /**
576             * Gets the server address to which to connect. If the server should be
577             * manually selected, a dialog asking the user to choose a server is displayed.
578             */
579            @Override
580            public Server
581            getServer() {
582                    boolean b = preferences().getBoolProperty(MANUAL_SERVER_SELECT_ON_STARTUP);
583                    return getServer(b);
584            }
585            
586            /**
587             * Gets the server address to which to connect. If the server should be
588             * manually selected, a dialog asking the user to choose a server is displayed.
589             * @param manualSelect Determines whether the server should be manually selected.
590             */
591            @Override
592            public Server
593            getServer(boolean manualSelect) {
594                    if(manualSelect) {
595                            JSConnectDlg dlg = new JSConnectDlg();
596                            dlg.setVisible(true);
597                            
598                            return dlg.getSelectedServer();
599                    }
600                    
601                    int i = preferences().getIntProperty(SERVER_INDEX);
602                    int size = CC.getServerList().getServerCount();
603                    if(size == 0) return null;
604                    if(i >= size) return CC.getServerList().getServer(0);
605                    
606                    return CC.getServerList().getServer(i);
607          }          }
608                    
609            public Timer
610            getGuiTimer() { return guiTimer; }
611            
612          protected LSConsoleModel          protected LSConsoleModel
613          getLSConsoleModel() { return getLSConsolePane().getModel(); }          getLSConsoleModel() { return getLSConsolePane().getModel(); }
614                    
# Line 483  public class MainFrame extends JSMainFra Line 620  public class MainFrame extends JSMainFra
620          protected LSConsoleFrame          protected LSConsoleFrame
621          getLSConsoleFrame() { return lsConsoleFrame; }          getLSConsoleFrame() { return lsConsoleFrame; }
622                    
623          protected void          public JSBackendLogFrame
624            getBackendLogFrame() { return backendLogFrame; }
625            
626            protected boolean
627          runScript() {          runScript() {
628                  String s = preferences().getStringProperty("lastScriptLocation");                  String s = preferences().getStringProperty("lastScriptLocation");
629                  JFileChooser fc = new JFileChooser(s);                  JFileChooser fc = new JFileChooser(s);
630                  fc.setFileFilter(new LscpFileFilter());                  fc.setFileFilter(new LscpFileFilter());
631                  int result = fc.showOpenDialog(this);                  int result = fc.showOpenDialog(this);
632                  if(result != JFileChooser.APPROVE_OPTION) return;                  if(result != JFileChooser.APPROVE_OPTION) return false;
633                                    
634                  String path = fc.getCurrentDirectory().getAbsolutePath();                  String path = fc.getCurrentDirectory().getAbsolutePath();
635                  preferences().setStringProperty("lastScriptLocation", path);                  preferences().setStringProperty("lastScriptLocation", path);
636                                                                                    
637                  runScript(fc.getSelectedFile());                  runScript(fc.getSelectedFile());
638                    
639                    return true;
640          }          }
641                    
642          private void          @Override
643            public void
644          runScript(String script) { runScript(new File(script)); }          runScript(String script) { runScript(new File(script)); }
645                    
646          private void          private void
# Line 562  public class MainFrame extends JSMainFra Line 705  public class MainFrame extends JSMainFra
705                    
706          private void          private void
707          showSidePane(boolean b) {          showSidePane(boolean b) {
708                  preferences().setBoolProperty("sidePane.visible", b);                  preferences().setBoolProperty("leftSidePane.visible", b);
709                  rootPane.remove(rightPane);                  rootPane.remove(rightPane);
710                  rootPane.remove(hSplitPane);                  rootPane.remove(hSplitPane);
711                                    
# Line 570  public class MainFrame extends JSMainFra Line 713  public class MainFrame extends JSMainFra
713                          hSplitPane.setRightComponent(rightPane);                          hSplitPane.setRightComponent(rightPane);
714                          rootPane.add(hSplitPane);                          rootPane.add(hSplitPane);
715                          int i = preferences().getIntProperty("MainFrame.hSplitDividerLocation", 220);                          int i = preferences().getIntProperty("MainFrame.hSplitDividerLocation", 220);
                         System.out.println("side pane: " + i);  
716                                                    
717                          hSplitPane.setDividerLocation(i);                          hSplitPane.setDividerLocation(i);
718                          hSplitPane.validate();                          hSplitPane.validate();
# Line 595  public class MainFrame extends JSMainFra Line 737  public class MainFrame extends JSMainFra
737                    
738          private void          private void
739          showDevicesPane(boolean b) {          showDevicesPane(boolean b) {
740                  preferences().setBoolProperty("devicesPane.visible", b);                  preferences().setBoolProperty("rightSidePane.visible", b);
741                                    
742                  int width = sidePane.getWidth();                  int width = leftSidePane.getWidth();
743                  int height = sidePane.getPreferredSize().height;                  int height = leftSidePane.getPreferredSize().height;
744                  if(width != 0) sidePane.setPreferredSize(new Dimension(width, height));                  if(width != 0) leftSidePane.setPreferredSize(new Dimension(width, height));
745                                    
746                  if(b) {                  if(b) {
747                          int w = preferences().getIntProperty("devicesPane.width", 200);                          int w = preferences().getIntProperty("devicesPane.width", 200);
748                                                    
749                          int h = spDevicesPane.getPreferredSize().height;                          int h = rightSidePane.getPreferredSize().height;
750                          spDevicesPane.setPreferredSize(new Dimension(w, h));                          rightSidePane.setPreferredSize(new Dimension(w, h));
751                  } else {                  } else {
752                          int w = spDevicesPane.getWidth();                          int w = rightSidePane.getWidth();
753                          if(w > 0 && w < 200) w = 200;                          if(w > 0 && w < 200) w = 200;
754                          if(w != 0) preferences().setIntProperty("devicesPane.width", w);                          if(w != 0) preferences().setIntProperty("devicesPane.width", w);
755                  }                  }
756                                    
757                  hSplitPane.setResizeWeight(0.0);                  hSplitPane.setResizeWeight(0.0);
758                  spDevicesPane.setVisible(b);                  rightSidePane.setVisible(b);
759                  hSplitPane.resetToPreferredSizes();                  hSplitPane.resetToPreferredSizes();
760                                    
761                  int w = getPreferredSize().width;                  int w = getPreferredSize().width;
# Line 630  public class MainFrame extends JSMainFra Line 772  public class MainFrame extends JSMainFra
772                  });                  });
773          }          }
774                    
775            public void
776            setMidiKeyboardVisible(boolean b) {
777                    preferences().setBoolProperty("midiKeyboard.visible", b);
778                    pianoKeyboardPane.setVisible(b);
779                    
780                    if(cbmiMidiKeyboardVisible.isSelected() != b) {
781                            cbmiMidiKeyboardVisible.setSelected(b);
782                    }
783                    
784                    if(standardBar.btnMidiKeyboard.isSelected() != b) {
785                            standardBar.btnMidiKeyboard.setSelected(b);
786                    }
787                    
788                    if(pianoKeyboardPane.btnPower.isSelected() != b) {
789                            pianoKeyboardPane.btnPower.setSelected(b);
790                    }
791                    
792                    rootPane.validate();
793                    rootPane.repaint();
794            }
795            
796            public void
797            setMidiKeyboardHeight(int height) {
798                    Dimension d = pianoKeyboardPane.getPreferredSize();
799                    d = new Dimension(d.width, height);
800                    pianoKeyboardPane.setPreferredSize(d);
801                    pianoKeyboardPane.setMinimumSize(d);
802                    pianoKeyboardPane.revalidate();
803                    pianoKeyboardPane.repaint();
804            }
805            
806          private void          private void
807          sidePanesVisibilityChanged() {          sidePanesVisibilityChanged() {
808                  boolean sidePaneVisible = cbmiSidePaneVisible.isSelected();                  boolean leftSidePaneVisible = cbmiLeftSidePaneVisible.isSelected();
809                  boolean devicesPaneVisible = cbmiDevicesPaneVisible.isSelected();                  boolean rightSidePaneVisible = cbmiRightSidePaneVisible.isSelected();
810                                    
811                  if(sidePaneVisible && devicesPaneVisible) {                  if(leftSidePaneVisible && rightSidePaneVisible) {
812                          hSplitPane.setResizeWeight(0.5);                          hSplitPane.setResizeWeight(0.5);
813                  } else if(sidePaneVisible && !devicesPaneVisible) {                  } else if(leftSidePaneVisible && !rightSidePaneVisible) {
814                          hSplitPane.setResizeWeight(1.0);                          hSplitPane.setResizeWeight(1.0);
815                  }                  }
816                                    
817                  if(!sidePaneVisible && !devicesPaneVisible) {                  if(!leftSidePaneVisible && !rightSidePaneVisible) {
818                          standardBar.showFantasiaLogo(false);                          standardBar.showFantasiaLogo(false);
819                          if(isResizable()) setResizable(false);                          if(isResizable()) setResizable(false);
820                  } else {                  } else {
# Line 655  public class MainFrame extends JSMainFra Line 828  public class MainFrame extends JSMainFra
828                                    
829                  RecentScriptHandler(String script) { this.script = script; }                  RecentScriptHandler(String script) { this.script = script; }
830                                    
831                    @Override
832                  public void                  public void
833                  actionPerformed(ActionEvent e) {                  actionPerformed(ActionEvent e) {
834                          runScript(script);                          runScript(script);
# Line 669  public class MainFrame extends JSMainFra Line 843  public class MainFrame extends JSMainFra
843                          super(s);                          super(s);
844                          setFont(getFont().deriveFont(java.awt.Font.BOLD));                          setFont(getFont().deriveFont(java.awt.Font.BOLD));
845                          setOpaque(false);                          setOpaque(false);
846                            setContentAreaFilled(false);
847                  }                  }
848          }          }
849    
850          private class FantasiaMenuBar extends JMenuBar {          private class FantasiaMenuBar extends JMenuBar {
                 private Insets pixmapInsets = new Insets(6, 6, 0, 6);  
                 private Insets pixmapInsets2 = new Insets(6, 6, 6, 6);  
                   
851                  FantasiaMenuBar() {                  FantasiaMenuBar() {
852                          setOpaque(false);                          setOpaque(false);
853                            setBorder(BorderFactory.createEmptyBorder(2, 6, 0, 0));
854                  }                  }
855                                    
856                    @Override
857                  protected void                  protected void
858                  paintComponent(Graphics g) {                  paintComponent(Graphics g) {
859                          super.paintComponent(g);                          //super.paintComponent(g);
860                            Graphics2D g2 = (Graphics2D)g;
861                            
862                            Paint oldPaint = g2.getPaint();
863                            Composite oldComposite = g2.getComposite();
864                            
865                            double h = getSize().getHeight();
866                            double w = getSize().getWidth();
867                            
868                            FantasiaPainter.paintGradient(g2, 0.0, 0.0, w - 1, h - 1, FantasiaPainter.color6, FantasiaPainter.color5);
869                            
870                            FantasiaPainter.Border b;
871                            
872                            
873                          if(standardBar.isVisible()) {                          if(standardBar.isVisible()) {
874                                  PixmapPane.paintComponent(this, g, Res.gfxMenuBarBg, pixmapInsets);                                  b = new FantasiaPainter.Border(true, true, false, true);
875                                    FantasiaPainter.paintBoldOuterBorder(g2, 0, 0, w - 1, h + 1, b);
876                          } else {                          } else {
877                                  PixmapPane.paintComponent(this, g, Res.gfxRoundBg14, pixmapInsets2);                                  b = new FantasiaPainter.Border(true, true, true, true);
878                                    FantasiaPainter.paintBoldOuterBorder(g2, 0, 0, w - 1, h - 1, b);
879                          }                          }
880                            
881                            g2.setPaint(oldPaint);
882                            g2.setComposite(oldComposite);
883                    }
884            }
885            
886            class RootPane extends FantasiaSubPanel {
887                    private final Color color1 = new Color(0x454545);
888                    private final Color color2 = new Color(0x2e2e2e);
889                    
890                    RootPane() {
891                            setLayout(new BorderLayout());
892                            setBorder(BorderFactory.createEmptyBorder(9, 10, 6, 10));
893                            setOpaque(false);
894                    
895                    }
896            
897                    @Override
898                    public void
899                    paintComponent(Graphics g) {
900                            Graphics2D g2 = (Graphics2D)g;
901                            
902                            Paint oldPaint = g2.getPaint();
903                            Composite oldComposite = g2.getComposite();
904                            
905                            double h = getSize().getHeight();
906                            double w = getSize().getWidth();
907                            
908                            FantasiaPainter.paintBorder(g2, 0, -3, w - 1, h - 1, 6, false);
909                            paintComponent(g2, 5, 1, w - 10, h - 6, color1, color2);
910                            
911                            g2.setPaint(oldPaint);
912                            g2.setComposite(oldComposite);
913                    }
914            }
915            
916            class BottomPane extends FantasiaPanel {
917                    BottomPane() {
918                            setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
919                            setOpaque(false);
920                            add(pianoKeyboardPane);
921                            
922                  }                  }
923          }          }
924  }  }

Legend:
Removed from v.1323  
changed lines
  Added in v.1786

  ViewVC Help
Powered by ViewVC