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.
  */
 /*
  * CommonGeneralFinishVisualPanel.java
  *
  * Created on October 10, 2002
  */
 
 package org.netbeans.modules.j2ee.sun.ide.sunresources.wizards;
 
 import javax.swing.*;
 
A single panel for a wizard - the GUI portion.

Author(s):
shirleyc
 
 public class CommonGeneralFinishVisualPanel extends javax.swing.JPanel implements ChangeListenerWizardConstants {
    
    
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.
 
     
     public static final String TYPE_JMS_RESOURCE = "_JMS";  //NOI18N
     public static final String TYPE_MAIL_RESOUCE = "_MAIL";  //NOI18N
     
     protected ResourceBundle bundle = NbBundle.getBundle("org.netbeans.modules.j2ee.sun.ide.sunresources.wizards.Bundle"); //NOI18N
 
     protected final CommonGeneralFinishPanel panel;
     protected FieldGroup[] groups;
     protected int fieldSize;
     protected ResourceConfigHelper helper;
     protected String panelType = ;
     protected ArrayList beans = new ArrayList();
     protected boolean createNewResource = false;
     
     // Variables declaration - general attributes
     protected javax.swing.JTextArea descriptionTextArea = null;
     protected javax.swing.JPanel jPanel1[] = null;
     protected javax.swing.JLabel jLabels[] = null;
     protected javax.swing.JComponent jFields[] = null;
     protected Field fields[] = null;
     protected String resourceName;
     protected boolean showGroupTitle = false;
     
     // Variable declaration - choice 
     private javax.swing.JPanel jPanel0;
     private boolean firstTime = true;
     private int y = 0;
    
    
Create the wizard panel and set up some basic properties.
 
     public CommonGeneralFinishVisualPanel(CommonGeneralFinishPanel panelFieldGroup[] groupsString panelType) {
        this. = true;
        this. = panel;
        this. = panel.getHelper();
        this. = panel.getResourceName();
        setFieldGroups(groups);
        if (groups.length > 1)
            this. = true;
        
        setLayout(new java.awt.GridBagLayout());
        initDescriptionComponent();
        
            
        setPanelType(panelType);
        initComponents();
        refreshFields();
        // Provide a name in the title bar.
        setName(NbBundle.getMessage(CommonGeneralFinishVisualPanel.class"TITLE_" + groups[0].getName())); //NOI18N
        getAccessibleContext().setAccessibleName(.getString("TITLE_" + groups[0].getName())); 
        getAccessibleContext().setAccessibleDescription(.getString("mail-resource_Description"));
        this. = false;
    }
    
    public void setFieldGroups(FieldGroup[] groups) {
        this. = groups;
         = 0;
        for (int i = 0; i < groups.lengthi++) {
             += groups[i].sizeField();
        }
    }
    
    
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.
    private void initComponents() {
        java.awt.GridBagConstraints gridBagConstraints;
        int gap = 0;
        int itemHeight = 28;
        if ( < 6) {
            itemHeight = 42;
            gap = 7;
        }
        int i = 0;
         = new JPanel[.];
         = new Field[];
         = new JLabel[];
         = new JComponent[];   
      
      for (int j = 0; j < .j++) {
        if () {
            JLabel label = new JLabel();
            label.setText(.getString("LBL_GROUP_" + [j].getName()));  //NOI18N
            label.getAccessibleContext().setAccessibleDescription(.getString("ACS_LBL_GROUP_" + [j].getName() + "A11yDesc"));  //NOI18N
            gridBagConstraints = new java.awt.GridBagConstraints();
            gridBagConstraints.gridx = 0;
            gridBagConstraints.gridy = this.;  this.++;
            gridBagConstraints.fill = ...;
            gridBagConstraints.ipadx = 0;
            gridBagConstraints.insets = new java.awt.Insets(5, 0, 0, 11);
            add(labelgridBagConstraints);
        }  
        
        Field[] flds = [j].getField();
        int size = flds.length;
        [j] = new javax.swing.JPanel();
        [j].setLayout(new java.awt.GridBagLayout());
        
        [j].setMaximumSize(new java.awt.Dimension(480, itemHeight * size));
        [j].setMinimumSize(new java.awt.Dimension(480, itemHeight * size));
        [j].setPreferredSize(new java.awt.Dimension(480, itemHeight * size));
        
        for (int k = 0; k < sizek++) {
            [i] = flds[k];
            JLabel jLabel = new JLabel();
            org.openide.awt.Mnemonics.setLocalizedText(jLabel.getString("LBL_" + [i].getName())); //NOI18N
            gridBagConstraints = new java.awt.GridBagConstraints();
            gridBagConstraints.gridx = 0;
            gridBagConstraints.gridy = k;
            gridBagConstraints.fill = ...;
            gridBagConstraints.ipadx = 0;
            gridBagConstraints.insets = new java.awt.Insets(2, 12, gap, 0);
            [i] = jLabel;
            [j].add([i], gridBagConstraints);
            
            if (FieldHelper.isList([i])) {
                JComboBox jComboBox = new JComboBox();
                jLabel.setLabelFor(jComboBox);
                jComboBox.getAccessibleContext().setAccessibleDescription(.getString("ToolTip_" + [i].getName()));  
                String tags[] = FieldHelper.getTags([i]);
                for (int h = 0; h < tags.lengthh++) {
                    jComboBox.addItem(tags[h]);
                }
                final int index = i;
                jComboBox.addActionListener(new java.awt.event.ActionListener() {
                    public void actionPerformed(java.awt.event.ActionEvent evt) {
                        jComboBoxActionPerformed(evtindex);
                    }
                });
                gridBagConstraints = new java.awt.GridBagConstraints();
                gridBagConstraints.gridx = 1;
                gridBagConstraints.gridy =  k;
                gridBagConstraints.fill = ...;
                gridBagConstraints.insets = new java.awt.Insets(2, 20, gap, 0);
                gridBagConstraints.weightx = 1.0;
                [i] = jComboBox;
                [j].add(jComboBoxgridBagConstraints);
            }  else {
                JTextField jTextField = new JTextField();
                jTextField.setText("jTextField1"); //NOI18N
                jLabel.setLabelFor(jTextField);
                jTextField.getAccessibleContext().setAccessibleDescription(.getString("ToolTip_" + [i].getName())); 
                jTextField.setToolTipText(.getString("ToolTip_" + [i].getName()));  //NOI18N
                jTextField.setMinimumSize(new java.awt.Dimension(340, 21));
                jTextField.setPreferredSize(new java.awt.Dimension(340, 21));
                final int index = i;
                /*
                jTextField.addActionListener(new java.awt.event.ActionListener() {
                    public void actionPerformed(java.awt.event.ActionEvent evt) {
                        jTextField1ActionPerformed(evt, index);
                    }
                });
                 */
                jTextField.addKeyListener(new java.awt.event.KeyAdapter() {
                    public void keyReleased(java.awt.event.KeyEvent evt) {
                        jTextField1KeyReleased(evtindex);
                    }
                });
                gridBagConstraints = new java.awt.GridBagConstraints();
                gridBagConstraints.gridx = 1;
                gridBagConstraints.gridy =  k;
                gridBagConstraints.fill = ...;
                gridBagConstraints.insets = new java.awt.Insets(2, 20, gap, 0);
                [i] = jTextField;
                [j].add(jTextFieldgridBagConstraints);
            }
            i++;
        }
        
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = this.;   this.++;
        gridBagConstraints.fill = ...;
        gridBagConstraints.insets = new java.awt.Insets(5, 0, 10, 11);
        [j].setBorder(new javax.swing.border.EtchedBorder());
        add([j], gridBagConstraints);
      }
    }    
    
    private void initDescriptionComponent() {
        java.awt.GridBagConstraints gridBagConstraints;
        
         = new javax.swing.JTextArea();
        .setEditable(false);
        .setFont(javax.swing.UIManager.getFont("Label.font")); //NOI18N
        .setText(.getString(this. + "_Description"));  //NOI18N
        .setDisabledTextColor(javax.swing.UIManager.getColor("Label.foreground"));  //NOI18N
        .setEnabled(false);
        .setOpaque(false);
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = this.this.++;
        gridBagConstraints.fill = ...;
        gridBagConstraints.weightx = 1.0;
        gridBagConstraints.weighty = 0.0;
        gridBagConstraints.insets = new java.awt.Insets(12, 12, 20, 11);
        add(gridBagConstraints);        
    }
    
    
    protected String getPanelType() {
        return ;
    }
    
    protected void setPanelType(String type) {
        this. = type
    }
    
    public void stateChanged(final javax.swing.event.ChangeEvent p1) {
    }
    public boolean createNew() {
        return ;
    }
    
    public void refreshFields() {
        ResourceConfigData data = this..getData();
        for (int i = 0; i < .i++) {
            String item;
            if (FieldHelper.isList([i])) {
                item = (String)((JComboBox)[i]).getSelectedItem();
            } else {
                item = (String)((JTextField)[i]).getText();
            }
            String fieldName = [i].getName();
            Object value = data.get(fieldName);
            if (value == null) {
                value = FieldHelper.getDefaultValue([i]);
                data.set(fieldNamevalue);
            }
            String val = (String)value;
            if (!item.equals(val)) {
                if (FieldHelper.isList([i])) {
                    ((JComboBox)[i]).setSelectedItem(val);
                } else {
                    ((JTextField)[i]).setText(val);
                }
            }
         }
    }
    
    private void jComboBoxActionPerformed(java.awt.event.ActionEvent evtint index) {
        ResourceConfigData data = this..getData();
        String item = (String)((JComboBox)[index]).getSelectedItem();
        String fieldName = [index].getName();
        String val = data.getString(fieldName);
        if (!item.equals(val))
            data.setString(fieldNameitem);
    }
    
    private void jTextField1KeyReleased(java.awt.event.KeyEvent evtint index) {
        ResourceConfigData data = this..getData();
        String item = (String)((JTextField)[index]).getText();
        String fieldName = [index].getName();
        String val = data.getString(fieldName);
        if (FieldHelper.isInt([index])) {
            try {
                Integer.parseInt(item);
            } catch (NumberFormatException ex) {
                JOptionPane.showMessageDialog(this.getString("MSG_NotNumber"));  //NOI18N
                if (val == null || val.length() == 0)
                    val = FieldHelper.getDefaultValue([index]);
                ((JTextField)[index]).setText(val);
                return;
            }
        }
        String jLabel = (String)this.[index].getText();
        //if (!item.equals(val) && !jLabel.equals(bundle.getString("LBL_" + __JndiName)) ) {  // don't save jndi name here or it will break 'duplicate jndi name validation' in edit mode
        if (!item.equals(val) && jLabel.equals(.getString("LBL_" + )) ) {  
//            item = item + data.getTargetFile();
            data.setString(fieldNameitem);
        }
        if (!item.equals(val)){
            data.setString(fieldNameitem);
            //panel.fireChangeEvent();
        }
        .fireChange(evt.getSource());
    }
    
    public CommonGeneralFinishVisualPanel setFirstTime(boolean first) {
        this. = first;
        return this;
    }
    
    public void initData() {
        refreshFields();
    }
    
     public void setHelper(ResourceConfigHelper helper){
        this. = helper;
        this..getData().setString("jndi-name"helper.getData().getTargetFile()); //NOI18N
        refreshFields();
    }
New to GrepCode? Check out our FAQ X