|
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.vcscore.commands; /** * Dialog that propmts the user for details when saving the output of the command to disk. * * @author Milos Kleint */ import java.util.*; import java.io.*; import javax.swing.*; import org.openide.util.NbBundle; import org.netbeans.modules.vcscore.util.*; public class SaveToFilePanel extends javax.swing.JPanel { public static final int STDOUT_INDEX = 0; public static final int STDERR_INDEX = 1; public static final int DATOUT_INDEX = 2; public static final int DATERR_INDEX = 3; /** Creates new form SaveToFilePanel */ public SaveToFilePanel() { initComponents(); initAccessibility(); } /** 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 Form Editor. */ private void initComponents() {//GEN-BEGIN:initComponents java.awt.GridBagConstraints gridBagConstraints; jPanel1 = new javax.swing.JPanel(); lblFile = new javax.swing.JLabel(); txFile = new javax.swing.JTextField(); btnFile = new javax.swing.JButton(); jPanel2 = new javax.swing.JPanel(); cbStdOut = new javax.swing.JCheckBox(); cbStdErr = new javax.swing.JCheckBox(); cbDataOut = new javax.swing.JCheckBox(); cbDataErr = new javax.swing.JCheckBox(); setLayout(new java.awt.GridBagLayout()); jPanel1.setLayout(new java.awt.GridBagLayout()); lblFile.setText(org.openide.util.NbBundle.getBundle(SaveToFilePanel.class).getString("SaveToFilePanel.lblFile.text")); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.insets = new java.awt.Insets(12, 12, 0, 0); gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; jPanel1.add(lblFile, gridBagConstraints); txFile.setColumns(10); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 1; gridBagConstraints.gridy = 0; gridBagConstraints.gridwidth = 6; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.ipadx = 63; gridBagConstraints.insets = new java.awt.Insets(12, 6, 0, 0); gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; gridBagConstraints.weightx = 1.0; jPanel1.add(txFile, gridBagConstraints); btnFile.setText(org.openide.util.NbBundle.getBundle(SaveToFilePanel.class).getString("SaveToFilePanel.btnFile.text")); btnFile.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnFileActionPerformed(evt); } }); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 7; gridBagConstraints.gridy = 0; gridBagConstraints.insets = new java.awt.Insets(12, 6, 0, 12); gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; jPanel1.add(btnFile, gridBagConstraints); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.weightx = 1.0; add(jPanel1, gridBagConstraints); jPanel2.setLayout(new java.awt.GridBagLayout()); cbStdOut.setText(org.openide.util.NbBundle.getBundle(SaveToFilePanel.class).getString("SaveToFilePanel.cbStdOut")); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.insets = new java.awt.Insets(6, 12, 0, 0); gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; jPanel2.add(cbStdOut, gridBagConstraints); cbStdErr.setText(org.openide.util.NbBundle.getBundle(SaveToFilePanel.class).getString("SaveToFilePanel.cbStdErr")); cbStdErr.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { cbStdErrActionPerformed(evt); } }); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 1; gridBagConstraints.insets = new java.awt.Insets(6, 12, 12, 0); gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; jPanel2.add(cbStdErr, gridBagConstraints); cbDataOut.setText(org.openide.util.NbBundle.getBundle(SaveToFilePanel.class).getString("SaveToFilePanel.cbDataOut")); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 1; gridBagConstraints.insets = new java.awt.Insets(6, 6, 0, 0); gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; gridBagConstraints.weightx = 1.0; jPanel2.add(cbDataOut, gridBagConstraints); cbDataErr.setText(org.openide.util.NbBundle.getBundle(SaveToFilePanel.class).getString("SaveToFilePanel.cbDataErr")); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 1; gridBagConstraints.gridy = 1; gridBagConstraints.insets = new java.awt.Insets(6, 6, 12, 0); gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; gridBagConstraints.weightx = 1.0; jPanel2.add(cbDataErr, gridBagConstraints); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridy = 1; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.weightx = 1.0; add(jPanel2, gridBagConstraints); }//GEN-END:initComponents private void initAccessibility() { getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(SaveToFilePanel.class, "ACSD_SaveToFilePanel.dialog")); lblFile.setDisplayedMnemonic(NbBundle.getMessage(SaveToFilePanel.class, "SaveToFilePanel.lblFile.mnemonic").charAt(0)); lblFile.setLabelFor(txFile); btnFile.setMnemonic(NbBundle.getMessage(SaveToFilePanel.class, "SaveToFilePanel.btnFile.mnemonic").charAt(0)); cbStdOut.setMnemonic(NbBundle.getMessage(SaveToFilePanel.class, "SaveToFilePanel.cbStdOut.mnemonic").charAt(0)); cbStdErr.setMnemonic(NbBundle.getMessage(SaveToFilePanel.class, "SaveToFilePanel.cbStdErr.mnemonic").charAt(0)); cbDataOut.setMnemonic(NbBundle.getMessage(SaveToFilePanel.class, "SaveToFilePanel.cbDataOut.mnemonic").charAt(0)); cbDataErr.setMnemonic(NbBundle.getMessage(SaveToFilePanel.class, "SaveToFilePanel.cbDataErr.mnemonic").charAt(0)); txFile.getAccessibleContext().setAccessibleName(NbBundle.getMessage(SaveToFilePanel.class, "ACSN_SaveToFilePanel.lblFile")); txFile.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(SaveToFilePanel.class, "ACSD_SaveToFilePanel.lblFile")); btnFile.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(SaveToFilePanel.class, "ACSD_SaveToFilePanel.btnFile")); cbStdOut.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(SaveToFilePanel.class, "ACSD_SaveToFilePanel.cbStdOut")); cbStdErr.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(SaveToFilePanel.class, "ACSD_SaveToFilePanel.cbStdErr")); cbDataOut.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(SaveToFilePanel.class, "ACSD_SaveToFilePanel.cbDataOut")); cbDataErr.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(SaveToFilePanel.class, "ACSD_SaveToFilePanel.cbDataErr")); } private void btnFileActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnFileActionPerformed // Add your handling code here: File initDir = new File(txFile.getText()); if (initDir.exists()) { if (initDir.isFile()) { initDir = initDir.getParentFile(); } } else { initDir = new File(System.getProperty("user.home")); //NOI18N } ChooseFileDialog chooseDir = new ChooseFileDialog(new JFrame(), initDir, false); VcsUtilities.centerWindow (chooseDir); // HelpCtx.setHelpIDString (chooseDir.getRootPane (), ); chooseDir.show(); String selected=chooseDir.getSelectedFile(); if( selected==null ){ //D.deb("no directory selected"); // NOI18N return ; } txFile.setText(selected); }//GEN-LAST:event_btnFileActionPerformed private void cbStdErrActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbStdErrActionPerformed // Add your handling code here: }//GEN-LAST:event_cbStdErrActionPerformed /** Getter for property setCurrentPanel. * @return Value of property setCurrentPanel. */ public int getCurrentPanel() { return this.currentPanel; } /** Setter for property setCurrentPanel. * @param setCurrentPanel New value of property setCurrentPanel. */ public void setCurrentPanel(int setCurrentPanel) { this.currentPanel = setCurrentPanel; disSelectAll(); switch (currentPanel) { case STDOUT_INDEX : { cbStdOut.setSelected(true); break; } case STDERR_INDEX : { cbStdErr.setSelected(true); break; } case DATERR_INDEX : { cbDataErr.setSelected(true); break; } case DATOUT_INDEX : { cbDataOut.setSelected(true); break; } } } /** * Set whether the output of a given index is enabled or not. */ public void setEnabledOutput(int outputIndex, boolean enabled) { switch (outputIndex) { case STDOUT_INDEX : { cbStdOut.setEnabled(enabled); break; } case STDERR_INDEX : { cbStdErr.setEnabled(enabled); break; } case DATERR_INDEX : { cbDataErr.setEnabled(enabled); break; } case DATOUT_INDEX : { cbDataOut.setEnabled(enabled); break; } } } private void disSelectAll() { cbDataErr.setSelected(false); cbDataOut.setSelected(false); cbStdOut.setSelected(false); cbStdErr.setSelected(false); } public boolean includeStdOut() { return cbStdOut.isSelected(); } public boolean includeStdErr() { return cbStdErr.isSelected(); } public boolean includeDatOut() { return cbDataOut.isSelected(); } public boolean includeDatErr() { return cbDataErr.isSelected(); } public String getFile() { return txFile.getText(); } // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JButton btnFile; private javax.swing.JCheckBox cbDataErr; private javax.swing.JCheckBox cbDataOut; private javax.swing.JCheckBox cbStdErr; private javax.swing.JCheckBox cbStdOut; private javax.swing.JPanel jPanel1; private javax.swing.JPanel jPanel2; private javax.swing.JLabel lblFile; private javax.swing.JTextField txFile; // End of variables declaration//GEN-END:variables /** Holds value of property setCurrentPanel. */ private int currentPanel; private static final long serialVersionUID = -1047633353725226509L; } |
... 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.