package com.uvigo.tMaestro.SCOCreator.templates;

import com.uvigo.mhp.*;
import java.awt.*;
import java.awt.event.*;
import org.havi.ui.*;

public class page1_3 extends Page
 {
     public page1_3()
 {
     try
 {
     initComponents();
     courseDelegate.setPage(this);
     }
     catch (Exception e)
 {
     e.printStackTrace();
     }
     }
     
     /** 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() {
        mainContextManager = new com.uvigo.mhp.ContextManager();
        courseDelegate = new com.uvigo.mhp.CourseDelegate();
        hScrollPane1 = new com.uvigo.mhp.ui.HScrollPane();
        hMultiPanel1 = new com.uvigo.mhp.ui.HMultiPanel();
        hScrollBar1 = new com.uvigo.mhp.ui.HScrollBar();
        hButton1 = new com.uvigo.mhp.ui.HButton();
        hButton2 = new com.uvigo.mhp.ui.HButton();
        hLabel1 = new com.uvigo.mhp.ui.HLabel();
        hPanel1 = new com.uvigo.mhp.ui.HPanel();
        hLabel2 = new com.uvigo.mhp.ui.HLabel();
        hButton3 = new com.uvigo.mhp.ui.HButton();
        hLabel3 = new com.uvigo.mhp.ui.HLabel();
        hButton4 = new com.uvigo.mhp.ui.HButton();
        hLabel4 = new com.uvigo.mhp.ui.HLabel();
        hButton5 = new com.uvigo.mhp.ui.HButton();
        test1 = new com.uvigo.mhp.Test();

        courseDelegate.setPage(this);

        setLayout(null);

        setBackground(java.awt.Color.orange);
        setBackgroundImageURL("file:/c:/teleco/demo/fondos/fondo3.jpg");
        setOpaque(true);
        hScrollPane1.setVerticalScrollControl(hScrollBar1);
        hMultiPanel1.setLayout(null);

        hMultiPanel1.setBackground(new java.awt.Color(204, 255, 204));
        hMultiPanel1.setOpaque(true);
        hScrollPane1.setViewportView(hMultiPanel1);

        add(hScrollPane1);
        hScrollPane1.setBounds(10, 10, 470, 310);

        hScrollBar1.setBackground(new java.awt.Color(255, 204, 204));
        hScrollBar1.setBackgroundMode(org.havi.ui.HVisible.BACKGROUND_FILL);
        hScrollBar1.setContentFile("file:/c:/teleco/demo/italia/cosa.xml");
        hScrollBar1.setForeground(new java.awt.Color(0, 153, 153));
        hScrollBar1.setName("scroll");
        hScrollBar1.setOrientation(org.havi.ui.HOrientable.ORIENT_TOP_TO_BOTTOM);
        hScrollBar1.setValue(0);
        add(hScrollBar1);
        hScrollBar1.setBounds(490, 10, 160, 190);

        hButton1.setContentFile("file:/c:/teleco/demo/botones/previous.xml");
        hButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                hButton1ActionPerformed(evt);
            }
        });

        add(hButton1);
        hButton1.setBounds(10, 330, 60, 52);

        hButton2.setContentFile("file:/c:/teleco/demo/botones/next.xml");
        hButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                hButton2ActionPerformed(evt);
            }
        });

        add(hButton2);
        hButton2.setBounds(80, 330, 60, 52);

        hLabel1.setBackground(java.awt.Color.white);
        hLabel1.setBackgroundMode(org.havi.ui.HVisible.BACKGROUND_FILL);
        hLabel1.setFont(new java.awt.Font("Monotype Corsiva", 0, 48));
        hLabel1.setLabel("???");
        add(hLabel1);
        hLabel1.setBounds(530, 210, 120, 110);

        hPanel1.setLayout(null);

        hPanel1.setBackground(java.awt.Color.magenta);
        hPanel1.setOpaque(true);
        hLabel2.setLabel("Comprobar respuestas");
        hPanel1.add(hLabel2);
        hLabel2.setBounds(2, 2, 358, 190);

        hButton3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                hButton3ActionPerformed(evt);
            }
        });

        hPanel1.add(hButton3);
        hButton3.setBounds(360, 2, 358, 190);

        hLabel3.setLabel("Mostrar soluci\u00f3n");
        hPanel1.add(hLabel3);
        hLabel3.setBounds(2, 192, 358, 190);

        hButton4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                hButton4ActionPerformed(evt);
            }
        });

        hPanel1.add(hButton4);
        hButton4.setBounds(360, 192, 358, 190);

        hLabel4.setLabel("Comenzar de nuevo");
        hPanel1.add(hLabel4);
        hLabel4.setBounds(2, 382, 358, 190);

        hButton5.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                hButton5ActionPerformed(evt);
            }
        });

        hPanel1.add(hButton5);
        hButton5.setBounds(360, 382, 358, 190);

        add(hPanel1);
        hPanel1.setBounds(250, 330, 410, 150);

        test1.setName("test1");
        test1.setQuestionsContainer(hMultiPanel1);
        test1.addTestListener(new com.uvigo.mhp.TestListener() {
            public void testInitialized(com.uvigo.mhp.TestEvent param0) {
            }
            public void testPassed(com.uvigo.mhp.TestEvent param0) {
                test1TestPassed(param0);
            }
            public void testFailed(com.uvigo.mhp.TestEvent param0) {
                test1TestFailed(param0);
            }
            public void testChecked(com.uvigo.mhp.TestEvent param0) {
            }
        });

        add(test1);
        test1.setBounds(180, 360, 0, 0);

    }
    // </editor-fold>//GEN-END:initComponents

    private void test1TestFailed(com.uvigo.mhp.TestEvent param0) {//GEN-FIRST:event_test1TestFailed
        System.out.println("Test suspenso");
        courseDelegate.lock();
    }//GEN-LAST:event_test1TestFailed

    private void test1TestPassed(com.uvigo.mhp.TestEvent param0) {//GEN-FIRST:event_test1TestPassed
        System.out.println("Test superado");
        courseDelegate.unlock();
    }//GEN-LAST:event_test1TestPassed

    private void hButton5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_hButton5ActionPerformed
        test1.reset();
        hLabel1.setLabel("???");
    }//GEN-LAST:event_hButton5ActionPerformed

    private void hButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_hButton4ActionPerformed
        test1.showCorrection();
    }//GEN-LAST:event_hButton4ActionPerformed

    private void hButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_hButton3ActionPerformed
        test1.checkAnswers();
        hLabel1.setLabel(test1.countCorrectAnswers()+"/"+test1.countQuestions());
    }//GEN-LAST:event_hButton3ActionPerformed

    private void hButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_hButton2ActionPerformed
        hMultiPanel1.gotoNextContext();
    }//GEN-LAST:event_hButton2ActionPerformed

    private void hButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_hButton1ActionPerformed
        hMultiPanel1.gotoPreviousContext();
    }//GEN-LAST:event_hButton1ActionPerformed
     
     
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private com.uvigo.mhp.CourseDelegate courseDelegate;
    private com.uvigo.mhp.ui.HButton hButton1;
    private com.uvigo.mhp.ui.HButton hButton2;
    private com.uvigo.mhp.ui.HButton hButton3;
    private com.uvigo.mhp.ui.HButton hButton4;
    private com.uvigo.mhp.ui.HButton hButton5;
    private com.uvigo.mhp.ui.HLabel hLabel1;
    private com.uvigo.mhp.ui.HLabel hLabel2;
    private com.uvigo.mhp.ui.HLabel hLabel3;
    private com.uvigo.mhp.ui.HLabel hLabel4;
    private com.uvigo.mhp.ui.HMultiPanel hMultiPanel1;
    private com.uvigo.mhp.ui.HPanel hPanel1;
    private com.uvigo.mhp.ui.HScrollBar hScrollBar1;
    private com.uvigo.mhp.ui.HScrollPane hScrollPane1;
    private com.uvigo.mhp.ContextManager mainContextManager;
    private com.uvigo.mhp.Test test1;
    // End of variables declaration//GEN-END:variables
     
     
     public static void main(String[] args)
 {
     HSceneFactory hsFactory = HSceneFactory.getInstance();
     HScene scene = hsFactory.getBestScene(new HSceneTemplate());
     scene.setLayout(new BorderLayout());
     
     scene.add(new page1_3());
     
     scene.addWindowListener(new WindowAdapter()
 {
     public void windowClosing(WindowEvent e)
 {
     System.exit(0);
     }
     }
     );
     scene.setVisible(true);
     scene.validate();
     }
}
