View Javadoc
1 /* 2 * ==================================================================== 3 * 4 * This code is subject to the freebxml License, Version 1.1 5 * 6 * Copyright (c) 2003 freebxml.org. All rights reserved. 7 * 8 * ==================================================================== 9 */ 10 package com.sun.xml.registry.client.browser.registration; 11 12 import java.awt.GridBagConstraints; 13 import java.awt.GridBagLayout; 14 15 import javax.swing.JComboBox; 16 import javax.swing.JLabel; 17 import javax.swing.JTextField; 18 import javax.swing.SwingConstants; 19 import javax.xml.registry.JAXRException; 20 import javax.xml.registry.infomodel.EmailAddress; 21 22 import com.sun.xml.registry.client.browser.swing.MappedDocumentListener; 23 import com.sun.xml.registry.client.browser.swing.RegistryComboBoxListener; 24 import com.sun.xml.registry.client.browser.swing.RegistryMappedPanel; 25 import com.sun.xml.registry.client.browser.swing.TextField; 26 27 /*** 28 * Panel for EmailAddress 29 * 30 * @author <a href="mailto:Farrukh.Najmi@Sun.COM">Farrukh S. Najmi</a> 31 * @author Fabian Ritzmann 32 */ 33 public class EmailAddressPanel extends RegistryMappedPanel { 34 35 private final EmailAddressModel model; 36 private final JTextField addressText = new JTextField(); 37 38 39 public EmailAddressPanel(EmailAddressModel email) { 40 41 super(email, "Can not display email address: "); 42 this.model = email; 43 44 GridBagLayout gbl = new GridBagLayout(); 45 GridBagConstraints c = new GridBagConstraints(); 46 setLayout(gbl); 47 48 JLabel addressLabel = new JLabel("Email Address:", SwingConstants.LEFT); 49 setConstraints(addressLabel, c, gbl, 0, 0, 1, 0.0, 50 GridBagConstraints.NONE, GridBagConstraints.WEST); 51 add(addressLabel); 52 53 this.addressText.getDocument().addDocumentListener(new AddressListener()); 54 setConstraints(addressText, c, gbl, 0, 1, 1, 0.5, 55 GridBagConstraints.BOTH, GridBagConstraints.WEST); 56 addTextField(new TextField() { 57 public JTextField getTextField() { 58 return addressText; 59 } 60 public String getText() throws JAXRException { 61 EmailAddress address = getEmailAddressModel().getAddress(); 62 if (address != null) { 63 return address.getAddress(); 64 } 65 return null; 66 } 67 }); 68 69 JLabel typeLabel = new JLabel("Address Type:", SwingConstants.LEFT); 70 setConstraints(typeLabel, c, gbl, 1, 0, 1, 0.0, 71 GridBagConstraints.NONE, GridBagConstraints.WEST); 72 add(typeLabel); 73 74 JComboBox typeCombo = new JComboBox(EmailAddressModel.EMAIL_TYPES); 75 typeCombo.addActionListener(new EmailTypeListener()); 76 typeCombo.setEditable(true); 77 setConstraints(typeCombo, c, gbl, 1, 1, 1, 0.5, 78 GridBagConstraints.HORIZONTAL, GridBagConstraints.WEST); 79 add(typeCombo); 80 } 81 82 83 public EmailAddressModel getEmailAddressModel() { 84 return this.model; 85 } 86 87 88 class AddressListener extends MappedDocumentListener { 89 90 AddressListener() { 91 super(getRegistryMappedPanel(), "Can not set email address: "); 92 } 93 94 protected void setText(String text) throws JAXRException { 95 getEmailAddressModel().setAddress(text); 96 } 97 } 98 99 100 class EmailTypeListener extends RegistryComboBoxListener { 101 102 EmailTypeListener() { 103 super(getEmailAddressModel(), getRegistryMappedPanel()); 104 } 105 } 106 107 }

This page was automatically generated by Maven