Oopsie. MailServerPrefsEditor now initializes values.

This commit is contained in:
grail%cafebabe.org 1999-02-23 11:34:59 +00:00
Родитель f5b23898ce
Коммит 7750c788fa
1 изменённых файлов: 40 добавлений и 20 удалений

Просмотреть файл

@ -36,6 +36,7 @@ import java.util.Hashtable;
import java.util.MissingResourceException; import java.util.MissingResourceException;
import java.util.ResourceBundle; import java.util.ResourceBundle;
import java.util.Vector; import java.util.Vector;
import java.io.File;
import javax.mail.Store; import javax.mail.Store;
import javax.mail.URLName; import javax.mail.URLName;
@ -50,6 +51,7 @@ import javax.swing.JComponent;
import javax.swing.JList; import javax.swing.JList;
import javax.swing.JScrollPane; import javax.swing.JScrollPane;
import javax.swing.ListModel; import javax.swing.ListModel;
import javax.swing.text.JTextComponent;
import javax.swing.border.BevelBorder; import javax.swing.border.BevelBorder;
import javax.swing.event.EventListenerList; import javax.swing.event.EventListenerList;
import javax.swing.event.ListDataEvent; import javax.swing.event.ListDataEvent;
@ -107,7 +109,6 @@ public class MailServerPrefsEditor implements PropertyEditor
public void actionPerformed(ActionEvent aEvent) { public void actionPerformed(ActionEvent aEvent) {
String action = aEvent.getActionCommand(); String action = aEvent.getActionCommand();
System.out.println(action);
if (action.equals(kNewKey)) { if (action.equals(kNewKey)) {
EditHostDialog hostDialog = EditHostDialog hostDialog =
new EditHostDialog(Util.GetParentFrame(fPanel), null); new EditHostDialog(Util.GetParentFrame(fPanel), null);
@ -144,39 +145,59 @@ public class MailServerPrefsEditor implements PropertyEditor
} }
} else if (action.equals(kChooseKey)) { } else if (action.equals(kChooseKey)) {
JFileChooser chooser = new JFileChooser(fPrefs.getMailDirectory()); JFileChooser chooser = new JFileChooser(fPrefs.getMailDirectory());
// chooser.addChoosableFileFilter(new FileFilter[] DirectoryFilter filter = new DirectoryFilter();
// {FileFilter.SharedFolder}); File selected;
String path;
chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
chooser.setFileFilter(filter);
chooser.addChoosableFileFilter(filter);
chooser.showDialog(fPanel, "Okay"); chooser.showDialog(fPanel, "Okay");
selected = chooser.getSelectedFile();
path = selected.getAbsolutePath();
((JTextComponent)
fPanel.getCtrlByName(kMailDirectoryKey)).setText(path);
fPrefs.setMailDirectory(path);
fListeners.firePropertyChange(null, null, fPrefs);
} }
} }
} }
class DirectoryFilter extends FileFilter {
public boolean accept(File f) {
return f.isDirectory();
}
public String getDescription() {
return "Directories";
}
}
public MailServerPrefsEditor() { public MailServerPrefsEditor() {
fModel = new ServerPrefsModel(); fModel = new ServerPrefsModel();
fHostListModel = new HostListModel(); fHostListModel = new HostListModel();
URL url = getClass().getResource("PrefDialogs.xml"); URL url = getClass().getResource("PrefDialogs.xml");
try { fPanel = new PageUI(url, "id", "serverPrefs", fModel, getClass());
fPanel = new PageUI(url, "id", "serverPrefs", fModel, getClass());
JComponent c; JComponent c;
ChangeAction ca = new ChangeAction(); ChangeAction ca = new ChangeAction();
Prefs prefs = new Prefs();
MailServerPrefs mail = prefs.getMailServerPrefs();
setValue(mail);
c = fPanel.getCtrlByName(kSMTPHostKey); c = fPanel.getCtrlByName(kSMTPHostKey);
c.addPropertyChangeListener(ca); c.addPropertyChangeListener(ca);
c = fPanel.getCtrlByName(kMailDirectoryKey); c = fPanel.getCtrlByName(kMailDirectoryKey);
c.addPropertyChangeListener(ca); c.addPropertyChangeListener(ca);
c = fPanel.getCtrlByName(kChooseKey);
c.addPropertyChangeListener(ca);
c = fPanel.getCtrlByName(kHostListKey); c = fPanel.getCtrlByName(kHostListKey);
if (c instanceof JList) { ((JList) c).setModel(fHostListModel);
((JList) c).setModel(fHostListModel); c.addPropertyChangeListener(new ListListener());
}
c.addPropertyChangeListener(new ListListener());
} catch (Exception e) {
e.printStackTrace();
}
} }
public String getAsText() { public String getAsText() {
@ -331,7 +352,6 @@ public class MailServerPrefsEditor implements PropertyEditor
class ChangeAction implements PropertyChangeListener { class ChangeAction implements PropertyChangeListener {
void event(EventObject aEvent) { void event(EventObject aEvent) {
getValue();
fListeners.firePropertyChange(null, null, fPrefs); fListeners.firePropertyChange(null, null, fPrefs);
} }