java: isac.util.tactics .. end renamed, formatted, inst_var_, import cleaned java_rename_format
authorwneuper
Wed, 15 Jun 2005 18:31:02 +0200
branchjava_rename_format
changeset 3922fcd5648113ca
parent 963 b4896ce4d1b0
java: isac.util.tactics .. end renamed, formatted, inst_var_, import cleaned
src/java/isac/util/tactics/Rewrite.java
src/java/isac/util/tactics/RewriteInst.java
src/java/isac/util/tactics/RewriteSet.java
src/java/isac/util/tactics/RewriteSetInst.java
src/java/isac/util/tactics/SimpleTactic.java
src/java/isac/util/tactics/StringListTactic.java
src/java/isac/util/tactics/SubProblemTactic.java
src/java/isac/util/tactics/Tactic.java
src/java/isac/util/tactics/TacticsContainer.java
src/java/isac/util/tactics/Theorem.java
src/java/isac/util/users/Accounts.java
src/java/isac/util/users/IUserSettings.java
src/java/isac/util/users/User.java
src/java/isac/util/users/UserAdmin.java
src/java/isac/util/users/UserModel.java
src/java/isac/util/users/UserModel_AK.java
src/java/isac/util/users/UserSettings.java
src/java/isac/util/usersettings/UserModel.java
src/java/isac/util/usersettings/UserSettings.java
src/java/isac/wsdialog/ActionOnUIElement.java
src/java/isac/wsdialog/DialogGuide.java
src/java/isac/wsdialog/DialogMathException.java
src/java/isac/wsdialog/DialogNotImplementedException.java
src/java/isac/wsdialog/DialogProtocolException.java
src/java/isac/wsdialog/DialogUnknownActionException.java
src/java/isac/wsdialog/IUIElement.java
src/java/isac/wsdialog/IUserAction.java
src/java/isac/wsdialog/UserAction.java
src/java/isac/wsdialog/UserActionOnCalcElement.java
src/java/isac/wsdialog/UserActionOnCalcHeadCompoundID.java
src/java/isac/wsdialog/UserActionOnInt.java
src/java/isac/wsdialog/UserActionOnIterator.java
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/java/isac/util/tactics/Rewrite.java	Wed Jun 15 18:31:02 2005 +0200
     1.3 @@ -0,0 +1,37 @@
     1.4 +/*
     1.5 + * Created on Jun 25, 2004
     1.6 + */
     1.7 +package isac.util.tactics;
     1.8 +
     1.9 +/**
    1.10 + * @author richard
    1.11 + */
    1.12 +public class Rewrite extends Tactic {
    1.13 +
    1.14 +    Theorem theorem_;
    1.15 +
    1.16 +    public Rewrite() {
    1.17 +    }
    1.18 +
    1.19 +    public String toSMLString() {
    1.20 +        return name_ + theorem_.toSMLString();
    1.21 +    }
    1.22 +
    1.23 +    /**
    1.24 +     * @return
    1.25 +     */
    1.26 +    public Theorem getTheorem() {
    1.27 +        return theorem_;
    1.28 +    }
    1.29 +
    1.30 +    /**
    1.31 +     * for use in
    1.32 +     * 
    1.33 +     * @see isac.util.parser.XMLParserDigest.java
    1.34 +     * @param theorem
    1.35 +     */
    1.36 +    public void setTheorem(Theorem theorem) {
    1.37 +        this.theorem_ = theorem;
    1.38 +    }
    1.39 +
    1.40 +}
    1.41 \ No newline at end of file
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/src/java/isac/util/tactics/RewriteInst.java	Wed Jun 15 18:31:02 2005 +0200
     2.3 @@ -0,0 +1,64 @@
     2.4 +/*
     2.5 + * Created on Jun 25, 2004
     2.6 + */
     2.7 +package isac.util.tactics;
     2.8 +
     2.9 +/**
    2.10 + * @author richard
    2.11 + */
    2.12 +public class RewriteInst extends Tactic {
    2.13 +    String variable_, value_;
    2.14 +
    2.15 +    Theorem theorem_;
    2.16 +
    2.17 +    public RewriteInst() {
    2.18 +    }
    2.19 +
    2.20 +    public String toSMLString() {
    2.21 +        return name_ + " ([\"(" + variable_ + "," + value_ + ")\"],"
    2.22 +                + theorem_.toSMLString() + ")";
    2.23 +    }
    2.24 +
    2.25 +    /**
    2.26 +     * @return
    2.27 +     */
    2.28 +    public String getValue() {
    2.29 +        return value_;
    2.30 +    }
    2.31 +
    2.32 +    /**
    2.33 +     * @return
    2.34 +     */
    2.35 +    public String getVariable() {
    2.36 +        return variable_;
    2.37 +    }
    2.38 +
    2.39 +    /**
    2.40 +     * @param string
    2.41 +     */
    2.42 +    public void setValue(String string) {
    2.43 +        value_ = string;
    2.44 +    }
    2.45 +
    2.46 +    /**
    2.47 +     * @param string
    2.48 +     */
    2.49 +    public void setVariable(String string) {
    2.50 +        variable_ = string;
    2.51 +    }
    2.52 +
    2.53 +    /**
    2.54 +     * @return
    2.55 +     */
    2.56 +    public Theorem getTheorem() {
    2.57 +        return theorem_;
    2.58 +    }
    2.59 +
    2.60 +    /**
    2.61 +     * @param theorem
    2.62 +     */
    2.63 +    public void setTheorem(Theorem theorem) {
    2.64 +        this.theorem_ = theorem;
    2.65 +    }
    2.66 +
    2.67 +}
    2.68 \ No newline at end of file
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/src/java/isac/util/tactics/RewriteSet.java	Wed Jun 15 18:31:02 2005 +0200
     3.3 @@ -0,0 +1,45 @@
     3.4 +/*
     3.5 + * Created on Oct 14, 2003
     3.6 + *
     3.7 + * To change the template for this generated file go to
     3.8 + * Window>Preferences>Java>Code Generation>Code and Comments
     3.9 + */
    3.10 +package isac.util.tactics;
    3.11 +
    3.12 +/**
    3.13 + * @author rgradisc
    3.14 + * 
    3.15 + * To change the template for this generated type comment go to
    3.16 + * Window>Preferences>Java>Code Generation>Code and Comments
    3.17 + */
    3.18 +public class RewriteSet extends Tactic {
    3.19 +    private String rule_set_;
    3.20 +
    3.21 +    public RewriteSet() {
    3.22 +    }
    3.23 +
    3.24 +    public RewriteSet(String name) {
    3.25 +        this.name_ = name;
    3.26 +    }
    3.27 +
    3.28 +    public RewriteSet(String name, String ruleSet) {
    3.29 +        this.name_ = name;
    3.30 +        this.rule_set_ = ruleSet;
    3.31 +    }
    3.32 +
    3.33 +    public String getName() {
    3.34 +        return name_;
    3.35 +    }
    3.36 +
    3.37 +    public void setRuleSet(String ruleSet) {
    3.38 +        this.rule_set_ = ruleSet;
    3.39 +    }
    3.40 +
    3.41 +    public String getRuleSet() {
    3.42 +        return this.rule_set_;
    3.43 +    }
    3.44 +
    3.45 +    public String toSMLString() {
    3.46 +        return name_ + " \"" + rule_set_ + "\"";
    3.47 +    }
    3.48 +}
    3.49 \ No newline at end of file
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/src/java/isac/util/tactics/RewriteSetInst.java	Wed Jun 15 18:31:02 2005 +0200
     4.3 @@ -0,0 +1,77 @@
     4.4 +/*
     4.5 + * Created on Oct 10, 2003
     4.6 + *
     4.7 + * To change the template for this generated file go to
     4.8 + * Window>Preferences>Java>Code Generation>Code and Comments
     4.9 + */
    4.10 +package isac.util.tactics;
    4.11 +
    4.12 +/**
    4.13 + * @author rgradisc
    4.14 + * 
    4.15 + * To change the template for this generated type comment go to
    4.16 + * Window>Preferences>Java>Code Generation>Code and Comments
    4.17 + */
    4.18 +public class RewriteSetInst extends Tactic {
    4.19 +
    4.20 +    String rule_set_, variable_, value_;
    4.21 +
    4.22 +    public RewriteSetInst() {
    4.23 +    }
    4.24 +
    4.25 +    public RewriteSetInst(String name) {
    4.26 +        this.name_ = name;
    4.27 +    }
    4.28 +
    4.29 +    public String getName() {
    4.30 +        return name_;
    4.31 +    }
    4.32 +
    4.33 +    public String toSMLString() {
    4.34 +        return name_ + " ([\"(" + variable_ + "," + value_ + ")\"], \""
    4.35 +                + rule_set_ + "\")";
    4.36 +    }
    4.37 +
    4.38 +    /**
    4.39 +     * @return
    4.40 +     */
    4.41 +    public String getRuleSet() {
    4.42 +        return rule_set_;
    4.43 +    }
    4.44 +
    4.45 +    /**
    4.46 +     * @return
    4.47 +     */
    4.48 +    public String getValue() {
    4.49 +        return value_;
    4.50 +    }
    4.51 +
    4.52 +    /**
    4.53 +     * @return
    4.54 +     */
    4.55 +    public String getVariable() {
    4.56 +        return variable_;
    4.57 +    }
    4.58 +
    4.59 +    /**
    4.60 +     * @param string
    4.61 +     */
    4.62 +    public void setRuleSet(String string) {
    4.63 +        rule_set_ = string;
    4.64 +    }
    4.65 +
    4.66 +    /**
    4.67 +     * @param string
    4.68 +     */
    4.69 +    public void setValue(String string) {
    4.70 +        value_ = string;
    4.71 +    }
    4.72 +
    4.73 +    /**
    4.74 +     * @param string
    4.75 +     */
    4.76 +    public void setVariable(String string) {
    4.77 +        variable_ = string;
    4.78 +    }
    4.79 +
    4.80 +}
    4.81 \ No newline at end of file
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/src/java/isac/util/tactics/SimpleTactic.java	Wed Jun 15 18:31:02 2005 +0200
     5.3 @@ -0,0 +1,42 @@
     5.4 +/*
     5.5 + * Created on Oct 9, 2003
     5.6 + *
     5.7 + * To change the template for this generated file go to
     5.8 + * Window>Preferences>Java>Code Generation>Code and Comments
     5.9 + */
    5.10 +package isac.util.tactics;
    5.11 +
    5.12 +/**
    5.13 + * @author rgradisc
    5.14 + * 
    5.15 + * To change the template for this generated type comment go to
    5.16 + * Window>Preferences>Java>Code Generation>Code and Comments
    5.17 + */
    5.18 +public class SimpleTactic extends Tactic {
    5.19 +
    5.20 +    private String argument_; // placeholder for MATH-ML
    5.21 +
    5.22 +    public SimpleTactic() {
    5.23 +    }
    5.24 +
    5.25 +    public SimpleTactic(String name) {
    5.26 +        this.name_ = name;
    5.27 +    }
    5.28 +
    5.29 +    public SimpleTactic(String name, String argument) {
    5.30 +        this.name_ = name;
    5.31 +        this.argument_ = argument;
    5.32 +    }
    5.33 +
    5.34 +    public void setArgument(String argument) {
    5.35 +        this.argument_ = argument;
    5.36 +    }
    5.37 +
    5.38 +    public String getArgument() {
    5.39 +        return "";
    5.40 +    }
    5.41 +
    5.42 +    public String toSMLString() {
    5.43 +        return name_ + " \"" + argument_ + "\"";
    5.44 +    }
    5.45 +}
    5.46 \ No newline at end of file
     6.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.2 +++ b/src/java/isac/util/tactics/StringListTactic.java	Wed Jun 15 18:31:02 2005 +0200
     6.3 @@ -0,0 +1,53 @@
     6.4 +/*
     6.5 + * Created on Oct 9, 2003
     6.6 + *
     6.7 + * To change the template for this generated file go to
     6.8 + * Window>Preferences>Java>Code Generation>Code and Comments
     6.9 + */
    6.10 +package isac.util.tactics;
    6.11 +
    6.12 +import java.util.Iterator;
    6.13 +import java.util.Vector;
    6.14 +
    6.15 +/**
    6.16 + * @author rgradisc
    6.17 + * 
    6.18 + * To change the template for this generated type comment go to
    6.19 + * Window>Preferences>Java>Code Generation>Code and Comments
    6.20 + */
    6.21 +public class StringListTactic extends Tactic {
    6.22 +
    6.23 +    private Vector string_list_ = new Vector();
    6.24 +
    6.25 +    public StringListTactic() {
    6.26 +    }
    6.27 +
    6.28 +    public StringListTactic(String name) {
    6.29 +        this.name_ = name;
    6.30 +    }
    6.31 +
    6.32 +    public StringListTactic(String name, Vector keyList) {
    6.33 +        this.name_ = name;
    6.34 +        this.string_list_ = keyList;
    6.35 +    }
    6.36 +
    6.37 +    public void addKey(String key) {
    6.38 +        this.string_list_.add(key);
    6.39 +    }
    6.40 +
    6.41 +    public String toSMLString() {
    6.42 +        StringBuffer sb = new StringBuffer();
    6.43 +        sb.append(name_);
    6.44 +        if (string_list_.size() > 0) {
    6.45 +            sb.append(" [");
    6.46 +            Iterator it = string_list_.iterator();
    6.47 +            while (it.hasNext()) {
    6.48 +                sb.append("\"" + it.next() + "\",");
    6.49 +            }
    6.50 +            sb.deleteCharAt(sb.length() - 1); // remove last ","
    6.51 +            sb.append("]");
    6.52 +        }
    6.53 +        return sb.toString();
    6.54 +    }
    6.55 +
    6.56 +}
    6.57 \ No newline at end of file
     7.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.2 +++ b/src/java/isac/util/tactics/SubProblemTactic.java	Wed Jun 15 18:31:02 2005 +0200
     7.3 @@ -0,0 +1,52 @@
     7.4 +/*
     7.5 + * Created on Nov 13, 2003
     7.6 + */
     7.7 +package isac.util.tactics;
     7.8 +
     7.9 +import java.util.Iterator;
    7.10 +import java.util.Vector;
    7.11 +
    7.12 +/**
    7.13 + * @author rgradisc
    7.14 + */
    7.15 +public class SubProblemTactic extends Tactic {
    7.16 +
    7.17 +    private String theory_ID_;
    7.18 +
    7.19 +    private Vector problem_ID_ = new Vector();
    7.20 +
    7.21 +    public SubProblemTactic() {
    7.22 +    }
    7.23 +
    7.24 +    public void addProblemString(String string) {
    7.25 +        this.problem_ID_.add(string);
    7.26 +    }
    7.27 +
    7.28 +    public String toSMLString() {
    7.29 +        StringBuffer sb = new StringBuffer();
    7.30 +        sb.append(name_ + " (\"" + theory_ID_ + "\", [");
    7.31 +        Iterator it = problem_ID_.iterator();
    7.32 +        while (it.hasNext()) {
    7.33 +            sb.append("\"" + it.next() + "\",");
    7.34 +        }
    7.35 +        sb.deleteCharAt(sb.length() - 1); // remove last ","
    7.36 +        sb.append("])");
    7.37 +        return sb.toString();
    7.38 +    }
    7.39 +
    7.40 +    public Vector getProblemID() {
    7.41 +        return problem_ID_;
    7.42 +    }
    7.43 +
    7.44 +    public String getTheoryID() {
    7.45 +        return theory_ID_;
    7.46 +    }
    7.47 +
    7.48 +    public void setProblemID(Vector vector) {
    7.49 +        problem_ID_ = vector;
    7.50 +    }
    7.51 +
    7.52 +    public void setTheoryID(String string) {
    7.53 +        theory_ID_ = string;
    7.54 +    }
    7.55 +}
    7.56 \ No newline at end of file
     8.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     8.2 +++ b/src/java/isac/util/tactics/Tactic.java	Wed Jun 15 18:31:02 2005 +0200
     8.3 @@ -0,0 +1,93 @@
     8.4 +/*
     8.5 + * Created on Sep 11, 2003
     8.6 + *
     8.7 + * To change the template for this generated file go to
     8.8 + * Window>Preferences>Java>Code Generation>Code and Comments
     8.9 + */
    8.10 +package isac.util.tactics;
    8.11 +
    8.12 +import isac.util.formulae.CalcElement;
    8.13 +import isac.util.formulae.CalcFormula;
    8.14 +
    8.15 +/**
    8.16 + * @author Alan Krempler (method stubs)
    8.17 + *  
    8.18 + */
    8.19 +public class Tactic extends CalcElement {
    8.20 +
    8.21 +    protected String name_;
    8.22 +
    8.23 +    public String getName() {
    8.24 +        return name_;
    8.25 +    }
    8.26 +
    8.27 +    public void setName(String name) {
    8.28 +        this.name_ = name;
    8.29 +    }
    8.30 +
    8.31 +    public String getDescription() {
    8.32 +        return "";
    8.33 +    }
    8.34 +
    8.35 +    //FIXME.WN0504 put down in inheritance (valid only for some tacs)
    8.36 +    public String getTheoremName() {
    8.37 +        return "";
    8.38 +    }
    8.39 +
    8.40 +    //FIXME.WN0504 put down in inheritance (valid only for some tacs)
    8.41 +    public String getTheoremDescription() {
    8.42 +        return "";
    8.43 +    }
    8.44 +
    8.45 +    //FIXME.WN0504 put down in inheritance (valid only for some tacs)
    8.46 +    public CalcFormula getTheoremSymbolic() {
    8.47 +        CalcFormula dummy;
    8.48 +        dummy = new CalcFormula();
    8.49 +        return dummy;
    8.50 +    }
    8.51 +
    8.52 +    //FIXME.WN0504 put down in inheritance (valid only for some tacs)
    8.53 +    public CalcFormula getTheoremInstantiated(CalcFormula formula) {
    8.54 +        CalcFormula dummy;
    8.55 +        dummy = new CalcFormula();
    8.56 +        return dummy;
    8.57 +    }
    8.58 +
    8.59 +    //FIXME.WN0504 put down in inheritance (valid only for some tacs)
    8.60 +    // itself and selected by passing an integer
    8.61 +    public CalcFormula makeFillFormula(CalcFormula formula, String pattern) {
    8.62 +        CalcFormula dummy;
    8.63 +        dummy = new CalcFormula();
    8.64 +        return dummy;
    8.65 +    }
    8.66 +
    8.67 +    /*
    8.68 +     * (non-Javadoc)
    8.69 +     * 
    8.70 +     * @see isac.util.CalcElement#getText()
    8.71 +     */
    8.72 +    public String toSMLString() {
    8.73 +        // TODO Auto-generated method stub
    8.74 +        return null;
    8.75 +    }
    8.76 +
    8.77 +    /*
    8.78 +     * (non-Javadoc)
    8.79 +     * 
    8.80 +     * @see isac.util.CalcElement#getMathML()
    8.81 +     */
    8.82 +    public String getMathML() {
    8.83 +        // TODO Auto-generated method stub
    8.84 +        return null;
    8.85 +    }
    8.86 +
    8.87 +    /*
    8.88 +     * (non-Javadoc)
    8.89 +     * 
    8.90 +     * @see isac.util.CalcElement#getType()
    8.91 +     */
    8.92 +    public int getType() {
    8.93 +        return CALCEL_TACTIC;
    8.94 +    }
    8.95 +
    8.96 +}
    8.97 \ No newline at end of file
     9.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     9.2 +++ b/src/java/isac/util/tactics/TacticsContainer.java	Wed Jun 15 18:31:02 2005 +0200
     9.3 @@ -0,0 +1,27 @@
     9.4 +/*
     9.5 + * Created on Mar 23, 2004
     9.6 + */
     9.7 +package isac.util.tactics;
     9.8 +
     9.9 +import java.util.Vector;
    9.10 +
    9.11 +/**
    9.12 + * @author richard gradischnegg renames Vector#add to
    9.13 + *         TacticsContainer#setResponse as required by
    9.14 + * @see isac.util.parser.XMLParserDigest
    9.15 + */
    9.16 +public class TacticsContainer {
    9.17 +    Vector tactics_;
    9.18 +
    9.19 +    public TacticsContainer() {
    9.20 +        tactics_ = new Vector();
    9.21 +    }
    9.22 +
    9.23 +    public void setResponse(Tactic tactic) {
    9.24 +        tactics_.add(tactic);
    9.25 +    }
    9.26 +
    9.27 +    public Vector getTactics() {
    9.28 +        return tactics_;
    9.29 +    }
    9.30 +}
    9.31 \ No newline at end of file
    10.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    10.2 +++ b/src/java/isac/util/tactics/Theorem.java	Wed Jun 15 18:31:02 2005 +0200
    10.3 @@ -0,0 +1,45 @@
    10.4 +/*
    10.5 + * Created on Jun 25, 2004
    10.6 + */
    10.7 +package isac.util.tactics;
    10.8 +
    10.9 +import java.io.Serializable;
   10.10 +
   10.11 +/**
   10.12 + * This is a helper class used by Rewrite Tactic and RewriteInst Tactic
   10.13 + * 
   10.14 + * @author richard
   10.15 + */
   10.16 +
   10.17 +public class Theorem implements Serializable {
   10.18 +    String id_, formula_;
   10.19 +
   10.20 +    //Theorem consist of the ID, and
   10.21 +    //the formula (still as a string -- waiting for MathML)
   10.22 +
   10.23 +    /**
   10.24 +     * Format the class to a string which can be used as SML-Input
   10.25 +     * 
   10.26 +     * @return
   10.27 +     */
   10.28 +    public String toSMLString() {
   10.29 +        return "(\"" + id_ + "\",\"\")"; //formula may be empty at input
   10.30 +    }
   10.31 +
   10.32 +    public String getFormula() {
   10.33 +        return formula_;
   10.34 +    }
   10.35 +
   10.36 +    public String getId() {
   10.37 +        return id_;
   10.38 +    }
   10.39 +
   10.40 +    public void setFormula(String string) {
   10.41 +        formula_ = string;
   10.42 +    }
   10.43 +
   10.44 +    public void setId(String string) {
   10.45 +        id_ = string;
   10.46 +    }
   10.47 +
   10.48 +}
   10.49 \ No newline at end of file
    11.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    11.2 +++ b/src/java/isac/util/users/Accounts.java	Wed Jun 15 18:31:02 2005 +0200
    11.3 @@ -0,0 +1,68 @@
    11.4 +/*
    11.5 + * @author Walther Neuper, member of the ISAC-team, 
    11.6 + * Copyright (c) 2005 by Walther Neuper 
    11.7 + * created Mar 12, 2005 8:09:42 AM
    11.8 + * Institute for Softwaretechnology, Graz University of Technology, Austria.
    11.9 + * 
   11.10 + * Use is subject to PGPL license terms.
   11.11 + */
   11.12 +package isac.util.users;
   11.13 +
   11.14 +import java.io.FileInputStream;
   11.15 +import java.io.FileNotFoundException;
   11.16 +import java.io.FileOutputStream;
   11.17 +import java.io.IOException;
   11.18 +import java.util.Enumeration;
   11.19 +import java.util.Properties;
   11.20 +
   11.21 +/**
   11.22 + * @author Walther Neuper
   11.23 + * 
   11.24 + * contains passwords looking forward to handle security issues elsewhere
   11.25 + * (outside isac)
   11.26 + */
   11.27 +public class Accounts extends Properties {
   11.28 +
   11.29 +    public Accounts(String userpath) {
   11.30 +        String filename = userpath + "accounts.txt";
   11.31 +        try {
   11.32 +            FileInputStream propInFile = new FileInputStream(filename);
   11.33 +            this.load(propInFile);
   11.34 +            this.list(System.out);
   11.35 +        } catch (FileNotFoundException e) {
   11.36 +            System.err.println("Can?t find " + filename);
   11.37 +        } catch (IOException e) {
   11.38 +            System.err.println("I/O failed.");
   11.39 +        }
   11.40 +    }
   11.41 +
   11.42 +    public boolean exists(String username) {
   11.43 +        Enumeration keys = this.propertyNames();//WN050311 how better ?
   11.44 +        String key = null;
   11.45 +        while (keys.hasMoreElements()) {
   11.46 +            key = (String) keys.nextElement();
   11.47 +            if (key.compareTo(username) == 0)
   11.48 +                return true;
   11.49 +        }
   11.50 +        return false;
   11.51 +    }
   11.52 +
   11.53 +    //WN050311 just for creation of the first file
   11.54 +    //beware of the fix path !
   11.55 +    public static void main(String[] args) {
   11.56 +        Accounts acs = new Accounts("isac/xmldata/users");
   11.57 +        acs.setProperty("x", "x");
   11.58 +        acs.setProperty("y", "y");
   11.59 +        acs.setProperty("anonymous", "anonymous");
   11.60 +
   11.61 +        String filename = "isac/xmldata/users/accounts.txt";
   11.62 +        try {
   11.63 +            FileOutputStream propOutFile = new FileOutputStream(filename);
   11.64 +            acs.store(propOutFile, "the list of isac users");
   11.65 +
   11.66 +        } catch (IOException e) {
   11.67 +            System.err.println("I/O failed.");
   11.68 +        }
   11.69 +    }
   11.70 +
   11.71 +}
   11.72 \ No newline at end of file
    12.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    12.2 +++ b/src/java/isac/util/users/IUserSettings.java	Wed Jun 15 18:31:02 2005 +0200
    12.3 @@ -0,0 +1,51 @@
    12.4 +/*
    12.5 + * @author Walther Neuper, member of the ISAC-team, 
    12.6 + * Copyright (c) 2005 by Walther Neuper 
    12.7 + * created Mar 12, 2005 3:09:15 PM
    12.8 + * Institute for Softwaretechnology, Graz University of Technology, Austria.
    12.9 + * 
   12.10 + * Use is subject to PGPL license terms.
   12.11 + */
   12.12 +package isac.util.users;
   12.13 +
   12.14 +/**
   12.15 + * @author Walther Neuper
   12.16 + * 
   12.17 + * semantics for review by AK
   12.18 + */
   12.19 +public interface IUserSettings {
   12.20 +
   12.21 +    //TODO comments with AK ?
   12.22 +    //TODO change type String to the one suggested by AK
   12.23 +    //public static final String start_worksheet = "start_worksheet";
   12.24 +
   12.25 +    //the following are situations implemented as keys for UserSettings
   12.26 +    //the identifiers must start with "KEYn_*" where n reappears in the
   12.27 +    // identifiers of the related values "VALn_*" ---------------------
   12.28 +    public static final String KEY1_START_SPECIFY = "KEY1_START_SPECIFY";
   12.29 +
   12.30 +    /**
   12.31 +     * _ALL_ the values of UserSettings _MUST_ be connect their
   12.32 +     * Integer-representation with the String-representation in
   12.33 +     * 
   12.34 +     * @see isac.util.users.UserSettings#createValstrValint
   12.35 +     */
   12.36 +    public static final int VAL1_SKIP_SPECIFY_TO_START_SOLVE = 23;
   12.37 +
   12.38 +    public static final int VAL1_POP_CALCHEAD_WITH_DESCRIPTIONS = 26;
   12.39 +
   12.40 +    //-----------------------------------------------------------------
   12.41 +    public static final String KEY2_NEXT_BUTTON = "KEY2_NEXT_BUTTON";
   12.42 +
   12.43 +    public static final int VAL2_FORMULAE_ONLY = 43;
   12.44 +
   12.45 +    public static final int VAL2_FORMULA_TACTIC_FORMULA_ = 46;
   12.46 +
   12.47 +    public static final int DUMMY = 0;
   12.48 +
   12.49 +    //-----------------------------------------------------------------
   12.50 +    public int getValue(String key);
   12.51 +
   12.52 +    public boolean setValue(String key, int value);
   12.53 +
   12.54 +}
   12.55 \ No newline at end of file
    13.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    13.2 +++ b/src/java/isac/util/users/User.java	Wed Jun 15 18:31:02 2005 +0200
    13.3 @@ -0,0 +1,46 @@
    13.4 +/****************************************************************** 
    13.5 + * @author Alois Kirchsteiger member of the isac team
    13.6 + * Copyright (c) 2004 by Alois Kirchsteiger
    13.7 + * create 02.09.2004, 09:22:43
    13.8 + * Insitute for Softwaretechnology, Graz University of Technology, Austria. 
    13.9 + * 
   13.10 + * Use is subject to license terms.
   13.11 + ******************************************************************/
   13.12 +
   13.13 +//TODO: implement!!!
   13.14 +package isac.util.users;
   13.15 +
   13.16 +import java.io.Serializable;
   13.17 +
   13.18 +/**
   13.19 + * @author Alois Kirchsteiger 02.09.2004 09:22:43
   13.20 + */
   13.21 +public class User implements Serializable {
   13.22 +    private String username_;
   13.23 +
   13.24 +    private String userpath_;
   13.25 +
   13.26 +    public User(String username, String userpath) {
   13.27 +        username_ = username;
   13.28 +        userpath_ = userpath;
   13.29 +    }
   13.30 +
   13.31 +    public UserAdmin getUserAdmin() {
   13.32 +        return new UserAdmin(userpath_, username_);
   13.33 +
   13.34 +    }
   13.35 +
   13.36 +    public UserModel getUserModel() {
   13.37 +        return new UserModel(userpath_, username_);
   13.38 +    }
   13.39 +
   13.40 +    public UserSettings getUserSettings() {
   13.41 +        return new UserSettings(userpath_, username_);
   13.42 +
   13.43 +    }
   13.44 +
   13.45 +    public String getUsername() {
   13.46 +        return username_;
   13.47 +    }
   13.48 +
   13.49 +}
   13.50 \ No newline at end of file
    14.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    14.2 +++ b/src/java/isac/util/users/UserAdmin.java	Wed Jun 15 18:31:02 2005 +0200
    14.3 @@ -0,0 +1,51 @@
    14.4 +/*
    14.5 + * @author Walther Neuper, member of the ISAC-team, 
    14.6 + * Copyright (c) 2005 by Walther Neuper 
    14.7 + * created Mar 12, 2005 8:55:37 AM
    14.8 + * Institute for Softwaretechnology, Graz University of Technology, Austria.
    14.9 + * 
   14.10 + * Use is subject to PGPL license terms.
   14.11 + */
   14.12 +package isac.util.users;
   14.13 +
   14.14 +import java.io.FileOutputStream;
   14.15 +import java.io.IOException;
   14.16 +import java.util.Properties;
   14.17 +
   14.18 +/**
   14.19 + * @author Walther Neuper
   14.20 + * 
   14.21 + * contains administrative data (and nothing about the dialog !!!) looking
   14.22 + * forward to be handled elsewhere outside isac
   14.23 + */
   14.24 +public class UserAdmin extends Properties {
   14.25 +
   14.26 +    private String userpath_;
   14.27 +
   14.28 +    private String username_;
   14.29 +
   14.30 +    public UserAdmin(String userpath, String username) {
   14.31 +        userpath_ = userpath;
   14.32 +        username_ = username;
   14.33 +        //TODO.WN050311
   14.34 +    }
   14.35 +
   14.36 +    //WN050311 just for creation of the first file
   14.37 +    //beware of the fix path !
   14.38 +    public static void main(String[] args) {
   14.39 +        UserAdmin a = new UserAdmin("isac/xmldata/users", "x");
   14.40 +        a.setProperty("firstName", "x-firstName");
   14.41 +        a.setProperty("lastName", "x-lastName");
   14.42 +
   14.43 +        String filename = "isac/xmldata/users/x_admin.txt";
   14.44 +        try {
   14.45 +            FileOutputStream propOutFile = new FileOutputStream(filename);
   14.46 +            a.store(propOutFile, "administrative data of user 'x'");
   14.47 +
   14.48 +        } catch (IOException e) {
   14.49 +            System.err.println("I/O failed.");
   14.50 +        }
   14.51 +
   14.52 +    }
   14.53 +
   14.54 +}
   14.55 \ No newline at end of file
    15.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    15.2 +++ b/src/java/isac/util/users/UserModel.java	Wed Jun 15 18:31:02 2005 +0200
    15.3 @@ -0,0 +1,193 @@
    15.4 +/*
    15.5 + * Created on Feb 22, 2005
    15.6 + *
    15.7 + * To change the template for this generated file go to
    15.8 + * Window>Preferences>Java>Code Generation>Code and Comments
    15.9 + */
   15.10 +package isac.util.users;
   15.11 +
   15.12 +import java.io.FileOutputStream;
   15.13 +import java.io.IOException;
   15.14 +import java.util.Properties;
   15.15 +
   15.16 +/**
   15.17 + * @author Alan Krempler
   15.18 + * 
   15.19 + * The UserModel is a class to gather statistics about one user's interaction
   15.20 + * with the system. Statistis are gathered per user and per interactional
   15.21 + * context.
   15.22 + */
   15.23 +public class UserModel extends Properties {
   15.24 +
   15.25 +    //	special value for retrieving the statistics regardless of the dialog atom
   15.26 +    // used in the interaction
   15.27 +    public static final int DIALOG_ATOM_ANY = 0;
   15.28 +
   15.29 +    // counter for identifying pending interactions
   15.30 +    private static int interaction_nr_ = 1;
   15.31 +
   15.32 +    private String userpath_;
   15.33 +
   15.34 +    private String username_;
   15.35 +
   15.36 +    public UserModel(String userpath, String username) {
   15.37 +        userpath_ = userpath;
   15.38 +        username_ = username;
   15.39 +        //TODO.WN050311
   15.40 +    }
   15.41 +
   15.42 +    /**
   15.43 +     * @param item_id
   15.44 +     *            ID of the item being queried, a tactic for example
   15.45 +     * @param dialog_atom
   15.46 +     *            ID of the interactional context use DIALOG_ATOM_ANY if asking
   15.47 +     *            for statistics for all dialog atoms
   15.48 +     * @return count of previously recorded interactions with this item
   15.49 +     */
   15.50 +    public int getTouchedCount(int item_id, int dialog_atom) {
   15.51 +        // FIXME: returning dummy value in absence of valid statistics
   15.52 +        return 0;
   15.53 +    }
   15.54 +
   15.55 +    /**
   15.56 +     * @param item_id
   15.57 +     *            ID of the item being queried, a tactic for example
   15.58 +     * @param dialog_atom
   15.59 +     *            ID of the interactional context use DIALOG_ATOM_ANY if asking
   15.60 +     *            for statistics for all dialog atoms
   15.61 +     * @return count of previously recorded successful interactions with this
   15.62 +     *         item
   15.63 +     */
   15.64 +    public int getSuccessCount(int item_id, int dialog_atom) {
   15.65 +        // FIXME: returning dummy value in absence of valid statistics
   15.66 +        return 0;
   15.67 +    }
   15.68 +
   15.69 +    /**
   15.70 +     * @param item_id
   15.71 +     *            ID of the item being queried, a tactic for example
   15.72 +     * @param dialog_atom
   15.73 +     *            ID of the interactional context use DIALOG_ATOM_ANY if asking
   15.74 +     *            for statistics for all dialog atoms
   15.75 +     * @return time of last recorded interaction with this item
   15.76 +     */
   15.77 +    public java.util.Date getTouchedLast(int item_id, int dialog_atom) {
   15.78 +        // FIXME: returning dummy value in absence of valid statistics
   15.79 +        return new java.util.Date();
   15.80 +    }
   15.81 +
   15.82 +    /**
   15.83 +     * @param item_id
   15.84 +     *            ID of the item being queried, a tactic for example
   15.85 +     * @param dialog_atom
   15.86 +     *            ID of the interactional context use DIALOG_ATOM_ANY if asking
   15.87 +     *            for statistics for all dialog atoms
   15.88 +     * @return time of last recorded successful interaction with this item
   15.89 +     */
   15.90 +    public java.util.Date getSuccessLast(int item_id, int dialog_atom) {
   15.91 +        // FIXME: returning dummy value in absence of valid statistics
   15.92 +        return new java.util.Date();
   15.93 +    }
   15.94 +
   15.95 +    /**
   15.96 +     * @param item_id
   15.97 +     *            ID of the item being queried, a tactic for example
   15.98 +     * @param dialog_atom
   15.99 +     *            ID of the interactional context use DIALOG_ATOM_ANY if asking
  15.100 +     *            for statistics for all dialog atoms
  15.101 +     * @return average time (seconds) spent in interactions with this item
  15.102 +     */
  15.103 +    public int getTimeSpentAvg(int item_id, int dialog_atom) {
  15.104 +        // FIXME: returning dummy value in absence of valid statistics
  15.105 +        return 0;
  15.106 +    }
  15.107 +
  15.108 +    /**
  15.109 +     * @param item_id
  15.110 +     *            ID of the item being queried, a tactic for example
  15.111 +     * @param dialog_atom
  15.112 +     *            ID of the interactional context use DIALOG_ATOM_ANY if asking
  15.113 +     *            for statistics for all dialog atoms
  15.114 +     * @return maximum time (seconds) spent in interactions with this item
  15.115 +     */
  15.116 +    public int getTimeSpentMax(int item_id, int dialog_atom) {
  15.117 +        // FIXME: returning dummy value in absence of valid statistics
  15.118 +        return 0;
  15.119 +    }
  15.120 +
  15.121 +    /**
  15.122 +     * @param item_id
  15.123 +     *            ID of the item being queried, a tactic for example
  15.124 +     * @param dialog_atom
  15.125 +     *            ID of the interactional context use DIALOG_ATOM_ANY if asking
  15.126 +     *            for statistics for all dialog atoms
  15.127 +     * @return standard deviation of time spent in interactions with this item
  15.128 +     */
  15.129 +    public float getTimeSpentStddev(int item_id, int dialog_atom) {
  15.130 +        // FIXME: returning dummy value in absence of valid statistics
  15.131 +        return 0;
  15.132 +    }
  15.133 +
  15.134 +    /**
  15.135 +     * Mark the beginning of an interaction with an item.
  15.136 +     * 
  15.137 +     * @param item_id
  15.138 +     *            ID of the item being acted upon, a tactic for example
  15.139 +     * @param dialog_atom
  15.140 +     *            ID of the interactional context
  15.141 +     * @return unique number to indentify the end of the transaction
  15.142 +     */
  15.143 +    public int startInteraction(int item_id, int dialog_atom) {
  15.144 +        // FIXME: insert code to record statistics
  15.145 +
  15.146 +        // record timestamp
  15.147 +        // new java.util.Date(); ...
  15.148 +
  15.149 +        // save in static vector of currently open interactions
  15.150 +        // ...
  15.151 +
  15.152 +        return interaction_nr_++;
  15.153 +    }
  15.154 +
  15.155 +    /**
  15.156 +     * Mark the end of an interaction with an item.
  15.157 +     * 
  15.158 +     * @param interaction_id
  15.159 +     *            ID of the interaction returned from the call to
  15.160 +     *            {@link # startInteraction() }
  15.161 +     * @param success
  15.162 +     *            information about the success of the interaction
  15.163 +     * @return false in case of failure - no matching start could be found, true
  15.164 +     *         in case of success
  15.165 +     */
  15.166 +    public boolean endInteraction(int interaction_id, int success) {
  15.167 +        // FIXME: insert code to record statistics
  15.168 +
  15.169 +        // record end timestamp
  15.170 +        // new java.util.Date(); ...
  15.171 +
  15.172 +        // add to statistics
  15.173 +
  15.174 +        // delete from static vector of currently open interactions
  15.175 +        // ...
  15.176 +
  15.177 +        return true;
  15.178 +    }
  15.179 +
  15.180 +    //WN050311 just for creation of the first file
  15.181 +    //beware of the fix path !
  15.182 +    public static void main(String[] args) {
  15.183 +        UserModel a = new UserModel("isac/xmldata/users", "x");
  15.184 +        a.setProperty("TODO-key", "TODO-value");
  15.185 +
  15.186 +        String filename = "isac/xmldata/users/x_model.txt";
  15.187 +        try {
  15.188 +            FileOutputStream propOutFile = new FileOutputStream(filename);
  15.189 +            a.store(propOutFile, "dynamic dialog data of user 'x'");
  15.190 +
  15.191 +        } catch (IOException e) {
  15.192 +            System.err.println("I/O failed.");
  15.193 +        }
  15.194 +
  15.195 +    }
  15.196 +}
  15.197 \ No newline at end of file
    16.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    16.2 +++ b/src/java/isac/util/users/UserModel_AK.java	Wed Jun 15 18:31:02 2005 +0200
    16.3 @@ -0,0 +1,105 @@
    16.4 +/****************************************************************** 
    16.5 + * @author Alois Kirchsteiger member of the isac team
    16.6 + * Copyright (c) 2004 by Alois Kirchsteiger
    16.7 + * create 02.09.2004, 09:25:44
    16.8 + * Insitute for Softwaretechnology, Graz University of Technology, Austria. 
    16.9 + * 
   16.10 + * Use is subject to license terms.
   16.11 + ******************************************************************/
   16.12 +
   16.13 +//TODO: implement!!!
   16.14 +package isac.util.users;
   16.15 +
   16.16 +import isac.session.SuccessInfo;
   16.17 +import isac.util.formulae.CalcElement;
   16.18 +
   16.19 +import java.io.Serializable;
   16.20 +import java.util.Iterator;
   16.21 +import java.util.Map;
   16.22 +import java.util.Set;
   16.23 +import java.util.TreeMap;
   16.24 +import java.util.Vector;
   16.25 +
   16.26 +/**
   16.27 + * @author Alois Kirchsteiger 02.09.2004 09:25:44
   16.28 + */
   16.29 +public class UserModel_AK implements Serializable {
   16.30 +
   16.31 +    /**
   16.32 +     * successInfos stores the successInfos for CalcElements. that means the key
   16.33 +     * for this TreeMap is a calcElement, the value is the relating SuccessInfo
   16.34 +     */
   16.35 +    private TreeMap success_infos_;
   16.36 +
   16.37 +    public UserModel_AK() {
   16.38 +    }
   16.39 +
   16.40 +    /**
   16.41 +     * gets the info for each CalcElement of the parameter calcElements
   16.42 +     * 
   16.43 +     * @param calcElements
   16.44 +     *            this Vector must not contain anything else than CalcElements
   16.45 +     * @return a TreeMap with the SuccessInfo for each CalcElement in the
   16.46 +     *         calcElements Vector. Those CalcElements are the index in the
   16.47 +     *         HashMap, the relating SuccessInfos are the values
   16.48 +     */
   16.49 +    public Map getSuccessInfoFor(Vector calcElements) {
   16.50 +        TreeMap result = new TreeMap();
   16.51 +        Iterator iterator = calcElements.iterator();
   16.52 +        while (iterator.hasNext()) {
   16.53 +            CalcElement calcElement = (CalcElement) iterator.next();
   16.54 +            if (success_infos_.containsKey(calcElement)) {
   16.55 +                result.put(calcElement, success_infos_.get(calcElement));
   16.56 +            } else {
   16.57 +                // no successInfo available
   16.58 +                result.put(calcElement, null);
   16.59 +            }
   16.60 +        }
   16.61 +        //TODO
   16.62 +        return result;
   16.63 +    }
   16.64 +
   16.65 +    /**
   16.66 +     * @param calcElement
   16.67 +     * @return SuccessInfo or null if no SuccessInfo available
   16.68 +     */
   16.69 +    public SuccessInfo getSuccessInfoFor(CalcElement calcElement) {
   16.70 +        return (SuccessInfo) success_infos_.get(calcElement);
   16.71 +    }
   16.72 +
   16.73 +    /**
   16.74 +     * @param calcElementsSuccesses,
   16.75 +     *            a TreeMap with a CalcElement as key and the relating success
   16.76 +     *            (Float between 0 and 1) as value
   16.77 +     */
   16.78 +    public void addSuccessInfoFor(Map calcElementsSuccesses)
   16.79 +            throws ClassCastException {
   16.80 +        Set set = calcElementsSuccesses.keySet();
   16.81 +        Iterator iterator = set.iterator();
   16.82 +        while (iterator.hasNext()) {
   16.83 +            try {
   16.84 +                CalcElement calcElement = (CalcElement) iterator.next();
   16.85 +                Float success = (Float) calcElementsSuccesses.get(calcElement);
   16.86 +                addSuccessInfoFor(calcElement, success.floatValue());
   16.87 +            } catch (ClassCastException e) {
   16.88 +                throw new ClassCastException(
   16.89 +                        "the parameter for the method "
   16.90 +                                + "void addSuccessInfoFor(TreeMap calcElementsSuccesses) "
   16.91 +                                + "must have CalcElements as keys and Floats as value!!");
   16.92 +            }
   16.93 +        }
   16.94 +    }
   16.95 +
   16.96 +    public void addSuccessInfoFor(CalcElement calcElement, float success) {
   16.97 +        SuccessInfo successInfo;
   16.98 +        if (success_infos_.containsKey(calcElement)) {
   16.99 +            successInfo = (SuccessInfo) success_infos_.get(calcElement);
  16.100 +            successInfo.addSuccess(success);
  16.101 +            success_infos_.put(calcElement, successInfo);
  16.102 +        } else {
  16.103 +            successInfo = new SuccessInfo(success);
  16.104 +            success_infos_.put(calcElement, successInfo);
  16.105 +        }
  16.106 +    }
  16.107 +
  16.108 +}
  16.109 \ No newline at end of file
    17.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    17.2 +++ b/src/java/isac/util/users/UserSettings.java	Wed Jun 15 18:31:02 2005 +0200
    17.3 @@ -0,0 +1,140 @@
    17.4 +/*
    17.5 + * Created on Feb 22, 2005
    17.6 + *
    17.7 + * @author Alan Krempler
    17.8 + */
    17.9 +
   17.10 +package isac.util.users;
   17.11 +
   17.12 +import java.io.FileInputStream;
   17.13 +import java.io.FileNotFoundException;
   17.14 +import java.io.FileOutputStream;
   17.15 +import java.io.IOException;
   17.16 +import java.util.Enumeration;
   17.17 +import java.util.HashMap;
   17.18 +import java.util.Map;
   17.19 +import java.util.Properties;
   17.20 +
   17.21 +/**
   17.22 + * Class for storing/retrieving user settings, i.e. settings which can be set
   17.23 + * manually by the user as opposed to the
   17.24 + * {@link isac.util.usersettings.UserModel#}, which is an abstraction of the
   17.25 + * system's expeience with a user and canot be altered manually. As there is no
   17.26 + * fixed set of user settings, you can regard this class as a simple storage
   17.27 + * backend for key/value pairs.
   17.28 + * 
   17.29 + * @author Alan Krempler
   17.30 + *  
   17.31 + */
   17.32 +public class UserSettings extends Properties implements IUserSettings {
   17.33 +
   17.34 +    private HashMap storage_;
   17.35 +
   17.36 +    String userpath_;
   17.37 +
   17.38 +    String username_;
   17.39 +
   17.40 +    public static Map valstr_valint_;
   17.41 +
   17.42 +    /**
   17.43 +     * connect the String-representation of a UserSettings-value with the
   17.44 +     * respective Integer-representation
   17.45 +     * 
   17.46 +     * @see isac.uti.users.IUserSettings
   17.47 +     */
   17.48 +    private HashMap createValstrValint() {
   17.49 +        HashMap m = new HashMap();
   17.50 +        m.put("DUMMY", new Integer(IUserSettings.DUMMY));
   17.51 +        m.put("VAL1_SKIP_SPECIFY_TO_START_SOLVE", new Integer(
   17.52 +                IUserSettings.VAL1_SKIP_SPECIFY_TO_START_SOLVE));
   17.53 +        m.put("VAL1_POP_CALCHEAD_WITH_DESCRIPTIONS", new Integer(
   17.54 +                IUserSettings.VAL1_POP_CALCHEAD_WITH_DESCRIPTIONS));
   17.55 +        m.put("VAL2_FORMULAE_ONLY", new Integer(
   17.56 +                IUserSettings.VAL2_FORMULAE_ONLY));
   17.57 +        m.put("VAL2_FORMULA_TACTIC_FORMULA_", new Integer(
   17.58 +                IUserSettings.VAL2_FORMULA_TACTIC_FORMULA_));
   17.59 +        //m.put("",
   17.60 +        //		new Integer(IUserSettings.));
   17.61 +        return m;
   17.62 +    }
   17.63 +
   17.64 +    public UserSettings(String userpath, String username) {
   17.65 +        userpath_ = userpath;
   17.66 +        username_ = username;
   17.67 +
   17.68 +        //load Properties (keystr, valstr) temporarily
   17.69 +        Properties keystr_valstr = new Properties();
   17.70 +        String filename = userpath_ + username + "_settings.txt";
   17.71 +        try {
   17.72 +            FileInputStream propInFile = new FileInputStream(filename);
   17.73 +            keystr_valstr.load(propInFile);
   17.74 +            keystr_valstr.list(System.out);
   17.75 +        } catch (FileNotFoundException e) {
   17.76 +            System.err.println("Can?t find " + filename);
   17.77 +        } catch (IOException e) {
   17.78 +            System.err.println("I/O failed.");
   17.79 +        }
   17.80 +
   17.81 +        //create HashMap (valstr, valint) temporarily
   17.82 +        HashMap valstr_valint = new HashMap();
   17.83 +        valstr_valint = this.createValstrValint();
   17.84 +
   17.85 +        //create HashMap (keystr, \\valstr\\ valint) and store it
   17.86 +        storage_ = new HashMap();
   17.87 +        Enumeration keystrs = keystr_valstr.propertyNames();//WN050311 how
   17.88 +        // better ?
   17.89 +        String keystr = null;
   17.90 +        String valstr = null;
   17.91 +        Object valint = null;
   17.92 +        while (keystrs.hasMoreElements()) {
   17.93 +            keystr = (String) keystrs.nextElement();
   17.94 +            valstr = keystr_valstr.getProperty(keystr);
   17.95 +            valint = valstr_valint.get(valstr);
   17.96 +            storage_.put(keystr, valint);
   17.97 +        }
   17.98 +    }
   17.99 +
  17.100 +    /**
  17.101 +     * @param key
  17.102 +     *            A string key
  17.103 +     * @return The string value associated with the key parameter; null, if
  17.104 +     *         nothing is stored under this key
  17.105 +     */
  17.106 +    public int getValue(String key) {
  17.107 +        return ((Integer) storage_.get(key)).intValue();
  17.108 +    }
  17.109 +
  17.110 +    /**
  17.111 +     * @param key
  17.112 +     *            The key under which "value" is to be stored. Existing data
  17.113 +     *            unde the same key will be replaced.
  17.114 +     * @param value
  17.115 +     *            The value to be stored under "key"
  17.116 +     * @return true in case of success, false in case of error, for example if
  17.117 +     *         trying to replace stored values without proper permissions
  17.118 +     */
  17.119 +    public boolean setValue(String key, int value) {
  17.120 +        //TODO.WN050311 storage_.put(key, value);
  17.121 +        return true;
  17.122 +    }
  17.123 +
  17.124 +    //WN050311 just for creation of the first file
  17.125 +    //beware of the fix path !
  17.126 +    public static void main(String[] args) {
  17.127 +        UserSettings s = new UserSettings("isac/xmldata/users/", "x");
  17.128 +        s.setProperty("start_worksheet", "SKIP_SPECIFY_START_SOLVE");
  17.129 +        s.setProperty("enter_specify", "SKIP_SPECIFY_START_SOLVE");
  17.130 +        s.setProperty("next_button", "FORMULAE_ONLY");
  17.131 +
  17.132 +        String filename = "isac/xmldata/users/x_settings.txt";
  17.133 +        try {
  17.134 +            FileOutputStream propOutFile = new FileOutputStream(filename);
  17.135 +            s.store(propOutFile, "static dialog data of user 'x'");
  17.136 +
  17.137 +        } catch (IOException e) {
  17.138 +            System.err.println("I/O failed.");
  17.139 +        }
  17.140 +    }
  17.141 +
  17.142 +}
  17.143 +
    18.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    18.2 +++ b/src/java/isac/util/usersettings/UserModel.java	Wed Jun 15 18:31:02 2005 +0200
    18.3 @@ -0,0 +1,163 @@
    18.4 +/*
    18.5 + * Created on Feb 22, 2005
    18.6 + *
    18.7 + * To change the template for this generated file go to
    18.8 + * Window>Preferences>Java>Code Generation>Code and Comments
    18.9 + */
   18.10 +package isac.util.usersettings;
   18.11 +
   18.12 +/**
   18.13 + * @author Alan Krempler
   18.14 + * 
   18.15 + * The UserModel is a class to gather statistics about one user's interaction
   18.16 + * with the system. Statistis are gathered per user and per interactional
   18.17 + * context.
   18.18 + */
   18.19 +public class UserModel {
   18.20 +
   18.21 +    //	special value for retrieving the statistics regardless of the dialog atom
   18.22 +    // used in the interaction
   18.23 +    public static final int DIALOG_ATOM_ANY = 0;
   18.24 +
   18.25 +    // counter for identifying pending interactions
   18.26 +    private static int interaction_nr_ = 1;
   18.27 +
   18.28 +    /**
   18.29 +     * @param item_id
   18.30 +     *            ID of the item being queried, a tactic for example
   18.31 +     * @param dialog_atom
   18.32 +     *            ID of the interactional context use DIALOG_ATOM_ANY if asking
   18.33 +     *            for statistics for all dialog atoms
   18.34 +     * @return count of previously recorded interactions with this item
   18.35 +     */
   18.36 +    public int getTouchedCount(int item_id, int dialog_atom) {
   18.37 +        // FIXME: returning dummy value in absence of valid statistics
   18.38 +        return 0;
   18.39 +    }
   18.40 +
   18.41 +    /**
   18.42 +     * @param item_id
   18.43 +     *            ID of the item being queried, a tactic for example
   18.44 +     * @param dialog_atom
   18.45 +     *            ID of the interactional context use DIALOG_ATOM_ANY if asking
   18.46 +     *            for statistics for all dialog atoms
   18.47 +     * @return count of previously recorded successful interactions with this
   18.48 +     *         item
   18.49 +     */
   18.50 +    public int getSuccessCount(int item_id, int dialog_atom) {
   18.51 +        // FIXME: returning dummy value in absence of valid statistics
   18.52 +        return 0;
   18.53 +    }
   18.54 +
   18.55 +    /**
   18.56 +     * @param item_id
   18.57 +     *            ID of the item being queried, a tactic for example
   18.58 +     * @param dialog_atom
   18.59 +     *            ID of the interactional context use DIALOG_ATOM_ANY if asking
   18.60 +     *            for statistics for all dialog atoms
   18.61 +     * @return time of last recorded interaction with this item
   18.62 +     */
   18.63 +    public java.util.Date getTouchedLast(int item_id, int dialog_atom) {
   18.64 +        // FIXME: returning dummy value in absence of valid statistics
   18.65 +        return new java.util.Date();
   18.66 +    }
   18.67 +
   18.68 +    /**
   18.69 +     * @param item_id
   18.70 +     *            ID of the item being queried, a tactic for example
   18.71 +     * @param dialog_atom
   18.72 +     *            ID of the interactional context use DIALOG_ATOM_ANY if asking
   18.73 +     *            for statistics for all dialog atoms
   18.74 +     * @return time of last recorded successful interaction with this item
   18.75 +     */
   18.76 +    public java.util.Date getSuccessLast(int item_id, int dialog_atom) {
   18.77 +        // FIXME: returning dummy value in absence of valid statistics
   18.78 +        return new java.util.Date();
   18.79 +    }
   18.80 +
   18.81 +    /**
   18.82 +     * @param item_id
   18.83 +     *            ID of the item being queried, a tactic for example
   18.84 +     * @param dialog_atom
   18.85 +     *            ID of the interactional context use DIALOG_ATOM_ANY if asking
   18.86 +     *            for statistics for all dialog atoms
   18.87 +     * @return average time (seconds) spent in interactions with this item
   18.88 +     */
   18.89 +    public int getTimeSpentAvg(int item_id, int dialog_atom) {
   18.90 +        // FIXME: returning dummy value in absence of valid statistics
   18.91 +        return 0;
   18.92 +    }
   18.93 +
   18.94 +    /**
   18.95 +     * @param item_id
   18.96 +     *            ID of the item being queried, a tactic for example
   18.97 +     * @param dialog_atom
   18.98 +     *            ID of the interactional context use DIALOG_ATOM_ANY if asking
   18.99 +     *            for statistics for all dialog atoms
  18.100 +     * @return maximum time (seconds) spent in interactions with this item
  18.101 +     */
  18.102 +    public int getTimeSpentMax(int item_id, int dialog_atom) {
  18.103 +        // FIXME: returning dummy value in absence of valid statistics
  18.104 +        return 0;
  18.105 +    }
  18.106 +
  18.107 +    /**
  18.108 +     * @param item_id
  18.109 +     *            ID of the item being queried, a tactic for example
  18.110 +     * @param dialog_atom
  18.111 +     *            ID of the interactional context use DIALOG_ATOM_ANY if asking
  18.112 +     *            for statistics for all dialog atoms
  18.113 +     * @return standard deviation of time spent in interactions with this item
  18.114 +     */
  18.115 +    public float getTimeSpentStddev(int item_id, int dialog_atom) {
  18.116 +        // FIXME: returning dummy value in absence of valid statistics
  18.117 +        return 0;
  18.118 +    }
  18.119 +
  18.120 +    /**
  18.121 +     * Mark the beginning of an interaction with an item.
  18.122 +     * 
  18.123 +     * @param item_id
  18.124 +     *            ID of the item being acted upon, a tactic for example
  18.125 +     * @param dialog_atom
  18.126 +     *            ID of the interactional context
  18.127 +     * @return unique number to indentify the end of the transaction
  18.128 +     */
  18.129 +    public int startInteraction(int item_id, int dialog_atom) {
  18.130 +        // FIXME: insert code to record statistics
  18.131 +
  18.132 +        // record timestamp
  18.133 +        // new java.util.Date(); ...
  18.134 +
  18.135 +        // save in static vector of currently open interactions
  18.136 +        // ...
  18.137 +
  18.138 +        return interaction_nr_++;
  18.139 +    }
  18.140 +
  18.141 +    /**
  18.142 +     * Mark the end of an interaction with an item.
  18.143 +     * 
  18.144 +     * @param interaction_id
  18.145 +     *            ID of the interaction returned from the call to
  18.146 +     *            {@link # startInteraction() }
  18.147 +     * @param success
  18.148 +     *            information about the success of the interaction
  18.149 +     * @return false in case of failure - no matching start could be found, true
  18.150 +     *         in case of success
  18.151 +     */
  18.152 +    public boolean endInteraction(int interaction_id, int success) {
  18.153 +        // FIXME: insert code to record statistics
  18.154 +
  18.155 +        // record end timestamp
  18.156 +        // new java.util.Date(); ...
  18.157 +
  18.158 +        // add to statistics
  18.159 +
  18.160 +        // delete from static vector of currently open interactions
  18.161 +        // ...
  18.162 +
  18.163 +        return true;
  18.164 +    }
  18.165 +
  18.166 +}
  18.167 \ No newline at end of file
    19.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    19.2 +++ b/src/java/isac/util/usersettings/UserSettings.java	Wed Jun 15 18:31:02 2005 +0200
    19.3 @@ -0,0 +1,55 @@
    19.4 +/*
    19.5 + * Created on Feb 22, 2005
    19.6 + *
    19.7 + * @author Alan Krempler
    19.8 + */
    19.9 +
   19.10 +package isac.util.usersettings;
   19.11 +
   19.12 +import java.io.Serializable;
   19.13 +import java.util.HashMap;
   19.14 +
   19.15 +/**
   19.16 + * Class for storing/retrieving user settings, i.e. settings which can be set
   19.17 + * manually by the user as opposed to the
   19.18 + * {@link isac.util.usersettings.UserModel#}, which is an abstraction of the
   19.19 + * system's expeience with a user and canot be altered manually. As there is no
   19.20 + * fixed set of user settings, you can regard this class as a simple storage
   19.21 + * backend for key/value pairs.
   19.22 + * 
   19.23 + * @author Alan Krempler
   19.24 + *  
   19.25 + */
   19.26 +public class UserSettings implements Serializable {
   19.27 +
   19.28 +    private HashMap storage_;
   19.29 +
   19.30 +    UserSettings() {
   19.31 +        storage_ = new HashMap();
   19.32 +    }
   19.33 +
   19.34 +    /**
   19.35 +     * @param key
   19.36 +     *            A string key
   19.37 +     * @return The string value associated with the key parameter; null, if
   19.38 +     *         nothing is stored under this key
   19.39 +     */
   19.40 +    public String getValue(String key) {
   19.41 +        return (String) storage_.get(key);
   19.42 +    }
   19.43 +
   19.44 +    /**
   19.45 +     * @param key
   19.46 +     *            The key under which "value" is to be stored. Existing data
   19.47 +     *            unde the same key will be replaced.
   19.48 +     * @param value
   19.49 +     *            The value to be stored under "key"
   19.50 +     * @return true in case of success, false in case of error, for example if
   19.51 +     *         trying to replace stored values without proper permissions
   19.52 +     */
   19.53 +    public boolean setValue(String key, String value) {
   19.54 +        storage_.put(key, value);
   19.55 +        return true;
   19.56 +    }
   19.57 +
   19.58 +}
   19.59 \ No newline at end of file
    20.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    20.2 +++ b/src/java/isac/wsdialog/ActionOnUIElement.java	Wed Jun 15 18:31:02 2005 +0200
    20.3 @@ -0,0 +1,24 @@
    20.4 +/*
    20.5 + * Created on Feb 6, 2004
    20.6 + */
    20.7 +package isac.wsdialog;
    20.8 +
    20.9 +/**
   20.10 + * Describes an action which has to pass a UI Element, e.g a activation or
   20.11 + * deactivating buttons.
   20.12 + * 
   20.13 + * @see isac.wsdialog.IUIElement
   20.14 + * @author Alan Krempler
   20.15 + */
   20.16 +public class ActionOnUIElement extends UserAction {
   20.17 +    private int ui_element_id_;
   20.18 +
   20.19 +    public ActionOnUIElement(int id, int ui_element_id) {
   20.20 +        super(id);
   20.21 +        ui_element_id_ = ui_element_id;
   20.22 +    }
   20.23 +
   20.24 +    public int getUIElementId() {
   20.25 +        return ui_element_id_;
   20.26 +    }
   20.27 +}
   20.28 \ No newline at end of file
    21.1 --- a/src/java/isac/wsdialog/DialogGuide.java	Fri Oct 10 12:15:14 2003 +0200
    21.2 +++ b/src/java/isac/wsdialog/DialogGuide.java	Wed Jun 15 18:31:02 2005 +0200
    21.3 @@ -1,124 +1,600 @@
    21.4  package isac.wsdialog;
    21.5  
    21.6 -import isac.bridge.CalcTree;
    21.7 +import isac.bridge.*;
    21.8 +import isac.session.SDialog;
    21.9  import isac.util.*;
   21.10 -import isac.util.ModSpec;
   21.11 -import isac.util.Tactic;
   21.12 +import isac.util.formulae.*;
   21.13 +import isac.util.interfaces.*;
   21.14 +import isac.util.tactics.*;
   21.15 +import isac.util.users.IUserSettings;
   21.16 +import isac.util.users.User;
   21.17 +import isac.util.users.UserSettings;
   21.18  
   21.19  import java.io.Serializable;
   21.20  import java.net.MalformedURLException;
   21.21  import java.rmi.*;
   21.22  import java.rmi.registry.LocateRegistry;
   21.23  import java.rmi.server.UnicastRemoteObject;
   21.24 -import java.util.StringTokenizer;
   21.25 +import java.util.Vector;
   21.26 +
   21.27 +import org.apache.log4j.Logger;
   21.28  
   21.29  /**
   21.30 + * The DialogGuide moderates the communication between two instances working on
   21.31 + * the same CalcTree object. One of these instances is the user, the other a
   21.32 + * math engine. Most probably, the user's GUI, the DialogGuide and the math
   21.33 + * engine reside on different machines and communicate with each other by means
   21.34 + * of RMI.
   21.35 + * 
   21.36   * @author Alan Krempler
   21.37   */
   21.38 +public class DialogGuide extends UnicastRemoteObject implements DGuide,
   21.39 +        IToUser, Serializable {
   21.40  
   21.41 +    static Logger logger_ = Logger.getLogger(BridgeRMI.class.getName());
   21.42  
   21.43 -public class DialogGuide extends UnicastRemoteObject 
   21.44 -                         implements DGuide, IToUser, IToCalc, Serializable {
   21.45 -  /**
   21.46 -   * @throws RemoteException
   21.47 -   */
   21.48 -  protected DialogGuide() throws RemoteException {
   21.49 -    super();
   21.50 -    this.rmiBind();
   21.51 -  }
   21.52 +    protected MathEngine math_engine_;
   21.53  
   21.54 -  protected CalcTree calcTree;
   21.55 - 
   21.56 -	public void attach(CalcTree calc_tree) {
   21.57 -	  
   21.58 -	}
   21.59 +    //the calc_tree_ is also known by the DialogIterators -- remove AK?LK?
   21.60 +    //WN0505 only needed by getElementsFromTo !! move method to Iterator?
   21.61 +    protected CalcTree calc_tree_;
   21.62  
   21.63 -	public void reDisplay() {
   21.64 -	}
   21.65 +    //protected CalcHead calc_head_;
   21.66  
   21.67 -	public void newCalculation(ModSpec mod_spec) {
   21.68 -	  calcTree = new CalcTree(mod_spec, "radish.ist.intra", 5555);    
   21.69 -	}
   21.70 +    //protected CalcHead calc_head_sub_;
   21.71  
   21.72 -	/* (non-Javadoc)
   21.73 -	 * @see isac.wsdialog.IToUser#calcChanged(isac.wsdialog.CalcChangedEvent)
   21.74 -	 */
   21.75 -	public void calcChanged(CalcChangedEvent event) {
   21.76 -		// TODO Auto-generated method stub
   21.77 -		
   21.78 -	}
   21.79 +    protected int phase_;
   21.80  
   21.81 -	/* (non-Javadoc)
   21.82 -	 * @see isac.wsdialog.IToCalc#iterator()
   21.83 -	 */
   21.84 -	public ICalcIterator iterator() {
   21.85 -		return calcTree.iterator();
   21.86 -	}
   21.87 +    private Vector datachange_listeners_;
   21.88  
   21.89 -	/* (non-Javadoc)
   21.90 -	 * @see isac.wsdialog.IToCalc#addListener(isac.wsdialog.IToUser)
   21.91 -	 */
   21.92 -	public boolean addListener(IToUser listener) {
   21.93 -		// TODO Auto-generated method stub
   21.94 -		return false;
   21.95 -	}
   21.96 -  
   21.97 -  public Tactic fetchProposedTactic() {
   21.98 -    //TODO: ask Walther for improvements. Stupid thing this.
   21.99 -    Tactic t = calcTree.fetchProposedTactic();
  21.100 -    StringTokenizer tokenizer = new StringTokenizer(t.getName(), "_");
  21.101 -    StringBuffer tacticStringCap = new StringBuffer();
  21.102 -    int tokens = tokenizer.countTokens();
  21.103 -    for (int i = 0; i < tokens; i++) {
  21.104 -      String s = tokenizer.nextToken().toLowerCase();
  21.105 -      char c = Character.toUpperCase(s.charAt(0));
  21.106 -      tacticStringCap.append(c).append(s.substring(1));
  21.107 -      if (i != tokens - 1)
  21.108 -        tacticStringCap.append("_");          
  21.109 +    private IToWorksheet ui_control_listener_;
  21.110 +
  21.111 +    //protected String session_id_;WN0503
  21.112 +
  21.113 +    protected UserSettings user_settings_;//hold whole hashmap locally
  21.114 +
  21.115 +    /**
  21.116 +     * @param ME_path
  21.117 +     *            URL of the math engine to be used
  21.118 +     * @param user_path
  21.119 +     *            path(without URL) to UserSettings, UserModel
  21.120 +     * @param session_dialog
  21.121 +     * @param session_id
  21.122 +     *            which create the DialogGuide and Worksheet
  21.123 +     * @throws RemoteException
  21.124 +     */
  21.125 +    public DialogGuide(String ME_path, String user_path,
  21.126 +            SDialog session_dialog, String session_id) throws RemoteException {
  21.127 +        super();
  21.128 +        this.rmiBind();
  21.129 +        datachange_listeners_ = new Vector();
  21.130 +        MathEngine.init(ME_path);
  21.131 +        math_engine_ = MathEngine.getMathEngine();
  21.132 +        phase_ = DIALOGPHASE_IDLE;
  21.133 +
  21.134 +        User user = null;
  21.135 +        try {
  21.136 +            user = session_dialog.getUser(session_id);
  21.137 +        } catch (RemoteException e1) {
  21.138 +            e1.printStackTrace();
  21.139 +        }
  21.140 +        user_settings_ = new UserSettings(user_path, user.getUsername());
  21.141      }
  21.142 -    //System.out.println(tacticStringCap.toString());
  21.143 -    t.setName(tacticStringCap.toString());
  21.144 -    return t;
  21.145 -  }
  21.146 -  
  21.147 -  public void setNextTactic(Tactic tactic) {
  21.148 -    calcTree.setNextTactic(tactic);
  21.149 -  }
  21.150 -  
  21.151 -  private void rmiBind(){
  21.152 -    if(System.getSecurityManager() == null) {
  21.153 -      System.setSecurityManager(new RMISecurityManager());
  21.154 +
  21.155 +    /**
  21.156 +     * start a calculation
  21.157 +     */
  21.158 +    public CalcTree startCalculation(int user_id, Formalization f,
  21.159 +            int start_from/* WN050421 , int requested_calchead_view */) {
  21.160 +
  21.161 +        phase_ = DIALOGPHASE_SOLVE;
  21.162 +        calc_tree_ = math_engine_.startCalculation(f);
  21.163 +        calc_tree_.addDataChangeListener(this);
  21.164 +        return calc_tree_;
  21.165      }
  21.166 -    
  21.167 -    try{
  21.168 -      LocateRegistry.createRegistry(1099);
  21.169 -    }catch(java.rmi.RemoteException exc2){
  21.170 -      System.err.println("can not create registry: " + exc2.getMessage());
  21.171 +
  21.172 +    /**
  21.173 +     * at the beginning of a calculation as well as of a subproblem;
  21.174 +     * 
  21.175 +     * @return CalcHead eg. for providing CalcHead#VIEWSTYLE_*
  21.176 +     * 
  21.177 +     * @see isac.wsdialog.DGuide#startSpecifying()
  21.178 +     */
  21.179 +    public CalcHead startSpecifying() {
  21.180 +        ICalcIterator it = null;
  21.181 +        CalcHead calc_head = null;
  21.182 +        int calchead_view;
  21.183 +        try {
  21.184 +            it = calc_tree_.iterator();
  21.185 +            //			WN0504DI it = this.iterator();//WN050421 NEW...
  21.186 +            it.moveRoot();
  21.187 +            //WN0504DI ...error DialogGuide_Stub.startSpecifying(Unknown
  21.188 +            //WN0504DI Source) with ...NEW
  21.189 +            calc_head = (CalcHead) it.getFormula();
  21.190 +        } catch (RemoteException e) {
  21.191 +            e.printStackTrace();
  21.192 +        }
  21.193 +
  21.194 +        //AK set viewstyle according to user settings
  21.195 +        switch (user_settings_.getValue(IUserSettings.KEY1_START_SPECIFY)) {
  21.196 +        //________________________________________________________
  21.197 +        case IUserSettings.VAL1_SKIP_SPECIFY_TO_START_SOLVE:
  21.198 +            calc_tree_.completeCalcHead();
  21.199 +            calchead_view = CalcHead.VIEWSTYLE_SINGLELINE;
  21.200 +            phase_ = DIALOGPHASE_SOLVE;
  21.201 +            break;
  21.202 +        //________________________________________________________
  21.203 +        case IUserSettings.VAL1_POP_CALCHEAD_WITH_DESCRIPTIONS:
  21.204 +            calc_tree_.autoCalculate(IToCalc.SCOPE_CALCULATION, 1);
  21.205 +            //...applies the Tactic Model_Problem which generates descriptions
  21.206 +            calchead_view = CalcHead.VIEWSTYLE_FULL;
  21.207 +            phase_ = DIALOGPHASE_SPECIFY;
  21.208 +            break;
  21.209 +        //________________________________________________________
  21.210 +        default:
  21.211 +            //=case IUserSettings.VAL1_SKIP_SPECIFY_TO_START_SOLVE:
  21.212 +            calc_tree_.completeCalcHead();
  21.213 +            calchead_view = CalcHead.VIEWSTYLE_SINGLELINE;
  21.214 +            phase_ = DIALOGPHASE_SOLVE;
  21.215 +            break;
  21.216 +        }
  21.217 +        calc_head.setViewStyle(calchead_view);
  21.218 +        return calc_head;
  21.219      }
  21.220 -    
  21.221 -    String name = "//localhost/isac-DialogGuide";
  21.222 -    try {
  21.223 -      System.out.println("try to bind as " + name);
  21.224 -      Naming.rebind(name, this);
  21.225 -      System.out.println("Object Manager bound to " + name);
  21.226 -    } catch (java.rmi.ConnectException e) {     
  21.227 -    System.err.println("failed to contact as " + name +
  21.228 -                       " (creating RMI-Server on localhost: 1099)");
  21.229 -    } catch (RemoteException e) {
  21.230 -      // TODO Auto-generated catch block
  21.231 -      e.printStackTrace();
  21.232 -    } catch (MalformedURLException e) {
  21.233 -      // TODO Auto-generated catch block
  21.234 -      e.printStackTrace();
  21.235 +
  21.236 +    //	/**
  21.237 +    //	 * @deprecated Use {@link #notifyUserAction(IUserAction)}instead
  21.238 +    //	 */
  21.239 +    //	public void modifyCalcHead(CalcHead calc_head) {
  21.240 +    //		// MathEngine.getMathEngine().modifyCalcHead(calc_head);
  21.241 +    //		calc_tree_.modifyCalcHead(calc_head);
  21.242 +    //	}
  21.243 +
  21.244 +    /**
  21.245 +     * dismiss the CalcHeadPanel and start DGuide#DIALOGPHASE_SOLVE
  21.246 +     * 
  21.247 +     * @see isac.util.interfaces.IToCalc#startSolving()
  21.248 +     */
  21.249 +    public void startSolving() throws Exception {
  21.250 +        calc_tree_.startSolving();
  21.251 +
  21.252      }
  21.253 -  }
  21.254 -  
  21.255 -  public static void main(String[] args) {
  21.256 -    try {
  21.257 -      new DialogGuide();
  21.258 -    } catch (RemoteException e) {
  21.259 -      // TODO Auto-generated catch block
  21.260 -      e.printStackTrace();
  21.261 +
  21.262 +    /**
  21.263 +     * accept the changes in a calculation reported by the bridge ..............
  21.264 +     * TODO handle these changes according to UserSettings and UserModel
  21.265 +     * 
  21.266 +     * ... and pass them to the Worksheet
  21.267 +     * 
  21.268 +     * @see isac.wsdialog.IToUser#calcChanged(isac.wsdialog.CalcChangedEvent)
  21.269 +     */
  21.270 +    public void calcChanged(CalcChangedEvent event) throws RemoteException {
  21.271 +        logger_.fatal(" WS<-. . : calcChanged (unc="
  21.272 +                + event.getLastUnchangedFormula().toSMLString() + ", del="
  21.273 +                + event.getLastDeletedFormula().toSMLString() + ", gen="
  21.274 +                + event.getLastGeneratedFormula().toSMLString());
  21.275 +        try {
  21.276 +            for (int i = 0; i < datachange_listeners_.size(); i++) {
  21.277 +                ((IToUser) datachange_listeners_.elementAt(i))
  21.278 +                        .calcChanged(event);//WN050513GOON
  21.279 +                // .calcChanged(event.createDialogIterators(this));
  21.280 +            }
  21.281 +        } catch (Exception e) {
  21.282 +            e.printStackTrace();
  21.283 +        }
  21.284      }
  21.285 -  }
  21.286 -}
  21.287 +
  21.288 +    /**
  21.289 +     * @see isac.wsdialog.DGuide#iterator(CalcIterator, DGuide)
  21.290 +     * @see isac.util.interfaces.IToCalc#iterator()
  21.291 +     */
  21.292 +    public ICalcIterator iterator(CalcIterator it, DGuide dg) {
  21.293 +        //WN050512...was before:
  21.294 +        //public ICalcIterator iterator() {
  21.295 +        //		try {
  21.296 +        //			return new DialogIterator((CalcIterator) calc_tree_.iterator(),
  21.297 +        //					this);
  21.298 +        //		} catch (Exception e) {
  21.299 +        //			e.printStackTrace();
  21.300 +        //		}
  21.301 +        //		return null;
  21.302 +        try {
  21.303 +            return new DialogIterator(it, dg);
  21.304 +        } catch (RemoteException e) {
  21.305 +            e.printStackTrace();
  21.306 +        }
  21.307 +        return null;
  21.308 +    }
  21.309 +
  21.310 +    /**
  21.311 +     * @see isac.wsdialog.IToCalc#addListener(isac.wsdialog.IToUser)
  21.312 +     */
  21.313 +    public boolean addDataChangeListener(IToUser listener)
  21.314 +            throws RemoteException {
  21.315 +        if (datachange_listeners_.contains(listener)) {
  21.316 +            return false;
  21.317 +        } else {
  21.318 +            datachange_listeners_.add(listener);
  21.319 +        }
  21.320 +        return true;
  21.321 +    }
  21.322 +
  21.323 +    public boolean registerUIControlListener(IToWorksheet listener)
  21.324 +            throws RemoteException {
  21.325 +        //WN0504 ???
  21.326 +        //		if (ui_control_listener_ != null) {
  21.327 +        //			ui_control_listener_.doUIAction(new UserAction(UI_DO_DETACH));
  21.328 +        //		}
  21.329 +        ui_control_listener_ = listener;
  21.330 +        return true;
  21.331 +    }
  21.332 +
  21.333 +    //	/**
  21.334 +    //	 * @see isac.wsdialog.IToCalc#fetchProposedTactic
  21.335 +    //	 * @deprecated Use {@link #notifyUserAction(IUserAction)}instead
  21.336 +    //	 */
  21.337 +    //	public Tactic fetchProposedTactic() {
  21.338 +    //		return calc_tree_.fetchProposedTactic();
  21.339 +    //	}
  21.340 +    //
  21.341 +    //
  21.342 +    //	/**
  21.343 +    //	 * @deprecated Use {@link #notifyUserAction(IUserAction)}instead
  21.344 +    //	 */
  21.345 +    //	public int setNextTactic(Tactic tactic) {
  21.346 +    //		return calc_tree_.setNextTactic(tactic);
  21.347 +    //	}
  21.348 +    //
  21.349 +    //	/**
  21.350 +    //	 * @deprecated Use {@link #notifyUserAction(IUserAction)}instead
  21.351 +    //	 */
  21.352 +    //	public int autoCalculate(int scope, int nSteps) {
  21.353 +    //		return calc_tree_.autoCalculate(scope, nSteps);
  21.354 +    //	}
  21.355 +    //
  21.356 +    //	/**
  21.357 +    //	 * @deprecated Use {@link #notifyUserAction(IUserAction)}instead
  21.358 +    //	 */
  21.359 +    //	public void tryMatch(CalcHead ch, CalcHeadCompoundID problemID)
  21.360 +    //			throws NotInSpecificationPhaseException {
  21.361 +    //
  21.362 +    //		// MathEngine.getMathEngine().tryMatch(ch, problemID);
  21.363 +    //		math_engine_.tryMatch(ch, problemID);
  21.364 +    //	}
  21.365 +    //
  21.366 +    //	/**
  21.367 +    //	 * @deprecated Use {@link #notifyUserAction(IUserAction)}instead
  21.368 +    //	 */
  21.369 +    //	public void tryRefine(CalcHead ch, CalcHeadCompoundID problemID)
  21.370 +    //			throws NotInSpecificationPhaseException {
  21.371 +    //
  21.372 +    //		// MathEngine.getMathEngine().tryRefine(ch , problemID);
  21.373 +    //		math_engine_.tryRefine(ch, problemID);
  21.374 +    //	}
  21.375 +    //
  21.376 +    //	/**
  21.377 +    //	 * @deprecated Use {@link #notifyUserAction(IUserAction)}instead
  21.378 +    //	 */
  21.379 +    //	public ICalcIterator getActiveFormula() {
  21.380 +    //		return calc_tree_.getActiveFormula();
  21.381 +    //	}
  21.382 +    //
  21.383 +    //	/**
  21.384 +    //	 * @throws RemoteException
  21.385 +    //	 * @deprecated Use {@link #notifyUserAction(IUserAction)}instead
  21.386 +    //	 */
  21.387 +    //	public int replaceFormula(CalcFormula newFormula) throws RemoteException
  21.388 +    // {
  21.389 +    //		return calc_tree_.replaceFormula(newFormula);
  21.390 +    //	}
  21.391 +    //
  21.392 +    //	/**
  21.393 +    //	 * @throws RemoteException
  21.394 +    //	 * @deprecated Use {@link #notifyUserAction(IUserAction)}instead
  21.395 +    //	 */
  21.396 +    //	public int appendFormula(CalcFormula newFormula) throws RemoteException {
  21.397 +    //		return calc_tree_.appendFormula(newFormula);
  21.398 +    //	}
  21.399 +    //
  21.400 +    //	/**
  21.401 +    //	 * @deprecated Use {@link #notifyUserAction(IUserAction)}instead
  21.402 +    //	 */
  21.403 +    //	public void moveActiveFormula(ICalcIterator newActiveFormula) {
  21.404 +    //		calc_tree_.moveActiveFormula(newActiveFormula);
  21.405 +    //	}
  21.406 +    //
  21.407 +    /**
  21.408 +     * Notify the Dialog Guide about interaction from the User
  21.409 +     * 
  21.410 +     * @param action
  21.411 +     * @return true, if the action has been processed, false if the processing
  21.412 +     *         the action has been denied
  21.413 +     * @throws RemoteException
  21.414 +     *  
  21.415 +     */
  21.416 +    public boolean notifyUserAction(IUserAction action)
  21.417 +            throws DialogProtocolException, RemoteException {
  21.418 +        int request = action.getActionID();
  21.419 +        logger_.fatal(" WS->DG: notifyUserAction request= " + request);
  21.420 +
  21.421 +        // two userActions dont care about the dialogphase
  21.422 +        //WN050420 would be nicer, if DialogGuide would set the Buttons
  21.423 +        switch (request) {
  21.424 +        case (UI_CALCULATE_1):
  21.425 +            if (phase_ == DIALOGPHASE_SPECIFY)
  21.426 +                request = UI_SPECIFY_TO_SOLVE;//WN#####################
  21.427 +            else
  21.428 +                request = UI_SOLVE_CALCULATE_1;
  21.429 +            break;
  21.430 +        case (UI_CALCULATE_ALL):
  21.431 +            if (phase_ == DIALOGPHASE_SPECIFY)
  21.432 +                request = UI_SPECIFY_CALCULATE_ALL;
  21.433 +            else
  21.434 +                request = UI_SOLVE_CALCULATE_ALL;
  21.435 +        }
  21.436 +        // all other userActions belong to a certain dialogphase
  21.437 +
  21.438 +        switch (phase_) {
  21.439 +        case DIALOGPHASE_IDLE:
  21.440 +            throw new DialogProtocolException(request, phase_);
  21.441 +        case DIALOGPHASE_SPECIFY:
  21.442 +            if (request < UI_DUMMY_FIRST_SPECIFY
  21.443 +                    || request > UI_DUMMY_LAST_SPECIFY)
  21.444 +                throw new DialogProtocolException(request, phase_);
  21.445 +            break;
  21.446 +        case DIALOGPHASE_SOLVE:
  21.447 +            if (request < UI_DUMMY_FIRST_SOLVE || request > UI_DUMMY_LAST_SOLVE)
  21.448 +                throw new DialogProtocolException(request, phase_);
  21.449 +            break;
  21.450 +        }
  21.451 +
  21.452 +        //*********** handle IUserAction's **********************
  21.453 +        CalcHead calc_head = new CalcHead();//WN0502023?????????
  21.454 +        try {
  21.455 +            calc_head = (CalcHead) calc_tree_.iterator().getFormula();
  21.456 +        } catch (Exception e) {
  21.457 +            e.printStackTrace();
  21.458 +        }
  21.459 +        switch (request) {
  21.460 +        case UI_SPECIFY_TRY_MATCH:
  21.461 +            throw new DialogNotImplementedException(request, phase_);
  21.462 +        //			try {
  21.463 +        //				tryMatch(calc_head, ((UserActionOnCalcHeadCompoundID) action)
  21.464 +        //						.getObjectID());
  21.465 +        //			} catch (NotInSpecificationPhaseException e) {
  21.466 +        //				throw new DialogMathException(request, phase_, e);
  21.467 +        //			}
  21.468 +        //			break;
  21.469 +
  21.470 +        case UI_SPECIFY_TRY_REFINE:
  21.471 +            throw new DialogNotImplementedException(request, phase_);
  21.472 +        //			try {
  21.473 +        //				tryRefine(calc_head, ((UserActionOnCalcHeadCompoundID) action)
  21.474 +        //						.getObjectID());
  21.475 +        //			} catch (NotInSpecificationPhaseException e) {
  21.476 +        //				throw new DialogMathException(request, phase_, e);
  21.477 +        //			}
  21.478 +        //			break;
  21.479 +
  21.480 +        case UI_SPECIFY_CHANGE_VIEW:
  21.481 +            calc_head.setViewStyle(((UserActionOnInt) action).getInt());
  21.482 +            break;
  21.483 +
  21.484 +        case UI_SPECIFY_COMPLETE_CALCHEAD:
  21.485 +            calc_tree_.completeCalcHead();
  21.486 +            // old-style filling the fields of the calc-head by setting
  21.487 +            // the HELP_ME flag
  21.488 +            // calc_head_.setCalcHeadStatus(CalcHead.MODEL_ITEM_HELP_ME);
  21.489 +            // modifyCalcHead(calc_head_);
  21.490 +            break;
  21.491 +        case UI_SPECIFY_COMPLETE_METHOD:
  21.492 +        case UI_SPECIFY_COMPLETE_THEORY:
  21.493 +        case UI_SPECIFY_COMPLETE_PROBLEM:
  21.494 +        case UI_SPECIFY_COMPLETE_GIVEN:
  21.495 +        case UI_SPECIFY_COMPLETE_FIND:
  21.496 +        case UI_SPECIFY_COMPLETE_RELATE:
  21.497 +            throw new DialogNotImplementedException(request, phase_);
  21.498 +
  21.499 +        case UI_SPECIFY_CHECK_CALCHEAD:
  21.500 +            calc_tree_.modifyCalcHead(calc_head);
  21.501 +            break;
  21.502 +
  21.503 +        // was: startCalculation() WN050428 ? really ?
  21.504 +        case UI_SPECIFY_TO_SOLVE:
  21.505 +        case UI_SPECIFY_CALCULATE_ALL:
  21.506 +            //if (user_settings_.getValue(""))
  21.507 +            if (true)
  21.508 +                calc_tree_.completeCalcHead();
  21.509 +            else
  21.510 +                calc_tree_.modifyCalcHead(calc_head);
  21.511 +
  21.512 +            if (calc_head.getCalcHeadStatus() != CalcHead.MODEL_ITEM_CORRECT)
  21.513 +                return false;
  21.514 +
  21.515 +            try {
  21.516 +                calc_tree_.startSolving();
  21.517 +            } catch (Exception e) {
  21.518 +                // TODO Auto-generated catch block
  21.519 +                e.printStackTrace();
  21.520 +            }
  21.521 +            // calc_tree_ = MathEngine.getMathEngine().startSolving(calcHead);
  21.522 +            // FIXME: AK020224: do not register with the calc_tree_ if finished
  21.523 +            // specifying a SUBPROBLEM
  21.524 +            //calc_tree_.addDataChangeListener(this);//WN050420-->startCalculation
  21.525 +
  21.526 +            phase_ = DIALOGPHASE_SOLVE;//FIXXXME.WN050428
  21.527 +        // fall through to calculate
  21.528 +
  21.529 +        case UI_SOLVE_CALCULATE_1:
  21.530 +        //WN050420 why not at (*) here ?
  21.531 +        case UI_SOLVE_CALCULATE_ALL:
  21.532 +            switch (request) {
  21.533 +            case UI_SPECIFY_CALCULATE_ALL:
  21.534 +            case UI_SOLVE_CALCULATE_ALL:
  21.535 +                calc_tree_.autoCalculate(IToCalc.SCOPE_CALCULATION, 0);
  21.536 +                break;
  21.537 +            case UI_SPECIFY_TO_SOLVE://WN050420 ???
  21.538 +            // break;
  21.539 +            default:
  21.540 +                calc_tree_.autoCalculate(IToCalc.SCOPE_CALCULATION, 1);
  21.541 +                //why not at (*) above ?
  21.542 +                break;
  21.543 +            }
  21.544 +            break;
  21.545 +
  21.546 +        case UI_SOLVE_CALCULATE_SUBPROBLEM:
  21.547 +            calc_tree_.autoCalculate(IToCalc.SCOPE_SUBPROBLEM, 0);
  21.548 +            break;
  21.549 +
  21.550 +        case UI_SOLVE_EDIT_ACTIVE_FORMULA:
  21.551 +            ui_control_listener_.doUIAction(new UserAction(UI_DO_EDIT_FORMULA));
  21.552 +            break;
  21.553 +
  21.554 +        case UI_SOLVE_EDIT_ACTIVE_FORMULA_COMPLETE:
  21.555 +            CalcFormula formula = (CalcFormula) ((UserActionOnCalcElement) action)
  21.556 +                    .getCalcElement();
  21.557 +            // if the position is null, the formula did not exist, so we try to
  21.558 +            // append a new formula
  21.559 +            if (formula.getPosition() == null) {
  21.560 +                calc_tree_.appendFormula(formula);
  21.561 +            } else {
  21.562 +                calc_tree_.replaceFormula(formula);
  21.563 +            }
  21.564 +            break;
  21.565 +
  21.566 +        case UI_SOLVE_APPEND_USER_FORMULA:
  21.567 +            // appendFormula((Formula) ((UserActionOnCalcElement)
  21.568 +            // action).getCalcElement());
  21.569 +            ui_control_listener_
  21.570 +                    .doUIAction(new UserAction(UI_DO_APPEND_FORMULA));
  21.571 +            break;
  21.572 +
  21.573 +        case UI_SOLVE_MOVE_ACTIVE_FORMULA:
  21.574 +            calc_tree_.moveActiveFormula(((UserActionOnIterator) action)
  21.575 +                    .getPosition());
  21.576 +            break;
  21.577 +
  21.578 +        case UI_SOLVE_GET_PROPOSED_TACTIC:
  21.579 +            throw new DialogNotImplementedException(request, phase_);
  21.580 +
  21.581 +        case UI_SOLVE_GET_APPLICABLE_TACTICS:
  21.582 +            throw new DialogNotImplementedException(request, phase_);
  21.583 +
  21.584 +        case UI_SOLVE_SET_NEXT_TACTIC:
  21.585 +            calc_tree_
  21.586 +                    .setNextTactic((Tactic) ((UserActionOnCalcElement) action)
  21.587 +                            .getCalcElement());
  21.588 +            //WN041126 extracted from isac.bridge.CalcTree#setNextTactic @@@
  21.589 +            //autoCalculate(SCOPE_CALCULATION, 1);
  21.590 +            break;
  21.591 +
  21.592 +        case UI_SOLVE_HELP_ENTERING_FORMULA:
  21.593 +            throw new DialogNotImplementedException(request, phase_);
  21.594 +
  21.595 +        case UI_SOLVE_SHOW_ASSUMPTIONS:
  21.596 +            throw new DialogNotImplementedException(request, phase_);
  21.597 +
  21.598 +        case UI_SOLVE_SHOW_DETAILS:
  21.599 +            throw new DialogNotImplementedException(request, phase_);
  21.600 +
  21.601 +        default:
  21.602 +            throw new DialogUnknownActionException(request, phase_);
  21.603 +        }
  21.604 +        return true;
  21.605 +    }
  21.606 +
  21.607 +    private void rmiBind() {
  21.608 +        if (System.getSecurityManager() == null) {
  21.609 +            System.setSecurityManager(new RMISecurityManager());
  21.610 +        }
  21.611 +
  21.612 +        try {
  21.613 +            LocateRegistry.createRegistry(1099);
  21.614 +        } catch (java.rmi.RemoteException exc2) {
  21.615 +            System.err.println("can not create registry: " + exc2.getMessage());
  21.616 +        }
  21.617 +
  21.618 +        String name = "//localhost/isac-DialogGuide";
  21.619 +        try {
  21.620 +            System.out.println("try to bind as " + name);
  21.621 +            Naming.rebind(name, this);
  21.622 +            System.out.println("Dialog Guide bound to " + name);
  21.623 +            //WN040906 was Object Manager ...
  21.624 +        } catch (java.rmi.ConnectException e) {
  21.625 +            System.err.println("failed to contact as " + name
  21.626 +                    + " (creating RMI-Server on localhost: 1099)");
  21.627 +        } catch (RemoteException e) {
  21.628 +            // TODO Auto-generated catch block
  21.629 +            e.printStackTrace();
  21.630 +        } catch (MalformedURLException e) {
  21.631 +            // TODO Auto-generated catch block
  21.632 +            e.printStackTrace();
  21.633 +        }
  21.634 +    }
  21.635 +
  21.636 +    //	public static void main(String[] args) {
  21.637 +    //		try {
  21.638 +    //			new DialogGuide(args[0]);
  21.639 +    //
  21.640 +    //		} catch (RemoteException e) {
  21.641 +    //			e.printStackTrace();
  21.642 +    //		}
  21.643 +    //	}
  21.644 +
  21.645 +    //	/**
  21.646 +    //	 * @see
  21.647 +    // isac.util.interfaces.IToCalc#completeCalcHead(isac.util.formulae.CalcHead)
  21.648 +    //	 * @deprecated Use {@link #notifyUserAction(IUserAction)}instead
  21.649 +    //	 */
  21.650 +    //	public void completeCalcHead(CalcHead calcHead) {
  21.651 +    //		// TODO Auto-generated method stub
  21.652 +    //
  21.653 +    //	}
  21.654 +    //
  21.655 +    //	/**
  21.656 +    //	 * @see
  21.657 +    // isac.util.interfaces.IToCalc#completeCalcHead(isac.util.formulae.CalcHead,
  21.658 +    //	 * int)
  21.659 +    //	 * @deprecated Use {@link #notifyUserAction(IUserAction)}instead
  21.660 +    //	 */
  21.661 +    //	public void completeCalcHead(CalcHead calcHead, int completeItem) {
  21.662 +    //		// TODO Auto-generated method stub
  21.663 +    //
  21.664 +    //	}
  21.665 +    //
  21.666 +    //	/**
  21.667 +    //	 * (non-Javadoc)
  21.668 +    //	 *
  21.669 +    //	 * @see isac.util.interfaces.IToCalc#completeCalcHead()
  21.670 +    //	 * @deprecated Use {@link #notifyUserAction(IUserAction)}instead
  21.671 +    //	 */
  21.672 +    //	public void completeCalcHead() throws RemoteException {
  21.673 +    //		// TODO Auto-generated method stub WN050223
  21.674 +    //
  21.675 +    //	}
  21.676 +    //
  21.677 +    //	/**
  21.678 +    //	 * @deprecated Use {@link #notifyUserAction(IUserAction)}instead
  21.679 +    //	 *
  21.680 +    //	 * @see
  21.681 +    // isac.util.interfaces.IToCalc#intermediateSteps(isac.util.interfaces.ICalcIterator)
  21.682 +    //	 */
  21.683 +    //	public int intermediateSteps(ICalcIterator i) throws RemoteException {
  21.684 +    //		// TODO Auto-generated method stub
  21.685 +    //		return 0;
  21.686 +    //	}
  21.687 +    //
  21.688 +    //	/**
  21.689 +    //	 * @see
  21.690 +    // isac.util.interfaces.IToCalc#getElementsFromTo(isac.util.interfaces.ICalcIterator,
  21.691 +    //	 * isac.util.interfaces.ICalcIterator, java.lang.Integer, boolean)
  21.692 +    //	 * @deprecated Use {@link #notifyUserAction(IUserAction)}instead
  21.693 +    //	 */
  21.694 +    //	public Vector getElementsFromTo(ICalcIterator iterator_from,
  21.695 +    //			ICalcIterator iterator_to, Integer level,
  21.696 +    //			boolean result_includes_tactics) throws RemoteException {
  21.697 +    //		// TODO Auto-generated method stub
  21.698 +    //		return null;
  21.699 +    //	}
  21.700 +
  21.701 +}
  21.702 \ No newline at end of file
    22.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    22.2 +++ b/src/java/isac/wsdialog/DialogMathException.java	Wed Jun 15 18:31:02 2005 +0200
    22.3 @@ -0,0 +1,22 @@
    22.4 +/*
    22.5 + * Created on Feb 12, 2004
    22.6 + *
    22.7 + */
    22.8 +
    22.9 +package isac.wsdialog;
   22.10 +
   22.11 +/**
   22.12 + * Exception thrown by the DialogGuide if the user action indicated caused an
   22.13 + * error in the math engine.
   22.14 + * 
   22.15 + * @author Alan Krempler
   22.16 + *  
   22.17 + */
   22.18 +class DialogMathException extends DialogProtocolException {
   22.19 +
   22.20 +    DialogMathException(int failed_action, int dialog_state, Throwable cause) {
   22.21 +        super(failed_action, dialog_state,
   22.22 +                "\nThis exception originates from the MathEngine.", cause);
   22.23 +    }
   22.24 +}
   22.25 +
    23.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    23.2 +++ b/src/java/isac/wsdialog/DialogNotImplementedException.java	Wed Jun 15 18:31:02 2005 +0200
    23.3 @@ -0,0 +1,20 @@
    23.4 +/*
    23.5 + * Created on Nov 18, 2003
    23.6 + */
    23.7 +
    23.8 +package isac.wsdialog;
    23.9 +
   23.10 +/**
   23.11 + * Exception thrown by the DialogGuide if the action requested by the user is
   23.12 + * known to the DialogGuide but not implemented yet.
   23.13 + * 
   23.14 + * @author Alan Krempler
   23.15 + */
   23.16 +class DialogNotImplementedException extends DialogProtocolException {
   23.17 +    protected int failed_action_;
   23.18 +
   23.19 +    DialogNotImplementedException(int failed_action, int dialog_state) {
   23.20 +        super(failed_action, dialog_state,
   23.21 +                "\nProcessing this request is not implemented yet.", null);
   23.22 +    }
   23.23 +}
   23.24 \ No newline at end of file
    24.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    24.2 +++ b/src/java/isac/wsdialog/DialogProtocolException.java	Wed Jun 15 18:31:02 2005 +0200
    24.3 @@ -0,0 +1,32 @@
    24.4 +/*
    24.5 + * Created on Nov 18, 2003
    24.6 + */
    24.7 +package isac.wsdialog;
    24.8 +
    24.9 +/**
   24.10 + * Exception thrown by the DialogGuide if the action requested by the user does
   24.11 + * not match the state of the DialogGuide, e.g. specifying during the solving
   24.12 + * phase.
   24.13 + * 
   24.14 + * @author Alan Krempler
   24.15 + */
   24.16 +public class DialogProtocolException extends Exception {
   24.17 +
   24.18 +    protected int failed_action_;
   24.19 +
   24.20 +    protected int dialog_state_;
   24.21 +
   24.22 +    DialogProtocolException(int failed_action, int dialog_state, String extra,
   24.23 +            Throwable cause) {
   24.24 +        super("The DialogGuide cannot process a request.\n"
   24.25 +                + "Requested action: " + String.valueOf(failed_action)
   24.26 +                + ", Dialog state:" + String.valueOf(dialog_state) + ", "
   24.27 +                + extra);
   24.28 +        failed_action_ = failed_action;
   24.29 +        dialog_state_ = dialog_state;
   24.30 +    }
   24.31 +
   24.32 +    DialogProtocolException(int failed_action, int dialog_state) {
   24.33 +        this(failed_action, dialog_state, null, null);
   24.34 +    }
   24.35 +}
   24.36 \ No newline at end of file
    25.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    25.2 +++ b/src/java/isac/wsdialog/DialogUnknownActionException.java	Wed Jun 15 18:31:02 2005 +0200
    25.3 @@ -0,0 +1,18 @@
    25.4 +/*
    25.5 + * Created on Nov 18, 2003
    25.6 + */
    25.7 +package isac.wsdialog;
    25.8 +
    25.9 +/**
   25.10 + * Exception thrown by the DialogGuide if the user action indicated is not known
   25.11 + * to the DialogGuide.
   25.12 + * 
   25.13 + * @author Alan Krempler
   25.14 + */
   25.15 +class DialogUnknownActionException extends DialogProtocolException {
   25.16 +
   25.17 +    DialogUnknownActionException(int failed_action, int dialog_state) {
   25.18 +        super(failed_action, dialog_state, "\nThis request is unknown.", null);
   25.19 +    }
   25.20 +
   25.21 +}
   25.22 \ No newline at end of file
    26.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    26.2 +++ b/src/java/isac/wsdialog/IUIElement.java	Wed Jun 15 18:31:02 2005 +0200
    26.3 @@ -0,0 +1,226 @@
    26.4 +/*
    26.5 + * Created on Dec 12, 2003
    26.6 + */
    26.7 +package isac.wsdialog;
    26.8 +
    26.9 +/**
   26.10 + * @author Alan Krempler
   26.11 + * 
   26.12 + * Constants describing interactions or request from the user
   26.13 + */
   26.14 +public interface IUIElement {
   26.15 +
   26.16 +    /** ***************** NOTIFICATIONS: SPECIFYING PHASE ********************** */
   26.17 +
   26.18 +    public static final int UI_DUMMY_FIRST_SPECIFY = 1;
   26.19 +
   26.20 +    /**
   26.21 +     * get descriptions into all items of a model; these give hints for input to
   26.22 +     * the user
   26.23 +     */
   26.24 +    public static final int UI_SPECIFY_GET_DESCRIPTIONS = 2;
   26.25 +
   26.26 +    /**
   26.27 +     * During the specifying phase, try to match a problem type to the data
   26.28 +     * entered so far WN //// ?items of the model entered so far
   26.29 +     */
   26.30 +    public static final int UI_SPECIFY_TRY_MATCH = 2;
   26.31 +
   26.32 +    /**
   26.33 +     * During the specifying phase, try to refine the problem type. WN ////
   26.34 +     */
   26.35 +    public static final int UI_SPECIFY_TRY_REFINE = 3;
   26.36 +
   26.37 +    /**
   26.38 +     * During the specifying phase, change the view on the CalcHead.
   26.39 +     */
   26.40 +    public static final int UI_SPECIFY_CHANGE_VIEW = 4;
   26.41 +
   26.42 +    /**
   26.43 +     * During the specifying phase, have the CalcHead completed by the math
   26.44 +     * engine.
   26.45 +     */
   26.46 +    public static final int UI_SPECIFY_COMPLETE_CALCHEAD = 5;
   26.47 +
   26.48 +    /**
   26.49 +     * During the specifying phase, have the Method field of the CalcHead
   26.50 +     * completed by the math engine.
   26.51 +     */
   26.52 +    public static final int UI_SPECIFY_COMPLETE_METHOD = 6;
   26.53 +
   26.54 +    /**
   26.55 +     * During the specifying phase, have the Theory field of the CalcHead
   26.56 +     * completed by the math engine.
   26.57 +     */
   26.58 +    public static final int UI_SPECIFY_COMPLETE_THEORY = 7;
   26.59 +
   26.60 +    /**
   26.61 +     * During the specifying phase, have the Problem field of the CalcHead
   26.62 +     * completed by the math engine.
   26.63 +     */
   26.64 +    public static final int UI_SPECIFY_COMPLETE_PROBLEM = 8;
   26.65 +
   26.66 +    /**
   26.67 +     * During the specifying phase, have the Given field of the CalcHead
   26.68 +     * completed by the math engine.
   26.69 +     */
   26.70 +    public static final int UI_SPECIFY_COMPLETE_GIVEN = 9;
   26.71 +
   26.72 +    /**
   26.73 +     * During the specifying phase, have the Find field of the CalcHead
   26.74 +     * completed by the math engine.
   26.75 +     */
   26.76 +    public static final int UI_SPECIFY_COMPLETE_FIND = 10;
   26.77 +
   26.78 +    /**
   26.79 +     * During the specifying phase, have the Relate field of the CalcHead
   26.80 +     * completed by the math engine.
   26.81 +     */
   26.82 +    public static final int UI_SPECIFY_COMPLETE_RELATE = 11;
   26.83 +
   26.84 +    /**
   26.85 +     * During the specifying phase, have the CalcHead checked for completeness
   26.86 +     * and consistency.
   26.87 +     */
   26.88 +    public static final int UI_SPECIFY_CHECK_CALCHEAD = 12;
   26.89 +
   26.90 +    /**
   26.91 +     * Leave the specifying phase, enter the solving phase and calculate the
   26.92 +     * first step of the method.
   26.93 +     */
   26.94 +    public static final int UI_SPECIFY_TO_SOLVE = 13;
   26.95 +
   26.96 +    /**
   26.97 +     * Leave the specifying phase, enter the solving phase and calculate until a
   26.98 +     * final result is reached.
   26.99 +     */
  26.100 +    public static final int UI_SPECIFY_CALCULATE_ALL = 14;
  26.101 +
  26.102 +    public static final int UI_DUMMY_LAST_SPECIFY = 14;
  26.103 +
  26.104 +    /** ***************** NOTIFICATIONS: SOLVING PHASE ********************** */
  26.105 +
  26.106 +    public static final int UI_DUMMY_FIRST_SOLVE = 21;
  26.107 +
  26.108 +    /**
  26.109 +     * During the solving phase, calculate one more step.
  26.110 +     */
  26.111 +    public static final int UI_SOLVE_CALCULATE_1 = 21;
  26.112 +
  26.113 +    /**
  26.114 +     * During the solving phase, calculate until a final result is reached.
  26.115 +     */
  26.116 +    public static final int UI_SOLVE_CALCULATE_ALL = 22;
  26.117 +
  26.118 +    /**
  26.119 +     * During the solving phase, calculate until the current subproblem is
  26.120 +     * solved.
  26.121 +     */
  26.122 +    public static final int UI_SOLVE_CALCULATE_SUBPROBLEM = 23;
  26.123 +
  26.124 +    /**
  26.125 +     * During the solving phase, request editing the currently active formula.
  26.126 +     * 
  26.127 +     * WN0412 If request is conceded, do
  26.128 +     * 
  26.129 +     * @see UI_SOLVE_EDIT_ACTIVE_FORMULA_COMPLETE
  26.130 +     */
  26.131 +    public static final int UI_SOLVE_EDIT_ACTIVE_FORMULA = 24;
  26.132 +
  26.133 +    /**
  26.134 +     * During the solving phase, notify that editing the currently active
  26.135 +     * formula is finished. This implies a request for updating the CalcTree.
  26.136 +     */
  26.137 +    public static final int UI_SOLVE_EDIT_ACTIVE_FORMULA_COMPLETE = 25;
  26.138 +
  26.139 +    /**
  26.140 +     * During the solving phase, request inserting a new formula _after_ the
  26.141 +     * currently active formula, making the new formula the currently active
  26.142 +     * formula. At present, this does not imply editing the formula and must be
  26.143 +     * requested in a separate step. WN0412: ...??? is this right interpreted by
  26.144 +     * ... WN0412 If request is conceded, do
  26.145 +     * 
  26.146 +     * @see UI_SOLVE_EDIT_ACTIVE_FORMULA_COMPLETE
  26.147 +     */
  26.148 +    public static final int UI_SOLVE_APPEND_USER_FORMULA = 26;
  26.149 +
  26.150 +    /**
  26.151 +     * During the solving phase, request making the referened formula the
  26.152 +     * currently active formula.
  26.153 +     */
  26.154 +    public static final int UI_SOLVE_MOVE_ACTIVE_FORMULA = 27;
  26.155 +
  26.156 +    /**
  26.157 +     * During the solving phase, ask for the tactic the math engine would apply
  26.158 +     * to the current formula.
  26.159 +     */
  26.160 +    public static final int UI_SOLVE_GET_PROPOSED_TACTIC = 30;
  26.161 +
  26.162 +    /**
  26.163 +     * During the solving phase, ask for a list of tactics to the current
  26.164 +     * formula.
  26.165 +     */
  26.166 +    public static final int UI_SOLVE_GET_APPLICABLE_TACTICS = 31;
  26.167 +
  26.168 +    /**
  26.169 +     * During the solving phase, set the tactic to be applied to the current
  26.170 +     * formula.
  26.171 +     */
  26.172 +    public static final int UI_SOLVE_SET_NEXT_TACTIC = 32;
  26.173 +
  26.174 +    /**
  26.175 +     * When entering a formula during the solving phase, request help on
  26.176 +     * entering the formula.
  26.177 +     */
  26.178 +    public static final int UI_SOLVE_HELP_ENTERING_FORMULA = 33;
  26.179 +
  26.180 +    /**
  26.181 +     * During the solving phase, show which assumptions hold at the current
  26.182 +     * point of calculation.
  26.183 +     */
  26.184 +    public static final int UI_SOLVE_SHOW_ASSUMPTIONS = 40;
  26.185 +
  26.186 +    /**
  26.187 +     * During the solving phase, request more detail about the currently
  26.188 +     * referenced element.
  26.189 +     */
  26.190 +    public static final int UI_SOLVE_SHOW_DETAILS = 41;
  26.191 +
  26.192 +    public static final int UI_DUMMY_LAST_SOLVE = 41;
  26.193 +
  26.194 +    /** ***************** NOTIFICATIONS: unaware of PHASE **************** */
  26.195 +
  26.196 +    public static final int UI_CALCULATE_1 = 101;
  26.197 +
  26.198 +    public static final int UI_CALCULATE_ALL = 102;
  26.199 +
  26.200 +    /** ***************** ACTIVE REQUESTS TO THE UI ********************** */
  26.201 +
  26.202 +    /**
  26.203 +     * Request editing the currently active formula. DG distinguishes between
  26.204 +     * SPECIFY and SOLVE; thus could drop UI_SOLVE_EDIT_ACTIVE_FORMULA : int
  26.205 +     */
  26.206 +    public static final int UI_DO_EDIT_FORMULA = 129;
  26.207 +
  26.208 +    /**
  26.209 +     * Request appending a new, empty formula.
  26.210 +     */
  26.211 +    public static final int UI_DO_APPEND_FORMULA = 130;
  26.212 +
  26.213 +    /**
  26.214 +     * Activate an UI element.
  26.215 +     */
  26.216 +    public static final int UI_DO_ACTIVATE = 131;
  26.217 +
  26.218 +    /**
  26.219 +     * Deactivate an UI element.
  26.220 +     */
  26.221 +    public static final int UI_DO_DEACTIVATE = 132;
  26.222 +
  26.223 +    /**
  26.224 +     * The Dialog Guide has detached the listener and will not send any more
  26.225 +     * control requests. If registered as a Data Change Listener, update
  26.226 +     * notifications will still arrive!
  26.227 +     */
  26.228 +    public static final int UI_DO_DETACH = 133; //WN ??? Design ???
  26.229 +}
  26.230 \ No newline at end of file
    27.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    27.2 +++ b/src/java/isac/wsdialog/IUserAction.java	Wed Jun 15 18:31:02 2005 +0200
    27.3 @@ -0,0 +1,23 @@
    27.4 +/*
    27.5 + * Created on Dec 12, 2003
    27.6 + */
    27.7 +package isac.wsdialog;
    27.8 +
    27.9 +import java.io.Serializable;
   27.10 +
   27.11 +import isac.wsdialog.IUIElement;
   27.12 +
   27.13 +/**
   27.14 + * Interface common to notifications about user interaction
   27.15 + * 
   27.16 + * @author Alan Krempler
   27.17 + */
   27.18 +public interface IUserAction extends IUIElement, Serializable {
   27.19 +
   27.20 +    /**
   27.21 +     * @return An integer value describing the action the user requested on the
   27.22 +     *         GUI
   27.23 +     */
   27.24 +    int getActionID();
   27.25 +
   27.26 +}
   27.27 \ No newline at end of file
    28.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    28.2 +++ b/src/java/isac/wsdialog/UserAction.java	Wed Jun 15 18:31:02 2005 +0200
    28.3 @@ -0,0 +1,31 @@
    28.4 +/*
    28.5 + * Created on Dec 12, 2003
    28.6 + */
    28.7 +package isac.wsdialog;
    28.8 +
    28.9 +/**
   28.10 + * Notification about the user clicking a GUI element.
   28.11 + * 
   28.12 + * @author Alan Krempler
   28.13 + */
   28.14 +public class UserAction implements IUserAction {
   28.15 +
   28.16 +    private int id_;
   28.17 +
   28.18 +    /**
   28.19 +     * TODO: move class subtree (including IUserAction) to package
   28.20 +     * isac.gui.worksheet? This way, the constructors could be package-private
   28.21 +     * to the objects which construct them.
   28.22 +     * 
   28.23 +     * @param id
   28.24 +     *            An integer value describing the action the user requested on
   28.25 +     *            the GUI
   28.26 +     */
   28.27 +    public UserAction(int id) {
   28.28 +        id_ = id;
   28.29 +    }
   28.30 +
   28.31 +    public int getActionID() {
   28.32 +        return id_;
   28.33 +    }
   28.34 +}
   28.35 \ No newline at end of file
    29.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    29.2 +++ b/src/java/isac/wsdialog/UserActionOnCalcElement.java	Wed Jun 15 18:31:02 2005 +0200
    29.3 @@ -0,0 +1,28 @@
    29.4 +/*
    29.5 + * Created on Feb 6, 2004
    29.6 + */
    29.7 +package isac.wsdialog;
    29.8 +
    29.9 +import isac.util.interfaces.ICalcElement;
   29.10 +
   29.11 +/**
   29.12 + * Describes a user action which has to pass a CalcElement, e.g a newly entered
   29.13 + * formula or tactic which is not yet part of the calculation tree.
   29.14 + * 
   29.15 + * @see isac.wsdialog.UserActionOnIterator
   29.16 + * @see isac.wsdialog.UserActionOnCalcHeadCompoundID
   29.17 + * @author Alan Krempler
   29.18 + */
   29.19 +public class UserActionOnCalcElement extends UserAction {
   29.20 +    private ICalcElement calc_element_;
   29.21 +
   29.22 +    public UserActionOnCalcElement(int id, ICalcElement calc_element) {
   29.23 +        super(id);
   29.24 +        calc_element_ = calc_element;
   29.25 +    }
   29.26 +
   29.27 +    public ICalcElement getCalcElement() {
   29.28 +        return calc_element_;
   29.29 +    }
   29.30 +
   29.31 +}
   29.32 \ No newline at end of file
    30.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    30.2 +++ b/src/java/isac/wsdialog/UserActionOnCalcHeadCompoundID.java	Wed Jun 15 18:31:02 2005 +0200
    30.3 @@ -0,0 +1,27 @@
    30.4 +/*
    30.5 + * Created on Dec 12, 2003
    30.6 + */
    30.7 +package isac.wsdialog;
    30.8 +
    30.9 +import isac.util.formulae.CalcHeadCompoundID;
   30.10 +
   30.11 +/**
   30.12 + * Describes an user action on part of a CalcHead.
   30.13 + * 
   30.14 + * @see isac.wsdialog.UserActionOnIterator
   30.15 + * @see isac.wsdialog.UserActionOnCalcHeadCompoundID
   30.16 + * @author Alan Krempler
   30.17 + */
   30.18 +public class UserActionOnCalcHeadCompoundID extends UserAction {
   30.19 +    private CalcHeadCompoundID chc_id_;
   30.20 +
   30.21 +    public UserActionOnCalcHeadCompoundID(int id, CalcHeadCompoundID chc_id) {
   30.22 +        super(id);
   30.23 +        chc_id_ = chc_id;
   30.24 +    }
   30.25 +
   30.26 +    public CalcHeadCompoundID getObjectID() {
   30.27 +        return chc_id_;
   30.28 +    }
   30.29 +
   30.30 +}
   30.31 \ No newline at end of file
    31.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    31.2 +++ b/src/java/isac/wsdialog/UserActionOnInt.java	Wed Jun 15 18:31:02 2005 +0200
    31.3 @@ -0,0 +1,35 @@
    31.4 +/*
    31.5 + * Created on Dec 12, 2003
    31.6 + */
    31.7 +package isac.wsdialog;
    31.8 +
    31.9 +/**
   31.10 + * Describes an user action passing an integer value.
   31.11 + * 
   31.12 + * @see isac.wsdialog.UserActionOnIterator
   31.13 + * @see isac.wsdialog.UserActionOnCalcHeadCompoundID
   31.14 + * @author Alan Krempler
   31.15 + */
   31.16 +public class UserActionOnInt extends UserAction {
   31.17 +    private int i_;
   31.18 +
   31.19 +    /**
   31.20 +     * @param id
   31.21 +     * @param i
   31.22 +     *            The integer value holding additional information to the
   31.23 +     *            UserAction
   31.24 +     */
   31.25 +    public UserActionOnInt(int id, int i) {
   31.26 +        super(id);
   31.27 +        i_ = i;
   31.28 +    }
   31.29 +
   31.30 +    /**
   31.31 +     * @return The integer value holding additional information to the
   31.32 +     *         UserAction
   31.33 +     */
   31.34 +    public int getInt() {
   31.35 +        return i_;
   31.36 +    }
   31.37 +
   31.38 +}
   31.39 \ No newline at end of file
    32.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    32.2 +++ b/src/java/isac/wsdialog/UserActionOnIterator.java	Wed Jun 15 18:31:02 2005 +0200
    32.3 @@ -0,0 +1,28 @@
    32.4 +/*
    32.5 + * Created on Dec 12, 2003
    32.6 + */
    32.7 +package isac.wsdialog;
    32.8 +
    32.9 +import isac.util.interfaces.ICalcIterator;
   32.10 +
   32.11 +/**
   32.12 + * Describes an user action which relates to a CalcElement which is part of the
   32.13 + * current calculation.
   32.14 + * 
   32.15 + * @see isac.wsdialog.UserActionOnCalcElement
   32.16 + * @see isac.wsdialog.UserActionOnCalcHeadCompoundID
   32.17 + * @author Alan Krempler
   32.18 + */
   32.19 +public class UserActionOnIterator extends UserAction {
   32.20 +    private ICalcIterator iterator_;
   32.21 +
   32.22 +    public UserActionOnIterator(int id, ICalcIterator iterator) {
   32.23 +        super(id);
   32.24 +        iterator_ = iterator;
   32.25 +    }
   32.26 +
   32.27 +    public ICalcIterator getPosition() {
   32.28 +        return iterator_;
   32.29 +    }
   32.30 +
   32.31 +}
   32.32 \ No newline at end of file