/*
 * ResetRunLocationPanel.java
 *
 * Created on August 15, 2006, 11:22 AM
 *
 */
package usda.weru.util;

import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import de.schlichtherle.truezip.file.TFile;
import usda.weru.util.gui.ResetRunLocationPanel_n;
import usda.weru.weps.RunFileData;

/**
 *
 * @author joelevin
 */
public class ResetRunLocationPanel extends ResetRunLocationPanel_n implements PropertyChangeListener {

    private static final long serialVersionUID = 1L;

    /**
     *
     */
    protected WepsFileChooser c_wfc;

    /**
     *
     */
    protected TFile c_default;

    /**
     *
     */
    protected ConfigData c_cd;

    /**
     *
     */
    protected RunFileData c_rfd;

    /** Creates a new instance of ResetRunLocationPanel
     * @param cd
     * @param wfc
     * @param rfd */
    public ResetRunLocationPanel(ConfigData cd, RunFileData rfd, WepsFileChooser wfc) {
        c_cd = cd;

        cd.fireAll(this);

        c_rfd = rfd;

        c_wfc = wfc;

    }

    /**
     *
     * @param evt
     */
    @Override
    protected void resetButtonActionPerformed(java.awt.event.ActionEvent evt) {
        c_wfc.setSelectedFile(c_default);
        c_rfd.setData(RunFileData.RunsLocation, c_default.getAbsolutePath());
        c_wfc.approveSelection();

    }

    /**
     *
     * @param e
     */
    @Override
    public void propertyChange(PropertyChangeEvent e) {
        if (e.getPropertyName().equals(ConfigData.DefaultRunsLocation)) {
            c_default = new TFile(e.getNewValue().toString());
        }
    }

}
