1 // re/mind - Remote Reminder Software
2 // Copyright (C) 2002 Moritz Petersen
3 //
4 // This program is free software; you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation; either version 2 of the License, or
7 // (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with this program; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 //
18 // $Id: XMLUserPreferences.java,v 1.1.1.1 2002/09/29 17:26:05 powerpete Exp $
19 package de.jface.remind.io;
20
21 import de.jface.remind.awtui.UserPreferencesFrame;
22 import de.jface.util.Dictionary;
23
24 import java.io.FileInputStream;
25 import java.io.FileNotFoundException;
26 import java.io.FileOutputStream;
27 import java.io.IOException;
28
29 import org.jdom.JDOMException;
30
31 /***
32 * Class <code>XMLUserPreferences</code>
33 * of project RemotePostIt.
34 *
35 * @author Moritz Petersen
36 * @version $Revision: 1.1.1.1 $
37 */
38 public class XMLUserPreferences
39 extends UserPreferences
40 {
41 private String user;
42 private String host;
43 private String password;
44
45 public XMLUserPreferences()
46 throws FileNotFoundException, IOException, JDOMException
47 {
48 try
49 {
50 FileInputStream in = new FileInputStream(getPreferencesPath());
51 Dictionary dictionary = Dictionary.create(in);
52
53 user = dictionary.get("user");
54 host = dictionary.get("host");
55 password = dictionary.get("password");
56 }
57 catch (Exception e)
58 {
59 UserPreferencesFrame frame = new UserPreferencesFrame();
60
61 user = frame.getUser();
62 host = frame.getHost();
63 password = frame.getPassword();
64
65 Dictionary dictionary = new Dictionary("remotepostit");
66
67 dictionary.put("user", user);
68 dictionary.put("host", host);
69 dictionary.put("password", password);
70
71 FileOutputStream out = new FileOutputStream(getPreferencesPath());
72
73 dictionary.write(out);
74 }
75 }
76
77 public void setUser(String user)
78 {
79 this.user = user;
80 }
81
82 public String getUser()
83 {
84 return user;
85 }
86
87 public void setHost(String host)
88 {
89 this.host = host;
90 }
91
92 public String getHost()
93 {
94 return host;
95 }
96
97 public void setPassword(String password)
98 {
99 this.password = password;
100 }
101
102 public String getPassword()
103 {
104 return password;
105 }
106 }
107
108 // ------1---------2---------3---------4---------5---------6---------7---------8
This page was automatically generated by Maven