|
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-2000 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.FsAdd; import org.netbeans.lib.cvsclient.command.update.*; import org.netbeans.lib.cvsclient.command.*; import org.netbeans.lib.cvsclient.command.add.*; import java.beans.Customizer; import javax.accessibility.*; /** * * @author mkleint * @version */ public class AddParamInput extends javax.swing.JPanel implements Customizer { private static final String K_NONE = NbBundle.getBundle(AddParamInput.class).getString("AddParamInput.NoSubstitution"); //NOI18N private static final String K_BINARY = NbBundle.getBundle(AddParamInput.class).getString("AddParamInput.BinarySubst"); //NOI18N private static final String K_KEYWORD_VALUE = NbBundle.getBundle(AddParamInput.class).getString("AddParamInput.KeywordValueSubst"); //NOI18N private static final String K_KEYWORD_VALUE_LOCKER = NbBundle.getBundle(AddParamInput.class).getString("AddParamInput.KeywordValueLockerSubst"); //NOI18N private static final String K_KEYWORD = NbBundle.getBundle(AddParamInput.class).getString("AddParamInput.Keyword"); //NOI18N private static final String K_VALUE = NbBundle.getBundle(AddParamInput.class).getString("AddParamInput.Value"); //NOI18N private static final String K_OLD = NbBundle.getBundle(AddParamInput.class).getString("AddParamInput.Old"); //NOI18N private Object[] comboValues = new Object[] { K_NONE, K_BINARY, K_KEYWORD_VALUE, K_KEYWORD_VALUE_LOCKER, K_KEYWORD, K_VALUE, K_OLD} ; private KeywordSubstitutionOptions[] cvsValues = new KeywordSubstitutionOptions[] { null, KeywordSubstitutionOptions.BINARY, KeywordSubstitutionOptions.DEFAULT, KeywordSubstitutionOptions.DEFAULT_LOCKER, KeywordSubstitutionOptions.ONLY_KEYWORDS, KeywordSubstitutionOptions.ONLY_VALUES, KeywordSubstitutionOptions.OLD_VALUES }; // needed to set the setRecursive() property private FsAdd addCommand; private List addCommandList; private CustomizerPropChangeSupport support; /** Creates new form LogParamInput */ public AddParamInput() { initComponents(); initAccessibility(); if (support == null) { support = new CustomizerPropChangeSupport(this); } cbRecursive.setMnemonic(bundle.getString("AddParamInput.cbRecursive.mnemonic").charAt(0)); //NOI18N lblKeyword.setDisplayedMnemonic(bundle.getString("AddParamInput.lblKeyword.mnemonic").charAt(0)); //NOI18N lblKeyword.setLabelFor(cbKeyword); lblMessage.setDisplayedMnemonic(bundle.getString("AddParamInput.lblMessage.mnemonic").charAt(0)); //NOI18N lblMessage.setLabelFor(taMessage); cbKeyword.setModel(new DefaultComboBoxModel(comboValues)); cbKeyword.setSelectedIndex(0); //TODO if all files in command are dirs, disable message + keyword subst. java.awt.event.ActionListener actionList = new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { setData(); } }; cbRecursive.addActionListener(actionList); cbKeyword.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(); } }; 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; lblMessage = new javax.swing.JLabel(); spMessage = new javax.swing.JScrollPane(); taMessage = new javax.swing.JTextArea(); lblKeyword = new javax.swing.JLabel(); cbKeyword = new javax.swing.JComboBox(); cbRecursive = new javax.swing.JCheckBox(); lblRecursive = new javax.swing.JLabel(); lblRecursive2 = new javax.swing.JLabel(); setLayout(new java.awt.GridBagLayout()); lblMessage.setText(java.util.ResourceBundle.getBundle("org/netbeans/modules/javacvs/customizers/Bundle").getString("AddParamInput.lblMessage.text")); lblMessage.setLabelFor(taMessage); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; gridBagConstraints.insets = new java.awt.Insets(12, 12, 0, 11); add(lblMessage, gridBagConstraints); spMessage.setPreferredSize(new java.awt.Dimension(100, 60)); spMessage.setViewportView(taMessage); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 1; gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; gridBagConstraints.weightx = 1.0; gridBagConstraints.weighty = 1.0; gridBagConstraints.insets = new java.awt.Insets(2, 12, 0, 11); add(spMessage, gridBagConstraints); lblKeyword.setText(java.util.ResourceBundle.getBundle("org/netbeans/modules/javacvs/customizers/Bundle").getString("AddParamInput.lblKeyword.text")); lblKeyword.setLabelFor(cbKeyword); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 2; gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; gridBagConstraints.insets = new java.awt.Insets(12, 12, 0, 0); add(lblKeyword, gridBagConstraints); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 1; gridBagConstraints.gridy = 2; gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; gridBagConstraints.insets = new java.awt.Insets(12, 12, 0, 12); add(cbKeyword, gridBagConstraints); cbRecursive.setText(java.util.ResourceBundle.getBundle("org/netbeans/modules/javacvs/customizers/Bundle").getString("AddParamInput.cbRecursive.text")); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 3; gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; gridBagConstraints.insets = new java.awt.Insets(12, 12, 0, 11); add(cbRecursive, gridBagConstraints); lblRecursive.setText(java.util.ResourceBundle.getBundle("org/netbeans/modules/javacvs/customizers/Bundle").getString("AddParamInput.lblRecursive.text")); lblRecursive.setLabelFor(cbRecursive); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 4; gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; gridBagConstraints.insets = new java.awt.Insets(0, 12, 0, 11); add(lblRecursive, gridBagConstraints); lblRecursive2.setText(java.util.ResourceBundle.getBundle("org/netbeans/modules/javacvs/customizers/Bundle").getString("AddParamInput.lblRecursive2.text")); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 5; gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; gridBagConstraints.insets = new java.awt.Insets(0, 12, 11, 11); add(lblRecursive2, gridBagConstraints); }//GEN-END:initComponents protected void setData() { if (addCommandList != null) { Iterator it = addCommandList.iterator(); FsAdd fsAdd = null; while (it.hasNext()) { fsAdd = (FsAdd)it.next(); setData(fsAdd); } if (fsAdd != null) { support.firePropertyChange(fsAdd); } } else { setData(addCommand); support.firePropertyChange(addCommand); } } protected void setData(FsAdd addCom) { if (addCom == null) return; String message = taMessage.getText(); if (message == null || (message.trim().equals(""))) { //NOI18N addCom.setMessage(null); } else { addCom.setMessage(message); } addCom.setKeywordSubst(cvsValues[cbKeyword.getSelectedIndex()]); addCom.setRecursive(cbRecursive.isSelected()); } protected void getData(FsAdd addCom) { if (addCom == null) return; cbRecursive.setSelected(addCom.isRecursive()); if (addCom.getMessage() != null) { taMessage.setText(addCom.getMessage()); } else { taMessage.setText(""); //NOI18N } for (int index = 0; index < cvsValues.length; index++) { if (cvsValues[index] == null) { if (addCom.getKeywordSubst() == null) { cbKeyword.setSelectedIndex(index); return; } } else { if (cvsValues[index].equals(addCom.getKeywordSubst())) { cbKeyword.setSelectedIndex(index); return; } } } support.firePropertyChange(addCom); } /** * The Customizer's setObject method. However the customizer accepts both the * FsAdd instance and a list of FsAdd 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 FsAdd) { addCommand = (FsAdd)obj; getData(addCommand); addCommandList = null; } if (obj instanceof List) { addCommandList = (List)obj; addCommand = null; if (addCommandList.size() > 0) { FsAdd add = (FsAdd)addCommandList.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.JLabel lblRecursive; private javax.swing.JTextArea taMessage; private javax.swing.JLabel lblRecursive2; private javax.swing.JCheckBox cbRecursive; private javax.swing.JLabel lblKeyword; private javax.swing.JScrollPane spMessage; private javax.swing.JLabel lblMessage; private javax.swing.JComboBox cbKeyword; // End of variables declaration//GEN-END:variables private static final java.util.ResourceBundle bundle = NbBundle.getBundle(AddParamInput.class); //NOI18N private void initAccessibility() { AccessibleContext context = this.getAccessibleContext(); context.setAccessibleDescription(bundle.getString("ACSD_AddParamInput")); context = cbRecursive.getAccessibleContext(); context.setAccessibleDescription(bundle.getString("ACSD_AddParamInput.cbRecursive")); context = taMessage.getAccessibleContext(); context.setAccessibleDescription(bundle.getString("ACSD_AddParamInput.taMessage")); context = cbKeyword.getAccessibleContext(); context.setAccessibleDescription(bundle.getString("ACSD_AddParamInput.cbKeyword")); } } |
... 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.