1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 /*
23  * ParcelPropertiesVisualPanel.java
24  *
25  * Created on January 15, 2003
26  */
27 
28 package org.openoffice.netbeans.modules.office.wizard;
29 
30 import org.openide.util.NbBundle;
31 
32 /** A single panel for a wizard - the GUI portion.
33  *
34  * @author tomaso
35  */
36 public class ParcelPropertiesVisualPanel extends javax.swing.JPanel {
37 
38     /** The wizard panel descriptor associated with this GUI panel.
39      * If you need to fire state changes or something similar, you can
40      * use this handle to do so.
41      */
42     private final ParcelPropertiesPanel panel;
43 
44     /** Create the wizard panel and set up some basic properties. */
ParcelPropertiesVisualPanel(ParcelPropertiesPanel panel)45     public ParcelPropertiesVisualPanel(ParcelPropertiesPanel panel) {
46         this.panel = panel;
47         initComponents();
48 
49         languagesComboBox.addItem("Java");
50         languagesComboBox.addItem("BeanShell");
51 
52         // Provide a name in the title bar.
53         setName(NbBundle.getMessage(ParcelPropertiesVisualPanel.class, "TITLE_ParcelPropertiesVisualPanel"));
54         /*
55         // Optional: provide a special description for this pane.
56         // You must have turned on WizardDescriptor.WizardPanel_helpDisplayed
57         // (see descriptor in standard iterator template for an example of this).
58         try {
59             putClientProperty("WizardPanel_helpURL", // NOI18N
60                 new URL("nbresloc:/org/openoffice/netbeans/modules/office/wizard/ParcelPropertiesVisualHelp.html")); // NOI18N
61         } catch (MalformedURLException mfue) {
62             throw new IllegalStateException(mfue.toString());
63         }
64          */
65     }
66 
67     /** This method is called from within the constructor to
68      * initialize the form.
69      * WARNING: Do NOT modify this code. The content of this method is
70      * always regenerated by the Form Editor.
71      */
initComponents()72     private void initComponents() {//GEN-BEGIN:initComponents
73         java.awt.GridBagConstraints gridBagConstraints;
74 
75         jLabel1 = new javax.swing.JLabel();
76         recipeName = new javax.swing.JTextField();
77         jLabel2 = new javax.swing.JLabel();
78         languagesComboBox = new javax.swing.JComboBox();
79         jPanel1 = new javax.swing.JPanel();
80 
81         setLayout(new java.awt.GridBagLayout());
82 
83         setPreferredSize(new java.awt.Dimension(500, 300));
84         jLabel1.setText("Parcel Recipe Name");
85         gridBagConstraints = new java.awt.GridBagConstraints();
86         gridBagConstraints.gridx = 0;
87         gridBagConstraints.gridy = 0;
88         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
89         gridBagConstraints.insets = new java.awt.Insets(12, 12, 11, 2);
90         add(jLabel1, gridBagConstraints);
91 
92         recipeName.addActionListener(new java.awt.event.ActionListener() {
93             public void actionPerformed(java.awt.event.ActionEvent evt) {
94                 recipeNameActionPerformed(evt);
95             }
96         });
97 
98         recipeName.addFocusListener(new java.awt.event.FocusAdapter() {
99             public void focusGained(java.awt.event.FocusEvent evt) {
100                 recipeNameFocusGained(evt);
101             }
102             public void focusLost(java.awt.event.FocusEvent evt) {
103                 recipeNameFocusLost(evt);
104             }
105         });
106 
107         gridBagConstraints = new java.awt.GridBagConstraints();
108         gridBagConstraints.gridx = 1;
109         gridBagConstraints.gridy = 0;
110         gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
111         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
112         gridBagConstraints.weightx = 1.0;
113         gridBagConstraints.insets = new java.awt.Insets(12, 0, 11, 11);
114         add(recipeName, gridBagConstraints);
115 
116         jLabel2.setText("Initial Script Language");
117         gridBagConstraints = new java.awt.GridBagConstraints();
118         gridBagConstraints.gridx = 0;
119         gridBagConstraints.gridy = 1;
120         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
121         gridBagConstraints.insets = new java.awt.Insets(0, 12, 11, 12);
122         add(jLabel2, gridBagConstraints);
123 
124         languagesComboBox.addActionListener(new java.awt.event.ActionListener() {
125             public void actionPerformed(java.awt.event.ActionEvent evt) {
126                 languagesComboBoxActionPerformed(evt);
127             }
128         });
129 
130         gridBagConstraints = new java.awt.GridBagConstraints();
131         gridBagConstraints.gridx = 1;
132         gridBagConstraints.gridy = 1;
133         gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
134         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
135         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
136         gridBagConstraints.insets = new java.awt.Insets(0, 0, 11, 11);
137         add(languagesComboBox, gridBagConstraints);
138 
139         gridBagConstraints = new java.awt.GridBagConstraints();
140         gridBagConstraints.fill = java.awt.GridBagConstraints.VERTICAL;
141         gridBagConstraints.weighty = 1.0;
142         add(jPanel1, gridBagConstraints);
143 
144     }//GEN-END:initComponents
145 
recipeNameFocusGained(java.awt.event.FocusEvent evt)146     private void recipeNameFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_recipeNameFocusGained
147         recipeName.selectAll();
148     }//GEN-LAST:event_recipeNameFocusGained
149 
recipeNameFocusLost(java.awt.event.FocusEvent evt)150     private void recipeNameFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_recipeNameFocusLost
151         changeName();
152     }//GEN-LAST:event_recipeNameFocusLost
153 
languagesComboBoxActionPerformed(java.awt.event.ActionEvent evt)154     private void languagesComboBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_languagesComboBoxActionPerformed
155         String language = (String)languagesComboBox.getSelectedItem();
156         panel.setLanguage(language);
157     }//GEN-LAST:event_languagesComboBoxActionPerformed
158 
recipeNameActionPerformed(java.awt.event.ActionEvent evt)159     private void recipeNameActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_recipeNameActionPerformed
160         changeName();
161     }//GEN-LAST:event_recipeNameActionPerformed
162 
changeName()163     private void changeName() {
164         String name = recipeName.getText().trim();
165         if (name.equals(""))
166             name = null;
167         panel.setName(name);
168     }
169 
170     // Variables declaration - do not modify//GEN-BEGIN:variables
171     private javax.swing.JTextField recipeName;
172     private javax.swing.JLabel jLabel2;
173     private javax.swing.JLabel jLabel1;
174     private javax.swing.JPanel jPanel1;
175     private javax.swing.JComboBox languagesComboBox;
176     // End of variables declaration//GEN-END:variables
177 
178 }
179