KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > suberic > pooka > gui > propedit > AddressEntryEditor


1 package net.suberic.pooka.gui.propedit;
2 import net.suberic.pooka.*;
3 import net.suberic.util.*;
4 import net.suberic.util.gui.*;
5 import net.suberic.util.gui.propedit.*;
6 import javax.swing.*;
7 import java.awt.event.*;
8 import java.awt.Cursor JavaDoc;
9 import java.util.Properties JavaDoc;
10
11 /**
12  * A property editor which edits an AddressBookEntry.
13  */

14 public class AddressEntryEditor extends CompositeEditorPane {
15   AddressBookEntry entry;
16
17   /**
18    * Creates an AddressEntryEditor from an AddressBookEntry and a
19    * VariableBundle.
20    */

21   public AddressEntryEditor(PropertyEditorManager newManager, AddressBookEntry newEntry) {
22     entry = newEntry;
23
24     Properties JavaDoc props = entry.getProperties();
25     VariableBundle wrappedBundle = new VariableBundle(props, newManager.getFactory().getSourceBundle());
26     PropertyEditorManager wrappedManager = new PropertyEditorManager(wrappedBundle, newManager.getFactory(), newManager.getIconManager());
27     configureEditor("currentAddress", "currentAddress", wrappedManager);
28   }
29
30   /**
31    * Sets the values to the current entry.
32    */

33   public void setValue() throws PropertyValueVetoException {
34     if (isEditorEnabled()) {
35       for (int i = 0; i < editors.size(); i++) {
36         ((SwingPropertyEditor)(editors.get(i))).setValue();
37       }
38     }
39
40     try {
41       entry.setAddresses(javax.mail.internet.InternetAddress.parse(manager.getProperty("currentAddress.address", "")));
42     } catch (javax.mail.internet.AddressException JavaDoc ae) {
43       ae.printStackTrace();
44
45     }
46     entry.setPersonalName(manager.getProperty("currentAddress.personalName", ""));
47     entry.setFirstName(manager.getProperty("currentAddress.firstName", ""));
48     entry.setLastName(manager.getProperty("currentAddress.lastName", ""));
49   }
50
51 }
52
Popular Tags