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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1864 - (show annotations) (download)
Sat Mar 14 20:44:58 2009 UTC (15 years 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 /*
2 * JSampler - a java front-end for LinuxSampler
3 *
4 * Copyright (C) 2005-2009 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.util.HashMap;
26 import java.util.Map;
27
28 import javax.swing.Icon;
29 import javax.swing.ImageIcon;
30 import javax.swing.UIManager;
31
32 import org.jsampler.CC;
33 import org.jsampler.JSPrefs;
34
35 import org.jsampler.view.InstrumentsDbTableView;
36 import org.jsampler.view.InstrumentsDbTreeView;
37 import org.jsampler.view.BasicIconSet;
38 import org.jsampler.view.JSMainFrame;
39 import org.jsampler.view.JSViewConfig;
40
41 import org.jvnet.substance.api.SubstanceConstants;
42 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 private BasicIconSet basicIconSet = new IconSet();
53
54 private Map nativeMenuPropsMap = null;
55 private Map menuPropsMap = null;
56
57 /** Creates a new instance of <code>ViewConfig</code> */
58 public
59 ViewConfig() {
60 try {
61 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 UIManager.setLookAndFeel(new SubstanceRavenGraphiteLookAndFeel());
67 UIManager.put(SubstanceLookAndFeel.WATERMARK_VISIBLE, Boolean.FALSE);
68
69 UIManager.put (
70 SubstanceLookAndFeel.TABBED_PANE_CONTENT_BORDER_KIND,
71 SubstanceConstants.TabContentPaneBorderKind.SINGLE_FULL
72 );
73
74 if(CC.isMacOS()) {
75 // fix for setting the menu bar on top of the screen
76 menuPropsMap = getMenuProperties();
77 setNativeMenuProperties();
78 }
79
80 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 } catch(Exception e) {
87 e.printStackTrace();
88 }
89 }
90
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
130 @Override
131 public JSPrefs
132 preferences() { return FantasiaPrefs.preferences(); }
133
134 /** Exports the view configuration of the current session. */
135 @Override
136 public String
137 exportSessionViewConfig() {
138 StringBuffer sb = new StringBuffer();
139 MainFrame frame = (MainFrame)CC.getMainFrame();
140
141 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
150 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 sb.append("#jsampler.fantasia: [channel]\r\n");
178
179 sb.append("#jsampler.fantasia: channelsPanel = ");
180 sb.append(channelsPane + 1).append("\r\n");
181
182 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 boolean b = c.getViewTracker().getOriginalView().isOptionsButtonSelected();
193 sb.append("#jsampler.fantasia: expanded = ").append(b).append("\r\n");
194
195 sb.append("#\r\n");
196 }
197 }
198
199 @Override
200 public InstrumentsDbTreeView
201 getInstrumentsDbTreeView() { return instrumentsDbTreeView; }
202
203 @Override
204 public InstrumentsDbTableView
205 getInstrumentsDbTableView() { return instrumentsDbTableView; }
206
207 @Override
208 public BasicIconSet
209 getBasicIconSet() { return basicIconSet; }
210
211 private class TreeView implements InstrumentsDbTreeView {
212 @Override
213 public Icon
214 getRootIcon() { return Res.iconDb16; }
215
216 @Override
217 public Icon
218 getClosedIcon() { return Res.iconFolder16; }
219
220 @Override
221 public Icon
222 getOpenIcon() { return Res.iconFolderOpen16; }
223
224 @Override
225 public Icon
226 getInstrumentIcon() { return Res.iconInstrument16; }
227
228 @Override
229 public Icon
230 getGigInstrumentIcon() { return Res.iconInstrument16; }
231 }
232
233 private static class TableView implements InstrumentsDbTableView {
234 @Override
235 public Icon
236 getFolderIcon() { return Res.iconFolder16; }
237
238 @Override
239 public Icon
240 getInstrumentIcon() { return Res.iconInstrument16; }
241
242 @Override
243 public Icon
244 getGigInstrumentIcon() { return Res.iconInstrument16; }
245 }
246
247 private class IconSet implements BasicIconSet {
248 @Override
249 public ImageIcon
250 getApplicationIcon() { return Res.iconAppIcon; }
251
252 @Override
253 public Icon
254 getBack16Icon() { return Res.iconBack16; }
255
256 @Override
257 public Icon
258 getUp16Icon() { return Res.iconUp16; }
259
260 @Override
261 public Icon
262 getForward16Icon() { return Res.iconNext16; }
263
264 @Override
265 public Icon
266 getReload16Icon() { return Res.iconReload16; }
267
268 @Override
269 public Icon
270 getPreferences16Icon() { return Res.iconPreferences16; }
271
272 @Override
273 public Icon
274 getWarning32Icon() { return Res.iconWarning32; }
275
276 @Override
277 public Icon
278 getQuestion32Icon() { return Res.iconQuestion32; }
279 }
280
281 @Override
282 public boolean
283 getInstrumentsDbSupport() { return true; }
284 }

  ViewVC Help
Powered by ViewVC