se.trixon.toolbox.dbtext.DbTextTopComponent.java Source code

Java tutorial

Introduction

Here is the source code for se.trixon.toolbox.dbtext.DbTextTopComponent.java

Source

/*
 * Copyright 2015 Patrik Karlsson.
 *
 * 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 se.trixon.toolbox.dbtext;

import java.awt.event.FocusAdapter;
import java.io.File;
import java.io.IOException;
import java.util.Calendar;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JFileChooser;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.SystemUtils;
import org.netbeans.api.settings.ConvertAsProperties;
import org.openide.util.NbBundle;
import org.openide.windows.*;
import se.trixon.almond.dialogs.FileChooserPanel;
import se.trixon.almond.dialogs.Message;
import se.trixon.almond.dictionary.Dict;
import se.trixon.almond.icon.Pict;
import se.trixon.toolbox.core.Toolbox;
import se.trixon.toolbox.core.base.ToolTopComponent;

/**
 * Checksum top component.
 */
@ConvertAsProperties(dtd = "-//se.trixon.toolbox.dbText//DbText//EN", autostore = false)
@TopComponent.Description(preferredID = "DbTextTopComponent",
        //iconBase="SET/PATH/TO/ICON/HERE",
        persistenceType = TopComponent.PERSISTENCE_ALWAYS)
