Fixed breakage of the preference beans.

git-svn-id: svn://10.0.0.236/trunk@29951 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
grail%cafebabe.org
1999-05-02 00:15:05 +00:00
parent e1f400aecd
commit cf037dd9f7
3 changed files with 54 additions and 19 deletions

View File

@@ -454,8 +454,11 @@ public class CompositionPanel extends GeneralPanel {
//get the sending identity
Preferences prefs = PreferencesFactory.Get();
int ident = mAddressBar.getOptionsPanel().getSelectedIdentity();
String userName = prefs.getString("mail.identity-" + ident + ".username", "Nobody") + " <"
+ prefs.getString("mail.identity-" + ident + ".email", "nobody@localhost") + ">";
String userName =
prefs.getString("mail.identity.username." + ident,
"Nobody") + " <"
+ prefs.getString("mail.identity.email." + ident,
"nobody@localhost") + ">";
if (userName != null) {
//create a mime message

View File

@@ -98,7 +98,7 @@ public class OptionsPanel extends JPanel implements Serializable {
Preferences prefs = PreferencesFactory.Get();
int numIdentities = prefs.getInt("mail.identities", 1);
for (int i=0; i<numIdentities; i++) {
ident.addPossibleValue(prefs.getString("mail.identity-" + i + ".description", "(no description available)"));
ident.addPossibleValue(prefs.getString("mail.identity.description."+ 1, "(no description available)"));
}
// Select the default identity
ident.setSelectedIndex(ActionFactory.getIdent());

View File

@@ -36,6 +36,7 @@ import calypso.util.Preferences;
import calypso.util.PreferencesFactory;
import grendel.ui.StoreFactory;
import java.util.Vector;
public class Prefs {
static Preferences fPrefs = PreferencesFactory.Get();
@@ -52,9 +53,19 @@ public class Prefs {
static final String kLocalProtocol = "berkeley";
static final String kUserPrefsCount = "mail.identities";
Vector ids = new Vector();
public Prefs() {
int total = getUserPrefsCount();
System.out.println("Total is " + total);
for (int i = 0; i < total; i++) {
addUserPrefs(readUserPrefs(i));
}
}
public int getUserPrefsCount() {
return Integer.parseInt(fPrefs.getString(kUserPrefsCount, "0"));
return Integer.parseInt(fPrefs.getString(kUserPrefsCount, "1"));
}
@@ -63,23 +74,45 @@ public class Prefs {
}
public UserPrefs getUserPrefs(int count) {
UserPrefs res = new UserPrefs();
res.setUserName(fPrefs.getString(kUserName + count,
"John Doe"));
res.setUserName(fPrefs.getString(kEmailAddress + count,
"john@doe.com"));
res.setUserName(fPrefs.getString(kOrganization + count,
""));
return res;
return (UserPrefs)ids.elementAt(count);
}
public void setUserPrefs(UserPrefs aPrefs) {
fPrefs.putString(kUserName, aPrefs.getUserName());
fPrefs.putString(kEmailAddress, aPrefs.getUserEmailAddress());
fPrefs.putString(kOrganization, aPrefs.getUserOrganization());
fPrefs.putString(kSignatureFile, aPrefs.getSignatureFile());
public UserPrefs readUserPrefs(int count) {
UserPrefs res = new UserPrefs();
res.setUserName(fPrefs.getString(kUserName + count,
"John Doe"));
res.setUserEmailAddress(fPrefs.getString(kEmailAddress + count,
"john@doe.com"));
res.setUserOrganization(fPrefs.getString(kOrganization + count,
""));
return res;
}
public synchronized void setUserPrefs(UserPrefs aPrefs) {
addUserPrefs(aPrefs);
}
public synchronized void addUserPrefs(UserPrefs aPrefs) {
int location = 0;
// we need to find out where the object is located for its suffix
if (ids.contains(aPrefs)) {
location = ids.indexOf(aPrefs);
} else {
location = ids.size() - 1;
}
fPrefs.putString(kUserName + location,
aPrefs.getUserName());
fPrefs.putString(kEmailAddress + location,
aPrefs.getUserEmailAddress());
fPrefs.putString(kOrganization + location,
aPrefs.getUserOrganization());
fPrefs.putString(kSignatureFile + location,
aPrefs.getSignatureFile());
ids.addElement(aPrefs);
}
public MailServerPrefs getMailServerPrefs() {
@@ -161,7 +194,6 @@ public class Prefs {
public void setUIPrefs(UIPrefs aUIPrefs) {
if (aUIPrefs.getLAF() != null) {
try {
System.out.println("Setting L&F to " + aUIPrefs.getLAF());
UIManager.setLookAndFeel(aUIPrefs.getLAF());
} catch (UnsupportedLookAndFeelException e) {
e.printStackTrace();