KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > j2ee > archive > customizer > CustomizerRun


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.archive.customizer;
21
22 import java.util.ArrayList JavaDoc;
23 import javax.swing.JPanel JavaDoc;
24 import org.netbeans.modules.j2ee.archive.project.ArchiveProjectProperties;
25 import org.netbeans.modules.j2ee.deployment.devmodules.api.Deployment;
26 import org.netbeans.modules.j2ee.deployment.devmodules.api.J2eeModule;
27 import org.netbeans.modules.j2ee.deployment.devmodules.api.J2eePlatform;
28 import org.openide.util.HelpCtx;
29 import org.openide.util.NbBundle;
30
31 public final class CustomizerRun extends JPanel JavaDoc implements ArchiveCustomizerPanel, HelpCtx.Provider {
32     
33     // Helper for storing properties
34
private transient final VisualPropertySupport vps;
35     
36     private String JavaDoc[] serverInstanceIDs;
37     private String JavaDoc[] serverNames;
38     boolean initialized = false;
39     
40         
41     public CustomizerRun(final ArchiveProjectProperties apProperties) {
42         initComponents();
43         this.getAccessibleContext().setAccessibleDescription(
44                 NbBundle.getMessage(CustomizerRun.class, "ACS_CustomizeRun_A11YDesc")); // NOI18N
45
vps = new VisualPropertySupport(apProperties);
46     }
47     
48     
49     public void initValues() {
50         initialized = false;
51         initServerInstances();
52         
53         vps.register(jComboBoxServer, serverNames, serverInstanceIDs, ArchiveProjectProperties.J2EE_SERVER_INSTANCE);
54         
55         initialized = true;
56     }
57     
58     
59         
60     /** This method is called from within the constructor to
61      * initialize the form.
62      * WARNING: Do NOT modify this code. The content of this method is
63      * always regenerated by the Form Editor.
64      */

65     // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
66
private void initComponents() {
67         java.awt.GridBagConstraints JavaDoc gridBagConstraints;
68
69         jLabelServer = new javax.swing.JLabel JavaDoc();
70         jComboBoxServer = new javax.swing.JComboBox JavaDoc();
71         filler = new javax.swing.JLabel JavaDoc();
72
73         jLabelServer.setDisplayedMnemonic(java.util.ResourceBundle.getBundle("org/netbeans/modules/j2ee/archive/customizer/Bundle").getString("MNM_Server_Label").charAt(0));
74         jLabelServer.setLabelFor(jComboBoxServer);
75         org.openide.awt.Mnemonics.setLocalizedText(jLabelServer, NbBundle.getMessage(CustomizerRun.class, "LBL_CustomizeRun_Server_JLabel"));
76
77         jComboBoxServer.addActionListener(new java.awt.event.ActionListener JavaDoc() {
78             public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt) {
79                 jComboBoxServerActionPerformed(evt);
80             }
81         });
82
83         jComboBoxServer.getAccessibleContext().setAccessibleDescription(java.util.ResourceBundle.getBundle("org/netbeans/modules/j2ee/archive/customizer/Bundle").getString("ACS_CustomizeRun_Server_A11YDesc"));
84
85         org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this);
86         this.setLayout(layout);
87         layout.setHorizontalGroup(
88             layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
89             .add(layout.createSequentialGroup()
90                 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
91                     .add(filler)
92                     .add(layout.createSequentialGroup()
93                         .add(jLabelServer)
94                         .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
95                         .add(jComboBoxServer, 0, 203, Short.MAX_VALUE)))
96                 .addContainerGap())
97         );
98         layout.setVerticalGroup(
99             layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
100             .add(layout.createSequentialGroup()
101                 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
102                     .add(filler)
103                     .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
104                         .add(jLabelServer)
105                         .add(jComboBoxServer, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
106                 .add(21, 21, 21))
107         );
108     }// </editor-fold>//GEN-END:initComponents
109

110     private void jComboBoxServerActionPerformed(java.awt.event.ActionEvent JavaDoc evt) {//GEN-FIRST:event_jComboBoxServerActionPerformed
111

112     }//GEN-LAST:event_jComboBoxServerActionPerformed
113

114     // Variables declaration - do not modify//GEN-BEGIN:variables
115
private javax.swing.JLabel JavaDoc filler;
116     private javax.swing.JComboBox JavaDoc jComboBoxServer;
117     private javax.swing.JLabel JavaDoc jLabelServer;
118     // End of variables declaration//GEN-END:variables
119

120     /** Help context where to find more about the paste type action.
121      * @return the help context for this action
122      */

123     public HelpCtx getHelpCtx() {
124         return new HelpCtx(CustomizerRun.class);
125     }
126     
127     private void initServerInstances() {
128         String JavaDoc[] servInstIDs = Deployment.getDefault().getServerInstanceIDs();
129         java.util.List JavaDoc servInstIDsList = new ArrayList JavaDoc();
130         java.util.List JavaDoc servNamesList = new ArrayList JavaDoc();
131         Deployment deployment = Deployment.getDefault();
132         for (int i = 0; i < servInstIDs.length; i++) {
133             String JavaDoc instanceID = servInstIDs[i];
134             J2eePlatform j2eePlat = deployment.getJ2eePlatform(instanceID);
135             String JavaDoc servInstDisplayName = Deployment.getDefault().getServerInstanceDisplayName(servInstIDs[i]);
136             if (servInstDisplayName != null
137                     && j2eePlat != null
138                     && j2eePlat.getSupportedModuleTypes().contains(J2eeModule.WAR))
139                    /* && j2eePlat.getSupportedSpecVersions().contains(J2eeModule.JAVA_EE_50)) */{ //see #74597
140
servInstIDsList.add(instanceID);
141                 servNamesList.add(servInstDisplayName);
142             }
143         }
144         serverInstanceIDs = (String JavaDoc[]) servInstIDsList.toArray(new String JavaDoc[servInstIDsList.size()]);
145         serverNames = (String JavaDoc[]) servNamesList.toArray(new String JavaDoc[servNamesList.size()]);
146     }
147     
148 }
149
Popular Tags