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-2000 Sun
 * Microsystems, Inc. All Rights Reserved.
 */



package org.netbeans.modules.javacvs.customizers;

import java.util.*;
import javax.swing.*;
import org.openide.util.*;
import java.beans.Customizer;
import javax.accessibility.*;

import org.netbeans.modules.javacvs.FsRemove;


/**
 *
 * @author  mkleint
 * @version
 */
public class RemoveParamInput extends javax.swing.JPanel implements Customizer {
    
    private FsRemove command;
    private List commandList;
    private CustomizerPropChangeSupport support;
    
    /** Creates new form LogParamInput */
    public RemoveParamInput() {
        initComponents();
        initAccessibility();
        if (support == null) {
            support = new CustomizerPropChangeSupport(this);
        }
        cbDeleteBeforeRemove.setMnemonic(bundle.getString("RemoveParamInput.cbDeleteBeforeRemove.mnemonic").charAt(0)); //NOI18N
        cbLocally.setMnemonic(bundle.getString("RemoveParamInput.cbLocally.mnemonic").charAt(0)); //NOI18N
        
        java.awt.event.ActionListener actionList = new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                setData();
            }
        };
        cbDeleteBeforeRemove.addActionListener(actionList);
        cbLocally.addActionListener(actionList);
    }
    
    /** 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 FormEditor.
     */
    private void initComponents() {//GEN-BEGIN:initComponents
        java.awt.GridBagConstraints gridBagConstraints;

        cbLocally = new javax.swing.JCheckBox();
        cbDeleteBeforeRemove = new javax.swing.JCheckBox();

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

        cbLocally.setText(java.util.ResourceBundle.getBundle("org/netbeans/modules/javacvs/customizers/Bundle").getString("RemoveParamInput.cbLocally.text"));
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
        gridBagConstraints.insets = new java.awt.Insets(12, 12, 0, 11);
        add(cbLocally, gridBagConstraints);

        cbDeleteBeforeRemove.setText(java.util.ResourceBundle.getBundle("org/netbeans/modules/javacvs/customizers/Bundle").getString("RemoveParamInput.cbDeleteBeforeRemove.text"));
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 1;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
        gridBagConstraints.weightx = 1.0;
        gridBagConstraints.weighty = 1.0;
        gridBagConstraints.insets = new java.awt.Insets(0, 12, 11, 11);
        add(cbDeleteBeforeRemove, gridBagConstraints);

    }//GEN-END:initComponents
    
    protected void setData() {
        if (commandList != null) {
            Iterator it = commandList.iterator();
            FsRemove fsCheck = null;
            while (it.hasNext()) {
                fsCheck = (FsRemove)it.next();
                setData(fsCheck);
            }
            if (fsCheck != null) {
                support.firePropertyChange(fsCheck);
            }
        } else {
            setData(command);
            support.firePropertyChange(command);
        }
    }
    
    protected void setData(FsRemove removeCom) {
        if (removeCom == null) return;
        removeCom.setRecursive(!cbLocally.isSelected());
        removeCom.setDeleteBeforeRemove(cbDeleteBeforeRemove.isSelected());
    }
    
    protected void getData(FsRemove removeCom) {
        if (removeCom == null) return;
        cbLocally.setSelected(!removeCom.isRecursive());
        cbDeleteBeforeRemove.setSelected(removeCom.isDeleteBeforeRemove());
        support.firePropertyChange(removeCom);
    }
    
    /**
     * The Customizer's setObject method. However the customizer accepts both the
     * FsRemove instance and a list of FsRemove instances. In case of a list,
     * it loads switches from the first comand in row, however sets all the instances.
     */
    
    public void setObject(java.lang.Object obj) {
        if (obj instanceof FsRemove) {
            command = (FsRemove)obj;
            getData(command);
            commandList = null;
        }
        if (obj instanceof List) {
            commandList = (List)obj;
            command = null;
            if (commandList.size() > 0) {
                FsRemove add = (FsRemove)commandList.get(0);
                getData(add);
            }
        }
    }
    
    
    public void removePropertyChangeListener(java.beans.PropertyChangeListener propertyChangeListener) {
        if (support == null) {
            support = new CustomizerPropChangeSupport(this);
        }
        support.removePropertyChangeListener(propertyChangeListener);
    }
    
    public void addPropertyChangeListener(java.beans.PropertyChangeListener propertyChangeListener) {
        if (support == null) {
            support = new CustomizerPropChangeSupport(this);
        }
        support.addPropertyChangeListener(propertyChangeListener);
    }
    protected void firePropertyChange(java.lang.String str, java.lang.Object obj, java.lang.Object obj2) {
        if (support == null) {
            support = new CustomizerPropChangeSupport(this);
        }
        support.firePropertyChange(str, obj, obj2);
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JCheckBox cbLocally;
    private javax.swing.JCheckBox cbDeleteBeforeRemove;
    // End of variables declaration//GEN-END:variables
    
    private static final java.util.ResourceBundle bundle = NbBundle.getBundle(RemoveParamInput.class);   //NOI18N
    
    private void initAccessibility() {
        
        AccessibleContext context = this.getAccessibleContext();
        context.setAccessibleDescription(bundle.getString("ACSD_RemoveParamInput"));
        
        context = cbLocally.getAccessibleContext();
        context.setAccessibleDescription(bundle.getString("ACSD_RemoveParamInput.cblocally"));
        
        context = cbDeleteBeforeRemove.getAccessibleContext();
        context.setAccessibleDescription(bundle.getString("ACSD_RemoveParamInput.cbBeforeRemove"));
        
    }
    
}
... 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.