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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1864 - (hide annotations) (download)
Sat Mar 14 20:44:58 2009 UTC (15 years, 1 month ago) by iliev
File size: 7915 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 iliev 1864 * Copyright (C) 2005-2009 Grigor Iliev <grigor@grigoriliev.com>
5 iliev 1286 *
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 iliev 1864 import java.util.HashMap;
26     import java.util.Map;
27    
28 iliev 1286 import javax.swing.Icon;
29 iliev 1786 import javax.swing.ImageIcon;
30 iliev 1286 import javax.swing.UIManager;
31    
32 iliev 1752 import org.jsampler.CC;
33 iliev 1286 import org.jsampler.JSPrefs;
34    
35     import org.jsampler.view.InstrumentsDbTableView;
36     import org.jsampler.view.InstrumentsDbTreeView;
37 iliev 1752 import org.jsampler.view.BasicIconSet;
38 iliev 1818 import org.jsampler.view.JSMainFrame;
39 iliev 1286 import org.jsampler.view.JSViewConfig;
40    
41 iliev 1743 import org.jvnet.substance.api.SubstanceConstants;
42 iliev 1286 import org.jvnet.substance.SubstanceLookAndFeel;
43     import org.jvnet.substance.skin.SubstanceRavenGraphiteLookAndFeel;
44    
45     /**
46     *
47     * @author Grigor Iliev
48     */
49     public class ViewConfig extends JSViewConfig {
50     private InstrumentsDbTreeView instrumentsDbTreeView = new TreeView();
51     private InstrumentsDbTableView instrumentsDbTableView = new TableView();
52 iliev 1752 private BasicIconSet basicIconSet = new IconSet();
53 iliev 1864
54     private Map nativeMenuPropsMap = null;
55     private Map menuPropsMap = null;
56 iliev 1286
57     /** Creates a new instance of <code>ViewConfig</code> */
58     public
59     ViewConfig() {
60     try {
61 iliev 1864 if(CC.isMacOS()) {
62     // fix for setting the menu bar on top of the screen
63     UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
64     nativeMenuPropsMap = getMenuProperties();
65     }
66 iliev 1286 UIManager.setLookAndFeel(new SubstanceRavenGraphiteLookAndFeel());
67 iliev 1743 UIManager.put(SubstanceLookAndFeel.WATERMARK_VISIBLE, Boolean.FALSE);
68 iliev 1496
69 iliev 1729 UIManager.put (
70     SubstanceLookAndFeel.TABBED_PANE_CONTENT_BORDER_KIND,
71     SubstanceConstants.TabContentPaneBorderKind.SINGLE_FULL
72     );
73 iliev 1864
74     if(CC.isMacOS()) {
75     // fix for setting the menu bar on top of the screen
76     menuPropsMap = getMenuProperties();
77     setNativeMenuProperties();
78     }
79 iliev 1729
80 iliev 1496 if(!preferences().getBoolProperty("TurnOffCustomWindowDecoration")) {
81     javax.swing.JFrame.setDefaultLookAndFeelDecorated(true);
82     javax.swing.JDialog.setDefaultLookAndFeelDecorated(true);
83     }
84    
85     Res.loadTheme(preferences().getStringProperty("Theme"));
86 iliev 1286 } catch(Exception e) {
87     e.printStackTrace();
88     }
89     }
90 iliev 1864
91     /**
92     * If running on Mac OS and third party LaF is used
93     * certain properties from the system LaF should be set
94     * to be able to move the menu bar on top of the screen.
95     */
96     public void
97     setNativeMenuProperties() {
98     setMenuProperties(nativeMenuPropsMap);
99     }
100    
101     /**
102     * If running on Mac OS and third party LaF is used
103     * certain properties from the system LaF should be set
104     * to be able to move the menu bar on top of the screen.
105     * This method is used to reverse them back to the LaF to be used.
106     */
107     public void
108     restoreMenuProperties() {
109     setMenuProperties(menuPropsMap);
110     }
111    
112     private void
113     setMenuProperties(Map props) {
114     if(props == null) return;
115     for(Object o : props.keySet()) UIManager.put(o, props.get(o));
116     }
117    
118     public Map
119     getMenuProperties() {
120     Map props = new HashMap();
121     props.put("MenuBarUI", UIManager.get("MenuBarUI"));
122     props.put("MenuUI", UIManager.get("MenuUI"));
123     props.put("MenuItemUI", UIManager.get("MenuItemUI"));
124     props.put("CheckBoxMenuItemUI", UIManager.get("CheckBoxMenuItemUI"));
125     props.put("RadioButtonMenuItemUI", UIManager.get("RadioButtonMenuItemUI"));
126     props.put("PopupMenuUI", UIManager.get("PopupMenuUI"));
127     return props;
128     }
129 iliev 1286
130 iliev 1786 @Override
131 iliev 1286 public JSPrefs
132     preferences() { return FantasiaPrefs.preferences(); }
133    
134 iliev 1767 /** Exports the view configuration of the current session. */
135 iliev 1786 @Override
136 iliev 1767 public String
137     exportSessionViewConfig() {
138     StringBuffer sb = new StringBuffer();
139     MainFrame frame = (MainFrame)CC.getMainFrame();
140    
141 iliev 1818 for(int i = 0; i < frame.getChannelsPaneCount(); i++) {
142     exportSamplerChannels(sb, i);
143     }
144    
145     MidiDevicesPane midi = frame.getRightSidePane().getDevicesPane().getMidiDevicesPane();
146    
147     for(int i = 0; i < midi.getDevicePaneCount(); i++) {
148     sb.append("#jsampler.fantasia: [MIDI device]\r\n");
149 iliev 1767
150 iliev 1818 boolean b = midi.getDevicePaneAt(i).isOptionsPaneExpanded();
151     sb.append("#jsampler.fantasia: expanded = ").append(b).append("\r\n");
152    
153     sb.append("#\r\n");
154     }
155    
156     AudioDevicesPane au = frame.getRightSidePane().getDevicesPane().getAudioDevicesPane();
157    
158     for(int i = 0; i < au.getDevicePaneCount(); i++) {
159     sb.append("#jsampler.fantasia: [audio device]\r\n");
160    
161     boolean b = au.getDevicePaneAt(i).isOptionsPaneExpanded();
162     sb.append("#jsampler.fantasia: expanded = ").append(b).append("\r\n");
163    
164     sb.append("#\r\n");
165     }
166    
167     return sb.toString();
168     }
169    
170     private void
171     exportSamplerChannels(StringBuffer sb, int channelsPane) {
172     JSMainFrame frame = CC.getMainFrame();
173    
174     for(int i = 0; i < frame.getChannelsPane(channelsPane).getChannelCount(); i++) {
175     Channel c = (Channel)frame.getChannelsPane(channelsPane).getChannel(i);
176    
177 iliev 1767 sb.append("#jsampler.fantasia: [channel]\r\n");
178    
179 iliev 1818 sb.append("#jsampler.fantasia: channelsPanel = ");
180     sb.append(channelsPane + 1).append("\r\n");
181    
182 iliev 1767 switch(c.getViewTracker().getOriginalView().getType()) {
183     case SMALL:
184     sb.append("#jsampler.fantasia: viewType = SMALL\r\n");
185     break;
186    
187     case NORMAL:
188     sb.append("#jsampler.fantasia: viewType = NORMAL\r\n");
189     break;
190     }
191    
192 iliev 1818 boolean b = c.getViewTracker().getOriginalView().isOptionsButtonSelected();
193     sb.append("#jsampler.fantasia: expanded = ").append(b).append("\r\n");
194 iliev 1767
195 iliev 1818 sb.append("#\r\n");
196 iliev 1767 }
197     }
198    
199 iliev 1786 @Override
200 iliev 1286 public InstrumentsDbTreeView
201     getInstrumentsDbTreeView() { return instrumentsDbTreeView; }
202    
203 iliev 1786 @Override
204 iliev 1286 public InstrumentsDbTableView
205     getInstrumentsDbTableView() { return instrumentsDbTableView; }
206    
207 iliev 1786 @Override
208 iliev 1752 public BasicIconSet
209     getBasicIconSet() { return basicIconSet; }
210    
211 iliev 1286 private class TreeView implements InstrumentsDbTreeView {
212 iliev 1786 @Override
213 iliev 1286 public Icon
214     getRootIcon() { return Res.iconDb16; }
215    
216 iliev 1786 @Override
217 iliev 1286 public Icon
218     getClosedIcon() { return Res.iconFolder16; }
219    
220 iliev 1786 @Override
221 iliev 1286 public Icon
222     getOpenIcon() { return Res.iconFolderOpen16; }
223    
224 iliev 1786 @Override
225 iliev 1286 public Icon
226     getInstrumentIcon() { return Res.iconInstrument16; }
227    
228 iliev 1786 @Override
229 iliev 1286 public Icon
230     getGigInstrumentIcon() { return Res.iconInstrument16; }
231     }
232    
233     private static class TableView implements InstrumentsDbTableView {
234 iliev 1786 @Override
235 iliev 1286 public Icon
236     getFolderIcon() { return Res.iconFolder16; }
237    
238 iliev 1786 @Override
239 iliev 1286 public Icon
240     getInstrumentIcon() { return Res.iconInstrument16; }
241    
242 iliev 1786 @Override
243 iliev 1286 public Icon
244     getGigInstrumentIcon() { return Res.iconInstrument16; }
245     }
246    
247 iliev 1752 private class IconSet implements BasicIconSet {
248 iliev 1786 @Override
249     public ImageIcon
250     getApplicationIcon() { return Res.iconAppIcon; }
251    
252     @Override
253 iliev 1752 public Icon
254     getBack16Icon() { return Res.iconBack16; }
255    
256 iliev 1786 @Override
257 iliev 1752 public Icon
258     getUp16Icon() { return Res.iconUp16; }
259    
260 iliev 1786 @Override
261 iliev 1752 public Icon
262     getForward16Icon() { return Res.iconNext16; }
263    
264 iliev 1786 @Override
265 iliev 1752 public Icon
266     getReload16Icon() { return Res.iconReload16; }
267    
268 iliev 1786 @Override
269 iliev 1752 public Icon
270     getPreferences16Icon() { return Res.iconPreferences16; }
271 iliev 1767
272 iliev 1786 @Override
273 iliev 1767 public Icon
274     getWarning32Icon() { return Res.iconWarning32; }
275    
276 iliev 1786 @Override
277 iliev 1767 public Icon
278     getQuestion32Icon() { return Res.iconQuestion32; }
279 iliev 1752 }
280    
281 iliev 1786 @Override
282 iliev 1286 public boolean
283     getInstrumentsDbSupport() { return true; }
284     }

  ViewVC Help
Powered by ViewVC