1 19 package org.netbeans.modules.j2ee.websphere6.dd.loaders.ui; 20 21 import java.awt.event.ActionEvent ; 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 34 public class WSMarkupLanguagesPanel extends SectionInnerPanel implements java.awt.event.ItemListener { 35 36 37 ExtendedServletsType extendedServlet; 38 MarkupLanguagesType markupLanguage; 39 WSWebExtDataObject dObj; 40 javax.swing.JTabbedPane markupLanguagesTabPanel; 41 42 43 public WSMarkupLanguagesPanel(SectionView view, final WSWebExtDataObject dObj, final MarkupLanguagesType markupLanguage,final ExtendedServletsType extendedServlet,final javax.swing.JTabbedPane 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 (MarkupLanguagesType.AVALIABLE_NAMES)); 51 mimeTypeComboBox.setModel(new javax.swing.DefaultComboBoxModel (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 gridBagConstraints = new java.awt.GridBagConstraints (); 69 gridBagConstraints.gridx = 0; 70 gridBagConstraints.gridy = 10; 71 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 73 gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; 74 gridBagConstraints.insets = new java.awt.Insets (5, 10, 0, 0); 75 gridBagConstraints.weightx = 1.0; 76 pagesContainerPanel.add(ptp,gridBagConstraints); 77 deleteButton.addActionListener(new java.awt.event.ActionListener () { 78 public void actionPerformed(ActionEvent 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 [] pagesNames=new String [pagesNumber]; 95 for(int i=0;i<pagesNumber;i++) { 96 pagesNames[i]=markupLanguage.getPages(i).getXmiId(); 97 } 98 javax.swing.DefaultComboBoxModel modelError=new javax.swing.DefaultComboBoxModel (pagesNames); 99 errorPageComboBox.setModel(modelError); 100 errorPageComboBox.setSelectedItem(markupLanguage.getErrorPage()); 101 102 javax.swing.DefaultComboBoxModel modelDefault=new javax.swing.DefaultComboBoxModel (pagesNames); 103 defaultPageComboBox.setModel(modelDefault); 104 defaultPageComboBox.setSelectedItem(markupLanguage.getDefaultPage()); 105 } 106 } 107 108 public void setValue(javax.swing.JComponent source, Object value) { 109 if (source==idField) { 110 markupLanguage.setXmiId(idField.getText().trim()); 111 } 112 } 113 114 public void linkButtonPressed(Object ddBean, String ddProperty) { 115 } 116 117 public void documentChanged(javax.swing.text.JTextComponent comp, String value) { 118 if (comp==idField) { 119 String val = (String )value; 120 if (val.length()==0) { 121 getSectionView() 122 .getErrorPanel() 123 .setError(new Error (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 source) { 132 if (idField==source) { 133 idField.setText(markupLanguage.getXmiId()); 134 } 135 } 136 140 141 public javax.swing.JComponent getErrorComponent(String errorId) { 142 if ("ID".equals(errorId)) return idField; 143 return null; 144 } 145 public void itemStateChanged(java.awt.event.ItemEvent evt) { 146 dObj.setChangedFromUI(true); 147 if(evt.getSource()==nameComboBox) { 148 markupLanguage.setName((String )nameComboBox.getSelectedItem()); 149 150 } else if(evt.getSource()==mimeTypeComboBox) { 151 markupLanguage.setMimeType((String )mimeTypeComboBox.getSelectedItem()); 152 } else if(evt.getSource()==errorPageComboBox) { 153 markupLanguage.setErrorPage((String )errorPageComboBox.getSelectedItem()); 154 } else if(evt.getSource()==defaultPageComboBox) { 155 markupLanguage.setDefaultPage((String )defaultPageComboBox.getSelectedItem()); 156 } 157 dObj.modelUpdatedFromUI(); 159 dObj.setChangedFromUI(false); 161 } 162 163 165 protected void startUIChange() { 166 dObj.setChangedFromUI(true); 167 } 168 169 171 protected void endUIChange() { 172 dObj.modelUpdatedFromUI(); 173 dObj.setChangedFromUI(false); 174 } 175 176 177 182 private void initComponents() { 184 jLabel1 = new javax.swing.JLabel (); 185 idField = new javax.swing.JTextField (); 186 jLabel2 = new javax.swing.JLabel (); 187 jLabel4 = new javax.swing.JLabel (); 188 mimeTypeComboBox = new javax.swing.JComboBox (); 189 errorPageComboBox = new javax.swing.JComboBox (); 190 nameComboBox = new javax.swing.JComboBox (); 191 jLabel3 = new javax.swing.JLabel (); 192 jLabel6 = new javax.swing.JLabel (); 193 defaultPageComboBox = new javax.swing.JComboBox (); 194 pagesContainerPanel = new javax.swing.JPanel (); 195 deleteButton = new javax.swing.JButton (); 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 () { 208 public void actionPerformed(java.awt.event.ActionEvent evt) { 209 defaultPageComboBoxActionPerformed(evt); 210 } 211 }); 212 213 pagesContainerPanel.setLayout(new java.awt.GridBagLayout ()); 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 } 277 private void defaultPageComboBoxActionPerformed(java.awt.event.ActionEvent evt) { } 280 281 private javax.swing.JComboBox defaultPageComboBox; 283 private javax.swing.JButton deleteButton; 284 private javax.swing.JComboBox errorPageComboBox; 285 private javax.swing.JTextField idField; 286 private javax.swing.JLabel jLabel1; 287 private javax.swing.JLabel jLabel2; 288 private javax.swing.JLabel jLabel3; 289 private javax.swing.JLabel jLabel4; 290 private javax.swing.JLabel jLabel6; 291 private javax.swing.JComboBox mimeTypeComboBox; 292 private javax.swing.JComboBox nameComboBox; 293 private javax.swing.JPanel pagesContainerPanel; 294 296 } 297 | Popular Tags |