package ggh.dialog;

import com.nexes.wizard.WizardPanelDescriptor;
import flanagan.math.Matrix;
import ggh.GGHData;
import javax.swing.JOptionPane;

/**
 *
 * @author Admin
 */
public class Dialog1_Start_Descriptor extends WizardPanelDescriptor {

    public static final String IDENTIFIER = "DIALOG1_START";

    public Dialog1_Start_Descriptor() {
        super(IDENTIFIER, new Dialog1_Start());
    }


    @Override
    public Object getNextPanelDescriptor() {
        Dialog1_Start dialog = (Dialog1_Start) this.getPanelComponent();

        Matrix u_vector = dialog.get_u_matrix();
        Matrix v_vector = dialog.get_v_matrix();
        Matrix w_vector = dialog.get_w_matrix();

        if (u_vector == null || v_vector == null || w_vector == null) {
            return Dialog1_Start_Descriptor.IDENTIFIER;
        }

         return Dialog2_Encrypt_Descriptor.IDENTIFIER; //dalsi dialog   
    }

    @Override
    public void aboutToHidePanel() { //nacteni dat z dialogu pred prepnutim dalsiho
        Dialog1_Start dialog = (Dialog1_Start) this.getPanelComponent();
        GGHData data = GGHData.getInstance();

        Matrix u_vector = dialog.get_u_matrix();
        Matrix v_vector = dialog.get_v_matrix();
        Matrix w_vector = dialog.get_w_matrix();

        if (u_vector == null || v_vector == null || w_vector == null) {
            JOptionPane.showMessageDialog(dialog, "Nejsou zadaná všechna data!", "Chybná data", JOptionPane.ERROR_MESSAGE);
            return;
        }

        data.setU_vector(u_vector);
        data.setV_vector(v_vector);
        data.setW_vector(w_vector);
    }

    @Override
    public Object getBackPanelDescriptor() {
        return null; //predchozi dialog
    }
}
