Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
   *
   * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
   *
   * The contents of this file are subject to the terms of either the GNU
   * General Public License Version 2 only ("GPL") or the Common
   * Development and Distribution License("CDDL") (collectively, the
   * "License"). You may not use this file except in compliance with the
  * License. You can obtain a copy of the License at
  * http://www.netbeans.org/cddl-gplv2.html
  * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
  * specific language governing permissions and limitations under the
  * License.  When distributing the software, include this License Header
  * Notice in each file and include the License file at
  * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
  * particular file as subject to the "Classpath" exception as provided
  * by Sun in the GPL Version 2 section of the License file that
  * accompanied this code. If applicable, add the following below the
  * License Header, with the fields enclosed by brackets [] replaced by
  * your own identifying information:
  * "Portions Copyrighted [year] [name of copyright owner]"
  *
  * Contributor(s):
  *
  * The Original Software is NetBeans. The Initial Developer of the Original
  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
  * Microsystems, Inc. All Rights Reserved.
  *
  * If you wish your version of this file to be governed by only the CDDL
  * or only the GPL Version 2, indicate your decision by adding
  * "[Contributor] elects to include this software in this distribution
  * under the [CDDL or GPL Version 2] license." If you do not indicate a
  * single choice of license, a recipient has the option to distribute
  * your version of this file under either the CDDL, the GPL Version 2 or
  * to extend the choice of license to its licensees as provided above.
  * However, if you add GPL Version 2 code and therefore, elected the GPL
  * Version 2 license, then the option applies only if the new code is
  * made subject to such option by the copyright holder.
  */
 /*
  * JMSWizardVisualPanel.java
  *
  * Created on November 17, 2003, 11:23 AM
  */
 
 package org.netbeans.modules.j2ee.sun.ide.sunresources.wizards;
 
 

