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.Color;
import java.awt.Dialog; 
import java.awt.Dimension; 
import java.awt.FlowLayout; 
import java.awt.GridBagConstraints;  
import java.awt.GridBagLayout; 
import java.awt.Insets; 
import java.awt.event.ActionListener; 
import java.awt.event.ActionEvent; 

import javax.swing.ButtonGroup; 
import javax.swing.JCheckBox; 
import javax.swing.JLabel; 
import javax.swing.JPanel; 
import javax.swing.JRadioButton; 
import javax.swing.JTextField; 

import javax.swing.event.ChangeListener;

import org.openide.DialogDisplayer; 
import org.openide.NotifyDescriptor; 
import org.openide.DialogDescriptor;
import org.openide.util.HelpCtx; 
import org.openide.util.NbBundle; 


/** 
 * Panel where the user enters the settings to create a new Object. 
*
* @author Ana von Klopp 
*/

public class MappingEditor extends JPanel implements ActionListener { 

    // UI Input Components
    private JRadioButton urlRadio; 
    private JRadioButton servletRadio; 
    private JTextField mappingField; 
    private ToolTipCombo servletCombo; 
    private JCheckBox[] cb; 

    private final static boolean debug = false; 

    private Dialog dialog; 
    private DialogDescriptor editDialog;

    private final static String URL = "URL"; 
    private final static String SERVLET = "SERVLET"; 
    private final static String SELECT_SERVLET = "SELECT"; 

    private static FilterMappingData fmd; 
    private static boolean haveNames = true; 
    
    private static boolean OK = false; 

    private static final long serialVersionUID = 4947167720581796971L;
    
    /**  Creates new form MappingEditor */
    public MappingEditor(FilterMappingData fmd, String[] servletNames) { 
	this.fmd = fmd;
    	this.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(MappingEditor.class, "ACSD_filter_mappings_edit")); 
	initComponents(servletNames); 
    }

    boolean isOK() { 
	return OK; 
    } 

    public HelpCtx getHelp () {
        return new HelpCtx("org.netbeans.modules.web.dd.wizards.MappingEditor");
    }
    
    /** This method is called from within the constructor to
     * initialize the form.
     */
    private void initComponents(String[] names) {

	if(debug) log("::initComponents()"); 

	Insets insets = new Insets(4, 20, 4, 0);
	Insets endInsets = new Insets(4, 20, 4, 60);

	// Entity covers entire row
        GridBagConstraints fullRowC = new GridBagConstraints();
        fullRowC.gridx = 0;                               
        fullRowC.gridy = GridBagConstraints.RELATIVE;     
        fullRowC.gridwidth = GridBagConstraints.REMAINDER;
        fullRowC.anchor = GridBagConstraints.WEST;         
        fullRowC.fill = GridBagConstraints.HORIZONTAL; 
        fullRowC.insets = endInsets;

	// Initial label
        GridBagConstraints firstC = new GridBagConstraints();
        firstC.gridx = 0;
        firstC.gridy = GridBagConstraints.RELATIVE;     
        //firstC.weightx = 0.2; 
        firstC.anchor = GridBagConstraints.WEST; 
        firstC.insets = insets;

	// Textfield covers end of row
        GridBagConstraints tflC = new GridBagConstraints();
        tflC.gridx = GridBagConstraints.RELATIVE;     
        tflC.weightx = 0.8; 
        tflC.gridwidth = GridBagConstraints.REMAINDER; 
        tflC.fill = GridBagConstraints.HORIZONTAL; 
        tflC.insets = endInsets;

        setPreferredSize(new Dimension(400, 150));
        this.setLayout(new GridBagLayout());
	
	// Add the component rows
	// 1. Filter name
        JLabel jLname = new JLabel();
	jLname.setText(NbBundle.getMessage(MappingEditor.class, 
					   "LBL_name_filter")); //NOI18N

	JTextField jTFname = new JTextField(25);
	jTFname.setText(fmd.getName()); 
	jTFname.setEnabled(false); 
	jTFname.setBackground(this.getBackground()); 
	jTFname.setDisabledTextColor(Color.black); 


	jLname.setLabelFor(jTFname);
	jLname.setDisplayedMnemonic(NbBundle.getMessage(MappingEditor.class, "LBL_name_filter_mnem").charAt(0));
	jTFname.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(MappingEditor.class,"ACSD_name_filter"));
	    
	this.add(jLname, firstC); 
	this.add(jTFname, tflC); 
	
	// Create the radio buttons: web module button
	urlRadio = new JRadioButton
	    (NbBundle.getMessage(MappingEditor.class, "LBL_url")); // NOI18N
	urlRadio.setMnemonic(NbBundle.getMessage(MappingEditor.class, "LBL_url_mnemonic").charAt(0)); // NOI18N
	urlRadio.addActionListener(this); 
	urlRadio.setActionCommand(URL);
	urlRadio.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(MappingEditor.class, "ACSD_pattern_mapping"));
	
	// Create the radio buttons: directory button
	servletRadio = new JRadioButton(NbBundle.getMessage(MappingEditor.class,"LBL_servlet")); // NOI18N
	servletRadio.setMnemonic(NbBundle.getMessage(MappingEditor.class,"LBL_servlet_mnemonic").charAt(0)); // NOI18N
	servletRadio.addActionListener(this); 
	servletRadio.setActionCommand(SERVLET); // NOI18N
	servletRadio.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(MappingEditor.class, "ACSD_servlet_mapping")); 
	
	// Create the radio button group
	ButtonGroup group = new ButtonGroup(); 
	group.add(urlRadio); 
	group.add(servletRadio); 

	// 2. URL row
	this.add(urlRadio, firstC);		 
	mappingField = new JTextField();
        
        mappingField.getAccessibleContext().setAccessibleName(NbBundle.getMessage(MappingEditor.class, "LBL_url"));
	mappingField.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(MappingEditor.class,"ACSD_pattern_mapping_desc"));
	this.add(mappingField, tflC); 

	// 3. Servlet row
	this.add(servletRadio, firstC); 
	if(names == null || names.length == 0) {
	    names = new String[1]; 
	    names[0] = NbBundle.getMessage(MappingEditor.class, 
					   "LBL_no_servlets"); // 
							       // NOI18N
	    haveNames = false; 
	} 
	servletCombo = new ToolTipCombo(names); 
	servletCombo.setBackground(this.getBackground()); 
	servletCombo.setActionCommand(SELECT_SERVLET);
	servletCombo.addActionListener(this); 
	servletCombo.setEnabled(haveNames);
	servletCombo.getAccessibleContext().setAccessibleName(NbBundle.getMessage(MappingEditor.class, "ACSD_select_servlet")); 
	servletCombo.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(MappingEditor.class, "ACSD_select_servlet_desc")); 

	servletRadio.setEnabled(haveNames);
	this.add(servletCombo, tflC); 


	if(fmd.getType() == FilterMappingData.Type.URL) {
	    urlRadio.setSelected(true); 
	    mappingField.setText(fmd.getPattern()); 
	} 
	else { 
	    servletRadio.setSelected(true); 
	    int size = servletCombo.getModel().getSize();
	    for(int i=0; i
... 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.