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