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

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

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1767 by iliev, Mon Sep 8 00:19:27 2008 UTC revision 1867 by iliev, Mon Mar 16 22:12:32 2009 UTC
# Line 1  Line 1 
1  /*  /*
2   *   JSampler - a java front-end for LinuxSampler   *   JSampler - a java front-end for LinuxSampler
3   *   *
4   *   Copyright (C) 2005-2008 Grigor Iliev <grigor@grigoriliev.com>   *   Copyright (C) 2005-2009 Grigor Iliev <grigor@grigoriliev.com>
5   *   *
6   *   This file is part of JSampler.   *   This file is part of JSampler.
7   *   *
# Line 22  Line 22 
22    
23  package org.jsampler.view.fantasia;  package org.jsampler.view.fantasia;
24    
25    import java.util.HashMap;
26    import java.util.Map;
27    
28  import javax.swing.Icon;  import javax.swing.Icon;
29  import javax.swing.JDialog;  import javax.swing.ImageIcon;
 import javax.swing.JFrame;  
30  import javax.swing.UIManager;  import javax.swing.UIManager;
31    
32  import org.jsampler.CC;  import org.jsampler.CC;
# Line 33  import org.jsampler.JSPrefs; Line 35  import org.jsampler.JSPrefs;
35  import org.jsampler.view.InstrumentsDbTableView;  import org.jsampler.view.InstrumentsDbTableView;
36  import org.jsampler.view.InstrumentsDbTreeView;  import org.jsampler.view.InstrumentsDbTreeView;
37  import org.jsampler.view.BasicIconSet;  import org.jsampler.view.BasicIconSet;
38    import org.jsampler.view.JSMainFrame;
39  import org.jsampler.view.JSViewConfig;  import org.jsampler.view.JSViewConfig;
40    
41  import org.jvnet.substance.api.SubstanceConstants;  import org.jvnet.substance.api.SubstanceConstants;
# Line 47  public class ViewConfig extends JSViewCo Line 50  public class ViewConfig extends JSViewCo
50          private InstrumentsDbTreeView instrumentsDbTreeView = new TreeView();          private InstrumentsDbTreeView instrumentsDbTreeView = new TreeView();
51          private InstrumentsDbTableView instrumentsDbTableView = new TableView();          private InstrumentsDbTableView instrumentsDbTableView = new TableView();
52          private BasicIconSet basicIconSet = new IconSet();          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> */          /** Creates a new instance of <code>ViewConfig</code> */
58          public          public
59          ViewConfig() {          ViewConfig() {
60                  try {                  try {
61                            if(isUsingScreenMenuBar()) {
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());                          UIManager.setLookAndFeel(new SubstanceRavenGraphiteLookAndFeel());
67                          UIManager.put(SubstanceLookAndFeel.WATERMARK_VISIBLE, Boolean.FALSE);                          UIManager.put(SubstanceLookAndFeel.WATERMARK_VISIBLE, Boolean.FALSE);
68                                                    
# Line 59  public class ViewConfig extends JSViewCo Line 70  public class ViewConfig extends JSViewCo
70                                  SubstanceLookAndFeel.TABBED_PANE_CONTENT_BORDER_KIND,                                  SubstanceLookAndFeel.TABBED_PANE_CONTENT_BORDER_KIND,
71                                  SubstanceConstants.TabContentPaneBorderKind.SINGLE_FULL                                  SubstanceConstants.TabContentPaneBorderKind.SINGLE_FULL
72                          );                          );
73    
74                            if(isUsingScreenMenuBar()) {
75                                    // fix for setting the menu bar on top of the screen
76                                    menuPropsMap = getMenuProperties();
77                                    setNativeMenuProperties();
78                            }
79                                                    
80                          if(!preferences().getBoolProperty("TurnOffCustomWindowDecoration")) {                          if(!preferences().getBoolProperty("TurnOffCustomWindowDecoration")) {
81                                  javax.swing.JFrame.setDefaultLookAndFeelDecorated(true);                                  javax.swing.JFrame.setDefaultLookAndFeelDecorated(true);
# Line 70  public class ViewConfig extends JSViewCo Line 87  public class ViewConfig extends JSViewCo
87                          e.printStackTrace();                          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          public JSPrefs
132          preferences() { return FantasiaPrefs.preferences(); }          preferences() { return FantasiaPrefs.preferences(); }
133                    
134          /** Exports the view configuration of the current session. */          /** Exports the view configuration of the current session. */
135            @Override
136          public String          public String
137          exportSessionViewConfig() {          exportSessionViewConfig() {
138                  StringBuffer sb = new StringBuffer();                  StringBuffer sb = new StringBuffer();
139                  MainFrame frame = (MainFrame)CC.getMainFrame();                  MainFrame frame = (MainFrame)CC.getMainFrame();
140                                    
141                  for(int i = 0; i < frame.getChannelsPane(0).getChannelCount(); i++) {                  for(int i = 0; i < frame.getChannelsPaneCount(); i++) {
142                          Channel c = (Channel)frame.getChannelsPane(0).getChannel(i);                          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");                          sb.append("#jsampler.fantasia: [channel]\r\n");
178                                                    
179                            sb.append("#jsampler.fantasia: channelLane = ");
180                            sb.append(channelsPane + 1).append("\r\n");
181                            
182                          switch(c.getViewTracker().getOriginalView().getType()) {                          switch(c.getViewTracker().getOriginalView().getType()) {
183                                  case SMALL:                                  case SMALL:
184                                          sb.append("#jsampler.fantasia: viewType = SMALL\r\n");                                          sb.append("#jsampler.fantasia: viewType = SMALL\r\n");
# Line 95  public class ViewConfig extends JSViewCo Line 189  public class ViewConfig extends JSViewCo
189                                          break;                                          break;
190                          }                          }
191                                                    
192                          sb.append("#jsampler.fantasia: \r\n");                          boolean b = c.getViewTracker().getOriginalView().isOptionsButtonSelected();
193                  }                          sb.append("#jsampler.fantasia: expanded = ").append(b).append("\r\n");
                   
                 MidiDevicesPane midi = frame.getRightSidePane().getDevicesPane().getMidiDevicesPane();  
                   
                 for(int i = 0; i < midi.getDevicePaneCount(); i++) {  
                         sb.append("#jsampler.fantasia: [MIDI device]\r\n");  
194                                                    
195                          if(midi.getDevicePaneAt(i).isOptionsPaneExpanded()) {                          sb.append("#\r\n");
                                 sb.append("#jsampler.fantasia: expanded = true\r\n");  
                         } else {  
                                 sb.append("#jsampler.fantasia: expanded = false\r\n");  
                         }  
                           
                         sb.append("#jsampler.fantasia: \r\n");  
196                  }                  }
                   
                 return sb.toString();  
197          }          }
198                    
199            @Override
200          public InstrumentsDbTreeView          public InstrumentsDbTreeView
201          getInstrumentsDbTreeView() { return instrumentsDbTreeView; }          getInstrumentsDbTreeView() { return instrumentsDbTreeView; }
202                    
203            @Override
204          public InstrumentsDbTableView          public InstrumentsDbTableView
205          getInstrumentsDbTableView() { return instrumentsDbTableView; }          getInstrumentsDbTableView() { return instrumentsDbTableView; }
206                    
207            @Override
208          public BasicIconSet          public BasicIconSet
209          getBasicIconSet() { return basicIconSet; }          getBasicIconSet() { return basicIconSet; }
210                    
211          private class TreeView implements InstrumentsDbTreeView {          private class TreeView implements InstrumentsDbTreeView {
212                    @Override
213                  public Icon                  public Icon
214                  getRootIcon() { return Res.iconDb16; }                  getRootIcon() { return Res.iconDb16; }
215                                    
216                    @Override
217                  public Icon                  public Icon
218                  getClosedIcon() { return Res.iconFolder16; }                  getClosedIcon() { return Res.iconFolder16; }
219                    
220                    @Override
221                  public Icon                  public Icon
222                  getOpenIcon() { return Res.iconFolderOpen16; }                  getOpenIcon() { return Res.iconFolderOpen16; }
223                    
224                    @Override
225                  public Icon                  public Icon
226                  getInstrumentIcon() { return Res.iconInstrument16; }                  getInstrumentIcon() { return Res.iconInstrument16; }
227                    
228                    @Override
229                  public Icon                  public Icon
230                  getGigInstrumentIcon() { return Res.iconInstrument16; }                  getGigInstrumentIcon() { return Res.iconInstrument16; }
231          }          }
232                    
233          private static class TableView implements InstrumentsDbTableView {          private static class TableView implements InstrumentsDbTableView {
234                    @Override
235                  public Icon                  public Icon
236                  getFolderIcon() { return Res.iconFolder16; }                  getFolderIcon() { return Res.iconFolder16; }
237                    
238                    @Override
239                  public Icon                  public Icon
240                  getInstrumentIcon() { return Res.iconInstrument16; }                  getInstrumentIcon() { return Res.iconInstrument16; }
241                    
242                    @Override
243                  public Icon                  public Icon
244                  getGigInstrumentIcon() { return Res.iconInstrument16; }                  getGigInstrumentIcon() { return Res.iconInstrument16; }
245          }          }
246                    
247          private class IconSet implements BasicIconSet {          private class IconSet implements BasicIconSet {
248                    @Override
249                    public ImageIcon
250                    getApplicationIcon() { return Res.iconAppIcon; }
251                    
252                    @Override
253                  public Icon                  public Icon
254                  getBack16Icon() { return Res.iconBack16; }                  getBack16Icon() { return Res.iconBack16; }
255                    
256                    @Override
257                  public Icon                  public Icon
258                  getUp16Icon() { return Res.iconUp16; }                  getUp16Icon() { return Res.iconUp16; }
259                    
260                    @Override
261                  public Icon                  public Icon
262                  getForward16Icon() { return Res.iconNext16; }                  getForward16Icon() { return Res.iconNext16; }
263                                    
264                    @Override
265                  public Icon                  public Icon
266                  getReload16Icon() { return Res.iconReload16; }                  getReload16Icon() { return Res.iconReload16; }
267                                    
268                    @Override
269                  public Icon                  public Icon
270                  getPreferences16Icon() { return Res.iconPreferences16; }                  getPreferences16Icon() { return Res.iconPreferences16; }
271                                    
272                    @Override
273                  public Icon                  public Icon
274                  getWarning32Icon() { return Res.iconWarning32; }                  getWarning32Icon() { return Res.iconWarning32; }
275                                    
276                    @Override
277                  public Icon                  public Icon
278                  getQuestion32Icon() { return Res.iconQuestion32; }                  getQuestion32Icon() { return Res.iconQuestion32; }
279          }          }
280                    
281            @Override
282          public boolean          public boolean
283          getInstrumentsDbSupport() { return true; }          getInstrumentsDbSupport() { return true; }
284  }  }

Legend:
Removed from v.1767  
changed lines
  Added in v.1867

  ViewVC Help
Powered by ViewVC