KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > j2ee > earproject > ui > customizer > CustomizerGeneral


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.earproject.ui.customizer;
21
22 import java.io.File JavaDoc;
23 import java.util.ArrayList JavaDoc;
24 import java.util.Iterator JavaDoc;
25 import java.util.List JavaDoc;
26 import javax.swing.DefaultListModel JavaDoc;
27 import javax.swing.JPanel JavaDoc;
28 import org.netbeans.api.java.platform.JavaPlatform;
29 import org.netbeans.api.java.platform.JavaPlatformManager;
30 import org.netbeans.api.java.platform.PlatformsCustomizer;
31 import org.netbeans.api.java.platform.Specification;
32 import org.openide.filesystems.FileObject;
33 import org.openide.filesystems.FileUtil;
34 import org.openide.util.HelpCtx;
35 import org.openide.util.NbBundle;
36
37 /**
38  * Customizer for general project attributes.
39  *
40  * @author phrebejk
41  */

42 public class CustomizerGeneral extends JPanel JavaDoc implements ArchiveCustomizerPanel, HelpCtx.Provider {
43     
44     private EarProjectProperties projProperties;
45     private VisualPropertySupport vps;
46
47     /** Whether this panel was already initialized. */
48     private boolean initialized;
49     
50     /** Creates new form CustomizerCompile */
51     public CustomizerGeneral(EarProjectProperties projProperties) {
52         initComponents();
53         this.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(CustomizerGeneral.class, "ACS_CustomizeGeneral_A11YDesc")); //NOI18N
54
jButton1.setVisible(false);
55         jComboBoxTarget.setVisible(false);
56         jLabelTarget.setVisible(false);
57         this.projProperties = projProperties;
58         vps = new VisualPropertySupport(projProperties);
59     }
60     
61     public void initValues() {
62         if (initialized) {
63             return;
64         }
65         FileObject projectFolder = projProperties.getProject().getProjectDirectory();
66         File JavaDoc pf = FileUtil.toFile(projectFolder);
67         jTextFieldProjectFolder.setText(pf == null ? "" : pf.getPath()); // NOI18N
68

69         //vps.register(jCheckBoxReqPrj, EarProjectProperties.NO_DEPENDENCIES);
70

71         //jTextFieldJ2EE.setText((String) projProperties.get(EarProjectProperties.J2EE_PLATFORM));
72
initPlatforms(vps);
73         
74         // XXX Listen to adding Projects artifacts
75
DefaultListModel JavaDoc lm = new DefaultListModel JavaDoc();
76         for( Iterator JavaDoc it = projProperties.getSortedSubprojectsList().iterator(); it.hasNext(); ) {
77             lm.addElement( it.next() );
78         }
79         initialized = true;
80         //jListSubprojects.setModel( lm );
81
}
82         
83     private void initPlatforms(VisualPropertySupport vps) {
84         // Read defined platforms
85
JavaPlatform[] platforms = JavaPlatformManager.getDefault().getInstalledPlatforms();
86         List JavaDoc<String JavaDoc> platformNames = new ArrayList JavaDoc<String JavaDoc>();
87         for( int i = 0; i < platforms.length; i++ ) {
88             Specification spec = platforms[i].getSpecification();
89             if ("j2se".equalsIgnoreCase (spec.getName())) { // NOI18N
90
platformNames.add(platforms[i].getDisplayName());
91             }
92         }
93         vps.register(jComboBoxTarget, platformNames.toArray(
94                 new String JavaDoc[platformNames.size()]), EarProjectProperties.JAVA_PLATFORM);
95     }
96     
97     
98     /** This method is called from within the constructor to
99      * initialize the form.
100      * WARNING: Do NOT modify this code. The content of this method is
101      * always regenerated by the Form Editor.
102      */

