KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > j2ee > ejbcore > ui > logicalview > entres > SendEmailPanel


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.modules.j2ee.ejbcore.ui.logicalview.entres;
21
22 import java.awt.BorderLayout JavaDoc;
23 import java.beans.PropertyChangeEvent JavaDoc;
24 import java.beans.PropertyChangeListener JavaDoc;
25 import javax.swing.event.DocumentEvent JavaDoc;
26 import javax.swing.event.DocumentListener JavaDoc;
27
28
29 /**
30  *
31  * @author blaha
32  */

33 public class SendEmailPanel extends javax.swing.JPanel JavaDoc {
34
35     public static final String JavaDoc IS_VALID = "SendEmailPanel_isValid"; //NOI18N
36

37     private final ServiceLocatorStrategyPanel slcPanel;
38
39     /** Creates new form SendEmailPanel */
40     public SendEmailPanel(String JavaDoc lastLocator) {
41         initComponents();
42         slcPanel = new ServiceLocatorStrategyPanel(lastLocator);
43         serviceLocatorPanel.add(slcPanel,BorderLayout.CENTER);
44         slcPanel.addPropertyChangeListener(new PropertyChangeListener JavaDoc() {
45             public void propertyChange(PropertyChangeEvent JavaDoc evt) {
46                 if (evt.getPropertyName().equals(ServiceLocatorStrategyPanel.IS_VALID)) {
47                     Object JavaDoc newvalue = evt.getNewValue();
48                     if ((newvalue != null) && (newvalue instanceof Boolean JavaDoc)) {
49                         boolean isServiceLocatorOk = ((Boolean JavaDoc)newvalue).booleanValue();
50                         if (isServiceLocatorOk) {
51                             checkJndiName();
52                         } else {
53                             firePropertyChange(IS_VALID, true, false);
54                         }
55                     }
56                 }
57             }
58         });
59         jndiName.getDocument().addDocumentListener(new DocumentListener JavaDoc() {
60             public void changedUpdate(DocumentEvent JavaDoc documentEvent) {
61                 checkJndiName();
62             }
63             public void insertUpdate(DocumentEvent JavaDoc documentEvent) {
64                 checkJndiName();
65             }
66             public void removeUpdate(DocumentEvent JavaDoc documentEvent) {
67                 checkJndiName();
68             }
69         });
70     }
71     
72     public String JavaDoc getServiceLocator(){
73         return slcPanel.classSelected();
74     }
75     
76     public String JavaDoc getJndiName(){
77         return jndiName.getText();
78     }
79     
80     /** This method is called from within the constructor to
81      * initialize the form.
82      * WARNING: Do NOT modify this code. The content of this method is
83      * always regenerated by the Form Editor.
84      */

85     // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
86
private void initComponents() {
87         java.awt.GridBagConstraints JavaDoc gridBagConstraints;
88
89         jLabel1 = new javax.swing.JLabel JavaDoc();
90         jndiName = new javax.swing.JTextField JavaDoc();
91         serviceLocatorPanel = new javax.swing.JPanel JavaDoc();
92
93         setLayout(new java.awt.GridBagLayout JavaDoc());
94
95         org.openide.awt.Mnemonics.setLocalizedText(jLabel1, org.openide.util.NbBundle.getBundle(SendEmailPanel.class).getString("LBL_jndiName"));
96         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
97         gridBagConstraints.gridx = 0;
98         gridBagConstraints.gridy = 0;
99         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
100         gridBagConstraints.insets = new java.awt.Insets JavaDoc(12, 12, 11, 11);
101         add(jLabel1, gridBagConstraints);
102
103         jndiName.setColumns(30);
104         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
105         gridBagConstraints.gridx = 1;
106         gridBagConstraints.gridy = 0;
107         gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
108         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
109         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
110         gridBagConstraints.weightx = 1.0;
111         gridBagConstraints.insets = new java.awt.Insets JavaDoc(12, 0, 11, 11);
112         add(jndiName, gridBagConstraints);
113
114         serviceLocatorPanel.setLayout(new java.awt.BorderLayout JavaDoc());
115
116         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
117         gridBagConstraints.gridx = 0;
118         gridBagConstraints.gridy = 4;
119         gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
120         gridBagConstraints.gridheight = java.awt.GridBagConstraints.REMAINDER;
121         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
122         gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
123         gridBagConstraints.weightx = 1.0;
124         gridBagConstraints.weighty = 1.0;
125         gridBagConstraints.insets = new java.awt.Insets JavaDoc(0, 12, 11, 11);
126         add(serviceLocatorPanel, gridBagConstraints);
127
128     }
129     // </editor-fold>//GEN-END:initComponents
130

131     
132     // Variables declaration - do not modify//GEN-BEGIN:variables
133
private javax.swing.JLabel JavaDoc jLabel1;
134     private javax.swing.JTextField JavaDoc jndiName;
135     private javax.swing.JPanel JavaDoc serviceLocatorPanel;
136     // End of variables declaration//GEN-END:variables
137

138     protected void checkJndiName() {
139         if (jndiName.getText().trim().equals("")) {
140             firePropertyChange(IS_VALID, true, false);
141         } else {
142             firePropertyChange(IS_VALID, false, true);
143         }
144     }
145     
146 }
147
Popular Tags