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.cvsclient.commands.tag;

import javax.swing.*;
import javax.swing.ButtonGroup;
import org.netbeans.modules.javacvs.commands.CvsTag;
import java.io.File;
import java.beans.Customizer;
import java.beans.PropertyChangeListener;
import java.util.*;
import org.netbeans.modules.javacvs.util.*;
import org.netbeans.modules.javacvs.*;
import org.openide.util.HelpCtx;
import org.netbeans.modules.javacvs.commands.*;
import org.netbeans.modules.cvsclient.FsCommandFactory;
import javax.accessibility.*;
import org.openide.util.*;

import org.netbeans.modules.javacvs.customizers.CustomizerPropChangeSupport;


/**
 * commit message dialog for simple (default switches only) mode..
 * @author  mkleint
 */
public class NbSimpleTagParamInput extends JPanel implements Customizer {

    FsTag command;
    private List commandList;
    private CustomizerPropChangeSupport support;    
    
    /** Creates new form LogParamInput */
    public NbSimpleTagParamInput() {
        initComponents ();
        initAccessibility();
        lblTag.setDisplayedMnemonic(bundle.getString("TagInfoPanel.lblMessage.mnemonic").charAt(0)); // NOI18N
        lblTag.setLabelFor(txTag);

        if (support == null) {
          support = new CustomizerPropChangeSupport(this);   
        }
        java.awt.event.ActionListener actionList = new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                setData();
            }
        };
        txTag.addActionListener(actionList);        
        java.awt.event.FocusAdapter focusList = new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                setData();
            }
        };  
        javax.swing.event.DocumentListener docList = new javax.swing.event.DocumentListener() {
                public void insertUpdate(javax.swing.event.DocumentEvent e) {
                    setData();
                }
                public void removeUpdate(javax.swing.event.DocumentEvent e) {
                    setData();
                }
                public void changedUpdate(javax.swing.event.DocumentEvent e) {
                    setData();
                }
        };

        txTag.addFocusListener(focusList);
        txTag.getDocument().addDocumentListener(docList);
    }

    /** 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;

        lblTag = new javax.swing.JLabel();
        txTag = new javax.swing.JTextField();

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

        lblTag.setText(java.util.ResourceBundle.getBundle("org/netbeans/modules/cvsclient/commands/tag/Bundle").getString("TagInfoPanel.lblMessage.text"));
        lblTag.setLabelFor(txTag);
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
        gridBagConstraints.weighty = 1.0;
        gridBagConstraints.insets = new java.awt.Insets(14, 12, 11, 12);
        add(lblTag, gridBagConstraints);

        txTag.setPreferredSize(new java.awt.Dimension(100, 21));
        txTag.setMinimumSize(new java.awt.Dimension(40, 21));
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
        gridBagConstraints.weightx = 1.0;
        gridBagConstraints.weighty = 1.0;
        gridBagConstraints.insets = new java.awt.Insets(12, 0, 11, 11);
        add(txTag, gridBagConstraints);

    }//GEN-END:initComponents

    protected void setData() {
        if (commandList != null) {
            Iterator it = commandList.iterator();
            FsTag fsCheck = null;
            while (it.hasNext()) {
                fsCheck = (FsTag)it.next();
                setData(fsCheck);
            }
            if (fsCheck != null) {
                support.firePropertyChange(fsCheck);
            }
        } else {
            setData(command);
            support.firePropertyChange(command);
        }
    }    
  
  public void setData(FsTag updCom) {
      if (updCom == null) return;
      updCom.setTag(txTag.getText());
  }
  
  
  public void getData(FsTag updCom) {
      if (updCom == null) return;
      if (updCom.getTag() != null) {
          txTag.setText(updCom.getTag());
      } else {
          txTag.setText(""); // NOI18N
      }
  }
  
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JTextField txTag;
    private javax.swing.JLabel lblTag;
    // End of variables declaration//GEN-END:variables

  private static final ResourceBundle bundle = NbBundle.getBundle(NbSimpleTagParamInput.class);   // NOI18N

  private void initAccessibility() {
        
        AccessibleContext context = this.getAccessibleContext();
        context.setAccessibleDescription(bundle.getString("ACSD_NbSimpleTagParamInput"));
        
        context = txTag.getAccessibleContext();
        context.setAccessibleDescription(bundle.getString("ACSD_NbSimpleTagParamInput.txTag"));
        
  }
  
  public void removePropertyChangeListener(PropertyChangeListener propertyChangeListener) {
      if (support == null) {
        support = new CustomizerPropChangeSupport(this);   
      }
      support.removePropertyChangeListener(propertyChangeListener);
  }
 
    /**
     * The Customizer's setObject method. However the customizer accepts both the
     * FsTag instance and a list of FsTag 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 FsTag) {
            command = (FsTag)obj;
            getData(command);
            commandList = null;
        }
        if (obj instanceof List) {
            commandList = (List)obj;
            command = null;
            if (commandList.size() > 0) {
                FsTag add = (FsTag)commandList.get(0);
                getData(add);
            }
        }
    }  

/*    public void setObject(java.lang.Object obj) {
      if (obj instanceof FileSystemCommandImpl) {
          FileSystemCommandImpl impl = (FileSystemCommandImpl)obj;
          FileSystemCommand command = impl.getOuterClassInstance();
          if (command instanceof CvsTag) {
              CvsTag newCommand = (CvsTag)command;
              if (currentFSCommand == null) {
                  currentFSCommand = newCommand;
              } else {
                  String tag = newCommand.getTag();
                  CvsTag com = (CvsTag)FsCommandFactory.getInstance().getCommand(newCommand.getClass(), true);
                  boolean ok = newCommand.copySwitchesFrom(com);
                  currentFSCommand = newCommand;
                  currentFSCommand.setTag(tag);
              }
              getData(currentFSCommand);
          }
      }
  }
 */
  
  
  public void addPropertyChangeListener(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);
  }  
  
}
... 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.