alvinalexander.com | career | drupal | java | mac | mysql | perl | scala | uml | unix  

What this is

This file is included in the DevDaily.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Other links

The source code

/*
 *                 Sun Public License Notice
 * 
 * The contents of this file are subject to the Sun Public License
 * Version 1.0 (the "License"). You may not use this file except in
 * compliance with the License. A copy of the License is available at
 * http://www.sun.com/
 * 
 * The Original Code is NetBeans. The Initial Developer of the Original
 * Code is Sun Microsystems, Inc. Portions Copyright 1997-2004 Sun
 * Microsystems, Inc. All Rights Reserved.
 */

package org.netbeans.modules.web.dd.wizards;

import java.awt.Dialog;
import org.openide.DialogDisplayer;
import org.openide.DialogDescriptor;
import org.openide.NotifyDescriptor;
import org.openide.util.NbBundle;

/**
 *
 * @author  mk115033
 */
public class AttrDialog extends javax.swing.JPanel {
    
    private Dialog dialog = null;
    private DialogDescriptor editDialog = null;
    private String errorMessage = null; 
    private boolean dialogOK = false;
    
    private String title, attrName,attrType;
    private boolean required,rtexpr;
    
    /** Creates new form AttrDialog */
    
    public AttrDialog(String title) {
        initComponents();
        this.title=title;
        this.attrName="";
        this.attrType="java.lang.String";//NOI18N
        this.required=false;
        this.rtexpr=true;
        
    }
    public AttrDialog(String title, String attrName, String attrType, boolean required, boolean rtexpr) {
        initComponents();
        this.title=title;
        this.attrName=attrName;
        this.attrType=attrType;
        this.required=required;
        this.rtexpr=rtexpr;
        jTextField1.setText(attrName);
        jComboBox1.setSelectedItem(attrType);
        jCheckBox1.setSelected(required);
        if (rtexpr) jRadioButton1.setSelected(true);
        else jRadioButton2.setSelected(true);

        
    }
    
    public void showDialog() {

	    editDialog = new DialogDescriptor
		(this, title, true, DialogDescriptor.OK_CANCEL_OPTION,
		 DialogDescriptor.CANCEL_OPTION,
		 new java.awt.event.ActionListener() {
		     public void actionPerformed(java.awt.event.ActionEvent e) {
			 evaluateInput(); 
		     }
		 }); 

	    dialog = DialogDisplayer.getDefault().createDialog(editDialog);
	    //dialog.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(TableRowDialog.class, "ACSD_initparam_edit")); // NOI18N

	    dialog.show();
	    //this.repaint();
    }
    public boolean getDialogOK() {
	return editDialog!=null && DialogDescriptor.OK_OPTION.equals(editDialog.getValue()) && dialogOK; 
    }
    private void evaluateInput() {
	if (editDialog.getValue().equals(NotifyDescriptor.CANCEL_OPTION)) { 
	    //dialog.dispose();
	    dialogOK = false; 
	    return; 
	}
        dialogOK=true;
        this.attrName=jTextField1.getText();
        this.attrType=(String)jComboBox1.getSelectedItem();
        this.required=jCheckBox1.isSelected();
        this.rtexpr=jRadioButton1.isSelected();
    }
    
    public String getAttrName(){
        return attrName;
    }
    public String getAttrType(){
        return attrType;
    }
    public boolean isRequired(){
        return required;
    }
    public boolean isRtexpr(){
        return rtexpr;
    }

