/*
 * 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.util.wepsFileChooser2.WepsFileChooser2;
import usda.weru.weps.RunFileData;

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

    private static final long serialVersionUID = 1L;

    protected WepsFileChooser2 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, WepsFileChooser2 wfc) {
        c_cd = cd;
        cd.fireAll(this);
        c_rfd = rfd;
        c_wfc = wfc;

    }

    @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();
        
    }

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

}
