/[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 2148 - (hide annotations) (download)
Thu Oct 14 14:45:42 2010 UTC (13 years, 6 months ago) by iliev
File size: 8322 byte(s)
* Add/Edit Instrument dialog and New MIDI Instrument wizard
  are now resizable
* Using multicolumn menus for loading instruments from
  Instruments Database and selecting values in string list parameters

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

  ViewVC Help
Powered by ViewVC