|
What this is
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-2003 Sun * Microsystems, Inc. All Rights Reserved. */ package org.netbeans.modules.javacvs.customizers; import java.util.*; import javax.swing.*; import org.openide.util.*; import org.netbeans.modules.javacvs.FsAnnotate; import org.netbeans.lib.cvsclient.command.annotate.*; import org.netbeans.lib.cvsclient.command.*; import java.beans.Customizer; import javax.accessibility.*; /** * * @author mkleint */ public class AnnotateParamInput extends javax.swing.JPanel implements Customizer { private FsAnnotate annotateCommand; private List annotateCommandList; private CustomizerPropChangeSupport support; /** Creates new form LogParamInput */ public AnnotateParamInput() { initComponents(); initAccessibility(); if (support == null) { support = new CustomizerPropChangeSupport(this); } cbDates.setMnemonic(bundle.getString("AnnotateParamInput.cbDates.mnemonic").charAt(0)); //NOI18N cbForceAnnotate.setMnemonic(bundle.getString("AnnotateParamInput.cbForceAnnotate.mnemonic").charAt(0)); //NOI18N cbLocal.setMnemonic(bundle.getString("AnnotateParamInput.cbLocal.mnemonic").charAt(0)); //NOI18N cbRevision.setMnemonic(bundle.getString("AnnotateParamInput.cbRevision.mnemonic").charAt(0)); //NOI18N txRevision.setEnabled(false); txDates.setEnabled(false); cbForceAnnotate.setEnabled(false); java.awt.event.ActionListener actionList = new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { setData(); } }; cbDates.addActionListener(actionList); cbForceAnnotate.addActionListener(actionList); cbLocal.addActionListener(actionList); cbRevision.addActionListener(actionList); txDates.addActionListener(actionList); txRevision.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(); } }; txDates.addFocusListener(focusList); txRevision.addFocusListener(focusList); txDates.getDocument().addDocumentListener(docList); txRevision.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; cbLocal = new javax.swing.JCheckBox(); cbDates = new javax.swing.JCheckBox(); txDates = new javax.swing.JTextField(); cbRevision = new javax.swing.JCheckBox(); txRevision = new javax.swing.JTextField(); cbForceAnnotate = new javax.swing.JCheckBox(); setLayout(new java.awt.GridBagLayout()); cbLocal.setText(java.util.ResourceBundle.getBundle("org/netbeans/modules/javacvs/customizers/Bundle").getString("AnnotateParamInput.cbLocal.text")); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 0; gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; gridBagConstraints.weightx = 1.0; gridBagConstraints.insets = new java.awt.Insets(12, 12, 0, 11); add(cbLocal, gridBagConstraints); cbDates.setText(java.util.ResourceBundle.getBundle("org/netbeans/modules/javacvs/customizers/Bundle").getString("AnnotateParamInput.cbDates.text")); cbDates.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { cbDatesActionPerformed(evt); } }); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 1; gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; gridBagConstraints.insets = new java.awt.Insets(0, 12, 0, 0); add(cbDates, gridBagConstraints); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 1; gridBagConstraints.gridy = 1; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.ipadx = 80; gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; gridBagConstraints.insets = new java.awt.Insets(0, 5, 0, 0); add(txDates, gridBagConstraints); cbRevision.setText(java.util.ResourceBundle.getBundle("org/netbeans/modules/javacvs/customizers/Bundle").getString("AnnotateParamInput.cbRevision.text")); cbRevision.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { cbRevisionActionPerformed(evt); } }); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 2; gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; gridBagConstraints.insets = new java.awt.Insets(0, 12, 11, 0); add(cbRevision, gridBagConstraints); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 1; gridBagConstraints.gridy = 2; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.ipadx = 80; gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; gridBagConstraints.insets = new java.awt.Insets(2, 5, 11, 0); add(txRevision, gridBagConstraints); cbForceAnnotate.setText(java.util.ResourceBundle.getBundle("org/netbeans/modules/javacvs/customizers/Bundle").getString("AnnotateParamInput.cbForceAnnotate.text")); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 2; gridBagConstraints.gridy = 2; gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; gridBagConstraints.weighty = 1.0; gridBagConstraints.insets = new java.awt.Insets(0, 12, 11, 11); add(cbForceAnnotate, gridBagConstraints); }//GEN-END:initComponents private void cbRevisionActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbRevisionActionPerformed // Add your handling code here: enableRevision(); }//GEN-LAST:event_cbRevisionActionPerformed private void cbDatesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbDatesActionPerformed // Add your handling code here: enableDates(); }//GEN-LAST:event_cbDatesActionPerformed private void enableDates() { txDates.setEnabled(cbDates.isSelected()); if (cbDates.isSelected()) { cbForceAnnotate.setEnabled(true); } else { if (!cbRevision.isSelected()) { cbForceAnnotate.setSelected(false); cbForceAnnotate.setEnabled(false); setData(); } } } private void enableRevision() { txRevision.setEnabled(cbRevision.isSelected()); if (cbRevision.isSelected()) { cbForceAnnotate.setEnabled(true); } else { if (!cbDates.isSelected()) { cbForceAnnotate.setSelected(false); cbForceAnnotate.setEnabled(false); setData(); } } } protected void setData() { if (annotateCommandList != null) { Iterator it = annotateCommandList.iterator(); FsAnnotate fsAnn = null; while (it.hasNext()) { fsAnn = (FsAnnotate)it.next(); setData(fsAnn); } if (fsAnn != null) { support.firePropertyChange(fsAnn); } } else { setData(annotateCommand); support.firePropertyChange(annotateCommand); } } protected void setData(FsAnnotate updCom) { if (updCom == null) return; updCom.setRecursive(!cbLocal.isSelected()); if (cbDates.isSelected()) { updCom.setAnnotateByDate(txDates.getText().trim()); } else { updCom.setAnnotateByDate(null); } if (cbRevision.isSelected()) { updCom.setAnnotateByRevision(txRevision.getText().trim()); } else { updCom.setAnnotateByRevision(null); } updCom.setUseHeadIfNotFound(cbForceAnnotate.isSelected()); } protected void getData(FsAnnotate updCom) { if (updCom == null) return; cbLocal.setSelected(!updCom.isRecursive()); cbForceAnnotate.setSelected(updCom.isUseHeadIfNotFound()); String updByDate = updCom.getAnnotateByDate(); if (updByDate != null && (!updByDate.equals(""))) { //NOI18N cbDates.setSelected(true); txDates.setText(updByDate); } else { cbDates.setSelected(false); txDates.setText(""); //NOI18N } String updByRev = updCom.getAnnotateByRevision(); if (updByRev != null && (!updByRev.equals(""))) { //NOI18N cbRevision.setSelected(true); txRevision.setText(updByRev); } else { cbRevision.setSelected(false); txRevision.setText(""); //NOI18N } enableDates(); enableRevision(); support.firePropertyChange(updCom); } /** * The Customizer's setObject method. However the customizer accepts both the * FsAnnotate instance and a list of FsAnnotate 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 FsAnnotate) { annotateCommand = (FsAnnotate)obj; annotateCommandList = null; getData(annotateCommand); } if (obj instanceof List) { annotateCommandList = (List)obj; annotateCommand = null; if (annotateCommandList.size() > 0) { FsAnnotate ann = (FsAnnotate)annotateCommandList.get(0); getData(ann); } } } 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 cbLocal; private javax.swing.JTextField txDates; private javax.swing.JCheckBox cbRevision; private javax.swing.JTextField txRevision; private javax.swing.JCheckBox cbDates; private javax.swing.JCheckBox cbForceAnnotate; // End of variables declaration//GEN-END:variables private static final java.util.ResourceBundle bundle = NbBundle.getBundle(AnnotateParamInput.class); //NOI18N private void initAccessibility() { AccessibleContext context = this.getAccessibleContext(); context.setAccessibleDescription(bundle.getString("ACSD_AnnotateParamInput")); context = cbLocal.getAccessibleContext(); context.setAccessibleDescription(bundle.getString("ACSD_AnnotateParamInput.cbLocal")); context = cbDates.getAccessibleContext(); context.setAccessibleDescription(bundle.getString("ACSD_AnnotateParamInput.cbDates")); context = txDates.getAccessibleContext(); context.setAccessibleDescription(bundle.getString("ACSD_AnnotateParamInput.txDates")); context = cbRevision.getAccessibleContext(); context.setAccessibleDescription(bundle.getString("ACSD_AnnotateParamInput.cbRevision")); context = txRevision.getAccessibleContext(); context.setAccessibleDescription(bundle.getString("ACSD_AnnotateParamInput.txRevision")); context = cbForceAnnotate.getAccessibleContext(); context.setAccessibleDescription(bundle.getString("ACSD_AnnotateParamInput.cbForceAnnotate")); } } |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
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.