001: /*
002: * Copyright (C) 2001, 2002 Robert MacGrogan
003: *
004: * This library is free software; you can redistribute it and/or
005: * modify it under the terms of the GNU Lesser General Public
006: * License as published by the Free Software Foundation; either
007: * version 2.1 of the License, or (at your option) any later version.
008: *
009: * This library is distributed in the hope that it will be useful,
010: * but WITHOUT ANY WARRANTY; without even the implied warranty of
011: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
012: * Lesser General Public License for more details.
013: *
014: * You should have received a copy of the GNU Lesser General Public
015: * License along with this library; if not, write to the Free Software
016: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
017: *
018: *
019: * $Archive: SourceJammer$
020: * $FileName: UserPrefs.java$
021: * $FileID: 4118$
022: *
023: * Last change:
024: * $AuthorName: Rob MacGrogan$
025: * $Date: 8/10/03 8:06 PM$
026: * $Comment: $
027: */
028: package org.sourcejammer.client.gui.conf;
029:
030: import java.awt.Dimension;
031: import java.awt.Rectangle;
032: import java.util.prefs.Preferences;
033:
034: /**
035: * Title: $FileName: UserPrefs.java$
036: * @author $AuthorName: Rob MacGrogan$
037: * @version $VerNum: 4$
038: * $KeyWordsOff: $
039: */
040: public class UserPrefs {
041:
042: private static UserPrefs instance = new UserPrefs();
043:
044: public static final String PROXY_ENABLED = "proxy enabled";
045: public static final String PROXY_PORT = "proxy port";
046: public static final String PROXY_HOST = "proxy host";
047: public static final String PROXY_USER = "proxy user";
048: public static final String PROXY_USE_PASSWORD = "proxy use password";
049:
050: public static final String WINDOW_X = "window x";
051: public static final String WINDOW_Y = "window y";
052: public static final String WINDOW_WIDTH = "window width";
053: public static final String WINDOW_HEIGHT = "window height";
054: public static final String WINDOW_MAX = "window maximized";
055:
056: public static final String LOOK_AND_FEEL = "look and feel";
057: public static final String SKIN_LF_THEME = "skin lf theme";
058:
059: public static final String VERTICAL_SPLIT = "vertical split";
060: public static final String HORIZONTAL_SPLIT = "horizontal split";
061:
062: private static final int DEFAULT_WINDOW_WIDTH = 800;
063: private static final int DEFAULT_WINDOW_HEIGHT = 500;
064:
065: public static final int DEFAULT_HORIZONTAL_SPLIT = 200;
066: public static final int DEFAULT_VERTICAL_SPLIT = 300;
067:
068: public static final String SYS_PROXY_ENABLED = "proxySet";
069: public static final String SYS_PROXY_HOST = "proxyHost";
070: public static final String SYS_PROXY_PORT = "proxyPort";
071: public static final String SYS_PROXY_USER = "proxyUser";
072: public static final String SYS_PROXY_PASSWORD = "proxyPasswd";
073:
074: public static final String LOCAL_REMOTE_SYNC_VIEW = "localRemoteSyncView";
075:
076: private UserPrefs() {
077: }
078:
079: public static UserPrefs getInstance() {
080: return instance;
081: }
082:
083: public void setString(String key, String val) {
084: Preferences prefs = Preferences.userNodeForPackage(this
085: .getClass());
086: prefs.put(key, val);
087: }
088:
089: public String getString(String key, String defaultVal) {
090: Preferences prefs = Preferences.userNodeForPackage(this
091: .getClass());
092: return prefs.get(key, defaultVal);
093: }
094:
095: public void setInt(String key, int val) {
096: Preferences prefs = Preferences.userNodeForPackage(this
097: .getClass());
098: prefs.putInt(key, val);
099: }
100:
101: public int getInt(String key, int defaultVal) {
102: Preferences prefs = Preferences.userNodeForPackage(this
103: .getClass());
104: return prefs.getInt(key, defaultVal);
105: }
106:
107: public void setBoolean(String key, boolean val) {
108: Preferences prefs = Preferences.userNodeForPackage(this
109: .getClass());
110: prefs.putBoolean(key, val);
111: }
112:
113: public boolean getBoolean(String key, boolean defaultVal) {
114: Preferences prefs = Preferences.userNodeForPackage(this
115: .getClass());
116: return prefs.getBoolean(key, defaultVal);
117: }
118:
119: public void removePreference(String key) {
120: Preferences prefs = Preferences.userNodeForPackage(this
121: .getClass());
122: prefs.remove(key);
123: }
124:
125: public Rectangle getStartupWindowBounds() {
126: Dimension sd = java.awt.Toolkit.getDefaultToolkit()
127: .getScreenSize();
128: int x = (sd.width - DEFAULT_WINDOW_WIDTH) / 2;
129: int y = (sd.height - DEFAULT_WINDOW_HEIGHT) / 2;
130:
131: x = getInt(WINDOW_X, x);
132: y = getInt(WINDOW_Y, y);
133: int width = getInt(WINDOW_WIDTH, DEFAULT_WINDOW_WIDTH);
134: int height = getInt(WINDOW_HEIGHT, DEFAULT_WINDOW_HEIGHT);
135: Rectangle bounds = new Rectangle(x, y, width, height);
136: return bounds;
137: }
138:
139: }
|