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.commit;

import javax.swing.*;
import javax.accessibility.*;
import javax.swing.ButtonGroup;
import org.netbeans.modules.javacvs.commands.CvsCommit;
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 org.netbeans.modules.javacvs.customizers.CustomizerPropChangeSupport;
import org.openide.util.*;



/**
 * commit message dialog for simple (default switches only) mode..
 * @author  mkleint
 */
public class NbSimpleCommitParamInput extends JPanel implements Customizer {
    private FsCommit currentFSCommand;
    private List commitCommandList;
    
    private CustomizerPropChangeSupport support;
    
    /** Creates new form LogParamInput */
    public NbSimpleCommitParamInput() {
        initComponents();
        initAccessibility();
        if (support == null) {
            support = new CustomizerPropChangeSupport(this);
        }
        lblMessage.setDisplayedMnemonic(bundle.getString("CommitParamInput.lblMessage.mnemonic").charAt(0)); //NOI18N
        lblMessage.setLabelFor(taMessage);
        java.awt.event.FocusAdapter focus = new java.awt.event.FocusAdapter() {
            public void focusGained(java.awt.event.FocusEvent evt) {
                SwingUtilities.invokeLater(new Runnable() {
                   public void run() {
                       taMessage.requestFocus();
                   }
                });
            }
        };
        this.addFocusListener(focus);                
        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();
                }
        };
        taMessage.addFocusListener(focusList);
        taMessage.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;

        spMessage = new javax.swing.JScrollPane();
        taMessage = new javax.swing.JTextArea();
        lblMessage = new javax.swing.JLabel();

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

        spMessage.setPreferredSize(new java.awt.Dimension(350, 200));
        spMessage.setViewportView(taMessage);

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 1;
        gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
        gridBagConstraints.weightx = 1.0;
        gridBagConstraints.weighty = 1.0;
        gridBagConstraints.insets = new java.awt.Insets(2, 12, 11, 11);
        add(spMessage, gridBagConstraints);

        lblMessage.setText(java.util.ResourceBundle.getBundle("org/netbeans/modules/cvsclient/commands/commit/Bundle").getString("CommitParamInput.lblMessage.text"));
        lblMessage.setLabelFor(taMessage);
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        gridBagConstraints.insets = new java.awt.Insets(12, 12, 0, 11);
        add(lblMessage, gridBagConstraints);

    }//GEN-END:initComponents
    

  protected void setData() {
      if (commitCommandList != null) {
          Iterator it = commitCommandList.iterator();
          FsCommit fsCheck = null;
          while (it.hasNext()) {
              fsCheck = (FsCommit)it.next();
              setData(fsCheck);
          }
          if (fsCheck != null) {
              support.firePropertyChange(fsCheck);
          }
      } else {
          setData(currentFSCommand);
          support.firePropertyChange(currentFSCommand);
      }
  }
    
    public void setData(FsCommit updCom) {
        if (updCom == null) return;
        updCom.setMessage(taMessage.getText());
    }
    
    
    public void getData(FsCommit updCom) {
        if (updCom == null) return;
        if (updCom.getMessage() != null) {
            taMessage.setText(updCom.getMessage());
        } else {
            taMessage.setText(""); //NOI18N
        }
    }
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JTextArea taMessage;
    private javax.swing.JScrollPane spMessage;
    private javax.swing.JLabel lblMessage;
    // End of variables declaration//GEN-END:variables
    
    private static final ResourceBundle bundle = NbBundle.getBundle(NbSimpleCommitParamInput.class);   //NOI18N
    
    private void initAccessibility() {
        
        AccessibleContext context = this.getAccessibleContext();
        context.setAccessibleDescription(bundle.getString("ACSD_CommitParamInput"));
        
        context = taMessage.getAccessibleContext();
        context.setAccessibleDescription(bundle.getString("ACSD_CommitParamInput.taMessage"));
        
    }
    public void setObject(java.lang.Object obj) {
        if (obj instanceof FsCommit) {
            currentFSCommand = (FsCommit)obj;
            commitCommandList = null;
            getData(currentFSCommand);
        }
        if (obj instanceof List) {
            commitCommandList = (List)obj;
            currentFSCommand = null;
            if (commitCommandList.size() > 0) {
                FsCommit check = (FsCommit)commitCommandList.get(0);
                getData(check);
            }
        }
    }
    
/*    public void setObject(java.lang.Object obj) {
        if (obj instanceof FileSystemCommandImpl) {
            FileSystemCommandImpl impl = (FileSystemCommandImpl)obj;
            FileSystemCommand command = impl.getOuterClassInstance();
            if (command instanceof CvsCommit) {
                CvsCommit newCommand = (CvsCommit)command;
                if (currentFSCommand == null) {
                    currentFSCommand = newCommand;
                } else {
                    String message = newCommand.getMessage();
                    CvsCommit com = (CvsCommit)FsCommandFactory.getInstance().getCommand(newCommand.getClass(), true);
                    boolean ok = newCommand.copySwitchesFrom(com);
                    currentFSCommand = newCommand;
                    currentFSCommand.setMessage(message);
                }
                getData(currentFSCommand);
            }
        }
    }
 */
    
    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);
    }
    
}
... 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.