Author(s):
nityad
 
 public class JMSWizardVisualPanel extends javax.swing.JPanel implements ChangeListenerWizardConstants{
     
     protected ResourceBundle bundle = NbBundle.getBundle("org.netbeans.modules.j2ee.sun.ide.sunresources.wizards.Bundle"); //NOI18N
     
     protected final JMSWizardPanel panel;
     protected ResourceConfigHelper helper;
     
     protected Field fields[] = null;    
     protected FieldGroup[] groups;
            
     protected ArrayList beans = new ArrayList();
     protected boolean createNewResource = false;
     private FieldGroup adminObjPropGroup;
    
      
Creates new form JMSWizardVisualPanel
 
     public JMSWizardVisualPanel(JMSWizardPanel panelFieldGroup[] groups) {
         this. = panel;
         this. = panel.getHelper();
         this. = groups;
         this. = panel.getFieldGroup();  //NOI18N
         
         initComponents();
         refreshFields();
         
         setName(NbBundle.getMessage(JMSWizardVisualPanel.class"LBL_GeneralAttributes_JMS")); //NOI18N
     }
    
    
This method is called from within the constructor to initialize the form. WARNING: Do NOT modify this code. The content of this method is always regenerated by the Form Editor.
 
     // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
     private void initComponents() {
         java.awt.GridBagConstraints gridBagConstraints;
 
         = new javax.swing.ButtonGroup();
         = new javax.swing.JPanel();
         = new javax.swing.JLabel();
         = new javax.swing.JRadioButton();
         = new javax.swing.JRadioButton();
         = new javax.swing.JLabel();
         = new javax.swing.JLabel();
         = new javax.swing.JTextArea();
         = new javax.swing.JPanel();
         = new javax.swing.JTextField();
         = new javax.swing.JComboBox();
         = new javax.swing.JTextField();
         = new javax.swing.JLabel();
         = new javax.swing.JLabel();
         = new javax.swing.JLabel();
        setLayout(new java.awt.GridBagLayout());
        .setLayout(new java.awt.GridBagLayout());
        java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle("org/netbeans/modules/j2ee/sun/ide/sunresources/wizards/Bundle"); // NOI18N
        .setText(bundle.getString("LBL_resource-type")); // NOI18N
        .setFocusable(false);
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 0;
        gridBagConstraints.gridwidth = 2;
        gridBagConstraints.fill = ...;
        gridBagConstraints.weightx = 1.0;
        gridBagConstraints.insets = new java.awt.Insets(10, 0, 10, 0);
        .add(gridBagConstraints);
        .getAccessibleContext().setAccessibleDescription(bundle.getString("ToolTip_resource-type")); // NOI18N
        org.openide.awt.Mnemonics.setLocalizedText(bundle.getString("LBL_Connector_QueueConnectionFactory")); // NOI18N
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                queueConnectionRadioButtonActionPerformed(evt);
            }
        });
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 5;
        gridBagConstraints.fill = ...;
        gridBagConstraints.ipadx = 3;
        gridBagConstraints.anchor = ...;
        gridBagConstraints.insets = new java.awt.Insets(0, 30, 0, 30);
        .add(gridBagConstraints);
        .getAccessibleContext().setAccessibleDescription(bundle.getString("ToolTip_Connector_QueueConnectionFactory")); // NOI18N
        org.openide.awt.Mnemonics.setLocalizedText(bundle.getString("LBL_Connector_TopicConnectionFactory")); // NOI18N
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                topicConnectionRadioButtonActionPerformed(evt);
            }
        });
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 6;
        gridBagConstraints.fill = ...;
        gridBagConstraints.anchor = ...;
        gridBagConstraints.insets = new java.awt.Insets(0, 30, 0, 30);
        .add(gridBagConstraints);
        .getAccessibleContext().setAccessibleDescription(bundle.getString("ToolTip_Connector_TopicConnectionFactory")); // NOI18N
        org.openide.awt.Mnemonics.setLocalizedText(bundle.getString("LBL_AdminObject_Queue")); // NOI18N
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                queueRadioButtonActionPerformed(evt);
            }
        });
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 2;
        gridBagConstraints.fill = ...;
        gridBagConstraints.anchor = ...;
        gridBagConstraints.insets = new java.awt.Insets(0, 30, 0, 30);
        .add(gridBagConstraints);
        .getAccessibleContext().setAccessibleDescription(bundle.getString("ToolTip_AdminObject_Queue")); // NOI18N
        org.openide.awt.Mnemonics.setLocalizedText(bundle.getString("LBL_AdminObject_Topic")); // NOI18N
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                topicRadioButtonActionPerformed(evt);
            }
        });
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 3;
        gridBagConstraints.fill = ...;
        gridBagConstraints.anchor = ...;
        gridBagConstraints.insets = new java.awt.Insets(0, 30, 10, 30);
        .add(gridBagConstraints);
        .getAccessibleContext().setAccessibleDescription(bundle.getString("ToolTip_AdminObject_Topic")); // NOI18N
        .setText(bundle.getString("LBL_jms-admin-object")); // NOI18N
        .setFocusable(false);
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 1;
        gridBagConstraints.fill = ...;
        gridBagConstraints.insets = new java.awt.Insets(0, 0, 10, 0);
        .add(gridBagConstraints);
        .getAccessibleContext().setAccessibleDescription(bundle.getString("jms-admin-object_Description")); // NOI18N
        .setText(bundle.getString("LBL_jms-connector")); // NOI18N
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 4;
        gridBagConstraints.fill = ...;
        gridBagConstraints.insets = new java.awt.Insets(0, 0, 10, 0);
        .add(gridBagConstraints);
        .getAccessibleContext().setAccessibleDescription(bundle.getString("jms-connector_Description")); // NOI18N
        org.openide.awt.Mnemonics.setLocalizedText(bundle.getString("LBL_Connector_ConnectionFactory")); // NOI18N
        .setToolTipText(bundle.getString("ToolTip_Connector_ConnectionFactory")); // NOI18N
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                connectionFactoryRadioButtonActionPerformed(evt);
            }
        });
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 7;
        gridBagConstraints.fill = ...;
        gridBagConstraints.anchor = ...;
        gridBagConstraints.insets = new java.awt.Insets(0, 30, 10, 30);
        .add(gridBagConstraints);
        .getAccessibleContext().setAccessibleDescription(bundle.getString("ToolTip_Connector_ConnectionFactory")); // NOI18N
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 2;
        gridBagConstraints.gridwidth = 2;
        gridBagConstraints.fill = ...;
        gridBagConstraints.weightx = 1.0;
        gridBagConstraints.weighty = 0.1;
        add(gridBagConstraints);
        .getAccessibleContext().setAccessibleName(bundle.getString("LBL_GeneralAttributes_JMS")); // NOI18N
        .getAccessibleContext().setAccessibleDescription(bundle.getString("jms-resource_Description")); // NOI18N
        .setEditable(false);
        .setLineWrap(true);
        .setText(bundle.getString("jms-resource_Description")); // NOI18N
        .setFocusable(false);
        .setOpaque(false);
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 0;
        gridBagConstraints.gridwidth = 2;
        gridBagConstraints.fill = ...;
        gridBagConstraints.weightx = 1.0;
        gridBagConstraints.weighty = 0.5;
        add(gridBagConstraints);
        .getAccessibleContext().setAccessibleName(bundle.getString("LBL_GeneralAttributes_JMS")); // NOI18N
        .getAccessibleContext().setAccessibleDescription(bundle.getString("jms-resource_Description")); // NOI18N
        .setLayout(new java.awt.GridBagLayout());
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jndiNameFieldActionPerformed(evt);
            }
        });
            public void keyReleased(java.awt.event.KeyEvent evt) {
                jndiNameFieldKeyReleased(evt);
            }
        });
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 0;
        gridBagConstraints.fill = ...;
        gridBagConstraints.insets = new java.awt.Insets(0, 0, 10, 0);
        .add(gridBagConstraints);
        .getAccessibleContext().setAccessibleName(bundle.getString("LBL_jndi-name")); // NOI18N
        .getAccessibleContext().setAccessibleDescription(bundle.getString("ToolTip_jndi-name")); // NOI18N
        initFields();
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                enabledComboBoxActionPerformed(evt);
            }
        });
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 1;
        gridBagConstraints.fill = ...;
        gridBagConstraints.insets = new java.awt.Insets(0, 0, 10, 0);
        .add(gridBagConstraints);
        .getAccessibleContext().setAccessibleName(bundle.getString("LBL_enabled")); // NOI18N
        .getAccessibleContext().setAccessibleDescription(bundle.getString("ToolTip_enabled")); // NOI18N
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                descFieldActionPerformed(evt);
            }
        });
            public void keyReleased(java.awt.event.KeyEvent evt) {
                descFieldKeyReleased(evt);
            }
        });
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 2;
        gridBagConstraints.fill = ...;
        gridBagConstraints.weightx = 1.0;
        gridBagConstraints.insets = new java.awt.Insets(0, 0, 10, 0);
        .add(gridBagConstraints);
        .getAccessibleContext().setAccessibleName(bundle.getString("LBL_description")); // NOI18N
        .getAccessibleContext().setAccessibleDescription(bundle.getString("ToolTip_description")); // NOI18N
        org.openide.awt.Mnemonics.setLocalizedText(bundle.getString("LBL_jndi-name")); // NOI18N
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 0;
        gridBagConstraints.fill = ...;
        gridBagConstraints.weightx = 1.0;
        gridBagConstraints.insets = new java.awt.Insets(0, 0, 10, 0);
        .add(gridBagConstraints);
        .getAccessibleContext().setAccessibleDescription(bundle.getString("ToolTip_jndi-name")); // NOI18N
        org.openide.awt.Mnemonics.setLocalizedText(bundle.getString("LBL_enabled")); // NOI18N
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 1;
        gridBagConstraints.fill = ...;
        gridBagConstraints.weightx = 1.0;
        gridBagConstraints.insets = new java.awt.Insets(0, 0, 10, 0);
        .add(gridBagConstraints);
        .getAccessibleContext().setAccessibleDescription(bundle.getString("ToolTip_enabled")); // NOI18N
        org.openide.awt.Mnemonics.setLocalizedText(bundle.getString("LBL_description")); // NOI18N
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 2;
        gridBagConstraints.fill = ...;
        gridBagConstraints.weightx = 1.0;
        gridBagConstraints.insets = new java.awt.Insets(0, 0, 10, 0);
        .add(gridBagConstraints);
        .getAccessibleContext().setAccessibleDescription(bundle.getString("ToolTip_description")); // NOI18N
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 1;
        gridBagConstraints.gridwidth = 2;
        gridBagConstraints.fill = ...;
        gridBagConstraints.weightx = 1.0;
        gridBagConstraints.weighty = 0.3;
        add(gridBagConstraints);
        .getAccessibleContext().setAccessibleName(bundle.getString("LBL_GeneralAttributes_JMS")); // NOI18N
        .getAccessibleContext().setAccessibleDescription(bundle.getString("jms-resource_Description")); // NOI18N
        getAccessibleContext().setAccessibleName(bundle.getString("LBL_GeneralAttributes_JMS")); // NOI18N
        getAccessibleContext().setAccessibleDescription(bundle.getString("jms-resource_Description")); // NOI18N
    }// </editor-fold>//GEN-END:initComponents
    private void connectionFactoryRadioButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_connectionFactoryRadioButtonActionPerformed
        this..getData().setString(); 
        this..getData().setProperties(new Vector());
        this..fireChange(evt.getSource());    
    }//GEN-LAST:event_connectionFactoryRadioButtonActionPerformed
    private void topicConnectionRadioButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_topicConnectionRadioButtonActionPerformed
        this..getData().setProperties(new Vector());
        this..fireChange(evt.getSource());
    }//GEN-LAST:event_topicConnectionRadioButtonActionPerformed
    private void queueConnectionRadioButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_queueConnectionRadioButtonActionPerformed
        this..getData().setProperties(new Vector());
        this..fireChange(evt.getSource());
    }//GEN-LAST:event_queueConnectionRadioButtonActionPerformed
    private void topicRadioButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_topicRadioButtonActionPerformed
        this..getData().setString(); 
        setPropsForAdminObj();
        this..fireChange(evt.getSource());
    }//GEN-LAST:event_topicRadioButtonActionPerformed
    private void queueRadioButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_queueRadioButtonActionPerformed
        this..getData().setString(); 
        setPropsForAdminObj();
        this..fireChange(evt.getSource());
    }//GEN-LAST:event_queueRadioButtonActionPerformed
    private void descFieldKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_descFieldKeyReleased
        ResourceConfigData data = this..getData();
        String value = data.getString();
        String newValue = .getText();
        if (!value.equals(newValue)) {
            this..getData().setString(newValue);
        }
        this..fireChange(evt.getSource());
    }//GEN-LAST:event_descFieldKeyReleased
    private void descFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_descFieldActionPerformed
        ResourceConfigData data = this..getData();
        String value = data.getString();
        String newValue = .getText();
        if (!value.equals(newValue)) {
            this..getData().setString(newValue);
            this..fireChange(evt.getSource());
        }
        
        if((this.getRootPane().getDefaultButton() != null) && (this.getRootPane().getDefaultButton().isEnabled())){
            this.getRootPane().getDefaultButton().doClick();
        }
    }//GEN-LAST:event_descFieldActionPerformed
        
    private void enabledComboBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_enabledComboBoxActionPerformed
        String newValue = (String).getSelectedItem();
        this..getData().setString(newValue);
    }//GEN-LAST:event_enabledComboBoxActionPerformed
    private void jndiNameFieldKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jndiNameFieldKeyReleased
        ResourceConfigData data = this..getData();
        String value = data.getString();
        String newValue = .getText();
        if (!value.equals(newValue)) {
            this..getData().setString(newValue);
        }
        this..fireChange(evt.getSource());
    }//GEN-LAST:event_jndiNameFieldKeyReleased
    private void jndiNameFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jndiNameFieldActionPerformed
        ResourceConfigData data = this..getData();
        String value = data.getString();
        String newValue = .getText();
        if (!value.equals(newValue)) {
            this..getData().setString(newValue);
            this..fireChange(evt.getSource());
        }
        
        if((this.getRootPane().getDefaultButton() != null) && (this.getRootPane().getDefaultButton().isEnabled())){
            this.getRootPane().getDefaultButton().doClick();
        }
    }//GEN-LAST:event_jndiNameFieldActionPerformed
    public void stateChanged(javax.swing.event.ChangeEvent e) {
    }    
    
     public void refreshFields() {
        ResourceConfigData data = this..getData();
        String jndiNameVal = (String).getText();
        String descVal = (String).getText();
        String enabledVal = (String).getSelectedItem();
        
         = [0].getField();
        for(int j=0; j<.j++){
            String fieldName = [j].getName();
            Object value = data.get(fieldName);
            if (value == null) {
                value = FieldHelper.getDefaultValue([j]);
                data.set(fieldNamevalue);
            }
            
            String defValue = (String)value;
            if(FieldHelper.isList([j])){
               if(! enabledVal.equals(defValue)){
                    .setSelectedItem(defValue);
                }
            }else{
                if(fieldName.equals("jndi-name") && (! jndiNameVal.equals(defValue)) ){ //NOI18N
                    String targetFile = data.getTargetFile();
                    if(targetFile != null){
                        .setText(targetFile);
                    }else
                        .setText(defValue);
                }else if(! jndiNameVal.equals(defValue)){
                    .setText(defValue);
                }
            }
        }
        
        String isResTypeSelected = this..getData().getString();
        if(isResTypeSelected == null || isResTypeSelected.trim().equals("") ){//NOI18N
            this..setSelected(true);
            this..getData().setString(,  ); 
            setPropsForAdminObj();
        }
     }
     
     public JMSWizardVisualPanel setFirstTime(boolean first) {
         //this.firstTime = first;
         return this;
     }
     
     private void initFields(){
          = [0].getField();
         for(int j=0; j<.j++){
             if(FieldHelper.isList([j])){
                 String tags[] = FieldHelper.getTags([j]);
                 for (int h = 0; h < tags.lengthh++) {
                     .addItem(tags[h]);
                 }
             }
         }//for
     }
     
     public void setHelper(ResourceConfigHelper helper){
         this. = helper;
         this..getData().setString("jndi-name"helper.getData().getTargetFile()); //NOI18N
         refreshFields();
     }
     
     private void setPropsForAdminObj() {
        ResourceConfigData data = this..getData();
        data.setProperties(new Vector());
        data.addProperty(""); //NOI18N
    }
     
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel adObjLabel;
    private javax.swing.JLabel chooseResLabel;
    private javax.swing.JLabel connLabel;
    private javax.swing.JTextField descField;
    private javax.swing.JLabel descLabel;
    private javax.swing.JLabel enabledLabel;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JTextArea jTextArea1;
    private javax.swing.JLabel jndiNameLabel;
    // End of variables declaration//GEN-END:variables