@TopComponent.Registration(mode = "editor", openAtStartup = false)
public final class DbTextTopComponent extends ToolTopComponent
        implements FileChooserPanel.FileChooserButtonListener, OperationListener {

    private static final int ICON_SIZE = TOOLBAR_ICON_SIZE;
    private final DbTextController mController;
    private final String[] mDefaultSeparators = new String[] { ";", "|" };
    private final String[] mDefaultQualifiers = new String[] { "", "'", "\"" };
    private File mDestination;
    private final Options mOptions = Options.INSTANCE;

    public DbTextTopComponent() {
        mBundle = NbBundle.getBundle(DbTextTopComponent.class);
        mToolName = mBundle.getString("Tool-Name");
        initComponents();
        setName(mToolName);
        mController = new DbTextController(this);
        init();
        initSourceChooser();
        initDestChooser();
    }

    @Override
    public void onFileChooserCancel(FileChooserPanel fileChooserPanel) {
        // nvm
    }

    @Override
    public void onFileChooserCheckBoxChange(FileChooserPanel fileChooserPanel, boolean isSelected) {
        // nvm
    }

    @Override
    public void onFileChooserDrop(FileChooserPanel fileChooserPanel) {
        if (fileChooserPanel == sourceChooserPanel) {
        }
    }

    @Override
    public void onFileChooserOk(FileChooserPanel fileChooserPanel, File file) {
        JFileChooser fileChooser = fileChooserPanel.getFileChooser();

        if (fileChooserPanel == sourceChooserPanel) {
            if (fileChooser.isMultiSelectionEnabled()) {
                String paths = StringUtils.join(fileChooser.getSelectedFiles(), SystemUtils.PATH_SEPARATOR);
                fileChooserPanel.setPath(paths);
            }
        }
    }

    @Override
    public void onFileChooserPreSelect(FileChooserPanel fileChooserPanel) {
        if (fileChooserPanel == sourceChooserPanel) {
            final String[] paths = sourceChooserPanel.getPath().split(SystemUtils.PATH_SEPARATOR);
            File[] files = new File[paths.length];

            for (int i = 0; i < files.length; i++) {
                files[i] = new File(paths[i]);
            }

            sourceChooserPanel.getFileChooser().setSelectedFiles(files);
        }
    }

    @Override
    public void onOperationFailed(String message) {
    }

    @Override
    public void onOperationFinished(String message) {
        startButton.setEnabled(true);
        makeBusy(false);

        new Thread(() -> {
            Message.information(Dict.OPERATION_COMPLETED.getString(), message);
        }).start();
    }

    @Override
    public void onOperationInterrupted() {
        startButton.setEnabled(true);

        makeBusy(false);
    }

    @Override
    public void onOperationLog(String message) {
        appendLog(message);
    }

    @Override
    public void onOperationProcessingStarted() {
    }

    @Override
    public void onOperationStarted() {
        startButton.setEnabled(false);

        makeBusy(true);
    }

    private void init() {
        startButton.setIcon(Pict.Actions.ARROW_RIGHT.get(ICON_SIZE));
        startButton.setToolTipText(Dict.START.getString());

        followLinksCheckBox.setEnabled(!SystemUtils.IS_OS_WINDOWS);
        recursiveCheckBox.setSelected(mOptions.isSourceRecursive());
        followLinksCheckBox.setSelected(mOptions.isSourceFollowLinks());

        fromSeparatorComboBox.setModel(new DefaultComboBoxModel(mDefaultSeparators));
        toSeparatorComboBox.setModel(new DefaultComboBoxModel(mDefaultSeparators));

        fromQualifierComboBox.setModel(new DefaultComboBoxModel(mDefaultQualifiers));
        toQualifierComboBox.setModel(new DefaultComboBoxModel(mDefaultQualifiers));

        if (SystemUtils.IS_OS_WINDOWS) {
            windowsRadioButton.setSelected(true);
        } else {
            unixRadioButton.setSelected(true);
            followLinksCheckBox.setToolTipText("");
        }
    }

    private void initSourceChooser() {
        sourceChooserPanel.setPath(mOptions.getSourcePaths());
        sourceChooserPanel.setDropMode(FileChooserPanel.DropMode.MULTI);
        sourceChooserPanel.setMode(JFileChooser.FILES_AND_DIRECTORIES);
        sourceChooserPanel.getFileChooser().setMultiSelectionEnabled(true);
        sourceChooserPanel.setButtonListener(this);
        sourceChooserPanel.getTextField().addFocusListener(new FocusAdapter() {
            @Override
            public void focusLost(java.awt.event.FocusEvent evt) {
                saveSourcePath();
            }
        });

        sourceChooserPanel.getTextField().getDocument().addDocumentListener(new DocumentListener() {
            @Override
            public void changedUpdate(DocumentEvent e) {
                saveSourcePath();
            }

            @Override
            public void insertUpdate(DocumentEvent e) {
                saveSourcePath();
            }

            @Override
            public void removeUpdate(DocumentEvent e) {
                saveSourcePath();
            }
        });
    }

    private void initDestChooser() {
        File dest = new File(FileUtils.getTempDirectory(), "dbText");
        try {
            FileUtils.forceMkdir(dest);
        } catch (IOException ex) {
            // nvm
        }

        if (dest.isDirectory()) {
            destChooserPanel.setPath(dest.getAbsolutePath());
        }

        destChooserPanel.setMode(JFileChooser.DIRECTORIES_ONLY);
        destChooserPanel.setButtonListener(this);
    }

    private void saveSourcePath() {
        mOptions.setSourcePaths(sourceChooserPanel.getPath());
    }

    /**
     * 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() {
        java.awt.GridBagConstraints gridBagConstraints;

        lineSeparatorButtonGroup = new javax.swing.ButtonGroup();
        toolBar = new javax.swing.JToolBar();
        startButton = new javax.swing.JButton();
        filler1 = new javax.swing.Box.Filler(new java.awt.Dimension(0, 0), new java.awt.Dimension(0, 0),
                new java.awt.Dimension(32767, 0));
        sourceChooserPanel = new se.trixon.almond.dialogs.FileChooserPanel();
        destChooserPanel = new se.trixon.almond.dialogs.FileChooserPanel();
        optionsPanel = new javax.swing.JPanel();
        sourcePanel = new javax.swing.JPanel();
        recursiveCheckBox = new javax.swing.JCheckBox();
        followLinksCheckBox = new javax.swing.JCheckBox();
        separatorPanel = new javax.swing.JPanel();
        separatorOriginalLabel = new javax.swing.JLabel();
        separatorCheckBox = new javax.swing.JCheckBox();
        fromSeparatorComboBox = new javax.swing.JComboBox();
        toSeparatorComboBox = new javax.swing.JComboBox();
        qualifierPanel = new javax.swing.JPanel();
        qualifierOriginalLabel = new javax.swing.JLabel();
        qualifierCheckBox = new javax.swing.JCheckBox();
        fromQualifierComboBox = new javax.swing.JComboBox();
        toQualifierComboBox = new javax.swing.JComboBox();
        lineSeparatorPanel = new javax.swing.JPanel();
        unixRadioButton = new javax.swing.JRadioButton();
        windowsRadioButton = new javax.swing.JRadioButton();
        jScrollPane1 = new javax.swing.JScrollPane();
        jTable1 = new javax.swing.JTable();

        toolBar.setFloatable(false);

        startButton.setFocusable(false);
        startButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                startButtonActionPerformed(evt);
            }
        });
        toolBar.add(startButton);
        toolBar.add(filler1);

        sourceChooserPanel.setHeader(Dict.SOURCE.getString());

        destChooserPanel.setHeader(Dict.DESTINATION.getString());

        optionsPanel.setLayout(new java.awt.GridLayout());

        sourcePanel.setBorder(javax.swing.BorderFactory.createTitledBorder(Dict.SOURCE.getString()));

        org.openide.awt.Mnemonics.setLocalizedText(recursiveCheckBox, Dict.SUBDIRECTORIES.getString());
        recursiveCheckBox.setFocusable(false);
        recursiveCheckBox.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        recursiveCheckBox.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                recursiveCheckBoxActionPerformed(evt);
            }
        });

        org.openide.awt.Mnemonics.setLocalizedText(followLinksCheckBox, Dict.FOLLOW_LINKS.getString());
        followLinksCheckBox.setToolTipText(org.openide.util.NbBundle.getMessage(DbTextTopComponent.class,
                "DbTextTopComponent.followLinksCheckBox.toolTipText")); // NOI18N
        followLinksCheckBox.setFocusable(false);
        followLinksCheckBox.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        followLinksCheckBox.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                followLinksCheckBoxActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout sourcePanelLayout = new javax.swing.GroupLayout(sourcePanel);
        sourcePanel.setLayout(sourcePanelLayout);
        sourcePanelLayout.setHorizontalGroup(sourcePanelLayout
                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(sourcePanelLayout.createSequentialGroup().addContainerGap()
                        .addGroup(sourcePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(followLinksCheckBox, javax.swing.GroupLayout.DEFAULT_SIZE,
                                        javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addComponent(recursiveCheckBox, javax.swing.GroupLayout.DEFAULT_SIZE,
                                        javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                        .addContainerGap()));
        sourcePanelLayout
                .setVerticalGroup(sourcePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(sourcePanelLayout.createSequentialGroup().addContainerGap()
                                .addComponent(recursiveCheckBox)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(followLinksCheckBox).addContainerGap()));

        optionsPanel.add(sourcePanel);

        separatorPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(Dict.SEPARATOR.getString()));

        org.openide.awt.Mnemonics.setLocalizedText(separatorOriginalLabel, Dict.ORIGINAL.getString());

        org.openide.awt.Mnemonics.setLocalizedText(separatorCheckBox, Dict.CHANGE_TO.getString());
        separatorCheckBox.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                separatorCheckBoxActionPerformed(evt);
            }
        });

        fromSeparatorComboBox.setEditable(true);
        fromSeparatorComboBox.setModel(
                new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
        fromSeparatorComboBox.setPreferredSize(new java.awt.Dimension(60, 28));

        toSeparatorComboBox.setEditable(true);
        toSeparatorComboBox.setModel(
                new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
        toSeparatorComboBox.setEnabled(false);
        toSeparatorComboBox.setMaximumSize(new java.awt.Dimension(60, 32767));
        toSeparatorComboBox.setMinimumSize(new java.awt.Dimension(60, 28));
        toSeparatorComboBox.setPreferredSize(new java.awt.Dimension(60, 28));

        javax.swing.GroupLayout separatorPanelLayout = new javax.swing.GroupLayout(separatorPanel);
        separatorPanel.setLayout(separatorPanelLayout);
        separatorPanelLayout.setHorizontalGroup(
                separatorPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(separatorPanelLayout.createSequentialGroup().addContainerGap()
                                .addGroup(separatorPanelLayout
                                        .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                        .addComponent(fromSeparatorComboBox, javax.swing.GroupLayout.PREFERRED_SIZE,
                                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                                javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addComponent(separatorOriginalLabel))
                                .addGap(18, 18, 18)
                                .addGroup(separatorPanelLayout
                                        .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                        .addComponent(separatorCheckBox).addComponent(toSeparatorComboBox,
                                                javax.swing.GroupLayout.PREFERRED_SIZE,
                                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                                javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));
        separatorPanelLayout.setVerticalGroup(
                separatorPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(separatorPanelLayout.createSequentialGroup()
                                .addGroup(separatorPanelLayout
                                        .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                        .addComponent(separatorCheckBox).addComponent(separatorOriginalLabel))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(separatorPanelLayout
                                        .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                        .addComponent(toSeparatorComboBox, javax.swing.GroupLayout.PREFERRED_SIZE,
                                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                                javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addComponent(fromSeparatorComboBox, javax.swing.GroupLayout.PREFERRED_SIZE,
                                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                                javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addGap(0, 0, 0)));

        optionsPanel.add(separatorPanel);

        qualifierPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(Dict.QUALIFIER.getString()));

        org.openide.awt.Mnemonics.setLocalizedText(qualifierOriginalLabel, Dict.ORIGINAL.getString());

        org.openide.awt.Mnemonics.setLocalizedText(qualifierCheckBox, Dict.CHANGE_TO.getString());
        qualifierCheckBox.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                qualifierCheckBoxActionPerformed(evt);
            }
        });

        fromQualifierComboBox.setEditable(true);
        fromQualifierComboBox.setModel(
                new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
        fromQualifierComboBox.setMaximumSize(new java.awt.Dimension(60, 32767));
        fromQualifierComboBox.setMinimumSize(new java.awt.Dimension(60, 28));
        fromQualifierComboBox.setPreferredSize(new java.awt.Dimension(60, 28));

        toQualifierComboBox.setEditable(true);
        toQualifierComboBox.setModel(
                new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
        toQualifierComboBox.setEnabled(false);
        toQualifierComboBox.setMaximumSize(new java.awt.Dimension(60, 32767));
        toQualifierComboBox.setMinimumSize(new java.awt.Dimension(60, 28));
        toQualifierComboBox.setPreferredSize(new java.awt.Dimension(60, 28));

        javax.swing.GroupLayout qualifierPanelLayout = new javax.swing.GroupLayout(qualifierPanel);
        qualifierPanel.setLayout(qualifierPanelLayout);
        qualifierPanelLayout.setHorizontalGroup(
                qualifierPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(qualifierPanelLayout.createSequentialGroup().addContainerGap()
                                .addGroup(qualifierPanelLayout
                                        .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                        .addComponent(fromQualifierComboBox, javax.swing.GroupLayout.PREFERRED_SIZE,
                                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                                javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addComponent(qualifierOriginalLabel))
                                .addGap(18, 18, 18)
                                .addGroup(qualifierPanelLayout
                                        .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                        .addComponent(qualifierCheckBox).addComponent(toQualifierComboBox,
                                                javax.swing.GroupLayout.PREFERRED_SIZE,
                                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                                javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));
        qualifierPanelLayout.setVerticalGroup(
                qualifierPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(qualifierPanelLayout.createSequentialGroup()
                                .addGroup(qualifierPanelLayout
                                        .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                        .addComponent(qualifierCheckBox).addComponent(qualifierOriginalLabel))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(qualifierPanelLayout
                                        .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                        .addComponent(toQualifierComboBox, javax.swing.GroupLayout.PREFERRED_SIZE,
                                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                                javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addComponent(fromQualifierComboBox, javax.swing.GroupLayout.PREFERRED_SIZE,
                                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                                javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addGap(0, 0, 0)));

        optionsPanel.add(qualifierPanel);

        lineSeparatorPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(Dict.LINE_SEPARATOR.getString()));

        lineSeparatorButtonGroup.add(unixRadioButton);
        org.openide.awt.Mnemonics.setLocalizedText(unixRadioButton, "UNIX"); // NOI18N

        lineSeparatorButtonGroup.add(windowsRadioButton);
        org.openide.awt.Mnemonics.setLocalizedText(windowsRadioButton, "Windows"); // NOI18N

        javax.swing.GroupLayout lineSeparatorPanelLayout = new javax.swing.GroupLayout(lineSeparatorPanel);
        lineSeparatorPanel.setLayout(lineSeparatorPanelLayout);
        lineSeparatorPanelLayout.setHorizontalGroup(
                lineSeparatorPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(
                        javax.swing.GroupLayout.Alignment.TRAILING,
                        lineSeparatorPanelLayout.createSequentialGroup().addContainerGap()
                                .addGroup(lineSeparatorPanelLayout
                                        .createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                        .addComponent(windowsRadioButton, javax.swing.GroupLayout.DEFAULT_SIZE,
                                                javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                        .addComponent(unixRadioButton, javax.swing.GroupLayout.DEFAULT_SIZE,
                                                javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                                .addContainerGap()));
        lineSeparatorPanelLayout.setVerticalGroup(
                lineSeparatorPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(lineSeparatorPanelLayout.createSequentialGroup().addContainerGap()
                                .addComponent(unixRadioButton)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(windowsRadioButton).addContainerGap()));

        optionsPanel.add(lineSeparatorPanel);

        jTable1.setModel(
                new javax.swing.table.DefaultTableModel(
                        new Object[][] { { null, null, null, null }, { null, null, null, null },
                                { null, null, null, null }, { null, null, null, null } },
                        new String[] { "Title 1", "Title 2", "Title 3", "Title 4" }));
        jScrollPane1.setViewportView(jTable1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addComponent(toolBar, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
                        Short.MAX_VALUE)
                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                .addComponent(jScrollPane1)
                                .addComponent(sourceChooserPanel, javax.swing.GroupLayout.DEFAULT_SIZE,
                                        javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addComponent(destChooserPanel, javax.swing.GroupLayout.Alignment.LEADING,
                                        javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
                                        Short.MAX_VALUE)
                                .addGroup(javax.swing.GroupLayout.Alignment.LEADING,
                                        layout.createSequentialGroup()
                                                .addComponent(optionsPanel, javax.swing.GroupLayout.PREFERRED_SIZE,
                                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                                .addGap(0, 0, Short.MAX_VALUE)))
                        .addContainerGap()));
        layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                        .addComponent(toolBar, javax.swing.GroupLayout.PREFERRED_SIZE,
                                javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(sourceChooserPanel, javax.swing.GroupLayout.PREFERRED_SIZE,
                                javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(destChooserPanel, javax.swing.GroupLayout.PREFERRED_SIZE,
                                javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(optionsPanel, javax.swing.GroupLayout.PREFERRED_SIZE,
                                javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 115, Short.MAX_VALUE)
                        .addContainerGap()));
    }// </editor-fold>//GEN-END:initComponents

    private void startButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_startButtonActionPerformed
        mLogBuilder = new StringBuilder();
        mDestination = new File(destChooserPanel.getPath());

        if (mInputOutput != null) {
            mInputOutput.closeInputOutput();
        }

        mInputOutput = IOProvider.getDefault().getIO(mToolName, false);
        mInputOutput.select();

        appendLog(Toolbox.getDefaultDateFormat().format(Calendar.getInstance().getTime()) + "\n");

        Operation operation = new Operation(this, mDestination);
        operation.start();
    }//GEN-LAST:event_startButtonActionPerformed

    private void separatorCheckBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_separatorCheckBoxActionPerformed
        toSeparatorComboBox.setEnabled(separatorCheckBox.isSelected());
    }//GEN-LAST:event_separatorCheckBoxActionPerformed

    private void qualifierCheckBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_qualifierCheckBoxActionPerformed
        toQualifierComboBox.setEnabled(qualifierCheckBox.isSelected());
    }//GEN-LAST:event_qualifierCheckBoxActionPerformed

    private void recursiveCheckBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_recursiveCheckBoxActionPerformed
        mOptions.setSourceRecursive(recursiveCheckBox.isSelected());
    }//GEN-LAST:event_recursiveCheckBoxActionPerformed

    private void followLinksCheckBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_followLinksCheckBoxActionPerformed
        mOptions.setSourceFollowLinks(followLinksCheckBox.isSelected());
    }//GEN-LAST:event_followLinksCheckBoxActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private se.trixon.almond.dialogs.FileChooserPanel destChooserPanel;
    private javax.swing.Box.Filler filler1;
    private javax.swing.JCheckBox followLinksCheckBox;
    private javax.swing.JComboBox fromQualifierComboBox;
    private javax.swing.JComboBox fromSeparatorComboBox;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTable jTable1;
    private javax.swing.ButtonGroup lineSeparatorButtonGroup;
    private javax.swing.JPanel lineSeparatorPanel;
    private javax.swing.JPanel optionsPanel;
    private javax.swing.JCheckBox qualifierCheckBox;
    private javax.swing.JLabel qualifierOriginalLabel;
    private javax.swing.JPanel qualifierPanel;
    private javax.swing.JCheckBox recursiveCheckBox;
    private javax.swing.JCheckBox separatorCheckBox;
    private javax.swing.JLabel separatorOriginalLabel;
    private javax.swing.JPanel separatorPanel;
    private se.trixon.almond.dialogs.FileChooserPanel sourceChooserPanel;
    private javax.swing.JPanel sourcePanel;
    private javax.swing.JButton startButton;
    private javax.swing.JComboBox toQualifierComboBox;
    private javax.swing.JComboBox toSeparatorComboBox;
    private javax.swing.JToolBar toolBar;
    private javax.swing.JRadioButton unixRadioButton;
    private javax.swing.JRadioButton windowsRadioButton;
    // End of variables declaration//GEN-END:variables

    @Override
    public void componentOpened() {
    }

    @Override
    public void componentClosed() {
    }

    void writeProperties(java.util.Properties p) {
        p.setProperty("version", "1.0");
    }

    void readProperties(java.util.Properties p) {
        String version = p.getProperty("version");
    }
}