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

Annotation of /jsampler/trunk/src/org/jsampler/view/fantasia/LSConsoleFrame.java

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1864 - (hide annotations) (download)
Sat Mar 14 20:44:58 2009 UTC (15 years ago) by iliev
File size: 5028 byte(s)
* Fixed bug in the parameter table when editing
  string list parameters with no possibilities
* Mac OS integration, work in progress:
* ant: added new target build-fantasia-osx
* Moved the menu bar on top of the screen
* Use custom application icon
* Register LSCP scripts to be opened with Fantasia
* Changed shortcut keys (use command key instead of ctrl key)

1 iliev 1286 /*
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.Dimension;
26 iliev 1786 import java.awt.Rectangle;
27 iliev 1286
28     import java.awt.event.ActionEvent;
29     import java.awt.event.ActionListener;
30     import java.awt.event.WindowAdapter;
31     import java.awt.event.WindowEvent;
32    
33     import javax.swing.JFrame;
34     import javax.swing.JMenu;
35     import javax.swing.JMenuBar;
36     import javax.swing.JMenuItem;
37    
38     import org.jsampler.CC;
39     import org.jsampler.view.std.JSLscpScriptDlg;
40 iliev 1786 import org.jsampler.view.std.StdUtils;
41 iliev 1286
42     import static org.jsampler.view.fantasia.FantasiaI18n.i18n;
43     import static org.jsampler.view.fantasia.FantasiaPrefs.preferences;
44    
45     /**
46     *
47     * @author Grigor Iliev
48     */
49     public class LSConsoleFrame extends JFrame {
50     private final JMenuBar menuBar = new JMenuBar();
51     private final LSConsolePane lsConsolePane = new LSConsolePane(this);
52    
53     /**
54     * Creates a new instance of <code>LSConsoleFrame</code>
55     */
56     public
57     LSConsoleFrame() {
58     setTitle(i18n.getLabel("LSConsoleFrame.title"));
59     if(Res.iconAppIcon != null) setIconImage(Res.iconLSConsole.getImage());
60    
61     add(lsConsolePane);
62     addMenu();
63     pack();
64     setSavedSize();
65    
66     addWindowListener(new WindowAdapter() {
67     public void
68     windowClosing(WindowEvent we) { onWindowClose(); }
69     });
70     }
71    
72     private void
73     addMenu() {
74 iliev 1864 if(CC.getViewConfig().isUsingScreenMenuBar()) {
75     ((ViewConfig)CC.getViewConfig()).setNativeMenuProperties();
76     }
77    
78 iliev 1286 JMenu m;
79     JMenuItem mi;
80    
81     setJMenuBar(menuBar);
82    
83     // Actions
84     m = new JMenu(i18n.getMenuLabel("lsconsole.actions"));
85     m.setFont(m.getFont().deriveFont(java.awt.Font.BOLD));
86     menuBar.add(m);
87    
88     JMenu clearMenu = new JMenu(i18n.getMenuLabel("lsconsole.clear"));
89    
90     mi = new JMenuItem(i18n.getMenuLabel("lsconsole.clearConsole"));
91     clearMenu.add(mi);
92     mi.addActionListener(lsConsolePane.clearConsoleAction);
93    
94     mi = new JMenuItem(i18n.getMenuLabel("lsconsole.clearSessionHistory"));
95     clearMenu.add(mi);
96     mi.addActionListener(lsConsolePane.clearSessionHistoryAction);
97    
98     m.add(clearMenu);
99    
100     JMenu exportMenu = new JMenu(i18n.getMenuLabel("lsconsole.export"));
101    
102     mi = new JMenuItem(i18n.getMenuLabel("lsconsole.export.session"));
103     exportMenu.add(mi);
104     mi.addActionListener(new ActionListener() {
105     public void
106     actionPerformed(ActionEvent e) {
107     JSLscpScriptDlg dlg = new JSLscpScriptDlg();
108     dlg.setCommands(lsConsolePane.getModel().getSessionHistory());
109     dlg.setVisible(true);
110     }
111     });
112    
113     mi = new JMenuItem(i18n.getMenuLabel("lsconsole.export.commandHistory"));
114     exportMenu.add(mi);
115     mi.addActionListener(new ActionListener() {
116     public void
117     actionPerformed(ActionEvent e) {
118     JSLscpScriptDlg dlg = new JSLscpScriptDlg();
119     dlg.setCommands(lsConsolePane.getModel().getCommandHistory());
120     dlg.setVisible(true);
121     }
122     });
123    
124     m.add(exportMenu);
125    
126     m.addSeparator();
127    
128     mi = new JMenuItem(i18n.getMenuLabel("lsconsole.runScript"));
129     m.add(mi);
130     mi.addActionListener(new ActionListener() {
131     public void
132     actionPerformed(ActionEvent e) {
133     ((MainFrame)CC.getMainFrame()).runScript();
134     }
135     });
136 iliev 1864
137     if(CC.getViewConfig().isUsingScreenMenuBar()) {
138     ((ViewConfig)CC.getViewConfig()).restoreMenuProperties();
139     }
140 iliev 1286 }
141    
142     /** Invoked when this window is about to close. */
143     private void
144     onWindowClose() {
145     boolean b = (getExtendedState() & MAXIMIZED_BOTH) == MAXIMIZED_BOTH;
146     preferences().setBoolProperty("LSConsoleFrame.windowMaximized", b);
147     if(b) return;
148    
149 iliev 1786 StdUtils.saveWindowBounds("LSConsoleFrame", getBounds());
150 iliev 1286 }
151    
152     private void
153     setDefaultSize() {
154     Dimension dimension = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
155     double width = dimension.getWidth();
156     double height = dimension.getHeight();
157     setBounds(100, 100, (int) width - 200, (int) height - 200);
158     }
159    
160     private void
161     setSavedSize() {
162 iliev 1786 Rectangle r = StdUtils.getWindowBounds("LSConsoleFrame");
163     if(r == null) {
164 iliev 1286 setDefaultSize();
165     return;
166     }
167    
168 iliev 1786 setBounds(r);
169     }
170    
171     @Override
172     public void
173     setVisible(boolean b) {
174     if(b == isVisible()) return;
175 iliev 1286
176 iliev 1786 super.setVisible(b);
177    
178     if(b && preferences().getBoolProperty("LSConsoleFrame.windowMaximized")) {
179 iliev 1286 setExtendedState(getExtendedState() | MAXIMIZED_BOTH);
180     }
181     }
182    
183     protected LSConsolePane
184     getLSConsolePane() { return lsConsolePane; }
185     }

  ViewVC Help
Powered by ViewVC