103     private void initComponents() {//GEN-BEGIN:initComponents
104
java.awt.GridBagConstraints JavaDoc gridBagConstraints;
105
106         jLabelProjectName = new javax.swing.JLabel JavaDoc();
107         jTextFieldProjectFolder = new javax.swing.JTextField JavaDoc();
108         jLabelTarget = new javax.swing.JLabel JavaDoc();
109         jComboBoxTarget = new javax.swing.JComboBox JavaDoc();
110         jButton1 = new javax.swing.JButton JavaDoc();
111         jPanel1 = new javax.swing.JPanel JavaDoc();
112
113         setLayout(new java.awt.GridBagLayout JavaDoc());
114
115         jLabelProjectName.setDisplayedMnemonic(org.openide.util.NbBundle.getMessage(CustomizerGeneral.class, "LBL_CustomizeGeneral_ProjectFolder_LabelMnemonic").charAt(0));
116         jLabelProjectName.setLabelFor(jTextFieldProjectFolder);
117         jLabelProjectName.setText(org.openide.util.NbBundle.getMessage(CustomizerGeneral.class, "LBL_CustomizeGeneral_ProjectFolder_JLabel"));
118         jLabelProjectName.setVerticalAlignment(javax.swing.SwingConstants.TOP);
119         jLabelProjectName.setAlignmentY(0.0F);
120         jLabelProjectName.setVerticalTextPosition(javax.swing.SwingConstants.TOP);
121         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
122         gridBagConstraints.gridx = 0;
123         gridBagConstraints.gridy = 0;
124         gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
125         gridBagConstraints.insets = new java.awt.Insets JavaDoc(12, 12, 12, 12);
126         add(jLabelProjectName, gridBagConstraints);
127
128         jTextFieldProjectFolder.setEditable(false);
129         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
130         gridBagConstraints.gridx = 1;
131         gridBagConstraints.gridy = 0;
132         gridBagConstraints.gridwidth = 2;
133         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
134         gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
135         gridBagConstraints.insets = new java.awt.Insets JavaDoc(12, 0, 12, 12);
136         add(jTextFieldProjectFolder, gridBagConstraints);
137         jTextFieldProjectFolder.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(CustomizerGeneral.class, "ACS_CustomizeGeneral_ProjectFolder_A11YDesc"));
138
139         jLabelTarget.setDisplayedMnemonic(org.openide.util.NbBundle.getMessage(CustomizerGeneral.class, "LBL_CustomizeGeneral_Platform_LabelMnemonic").charAt(0));
140         jLabelTarget.setLabelFor(jComboBoxTarget);
141         jLabelTarget.setText(org.openide.util.NbBundle.getMessage(CustomizerGeneral.class, "LBL_CustomizeGeneral_Platform_JLabel"));
142         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
143         gridBagConstraints.gridx = 0;
144         gridBagConstraints.gridy = 1;
145         gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
146         gridBagConstraints.insets = new java.awt.Insets JavaDoc(0, 12, 12, 12);
147         add(jLabelTarget, gridBagConstraints);
148
149         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
150         gridBagConstraints.gridx = 1;
151         gridBagConstraints.gridy = 1;
152         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
153         gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
154         gridBagConstraints.weightx = 1.0;
155         gridBagConstraints.insets = new java.awt.Insets JavaDoc(0, 0, 12, 0);
156         add(jComboBoxTarget, gridBagConstraints);
157         jComboBoxTarget.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(CustomizerGeneral.class, "ACS_CustomizeGeneral_Platform_A11YDesc"));
158
159         jButton1.setMnemonic(org.openide.util.NbBundle.getMessage(CustomizerGeneral.class, "LBL_CustomizeGeneral_PlatformEdit_LabelMnemonic").charAt(0));
160         jButton1.setText(org.openide.util.NbBundle.getMessage(CustomizerGeneral.class, "LBL_CustomizeGeneral_Platform_JButton"));
161         jButton1.addActionListener(new java.awt.event.ActionListener JavaDoc() {
162             public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt) {
163                 createNewPlatform(evt);
164             }
165         });
166
167         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
168         gridBagConstraints.gridx = 2;
169         gridBagConstraints.gridy = 1;
170         gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
171         gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHEAST;
172         gridBagConstraints.insets = new java.awt.Insets JavaDoc(0, 6, 12, 12);
173         add(jButton1, gridBagConstraints);
174         jButton1.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(CustomizerGeneral.class, "ACS_CustomizeGeneral_PlatformEdit_A11YDesc"));
175
176         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
177         gridBagConstraints.gridx = 0;
178         gridBagConstraints.gridy = 2;
179         gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
180         gridBagConstraints.gridheight = java.awt.GridBagConstraints.REMAINDER;
181         gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
182         gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
183         gridBagConstraints.weightx = 1.0;
184         gridBagConstraints.weighty = 1.0;
185         add(jPanel1, gridBagConstraints);
186
187     }//GEN-END:initComponents
188

189     private void createNewPlatform(java.awt.event.ActionEvent JavaDoc evt) {//GEN-FIRST:event_createNewPlatform
190
PlatformsCustomizer.showCustomizer(null);
191         initPlatforms (vps);
192     }//GEN-LAST:event_createNewPlatform
193

194     // Variables declaration - do not modify//GEN-BEGIN:variables
195
private javax.swing.JButton JavaDoc jButton1;
196     private javax.swing.JComboBox JavaDoc jComboBoxTarget;
197     private javax.swing.JLabel JavaDoc jLabelProjectName;
198     private javax.swing.JLabel JavaDoc jLabelTarget;
199     private javax.swing.JPanel JavaDoc jPanel1;
200     private javax.swing.JTextField JavaDoc jTextFieldProjectFolder;
201     // End of variables declaration//GEN-END:variables
202

203     /** Help context where to find more about the paste type action.
204      * @return the help context for this action
205      */

206     public HelpCtx getHelpCtx() {
207         return new HelpCtx(this.getClass());
208     }
209
210 }
211
Popular Tags