/[svn]/jsampler/trunk/src/org/jsampler/Prefs.java
ViewVC logotype

Contents of /jsampler/trunk/src/org/jsampler/Prefs.java

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1688 - (show annotations) (download)
Thu Feb 14 16:52:36 2008 UTC (16 years, 2 months ago) by iliev
File size: 5033 byte(s)
* Implemented a backend list with option to manually choose a backend
  to connect on startup(Edit/Preferences, then click the `Backend' tab)
  and option to change the backend without restarting JSampler
  (Actions/Change Backend or Ctrl + B)

* Added confirmation messages for removing sampler channels and
  audio/MIDI devices (Edit/Preferences, then click the `View' tab)

1 /*
2 * JSampler - a java front-end for LinuxSampler
3 *
4 * Copyright (C) 2005-2006 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;
24
25 import java.util.prefs.Preferences;
26
27
28 /**
29 * This class represents the preferences of the JSampler package.
30 * @author Grigor Iliev
31 */
32 public class Prefs {
33 private final static String prefNode = "org.jsampler";
34
35 private final static String VIEW = "VIEW";
36 private final static String DEF_VIEW = "classic";
37
38 private final static String JSAMPLER_HOME = "JSampler.home";
39 private final static String DEF_JSAMPLER_HOME = null;
40
41 private final static String INTERFACE_LANGUAGE = "iface.language";
42 private final static String DEF_INTERFACE_LANGUAGE = "en";
43
44 private final static String INTERFACE_COUNTRY = "iface.country";
45 private final static String DEF_INTERFACE_COUNTRY = "US";
46
47 private final static String INTERFACE_FONT = "iface.font";
48 private final static String DEF_INTERFACE_FONT = null;
49
50
51 private static Preferences userPrefs = Preferences.userRoot().node(prefNode);
52
53 /**
54 * Gets the user preferences node of the JSampler package.
55 * @return The user preferences node of the JSampler package.
56 */
57 private static Preferences
58 user() { return userPrefs; }
59
60
61 // VIEW
62 /**
63 * Gets the name of the current View.
64 * @return the name of the current View.
65 */
66 public static String
67 getView() { return user().get(VIEW, DEF_VIEW); }
68
69 /**
70 * Sets the current View of JSampler.
71 * @param view the name of the new View.
72 */
73 public static void
74 setView(String view) {
75 if(view == null) user().remove(VIEW);
76 else if(!view.equals(getView())) user().put(VIEW, view);
77 }
78
79 /**
80 * Gets the interface language.
81 * @return The interface language.
82 */
83 public static String
84 getInterfaceLanguage() { return user().get(INTERFACE_LANGUAGE, DEF_INTERFACE_LANGUAGE); }
85
86 /**
87 * Sets the interface language.
88 * @return <code>true</code> if the interface language has changed and <code>false</code>
89 * otherwise.
90 */
91 public static boolean
92 setInterfaceLanguage(String language) {
93 if(language == null) {
94 user().remove(INTERFACE_LANGUAGE);
95 return true;
96 } else if(!language.equals(getInterfaceLanguage())) {
97 user().put(INTERFACE_LANGUAGE, language);
98 return true;
99 }
100 return false;
101 }
102
103 /**
104 * Gets the interface country.
105 * @return The interface country.
106 */
107 public static String
108 getInterfaceCountry() { return user().get(INTERFACE_COUNTRY, DEF_INTERFACE_COUNTRY); }
109
110 /**
111 * Sets the interface country.
112 * @return <code>true</code> if the interface country has changed and <code>false</code>
113 * otherwise.
114 */
115 public static boolean
116 setInterfaceCountry(String country) {
117 if(country == null) {
118 user().remove(INTERFACE_COUNTRY);
119 return true;
120 } else if(!country.equals(getInterfaceCountry())) {
121 user().put(INTERFACE_COUNTRY, country);
122 return true;
123 }
124 return false;
125 }
126
127 /**
128 * Gets the interface font.
129 * @return The interface font.
130 */
131 public static String
132 getInterfaceFont() { return user().get(INTERFACE_FONT, DEF_INTERFACE_FONT); }
133
134 /**
135 * Sets the interface font.
136 * @return <code>true</code> if the interface font has changed and <code>false</code>
137 * otherwise.
138 */
139 public static boolean
140 setInterfaceFont(String font) {
141 if(font == null) {
142 if(getInterfaceFont() == null) return false;
143 user().remove(INTERFACE_FONT);
144 return true;
145 } else if(!font.equals(getInterfaceFont())) {
146 user().put(INTERFACE_FONT, font);
147 return true;
148 }
149 return false;
150 }
151
152 // PREFERENCES
153 /**
154 * Gets the absolute path of JSampler home directory.
155 * @return The absolute path of JSampler home directory or
156 * <code>null</code> if the JSampler home directory is not set.
157 */
158 public static String
159 getJSamplerHome() { return user().get(JSAMPLER_HOME, DEF_JSAMPLER_HOME); }
160
161 /**
162 * Sets the JSampler home directory.
163 * @param home The absolute path of JSampler home directory.
164 * @return <code>true</code> if the JSampler home directory has
165 * been changed and <code>false</code> otherwise.
166 */
167 public static boolean
168 setJSamplerHome(String home) {
169 if(home == null) {
170 if(getJSamplerHome() == null) return false;
171 user().remove(JSAMPLER_HOME);
172 return true;
173 } else if(!home.equals(getJSamplerHome())) {
174 user().put(JSAMPLER_HOME, home);
175 return true;
176 }
177 return false;
178 }
179 }

  ViewVC Help
Powered by ViewVC