KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > j2ee > ejbcore > ejb > wizard > dd > EjbJarXmlVisualPanel1


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.ejb.wizard.dd;
21
22 import java.awt.Component JavaDoc;
23 import java.awt.event.ActionEvent JavaDoc;
24 import java.awt.event.ActionListener JavaDoc;
25 import java.io.File JavaDoc;
26 import javax.swing.DefaultListCellRenderer JavaDoc;
27 import javax.swing.JList JavaDoc;
28 import javax.swing.JPanel JavaDoc;
29 import org.netbeans.api.project.Project;
30 import org.netbeans.api.project.ProjectUtils;
31 import org.netbeans.modules.j2ee.api.ejbjar.EjbJar;
32 import org.openide.filesystems.FileObject;
33 import org.openide.filesystems.FileUtil;
34 import org.openide.util.NbBundle;
35
36 /**
37  *
38  * @author Martin Adamek
39  */

40 public final class EjbJarXmlVisualPanel1 extends JPanel JavaDoc {
41
42     // generated by apisupport wizard
43

44     private Project project;
45     
46     public EjbJarXmlVisualPanel1() {
47         initComponents();
48         locationCombo.setRenderer(new FileObjectListCellRenderer());
49     }
50
51     void setProject(Project project) {
52         this.project = project;
53         EjbJar[] apiEjbJars = EjbJar.getEjbJars(project);
54         // initialize visual components
55
fileNameText.setText("ejb-jar.xml"); // NOI18N
56
projectText.setText(ProjectUtils.getInformation(project).getDisplayName());
57         for (int i = 0; i < apiEjbJars.length; i++) {
58             if (apiEjbJars[i].getDeploymentDescriptor() == null) {
59                 locationCombo.addItem(apiEjbJars[i].getMetaInf());
60             }
61         }
62         refreshLocation();
63         locationCombo.addActionListener(new ActionListener JavaDoc() {
64             public void actionPerformed(ActionEvent JavaDoc actionEvent) {
65                 refreshLocation();
66             }
67         });
68     }
69     
70     FileObject getSelectedLocation() {
71         return (FileObject) locationCombo.getSelectedItem();
72     }
73     
74     @Override JavaDoc
75     public String JavaDoc getName() {
76         return NbBundle.getMessage(EjbJarXmlVisualPanel1.class, "LBL_SelectLocation");
77     }
78     
79     private void refreshLocation() {
80         FileObject fileObject = (FileObject) locationCombo.getSelectedItem();
81         if (fileObject != null) {
82             createdFileText.setText(FileUtil.getFileDisplayName(fileObject) + File.separator + "ejb-jar.xml");
83         }
84         firePropertyChange("", null, null);
85     }
86     
87     private class FileObjectListCellRenderer extends DefaultListCellRenderer JavaDoc {
88         public Component JavaDoc getListCellRendererComponent(JList JavaDoc list, Object JavaDoc value, int index, boolean isSelected, boolean cellHasFocus) {
89             if (value instanceof FileObject) {
90                 FileObject fileObject = (FileObject) value;
91                 setText(FileUtil.getFileDisplayName(fileObject));
92             }
93             return this;
94         }
95     }
96     
97     /** This method is called from within the constructor to
98      * initialize the form.
99      * WARNING: Do NOT modify this code. The content of this method is
100      * always regenerated by the Form Editor.
101      */

102     // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
103
private void initComponents() {
104         jLabel1 = new javax.swing.JLabel JavaDoc();
105         jLabel2 = new javax.swing.JLabel JavaDoc();
106         jLabel3 = new javax.swing.JLabel JavaDoc();
107         jLabel4 = new javax.swing.JLabel JavaDoc();
108         createdFileText = new javax.swing.JTextField JavaDoc();
109         projectText = new javax.swing.JTextField JavaDoc();
110         fileNameText = new javax.swing.JTextField JavaDoc();
111         locationCombo = new javax.swing.JComboBox JavaDoc();
112
113         org.openide.awt.Mnemonics.setLocalizedText(jLabel1, org.openide.util.NbBundle.getMessage(EjbJarXmlVisualPanel1.class, "LBL_Name"));
114
115         org.openide.awt.Mnemonics.setLocalizedText(jLabel2, org.openide.util.NbBundle.getMessage(EjbJarXmlVisualPanel1.class, "LBL_Project"));
116
117         org.openide.awt.Mnemonics.setLocalizedText(jLabel3, org.openide.util.NbBundle.getMessage(EjbJarXmlVisualPanel1.class, "LBL_Location"));
118
119         org.openide.awt.Mnemonics.setLocalizedText(jLabel4, org.openide.util.NbBundle.getMessage(EjbJarXmlVisualPanel1.class, "LBL_CreatedFile"));
120
121         createdFileText.setEditable(false);
122
123         projectText.setEditable(false);
124
125         fileNameText.setEditable(false);
126
127         org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this);
128         this.setLayout(layout);
129         layout.setHorizontalGroup(
130             layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
131             .add(layout.createSequentialGroup()
132                 .addContainerGap()
133                 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
134                     .add(jLabel4)
135                     .add(jLabel2)
136                     .add(jLabel1)
137                     .add(jLabel3))
138                 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
139                 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
140                     .add(projectText, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 287, Short.MAX_VALUE)
141                     .add(createdFileText, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 287, Short.MAX_VALUE)
142                     .add(fileNameText, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 287, Short.MAX_VALUE)
143                     .add(locationCombo, 0, 287, Short.MAX_VALUE))
144                 .addContainerGap())
145         );
146         layout.setVerticalGroup(
147             layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
148             .add(layout.createSequentialGroup()
149                 .addContainerGap()
150                 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
151                     .add(jLabel1)
152                     .add(fileNameText, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
153                 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
154                 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
155                     .add(jLabel2)
156                     .add(projectText, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
157                 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
158                 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
159                     .add(jLabel3)
160                     .add(locationCombo, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
161                 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
162                 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
163                     .add(jLabel4)
164                     .add(createdFileText, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
165                 .addContainerGap(189, Short.MAX_VALUE))
166         );
167     }// </editor-fold>//GEN-END:initComponents
168

169     
170     // Variables declaration - do not modify//GEN-BEGIN:variables
171
private javax.swing.JTextField JavaDoc createdFileText;
172     private javax.swing.JTextField JavaDoc fileNameText;
173     private javax.swing.JLabel JavaDoc jLabel1;
174     private javax.swing.JLabel JavaDoc jLabel2;
175     private javax.swing.JLabel JavaDoc jLabel3;
176     private javax.swing.JLabel JavaDoc jLabel4;
177     private javax.swing.JComboBox JavaDoc locationCombo;
178     private javax.swing.JTextField JavaDoc projectText;
179     // End of variables declaration//GEN-END:variables
180

181 }
182
183
Popular Tags