Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: org/jabbee/resources/PreferencesHandler.java


1   /*
2    * PreferencesHandler.java
3    *
4    * Created on October 23, 2002, 8:46 AM
5    *
6    *
7    * License:
8    *
9    * The contents of this file are subject to the Jabber Open Source
10   * License Version 1.0 (the "License"). You may not copy or use this
11   * file, in either source code or executable form, except in compliance
12   * with the License. You may obtain a copy of the License at
13   * http://www.jabber.com/license/ or at http://www.opensource.org/.
14   * Software distributed under the License is distributed on an "AS IS" 
15   * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
16   * the License for the specific language governing rights and limitations
17   * under the License.
18   *
19   * Copyrights:
20   *
21   * Portions created by or assigned to Jabber.com, Inc. are Copyright
22   * (c) 1999-2000 Jabber.com, Inc. All Rights Reserved. Contact information
23   * for Jabber.com, Inc. is available at http://www.jabber.com/. Portions
24   * Copyright (c) 1998-1999 Jeremie Miller.
25   *
26   * Acknowledgements:
27   *
28   * Special thanks to the Jabber Open Source Contributors for their
29   * suggestions and support of Jabber.
30   *
31   */
32  
33  package org.jabbee.resources;
34  
35  /**
36   * PreferencesHandler is the interface between the Jabbee application and any/all
37   * preferences that are saved from it, or need to be retreived by it.
38   *
39   * @author  Gregory Kaczmarczyk
40   *
41   * @version 0.01
42   */
43  public final class PreferencesHandler {
44  
45      private java.util.prefs.Preferences prefs;
46      private String configFile;
47      private boolean relativePaths;
48      private boolean toolTips;
49      
50      /** Creates a new instance of PreferencesHandler */
51      public PreferencesHandler(java.util.prefs.Preferences p) {
52          prefs = p;
53      }
54  
55      /** Retreives the current state of tooltips
56       *
57       * @return boolean True if tooltips are enabled, false if not
58       */
59      public boolean areToolTipsEnabled() {
60          return (prefs.getBoolean("jabbee-tooltips", true));
61      }
62  
63      /** Gets the full path to the Jabber Configuration file.
64       *
65       * @return String Path to jabber.xml
66       */
67      public String getConfigFile() {
68          return (prefs.get("jabbee-config_file", ""));
69      }
70  
71      /** Sets the full path to the Jabber Configuration file to the
72       *  user's preferences.
73       *
74       * @param cf Path to jabber.xml
75       */
76      public void setConfigFile(String cf) {
77          prefs.put("jabbee-config_file", cf);
78      }
79  
80      /** Sets whether or not to userelative paths in the Jabber configuration
81       *  file.
82       *
83       * @param rp True - use paths relative to jabber.xml.
84       *           False - use full path name for all files.
85       */
86      public void setRelativePaths(boolean rp) {
87          prefs.putBoolean("jabbee-relative_paths", rp);
88      }
89  
90      /** Sets tooltips to be visible or not visible
91       *
92       * @param bool True to display tooltips, false to hide tooltips
93       */
94      public void setToolTips(boolean bool) {
95          prefs.putBoolean("jabbee-tooltips", bool);
96      }
97  
98      /** Gets whether or not to use relative paths for all files in the Jabber
99       *  configuration file.
100      *
101      * @return boolean If true, use relative paths, otherwise full path name
102      */
103     public boolean useRelativePaths() {
104         return (prefs.getBoolean("jabbee-relative_paths", true));
105     }
106 }