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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1688 - (show annotations) (download)
Thu Feb 14 16:52:36 2008 UTC (16 years, 2 months ago) by iliev
File size: 20111 byte(s)
* Implemented a backend list with option to manually choose a backend
  to connect on startup(Edit/Preferences, then click the `Backend' tab)
  and option to change the backend without restarting JSampler
  (Actions/Change Backend or Ctrl + B)

* Added confirmation messages for removing sampler channels and
  audio/MIDI devices (Edit/Preferences, then click the `View' tab)

1 /*
2 * JSampler - a java front-end for LinuxSampler
3 *
4 * Copyright (C) 2005-2007 Grigor Iliev <grigor@grigoriliev.com>
5 *
6 * This file is part of JSampler.
7 *
8 * JSampler is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2
10 * as published by the Free Software Foundation.
11 *
12 * JSampler is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with JSampler; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
20 * MA 02111-1307 USA
21 */
22
23 package org.jsampler.view.fantasia;
24
25 import java.awt.BorderLayout;
26 import java.awt.Dialog;
27 import java.awt.Dimension;
28 import java.awt.Frame;
29 import java.awt.Graphics;
30 import java.awt.GridBagConstraints;
31 import java.awt.GridBagLayout;
32 import java.awt.Insets;
33 import java.awt.Point;
34
35 import java.awt.event.ActionEvent;
36 import java.awt.event.ActionListener;
37 import java.awt.event.KeyEvent;
38 import java.awt.event.MouseAdapter;
39 import java.awt.event.MouseEvent;
40
41 import java.io.BufferedReader;
42 import java.io.File;
43 import java.io.FileNotFoundException;
44 import java.io.FileReader;
45
46 import java.util.Vector;
47 import java.util.logging.Level;
48
49 import javax.swing.BorderFactory;
50 import javax.swing.Box;
51 import javax.swing.BoxLayout;
52 import javax.swing.JCheckBoxMenuItem;
53 import javax.swing.JComponent;
54 import javax.swing.JDialog;
55 import javax.swing.JFileChooser;
56 import javax.swing.JFrame;
57 import javax.swing.JMenu;
58 import javax.swing.JMenuBar;
59 import javax.swing.JMenuItem;
60 import javax.swing.JPanel;
61 import javax.swing.JPopupMenu;
62 import javax.swing.JScrollPane;
63 import javax.swing.JSplitPane;
64 import javax.swing.JToggleButton;
65 import javax.swing.KeyStroke;
66 import javax.swing.SwingUtilities;
67 import javax.swing.UIManager;
68
69 import net.sf.juife.TitleBar;
70
71 import org.jsampler.CC;
72 import org.jsampler.HF;
73 import org.jsampler.LSConsoleModel;
74 import org.jsampler.Server;
75
76 import org.jsampler.view.JSChannel;
77 import org.jsampler.view.JSChannelsPane;
78 import org.jsampler.view.JSMainFrame;
79 import org.jsampler.view.LscpFileFilter;
80
81 import org.jsampler.view.std.JSConnectDlg;
82 import org.jsampler.view.std.JSDetailedErrorDlg;
83 import org.jsampler.view.std.JSQuitDlg;
84 import org.jsampler.view.std.JSamplerHomeChooser;
85
86 import static org.jsampler.view.fantasia.A4n.a4n;
87 import static org.jsampler.view.fantasia.FantasiaI18n.i18n;
88 import static org.jsampler.view.fantasia.FantasiaPrefs.preferences;
89 import static org.jsampler.view.std.StdPrefs.*;
90
91
92 /**
93 *
94 * @author Grigor Iliev
95 */
96 public class MainFrame extends JSMainFrame {
97 private final StandardBar standardBar = new StandardBar();
98 private final FantasiaMenuBar menuBar = new FantasiaMenuBar();
99 private final JPanel rootPane = new JPanel();
100 private final MainPane mainPane = new MainPane();
101 private final DevicesPane devicesPane = new DevicesPane();
102 private final JScrollPane spDevicesPane = new JScrollPane();
103
104 private final JMenu recentScriptsMenu =
105 new JMenu(i18n.getMenuLabel("actions.recentScripts"));
106
107 private final JSplitPane hSplitPane;
108
109 private final SidePane sidePane = new SidePane();
110 private final JPanel rightPane;
111
112 private final LSConsoleFrame lsConsoleFrame = new LSConsoleFrame();
113 private final Vector<String> recentScripts = new Vector<String>();
114
115
116 private final JCheckBoxMenuItem cbmiToolBarVisible =
117 new JCheckBoxMenuItem(i18n.getMenuLabel("view.toolBar"));
118
119 private final JCheckBoxMenuItem cbmiSidePaneVisible =
120 new JCheckBoxMenuItem(i18n.getMenuLabel("view.sidePane"));
121
122 private final JCheckBoxMenuItem cbmiDevicesPaneVisible =
123 new JCheckBoxMenuItem(i18n.getMenuLabel("view.devicesPane"));
124
125 /** Creates a new instance of <code>MainFrame</code> */
126 public
127 MainFrame() {
128 setTitle(i18n.getLabel("MainFrame.title"));
129
130 if(Res.iconAppIcon != null) setIconImage(Res.iconAppIcon.getImage());
131
132 getContentPane().add(standardBar, BorderLayout.NORTH);
133
134 rightPane = createRightPane();
135
136 hSplitPane = new JSplitPane (
137 JSplitPane.HORIZONTAL_SPLIT,
138 true, // continuousLayout
139 sidePane, rightPane
140 );
141 hSplitPane.setResizeWeight(0.5);
142
143 rootPane.setLayout(new BorderLayout());
144 rootPane.setBorder(BorderFactory.createEmptyBorder(6, 0, 0, 0));
145 rootPane.setOpaque(false);
146 rootPane.add(hSplitPane);
147
148 addMenu();
149
150 addChannelsPane(mainPane.getChannelsPane());
151
152 getContentPane().add(rootPane);
153
154 int i = preferences().getIntProperty("MainFrame.hSplitDividerLocation", 220);
155 hSplitPane.setDividerLocation(i);
156
157 setSavedSize();
158 }
159
160 private JPanel
161 createRightPane() {
162 JPanel p = new JPanel();
163 GridBagLayout gridbag = new GridBagLayout();
164 GridBagConstraints c = new GridBagConstraints();
165
166 p.setLayout(gridbag);
167
168 c.fill = GridBagConstraints.BOTH;
169
170 spDevicesPane.setViewportView(devicesPane);
171 spDevicesPane.setBorder(BorderFactory.createEmptyBorder());
172 int h = spDevicesPane.getMinimumSize().height;
173 spDevicesPane.setMinimumSize(new Dimension(200, h));
174
175 c.gridx = 1;
176 c.gridy = 0;
177 c.weightx = 1.0;
178 c.weighty = 1.0;
179 c.insets = new Insets(0, 3, 3, 0);
180 gridbag.setConstraints(spDevicesPane, c);
181 p.add(spDevicesPane);
182
183 c.gridx = 0;
184 c.gridy = 0;
185 c.weightx = 0.0;
186 c.weighty = 1.0;
187 c.insets = new Insets(0, 3, 3, 3);
188 c.fill = GridBagConstraints.VERTICAL;
189 gridbag.setConstraints(mainPane, c);
190 p.add(mainPane);
191
192 return p;
193 }
194
195 private void
196 setSavedSize() {
197 String s = preferences().getStringProperty("MainFrame.sizeAndLocation");
198 if(s == null) {
199 setDefaultSizeAndLocation();
200 return;
201 }
202 pack();
203 try {
204 int i = s.indexOf(',');
205 int x = Integer.parseInt(s.substring(0, i));
206
207 s = s.substring(i + 1);
208 i = s.indexOf(',');
209 int y = Integer.parseInt(s.substring(0, i));
210
211 s = s.substring(i + 1);
212 i = s.indexOf(',');
213 int width = Integer.parseInt(s.substring(0, i));
214
215 s = s.substring(i + 1);
216 int height = Integer.parseInt(s);
217
218 setBounds(x, y, width, height);
219 } catch(Exception x) {
220 String msg = "Parsing of window size and location string failed";
221 CC.getLogger().log(Level.INFO, msg, x);
222 setDefaultSizeAndLocation();
223 }
224
225 if(preferences().getBoolProperty("MainFrame.windowMaximized")) {
226 setExtendedState(getExtendedState() | MAXIMIZED_BOTH);
227 }
228 }
229
230 private void
231 setDefaultSizeAndLocation() {
232 setPreferredSize(new Dimension(900, 600));
233 pack();
234 setLocationRelativeTo(null);
235 }
236
237
238 /** Invoked when this window is about to close. */
239 protected void
240 onWindowClose() {
241 boolean b = preferences().getBoolProperty(CONFIRM_APP_QUIT);
242 if(b && CC.getSamplerModel().isModified()) {
243 JSQuitDlg dlg = new JSQuitDlg(Res.iconQuestion32);
244 dlg.setVisible(true);
245 if(dlg.isCancelled()) return;
246 }
247
248 sidePane.savePreferences();
249
250 int i = hSplitPane.getDividerLocation();
251 preferences().setIntProperty("MainFrame.hSplitDividerLocation", i);
252
253 preferences().setBoolProperty (
254 "MainFrame.windowMaximized",
255 (getExtendedState() & MAXIMIZED_BOTH) == MAXIMIZED_BOTH
256 );
257
258 if(preferences().getBoolProperty("MainFrame.windowMaximized")) {
259 super.onWindowClose();
260 return;
261 }
262
263 java.awt.Point p = getLocation();
264 Dimension d = getSize();
265 StringBuffer sb = new StringBuffer();
266 sb.append(p.x).append(',').append(p.y).append(',');
267 sb.append(d.width).append(',').append(d.height);
268 preferences().setStringProperty("MainFrame.sizeAndLocation", sb.toString());
269
270 String[] list = recentScripts.toArray(new String[recentScripts.size()]);
271 preferences().setStringListProperty(RECENT_LSCP_SCRIPTS, list);
272
273 if(preferences().getBoolProperty(SAVE_LS_CONSOLE_HISTORY)) {
274 if(lsConsoleFrame != null) getLSConsolePane().saveConsoleHistory();
275 }
276
277 super.onWindowClose();
278 }
279
280 private void
281 addMenu() {
282 JMenu m;
283 JMenuItem mi;
284
285 setJMenuBar(menuBar);
286
287 // Actions
288 m = new FantasiaMenu(i18n.getMenuLabel("actions"));
289
290 mi = new JMenuItem(a4n.refresh);
291 mi.setIcon(null);
292 mi.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F5, 0));
293 m.add(mi);
294
295 mi = new JMenuItem(a4n.samplerInfo);
296 mi.setIcon(null);
297 m.add(mi);
298
299 mi = new JMenuItem(a4n.resetSampler);
300 mi.setIcon(null);
301 m.add(mi);
302
303 m.addSeparator();
304
305 JMenu exportMenu = new JMenu(i18n.getMenuLabel("actions.export"));
306 m.add(exportMenu);
307
308 mi = new JMenuItem(a4n.exportSamplerConfig);
309 mi.setIcon(null);
310 mi.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, KeyEvent.CTRL_MASK));
311 exportMenu.add(mi);
312
313 mi = new JMenuItem(a4n.exportMidiInstrumentMaps);
314 mi.setIcon(null);
315 exportMenu.add(mi);
316
317 m.addSeparator();
318
319 mi = new JMenuItem(a4n.loadScript);
320 mi.setIcon(null);
321 mi.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, KeyEvent.CTRL_MASK));
322 m.add(mi);
323
324 String[] list = preferences().getStringListProperty(RECENT_LSCP_SCRIPTS);
325 for(String s : list) recentScripts.add(s);
326
327 updateRecentScriptsMenu();
328
329 m.add(recentScriptsMenu);
330
331 m.addSeparator();
332
333 mi = new JMenuItem(a4n.changeBackend);
334 mi.setIcon(null);
335 mi.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_B, KeyEvent.CTRL_MASK));
336 m.add(mi);
337
338 m.addSeparator();
339
340 mi = new JMenuItem(i18n.getMenuLabel("actions.exit"));
341 m.add(mi);
342 mi.addActionListener(new ActionListener() {
343 public void
344 actionPerformed(ActionEvent e) { onWindowClose(); }
345 });
346
347 menuBar.add(m);
348
349
350 // Edit
351 m = new FantasiaMenu(i18n.getMenuLabel("edit"));
352 menuBar.add(m);
353
354 mi = new JMenuItem(i18n.getMenuLabel("edit.addChannel"));
355 m.add(mi);
356 mi.addActionListener(new ActionListener() {
357 public void
358 actionPerformed(ActionEvent e) {
359 CC.getSamplerModel().addBackendChannel();
360 }
361 });
362
363 m.addSeparator();
364
365 mi = new JMenuItem(a4n.createMidiDevice);
366 mi.setIcon(null);
367 m.add(mi);
368
369 mi = new JMenuItem(a4n.createAudioDevice);
370 mi.setIcon(null);
371 m.add(mi);
372
373 m.addSeparator();
374
375 mi = new JMenuItem(a4n.editPreferences);
376 mi.setIcon(null);
377 mi.setAccelerator(KeyStroke.getKeyStroke (
378 KeyEvent.VK_P, KeyEvent.CTRL_MASK | KeyEvent.SHIFT_MASK
379 ));
380 m.add(mi);
381
382 // View
383 m = new FantasiaMenu(i18n.getMenuLabel("view"));
384 menuBar.add(m);
385
386 m.add(cbmiToolBarVisible);
387
388 cbmiToolBarVisible.addActionListener(new ActionListener() {
389 public void
390 actionPerformed(ActionEvent e) {
391 showToolBar(cbmiToolBarVisible.getState());
392 }
393 });
394
395 boolean b = preferences().getBoolProperty("toolBar.visible");
396 cbmiToolBarVisible.setSelected(b);
397 showToolBar(b);
398
399 cbmiSidePaneVisible.setAccelerator(KeyStroke.getKeyStroke (
400 KeyEvent.VK_L, KeyEvent.CTRL_MASK | KeyEvent.SHIFT_MASK
401 ));
402 m.add(cbmiSidePaneVisible);
403
404 cbmiSidePaneVisible.addActionListener(new ActionListener() {
405 public void
406 actionPerformed(ActionEvent e) {
407 showSidePane(cbmiSidePaneVisible.getState());
408 }
409 });
410
411 b = preferences().getBoolProperty("sidePane.visible");
412 cbmiSidePaneVisible.setSelected(b);
413 showSidePane(b);
414
415 cbmiDevicesPaneVisible.setAccelerator(KeyStroke.getKeyStroke (
416 KeyEvent.VK_R, KeyEvent.CTRL_MASK | KeyEvent.SHIFT_MASK
417 ));
418 m.add(cbmiDevicesPaneVisible);
419
420 cbmiDevicesPaneVisible.addActionListener(new ActionListener() {
421 public void
422 actionPerformed(ActionEvent e) {
423 showDevicesPane(cbmiDevicesPaneVisible.getState());
424 }
425 });
426
427 b = preferences().getBoolProperty("devicesPane.visible");
428 cbmiDevicesPaneVisible.setSelected(b);
429 showDevicesPane(b);
430
431
432 // Window
433 m = new FantasiaMenu(i18n.getMenuLabel("window"));
434 menuBar.add(m);
435
436 mi = new JMenuItem(a4n.windowLSConsole);
437 mi.setIcon(null);
438 m.add(mi);
439
440 mi = new JMenuItem(a4n.windowInstrumentsDb);
441 mi.setIcon(null);
442 m.add(mi);
443
444
445 // Help
446 m = new FantasiaMenu(i18n.getMenuLabel("help"));
447
448 mi = new JMenuItem(a4n.browseOnlineTutorial);
449 mi.setIcon(null);
450 m.add(mi);
451
452 m.addSeparator();
453
454 mi = new JMenuItem(a4n.helpAbout);
455 mi.setIcon(null);
456 m.add(mi);
457
458 menuBar.add(m);
459 }
460
461 /**
462 * This method does nothing, because <b>Fantasia</b> has exactly
463 * one pane containing sampler channels, which can not be changed.
464 */
465 public void
466 insertChannelsPane(JSChannelsPane pane, int idx) {
467
468 }
469
470 /**
471 * This method always returns the <code>JSChannelsPane</code> at index 0,
472 * because the <b>Fantasia</b> view has exactly one pane containing sampler channels.
473 * @return The <code>JSChannelsPane</code> at index 0.
474 */
475 public JSChannelsPane
476 getSelectedChannelsPane() { return getChannelsPane(0); }
477
478 /**
479 * This method does nothing because the <b>Fantasia</b> view has
480 * exactly one pane containing sampler channels which is always shown.
481 */
482 public void
483 setSelectedChannelsPane(JSChannelsPane pane) { }
484
485 public void
486 installJSamplerHome() {
487 JSamplerHomeChooser chooser = new JSamplerHomeChooser(this);
488 chooser.setVisible(true);
489 if(chooser.isCancelled()) return;
490
491 CC.changeJSamplerHome(chooser.getJSamplerHome());
492 }
493
494 public void
495 showDetailedErrorMessage(Frame owner, String err, String details) {
496 JSDetailedErrorDlg dlg = new JSDetailedErrorDlg (
497 owner, Res.iconWarning32, i18n.getError("error"), err, details
498 );
499 dlg.setVisible(true);
500 }
501
502 public void
503 showDetailedErrorMessage(Dialog owner, String err, String details) {
504 JSDetailedErrorDlg dlg = new JSDetailedErrorDlg (
505 owner, Res.iconWarning32, i18n.getError("error"), err, details
506 );
507 dlg.setVisible(true);
508 }
509
510 /**
511 * Gets the server address to which to connect. If the server should be
512 * manually selected, a dialog asking the user to choose a server is displayed.
513 */
514 public Server
515 getServer() {
516 boolean b = preferences().getBoolProperty(MANUAL_SERVER_SELECT_ON_STARTUP);
517 return getServer(b);
518 }
519
520 /**
521 * Gets the server address to which to connect. If the server should be
522 * manually selected, a dialog asking the user to choose a server is displayed.
523 * @param manualSelect Determines whether the server should be manually selected.
524 */
525 public Server
526 getServer(boolean manualSelect) {
527 if(manualSelect) {
528 JSConnectDlg dlg = new JSConnectDlg();
529 dlg.setVisible(true);
530 return dlg.getSelectedServer();
531 }
532
533 int i = preferences().getIntProperty(SERVER_INDEX);
534 int size = CC.getServerList().getServerCount();
535 if(size == 0) return null;
536 if(i >= size) return CC.getServerList().getServer(0);
537
538 return CC.getServerList().getServer(i);
539 }
540
541 protected LSConsoleModel
542 getLSConsoleModel() { return getLSConsolePane().getModel(); }
543
544 protected LSConsolePane
545 getLSConsolePane() {
546 return getLSConsoleFrame().getLSConsolePane();
547 }
548
549 protected LSConsoleFrame
550 getLSConsoleFrame() { return lsConsoleFrame; }
551
552 protected boolean
553 runScript() {
554 String s = preferences().getStringProperty("lastScriptLocation");
555 JFileChooser fc = new JFileChooser(s);
556 fc.setFileFilter(new LscpFileFilter());
557 int result = fc.showOpenDialog(this);
558 if(result != JFileChooser.APPROVE_OPTION) return false;
559
560 String path = fc.getCurrentDirectory().getAbsolutePath();
561 preferences().setStringProperty("lastScriptLocation", path);
562
563 runScript(fc.getSelectedFile());
564
565 return true;
566 }
567
568 private void
569 runScript(String script) { runScript(new File(script)); }
570
571 private void
572 runScript(File script) {
573 FileReader fr;
574 try { fr = new FileReader(script); }
575 catch(FileNotFoundException e) {
576 HF.showErrorMessage(i18n.getMessage("FileNotFound!"));
577 return;
578 }
579
580 BufferedReader br = new BufferedReader(fr);
581
582 try {
583 String s = br.readLine();
584 while(s != null) {
585 getLSConsoleModel().setCommandLineText(s);
586 getLSConsoleModel().execCommand();
587 s = br.readLine();
588 }
589 } catch(Exception e) {
590 HF.showErrorMessage(e);
591 return;
592 }
593
594 String s = script.getAbsolutePath();
595 recentScripts.remove(s);
596 recentScripts.insertElementAt(s, 0);
597
598 updateRecentScriptsMenu();
599 }
600
601 protected void
602 clearRecentScripts() {
603 recentScripts.removeAllElements();
604 updateRecentScriptsMenu();
605 }
606
607 protected void
608 updateRecentScriptsMenu() {
609 int size = preferences().getIntProperty(RECENT_LSCP_SCRIPTS_SIZE);
610 while(recentScripts.size() > size) {
611 recentScripts.removeElementAt(recentScripts.size() - 1);
612 }
613
614 recentScriptsMenu.removeAll();
615
616 for(String script : recentScripts) {
617 JMenuItem mi = new JMenuItem(script);
618 recentScriptsMenu.add(mi);
619 mi.addActionListener(new RecentScriptHandler(script));
620 }
621
622 recentScriptsMenu.setEnabled(recentScripts.size() != 0);
623 }
624
625 private void
626 showToolBar(boolean b) {
627 preferences().setBoolProperty("toolBar.visible", b);
628 standardBar.setVisible(b);
629 }
630
631 private void
632 showSidePane(boolean b) {
633 preferences().setBoolProperty("sidePane.visible", b);
634 rootPane.remove(rightPane);
635 rootPane.remove(hSplitPane);
636
637 if(b) {
638 hSplitPane.setRightComponent(rightPane);
639 rootPane.add(hSplitPane);
640 int i = preferences().getIntProperty("MainFrame.hSplitDividerLocation", 220);
641
642 hSplitPane.setDividerLocation(i);
643 hSplitPane.validate();
644 } else {
645 rootPane.add(rightPane);
646
647 }
648
649 int w = getPreferredSize().width;
650 int h = getSize().height;
651 setSize(new Dimension(w, h));
652
653 rootPane.revalidate();
654 rootPane.validate();
655 rootPane.repaint();
656
657 SwingUtilities.invokeLater(new Runnable() {
658 public void
659 run() { sidePanesVisibilityChanged(); }
660 });
661 }
662
663 private void
664 showDevicesPane(boolean b) {
665 preferences().setBoolProperty("devicesPane.visible", b);
666
667 int width = sidePane.getWidth();
668 int height = sidePane.getPreferredSize().height;
669 if(width != 0) sidePane.setPreferredSize(new Dimension(width, height));
670
671 if(b) {
672 int w = preferences().getIntProperty("devicesPane.width", 200);
673
674 int h = spDevicesPane.getPreferredSize().height;
675 spDevicesPane.setPreferredSize(new Dimension(w, h));
676 } else {
677 int w = spDevicesPane.getWidth();
678 if(w > 0 && w < 200) w = 200;
679 if(w != 0) preferences().setIntProperty("devicesPane.width", w);
680 }
681
682 hSplitPane.setResizeWeight(0.0);
683 spDevicesPane.setVisible(b);
684 hSplitPane.resetToPreferredSizes();
685
686 int w = getPreferredSize().width;
687 int h = getSize().height;
688 setSize(new Dimension(w, h));
689
690 rootPane.validate();
691 rootPane.repaint();
692 //hSplitPane.validate();
693
694 SwingUtilities.invokeLater(new Runnable() {
695 public void
696 run() { sidePanesVisibilityChanged(); }
697 });
698 }
699
700 private void
701 sidePanesVisibilityChanged() {
702 boolean sidePaneVisible = cbmiSidePaneVisible.isSelected();
703 boolean devicesPaneVisible = cbmiDevicesPaneVisible.isSelected();
704
705 if(sidePaneVisible && devicesPaneVisible) {
706 hSplitPane.setResizeWeight(0.5);
707 } else if(sidePaneVisible && !devicesPaneVisible) {
708 hSplitPane.setResizeWeight(1.0);
709 }
710
711 if(!sidePaneVisible && !devicesPaneVisible) {
712 standardBar.showFantasiaLogo(false);
713 if(isResizable()) setResizable(false);
714 } else {
715 standardBar.showFantasiaLogo(true);
716 if(!isResizable()) setResizable(true);
717 }
718 }
719
720 private class RecentScriptHandler implements ActionListener {
721 private String script;
722
723 RecentScriptHandler(String script) { this.script = script; }
724
725 public void
726 actionPerformed(ActionEvent e) {
727 runScript(script);
728 if(preferences().getBoolProperty(SHOW_LS_CONSOLE_WHEN_RUN_SCRIPT)) {
729 a4n.windowLSConsole.actionPerformed(null);
730 }
731 }
732 }
733
734 private static class FantasiaMenu extends JMenu {
735 FantasiaMenu(String s) {
736 super(s);
737 setFont(getFont().deriveFont(java.awt.Font.BOLD));
738 setOpaque(false);
739 }
740 }
741
742 private class FantasiaMenuBar extends JMenuBar {
743 private Insets pixmapInsets = new Insets(6, 6, 0, 6);
744 private Insets pixmapInsets2 = new Insets(6, 6, 6, 6);
745
746 FantasiaMenuBar() {
747 setOpaque(false);
748 }
749
750 protected void
751 paintComponent(Graphics g) {
752 super.paintComponent(g);
753 if(standardBar.isVisible()) {
754 PixmapPane.paintComponent(this, g, Res.gfxMenuBarBg, pixmapInsets);
755 } else {
756 PixmapPane.paintComponent(this, g, Res.gfxRoundBg14, pixmapInsets2);
757 }
758 }
759 }
760 }

  ViewVC Help
Powered by ViewVC