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.
  */
 /*
  * CPPropertiesPanelVisualPanel.java
  *
  * Created on October 8, 2003
  */
 
 package org.netbeans.modules.j2ee.sun.ide.sunresources.wizards;
 
 
A single panel for a wizard - the GUI portion.

Author(s):
nityad
 
 public class CPPropertiesPanelVisualPanel extends javax.swing.JPanel implements WizardConstantsTableModelListener{
    
    
The wizard panel descriptor associated with this GUI panel. If you need to fire state changes or something similar, you can use this handle to do so.
 
     private final CPPropertiesPanelPanel panel;
     private ResourceConfigHelper helper;
     private Field dsFieldtypeField;
        
    
Create the wizard panel and set up some basic properties.
 
     public CPPropertiesPanelVisualPanel(CPPropertiesPanelPanel panelResourceConfigHelper helperWizard wizardInfo) {
         this. = panel;
         this. = helper;
         this. = new PropertiesTableModel(this..getData());     
         
         initComponents();
         // Provide a name in the title bar.
         setName(NbBundle.getMessage(CPPropertiesPanelVisualPanel.class"TITLE_ConnPoolWizardPanel_properties")); //NOI18N
         
         this. = FieldGroupHelper.getFieldGroup(wizardInfo); 
         this. = FieldGroupHelper.getFieldGroup(wizardInfo);  
         this. = FieldHelper.getField();  
       
         setPropTableCellEditor();
         this..addTableModelListener(this);
         
         String dsClassName = this..getData().getString();
         if (dsClassName.length() == 0)
            dsClassName = FieldHelper.getDefaultValue();
        .setText(dsClassName);
        
        this. = FieldHelper.getField();         
        String resType = this..getData().getString();
        if (resType.length() == 0) {
            resType = FieldHelper.getDefaultValue();
        }    
        .setSelectedItem(resType);
    }
    
    
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.JPanel();
         = new javax.swing.JTextField();
         = new javax.swing.JLabel();
         = new javax.swing.JLabel();
         = new javax.swing.JTextField();
         = new javax.swing.JLabel();
         = new javax.swing.JComboBox();
         = new javax.swing.JScrollPane();
         = new PropertiesTable();
         = new javax.swing.JPanel();
         = new javax.swing.JButton();
         = new javax.swing.JButton();
         = new javax.swing.JTextArea();
         = new javax.swing.JLabel();
        setLayout(new java.awt.GridBagLayout());
        .setLayout(new java.awt.GridBagLayout());
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                classNameFieldActionPerformed(evt);
            }
        });
            public void keyReleased(java.awt.event.KeyEvent evt) {
                classNameFieldKeyReleased(evt);
            }
        });
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 0;
        gridBagConstraints.fill = ...;
        gridBagConstraints.insets = new java.awt.Insets(12, 0, 0, 0);
        .add(gridBagConstraints);
        .getAccessibleContext().setAccessibleDescription(.getString("ACS_datasource-classnamefieldA11yDesc"));
        org.openide.awt.Mnemonics.setLocalizedText(.getString("LBL_datasource-classname"));
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 0;
        gridBagConstraints.fill = ...;
        gridBagConstraints.insets = new java.awt.Insets(12, 0, 0, 0);
        .add(gridBagConstraints);
        .getAccessibleContext().setAccessibleDescription(.getString("ToolTip_datasource-classname"));
        org.openide.awt.Mnemonics.setLocalizedText(.getString("LBL_res-type"));
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 1;
        gridBagConstraints.fill = ...;
        gridBagConstraints.insets = new java.awt.Insets(12, 0, 0, 0);
        .add(gridBagConstraints);
        .getAccessibleContext().setAccessibleDescription(.getString("ACS_res-typefieldA11yDesc"));
            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(12, 0, 0, 0);
        .add(gridBagConstraints);
        java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle("org/netbeans/modules/j2ee/sun/ide/sunresources/wizards/Bundle"); // 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.ipadx = 49;
        gridBagConstraints.insets = new java.awt.Insets(12, 0, 0, 0);
        .add(gridBagConstraints);
        .getAccessibleContext().setAccessibleName(bundle.getString("LBL_description")); // NOI18N
        .getAccessibleContext().setAccessibleDescription(bundle.getString("ToolTip_description")); // NOI18N
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                resTypeComboActionPerformed(evt);
            }
        });
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 1;
        gridBagConstraints.fill = ...;
        gridBagConstraints.insets = new java.awt.Insets(12, 0, 0, 0);
        .add(gridBagConstraints);
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 1;
        gridBagConstraints.gridwidth = ...;
        gridBagConstraints.fill = ...;
        gridBagConstraints.weightx = 1.0;
        gridBagConstraints.weighty = 1.0;
        add(gridBagConstraints);
        .getAccessibleContext().setAccessibleName(bundle.getString("TITLE_ConnPoolWizardPanel_properties")); // NOI18N
        .getAccessibleContext().setAccessibleDescription(bundle.getString("CPPropertyPanel_Description")); // NOI18N
        .setPreferredSize(new java.awt.Dimension(453, 17));
        .setModel();
        .getAccessibleContext().setAccessibleName(bundle.getString("LBL_properties")); // NOI18N
        .getAccessibleContext().setAccessibleDescription(bundle.getString("ACS_propTableCommon_A11yDesc")); // NOI18N
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 3;
        gridBagConstraints.fill = ...;
        gridBagConstraints.weightx = 1.0;
        gridBagConstraints.insets = new java.awt.Insets(10, 12, 10, 11);
        add(gridBagConstraints);
        .getAccessibleContext().setAccessibleName(bundle.getString("LBL_properties")); // NOI18N
        .getAccessibleContext().setAccessibleDescription(bundle.getString("ACS_propTableCommon_A11yDesc")); // NOI18N
        org.openide.awt.Mnemonics.setLocalizedText(bundle.getString("LBL_Add"));
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                addButtonActionPerformed(evt);
            }
        });
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 0;
        gridBagConstraints.fill = ...;
        gridBagConstraints.insets = new java.awt.Insets(0, 12, 0, 12);
        .add(gridBagConstraints);
        .getAccessibleContext().setAccessibleDescription(bundle.getString("ACS_AddButtonA11yDesc"));
        org.openide.awt.Mnemonics.setLocalizedText(bundle.getString("LBL_Remove"));
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                removeButtonActionPerformed(evt);
            }
        });
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 1;
        gridBagConstraints.fill = ...;
        gridBagConstraints.insets = new java.awt.Insets(12, 12, 0, 12);
        .add(gridBagConstraints);
        .getAccessibleContext().setAccessibleName(bundle.getString("LBL_Remove"));
        .getAccessibleContext().setAccessibleDescription(bundle.getString("ACS_RemoveButtonA11yDesc"));
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 2;
        gridBagConstraints.gridheight = 2;
        gridBagConstraints.fill = ...;
        gridBagConstraints.ipady = 100;
        add(gridBagConstraints);
        .getAccessibleContext().setAccessibleName(bundle.getString("LBL_properties")); // NOI18N
        .getAccessibleContext().setAccessibleDescription(bundle.getString("ACS_propTableCommon_A11yDesc")); // NOI18N
        .setEditable(false);
        .setText(bundle.getString("CPPropertyPanel_Description"));
        .setOpaque(false);
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 0;
        gridBagConstraints.gridwidth = ...;
        gridBagConstraints.fill = ...;
        gridBagConstraints.weightx = 1.0;
        gridBagConstraints.weighty = 1.0;
        gridBagConstraints.insets = new java.awt.Insets(0, 0, 1, 0);
        add(gridBagConstraints);
        .getAccessibleContext().setAccessibleName(bundle.getString("CPPropertyPanel_Description"));
        .getAccessibleContext().setAccessibleDescription(bundle.getString("CPPropertyPanel_Description"));
        .setLabelFor();
        org.openide.awt.Mnemonics.setLocalizedText(bundle.getString("LBL_properties")); // NOI18N
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 2;
        gridBagConstraints.fill = ...;
        gridBagConstraints.weightx = 1.0;
        add(gridBagConstraints);
        getAccessibleContext().setAccessibleName(bundle.getString("TITLE_ConnPoolWizardPanel_properties")); // NOI18N
        getAccessibleContext().setAccessibleDescription(bundle.getString("CPPropertyPanel_Description")); // NOI18N
    }// </editor-fold>//GEN-END:initComponents
    private void classNameFieldKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_classNameFieldKeyReleased
        // Add your handling code here:
        ResourceConfigData data = this..getData();
        String value = data.getString();
        String newValue = .getText();
        if (!value.equals(newValue)) {
            this..getData().setString(newValue);
            //fireChange(this);
        }
        this..fireChangeEvent(this);
    }//GEN-LAST:event_classNameFieldKeyReleased
    private void descFieldKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_descFieldKeyReleased
        // Add your handling code here:
        ResourceConfigData data = this..getData();
        String value = data.getString();
        String newValue = .getText();
        if (!value.equals(newValue)) {
            this..getData().setString(newValue);
            //fireChange(this);
        }
        this..fireChangeEvent(this);
    }//GEN-LAST:event_descFieldKeyReleased
    private void descFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_descFieldActionPerformed
        // Add your handling code here:
        ResourceConfigData data = this..getData();
        String item = .getText();
        Object value = data.get();  
        if (!item.equals((String)value)){
            data.setString(item);  
        }
        
        this..fireChangeEvent(this);
        if((this.getRootPane().getDefaultButton() != null) && (this.getRootPane().getDefaultButton().isEnabled())){
            this.getRootPane().getDefaultButton().doClick();
        }
    }//GEN-LAST:event_descFieldActionPerformed
    private void classNameFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_classNameFieldActionPerformed
        // Add your handling code here:
        ResourceConfigData data = this..getData();
        String item = .getText();
        Object value = data.get();  
        if (value == null)
            value = FieldHelper.getDefaultValue();
        if (!item.equals((String)value))
            data.setString(item);  
        
        this..fireChangeEvent(this);
        if((this.getRootPane().getDefaultButton() != null) && (this.getRootPane().getDefaultButton().isEnabled())){
            this.getRootPane().getDefaultButton().doClick();
        }
    }//GEN-LAST:event_classNameFieldActionPerformed
    private void removeButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_removeButtonActionPerformed
        // Add your handling code here:
        int selectedRow = .getSelectedRow();
        if (selectedRow != -1) {
            //Fix for bug#4958730 - value overwrites into next row
            .editingStopped(new ChangeEvent (this));
            this..getData().removeProperty(selectedRow);
            .fireTableDataChanged();
        }
    }//GEN-LAST:event_removeButtonActionPerformed
    private void addButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addButtonActionPerformed
        // Add your handling code here:
        //Fix for bug#4958730 - value overwrites into next row
        .editingStopped(new ChangeEvent (this));
        ResourceConfigData data = this..getData();
        data.addProperty(new NameValuePair()); 
    }//GEN-LAST:event_addButtonActionPerformed
    private void resTypeComboActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_resTypeComboActionPerformed
        String itemValue = (String).getSelectedItem();
        ResourceConfigData data = this..getData();
        data.setString(itemValue);
    }//GEN-LAST:event_resTypeComboActionPerformed
    public void tableChanged(javax.swing.event.TableModelEvent e) {
         setPropTableCellEditor();
         this..fireChangeEvent(this);
    }    
    
    public void setPropTableCellEditor() {
        javax.swing.JComboBox propNameComboBox = new javax.swing.JComboBox();
        String[] remainingProperties = FieldHelper.getRemainingFieldNames(this..getData().getPropertyNames());
        for (int i = 0; i < remainingProperties.lengthi++) 
            propNameComboBox.addItem(remainingProperties[i]);
        
        this. = .getColumnModel().getColumn(0);
        propNameComboBox.setEditable(true);
        this..setCellEditor(new javax.swing.DefaultCellEditor(propNameComboBox));
        this. = .getColumnModel().getColumn(1);
                
        editor.setClickCountToStart(1);
        this..setCellEditor(editor);
    }
    
     public void refreshFields() {
        ResourceConfigData data = this..getData();
        String item = .getText();
        String val = data.getString();
        if (!item.equals(val))
            .setText(val);
        
        item = (String).getSelectedItem();
        val = data.getString();  
        if (!item.equals(val)) {
            .setSelectedItem(val);
        }    
    }
     
    public void setInitialFocus(){
        new setFocus();
    }
    
    private String[] resourceTypes = {
        .,    
    };
    
        return model;
    }
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton addButton;
    private javax.swing.JLabel classNameLabel;
    private javax.swing.JTextField descField;
    private javax.swing.JLabel descLabel;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JTable jTable1;
    private javax.swing.JButton removeButton;
    private javax.swing.JLabel resTypeLabel;
    // End of variables declaration//GEN-END:variables
    private ResourceBundle bundle = NbBundle.getBundle("org.netbeans.modules.j2ee.sun.ide.sunresources.wizards.Bundle"); //NOI18N
    private TableColumn nameColumn;
    private TableColumn valueColumn;
    
New to GrepCode? Check out our FAQ X