/*
 *  userAction.java
 * 
 *  RELOAD Editor - An IMS Metadata, Content Packaging and Learning Design tool 
 *  with ADAPTATION AT ACTIVITY LEVEL
 *
 *  Copyright (c) 2006 Miguel Fern�ndez Lores
 *
 *  Technical Contact:
 *  Miguel Fernandez Lores
 *  e-mail: tucias@hotmail.com
 *
 */

package uk.ac.reload.editor.scormadaptive.rules.user;

import uk.ac.reload.editor.scormadaptive.rules.jdom.criterion.Criterion;
import uk.ac.reload.editor.scormadaptive.rules.jdom.rule.adaptationCriterion;
import uk.ac.reload.editor.scormadaptive.rules.syntax.Activity;
import uk.ac.reload.editor.scormadaptive.rules.syntax.Rule;
import java.util.ArrayList;
import javax.swing.DefaultListModel;

/**
 * Class that contains everything relating to user actions
 * to go to previus state when the user
 * clicks BACK button
 *
 * @author  lagar
 * @version 0.2 
 */
public class userAction {
    
    private Integer iType;
    
    public final static int                 CREATE = 0;
    public final static int                 ANDCRI = 1;
    public final static int                   ORCRI = 2;
    public final static int                 NOTCRI = 3;
    public final static int                    DONE = 4;
    public final static int                  SELECT = 5;
    public final static int                    SHOW = 6;
    public final static int                 ANDACT = 7;
    public final static int                   ORACT = 8;
    public final static int                 XORACT = 9;
    public final static int                 NOTACT = 10;
    public final static int   CREATECOMPLEX = 11;
  
    //La lista de criterios usados
    private ArrayList<adaptationCriterion> oaCri;
    
    //El texto que habia
    private String sOldText;
    
    //Las LogicalExpression seleccionadas en _ruleActionList
    //O los indices seleccionados en los combos de seleccion de parametro
    private int[] oIndices = null;
    
    /** Creates a new instance of userAction */
    //public userAction(String old, ArrayList<adaptationCriterion> cri, ArrayList<Activity> act, DefaultListModel model, int tipo) {
    public userAction(String old, ArrayList<adaptationCriterion> cri, int tipo) {
        iType = tipo;
        //oAct = act;
        oaCri = cri;
        //oModel = model;
        sOldText = old;
    }
    
    public userAction(Rule rs, int tipo){
        iType = tipo;
        //oAct = new ArrayList<Activity>(rs.getActivities());
        oaCri = rs.getCriteriaUsed();
        //oModel = new DefaultListModel();
        //for (int i = 0; i< rs.getListModelSize(); i++){
            //oModel.add(i,rs.getListModel().get(i));
        //}
        sOldText = null;
    }
    
    public userAction(Rule rs, String oldText, int tipo){
        iType = tipo;
        //oAct = new ArrayList<Activity>(rs.getActivities());
        oaCri = rs.getCriteriaUsed();
        //oModel = new DefaultListModel();
        //for (int i = 0; i< rs.getListModelSize(); i++){
            //oModel.add(i,rs.getListModel().get(i));
        //}
        sOldText = new String(oldText);
    }
    
    public void actualizeIndices(int[] indices) {
        oIndices = indices;
    }

    public void actualizeIndices(int cri, int op, int val) {
        if (oIndices == null) oIndices = new int[3];
        oIndices[0] = cri;
        oIndices[1] = op;
        oIndices[2] = val;
    }
    
    public void actualizeIndices(int indice) {
        if (oIndices == null) {
            oIndices = new int[1];
            oIndices[0] = indice;
        }
        else oIndices[0] = indice;
    }
    
    public int[] getIndices() {
        return oIndices;
    }
    
    public int getType() {
        return iType;
    }
    
    public String getText() {
        return sOldText;
    }
    
    public ArrayList<adaptationCriterion> getCriteria(){
        return oaCri;
    }

    public void actualizeIndices(int cri, int op, int val, int com, int comv) {
       if (oIndices == null) oIndices = new int[5];
        oIndices[0] = cri;
        oIndices[1] = op;
        oIndices[2] = val;
        oIndices[3] = com;
        oIndices[4] = comv;
    }
}
