# HG changeset patch # User wneuper # Date 1118853062 -7200 # Node ID fcd5648113caf7cd54f1799c32e8063047a2d0e7 # Parent b4896ce4d1b046d998f8d4cd029584ca54e59f52 java: isac.util.tactics .. end renamed, formatted, inst_var_, import cleaned diff -r b4896ce4d1b0 -r fcd5648113ca src/java/isac/util/tactics/Rewrite.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/java/isac/util/tactics/Rewrite.java Wed Jun 15 18:31:02 2005 +0200 @@ -0,0 +1,37 @@ +/* + * Created on Jun 25, 2004 + */ +package isac.util.tactics; + +/** + * @author richard + */ +public class Rewrite extends Tactic { + + Theorem theorem_; + + public Rewrite() { + } + + public String toSMLString() { + return name_ + theorem_.toSMLString(); + } + + /** + * @return + */ + public Theorem getTheorem() { + return theorem_; + } + + /** + * for use in + * + * @see isac.util.parser.XMLParserDigest.java + * @param theorem + */ + public void setTheorem(Theorem theorem) { + this.theorem_ = theorem; + } + +} \ No newline at end of file diff -r b4896ce4d1b0 -r fcd5648113ca src/java/isac/util/tactics/RewriteInst.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/java/isac/util/tactics/RewriteInst.java Wed Jun 15 18:31:02 2005 +0200 @@ -0,0 +1,64 @@ +/* + * Created on Jun 25, 2004 + */ +package isac.util.tactics; + +/** + * @author richard + */ +public class RewriteInst extends Tactic { + String variable_, value_; + + Theorem theorem_; + + public RewriteInst() { + } + + public String toSMLString() { + return name_ + " ([\"(" + variable_ + "," + value_ + ")\"]," + + theorem_.toSMLString() + ")"; + } + + /** + * @return + */ + public String getValue() { + return value_; + } + + /** + * @return + */ + public String getVariable() { + return variable_; + } + + /** + * @param string + */ + public void setValue(String string) { + value_ = string; + } + + /** + * @param string + */ + public void setVariable(String string) { + variable_ = string; + } + + /** + * @return + */ + public Theorem getTheorem() { + return theorem_; + } + + /** + * @param theorem + */ + public void setTheorem(Theorem theorem) { + this.theorem_ = theorem; + } + +} \ No newline at end of file diff -r b4896ce4d1b0 -r fcd5648113ca src/java/isac/util/tactics/RewriteSet.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/java/isac/util/tactics/RewriteSet.java Wed Jun 15 18:31:02 2005 +0200 @@ -0,0 +1,45 @@ +/* + * Created on Oct 14, 2003 + * + * To change the template for this generated file go to + * Window>Preferences>Java>Code Generation>Code and Comments + */ +package isac.util.tactics; + +/** + * @author rgradisc + * + * To change the template for this generated type comment go to + * Window>Preferences>Java>Code Generation>Code and Comments + */ +public class RewriteSet extends Tactic { + private String rule_set_; + + public RewriteSet() { + } + + public RewriteSet(String name) { + this.name_ = name; + } + + public RewriteSet(String name, String ruleSet) { + this.name_ = name; + this.rule_set_ = ruleSet; + } + + public String getName() { + return name_; + } + + public void setRuleSet(String ruleSet) { + this.rule_set_ = ruleSet; + } + + public String getRuleSet() { + return this.rule_set_; + } + + public String toSMLString() { + return name_ + " \"" + rule_set_ + "\""; + } +} \ No newline at end of file diff -r b4896ce4d1b0 -r fcd5648113ca src/java/isac/util/tactics/RewriteSetInst.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/java/isac/util/tactics/RewriteSetInst.java Wed Jun 15 18:31:02 2005 +0200 @@ -0,0 +1,77 @@ +/* + * Created on Oct 10, 2003 + * + * To change the template for this generated file go to + * Window>Preferences>Java>Code Generation>Code and Comments + */ +package isac.util.tactics; + +/** + * @author rgradisc + * + * To change the template for this generated type comment go to + * Window>Preferences>Java>Code Generation>Code and Comments + */ +public class RewriteSetInst extends Tactic { + + String rule_set_, variable_, value_; + + public RewriteSetInst() { + } + + public RewriteSetInst(String name) { + this.name_ = name; + } + + public String getName() { + return name_; + } + + public String toSMLString() { + return name_ + " ([\"(" + variable_ + "," + value_ + ")\"], \"" + + rule_set_ + "\")"; + } + + /** + * @return + */ + public String getRuleSet() { + return rule_set_; + } + + /** + * @return + */ + public String getValue() { + return value_; + } + + /** + * @return + */ + public String getVariable() { + return variable_; + } + + /** + * @param string + */ + public void setRuleSet(String string) { + rule_set_ = string; + } + + /** + * @param string + */ + public void setValue(String string) { + value_ = string; + } + + /** + * @param string + */ + public void setVariable(String string) { + variable_ = string; + } + +} \ No newline at end of file diff -r b4896ce4d1b0 -r fcd5648113ca src/java/isac/util/tactics/SimpleTactic.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/java/isac/util/tactics/SimpleTactic.java Wed Jun 15 18:31:02 2005 +0200 @@ -0,0 +1,42 @@ +/* + * Created on Oct 9, 2003 + * + * To change the template for this generated file go to + * Window>Preferences>Java>Code Generation>Code and Comments + */ +package isac.util.tactics; + +/** + * @author rgradisc + * + * To change the template for this generated type comment go to + * Window>Preferences>Java>Code Generation>Code and Comments + */ +public class SimpleTactic extends Tactic { + + private String argument_; // placeholder for MATH-ML + + public SimpleTactic() { + } + + public SimpleTactic(String name) { + this.name_ = name; + } + + public SimpleTactic(String name, String argument) { + this.name_ = name; + this.argument_ = argument; + } + + public void setArgument(String argument) { + this.argument_ = argument; + } + + public String getArgument() { + return ""; + } + + public String toSMLString() { + return name_ + " \"" + argument_ + "\""; + } +} \ No newline at end of file diff -r b4896ce4d1b0 -r fcd5648113ca src/java/isac/util/tactics/StringListTactic.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/java/isac/util/tactics/StringListTactic.java Wed Jun 15 18:31:02 2005 +0200 @@ -0,0 +1,53 @@ +/* + * Created on Oct 9, 2003 + * + * To change the template for this generated file go to + * Window>Preferences>Java>Code Generation>Code and Comments + */ +package isac.util.tactics; + +import java.util.Iterator; +import java.util.Vector; + +/** + * @author rgradisc + * + * To change the template for this generated type comment go to + * Window>Preferences>Java>Code Generation>Code and Comments + */ +public class StringListTactic extends Tactic { + + private Vector string_list_ = new Vector(); + + public StringListTactic() { + } + + public StringListTactic(String name) { + this.name_ = name; + } + + public StringListTactic(String name, Vector keyList) { + this.name_ = name; + this.string_list_ = keyList; + } + + public void addKey(String key) { + this.string_list_.add(key); + } + + public String toSMLString() { + StringBuffer sb = new StringBuffer(); + sb.append(name_); + if (string_list_.size() > 0) { + sb.append(" ["); + Iterator it = string_list_.iterator(); + while (it.hasNext()) { + sb.append("\"" + it.next() + "\","); + } + sb.deleteCharAt(sb.length() - 1); // remove last "," + sb.append("]"); + } + return sb.toString(); + } + +} \ No newline at end of file diff -r b4896ce4d1b0 -r fcd5648113ca src/java/isac/util/tactics/SubProblemTactic.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/java/isac/util/tactics/SubProblemTactic.java Wed Jun 15 18:31:02 2005 +0200 @@ -0,0 +1,52 @@ +/* + * Created on Nov 13, 2003 + */ +package isac.util.tactics; + +import java.util.Iterator; +import java.util.Vector; + +/** + * @author rgradisc + */ +public class SubProblemTactic extends Tactic { + + private String theory_ID_; + + private Vector problem_ID_ = new Vector(); + + public SubProblemTactic() { + } + + public void addProblemString(String string) { + this.problem_ID_.add(string); + } + + public String toSMLString() { + StringBuffer sb = new StringBuffer(); + sb.append(name_ + " (\"" + theory_ID_ + "\", ["); + Iterator it = problem_ID_.iterator(); + while (it.hasNext()) { + sb.append("\"" + it.next() + "\","); + } + sb.deleteCharAt(sb.length() - 1); // remove last "," + sb.append("])"); + return sb.toString(); + } + + public Vector getProblemID() { + return problem_ID_; + } + + public String getTheoryID() { + return theory_ID_; + } + + public void setProblemID(Vector vector) { + problem_ID_ = vector; + } + + public void setTheoryID(String string) { + theory_ID_ = string; + } +} \ No newline at end of file diff -r b4896ce4d1b0 -r fcd5648113ca src/java/isac/util/tactics/Tactic.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/java/isac/util/tactics/Tactic.java Wed Jun 15 18:31:02 2005 +0200 @@ -0,0 +1,93 @@ +/* + * Created on Sep 11, 2003 + * + * To change the template for this generated file go to + * Window>Preferences>Java>Code Generation>Code and Comments + */ +package isac.util.tactics; + +import isac.util.formulae.CalcElement; +import isac.util.formulae.CalcFormula; + +/** + * @author Alan Krempler (method stubs) + * + */ +public class Tactic extends CalcElement { + + protected String name_; + + public String getName() { + return name_; + } + + public void setName(String name) { + this.name_ = name; + } + + public String getDescription() { + return ""; + } + + //FIXME.WN0504 put down in inheritance (valid only for some tacs) + public String getTheoremName() { + return ""; + } + + //FIXME.WN0504 put down in inheritance (valid only for some tacs) + public String getTheoremDescription() { + return ""; + } + + //FIXME.WN0504 put down in inheritance (valid only for some tacs) + public CalcFormula getTheoremSymbolic() { + CalcFormula dummy; + dummy = new CalcFormula(); + return dummy; + } + + //FIXME.WN0504 put down in inheritance (valid only for some tacs) + public CalcFormula getTheoremInstantiated(CalcFormula formula) { + CalcFormula dummy; + dummy = new CalcFormula(); + return dummy; + } + + //FIXME.WN0504 put down in inheritance (valid only for some tacs) + // itself and selected by passing an integer + public CalcFormula makeFillFormula(CalcFormula formula, String pattern) { + CalcFormula dummy; + dummy = new CalcFormula(); + return dummy; + } + + /* + * (non-Javadoc) + * + * @see isac.util.CalcElement#getText() + */ + public String toSMLString() { + // TODO Auto-generated method stub + return null; + } + + /* + * (non-Javadoc) + * + * @see isac.util.CalcElement#getMathML() + */ + public String getMathML() { + // TODO Auto-generated method stub + return null; + } + + /* + * (non-Javadoc) + * + * @see isac.util.CalcElement#getType() + */ + public int getType() { + return CALCEL_TACTIC; + } + +} \ No newline at end of file diff -r b4896ce4d1b0 -r fcd5648113ca src/java/isac/util/tactics/TacticsContainer.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/java/isac/util/tactics/TacticsContainer.java Wed Jun 15 18:31:02 2005 +0200 @@ -0,0 +1,27 @@ +/* + * Created on Mar 23, 2004 + */ +package isac.util.tactics; + +import java.util.Vector; + +/** + * @author richard gradischnegg renames Vector#add to + * TacticsContainer#setResponse as required by + * @see isac.util.parser.XMLParserDigest + */ +public class TacticsContainer { + Vector tactics_; + + public TacticsContainer() { + tactics_ = new Vector(); + } + + public void setResponse(Tactic tactic) { + tactics_.add(tactic); + } + + public Vector getTactics() { + return tactics_; + } +} \ No newline at end of file diff -r b4896ce4d1b0 -r fcd5648113ca src/java/isac/util/tactics/Theorem.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/java/isac/util/tactics/Theorem.java Wed Jun 15 18:31:02 2005 +0200 @@ -0,0 +1,45 @@ +/* + * Created on Jun 25, 2004 + */ +package isac.util.tactics; + +import java.io.Serializable; + +/** + * This is a helper class used by Rewrite Tactic and RewriteInst Tactic + * + * @author richard + */ + +public class Theorem implements Serializable { + String id_, formula_; + + //Theorem consist of the ID, and + //the formula (still as a string -- waiting for MathML) + + /** + * Format the class to a string which can be used as SML-Input + * + * @return + */ + public String toSMLString() { + return "(\"" + id_ + "\",\"\")"; //formula may be empty at input + } + + public String getFormula() { + return formula_; + } + + public String getId() { + return id_; + } + + public void setFormula(String string) { + formula_ = string; + } + + public void setId(String string) { + id_ = string; + } + +} \ No newline at end of file diff -r b4896ce4d1b0 -r fcd5648113ca src/java/isac/util/users/Accounts.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/java/isac/util/users/Accounts.java Wed Jun 15 18:31:02 2005 +0200 @@ -0,0 +1,68 @@ +/* + * @author Walther Neuper, member of the ISAC-team, + * Copyright (c) 2005 by Walther Neuper + * created Mar 12, 2005 8:09:42 AM + * Institute for Softwaretechnology, Graz University of Technology, Austria. + * + * Use is subject to PGPL license terms. + */ +package isac.util.users; + +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.util.Enumeration; +import java.util.Properties; + +/** + * @author Walther Neuper + * + * contains passwords looking forward to handle security issues elsewhere + * (outside isac) + */ +public class Accounts extends Properties { + + public Accounts(String userpath) { + String filename = userpath + "accounts.txt"; + try { + FileInputStream propInFile = new FileInputStream(filename); + this.load(propInFile); + this.list(System.out); + } catch (FileNotFoundException e) { + System.err.println("Can?t find " + filename); + } catch (IOException e) { + System.err.println("I/O failed."); + } + } + + public boolean exists(String username) { + Enumeration keys = this.propertyNames();//WN050311 how better ? + String key = null; + while (keys.hasMoreElements()) { + key = (String) keys.nextElement(); + if (key.compareTo(username) == 0) + return true; + } + return false; + } + + //WN050311 just for creation of the first file + //beware of the fix path ! + public static void main(String[] args) { + Accounts acs = new Accounts("isac/xmldata/users"); + acs.setProperty("x", "x"); + acs.setProperty("y", "y"); + acs.setProperty("anonymous", "anonymous"); + + String filename = "isac/xmldata/users/accounts.txt"; + try { + FileOutputStream propOutFile = new FileOutputStream(filename); + acs.store(propOutFile, "the list of isac users"); + + } catch (IOException e) { + System.err.println("I/O failed."); + } + } + +} \ No newline at end of file diff -r b4896ce4d1b0 -r fcd5648113ca src/java/isac/util/users/IUserSettings.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/java/isac/util/users/IUserSettings.java Wed Jun 15 18:31:02 2005 +0200 @@ -0,0 +1,51 @@ +/* + * @author Walther Neuper, member of the ISAC-team, + * Copyright (c) 2005 by Walther Neuper + * created Mar 12, 2005 3:09:15 PM + * Institute for Softwaretechnology, Graz University of Technology, Austria. + * + * Use is subject to PGPL license terms. + */ +package isac.util.users; + +/** + * @author Walther Neuper + * + * semantics for review by AK + */ +public interface IUserSettings { + + //TODO comments with AK ? + //TODO change type String to the one suggested by AK + //public static final String start_worksheet = "start_worksheet"; + + //the following are situations implemented as keys for UserSettings + //the identifiers must start with "KEYn_*" where n reappears in the + // identifiers of the related values "VALn_*" --------------------- + public static final String KEY1_START_SPECIFY = "KEY1_START_SPECIFY"; + + /** + * _ALL_ the values of UserSettings _MUST_ be connect their + * Integer-representation with the String-representation in + * + * @see isac.util.users.UserSettings#createValstrValint + */ + public static final int VAL1_SKIP_SPECIFY_TO_START_SOLVE = 23; + + public static final int VAL1_POP_CALCHEAD_WITH_DESCRIPTIONS = 26; + + //----------------------------------------------------------------- + public static final String KEY2_NEXT_BUTTON = "KEY2_NEXT_BUTTON"; + + public static final int VAL2_FORMULAE_ONLY = 43; + + public static final int VAL2_FORMULA_TACTIC_FORMULA_ = 46; + + public static final int DUMMY = 0; + + //----------------------------------------------------------------- + public int getValue(String key); + + public boolean setValue(String key, int value); + +} \ No newline at end of file diff -r b4896ce4d1b0 -r fcd5648113ca src/java/isac/util/users/User.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/java/isac/util/users/User.java Wed Jun 15 18:31:02 2005 +0200 @@ -0,0 +1,46 @@ +/****************************************************************** + * @author Alois Kirchsteiger member of the isac team + * Copyright (c) 2004 by Alois Kirchsteiger + * create 02.09.2004, 09:22:43 + * Insitute for Softwaretechnology, Graz University of Technology, Austria. + * + * Use is subject to license terms. + ******************************************************************/ + +//TODO: implement!!! +package isac.util.users; + +import java.io.Serializable; + +/** + * @author Alois Kirchsteiger 02.09.2004 09:22:43 + */ +public class User implements Serializable { + private String username_; + + private String userpath_; + + public User(String username, String userpath) { + username_ = username; + userpath_ = userpath; + } + + public UserAdmin getUserAdmin() { + return new UserAdmin(userpath_, username_); + + } + + public UserModel getUserModel() { + return new UserModel(userpath_, username_); + } + + public UserSettings getUserSettings() { + return new UserSettings(userpath_, username_); + + } + + public String getUsername() { + return username_; + } + +} \ No newline at end of file diff -r b4896ce4d1b0 -r fcd5648113ca src/java/isac/util/users/UserAdmin.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/java/isac/util/users/UserAdmin.java Wed Jun 15 18:31:02 2005 +0200 @@ -0,0 +1,51 @@ +/* + * @author Walther Neuper, member of the ISAC-team, + * Copyright (c) 2005 by Walther Neuper + * created Mar 12, 2005 8:55:37 AM + * Institute for Softwaretechnology, Graz University of Technology, Austria. + * + * Use is subject to PGPL license terms. + */ +package isac.util.users; + +import java.io.FileOutputStream; +import java.io.IOException; +import java.util.Properties; + +/** + * @author Walther Neuper + * + * contains administrative data (and nothing about the dialog !!!) looking + * forward to be handled elsewhere outside isac + */ +public class UserAdmin extends Properties { + + private String userpath_; + + private String username_; + + public UserAdmin(String userpath, String username) { + userpath_ = userpath; + username_ = username; + //TODO.WN050311 + } + + //WN050311 just for creation of the first file + //beware of the fix path ! + public static void main(String[] args) { + UserAdmin a = new UserAdmin("isac/xmldata/users", "x"); + a.setProperty("firstName", "x-firstName"); + a.setProperty("lastName", "x-lastName"); + + String filename = "isac/xmldata/users/x_admin.txt"; + try { + FileOutputStream propOutFile = new FileOutputStream(filename); + a.store(propOutFile, "administrative data of user 'x'"); + + } catch (IOException e) { + System.err.println("I/O failed."); + } + + } + +} \ No newline at end of file diff -r b4896ce4d1b0 -r fcd5648113ca src/java/isac/util/users/UserModel.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/java/isac/util/users/UserModel.java Wed Jun 15 18:31:02 2005 +0200 @@ -0,0 +1,193 @@ +/* + * Created on Feb 22, 2005 + * + * To change the template for this generated file go to + * Window>Preferences>Java>Code Generation>Code and Comments + */ +package isac.util.users; + +import java.io.FileOutputStream; +import java.io.IOException; +import java.util.Properties; + +/** + * @author Alan Krempler + * + * The UserModel is a class to gather statistics about one user's interaction + * with the system. Statistis are gathered per user and per interactional + * context. + */ +public class UserModel extends Properties { + + // special value for retrieving the statistics regardless of the dialog atom + // used in the interaction + public static final int DIALOG_ATOM_ANY = 0; + + // counter for identifying pending interactions + private static int interaction_nr_ = 1; + + private String userpath_; + + private String username_; + + public UserModel(String userpath, String username) { + userpath_ = userpath; + username_ = username; + //TODO.WN050311 + } + + /** + * @param item_id + * ID of the item being queried, a tactic for example + * @param dialog_atom + * ID of the interactional context use DIALOG_ATOM_ANY if asking + * for statistics for all dialog atoms + * @return count of previously recorded interactions with this item + */ + public int getTouchedCount(int item_id, int dialog_atom) { + // FIXME: returning dummy value in absence of valid statistics + return 0; + } + + /** + * @param item_id + * ID of the item being queried, a tactic for example + * @param dialog_atom + * ID of the interactional context use DIALOG_ATOM_ANY if asking + * for statistics for all dialog atoms + * @return count of previously recorded successful interactions with this + * item + */ + public int getSuccessCount(int item_id, int dialog_atom) { + // FIXME: returning dummy value in absence of valid statistics + return 0; + } + + /** + * @param item_id + * ID of the item being queried, a tactic for example + * @param dialog_atom + * ID of the interactional context use DIALOG_ATOM_ANY if asking + * for statistics for all dialog atoms + * @return time of last recorded interaction with this item + */ + public java.util.Date getTouchedLast(int item_id, int dialog_atom) { + // FIXME: returning dummy value in absence of valid statistics + return new java.util.Date(); + } + + /** + * @param item_id + * ID of the item being queried, a tactic for example + * @param dialog_atom + * ID of the interactional context use DIALOG_ATOM_ANY if asking + * for statistics for all dialog atoms + * @return time of last recorded successful interaction with this item + */ + public java.util.Date getSuccessLast(int item_id, int dialog_atom) { + // FIXME: returning dummy value in absence of valid statistics + return new java.util.Date(); + } + + /** + * @param item_id + * ID of the item being queried, a tactic for example + * @param dialog_atom + * ID of the interactional context use DIALOG_ATOM_ANY if asking + * for statistics for all dialog atoms + * @return average time (seconds) spent in interactions with this item + */ + public int getTimeSpentAvg(int item_id, int dialog_atom) { + // FIXME: returning dummy value in absence of valid statistics + return 0; + } + + /** + * @param item_id + * ID of the item being queried, a tactic for example + * @param dialog_atom + * ID of the interactional context use DIALOG_ATOM_ANY if asking + * for statistics for all dialog atoms + * @return maximum time (seconds) spent in interactions with this item + */ + public int getTimeSpentMax(int item_id, int dialog_atom) { + // FIXME: returning dummy value in absence of valid statistics + return 0; + } + + /** + * @param item_id + * ID of the item being queried, a tactic for example + * @param dialog_atom + * ID of the interactional context use DIALOG_ATOM_ANY if asking + * for statistics for all dialog atoms + * @return standard deviation of time spent in interactions with this item + */ + public float getTimeSpentStddev(int item_id, int dialog_atom) { + // FIXME: returning dummy value in absence of valid statistics + return 0; + } + + /** + * Mark the beginning of an interaction with an item. + * + * @param item_id + * ID of the item being acted upon, a tactic for example + * @param dialog_atom + * ID of the interactional context + * @return unique number to indentify the end of the transaction + */ + public int startInteraction(int item_id, int dialog_atom) { + // FIXME: insert code to record statistics + + // record timestamp + // new java.util.Date(); ... + + // save in static vector of currently open interactions + // ... + + return interaction_nr_++; + } + + /** + * Mark the end of an interaction with an item. + * + * @param interaction_id + * ID of the interaction returned from the call to + * {@link # startInteraction() } + * @param success + * information about the success of the interaction + * @return false in case of failure - no matching start could be found, true + * in case of success + */ + public boolean endInteraction(int interaction_id, int success) { + // FIXME: insert code to record statistics + + // record end timestamp + // new java.util.Date(); ... + + // add to statistics + + // delete from static vector of currently open interactions + // ... + + return true; + } + + //WN050311 just for creation of the first file + //beware of the fix path ! + public static void main(String[] args) { + UserModel a = new UserModel("isac/xmldata/users", "x"); + a.setProperty("TODO-key", "TODO-value"); + + String filename = "isac/xmldata/users/x_model.txt"; + try { + FileOutputStream propOutFile = new FileOutputStream(filename); + a.store(propOutFile, "dynamic dialog data of user 'x'"); + + } catch (IOException e) { + System.err.println("I/O failed."); + } + + } +} \ No newline at end of file diff -r b4896ce4d1b0 -r fcd5648113ca src/java/isac/util/users/UserModel_AK.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/java/isac/util/users/UserModel_AK.java Wed Jun 15 18:31:02 2005 +0200 @@ -0,0 +1,105 @@ +/****************************************************************** + * @author Alois Kirchsteiger member of the isac team + * Copyright (c) 2004 by Alois Kirchsteiger + * create 02.09.2004, 09:25:44 + * Insitute for Softwaretechnology, Graz University of Technology, Austria. + * + * Use is subject to license terms. + ******************************************************************/ + +//TODO: implement!!! +package isac.util.users; + +import isac.session.SuccessInfo; +import isac.util.formulae.CalcElement; + +import java.io.Serializable; +import java.util.Iterator; +import java.util.Map; +import java.util.Set; +import java.util.TreeMap; +import java.util.Vector; + +/** + * @author Alois Kirchsteiger 02.09.2004 09:25:44 + */ +public class UserModel_AK implements Serializable { + + /** + * successInfos stores the successInfos for CalcElements. that means the key + * for this TreeMap is a calcElement, the value is the relating SuccessInfo + */ + private TreeMap success_infos_; + + public UserModel_AK() { + } + + /** + * gets the info for each CalcElement of the parameter calcElements + * + * @param calcElements + * this Vector must not contain anything else than CalcElements + * @return a TreeMap with the SuccessInfo for each CalcElement in the + * calcElements Vector. Those CalcElements are the index in the + * HashMap, the relating SuccessInfos are the values + */ + public Map getSuccessInfoFor(Vector calcElements) { + TreeMap result = new TreeMap(); + Iterator iterator = calcElements.iterator(); + while (iterator.hasNext()) { + CalcElement calcElement = (CalcElement) iterator.next(); + if (success_infos_.containsKey(calcElement)) { + result.put(calcElement, success_infos_.get(calcElement)); + } else { + // no successInfo available + result.put(calcElement, null); + } + } + //TODO + return result; + } + + /** + * @param calcElement + * @return SuccessInfo or null if no SuccessInfo available + */ + public SuccessInfo getSuccessInfoFor(CalcElement calcElement) { + return (SuccessInfo) success_infos_.get(calcElement); + } + + /** + * @param calcElementsSuccesses, + * a TreeMap with a CalcElement as key and the relating success + * (Float between 0 and 1) as value + */ + public void addSuccessInfoFor(Map calcElementsSuccesses) + throws ClassCastException { + Set set = calcElementsSuccesses.keySet(); + Iterator iterator = set.iterator(); + while (iterator.hasNext()) { + try { + CalcElement calcElement = (CalcElement) iterator.next(); + Float success = (Float) calcElementsSuccesses.get(calcElement); + addSuccessInfoFor(calcElement, success.floatValue()); + } catch (ClassCastException e) { + throw new ClassCastException( + "the parameter for the method " + + "void addSuccessInfoFor(TreeMap calcElementsSuccesses) " + + "must have CalcElements as keys and Floats as value!!"); + } + } + } + + public void addSuccessInfoFor(CalcElement calcElement, float success) { + SuccessInfo successInfo; + if (success_infos_.containsKey(calcElement)) { + successInfo = (SuccessInfo) success_infos_.get(calcElement); + successInfo.addSuccess(success); + success_infos_.put(calcElement, successInfo); + } else { + successInfo = new SuccessInfo(success); + success_infos_.put(calcElement, successInfo); + } + } + +} \ No newline at end of file diff -r b4896ce4d1b0 -r fcd5648113ca src/java/isac/util/users/UserSettings.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/java/isac/util/users/UserSettings.java Wed Jun 15 18:31:02 2005 +0200 @@ -0,0 +1,140 @@ +/* + * Created on Feb 22, 2005 + * + * @author Alan Krempler + */ + +package isac.util.users; + +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.util.Enumeration; +import java.util.HashMap; +import java.util.Map; +import java.util.Properties; + +/** + * Class for storing/retrieving user settings, i.e. settings which can be set + * manually by the user as opposed to the + * {@link isac.util.usersettings.UserModel#}, which is an abstraction of the + * system's expeience with a user and canot be altered manually. As there is no + * fixed set of user settings, you can regard this class as a simple storage + * backend for key/value pairs. + * + * @author Alan Krempler + * + */ +public class UserSettings extends Properties implements IUserSettings { + + private HashMap storage_; + + String userpath_; + + String username_; + + public static Map valstr_valint_; + + /** + * connect the String-representation of a UserSettings-value with the + * respective Integer-representation + * + * @see isac.uti.users.IUserSettings + */ + private HashMap createValstrValint() { + HashMap m = new HashMap(); + m.put("DUMMY", new Integer(IUserSettings.DUMMY)); + m.put("VAL1_SKIP_SPECIFY_TO_START_SOLVE", new Integer( + IUserSettings.VAL1_SKIP_SPECIFY_TO_START_SOLVE)); + m.put("VAL1_POP_CALCHEAD_WITH_DESCRIPTIONS", new Integer( + IUserSettings.VAL1_POP_CALCHEAD_WITH_DESCRIPTIONS)); + m.put("VAL2_FORMULAE_ONLY", new Integer( + IUserSettings.VAL2_FORMULAE_ONLY)); + m.put("VAL2_FORMULA_TACTIC_FORMULA_", new Integer( + IUserSettings.VAL2_FORMULA_TACTIC_FORMULA_)); + //m.put("", + // new Integer(IUserSettings.)); + return m; + } + + public UserSettings(String userpath, String username) { + userpath_ = userpath; + username_ = username; + + //load Properties (keystr, valstr) temporarily + Properties keystr_valstr = new Properties(); + String filename = userpath_ + username + "_settings.txt"; + try { + FileInputStream propInFile = new FileInputStream(filename); + keystr_valstr.load(propInFile); + keystr_valstr.list(System.out); + } catch (FileNotFoundException e) { + System.err.println("Can?t find " + filename); + } catch (IOException e) { + System.err.println("I/O failed."); + } + + //create HashMap (valstr, valint) temporarily + HashMap valstr_valint = new HashMap(); + valstr_valint = this.createValstrValint(); + + //create HashMap (keystr, \\valstr\\ valint) and store it + storage_ = new HashMap(); + Enumeration keystrs = keystr_valstr.propertyNames();//WN050311 how + // better ? + String keystr = null; + String valstr = null; + Object valint = null; + while (keystrs.hasMoreElements()) { + keystr = (String) keystrs.nextElement(); + valstr = keystr_valstr.getProperty(keystr); + valint = valstr_valint.get(valstr); + storage_.put(keystr, valint); + } + } + + /** + * @param key + * A string key + * @return The string value associated with the key parameter; null, if + * nothing is stored under this key + */ + public int getValue(String key) { + return ((Integer) storage_.get(key)).intValue(); + } + + /** + * @param key + * The key under which "value" is to be stored. Existing data + * unde the same key will be replaced. + * @param value + * The value to be stored under "key" + * @return true in case of success, false in case of error, for example if + * trying to replace stored values without proper permissions + */ + public boolean setValue(String key, int value) { + //TODO.WN050311 storage_.put(key, value); + return true; + } + + //WN050311 just for creation of the first file + //beware of the fix path ! + public static void main(String[] args) { + UserSettings s = new UserSettings("isac/xmldata/users/", "x"); + s.setProperty("start_worksheet", "SKIP_SPECIFY_START_SOLVE"); + s.setProperty("enter_specify", "SKIP_SPECIFY_START_SOLVE"); + s.setProperty("next_button", "FORMULAE_ONLY"); + + String filename = "isac/xmldata/users/x_settings.txt"; + try { + FileOutputStream propOutFile = new FileOutputStream(filename); + s.store(propOutFile, "static dialog data of user 'x'"); + + } catch (IOException e) { + System.err.println("I/O failed."); + } + } + +} + diff -r b4896ce4d1b0 -r fcd5648113ca src/java/isac/util/usersettings/UserModel.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/java/isac/util/usersettings/UserModel.java Wed Jun 15 18:31:02 2005 +0200 @@ -0,0 +1,163 @@ +/* + * Created on Feb 22, 2005 + * + * To change the template for this generated file go to + * Window>Preferences>Java>Code Generation>Code and Comments + */ +package isac.util.usersettings; + +/** + * @author Alan Krempler + * + * The UserModel is a class to gather statistics about one user's interaction + * with the system. Statistis are gathered per user and per interactional + * context. + */ +public class UserModel { + + // special value for retrieving the statistics regardless of the dialog atom + // used in the interaction + public static final int DIALOG_ATOM_ANY = 0; + + // counter for identifying pending interactions + private static int interaction_nr_ = 1; + + /** + * @param item_id + * ID of the item being queried, a tactic for example + * @param dialog_atom + * ID of the interactional context use DIALOG_ATOM_ANY if asking + * for statistics for all dialog atoms + * @return count of previously recorded interactions with this item + */ + public int getTouchedCount(int item_id, int dialog_atom) { + // FIXME: returning dummy value in absence of valid statistics + return 0; + } + + /** + * @param item_id + * ID of the item being queried, a tactic for example + * @param dialog_atom + * ID of the interactional context use DIALOG_ATOM_ANY if asking + * for statistics for all dialog atoms + * @return count of previously recorded successful interactions with this + * item + */ + public int getSuccessCount(int item_id, int dialog_atom) { + // FIXME: returning dummy value in absence of valid statistics + return 0; + } + + /** + * @param item_id + * ID of the item being queried, a tactic for example + * @param dialog_atom + * ID of the interactional context use DIALOG_ATOM_ANY if asking + * for statistics for all dialog atoms + * @return time of last recorded interaction with this item + */ + public java.util.Date getTouchedLast(int item_id, int dialog_atom) { + // FIXME: returning dummy value in absence of valid statistics + return new java.util.Date(); + } + + /** + * @param item_id + * ID of the item being queried, a tactic for example + * @param dialog_atom + * ID of the interactional context use DIALOG_ATOM_ANY if asking + * for statistics for all dialog atoms + * @return time of last recorded successful interaction with this item + */ + public java.util.Date getSuccessLast(int item_id, int dialog_atom) { + // FIXME: returning dummy value in absence of valid statistics + return new java.util.Date(); + } + + /** + * @param item_id + * ID of the item being queried, a tactic for example + * @param dialog_atom + * ID of the interactional context use DIALOG_ATOM_ANY if asking + * for statistics for all dialog atoms + * @return average time (seconds) spent in interactions with this item + */ + public int getTimeSpentAvg(int item_id, int dialog_atom) { + // FIXME: returning dummy value in absence of valid statistics + return 0; + } + + /** + * @param item_id + * ID of the item being queried, a tactic for example + * @param dialog_atom + * ID of the interactional context use DIALOG_ATOM_ANY if asking + * for statistics for all dialog atoms + * @return maximum time (seconds) spent in interactions with this item + */ + public int getTimeSpentMax(int item_id, int dialog_atom) { + // FIXME: returning dummy value in absence of valid statistics + return 0; + } + + /** + * @param item_id + * ID of the item being queried, a tactic for example + * @param dialog_atom + * ID of the interactional context use DIALOG_ATOM_ANY if asking + * for statistics for all dialog atoms + * @return standard deviation of time spent in interactions with this item + */ + public float getTimeSpentStddev(int item_id, int dialog_atom) { + // FIXME: returning dummy value in absence of valid statistics + return 0; + } + + /** + * Mark the beginning of an interaction with an item. + * + * @param item_id + * ID of the item being acted upon, a tactic for example + * @param dialog_atom + * ID of the interactional context + * @return unique number to indentify the end of the transaction + */ + public int startInteraction(int item_id, int dialog_atom) { + // FIXME: insert code to record statistics + + // record timestamp + // new java.util.Date(); ... + + // save in static vector of currently open interactions + // ... + + return interaction_nr_++; + } + + /** + * Mark the end of an interaction with an item. + * + * @param interaction_id + * ID of the interaction returned from the call to + * {@link # startInteraction() } + * @param success + * information about the success of the interaction + * @return false in case of failure - no matching start could be found, true + * in case of success + */ + public boolean endInteraction(int interaction_id, int success) { + // FIXME: insert code to record statistics + + // record end timestamp + // new java.util.Date(); ... + + // add to statistics + + // delete from static vector of currently open interactions + // ... + + return true; + } + +} \ No newline at end of file diff -r b4896ce4d1b0 -r fcd5648113ca src/java/isac/util/usersettings/UserSettings.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/java/isac/util/usersettings/UserSettings.java Wed Jun 15 18:31:02 2005 +0200 @@ -0,0 +1,55 @@ +/* + * Created on Feb 22, 2005 + * + * @author Alan Krempler + */ + +package isac.util.usersettings; + +import java.io.Serializable; +import java.util.HashMap; + +/** + * Class for storing/retrieving user settings, i.e. settings which can be set + * manually by the user as opposed to the + * {@link isac.util.usersettings.UserModel#}, which is an abstraction of the + * system's expeience with a user and canot be altered manually. As there is no + * fixed set of user settings, you can regard this class as a simple storage + * backend for key/value pairs. + * + * @author Alan Krempler + * + */ +public class UserSettings implements Serializable { + + private HashMap storage_; + + UserSettings() { + storage_ = new HashMap(); + } + + /** + * @param key + * A string key + * @return The string value associated with the key parameter; null, if + * nothing is stored under this key + */ + public String getValue(String key) { + return (String) storage_.get(key); + } + + /** + * @param key + * The key under which "value" is to be stored. Existing data + * unde the same key will be replaced. + * @param value + * The value to be stored under "key" + * @return true in case of success, false in case of error, for example if + * trying to replace stored values without proper permissions + */ + public boolean setValue(String key, String value) { + storage_.put(key, value); + return true; + } + +} \ No newline at end of file diff -r b4896ce4d1b0 -r fcd5648113ca src/java/isac/wsdialog/ActionOnUIElement.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/java/isac/wsdialog/ActionOnUIElement.java Wed Jun 15 18:31:02 2005 +0200 @@ -0,0 +1,24 @@ +/* + * Created on Feb 6, 2004 + */ +package isac.wsdialog; + +/** + * Describes an action which has to pass a UI Element, e.g a activation or + * deactivating buttons. + * + * @see isac.wsdialog.IUIElement + * @author Alan Krempler + */ +public class ActionOnUIElement extends UserAction { + private int ui_element_id_; + + public ActionOnUIElement(int id, int ui_element_id) { + super(id); + ui_element_id_ = ui_element_id; + } + + public int getUIElementId() { + return ui_element_id_; + } +} \ No newline at end of file diff -r b4896ce4d1b0 -r fcd5648113ca src/java/isac/wsdialog/DialogGuide.java --- a/src/java/isac/wsdialog/DialogGuide.java Fri Oct 10 12:15:14 2003 +0200 +++ b/src/java/isac/wsdialog/DialogGuide.java Wed Jun 15 18:31:02 2005 +0200 @@ -1,124 +1,600 @@ package isac.wsdialog; -import isac.bridge.CalcTree; +import isac.bridge.*; +import isac.session.SDialog; import isac.util.*; -import isac.util.ModSpec; -import isac.util.Tactic; +import isac.util.formulae.*; +import isac.util.interfaces.*; +import isac.util.tactics.*; +import isac.util.users.IUserSettings; +import isac.util.users.User; +import isac.util.users.UserSettings; import java.io.Serializable; import java.net.MalformedURLException; import java.rmi.*; import java.rmi.registry.LocateRegistry; import java.rmi.server.UnicastRemoteObject; -import java.util.StringTokenizer; +import java.util.Vector; + +import org.apache.log4j.Logger; /** + * The DialogGuide moderates the communication between two instances working on + * the same CalcTree object. One of these instances is the user, the other a + * math engine. Most probably, the user's GUI, the DialogGuide and the math + * engine reside on different machines and communicate with each other by means + * of RMI. + * * @author Alan Krempler */ +public class DialogGuide extends UnicastRemoteObject implements DGuide, + IToUser, Serializable { + static Logger logger_ = Logger.getLogger(BridgeRMI.class.getName()); -public class DialogGuide extends UnicastRemoteObject - implements DGuide, IToUser, IToCalc, Serializable { - /** - * @throws RemoteException - */ - protected DialogGuide() throws RemoteException { - super(); - this.rmiBind(); - } + protected MathEngine math_engine_; - protected CalcTree calcTree; - - public void attach(CalcTree calc_tree) { - - } + //the calc_tree_ is also known by the DialogIterators -- remove AK?LK? + //WN0505 only needed by getElementsFromTo !! move method to Iterator? + protected CalcTree calc_tree_; - public void reDisplay() { - } + //protected CalcHead calc_head_; - public void newCalculation(ModSpec mod_spec) { - calcTree = new CalcTree(mod_spec, "radish.ist.intra", 5555); - } + //protected CalcHead calc_head_sub_; - /* (non-Javadoc) - * @see isac.wsdialog.IToUser#calcChanged(isac.wsdialog.CalcChangedEvent) - */ - public void calcChanged(CalcChangedEvent event) { - // TODO Auto-generated method stub - - } + protected int phase_; - /* (non-Javadoc) - * @see isac.wsdialog.IToCalc#iterator() - */ - public ICalcIterator iterator() { - return calcTree.iterator(); - } + private Vector datachange_listeners_; - /* (non-Javadoc) - * @see isac.wsdialog.IToCalc#addListener(isac.wsdialog.IToUser) - */ - public boolean addListener(IToUser listener) { - // TODO Auto-generated method stub - return false; - } - - public Tactic fetchProposedTactic() { - //TODO: ask Walther for improvements. Stupid thing this. - Tactic t = calcTree.fetchProposedTactic(); - StringTokenizer tokenizer = new StringTokenizer(t.getName(), "_"); - StringBuffer tacticStringCap = new StringBuffer(); - int tokens = tokenizer.countTokens(); - for (int i = 0; i < tokens; i++) { - String s = tokenizer.nextToken().toLowerCase(); - char c = Character.toUpperCase(s.charAt(0)); - tacticStringCap.append(c).append(s.substring(1)); - if (i != tokens - 1) - tacticStringCap.append("_"); + private IToWorksheet ui_control_listener_; + + //protected String session_id_;WN0503 + + protected UserSettings user_settings_;//hold whole hashmap locally + + /** + * @param ME_path + * URL of the math engine to be used + * @param user_path + * path(without URL) to UserSettings, UserModel + * @param session_dialog + * @param session_id + * which create the DialogGuide and Worksheet + * @throws RemoteException + */ + public DialogGuide(String ME_path, String user_path, + SDialog session_dialog, String session_id) throws RemoteException { + super(); + this.rmiBind(); + datachange_listeners_ = new Vector(); + MathEngine.init(ME_path); + math_engine_ = MathEngine.getMathEngine(); + phase_ = DIALOGPHASE_IDLE; + + User user = null; + try { + user = session_dialog.getUser(session_id); + } catch (RemoteException e1) { + e1.printStackTrace(); + } + user_settings_ = new UserSettings(user_path, user.getUsername()); } - //System.out.println(tacticStringCap.toString()); - t.setName(tacticStringCap.toString()); - return t; - } - - public void setNextTactic(Tactic tactic) { - calcTree.setNextTactic(tactic); - } - - private void rmiBind(){ - if(System.getSecurityManager() == null) { - System.setSecurityManager(new RMISecurityManager()); + + /** + * start a calculation + */ + public CalcTree startCalculation(int user_id, Formalization f, + int start_from/* WN050421 , int requested_calchead_view */) { + + phase_ = DIALOGPHASE_SOLVE; + calc_tree_ = math_engine_.startCalculation(f); + calc_tree_.addDataChangeListener(this); + return calc_tree_; } - - try{ - LocateRegistry.createRegistry(1099); - }catch(java.rmi.RemoteException exc2){ - System.err.println("can not create registry: " + exc2.getMessage()); + + /** + * at the beginning of a calculation as well as of a subproblem; + * + * @return CalcHead eg. for providing CalcHead#VIEWSTYLE_* + * + * @see isac.wsdialog.DGuide#startSpecifying() + */ + public CalcHead startSpecifying() { + ICalcIterator it = null; + CalcHead calc_head = null; + int calchead_view; + try { + it = calc_tree_.iterator(); + // WN0504DI it = this.iterator();//WN050421 NEW... + it.moveRoot(); + //WN0504DI ...error DialogGuide_Stub.startSpecifying(Unknown + //WN0504DI Source) with ...NEW + calc_head = (CalcHead) it.getFormula(); + } catch (RemoteException e) { + e.printStackTrace(); + } + + //AK set viewstyle according to user settings + switch (user_settings_.getValue(IUserSettings.KEY1_START_SPECIFY)) { + //________________________________________________________ + case IUserSettings.VAL1_SKIP_SPECIFY_TO_START_SOLVE: + calc_tree_.completeCalcHead(); + calchead_view = CalcHead.VIEWSTYLE_SINGLELINE; + phase_ = DIALOGPHASE_SOLVE; + break; + //________________________________________________________ + case IUserSettings.VAL1_POP_CALCHEAD_WITH_DESCRIPTIONS: + calc_tree_.autoCalculate(IToCalc.SCOPE_CALCULATION, 1); + //...applies the Tactic Model_Problem which generates descriptions + calchead_view = CalcHead.VIEWSTYLE_FULL; + phase_ = DIALOGPHASE_SPECIFY; + break; + //________________________________________________________ + default: + //=case IUserSettings.VAL1_SKIP_SPECIFY_TO_START_SOLVE: + calc_tree_.completeCalcHead(); + calchead_view = CalcHead.VIEWSTYLE_SINGLELINE; + phase_ = DIALOGPHASE_SOLVE; + break; + } + calc_head.setViewStyle(calchead_view); + return calc_head; } - - String name = "//localhost/isac-DialogGuide"; - try { - System.out.println("try to bind as " + name); - Naming.rebind(name, this); - System.out.println("Object Manager bound to " + name); - } catch (java.rmi.ConnectException e) { - System.err.println("failed to contact as " + name + - " (creating RMI-Server on localhost: 1099)"); - } catch (RemoteException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (MalformedURLException e) { - // TODO Auto-generated catch block - e.printStackTrace(); + + // /** + // * @deprecated Use {@link #notifyUserAction(IUserAction)}instead + // */ + // public void modifyCalcHead(CalcHead calc_head) { + // // MathEngine.getMathEngine().modifyCalcHead(calc_head); + // calc_tree_.modifyCalcHead(calc_head); + // } + + /** + * dismiss the CalcHeadPanel and start DGuide#DIALOGPHASE_SOLVE + * + * @see isac.util.interfaces.IToCalc#startSolving() + */ + public void startSolving() throws Exception { + calc_tree_.startSolving(); + } - } - - public static void main(String[] args) { - try { - new DialogGuide(); - } catch (RemoteException e) { - // TODO Auto-generated catch block - e.printStackTrace(); + + /** + * accept the changes in a calculation reported by the bridge .............. + * TODO handle these changes according to UserSettings and UserModel + * + * ... and pass them to the Worksheet + * + * @see isac.wsdialog.IToUser#calcChanged(isac.wsdialog.CalcChangedEvent) + */ + public void calcChanged(CalcChangedEvent event) throws RemoteException { + logger_.fatal(" WS<-. . : calcChanged (unc=" + + event.getLastUnchangedFormula().toSMLString() + ", del=" + + event.getLastDeletedFormula().toSMLString() + ", gen=" + + event.getLastGeneratedFormula().toSMLString()); + try { + for (int i = 0; i < datachange_listeners_.size(); i++) { + ((IToUser) datachange_listeners_.elementAt(i)) + .calcChanged(event);//WN050513GOON + // .calcChanged(event.createDialogIterators(this)); + } + } catch (Exception e) { + e.printStackTrace(); + } } - } -} + + /** + * @see isac.wsdialog.DGuide#iterator(CalcIterator, DGuide) + * @see isac.util.interfaces.IToCalc#iterator() + */ + public ICalcIterator iterator(CalcIterator it, DGuide dg) { + //WN050512...was before: + //public ICalcIterator iterator() { + // try { + // return new DialogIterator((CalcIterator) calc_tree_.iterator(), + // this); + // } catch (Exception e) { + // e.printStackTrace(); + // } + // return null; + try { + return new DialogIterator(it, dg); + } catch (RemoteException e) { + e.printStackTrace(); + } + return null; + } + + /** + * @see isac.wsdialog.IToCalc#addListener(isac.wsdialog.IToUser) + */ + public boolean addDataChangeListener(IToUser listener) + throws RemoteException { + if (datachange_listeners_.contains(listener)) { + return false; + } else { + datachange_listeners_.add(listener); + } + return true; + } + + public boolean registerUIControlListener(IToWorksheet listener) + throws RemoteException { + //WN0504 ??? + // if (ui_control_listener_ != null) { + // ui_control_listener_.doUIAction(new UserAction(UI_DO_DETACH)); + // } + ui_control_listener_ = listener; + return true; + } + + // /** + // * @see isac.wsdialog.IToCalc#fetchProposedTactic + // * @deprecated Use {@link #notifyUserAction(IUserAction)}instead + // */ + // public Tactic fetchProposedTactic() { + // return calc_tree_.fetchProposedTactic(); + // } + // + // + // /** + // * @deprecated Use {@link #notifyUserAction(IUserAction)}instead + // */ + // public int setNextTactic(Tactic tactic) { + // return calc_tree_.setNextTactic(tactic); + // } + // + // /** + // * @deprecated Use {@link #notifyUserAction(IUserAction)}instead + // */ + // public int autoCalculate(int scope, int nSteps) { + // return calc_tree_.autoCalculate(scope, nSteps); + // } + // + // /** + // * @deprecated Use {@link #notifyUserAction(IUserAction)}instead + // */ + // public void tryMatch(CalcHead ch, CalcHeadCompoundID problemID) + // throws NotInSpecificationPhaseException { + // + // // MathEngine.getMathEngine().tryMatch(ch, problemID); + // math_engine_.tryMatch(ch, problemID); + // } + // + // /** + // * @deprecated Use {@link #notifyUserAction(IUserAction)}instead + // */ + // public void tryRefine(CalcHead ch, CalcHeadCompoundID problemID) + // throws NotInSpecificationPhaseException { + // + // // MathEngine.getMathEngine().tryRefine(ch , problemID); + // math_engine_.tryRefine(ch, problemID); + // } + // + // /** + // * @deprecated Use {@link #notifyUserAction(IUserAction)}instead + // */ + // public ICalcIterator getActiveFormula() { + // return calc_tree_.getActiveFormula(); + // } + // + // /** + // * @throws RemoteException + // * @deprecated Use {@link #notifyUserAction(IUserAction)}instead + // */ + // public int replaceFormula(CalcFormula newFormula) throws RemoteException + // { + // return calc_tree_.replaceFormula(newFormula); + // } + // + // /** + // * @throws RemoteException + // * @deprecated Use {@link #notifyUserAction(IUserAction)}instead + // */ + // public int appendFormula(CalcFormula newFormula) throws RemoteException { + // return calc_tree_.appendFormula(newFormula); + // } + // + // /** + // * @deprecated Use {@link #notifyUserAction(IUserAction)}instead + // */ + // public void moveActiveFormula(ICalcIterator newActiveFormula) { + // calc_tree_.moveActiveFormula(newActiveFormula); + // } + // + /** + * Notify the Dialog Guide about interaction from the User + * + * @param action + * @return true, if the action has been processed, false if the processing + * the action has been denied + * @throws RemoteException + * + */ + public boolean notifyUserAction(IUserAction action) + throws DialogProtocolException, RemoteException { + int request = action.getActionID(); + logger_.fatal(" WS->DG: notifyUserAction request= " + request); + + // two userActions dont care about the dialogphase + //WN050420 would be nicer, if DialogGuide would set the Buttons + switch (request) { + case (UI_CALCULATE_1): + if (phase_ == DIALOGPHASE_SPECIFY) + request = UI_SPECIFY_TO_SOLVE;//WN##################### + else + request = UI_SOLVE_CALCULATE_1; + break; + case (UI_CALCULATE_ALL): + if (phase_ == DIALOGPHASE_SPECIFY) + request = UI_SPECIFY_CALCULATE_ALL; + else + request = UI_SOLVE_CALCULATE_ALL; + } + // all other userActions belong to a certain dialogphase + + switch (phase_) { + case DIALOGPHASE_IDLE: + throw new DialogProtocolException(request, phase_); + case DIALOGPHASE_SPECIFY: + if (request < UI_DUMMY_FIRST_SPECIFY + || request > UI_DUMMY_LAST_SPECIFY) + throw new DialogProtocolException(request, phase_); + break; + case DIALOGPHASE_SOLVE: + if (request < UI_DUMMY_FIRST_SOLVE || request > UI_DUMMY_LAST_SOLVE) + throw new DialogProtocolException(request, phase_); + break; + } + + //*********** handle IUserAction's ********************** + CalcHead calc_head = new CalcHead();//WN0502023????????? + try { + calc_head = (CalcHead) calc_tree_.iterator().getFormula(); + } catch (Exception e) { + e.printStackTrace(); + } + switch (request) { + case UI_SPECIFY_TRY_MATCH: + throw new DialogNotImplementedException(request, phase_); + // try { + // tryMatch(calc_head, ((UserActionOnCalcHeadCompoundID) action) + // .getObjectID()); + // } catch (NotInSpecificationPhaseException e) { + // throw new DialogMathException(request, phase_, e); + // } + // break; + + case UI_SPECIFY_TRY_REFINE: + throw new DialogNotImplementedException(request, phase_); + // try { + // tryRefine(calc_head, ((UserActionOnCalcHeadCompoundID) action) + // .getObjectID()); + // } catch (NotInSpecificationPhaseException e) { + // throw new DialogMathException(request, phase_, e); + // } + // break; + + case UI_SPECIFY_CHANGE_VIEW: + calc_head.setViewStyle(((UserActionOnInt) action).getInt()); + break; + + case UI_SPECIFY_COMPLETE_CALCHEAD: + calc_tree_.completeCalcHead(); + // old-style filling the fields of the calc-head by setting + // the HELP_ME flag + // calc_head_.setCalcHeadStatus(CalcHead.MODEL_ITEM_HELP_ME); + // modifyCalcHead(calc_head_); + break; + case UI_SPECIFY_COMPLETE_METHOD: + case UI_SPECIFY_COMPLETE_THEORY: + case UI_SPECIFY_COMPLETE_PROBLEM: + case UI_SPECIFY_COMPLETE_GIVEN: + case UI_SPECIFY_COMPLETE_FIND: + case UI_SPECIFY_COMPLETE_RELATE: + throw new DialogNotImplementedException(request, phase_); + + case UI_SPECIFY_CHECK_CALCHEAD: + calc_tree_.modifyCalcHead(calc_head); + break; + + // was: startCalculation() WN050428 ? really ? + case UI_SPECIFY_TO_SOLVE: + case UI_SPECIFY_CALCULATE_ALL: + //if (user_settings_.getValue("")) + if (true) + calc_tree_.completeCalcHead(); + else + calc_tree_.modifyCalcHead(calc_head); + + if (calc_head.getCalcHeadStatus() != CalcHead.MODEL_ITEM_CORRECT) + return false; + + try { + calc_tree_.startSolving(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + // calc_tree_ = MathEngine.getMathEngine().startSolving(calcHead); + // FIXME: AK020224: do not register with the calc_tree_ if finished + // specifying a SUBPROBLEM + //calc_tree_.addDataChangeListener(this);//WN050420-->startCalculation + + phase_ = DIALOGPHASE_SOLVE;//FIXXXME.WN050428 + // fall through to calculate + + case UI_SOLVE_CALCULATE_1: + //WN050420 why not at (*) here ? + case UI_SOLVE_CALCULATE_ALL: + switch (request) { + case UI_SPECIFY_CALCULATE_ALL: + case UI_SOLVE_CALCULATE_ALL: + calc_tree_.autoCalculate(IToCalc.SCOPE_CALCULATION, 0); + break; + case UI_SPECIFY_TO_SOLVE://WN050420 ??? + // break; + default: + calc_tree_.autoCalculate(IToCalc.SCOPE_CALCULATION, 1); + //why not at (*) above ? + break; + } + break; + + case UI_SOLVE_CALCULATE_SUBPROBLEM: + calc_tree_.autoCalculate(IToCalc.SCOPE_SUBPROBLEM, 0); + break; + + case UI_SOLVE_EDIT_ACTIVE_FORMULA: + ui_control_listener_.doUIAction(new UserAction(UI_DO_EDIT_FORMULA)); + break; + + case UI_SOLVE_EDIT_ACTIVE_FORMULA_COMPLETE: + CalcFormula formula = (CalcFormula) ((UserActionOnCalcElement) action) + .getCalcElement(); + // if the position is null, the formula did not exist, so we try to + // append a new formula + if (formula.getPosition() == null) { + calc_tree_.appendFormula(formula); + } else { + calc_tree_.replaceFormula(formula); + } + break; + + case UI_SOLVE_APPEND_USER_FORMULA: + // appendFormula((Formula) ((UserActionOnCalcElement) + // action).getCalcElement()); + ui_control_listener_ + .doUIAction(new UserAction(UI_DO_APPEND_FORMULA)); + break; + + case UI_SOLVE_MOVE_ACTIVE_FORMULA: + calc_tree_.moveActiveFormula(((UserActionOnIterator) action) + .getPosition()); + break; + + case UI_SOLVE_GET_PROPOSED_TACTIC: + throw new DialogNotImplementedException(request, phase_); + + case UI_SOLVE_GET_APPLICABLE_TACTICS: + throw new DialogNotImplementedException(request, phase_); + + case UI_SOLVE_SET_NEXT_TACTIC: + calc_tree_ + .setNextTactic((Tactic) ((UserActionOnCalcElement) action) + .getCalcElement()); + //WN041126 extracted from isac.bridge.CalcTree#setNextTactic @@@ + //autoCalculate(SCOPE_CALCULATION, 1); + break; + + case UI_SOLVE_HELP_ENTERING_FORMULA: + throw new DialogNotImplementedException(request, phase_); + + case UI_SOLVE_SHOW_ASSUMPTIONS: + throw new DialogNotImplementedException(request, phase_); + + case UI_SOLVE_SHOW_DETAILS: + throw new DialogNotImplementedException(request, phase_); + + default: + throw new DialogUnknownActionException(request, phase_); + } + return true; + } + + private void rmiBind() { + if (System.getSecurityManager() == null) { + System.setSecurityManager(new RMISecurityManager()); + } + + try { + LocateRegistry.createRegistry(1099); + } catch (java.rmi.RemoteException exc2) { + System.err.println("can not create registry: " + exc2.getMessage()); + } + + String name = "//localhost/isac-DialogGuide"; + try { + System.out.println("try to bind as " + name); + Naming.rebind(name, this); + System.out.println("Dialog Guide bound to " + name); + //WN040906 was Object Manager ... + } catch (java.rmi.ConnectException e) { + System.err.println("failed to contact as " + name + + " (creating RMI-Server on localhost: 1099)"); + } catch (RemoteException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (MalformedURLException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + // public static void main(String[] args) { + // try { + // new DialogGuide(args[0]); + // + // } catch (RemoteException e) { + // e.printStackTrace(); + // } + // } + + // /** + // * @see + // isac.util.interfaces.IToCalc#completeCalcHead(isac.util.formulae.CalcHead) + // * @deprecated Use {@link #notifyUserAction(IUserAction)}instead + // */ + // public void completeCalcHead(CalcHead calcHead) { + // // TODO Auto-generated method stub + // + // } + // + // /** + // * @see + // isac.util.interfaces.IToCalc#completeCalcHead(isac.util.formulae.CalcHead, + // * int) + // * @deprecated Use {@link #notifyUserAction(IUserAction)}instead + // */ + // public void completeCalcHead(CalcHead calcHead, int completeItem) { + // // TODO Auto-generated method stub + // + // } + // + // /** + // * (non-Javadoc) + // * + // * @see isac.util.interfaces.IToCalc#completeCalcHead() + // * @deprecated Use {@link #notifyUserAction(IUserAction)}instead + // */ + // public void completeCalcHead() throws RemoteException { + // // TODO Auto-generated method stub WN050223 + // + // } + // + // /** + // * @deprecated Use {@link #notifyUserAction(IUserAction)}instead + // * + // * @see + // isac.util.interfaces.IToCalc#intermediateSteps(isac.util.interfaces.ICalcIterator) + // */ + // public int intermediateSteps(ICalcIterator i) throws RemoteException { + // // TODO Auto-generated method stub + // return 0; + // } + // + // /** + // * @see + // isac.util.interfaces.IToCalc#getElementsFromTo(isac.util.interfaces.ICalcIterator, + // * isac.util.interfaces.ICalcIterator, java.lang.Integer, boolean) + // * @deprecated Use {@link #notifyUserAction(IUserAction)}instead + // */ + // public Vector getElementsFromTo(ICalcIterator iterator_from, + // ICalcIterator iterator_to, Integer level, + // boolean result_includes_tactics) throws RemoteException { + // // TODO Auto-generated method stub + // return null; + // } + +} \ No newline at end of file diff -r b4896ce4d1b0 -r fcd5648113ca src/java/isac/wsdialog/DialogMathException.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/java/isac/wsdialog/DialogMathException.java Wed Jun 15 18:31:02 2005 +0200 @@ -0,0 +1,22 @@ +/* + * Created on Feb 12, 2004 + * + */ + +package isac.wsdialog; + +/** + * Exception thrown by the DialogGuide if the user action indicated caused an + * error in the math engine. + * + * @author Alan Krempler + * + */ +class DialogMathException extends DialogProtocolException { + + DialogMathException(int failed_action, int dialog_state, Throwable cause) { + super(failed_action, dialog_state, + "\nThis exception originates from the MathEngine.", cause); + } +} + diff -r b4896ce4d1b0 -r fcd5648113ca src/java/isac/wsdialog/DialogNotImplementedException.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/java/isac/wsdialog/DialogNotImplementedException.java Wed Jun 15 18:31:02 2005 +0200 @@ -0,0 +1,20 @@ +/* + * Created on Nov 18, 2003 + */ + +package isac.wsdialog; + +/** + * Exception thrown by the DialogGuide if the action requested by the user is + * known to the DialogGuide but not implemented yet. + * + * @author Alan Krempler + */ +class DialogNotImplementedException extends DialogProtocolException { + protected int failed_action_; + + DialogNotImplementedException(int failed_action, int dialog_state) { + super(failed_action, dialog_state, + "\nProcessing this request is not implemented yet.", null); + } +} \ No newline at end of file diff -r b4896ce4d1b0 -r fcd5648113ca src/java/isac/wsdialog/DialogProtocolException.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/java/isac/wsdialog/DialogProtocolException.java Wed Jun 15 18:31:02 2005 +0200 @@ -0,0 +1,32 @@ +/* + * Created on Nov 18, 2003 + */ +package isac.wsdialog; + +/** + * Exception thrown by the DialogGuide if the action requested by the user does + * not match the state of the DialogGuide, e.g. specifying during the solving + * phase. + * + * @author Alan Krempler + */ +public class DialogProtocolException extends Exception { + + protected int failed_action_; + + protected int dialog_state_; + + DialogProtocolException(int failed_action, int dialog_state, String extra, + Throwable cause) { + super("The DialogGuide cannot process a request.\n" + + "Requested action: " + String.valueOf(failed_action) + + ", Dialog state:" + String.valueOf(dialog_state) + ", " + + extra); + failed_action_ = failed_action; + dialog_state_ = dialog_state; + } + + DialogProtocolException(int failed_action, int dialog_state) { + this(failed_action, dialog_state, null, null); + } +} \ No newline at end of file diff -r b4896ce4d1b0 -r fcd5648113ca src/java/isac/wsdialog/DialogUnknownActionException.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/java/isac/wsdialog/DialogUnknownActionException.java Wed Jun 15 18:31:02 2005 +0200 @@ -0,0 +1,18 @@ +/* + * Created on Nov 18, 2003 + */ +package isac.wsdialog; + +/** + * Exception thrown by the DialogGuide if the user action indicated is not known + * to the DialogGuide. + * + * @author Alan Krempler + */ +class DialogUnknownActionException extends DialogProtocolException { + + DialogUnknownActionException(int failed_action, int dialog_state) { + super(failed_action, dialog_state, "\nThis request is unknown.", null); + } + +} \ No newline at end of file diff -r b4896ce4d1b0 -r fcd5648113ca src/java/isac/wsdialog/IUIElement.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/java/isac/wsdialog/IUIElement.java Wed Jun 15 18:31:02 2005 +0200 @@ -0,0 +1,226 @@ +/* + * Created on Dec 12, 2003 + */ +package isac.wsdialog; + +/** + * @author Alan Krempler + * + * Constants describing interactions or request from the user + */ +public interface IUIElement { + + /** ***************** NOTIFICATIONS: SPECIFYING PHASE ********************** */ + + public static final int UI_DUMMY_FIRST_SPECIFY = 1; + + /** + * get descriptions into all items of a model; these give hints for input to + * the user + */ + public static final int UI_SPECIFY_GET_DESCRIPTIONS = 2; + + /** + * During the specifying phase, try to match a problem type to the data + * entered so far WN //// ?items of the model entered so far + */ + public static final int UI_SPECIFY_TRY_MATCH = 2; + + /** + * During the specifying phase, try to refine the problem type. WN //// + */ + public static final int UI_SPECIFY_TRY_REFINE = 3; + + /** + * During the specifying phase, change the view on the CalcHead. + */ + public static final int UI_SPECIFY_CHANGE_VIEW = 4; + + /** + * During the specifying phase, have the CalcHead completed by the math + * engine. + */ + public static final int UI_SPECIFY_COMPLETE_CALCHEAD = 5; + + /** + * During the specifying phase, have the Method field of the CalcHead + * completed by the math engine. + */ + public static final int UI_SPECIFY_COMPLETE_METHOD = 6; + + /** + * During the specifying phase, have the Theory field of the CalcHead + * completed by the math engine. + */ + public static final int UI_SPECIFY_COMPLETE_THEORY = 7; + + /** + * During the specifying phase, have the Problem field of the CalcHead + * completed by the math engine. + */ + public static final int UI_SPECIFY_COMPLETE_PROBLEM = 8; + + /** + * During the specifying phase, have the Given field of the CalcHead + * completed by the math engine. + */ + public static final int UI_SPECIFY_COMPLETE_GIVEN = 9; + + /** + * During the specifying phase, have the Find field of the CalcHead + * completed by the math engine. + */ + public static final int UI_SPECIFY_COMPLETE_FIND = 10; + + /** + * During the specifying phase, have the Relate field of the CalcHead + * completed by the math engine. + */ + public static final int UI_SPECIFY_COMPLETE_RELATE = 11; + + /** + * During the specifying phase, have the CalcHead checked for completeness + * and consistency. + */ + public static final int UI_SPECIFY_CHECK_CALCHEAD = 12; + + /** + * Leave the specifying phase, enter the solving phase and calculate the + * first step of the method. + */ + public static final int UI_SPECIFY_TO_SOLVE = 13; + + /** + * Leave the specifying phase, enter the solving phase and calculate until a + * final result is reached. + */ + public static final int UI_SPECIFY_CALCULATE_ALL = 14; + + public static final int UI_DUMMY_LAST_SPECIFY = 14; + + /** ***************** NOTIFICATIONS: SOLVING PHASE ********************** */ + + public static final int UI_DUMMY_FIRST_SOLVE = 21; + + /** + * During the solving phase, calculate one more step. + */ + public static final int UI_SOLVE_CALCULATE_1 = 21; + + /** + * During the solving phase, calculate until a final result is reached. + */ + public static final int UI_SOLVE_CALCULATE_ALL = 22; + + /** + * During the solving phase, calculate until the current subproblem is + * solved. + */ + public static final int UI_SOLVE_CALCULATE_SUBPROBLEM = 23; + + /** + * During the solving phase, request editing the currently active formula. + * + * WN0412 If request is conceded, do + * + * @see UI_SOLVE_EDIT_ACTIVE_FORMULA_COMPLETE + */ + public static final int UI_SOLVE_EDIT_ACTIVE_FORMULA = 24; + + /** + * During the solving phase, notify that editing the currently active + * formula is finished. This implies a request for updating the CalcTree. + */ + public static final int UI_SOLVE_EDIT_ACTIVE_FORMULA_COMPLETE = 25; + + /** + * During the solving phase, request inserting a new formula _after_ the + * currently active formula, making the new formula the currently active + * formula. At present, this does not imply editing the formula and must be + * requested in a separate step. WN0412: ...??? is this right interpreted by + * ... WN0412 If request is conceded, do + * + * @see UI_SOLVE_EDIT_ACTIVE_FORMULA_COMPLETE + */ + public static final int UI_SOLVE_APPEND_USER_FORMULA = 26; + + /** + * During the solving phase, request making the referened formula the + * currently active formula. + */ + public static final int UI_SOLVE_MOVE_ACTIVE_FORMULA = 27; + + /** + * During the solving phase, ask for the tactic the math engine would apply + * to the current formula. + */ + public static final int UI_SOLVE_GET_PROPOSED_TACTIC = 30; + + /** + * During the solving phase, ask for a list of tactics to the current + * formula. + */ + public static final int UI_SOLVE_GET_APPLICABLE_TACTICS = 31; + + /** + * During the solving phase, set the tactic to be applied to the current + * formula. + */ + public static final int UI_SOLVE_SET_NEXT_TACTIC = 32; + + /** + * When entering a formula during the solving phase, request help on + * entering the formula. + */ + public static final int UI_SOLVE_HELP_ENTERING_FORMULA = 33; + + /** + * During the solving phase, show which assumptions hold at the current + * point of calculation. + */ + public static final int UI_SOLVE_SHOW_ASSUMPTIONS = 40; + + /** + * During the solving phase, request more detail about the currently + * referenced element. + */ + public static final int UI_SOLVE_SHOW_DETAILS = 41; + + public static final int UI_DUMMY_LAST_SOLVE = 41; + + /** ***************** NOTIFICATIONS: unaware of PHASE **************** */ + + public static final int UI_CALCULATE_1 = 101; + + public static final int UI_CALCULATE_ALL = 102; + + /** ***************** ACTIVE REQUESTS TO THE UI ********************** */ + + /** + * Request editing the currently active formula. DG distinguishes between + * SPECIFY and SOLVE; thus could drop UI_SOLVE_EDIT_ACTIVE_FORMULA : int + */ + public static final int UI_DO_EDIT_FORMULA = 129; + + /** + * Request appending a new, empty formula. + */ + public static final int UI_DO_APPEND_FORMULA = 130; + + /** + * Activate an UI element. + */ + public static final int UI_DO_ACTIVATE = 131; + + /** + * Deactivate an UI element. + */ + public static final int UI_DO_DEACTIVATE = 132; + + /** + * The Dialog Guide has detached the listener and will not send any more + * control requests. If registered as a Data Change Listener, update + * notifications will still arrive! + */ + public static final int UI_DO_DETACH = 133; //WN ??? Design ??? +} \ No newline at end of file diff -r b4896ce4d1b0 -r fcd5648113ca src/java/isac/wsdialog/IUserAction.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/java/isac/wsdialog/IUserAction.java Wed Jun 15 18:31:02 2005 +0200 @@ -0,0 +1,23 @@ +/* + * Created on Dec 12, 2003 + */ +package isac.wsdialog; + +import java.io.Serializable; + +import isac.wsdialog.IUIElement; + +/** + * Interface common to notifications about user interaction + * + * @author Alan Krempler + */ +public interface IUserAction extends IUIElement, Serializable { + + /** + * @return An integer value describing the action the user requested on the + * GUI + */ + int getActionID(); + +} \ No newline at end of file diff -r b4896ce4d1b0 -r fcd5648113ca src/java/isac/wsdialog/UserAction.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/java/isac/wsdialog/UserAction.java Wed Jun 15 18:31:02 2005 +0200 @@ -0,0 +1,31 @@ +/* + * Created on Dec 12, 2003 + */ +package isac.wsdialog; + +/** + * Notification about the user clicking a GUI element. + * + * @author Alan Krempler + */ +public class UserAction implements IUserAction { + + private int id_; + + /** + * TODO: move class subtree (including IUserAction) to package + * isac.gui.worksheet? This way, the constructors could be package-private + * to the objects which construct them. + * + * @param id + * An integer value describing the action the user requested on + * the GUI + */ + public UserAction(int id) { + id_ = id; + } + + public int getActionID() { + return id_; + } +} \ No newline at end of file diff -r b4896ce4d1b0 -r fcd5648113ca src/java/isac/wsdialog/UserActionOnCalcElement.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/java/isac/wsdialog/UserActionOnCalcElement.java Wed Jun 15 18:31:02 2005 +0200 @@ -0,0 +1,28 @@ +/* + * Created on Feb 6, 2004 + */ +package isac.wsdialog; + +import isac.util.interfaces.ICalcElement; + +/** + * Describes a user action which has to pass a CalcElement, e.g a newly entered + * formula or tactic which is not yet part of the calculation tree. + * + * @see isac.wsdialog.UserActionOnIterator + * @see isac.wsdialog.UserActionOnCalcHeadCompoundID + * @author Alan Krempler + */ +public class UserActionOnCalcElement extends UserAction { + private ICalcElement calc_element_; + + public UserActionOnCalcElement(int id, ICalcElement calc_element) { + super(id); + calc_element_ = calc_element; + } + + public ICalcElement getCalcElement() { + return calc_element_; + } + +} \ No newline at end of file diff -r b4896ce4d1b0 -r fcd5648113ca src/java/isac/wsdialog/UserActionOnCalcHeadCompoundID.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/java/isac/wsdialog/UserActionOnCalcHeadCompoundID.java Wed Jun 15 18:31:02 2005 +0200 @@ -0,0 +1,27 @@ +/* + * Created on Dec 12, 2003 + */ +package isac.wsdialog; + +import isac.util.formulae.CalcHeadCompoundID; + +/** + * Describes an user action on part of a CalcHead. + * + * @see isac.wsdialog.UserActionOnIterator + * @see isac.wsdialog.UserActionOnCalcHeadCompoundID + * @author Alan Krempler + */ +public class UserActionOnCalcHeadCompoundID extends UserAction { + private CalcHeadCompoundID chc_id_; + + public UserActionOnCalcHeadCompoundID(int id, CalcHeadCompoundID chc_id) { + super(id); + chc_id_ = chc_id; + } + + public CalcHeadCompoundID getObjectID() { + return chc_id_; + } + +} \ No newline at end of file diff -r b4896ce4d1b0 -r fcd5648113ca src/java/isac/wsdialog/UserActionOnInt.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/java/isac/wsdialog/UserActionOnInt.java Wed Jun 15 18:31:02 2005 +0200 @@ -0,0 +1,35 @@ +/* + * Created on Dec 12, 2003 + */ +package isac.wsdialog; + +/** + * Describes an user action passing an integer value. + * + * @see isac.wsdialog.UserActionOnIterator + * @see isac.wsdialog.UserActionOnCalcHeadCompoundID + * @author Alan Krempler + */ +public class UserActionOnInt extends UserAction { + private int i_; + + /** + * @param id + * @param i + * The integer value holding additional information to the + * UserAction + */ + public UserActionOnInt(int id, int i) { + super(id); + i_ = i; + } + + /** + * @return The integer value holding additional information to the + * UserAction + */ + public int getInt() { + return i_; + } + +} \ No newline at end of file diff -r b4896ce4d1b0 -r fcd5648113ca src/java/isac/wsdialog/UserActionOnIterator.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/java/isac/wsdialog/UserActionOnIterator.java Wed Jun 15 18:31:02 2005 +0200 @@ -0,0 +1,28 @@ +/* + * Created on Dec 12, 2003 + */ +package isac.wsdialog; + +import isac.util.interfaces.ICalcIterator; + +/** + * Describes an user action which relates to a CalcElement which is part of the + * current calculation. + * + * @see isac.wsdialog.UserActionOnCalcElement + * @see isac.wsdialog.UserActionOnCalcHeadCompoundID + * @author Alan Krempler + */ +public class UserActionOnIterator extends UserAction { + private ICalcIterator iterator_; + + public UserActionOnIterator(int id, ICalcIterator iterator) { + super(id); + iterator_ = iterator; + } + + public ICalcIterator getPosition() { + return iterator_; + } + +} \ No newline at end of file