package nl.fontys.sofa.limo.view.wizard.leg.normal;
import java.util.ArrayList;
import javax.swing.event.ChangeListener;
import nl.fontys.sofa.limo.domain.component.leg.Leg;
import nl.fontys.sofa.limo.view.custom.panel.ProceduresPanel;
import nl.fontys.sofa.limo.view.util.LIMOResourceBundle;
import org.openide.WizardDescriptor;
import org.openide.WizardValidationException;
import org.openide.util.HelpCtx;
/**
* Add Procedure to leg
*
* @author Pascal Lindner
*/
public class ProceduresLegTypeWizard implements WizardDescriptor.Panel<WizardDescriptor>, WizardDescriptor.ValidatingPanel<WizardDescriptor> {
private ProceduresPanel component;
private Leg leg;
public ProceduresLegTypeWizard() {
}
@Override
public ProceduresPanel getComponent() {
if (component == null) {
component = new ProceduresPanel();
}
return component;
}
@Override
public HelpCtx getHelp() {
return HelpCtx.DEFAULT_HELP;
}
@Override
public boolean isValid() {
return true;
}
@Override
public void addChangeListener(ChangeListener l) {
}
@Override
public void removeChangeListener(ChangeListener l) {
}
@Override
public void readSettings(WizardDescriptor wiz) {
leg = (Leg) wiz.getProperty("leg");
getComponent().update(new ArrayList(leg.getProcedures()));
}
@Override
public void storeSettings(WizardDescriptor wiz) {
leg.setProcedures(getComponent().getProcedures());
}
@Override
public void validate() throws WizardValidationException {
if (component.getProcedures().isEmpty()) {
throw new WizardValidationException(null, null, LIMOResourceBundle.getString("VALUE_NOT_SET2", LIMOResourceBundle.getString("PROCEDURES")));
}
}
}