|
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.FsImport; import org.netbeans.lib.cvsclient.command.*; import org.netbeans.lib.cvsclient.command.importcmd.*; import java.beans.Customizer; import javax.accessibility.*; /** * Customizer for the import command. * @author mkleint */ public class ImportParamInput extends javax.swing.JPanel implements Customizer { private static final String K_NONE = NbBundle.getBundle(ImportParamInput.class).getString("ImportParamInput.NoSubstitution"); //NOI18N private static final String K_BINARY = NbBundle.getBundle(ImportParamInput.class).getString("ImportParamInput.BinarySubst"); //NOI18N private static final String K_KEYWORD_VALUE = NbBundle.getBundle(ImportParamInput.class).getString("ImportParamInput.KeywordValueSubst"); //NOI18N private static final String K_KEYWORD_VALUE_LOCKER = NbBundle.getBundle(ImportParamInput.class).getString("ImportParamInput.KeywordValueLockerSubst"); //NOI18N private static final String K_KEYWORD = NbBundle.getBundle(ImportParamInput.class).getString("ImportParamInput.Keyword"); //NOI18N private static final String K_VALUE = NbBundle.getBundle(ImportParamInput.class).getString("ImportParamInput.Value"); //NOI18N private static final String K_OLD = NbBundle.getBundle(ImportParamInput.class).getString("ImportParamInput.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 FsImport importCommand; private List commandList; private CustomizerPropChangeSupport support; /** Creates new form LogParamInput */ public ImportParamInput() { initComponents(); initAccessibility(); if (support == null) { support = new CustomizerPropChangeSupport(this); } lblKeyword.setDisplayedMnemonic(bundle.getString("ImportParamInput.lblKeyword.mnemonic").charAt(0)); //NOI18N lblKeyword.setLabelFor(cbKeyword); lblMessage.setDisplayedMnemonic(bundle.getString("ImportParamInput.lblMessage.mnemonic").charAt(0)); //NOI18N lblMessage.setLabelFor(taMessage); lblSourceDir.setDisplayedMnemonic(bundle.getString("ImportParamInput.lblSourceDir.mnemonic").charAt(0)); //NOI18N lblSourceDir.setLabelFor(txSourceDir); lblReleaseTag.setDisplayedMnemonic(bundle.getString("ImportParamInput.lblReleaseTag.mnemonic").charAt(0)); //NOI18N lblReleaseTag.setLabelFor(txReleaseTag); lblVendorTag.setDisplayedMnemonic(bundle.getString("ImportParamInput.lblVendorTag.mnemonic").charAt(0)); //NOI18N lblVendorTag.setLabelFor(txVendorTag); cbBranch.setMnemonic(bundle.getString("ImportParamInput.cbBranch.mnemonic").charAt(0)); //NOI18N 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(); } }; cbKeyword.addActionListener(actionList); cbBranch.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); txBranch.addFocusListener(focusList); txReleaseTag.addFocusListener(focusList); txSourceDir.addFocusListener(focusList); txVendorTag.addFocusListener(focusList); taMessage.getDocument().addDocumentListener(docList); txBranch.getDocument().addDocumentListener(docList); txReleaseTag.getDocument().addDocumentListener(docList); txSourceDir.getDocument().addDocumentListener(docList); txVendorTag.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; lblSourceDir = new javax.swing.JLabel(); txSourceDir = new javax.swing.JTextField(); lblVendorTag = new javax.swing.JLabel(); txVendorTag = new javax.swing.JTextField(); lblReleaseTag = new javax.swing.JLabel(); txReleaseTag = new javax.swing.JTextField(); 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(); cbBranch = new javax.swing.JCheckBox(); txBranch = new javax.swing.JTextField(); setLayout(new java.awt.GridBagLayout()); lblSourceDir.setText(java.util.ResourceBundle.getBundle("org/netbeans/modules/javacvs/customizers/Bundle").getString("ImportParamInput.lblSourceDir.text")); lblSourceDir.setLabelFor(txSourceDir); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 0; gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; gridBagConstraints.insets = new java.awt.Insets(12, 12, 0, 12); add(lblSourceDir, gridBagConstraints); txSourceDir.setPreferredSize(new java.awt.Dimension(70, 21)); txSourceDir.setMinimumSize(new java.awt.Dimension(30, 21)); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 1; gridBagConstraints.gridy = 0; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.insets = new java.awt.Insets(12, 0, 0, 12); add(txSourceDir, gridBagConstraints); lblVendorTag.setText(java.util.ResourceBundle.getBundle("org/netbeans/modules/javacvs/customizers/Bundle").getString("ImportParamInput.lblVendorTag.text")); lblVendorTag.setLabelFor(txVendorTag); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 1; gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; gridBagConstraints.insets = new java.awt.Insets(5, 12, 0, 12); add(lblVendorTag, gridBagConstraints); txVendorTag.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { txVendorTagActionPerformed(evt); } }); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 1; gridBagConstraints.gridy = 1; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.insets = new java.awt.Insets(5, 0, 0, 12); add(txVendorTag, gridBagConstraints); lblReleaseTag.setText(java.util.ResourceBundle.getBundle("org/netbeans/modules/javacvs/customizers/Bundle").getString("ImportParamInput.lblReleaseTag.text")); lblReleaseTag.setLabelFor(txReleaseTag); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 2; gridBagConstraints.gridy = 1; gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; gridBagConstraints.insets = new java.awt.Insets(5, 0, 0, 12); add(lblReleaseTag, gridBagConstraints); txReleaseTag.setPreferredSize(new java.awt.Dimension(70, 21)); txReleaseTag.setMinimumSize(new java.awt.Dimension(30, 21)); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 3; gridBagConstraints.gridy = 1; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.insets = new java.awt.Insets(5, 0, 0, 11); add(txReleaseTag, gridBagConstraints); lblMessage.setText(java.util.ResourceBundle.getBundle("org/netbeans/modules/javacvs/customizers/Bundle").getString("ImportParamInput.lblMessage.text")); lblMessage.setLabelFor(taMessage); 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(lblMessage, gridBagConstraints); spMessage.setPreferredSize(new java.awt.Dimension(100, 60)); spMessage.setViewportView(taMessage); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 3; gridBagConstraints.gridwidth = 4; 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("ImportParamInput.lblKeyword.text")); lblKeyword.setLabelFor(cbKeyword); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 4; gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; gridBagConstraints.insets = new java.awt.Insets(12, 12, 0, 12); add(lblKeyword, gridBagConstraints); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 1; gridBagConstraints.gridy = 4; gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; gridBagConstraints.insets = new java.awt.Insets(12, 0, 0, 0); add(cbKeyword, gridBagConstraints); cbBranch.setText(java.util.ResourceBundle.getBundle("org/netbeans/modules/javacvs/customizers/Bundle").getString("ImportParamInput.cbBranch.text")); cbBranch.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { cbBranchActionPerformed(evt); } }); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 5; gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; gridBagConstraints.insets = new java.awt.Insets(5, 12, 11, 5); add(cbBranch, gridBagConstraints); txBranch.setPreferredSize(new java.awt.Dimension(70, 21)); txBranch.setMinimumSize(new java.awt.Dimension(30, 21)); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 1; gridBagConstraints.gridy = 5; gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; gridBagConstraints.insets = new java.awt.Insets(5, 0, 11, 0); add(txBranch, gridBagConstraints); }//GEN-END:initComponents private void txVendorTagActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txVendorTagActionPerformed // Add your handling code here: }//GEN-LAST:event_txVendorTagActionPerformed private void cbBranchActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbBranchActionPerformed // Add your handling code here: txBranch.setEnabled(cbBranch.isSelected()); }//GEN-LAST:event_cbBranchActionPerformed protected void setData() { if (commandList != null) { Iterator it = commandList.iterator(); FsImport fsCheck = null; while (it.hasNext()) { fsCheck = (FsImport)it.next(); setData(fsCheck); } if (fsCheck != null) { support.firePropertyChange(fsCheck); } } else { setData(importCommand); support.firePropertyChange(importCommand); } } protected void setData(FsImport importCom) { if (importCom == null) return; String message = taMessage.getText(); if (message == null || (message.trim().equals(""))) { //NOI18N importCom.setLogMessage(""); //NOI18N } else { importCom.setLogMessage(message); } importCom.setKeywordSubstitutionOptions(cvsValues[cbKeyword.getSelectedIndex()]); importCom.setModule(txSourceDir.getText()); importCom.setReleaseTag(txReleaseTag.getText()); importCom.setVendorTag(txVendorTag.getText()); if (cbBranch.isSelected()) { importCom.setVendorBranch(txBranch.getText()); } else { importCom.setVendorBranch(null); } } public void getData(FsImport importCom) { if (importCom == null) return; if (importCom.getLogMessage() != null) { taMessage.setText(importCom.getLogMessage()); } else { taMessage.setText(""); //NOI18N } if (importCom.getVendorBranch() != null) { txBranch.setText(importCom.getVendorBranch()); cbBranch.setSelected(true); } else { cbBranch.setSelected(false); txBranch.setText(""); //NOI18N } txBranch.setEnabled(cbBranch.isSelected()); if (importCom.getReleaseTag() != null) { txReleaseTag.setText(importCom.getReleaseTag()); } else { txReleaseTag.setText(""); //NOI18N } if (importCom.getVendorTag() != null) { txVendorTag.setText(importCom.getVendorTag()); } else { txVendorTag.setText(""); //NOI18N } if (importCom.getModule() != null) { txSourceDir.setText(importCom.getModule()); } else { txSourceDir.setText(""); //NOI18N } for (int index = 0; index < cvsValues.length; index++) { if (cvsValues[index] == null) { if (importCom.getKeywordSubstitutionOptions() == null) { cbKeyword.setSelectedIndex(index); return; } } else { if (cvsValues[index].equals(importCom.getKeywordSubstitutionOptions())) { cbKeyword.setSelectedIndex(index); return; } } } support.firePropertyChange(importCom); } /** * The Customizer's setObject method. However the customizer accepts both the * FsDiff instance and a list of FsDiff 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 FsImport) { importCommand = (FsImport)obj; getData(importCommand); commandList = null; } if (obj instanceof List) { commandList = (List)obj; importCommand = null; if (commandList.size() > 0) { FsImport check = (FsImport)commandList.get(0); getData(check); } } } 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.JTextArea taMessage; private javax.swing.JTextField txBranch; private javax.swing.JLabel lblVendorTag; private javax.swing.JTextField txReleaseTag; private javax.swing.JLabel lblReleaseTag; private javax.swing.JLabel lblSourceDir; private javax.swing.JLabel lblKeyword; private javax.swing.JTextField txVendorTag; private javax.swing.JCheckBox cbBranch; private javax.swing.JTextField txSourceDir; 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(ImportParamInput.class); //NOI18N private void initAccessibility() { AccessibleContext context = this.getAccessibleContext(); context.setAccessibleDescription(bundle.getString("ACSD_ImportParamInput")); context = cbBranch.getAccessibleContext(); context.setAccessibleDescription(bundle.getString("ACSD_ImportParamInput.cbBranch")); context = txBranch.getAccessibleContext(); context.setAccessibleDescription(bundle.getString("ACSD_ImportParamInput.txBranch")); context = cbKeyword.getAccessibleContext(); context.setAccessibleDescription(bundle.getString("ACSD_ImportParamInput.cbKeyword")); context = txVendorTag.getAccessibleContext(); context.setAccessibleDescription(bundle.getString("ACSD_ImportParamInput.txVendorTag")); context = txSourceDir.getAccessibleContext(); context.setAccessibleDescription(bundle.getString("ACSD_ImportParamInput.txSourceDir")); context = txReleaseTag.getAccessibleContext(); context.setAccessibleDescription(bundle.getString("ACSD_ImportParamInput.txReleaseTag")); context = taMessage.getAccessibleContext(); context.setAccessibleDescription(bundle.getString("ACSD_ImportParamInput.taMessage")); } } |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2024 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.