/[svn]/jsampler/trunk/src/org/jsampler/view/classic/ClassicPrefs.java
ViewVC logotype

Diff of /jsampler/trunk/src/org/jsampler/view/classic/ClassicPrefs.java

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

revision 1203 by iliev, Mon Apr 2 21:18:31 2007 UTC revision 1204 by iliev, Thu May 24 21:43:45 2007 UTC
# Line 36  import org.jsampler.CC; Line 36  import org.jsampler.CC;
36  public class ClassicPrefs {  public class ClassicPrefs {
37          private final static String prefNode = "org.jsampler.view.classic";          private final static String prefNode = "org.jsampler.view.classic";
38                    
39          private final static String WINDOW_SIZE_AND_LOCATION = "Mainframe.sizeAndLocation";          private final static String WINDOW_SIZE_AND_LOCATION = ".sizeAndLocation";
40          private final static String DEF_WINDOW_SIZE_AND_LOCATION = null;          private final static String DEF_WINDOW_SIZE_AND_LOCATION = null;
41                    
42          private final static String WINDOW_MAXIMIZED = "Mainframe.maximized";          private final static String WINDOW_MAXIMIZED = ".maximized";
43          private final static boolean DEF_WINDOW_MAXIMIZED = false;          private final static boolean DEF_WINDOW_MAXIMIZED = false;
44                    
45          private final static String SAVE_WINDOW_PROPERTIES = "Mainframe.saveProperties";          private final static String SAVE_WINDOW_PROPERTIES = "Mainframe.saveProperties";
# Line 147  public class ClassicPrefs { Line 147  public class ClassicPrefs {
147          user() { return userPrefs; }          user() { return userPrefs; }
148                    
149          /**          /**
150           * Gets a string representation of the main window's size and location.           * Gets a string representation of a window's size and location.
151           * The string representation is a comma-separated list           * The string representation is a comma-separated list
152           * of x and y coordinates, and width and height of the window.           * of x and y coordinates, and width and height of the window.
153           * @return A string representation of the main window's size and location,           * @param window The name of the window whose size and location should be obtained.
154             * @return A string representation of the window's size and location,
155           * or <code>null</code> if the value is not set.           * or <code>null</code> if the value is not set.
156           */           */
157          public static String          public static String
158          getWindowSizeAndLocation() {          getWindowSizeAndLocation(String window) {
159                  return user().get(WINDOW_SIZE_AND_LOCATION, DEF_WINDOW_SIZE_AND_LOCATION);                  return user().get(window + WINDOW_SIZE_AND_LOCATION, DEF_WINDOW_SIZE_AND_LOCATION);
160          }          }
161                    
162          /**          /**
163           * Sets the main window's size and location.           * Sets the window's size and location.
164           * Use <code>null</code> to remove the current value.           * Use <code>null</code> to remove the current value.
165           * @param s A string representation of the main window's size and location.           * @param window The name of the window whose size and location should be set.
166             * @param s A string representation of the window's size and location.
167           */           */
168          public static void          public static void
169          setWindowSizeAndLocation(String s) {          setWindowSizeAndLocation(String window, String s) {
170                  if(s == null) {                  if(s == null) {
171                          user().remove(WINDOW_SIZE_AND_LOCATION);                          user().remove(window + WINDOW_SIZE_AND_LOCATION);
172                          return;                          return;
173                  }                  }
174                                    
175                  user().put(WINDOW_SIZE_AND_LOCATION, s);                  user().put(window + WINDOW_SIZE_AND_LOCATION, s);
176          }          }
177                    
178          /**          /**
179           * Determines whether the main window should be maximized.           * Determines whether the specified window should be maximized.
180           * @return <code>true</code> if the main window should be maximized,           * @param window The name of the window.
181             * @return <code>true</code> if the specified window should be maximized,
182           * <code>false</code> otherwise.           * <code>false</code> otherwise.
183           */           */
184          public static boolean          public static boolean
185          getWindowMaximized() {          getWindowMaximized(String window) {
186                  return user().getBoolean(WINDOW_MAXIMIZED, DEF_WINDOW_MAXIMIZED);                  return user().getBoolean(window + WINDOW_MAXIMIZED, DEF_WINDOW_MAXIMIZED);
187          }          }
188                    
189          /**          /**
190           * Sets whether the main window should be maximized.           * Sets whether the specified window should be maximized.
191           * @param b If <code>true</code> the main window should be maximized.           * @param window The name of the window.
192             * @param b If <code>true</code> the specified window should be maximized.
193           */           */
194          public static void          public static void
195          setWindowMaximized(boolean b) {          setWindowMaximized(String window, boolean b) {
196                  if(b == getWindowMaximized()) return;                  if(b == getWindowMaximized(window)) return;
197                  user().putBoolean(WINDOW_MAXIMIZED, b);                  user().putBoolean(window + WINDOW_MAXIMIZED, b);
198          }          }
199                    
200          /**          /**
# Line 964  public class ClassicPrefs { Line 968  public class ClassicPrefs {
968          }          }
969                    
970                    
971            /**
972             * Gets an integer property.
973             * @param name The name of the property.
974             * @return The value of the specified property.
975             * If the property is not set, the return value is zero.
976             */
977            public static int
978            getIntProperty(String name) {
979                    return user().getInt(name, 0);
980            }
981            
982            /**
983             * Sets an integer property.
984             * @param name The name of the property.
985             * @param i The new value for the specified property.
986             */
987            public static void
988            setIntProperty(String name, int i) {
989                    if(i == getIntProperty(name)) return;
990                    user().putInt(name, i);
991            }
992            
993            
994            /**
995             * Gets a boolean property.
996             * @param name The name of the property.
997             * @return The value of the specified property.
998             * If the property is not set, the return value is <code>false</code>.
999             */
1000            public static boolean
1001            getBoolProperty(String name) {
1002                    return user().getBoolean(name, false);
1003            }
1004            
1005            /**
1006             * Sets a boolean property.
1007             * @param name The name of the property.
1008             * @param b The new value for the specified property.
1009             */
1010            public static void
1011            setBoolProperty(String name, boolean b) {
1012                    if(b == getBoolProperty(name)) return;
1013                    user().putBoolean(name, b);
1014            }
1015  }  }

Legend:
Removed from v.1203  
changed lines
  Added in v.1204

  ViewVC Help
Powered by ViewVC