KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > j2ee > websphere6 > dd > loaders > ui > WSMarkupLanguagesPanel


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 package org.netbeans.modules.j2ee.websphere6.dd.loaders.ui;
20
21 import java.awt.event.ActionEvent JavaDoc;
22 import org.netbeans.modules.j2ee.websphere6.dd.beans.ExtendedServletsType;
23 import org.netbeans.modules.j2ee.websphere6.dd.beans.MarkupLanguagesType;
24 import org.netbeans.modules.j2ee.websphere6.dd.beans.PageType;
25 import org.netbeans.modules.j2ee.websphere6.dd.beans.WSWebExt;
26 import org.netbeans.modules.j2ee.websphere6.dd.loaders.webext.WSWebExtDataObject;
27 import org.netbeans.modules.xml.multiview.*;
28 import org.netbeans.modules.xml.multiview.ui.*;
29 import org.netbeans.modules.xml.multiview.Error;
30 /**
31  *
32  * @author dlm198383
33  */

34 public class WSMarkupLanguagesPanel extends SectionInnerPanel implements java.awt.event.ItemListener JavaDoc{
35     
36     
37     ExtendedServletsType extendedServlet;
38     MarkupLanguagesType markupLanguage;
39     WSWebExtDataObject dObj;
40     javax.swing.JTabbedPane JavaDoc markupLanguagesTabPanel;
41     
42     
43     public WSMarkupLanguagesPanel(SectionView view, final WSWebExtDataObject dObj, final MarkupLanguagesType markupLanguage,final ExtendedServletsType extendedServlet,final javax.swing.JTabbedPane JavaDoc markupLanguagesTabPanel) {
44         super(view);
45         this.dObj=dObj;
46         this.markupLanguage=markupLanguage;
47         this.markupLanguagesTabPanel=markupLanguagesTabPanel;
48         this.extendedServlet=extendedServlet;
49         initComponents();
50         nameComboBox.setModel(new javax.swing.DefaultComboBoxModel JavaDoc(MarkupLanguagesType.AVALIABLE_NAMES));
51         mimeTypeComboBox.setModel(new javax.swing.DefaultComboBoxModel JavaDoc(MarkupLanguagesType.AVALIABLE_MIME_TYPES));
52         
53         idField.setText(markupLanguage.getXmiId());
54         nameComboBox.setSelectedItem(markupLanguage.getName());
55         mimeTypeComboBox.setSelectedItem(markupLanguage.getMimeType());
56         
57         addModifier(idField);
58         nameComboBox.addItemListener(this);
59         mimeTypeComboBox.addItemListener(this);
60         errorPageComboBox.addItemListener(this);
61         defaultPageComboBox.addItemListener(this);
62         
63         setComboBoxModels();
64         
65         PageTableModel model = new PageTableModel(dObj.getModelSynchronizer());
66         PagesTablePanel ptp= new PagesTablePanel(dObj, model,errorPageComboBox,defaultPageComboBox);
67         ptp.setModel(markupLanguage,markupLanguage.getPages());
68         java.awt.GridBagConstraints JavaDoc gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
69         gridBagConstraints.gridx = 0;
70         gridBagConstraints.gridy = 10;
71         //gridBagConstraints.gridwidth = 4;
72
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
73         gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
74         gridBagConstraints.insets = new java.awt.Insets JavaDoc(5, 10, 0, 0);
75         gridBagConstraints.weightx = 1.0;
76         pagesContainerPanel.add(ptp,gridBagConstraints);
77         deleteButton.addActionListener(new java.awt.event.ActionListener JavaDoc() {
78             public void actionPerformed(ActionEvent JavaDoc e) {
79         dObj.setChangedFromUI(true);
80                 int selectedTab=markupLanguagesTabPanel.getSelectedIndex();
81                 markupLanguagesTabPanel.removeTabAt(selectedTab);
82                 for(int i=0;i<markupLanguagesTabPanel.getTabCount();i++) {
83                  markupLanguagesTabPanel.setTitleAt(i,""+(i+1));
84                 }
85                 extendedServlet.removeMarkupLanguages(markupLanguage);
86                 dObj.modelUpdatedFromUI();
87                 dObj.setChangedFromUI(false);
88             }
89         });
90     }
91     public void setComboBoxModels() {
92         int pagesNumber=markupLanguage.getPages().length;
93         if(pagesNumber!=0) {
94             String JavaDoc [] pagesNames=new String JavaDoc[pagesNumber];
95             for(int i=0;i<pagesNumber;i++) {
96                 pagesNames[i]=markupLanguage.getPages(i).getXmiId();
97             }
98             javax.swing.DefaultComboBoxModel JavaDoc modelError=new javax.swing.DefaultComboBoxModel JavaDoc(pagesNames);
99             errorPageComboBox.setModel(modelError);
100             errorPageComboBox.setSelectedItem(markupLanguage.getErrorPage());
101             
102             javax.swing.DefaultComboBoxModel JavaDoc modelDefault=new javax.swing.DefaultComboBoxModel JavaDoc(pagesNames);
103             defaultPageComboBox.setModel(modelDefault);
104             defaultPageComboBox.setSelectedItem(markupLanguage.getDefaultPage());
105         }
106     }
107     
108     public void setValue(javax.swing.JComponent JavaDoc source, Object JavaDoc value) {
109         if (source==idField) {
110             markupLanguage.setXmiId(idField.getText().trim());
111         }
112     }
113     
114     public void linkButtonPressed(Object JavaDoc ddBean, String JavaDoc ddProperty) {
115     }
116     
117     public void documentChanged(javax.swing.text.JTextComponent JavaDoc comp, String JavaDoc value) {
118         if (comp==idField) {
119             String JavaDoc val = (String JavaDoc)value;
120             if (val.length()==0) {
121                 getSectionView()
122                 .getErrorPanel()
123                 .setError(new Error JavaDoc(Error.MISSING_VALUE_MESSAGE, "ID", comp));
124                 return;
125             }
126             getSectionView().getErrorPanel().clearError();
127         }
128         
129     }
130     
131     public void rollbackValue(javax.swing.text.JTextComponent JavaDoc source) {
132         if (idField==source) {
133             idField.setText(markupLanguage.getXmiId());
134         }
135     }
136     /*
137     protected void signalUIChange() {
138         dObj.modelUpdatedFromUI();
139     }*/

140     
141     public javax.swing.JComponent JavaDoc getErrorComponent(String JavaDoc errorId) {
142         if ("ID".equals(errorId)) return idField;
143         return null;
144     }
145     public void itemStateChanged(java.awt.event.ItemEvent JavaDoc evt) {
146     dObj.setChangedFromUI(true);
147         if(evt.getSource()==nameComboBox) {
148             markupLanguage.setName((String JavaDoc)nameComboBox.getSelectedItem());
149             
150         } else if(evt.getSource()==mimeTypeComboBox) {
151             markupLanguage.setMimeType((String JavaDoc)mimeTypeComboBox.getSelectedItem());
152         } else if(evt.getSource()==errorPageComboBox) {
153             markupLanguage.setErrorPage((String JavaDoc)errorPageComboBox.getSelectedItem());
154         } else if(evt.getSource()==defaultPageComboBox) {
155             markupLanguage.setDefaultPage((String JavaDoc)defaultPageComboBox.getSelectedItem());
156         }
157         // TODO add your handling code here:
158
dObj.modelUpdatedFromUI();
159         //dObj.setChangedFromUI(true);
160
dObj.setChangedFromUI(false);
161     }
162     
163     /** This will be called before model is changed from this panel
164      */

165     protected void startUIChange() {
166         dObj.setChangedFromUI(true);
167     }
168     
169     /** This will be called after model is changed from this panel
170      */

171     protected void endUIChange() {
172         dObj.modelUpdatedFromUI();
173         dObj.setChangedFromUI(false);
174     }
175     
176     
177     /** This method is called from within the constructor to
178      * initialize the form.
179      * WARNING: Do NOT modify this code. The content of this method is
180      * always regenerated by the Form Editor.
181      */

182     // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
183
private void initComponents() {
184         jLabel1 = new javax.swing.JLabel JavaDoc();
185         idField = new javax.swing.JTextField JavaDoc();
186         jLabel2 = new javax.swing.JLabel JavaDoc();
187         jLabel4 = new javax.swing.JLabel JavaDoc();
188         mimeTypeComboBox = new javax.swing.JComboBox JavaDoc();
189         errorPageComboBox = new javax.swing.JComboBox JavaDoc();
190         nameComboBox = new javax.swing.JComboBox JavaDoc();
191         jLabel3 = new javax.swing.JLabel JavaDoc();
192         jLabel6 = new javax.swing.JLabel JavaDoc();
193         defaultPageComboBox = new javax.swing.JComboBox JavaDoc();
194         pagesContainerPanel = new javax.swing.JPanel JavaDoc();
195         deleteButton = new javax.swing.JButton JavaDoc();
196
197         jLabel1.setText("Name:");
198
199         jLabel2.setText("ID:");
200
201         jLabel4.setText("MIME Type:");
202
203         jLabel3.setText("Error Page:");
204
205         jLabel6.setText("Default Page:");
206
207         defaultPageComboBox.addActionListener(new java.awt.event.ActionListener JavaDoc() {
208             public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt) {
209                 defaultPageComboBoxActionPerformed(evt);
210             }
211         });
212
213         pagesContainerPanel.setLayout(new java.awt.GridBagLayout JavaDoc());
214
215         pagesContainerPanel.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1));
216
217         deleteButton.setText(java.util.ResourceBundle.getBundle("org/netbeans/modules/j2ee/websphere6/dd/loaders/ui/Bundle").getString("LBL_DeleteMarkupLanguage"));
218
219         org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this);
220         this.setLayout(layout);
221         layout.setHorizontalGroup(
222             layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
223             .add(layout.createSequentialGroup()
224                 .addContainerGap()
225                 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
226                     .add(pagesContainerPanel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 459, Short.MAX_VALUE)
227                     .add(layout.createSequentialGroup()
228                         .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
229                             .add(jLabel6)
230                             .add(jLabel4)
231                             .add(jLabel2)
232                             .add(jLabel1)
233                             .add(jLabel3))
234                         .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
235                         .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
236                             .add(idField, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 389, Short.MAX_VALUE)
237                             .add(layout.createSequentialGroup()
238                                 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING, false)
239                                     .add(org.jdesktop.layout.GroupLayout.LEADING, nameComboBox, 0, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
240                                     .add(org.jdesktop.layout.GroupLayout.LEADING, defaultPageComboBox, 0, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
241                                     .add(org.jdesktop.layout.GroupLayout.LEADING, errorPageComboBox, 0, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
242                                     .add(org.jdesktop.layout.GroupLayout.LEADING, mimeTypeComboBox, 0, 112, Short.MAX_VALUE))
243                                 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 102, Short.MAX_VALUE)
244                                 .add(deleteButton)))))
245                 .addContainerGap())
246         );
247         layout.setVerticalGroup(
248             layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
249             .add(layout.createSequentialGroup()
250                 .addContainerGap()
251                 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
252                     .add(jLabel2)
253                     .add(idField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
254                 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
255                 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
256                     .add(jLabel1)
257                     .add(nameComboBox, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
258                     .add(deleteButton))
259                 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
260                 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
261                     .add(jLabel4)
262                     .add(mimeTypeComboBox, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
263                 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
264                 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
265                     .add(jLabel3)
266                     .add(errorPageComboBox, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
267                 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
268                 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
269                     .add(jLabel6)
270                     .add(defaultPageComboBox, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
271                 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
272                 .add(pagesContainerPanel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 84, Short.MAX_VALUE)
273                 .addContainerGap())
274         );
275     }// </editor-fold>//GEN-END:initComponents
276

277     private void defaultPageComboBoxActionPerformed(java.awt.event.ActionEvent JavaDoc evt) {//GEN-FIRST:event_defaultPageComboBoxActionPerformed
278
}//GEN-LAST:event_defaultPageComboBoxActionPerformed
279

280     
281     // Variables declaration - do not modify//GEN-BEGIN:variables
282
private javax.swing.JComboBox JavaDoc defaultPageComboBox;
283     private javax.swing.JButton JavaDoc deleteButton;
284     private javax.swing.JComboBox JavaDoc errorPageComboBox;
285     private javax.swing.JTextField JavaDoc idField;
286     private javax.swing.JLabel JavaDoc jLabel1;
287     private javax.swing.JLabel JavaDoc jLabel2;
288     private javax.swing.JLabel JavaDoc jLabel3;
289     private javax.swing.JLabel JavaDoc jLabel4;
290     private javax.swing.JLabel JavaDoc jLabel6;
291     private javax.swing.JComboBox JavaDoc mimeTypeComboBox;
292     private javax.swing.JComboBox JavaDoc nameComboBox;
293     private javax.swing.JPanel JavaDoc pagesContainerPanel;
294     // End of variables declaration//GEN-END:variables
295

296 }
297
Popular Tags