2
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
4
* Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
6
* The contents of this file are subject to the terms of either the GNU
7
* General Public License Version 2 only ("GPL") or the Common
8
* Development and Distribution License("CDDL") (collectively, the
9
* "License"). You may not use this file except in compliance with the
10
* License. You can obtain a copy of the License at
11
* http://www.netbeans.org/cddl-gplv2.html
12
* or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
13
* specific language governing permissions and limitations under the
14
* License. When distributing the software, include this License Header
15
* Notice in each file and include the License file at
16
* nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
17
* particular file as subject to the "Classpath" exception as provided
18
* by Sun in the GPL Version 2 section of the License file that
19
* accompanied this code. If applicable, add the following below the
20
* License Header, with the fields enclosed by brackets [] replaced by
21
* your own identifying information:
22
* "Portions Copyrighted [year] [name of copyright owner]"
26
* The Original Software is NetBeans. The Initial Developer of the Original
27
* Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
28
* Microsystems, Inc. All Rights Reserved.
30
* If you wish your version of this file to be governed by only the CDDL
31
* or only the GPL Version 2, indicate your decision by adding
32
* "[Contributor] elects to include this software in this distribution
33
* under the [CDDL or GPL Version 2] license." If you do not indicate a
34
* single choice of license, a recipient has the option to distribute
35
* your version of this file under either the CDDL, the GPL Version 2 or
36
* to extend the choice of license to its licensees as provided above.
37
* However, if you add GPL Version 2 code and therefore, elected the GPL
38
* Version 2 license, then the option applies only if the new code is
39
* made subject to such option by the copyright holder.
42
package org.netbeans.modules.j2ee.clientproject.ui.wizards;
45
import java.text.MessageFormat;
47
import javax.swing.JButton;
48
import javax.swing.event.DocumentEvent;
49
import javax.swing.event.DocumentListener;
51
import org.openide.util.NbBundle;
53
import org.netbeans.spi.project.support.ant.GeneratedFilesHelper;
55
public class ImportBuildfile extends javax.swing.JPanel implements DocumentListener {
56
private static final long serialVersionUID = 1L;
59
private String filePath;
61
/** Creates new form ImportBuildfile */
62
public ImportBuildfile(String filePath, JButton okButton) {
64
this.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(ImportBuildfile.class, "ACS_IW_BuildFileDialog_A11YDesc")); // NOI18N
67
this.filePath = filePath;
70
String fileName = filePath + File.separator + GeneratedFilesHelper.BUILD_XML_PATH;
71
String msg = MessageFormat.format(
72
NbBundle.getMessage(ImportBuildfile.class, "LBL_IW_BuildfileDesc_Label"),
74
jLabelDesc.setText(msg);
75
jTextFieldBuildName.getDocument().addDocumentListener(this);
76
jTextFieldBuildName.setText(NbBundle.getMessage(ImportBuildfile.class, "LBL_IW_ProposedName_TextField")); //NOI18N
79
/** This method is called from within the constructor to
80
* initialize the form.
81
* WARNING: Do NOT modify this code. The content of this method is
82
* always regenerated by the Form Editor.
84
// <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
85
private void initComponents() {
86
java.awt.GridBagConstraints gridBagConstraints;
88
jLabelDesc = new javax.swing.JLabel();
89
jLabelBuildName = new javax.swing.JLabel();
90
jTextFieldBuildName = new javax.swing.JTextField();
91
jLabelCreatedFile = new javax.swing.JLabel();
92
jTextFieldCreatedFile = new javax.swing.JTextField();
94
setLayout(new java.awt.GridBagLayout());
96
gridBagConstraints = new java.awt.GridBagConstraints();
97
gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
98
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
99
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
100
gridBagConstraints.insets = new java.awt.Insets(12, 12, 11, 11);
101
add(jLabelDesc, gridBagConstraints);
103
jLabelBuildName.setDisplayedMnemonic(org.openide.util.NbBundle.getMessage(ImportBuildfile.class, "LBL_IW_BuildFilename_LabelMnemonic").charAt(0));
104
jLabelBuildName.setLabelFor(jTextFieldBuildName);
105
jLabelBuildName.setText(NbBundle.getMessage(ImportBuildfile.class, "LBL_IW_BuildFilename_Label"));
106
gridBagConstraints = new java.awt.GridBagConstraints();
107
gridBagConstraints.gridx = 0;
108
gridBagConstraints.gridy = 1;
109
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
110
gridBagConstraints.insets = new java.awt.Insets(0, 12, 11, 11);
111
add(jLabelBuildName, gridBagConstraints);
113
gridBagConstraints = new java.awt.GridBagConstraints();
114
gridBagConstraints.gridx = 1;
115
gridBagConstraints.gridy = 1;
116
gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
117
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
118
gridBagConstraints.weightx = 1.0;
119
gridBagConstraints.insets = new java.awt.Insets(0, 0, 11, 11);
120
add(jTextFieldBuildName, gridBagConstraints);
121
jTextFieldBuildName.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(ImportBuildfile.class, "ACS_LBL_IW_BuildFilename_A11YDesc"));
123
jLabelCreatedFile.setDisplayedMnemonic(org.openide.util.NbBundle.getMessage(ImportBuildfile.class, "LBL_IW_CreatedFile_LabelMnemonic").charAt(0));
124
jLabelCreatedFile.setLabelFor(jTextFieldCreatedFile);
125
jLabelCreatedFile.setText(NbBundle.getMessage(ImportBuildfile.class, "LBL_IW_CreatedFile_Label"));
126
gridBagConstraints = new java.awt.GridBagConstraints();
127
gridBagConstraints.gridx = 0;
128
gridBagConstraints.gridy = 2;
129
gridBagConstraints.gridheight = java.awt.GridBagConstraints.REMAINDER;
130
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
131
gridBagConstraints.weighty = 1.0;
132
gridBagConstraints.insets = new java.awt.Insets(0, 12, 11, 11);
133
add(jLabelCreatedFile, gridBagConstraints);
135
jTextFieldCreatedFile.setEditable(false);
136
gridBagConstraints = new java.awt.GridBagConstraints();
137
gridBagConstraints.gridx = 1;
138
gridBagConstraints.gridy = 2;
139
gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
140
gridBagConstraints.gridheight = java.awt.GridBagConstraints.REMAINDER;
141
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
142
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTH;
143
gridBagConstraints.weighty = 1.0;
144
gridBagConstraints.insets = new java.awt.Insets(0, 0, 11, 11);
145
add(jTextFieldCreatedFile, gridBagConstraints);
146
jTextFieldCreatedFile.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(ImportBuildfile.class, "ACS_LBL_IW_CreatedFile_A11YDesc"));
148
}// </editor-fold>//GEN-END:initComponents
150
// Variables declaration - do not modify//GEN-BEGIN:variables
151
private javax.swing.JLabel jLabelBuildName;
152
private javax.swing.JLabel jLabelCreatedFile;
153
private javax.swing.JLabel jLabelDesc;
154
private javax.swing.JTextField jTextFieldBuildName;
155
private javax.swing.JTextField jTextFieldCreatedFile;
156
// End of variables declaration//GEN-END:variables
158
protected String getBuildName() {
159
return jTextFieldBuildName.getText().trim();
162
// Implementation of DocumentListener --------------------------------------
163
public void changedUpdate(DocumentEvent e) {
167
public void insertUpdate(DocumentEvent e) {
171
public void removeUpdate(DocumentEvent e) {
174
// End if implementation of DocumentListener -------------------------------
176
private void updateButton() {
177
jTextFieldCreatedFile.setText(filePath + File.separator + jTextFieldBuildName.getText());
179
if (jTextFieldBuildName.getText().trim().length() == 0 || jTextFieldBuildName.getText().trim().equals(GeneratedFilesHelper.BUILD_XML_PATH)) {
180
ok.setEnabled(false);