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 javax.swing.Icon; |
26 |
import javax.swing.ImageIcon; |
27 |
import javax.swing.UIManager; |
28 |
|
29 |
import org.jsampler.CC; |
30 |
import org.jsampler.JSPrefs; |
31 |
|
32 |
import org.jsampler.view.InstrumentsDbTableView; |
33 |
import org.jsampler.view.InstrumentsDbTreeView; |
34 |
import org.jsampler.view.BasicIconSet; |
35 |
import org.jsampler.view.JSViewConfig; |
36 |
|
37 |
import org.jvnet.substance.api.SubstanceConstants; |
38 |
import org.jvnet.substance.SubstanceLookAndFeel; |
39 |
import org.jvnet.substance.skin.SubstanceRavenGraphiteLookAndFeel; |
40 |
|
41 |
/** |
42 |
* |
43 |
* @author Grigor Iliev |
44 |
*/ |
45 |
public class ViewConfig extends JSViewConfig { |
46 |
private InstrumentsDbTreeView instrumentsDbTreeView = new TreeView(); |
47 |
private InstrumentsDbTableView instrumentsDbTableView = new TableView(); |
48 |
private BasicIconSet basicIconSet = new IconSet(); |
49 |
|
50 |
/** Creates a new instance of <code>ViewConfig</code> */ |
51 |
public |
52 |
ViewConfig() { |
53 |
try { |
54 |
UIManager.setLookAndFeel(new SubstanceRavenGraphiteLookAndFeel()); |
55 |
UIManager.put(SubstanceLookAndFeel.WATERMARK_VISIBLE, Boolean.FALSE); |
56 |
|
57 |
UIManager.put ( |
58 |
SubstanceLookAndFeel.TABBED_PANE_CONTENT_BORDER_KIND, |
59 |
SubstanceConstants.TabContentPaneBorderKind.SINGLE_FULL |
60 |
); |
61 |
|
62 |
if(!preferences().getBoolProperty("TurnOffCustomWindowDecoration")) { |
63 |
javax.swing.JFrame.setDefaultLookAndFeelDecorated(true); |
64 |
javax.swing.JDialog.setDefaultLookAndFeelDecorated(true); |
65 |
} |
66 |
|
67 |
Res.loadTheme(preferences().getStringProperty("Theme")); |
68 |
} catch(Exception e) { |
69 |
e.printStackTrace(); |
70 |
} |
71 |
} |
72 |
|
73 |
@Override |
74 |
public JSPrefs |
75 |
preferences() { return FantasiaPrefs.preferences(); } |
76 |
|
77 |
/** Exports the view configuration of the current session. */ |
78 |
@Override |
79 |
public String |
80 |
exportSessionViewConfig() { |
81 |
StringBuffer sb = new StringBuffer(); |
82 |
MainFrame frame = (MainFrame)CC.getMainFrame(); |
83 |
|
84 |
for(int i = 0; i < frame.getChannelsPane(0).getChannelCount(); i++) { |
85 |
Channel c = (Channel)frame.getChannelsPane(0).getChannel(i); |
86 |
|
87 |
sb.append("#jsampler.fantasia: [channel]\r\n"); |
88 |
|
89 |
switch(c.getViewTracker().getOriginalView().getType()) { |
90 |
case SMALL: |
91 |
sb.append("#jsampler.fantasia: viewType = SMALL\r\n"); |
92 |
break; |
93 |
|
94 |
case NORMAL: |
95 |
sb.append("#jsampler.fantasia: viewType = NORMAL\r\n"); |
96 |
break; |
97 |
} |
98 |
|
99 |
sb.append("#jsampler.fantasia: \r\n"); |
100 |
} |
101 |
|
102 |
MidiDevicesPane midi = frame.getRightSidePane().getDevicesPane().getMidiDevicesPane(); |
103 |
|
104 |
for(int i = 0; i < midi.getDevicePaneCount(); i++) { |
105 |
sb.append("#jsampler.fantasia: [MIDI device]\r\n"); |
106 |
|
107 |
if(midi.getDevicePaneAt(i).isOptionsPaneExpanded()) { |
108 |
sb.append("#jsampler.fantasia: expanded = true\r\n"); |
109 |
} else { |
110 |
sb.append("#jsampler.fantasia: expanded = false\r\n"); |
111 |
} |
112 |
|
113 |
sb.append("#jsampler.fantasia: \r\n"); |
114 |
} |
115 |
|
116 |
return sb.toString(); |
117 |
} |
118 |
|
119 |
@Override |
120 |
public InstrumentsDbTreeView |
121 |
getInstrumentsDbTreeView() { return instrumentsDbTreeView; } |
122 |
|
123 |
@Override |
124 |
public InstrumentsDbTableView |
125 |
getInstrumentsDbTableView() { return instrumentsDbTableView; } |
126 |
|
127 |
@Override |
128 |
public BasicIconSet |
129 |
getBasicIconSet() { return basicIconSet; } |
130 |
|
131 |
private class TreeView implements InstrumentsDbTreeView { |
132 |
@Override |
133 |
public Icon |
134 |
getRootIcon() { return Res.iconDb16; } |
135 |
|
136 |
@Override |
137 |
public Icon |
138 |
getClosedIcon() { return Res.iconFolder16; } |
139 |
|
140 |
@Override |
141 |
public Icon |
142 |
getOpenIcon() { return Res.iconFolderOpen16; } |
143 |
|
144 |
@Override |
145 |
public Icon |
146 |
getInstrumentIcon() { return Res.iconInstrument16; } |
147 |
|
148 |
@Override |
149 |
public Icon |
150 |
getGigInstrumentIcon() { return Res.iconInstrument16; } |
151 |
} |
152 |
|
153 |
private static class TableView implements InstrumentsDbTableView { |
154 |
@Override |
155 |
public Icon |
156 |
getFolderIcon() { return Res.iconFolder16; } |
157 |
|
158 |
@Override |
159 |
public Icon |
160 |
getInstrumentIcon() { return Res.iconInstrument16; } |
161 |
|
162 |
@Override |
163 |
public Icon |
164 |
getGigInstrumentIcon() { return Res.iconInstrument16; } |
165 |
} |
166 |
|
167 |
private class IconSet implements BasicIconSet { |
168 |
@Override |
169 |
public ImageIcon |
170 |
getApplicationIcon() { return Res.iconAppIcon; } |
171 |
|
172 |
@Override |
173 |
public Icon |
174 |
getBack16Icon() { return Res.iconBack16; } |
175 |
|
176 |
@Override |
177 |
public Icon |
178 |
getUp16Icon() { return Res.iconUp16; } |
179 |
|
180 |
@Override |
181 |
public Icon |
182 |
getForward16Icon() { return Res.iconNext16; } |
183 |
|
184 |
@Override |
185 |
public Icon |
186 |
getReload16Icon() { return Res.iconReload16; } |
187 |
|
188 |
@Override |
189 |
public Icon |
190 |
getPreferences16Icon() { return Res.iconPreferences16; } |
191 |
|
192 |
@Override |
193 |
public Icon |
194 |
getWarning32Icon() { return Res.iconWarning32; } |
195 |
|
196 |
@Override |
197 |
public Icon |
198 |
getQuestion32Icon() { return Res.iconQuestion32; } |
199 |
} |
200 |
|
201 |
@Override |
202 |
public boolean |
203 |
getInstrumentsDbSupport() { return true; } |
204 |
} |