KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > j2ee > ejbjarproject > ui > wizards > ImportBuildfile


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.ejbjarproject.ui.wizards;
21
22 import java.io.File JavaDoc;
23 import java.text.MessageFormat JavaDoc;
24
25 import javax.swing.JButton JavaDoc;
26 import javax.swing.event.DocumentEvent JavaDoc;
27 import javax.swing.event.DocumentListener JavaDoc;
28
29 import org.openide.util.NbBundle;
30
31 import org.netbeans.spi.project.support.ant.GeneratedFilesHelper;
32
33 public class ImportBuildfile extends javax.swing.JPanel JavaDoc implements DocumentListener JavaDoc {
34
35     private JButton JavaDoc ok;
36     private String JavaDoc filePath;
37
38     /** Creates new form ImportBuildfile */
39     public ImportBuildfile(String JavaDoc filePath, JButton JavaDoc okButton) {
40         initComponents();
41         this.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(ImportBuildfile.class, "ACS_IW_BuildFileDialog_A11YDesc")); // NOI18N
42

43         ok = okButton;
44         this.filePath = filePath;
45         ok.setEnabled(false);
46         
47         String JavaDoc fileName = filePath + File.separator + GeneratedFilesHelper.BUILD_XML_PATH;
48         String JavaDoc msg = MessageFormat.format(NbBundle.getMessage(ImportBuildfile.class, "LBL_IW_BuildfileDesc_Label"), new String JavaDoc[] {fileName}); //NOI18N
49
jLabelDesc.setText(msg);
50         jTextFieldBuildName.getDocument().addDocumentListener(this);
51         jTextFieldBuildName.setText(NbBundle.getMessage(ImportBuildfile.class, "LBL_IW_ProposedName_TextField")); //NOI18N
52
}
53     
54     /** This method is called from within the constructor to
55      * initialize the form.
56      * WARNING: Do NOT modify this code. The content of this method is
57      * always regenerated by the Form Editor.
58      */

59     private void initComponents() {//GEN-BEGIN:initComponents
60
java.awt.GridBagConstraints JavaDoc gridBagConstraints;
61
62         jLabelDesc = new javax.swing.JLabel JavaDoc();
63         jLabelBuildName = new javax.swing.JLabel JavaDoc();
64         jTextFieldBuildName = new javax.swing.JTextField JavaDoc();
65         jLabelCreatedFile = new javax.swing.JLabel JavaDoc();
66         jTextFieldCreatedFile = new javax.swing.JTextField JavaDoc();
67
68         setLayout(new java.awt.GridBagLayout JavaDoc());
69
70         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
71         gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
72         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
73         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
74         gridBagConstraints.insets = new java.awt.Insets JavaDoc(12, 12, 11, 11);
75         add(jLabelDesc, gridBagConstraints);
76
77         jLabelBuildName.setDisplayedMnemonic(org.openide.util.NbBundle.getMessage(ImportBuildfile.class, "LBL_IW_BuildFilename_LabelMnemonic").charAt(0));
78         jLabelBuildName.setLabelFor(jTextFieldBuildName);
79         jLabelBuildName.setText(NbBundle.getMessage(ImportBuildfile.class, "LBL_IW_BuildFilename_Label"));
80         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
81         gridBagConstraints.gridx = 0;
82         gridBagConstraints.gridy = 1;
83         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
84         gridBagConstraints.insets = new java.awt.Insets JavaDoc(0, 12, 11, 11);
85         add(jLabelBuildName, gridBagConstraints);
86
87         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
88         gridBagConstraints.gridx = 1;
89         gridBagConstraints.gridy = 1;
90         gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
91         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
92         gridBagConstraints.weightx = 1.0;
93         gridBagConstraints.insets = new java.awt.Insets JavaDoc(0, 0, 11, 11);
94         add(jTextFieldBuildName, gridBagConstraints);
95         jTextFieldBuildName.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(ImportBuildfile.class, "ACS_LBL_IW_BuildFilename_A11YDesc"));
96
97         jLabelCreatedFile.setDisplayedMnemonic(org.openide.util.NbBundle.getMessage(ImportBuildfile.class, "LBL_IW_CreatedFile_LabelMnemonic").charAt(0));
98         jLabelCreatedFile.setLabelFor(jTextFieldCreatedFile);
99         jLabelCreatedFile.setText(NbBundle.getMessage(ImportBuildfile.class, "LBL_IW_CreatedFile_Label"));
100         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
101         gridBagConstraints.gridx = 0;
102         gridBagConstraints.gridy = 2;
103         gridBagConstraints.gridheight = java.awt.GridBagConstraints.REMAINDER;
104         gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
105         gridBagConstraints.weighty = 1.0;
106         gridBagConstraints.insets = new java.awt.Insets JavaDoc(0, 12, 11, 11);
107         add(jLabelCreatedFile, gridBagConstraints);
108
109         jTextFieldCreatedFile.setEditable(false);
110         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
111         gridBagConstraints.gridx = 1;
112         gridBagConstraints.gridy = 2;
113         gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
114         gridBagConstraints.gridheight = java.awt.GridBagConstraints.REMAINDER;
115         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
116         gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTH;
117         gridBagConstraints.weighty = 1.0;
118         gridBagConstraints.insets = new java.awt.Insets JavaDoc(0, 0, 11, 11);
119         add(jTextFieldCreatedFile, gridBagConstraints);
120         jTextFieldCreatedFile.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(ImportBuildfile.class, "ACS_LBL_IW_CreatedFile_A11YDesc"));
121
122     }//GEN-END:initComponents
123

124     // Variables declaration - do not modify//GEN-BEGIN:variables
125
private javax.swing.JLabel JavaDoc jLabelBuildName;
126     private javax.swing.JLabel JavaDoc jLabelCreatedFile;
127     private javax.swing.JLabel JavaDoc jLabelDesc;
128     private javax.swing.JTextField JavaDoc jTextFieldBuildName;
129     private javax.swing.JTextField JavaDoc jTextFieldCreatedFile;
130     // End of variables declaration//GEN-END:variables
131

132     protected String JavaDoc getBuildName() {
133         return jTextFieldBuildName.getText().trim();
134     }
135     
136     // Implementation of DocumentListener --------------------------------------
137
public void changedUpdate(DocumentEvent JavaDoc e) {
138         updateButton();
139     }
140     
141     public void insertUpdate(DocumentEvent JavaDoc e) {
142         updateButton();
143     }
144     
145     public void removeUpdate(DocumentEvent JavaDoc e) {
146         updateButton();
147     }
148     // End if implementation of DocumentListener -------------------------------
149

150     private void updateButton() {
151         jTextFieldCreatedFile.setText(filePath + File.separator + jTextFieldBuildName.getText());
152
153         if (jTextFieldBuildName.getText().trim().length() == 0 || jTextFieldBuildName.getText().trim().equals(GeneratedFilesHelper.BUILD_XML_PATH))
154             ok.setEnabled(false);
155         else
156             ok.setEnabled(true);
157     }
158 }
159
Popular Tags