/[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 1729 - (show annotations) (download)
Tue Apr 29 22:22:40 2008 UTC (15 years, 11 months ago) by iliev
File size: 19991 byte(s)
* Added support for handling lost files in the Instruments Database
  (In the Instruments Database window choose Actions/Check For Lost Files)
* Fantasia: Added option to show the Instruments Database
  on the Right-Side Pane of the Fantasia's main window
  (choose Edit/Preferences, then click the `View' tab)
* Added new menu item in the Instruments Database window: Edit/Find
* Some minor bugfixes and enhancements

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

  ViewVC Help
Powered by ViewVC