    /** 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() {//GEN-BEGIN:initComponents
        java.awt.GridBagConstraints gridBagConstraints;

        buttonGroup1 = new javax.swing.ButtonGroup();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jTextField1 = new javax.swing.JTextField();
        jComboBox1 = new javax.swing.JComboBox();
        jCheckBox1 = new javax.swing.JCheckBox();
        jPanel1 = new javax.swing.JPanel();
        jRadioButton1 = new javax.swing.JRadioButton();
        jRadioButton2 = new javax.swing.JRadioButton();

        setLayout(new java.awt.GridBagLayout());

        getAccessibleContext().setAccessibleDescription(java.util.ResourceBundle.getBundle("org/netbeans/modules/web/dd/wizards/Bundle").getString("A11Y_DESC_AttrDialog"));
        jLabel1.setDisplayedMnemonic(java.util.ResourceBundle.getBundle("org/netbeans/modules/web/dd/wizards/Bundle").getString("A11Y_AttrName_mnem").charAt(0));
        jLabel1.setLabelFor(jTextField1);
        jLabel1.setText(org.openide.util.NbBundle.getMessage(AttrDialog.class, "LBL_AttrName"));
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 0;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        gridBagConstraints.weightx = 1.0;
        gridBagConstraints.insets = new java.awt.Insets(6, 6, 6, 0);
        add(jLabel1, gridBagConstraints);

        jLabel2.setDisplayedMnemonic(java.util.ResourceBundle.getBundle("org/netbeans/modules/web/dd/wizards/Bundle").getString("A11Y_AttrType_mnem").charAt(0));
        jLabel2.setLabelFor(jComboBox1);
        jLabel2.setText(org.openide.util.NbBundle.getMessage(AttrDialog.class, "LBL_AttrType"));
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 1;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        gridBagConstraints.insets = new java.awt.Insets(0, 6, 6, 0);
        add(jLabel2, gridBagConstraints);

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        gridBagConstraints.weightx = 1.0;
        gridBagConstraints.insets = new java.awt.Insets(6, 6, 6, 0);
        add(jTextField1, gridBagConstraints);
        jTextField1.getAccessibleContext().setAccessibleDescription(java.util.ResourceBundle.getBundle("org/netbeans/modules/web/dd/wizards/Bundle").getString("LBL_AttrName"));

        jComboBox1.setEditable(true);
        jComboBox1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "java.lang.String", "boolean", "char", "byte", "short", "int", "long", "float", "double", "java.lang.Boolean", "java.lang.Character", "java.lang.Byte", "java.lang.Short", "java.lang.Integer", "java.lang.Long", "java.lang.Float", "java.lang.Double", "java.lang.Object" }));
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 1;
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        gridBagConstraints.weightx = 1.0;
        gridBagConstraints.insets = new java.awt.Insets(0, 6, 6, 0);
        add(jComboBox1, gridBagConstraints);
        jComboBox1.getAccessibleContext().setAccessibleDescription(java.util.ResourceBundle.getBundle("org/netbeans/modules/web/dd/wizards/Bundle").getString("LBL_AttrType"));

        jCheckBox1.setMnemonic(java.util.ResourceBundle.getBundle("org/netbeans/modules/web/dd/wizards/Bundle").getString("A11Y_AttrRequired_mnem").charAt(0));
        jCheckBox1.setText(org.openide.util.NbBundle.getMessage(AttrDialog.class, "OPT_attrRequired"));
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 2;
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        gridBagConstraints.insets = new java.awt.Insets(0, 6, 6, 0);
        add(jCheckBox1, gridBagConstraints);
        jCheckBox1.getAccessibleContext().setAccessibleDescription(java.util.ResourceBundle.getBundle("org/netbeans/modules/web/dd/wizards/Bundle").getString("OPT_attrRequired"));

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        gridBagConstraints.weightx = 3.0;
        add(jPanel1, gridBagConstraints);

        jRadioButton1.setMnemonic(java.util.ResourceBundle.getBundle("org/netbeans/modules/web/dd/wizards/Bundle").getString("A11Y_AttrRequestTime_mnem").charAt(0));
        jRadioButton1.setSelected(true);
        jRadioButton1.setText(org.openide.util.NbBundle.getMessage(AttrDialog.class, "OPT_attrRequestTime"));
        buttonGroup1.add(jRadioButton1);
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 3;
        gridBagConstraints.gridwidth = 2;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        gridBagConstraints.insets = new java.awt.Insets(0, 6, 0, 6);
        add(jRadioButton1, gridBagConstraints);
        jRadioButton1.getAccessibleContext().setAccessibleDescription(java.util.ResourceBundle.getBundle("org/netbeans/modules/web/dd/wizards/Bundle").getString("OPT_attrRequestTime"));

        jRadioButton2.setMnemonic(java.util.ResourceBundle.getBundle("org/netbeans/modules/web/dd/wizards/Bundle").getString("A11Y_AttrJspTranslationTime_mnem").charAt(0));
        jRadioButton2.setText(org.openide.util.NbBundle.getMessage(AttrDialog.class, "OPT_attrTranslationTime"));
        buttonGroup1.add(jRadioButton2);
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 4;
        gridBagConstraints.gridwidth = 2;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        gridBagConstraints.insets = new java.awt.Insets(0, 6, 6, 6);
        add(jRadioButton2, gridBagConstraints);
        jRadioButton2.getAccessibleContext().setAccessibleDescription(java.util.ResourceBundle.getBundle("org/netbeans/modules/web/dd/wizards/Bundle").getString("OPT_attrTranslationTime"));

    }//GEN-END:initComponents
    
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.ButtonGroup buttonGroup1;
    private javax.swing.JCheckBox jCheckBox1;
    private javax.swing.JComboBox jComboBox1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JRadioButton jRadioButton1;
    private javax.swing.JRadioButton jRadioButton2;
    private javax.swing.JTextField jTextField1;
    // End of variables declaration//GEN-END:variables
    
}
... this post is sponsored by my books ...

#1 New Release!

FP Best Seller

 

new blog posts

 

Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.