/* Copyright 2004-2014 Jim Voris
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.qumasoft.guitools.qwin.dialog;
import com.qumasoft.guitools.qwin.operation.OperationAutoAddFiles;
/**
* Auto-add files dialog.
*
* @author Jim Voris
*/
public class AutoAddFilesDialog extends AbstractQWinCommandDialog {
private static final long serialVersionUID = -8551325040484621298L;
private final OperationAutoAddFiles operationAutoAddFiles;
/**
* Create a new auto-add files dialog.
*
* @param parent the parent frame.
* @param modal is this modal.
* @param operation the auto-add operation that will do the work.
*/
public AutoAddFilesDialog(java.awt.Frame parent, boolean modal, OperationAutoAddFiles operation) {
super(parent, modal);
operationAutoAddFiles = operation;
initComponents();
setFont();
center();
}
/**
* 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.
*/
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
okButton = new javax.swing.JButton();
cancelButton = new javax.swing.JButton();
recurseDirectoriesCheckBox = new javax.swing.JCheckBox();
createAllDirectoriesCheckBox = new javax.swing.JCheckBox();
filterFileTypesPanel = new javax.swing.JPanel();
includeExtensionsCheckBox = new javax.swing.JCheckBox();
includeExtensionsTextField = new javax.swing.JTextField();
excludeExtensionsCheckBox = new javax.swing.JCheckBox();
excludeExtensionsTextField = new javax.swing.JTextField();
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
setTitle("Auto Add Files/Directories");
setResizable(false);
addWindowListener(new java.awt.event.WindowAdapter() {
public void windowClosing(java.awt.event.WindowEvent evt) {
closeDialog(evt);
}
});
okButton.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
okButton.setText(" OK ");
okButton.setMaximumSize(new java.awt.Dimension(80, 25));
okButton.setMinimumSize(new java.awt.Dimension(80, 25));
okButton.setPreferredSize(new java.awt.Dimension(80, 25));
okButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
okButtonActionPerformed(evt);
}
});
cancelButton.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
cancelButton.setText("Cancel");
cancelButton.setMaximumSize(new java.awt.Dimension(80, 25));
cancelButton.setMinimumSize(new java.awt.Dimension(80, 25));
cancelButton.setPreferredSize(new java.awt.Dimension(80, 25));
cancelButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cancelButtonActionPerformed(evt);
}
});
recurseDirectoriesCheckBox.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
recurseDirectoriesCheckBox.setText("Recurse workfile directories");
recurseDirectoriesCheckBox.setToolTipText("Enable this to create archives for an entire directory tree.");
recurseDirectoriesCheckBox.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
recurseDirectoriesCheckBoxActionPerformed(evt);
}
});
createAllDirectoriesCheckBox.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
createAllDirectoriesCheckBox.setText("Create All Directories");
createAllDirectoriesCheckBox.setToolTipText("Enable this to always create archive directories, even if there are no controlled files in that directory.");
createAllDirectoriesCheckBox.setEnabled(false);
filterFileTypesPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Filter File Types", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Arial", 0, 12))); // NOI18N
filterFileTypesPanel.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
includeExtensionsCheckBox.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
includeExtensionsCheckBox.setText("Include Extensions:");
includeExtensionsCheckBox.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
includeExtensionsCheckBoxActionPerformed(evt);
}
});
includeExtensionsTextField.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
includeExtensionsTextField.setEnabled(false);
excludeExtensionsCheckBox.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
excludeExtensionsCheckBox.setText("Exclude Extensions:");
excludeExtensionsCheckBox.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
excludeExtensionsCheckBoxActionPerformed(evt);
}
});
excludeExtensionsTextField.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
excludeExtensionsTextField.setEnabled(false);
org.jdesktop.layout.GroupLayout filterFileTypesPanelLayout = new org.jdesktop.layout.GroupLayout(filterFileTypesPanel);
filterFileTypesPanel.setLayout(filterFileTypesPanelLayout);
filterFileTypesPanelLayout.setHorizontalGroup(
filterFileTypesPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(filterFileTypesPanelLayout.createSequentialGroup()
.add(filterFileTypesPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(org.jdesktop.layout.GroupLayout.TRAILING, excludeExtensionsCheckBox, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 188, Short.MAX_VALUE)
.add(org.jdesktop.layout.GroupLayout.TRAILING, includeExtensionsCheckBox, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 188, Short.MAX_VALUE))
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(filterFileTypesPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(org.jdesktop.layout.GroupLayout.TRAILING, includeExtensionsTextField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 200, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.add(org.jdesktop.layout.GroupLayout.TRAILING, excludeExtensionsTextField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 200, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
.addContainerGap())
);
filterFileTypesPanelLayout.setVerticalGroup(
filterFileTypesPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(filterFileTypesPanelLayout.createSequentialGroup()
.add(10, 10, 10)
.add(filterFileTypesPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(includeExtensionsTextField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.add(includeExtensionsCheckBox))
.add(17, 17, 17)
.add(filterFileTypesPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(excludeExtensionsTextField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.add(excludeExtensionsCheckBox))
.add(3, 3, 3))
);
org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createSequentialGroup()
.addContainerGap()
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createSequentialGroup()
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(recurseDirectoriesCheckBox, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 250, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.add(createAllDirectoriesCheckBox, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 250, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
.addContainerGap(181, Short.MAX_VALUE))
.add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
.add(org.jdesktop.layout.GroupLayout.LEADING, filterFileTypesPanel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.add(layout.createSequentialGroup()
.add(okButton, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 100, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 212, Short.MAX_VALUE)
.add(cancelButton, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 100, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
.add(19, 19, 19))))
);
layout.setVerticalGroup(
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createSequentialGroup()
.add(12, 12, 12)
.add(recurseDirectoriesCheckBox)
.add(0, 0, 0)
.add(createAllDirectoriesCheckBox)
.add(7, 7, 7)
.add(filterFileTypesPanel, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.add(5, 5, 5)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(okButton, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.add(cancelButton, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
.add(29, 29, 29))
);
pack();
}// </editor-fold>//GEN-END:initComponents
private void recurseDirectoriesCheckBoxActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_recurseDirectoriesCheckBoxActionPerformed
{//GEN-HEADEREND:event_recurseDirectoriesCheckBoxActionPerformed
// Add your handling code here:
if (getRecurseDirectoriesFlag()) {
createAllDirectoriesCheckBox.setEnabled(true);
} else {
createAllDirectoriesCheckBox.setEnabled(false);
}
}//GEN-LAST:event_recurseDirectoriesCheckBoxActionPerformed
private void excludeExtensionsCheckBoxActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_excludeExtensionsCheckBoxActionPerformed
{//GEN-HEADEREND:event_excludeExtensionsCheckBoxActionPerformed
if (getExcludeExtensionsFlag()) {
includeExtensionsCheckBox.setEnabled(false);
excludeExtensionsTextField.setEnabled(true);
excludeExtensionsTextField.requestFocusInWindow();
} else {
includeExtensionsCheckBox.setEnabled(true);
excludeExtensionsTextField.setEnabled(false);
}
}//GEN-LAST:event_excludeExtensionsCheckBoxActionPerformed
private void includeExtensionsCheckBoxActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_includeExtensionsCheckBoxActionPerformed
{//GEN-HEADEREND:event_includeExtensionsCheckBoxActionPerformed
if (getIncludeExtensionsFlag()) {
includeExtensionsTextField.setEnabled(true);
excludeExtensionsCheckBox.setEnabled(false);
includeExtensionsTextField.requestFocusInWindow();
} else {
includeExtensionsTextField.setEnabled(false);
excludeExtensionsCheckBox.setEnabled(true);
}
}//GEN-LAST:event_includeExtensionsCheckBoxActionPerformed
private void cancelButtonActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_cancelButtonActionPerformed
{//GEN-HEADEREND:event_cancelButtonActionPerformed
closeDialog(null);
}//GEN-LAST:event_cancelButtonActionPerformed
private void okButtonActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_okButtonActionPerformed
{//GEN-HEADEREND:event_okButtonActionPerformed
closeDialog(null);
operationAutoAddFiles.processDialogResult(getRecurseDirectoriesFlag(), getIncludeExtensions(), getExcludeExtensions(), getCreateAllDirectoriesFlag());
}//GEN-LAST:event_okButtonActionPerformed
/**
* Closes the dialog
*/
private void closeDialog(java.awt.event.WindowEvent evt)
{//GEN-FIRST:event_closeDialog
setVisible(false);
dispose();
}//GEN-LAST:event_closeDialog
@Override
public void dismissDialog() {
cancelButtonActionPerformed(null);
}
private boolean getRecurseDirectoriesFlag() {
boolean retVal = false;
Object recurse = recurseDirectoriesCheckBox.getSelectedObjects();
if (recurse != null) {
retVal = true;
}
return retVal;
}
private boolean getCreateAllDirectoriesFlag() {
boolean retVal = false;
Object recurse = createAllDirectoriesCheckBox.getSelectedObjects();
if (recurse != null) {
retVal = true;
}
return retVal;
}
private boolean getIncludeExtensionsFlag() {
boolean retVal = false;
Object include = includeExtensionsCheckBox.getSelectedObjects();
if (include != null) {
retVal = true;
}
return retVal;
}
private boolean getExcludeExtensionsFlag() {
boolean retVal = false;
Object exclude = excludeExtensionsCheckBox.getSelectedObjects();
if (exclude != null) {
retVal = true;
}
return retVal;
}
String getIncludeExtensions() {
String includeExtensions = null;
if (getIncludeExtensionsFlag()) {
includeExtensions = includeExtensionsTextField.getText();
}
return includeExtensions;
}
String getExcludeExtensions() {
String excludeExtensions = null;
if (getExcludeExtensionsFlag()) {
excludeExtensions = excludeExtensionsTextField.getText();
}
return excludeExtensions;
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton cancelButton;
private javax.swing.JCheckBox createAllDirectoriesCheckBox;
private javax.swing.JCheckBox excludeExtensionsCheckBox;
private javax.swing.JTextField excludeExtensionsTextField;
private javax.swing.JPanel filterFileTypesPanel;
private javax.swing.JCheckBox includeExtensionsCheckBox;
private javax.swing.JTextField includeExtensionsTextField;
private javax.swing.JButton okButton;
private javax.swing.JCheckBox recurseDirectoriesCheckBox;
// End of variables declaration//GEN-END:variables
}