src/java/isac/wsdialog/DialogGuide.java
branchjava_rename_format
changeset 3922 fcd5648113ca
parent 960 30baa0cd35f8
     1.1 --- a/src/java/isac/wsdialog/DialogGuide.java	Fri Oct 10 12:15:14 2003 +0200
     1.2 +++ b/src/java/isac/wsdialog/DialogGuide.java	Wed Jun 15 18:31:02 2005 +0200
     1.3 @@ -1,124 +1,600 @@
     1.4  package isac.wsdialog;
     1.5  
     1.6 -import isac.bridge.CalcTree;
     1.7 +import isac.bridge.*;
     1.8 +import isac.session.SDialog;
     1.9  import isac.util.*;
    1.10 -import isac.util.ModSpec;
    1.11 -import isac.util.Tactic;
    1.12 +import isac.util.formulae.*;
    1.13 +import isac.util.interfaces.*;
    1.14 +import isac.util.tactics.*;
    1.15 +import isac.util.users.IUserSettings;
    1.16 +import isac.util.users.User;
    1.17 +import isac.util.users.UserSettings;
    1.18  
    1.19  import java.io.Serializable;
    1.20  import java.net.MalformedURLException;
    1.21  import java.rmi.*;
    1.22  import java.rmi.registry.LocateRegistry;
    1.23  import java.rmi.server.UnicastRemoteObject;
    1.24 -import java.util.StringTokenizer;
    1.25 +import java.util.Vector;
    1.26 +
    1.27 +import org.apache.log4j.Logger;
    1.28  
    1.29  /**
    1.30 + * The DialogGuide moderates the communication between two instances working on
    1.31 + * the same CalcTree object. One of these instances is the user, the other a
    1.32 + * math engine. Most probably, the user's GUI, the DialogGuide and the math
    1.33 + * engine reside on different machines and communicate with each other by means
    1.34 + * of RMI.
    1.35 + * 
    1.36   * @author Alan Krempler
    1.37   */
    1.38 +public class DialogGuide extends UnicastRemoteObject implements DGuide,
    1.39 +        IToUser, Serializable {
    1.40  
    1.41 +    static Logger logger_ = Logger.getLogger(BridgeRMI.class.getName());
    1.42  
    1.43 -public class DialogGuide extends UnicastRemoteObject 
    1.44 -                         implements DGuide, IToUser, IToCalc, Serializable {
    1.45 -  /**
    1.46 -   * @throws RemoteException
    1.47 -   */
    1.48 -  protected DialogGuide() throws RemoteException {
    1.49 -    super();
    1.50 -    this.rmiBind();
    1.51 -  }
    1.52 +    protected MathEngine math_engine_;
    1.53  
    1.54 -  protected CalcTree calcTree;
    1.55 - 
    1.56 -	public void attach(CalcTree calc_tree) {
    1.57 -	  
    1.58 -	}
    1.59 +    //the calc_tree_ is also known by the DialogIterators -- remove AK?LK?
    1.60 +    //WN0505 only needed by getElementsFromTo !! move method to Iterator?
    1.61 +    protected CalcTree calc_tree_;
    1.62  
    1.63 -	public void reDisplay() {
    1.64 -	}
    1.65 +    //protected CalcHead calc_head_;
    1.66  
    1.67 -	public void newCalculation(ModSpec mod_spec) {
    1.68 -	  calcTree = new CalcTree(mod_spec, "radish.ist.intra", 5555);    
    1.69 -	}
    1.70 +    //protected CalcHead calc_head_sub_;
    1.71  
    1.72 -	/* (non-Javadoc)
    1.73 -	 * @see isac.wsdialog.IToUser#calcChanged(isac.wsdialog.CalcChangedEvent)
    1.74 -	 */
    1.75 -	public void calcChanged(CalcChangedEvent event) {
    1.76 -		// TODO Auto-generated method stub
    1.77 -		
    1.78 -	}
    1.79 +    protected int phase_;
    1.80  
    1.81 -	/* (non-Javadoc)
    1.82 -	 * @see isac.wsdialog.IToCalc#iterator()
    1.83 -	 */
    1.84 -	public ICalcIterator iterator() {
    1.85 -		return calcTree.iterator();
    1.86 -	}
    1.87 +    private Vector datachange_listeners_;
    1.88  
    1.89 -	/* (non-Javadoc)
    1.90 -	 * @see isac.wsdialog.IToCalc#addListener(isac.wsdialog.IToUser)
    1.91 -	 */
    1.92 -	public boolean addListener(IToUser listener) {
    1.93 -		// TODO Auto-generated method stub
    1.94 -		return false;
    1.95 -	}
    1.96 -  
    1.97 -  public Tactic fetchProposedTactic() {
    1.98 -    //TODO: ask Walther for improvements. Stupid thing this.
    1.99 -    Tactic t = calcTree.fetchProposedTactic();
   1.100 -    StringTokenizer tokenizer = new StringTokenizer(t.getName(), "_");
   1.101 -    StringBuffer tacticStringCap = new StringBuffer();
   1.102 -    int tokens = tokenizer.countTokens();
   1.103 -    for (int i = 0; i < tokens; i++) {
   1.104 -      String s = tokenizer.nextToken().toLowerCase();
   1.105 -      char c = Character.toUpperCase(s.charAt(0));
   1.106 -      tacticStringCap.append(c).append(s.substring(1));
   1.107 -      if (i != tokens - 1)
   1.108 -        tacticStringCap.append("_");          
   1.109 +    private IToWorksheet ui_control_listener_;
   1.110 +
   1.111 +    //protected String session_id_;WN0503
   1.112 +
   1.113 +    protected UserSettings user_settings_;//hold whole hashmap locally
   1.114 +
   1.115 +    /**
   1.116 +     * @param ME_path
   1.117 +     *            URL of the math engine to be used
   1.118 +     * @param user_path
   1.119 +     *            path(without URL) to UserSettings, UserModel
   1.120 +     * @param session_dialog
   1.121 +     * @param session_id
   1.122 +     *            which create the DialogGuide and Worksheet
   1.123 +     * @throws RemoteException
   1.124 +     */
   1.125 +    public DialogGuide(String ME_path, String user_path,
   1.126 +            SDialog session_dialog, String session_id) throws RemoteException {
   1.127 +        super();
   1.128 +        this.rmiBind();
   1.129 +        datachange_listeners_ = new Vector();
   1.130 +        MathEngine.init(ME_path);
   1.131 +        math_engine_ = MathEngine.getMathEngine();
   1.132 +        phase_ = DIALOGPHASE_IDLE;
   1.133 +
   1.134 +        User user = null;
   1.135 +        try {
   1.136 +            user = session_dialog.getUser(session_id);
   1.137 +        } catch (RemoteException e1) {
   1.138 +            e1.printStackTrace();
   1.139 +        }
   1.140 +        user_settings_ = new UserSettings(user_path, user.getUsername());
   1.141      }
   1.142 -    //System.out.println(tacticStringCap.toString());
   1.143 -    t.setName(tacticStringCap.toString());
   1.144 -    return t;
   1.145 -  }
   1.146 -  
   1.147 -  public void setNextTactic(Tactic tactic) {
   1.148 -    calcTree.setNextTactic(tactic);
   1.149 -  }
   1.150 -  
   1.151 -  private void rmiBind(){
   1.152 -    if(System.getSecurityManager() == null) {
   1.153 -      System.setSecurityManager(new RMISecurityManager());
   1.154 +
   1.155 +    /**
   1.156 +     * start a calculation
   1.157 +     */
   1.158 +    public CalcTree startCalculation(int user_id, Formalization f,
   1.159 +            int start_from/* WN050421 , int requested_calchead_view */) {
   1.160 +
   1.161 +        phase_ = DIALOGPHASE_SOLVE;
   1.162 +        calc_tree_ = math_engine_.startCalculation(f);
   1.163 +        calc_tree_.addDataChangeListener(this);
   1.164 +        return calc_tree_;
   1.165      }
   1.166 -    
   1.167 -    try{
   1.168 -      LocateRegistry.createRegistry(1099);
   1.169 -    }catch(java.rmi.RemoteException exc2){
   1.170 -      System.err.println("can not create registry: " + exc2.getMessage());
   1.171 +
   1.172 +    /**
   1.173 +     * at the beginning of a calculation as well as of a subproblem;
   1.174 +     * 
   1.175 +     * @return CalcHead eg. for providing CalcHead#VIEWSTYLE_*
   1.176 +     * 
   1.177 +     * @see isac.wsdialog.DGuide#startSpecifying()
   1.178 +     */
   1.179 +    public CalcHead startSpecifying() {
   1.180 +        ICalcIterator it = null;
   1.181 +        CalcHead calc_head = null;
   1.182 +        int calchead_view;
   1.183 +        try {
   1.184 +            it = calc_tree_.iterator();
   1.185 +            //			WN0504DI it = this.iterator();//WN050421 NEW...
   1.186 +            it.moveRoot();
   1.187 +            //WN0504DI ...error DialogGuide_Stub.startSpecifying(Unknown
   1.188 +            //WN0504DI Source) with ...NEW
   1.189 +            calc_head = (CalcHead) it.getFormula();
   1.190 +        } catch (RemoteException e) {
   1.191 +            e.printStackTrace();
   1.192 +        }
   1.193 +
   1.194 +        //AK set viewstyle according to user settings
   1.195 +        switch (user_settings_.getValue(IUserSettings.KEY1_START_SPECIFY)) {
   1.196 +        //________________________________________________________
   1.197 +        case IUserSettings.VAL1_SKIP_SPECIFY_TO_START_SOLVE:
   1.198 +            calc_tree_.completeCalcHead();
   1.199 +            calchead_view = CalcHead.VIEWSTYLE_SINGLELINE;
   1.200 +            phase_ = DIALOGPHASE_SOLVE;
   1.201 +            break;
   1.202 +        //________________________________________________________
   1.203 +        case IUserSettings.VAL1_POP_CALCHEAD_WITH_DESCRIPTIONS:
   1.204 +            calc_tree_.autoCalculate(IToCalc.SCOPE_CALCULATION, 1);
   1.205 +            //...applies the Tactic Model_Problem which generates descriptions
   1.206 +            calchead_view = CalcHead.VIEWSTYLE_FULL;
   1.207 +            phase_ = DIALOGPHASE_SPECIFY;
   1.208 +            break;
   1.209 +        //________________________________________________________
   1.210 +        default:
   1.211 +            //=case IUserSettings.VAL1_SKIP_SPECIFY_TO_START_SOLVE:
   1.212 +            calc_tree_.completeCalcHead();
   1.213 +            calchead_view = CalcHead.VIEWSTYLE_SINGLELINE;
   1.214 +            phase_ = DIALOGPHASE_SOLVE;
   1.215 +            break;
   1.216 +        }
   1.217 +        calc_head.setViewStyle(calchead_view);
   1.218 +        return calc_head;
   1.219      }
   1.220 -    
   1.221 -    String name = "//localhost/isac-DialogGuide";
   1.222 -    try {
   1.223 -      System.out.println("try to bind as " + name);
   1.224 -      Naming.rebind(name, this);
   1.225 -      System.out.println("Object Manager bound to " + name);
   1.226 -    } catch (java.rmi.ConnectException e) {     
   1.227 -    System.err.println("failed to contact as " + name +
   1.228 -                       " (creating RMI-Server on localhost: 1099)");
   1.229 -    } catch (RemoteException e) {
   1.230 -      // TODO Auto-generated catch block
   1.231 -      e.printStackTrace();
   1.232 -    } catch (MalformedURLException e) {
   1.233 -      // TODO Auto-generated catch block
   1.234 -      e.printStackTrace();
   1.235 +
   1.236 +    //	/**
   1.237 +    //	 * @deprecated Use {@link #notifyUserAction(IUserAction)}instead
   1.238 +    //	 */
   1.239 +    //	public void modifyCalcHead(CalcHead calc_head) {
   1.240 +    //		// MathEngine.getMathEngine().modifyCalcHead(calc_head);
   1.241 +    //		calc_tree_.modifyCalcHead(calc_head);
   1.242 +    //	}
   1.243 +
   1.244 +    /**
   1.245 +     * dismiss the CalcHeadPanel and start DGuide#DIALOGPHASE_SOLVE
   1.246 +     * 
   1.247 +     * @see isac.util.interfaces.IToCalc#startSolving()
   1.248 +     */
   1.249 +    public void startSolving() throws Exception {
   1.250 +        calc_tree_.startSolving();
   1.251 +
   1.252      }
   1.253 -  }
   1.254 -  
   1.255 -  public static void main(String[] args) {
   1.256 -    try {
   1.257 -      new DialogGuide();
   1.258 -    } catch (RemoteException e) {
   1.259 -      // TODO Auto-generated catch block
   1.260 -      e.printStackTrace();
   1.261 +
   1.262 +    /**
   1.263 +     * accept the changes in a calculation reported by the bridge ..............
   1.264 +     * TODO handle these changes according to UserSettings and UserModel
   1.265 +     * 
   1.266 +     * ... and pass them to the Worksheet
   1.267 +     * 
   1.268 +     * @see isac.wsdialog.IToUser#calcChanged(isac.wsdialog.CalcChangedEvent)
   1.269 +     */
   1.270 +    public void calcChanged(CalcChangedEvent event) throws RemoteException {
   1.271 +        logger_.fatal(" WS<-. . : calcChanged (unc="
   1.272 +                + event.getLastUnchangedFormula().toSMLString() + ", del="
   1.273 +                + event.getLastDeletedFormula().toSMLString() + ", gen="
   1.274 +                + event.getLastGeneratedFormula().toSMLString());
   1.275 +        try {
   1.276 +            for (int i = 0; i < datachange_listeners_.size(); i++) {
   1.277 +                ((IToUser) datachange_listeners_.elementAt(i))
   1.278 +                        .calcChanged(event);//WN050513GOON
   1.279 +                // .calcChanged(event.createDialogIterators(this));
   1.280 +            }
   1.281 +        } catch (Exception e) {
   1.282 +            e.printStackTrace();
   1.283 +        }
   1.284      }
   1.285 -  }
   1.286 -}
   1.287 +
   1.288 +    /**
   1.289 +     * @see isac.wsdialog.DGuide#iterator(CalcIterator, DGuide)
   1.290 +     * @see isac.util.interfaces.IToCalc#iterator()
   1.291 +     */
   1.292 +    public ICalcIterator iterator(CalcIterator it, DGuide dg) {
   1.293 +        //WN050512...was before:
   1.294 +        //public ICalcIterator iterator() {
   1.295 +        //		try {
   1.296 +        //			return new DialogIterator((CalcIterator) calc_tree_.iterator(),
   1.297 +        //					this);
   1.298 +        //		} catch (Exception e) {
   1.299 +        //			e.printStackTrace();
   1.300 +        //		}
   1.301 +        //		return null;
   1.302 +        try {
   1.303 +            return new DialogIterator(it, dg);
   1.304 +        } catch (RemoteException e) {
   1.305 +            e.printStackTrace();
   1.306 +        }
   1.307 +        return null;
   1.308 +    }
   1.309 +
   1.310 +    /**
   1.311 +     * @see isac.wsdialog.IToCalc#addListener(isac.wsdialog.IToUser)
   1.312 +     */
   1.313 +    public boolean addDataChangeListener(IToUser listener)
   1.314 +            throws RemoteException {
   1.315 +        if (datachange_listeners_.contains(listener)) {
   1.316 +            return false;
   1.317 +        } else {
   1.318 +            datachange_listeners_.add(listener);
   1.319 +        }
   1.320 +        return true;
   1.321 +    }
   1.322 +
   1.323 +    public boolean registerUIControlListener(IToWorksheet listener)
   1.324 +            throws RemoteException {
   1.325 +        //WN0504 ???
   1.326 +        //		if (ui_control_listener_ != null) {
   1.327 +        //			ui_control_listener_.doUIAction(new UserAction(UI_DO_DETACH));
   1.328 +        //		}
   1.329 +        ui_control_listener_ = listener;
   1.330 +        return true;
   1.331 +    }
   1.332 +
   1.333 +    //	/**
   1.334 +    //	 * @see isac.wsdialog.IToCalc#fetchProposedTactic
   1.335 +    //	 * @deprecated Use {@link #notifyUserAction(IUserAction)}instead
   1.336 +    //	 */
   1.337 +    //	public Tactic fetchProposedTactic() {
   1.338 +    //		return calc_tree_.fetchProposedTactic();
   1.339 +    //	}
   1.340 +    //
   1.341 +    //
   1.342 +    //	/**
   1.343 +    //	 * @deprecated Use {@link #notifyUserAction(IUserAction)}instead
   1.344 +    //	 */
   1.345 +    //	public int setNextTactic(Tactic tactic) {
   1.346 +    //		return calc_tree_.setNextTactic(tactic);
   1.347 +    //	}
   1.348 +    //
   1.349 +    //	/**
   1.350 +    //	 * @deprecated Use {@link #notifyUserAction(IUserAction)}instead
   1.351 +    //	 */
   1.352 +    //	public int autoCalculate(int scope, int nSteps) {
   1.353 +    //		return calc_tree_.autoCalculate(scope, nSteps);
   1.354 +    //	}
   1.355 +    //
   1.356 +    //	/**
   1.357 +    //	 * @deprecated Use {@link #notifyUserAction(IUserAction)}instead
   1.358 +    //	 */
   1.359 +    //	public void tryMatch(CalcHead ch, CalcHeadCompoundID problemID)
   1.360 +    //			throws NotInSpecificationPhaseException {
   1.361 +    //
   1.362 +    //		// MathEngine.getMathEngine().tryMatch(ch, problemID);
   1.363 +    //		math_engine_.tryMatch(ch, problemID);
   1.364 +    //	}
   1.365 +    //
   1.366 +    //	/**
   1.367 +    //	 * @deprecated Use {@link #notifyUserAction(IUserAction)}instead
   1.368 +    //	 */
   1.369 +    //	public void tryRefine(CalcHead ch, CalcHeadCompoundID problemID)
   1.370 +    //			throws NotInSpecificationPhaseException {
   1.371 +    //
   1.372 +    //		// MathEngine.getMathEngine().tryRefine(ch , problemID);
   1.373 +    //		math_engine_.tryRefine(ch, problemID);
   1.374 +    //	}
   1.375 +    //
   1.376 +    //	/**
   1.377 +    //	 * @deprecated Use {@link #notifyUserAction(IUserAction)}instead
   1.378 +    //	 */
   1.379 +    //	public ICalcIterator getActiveFormula() {
   1.380 +    //		return calc_tree_.getActiveFormula();
   1.381 +    //	}
   1.382 +    //
   1.383 +    //	/**
   1.384 +    //	 * @throws RemoteException
   1.385 +    //	 * @deprecated Use {@link #notifyUserAction(IUserAction)}instead
   1.386 +    //	 */
   1.387 +    //	public int replaceFormula(CalcFormula newFormula) throws RemoteException
   1.388 +    // {
   1.389 +    //		return calc_tree_.replaceFormula(newFormula);
   1.390 +    //	}
   1.391 +    //
   1.392 +    //	/**
   1.393 +    //	 * @throws RemoteException
   1.394 +    //	 * @deprecated Use {@link #notifyUserAction(IUserAction)}instead
   1.395 +    //	 */
   1.396 +    //	public int appendFormula(CalcFormula newFormula) throws RemoteException {
   1.397 +    //		return calc_tree_.appendFormula(newFormula);
   1.398 +    //	}
   1.399 +    //
   1.400 +    //	/**
   1.401 +    //	 * @deprecated Use {@link #notifyUserAction(IUserAction)}instead
   1.402 +    //	 */
   1.403 +    //	public void moveActiveFormula(ICalcIterator newActiveFormula) {
   1.404 +    //		calc_tree_.moveActiveFormula(newActiveFormula);
   1.405 +    //	}
   1.406 +    //
   1.407 +    /**
   1.408 +     * Notify the Dialog Guide about interaction from the User
   1.409 +     * 
   1.410 +     * @param action
   1.411 +     * @return true, if the action has been processed, false if the processing
   1.412 +     *         the action has been denied
   1.413 +     * @throws RemoteException
   1.414 +     *  
   1.415 +     */
   1.416 +    public boolean notifyUserAction(IUserAction action)
   1.417 +            throws DialogProtocolException, RemoteException {
   1.418 +        int request = action.getActionID();
   1.419 +        logger_.fatal(" WS->DG: notifyUserAction request= " + request);
   1.420 +
   1.421 +        // two userActions dont care about the dialogphase
   1.422 +        //WN050420 would be nicer, if DialogGuide would set the Buttons
   1.423 +        switch (request) {
   1.424 +        case (UI_CALCULATE_1):
   1.425 +            if (phase_ == DIALOGPHASE_SPECIFY)
   1.426 +                request = UI_SPECIFY_TO_SOLVE;//WN#####################
   1.427 +            else
   1.428 +                request = UI_SOLVE_CALCULATE_1;
   1.429 +            break;
   1.430 +        case (UI_CALCULATE_ALL):
   1.431 +            if (phase_ == DIALOGPHASE_SPECIFY)
   1.432 +                request = UI_SPECIFY_CALCULATE_ALL;
   1.433 +            else
   1.434 +                request = UI_SOLVE_CALCULATE_ALL;
   1.435 +        }
   1.436 +        // all other userActions belong to a certain dialogphase
   1.437 +
   1.438 +        switch (phase_) {
   1.439 +        case DIALOGPHASE_IDLE:
   1.440 +            throw new DialogProtocolException(request, phase_);
   1.441 +        case DIALOGPHASE_SPECIFY:
   1.442 +            if (request < UI_DUMMY_FIRST_SPECIFY
   1.443 +                    || request > UI_DUMMY_LAST_SPECIFY)
   1.444 +                throw new DialogProtocolException(request, phase_);
   1.445 +            break;
   1.446 +        case DIALOGPHASE_SOLVE:
   1.447 +            if (request < UI_DUMMY_FIRST_SOLVE || request > UI_DUMMY_LAST_SOLVE)
   1.448 +                throw new DialogProtocolException(request, phase_);
   1.449 +            break;
   1.450 +        }
   1.451 +
   1.452 +        //*********** handle IUserAction's **********************
   1.453 +        CalcHead calc_head = new CalcHead();//WN0502023?????????
   1.454 +        try {
   1.455 +            calc_head = (CalcHead) calc_tree_.iterator().getFormula();
   1.456 +        } catch (Exception e) {
   1.457 +            e.printStackTrace();
   1.458 +        }
   1.459 +        switch (request) {
   1.460 +        case UI_SPECIFY_TRY_MATCH:
   1.461 +            throw new DialogNotImplementedException(request, phase_);
   1.462 +        //			try {
   1.463 +        //				tryMatch(calc_head, ((UserActionOnCalcHeadCompoundID) action)
   1.464 +        //						.getObjectID());
   1.465 +        //			} catch (NotInSpecificationPhaseException e) {
   1.466 +        //				throw new DialogMathException(request, phase_, e);
   1.467 +        //			}
   1.468 +        //			break;
   1.469 +
   1.470 +        case UI_SPECIFY_TRY_REFINE:
   1.471 +            throw new DialogNotImplementedException(request, phase_);
   1.472 +        //			try {
   1.473 +        //				tryRefine(calc_head, ((UserActionOnCalcHeadCompoundID) action)
   1.474 +        //						.getObjectID());
   1.475 +        //			} catch (NotInSpecificationPhaseException e) {
   1.476 +        //				throw new DialogMathException(request, phase_, e);
   1.477 +        //			}
   1.478 +        //			break;
   1.479 +
   1.480 +        case UI_SPECIFY_CHANGE_VIEW:
   1.481 +            calc_head.setViewStyle(((UserActionOnInt) action).getInt());
   1.482 +            break;
   1.483 +
   1.484 +        case UI_SPECIFY_COMPLETE_CALCHEAD:
   1.485 +            calc_tree_.completeCalcHead();
   1.486 +            // old-style filling the fields of the calc-head by setting
   1.487 +            // the HELP_ME flag
   1.488 +            // calc_head_.setCalcHeadStatus(CalcHead.MODEL_ITEM_HELP_ME);
   1.489 +            // modifyCalcHead(calc_head_);
   1.490 +            break;
   1.491 +        case UI_SPECIFY_COMPLETE_METHOD:
   1.492 +        case UI_SPECIFY_COMPLETE_THEORY:
   1.493 +        case UI_SPECIFY_COMPLETE_PROBLEM:
   1.494 +        case UI_SPECIFY_COMPLETE_GIVEN:
   1.495 +        case UI_SPECIFY_COMPLETE_FIND:
   1.496 +        case UI_SPECIFY_COMPLETE_RELATE:
   1.497 +            throw new DialogNotImplementedException(request, phase_);
   1.498 +
   1.499 +        case UI_SPECIFY_CHECK_CALCHEAD:
   1.500 +            calc_tree_.modifyCalcHead(calc_head);
   1.501 +            break;
   1.502 +
   1.503 +        // was: startCalculation() WN050428 ? really ?
   1.504 +        case UI_SPECIFY_TO_SOLVE:
   1.505 +        case UI_SPECIFY_CALCULATE_ALL:
   1.506 +            //if (user_settings_.getValue(""))
   1.507 +            if (true)
   1.508 +                calc_tree_.completeCalcHead();
   1.509 +            else
   1.510 +                calc_tree_.modifyCalcHead(calc_head);
   1.511 +
   1.512 +            if (calc_head.getCalcHeadStatus() != CalcHead.MODEL_ITEM_CORRECT)
   1.513 +                return false;
   1.514 +
   1.515 +            try {
   1.516 +                calc_tree_.startSolving();
   1.517 +            } catch (Exception e) {
   1.518 +                // TODO Auto-generated catch block
   1.519 +                e.printStackTrace();
   1.520 +            }
   1.521 +            // calc_tree_ = MathEngine.getMathEngine().startSolving(calcHead);
   1.522 +            // FIXME: AK020224: do not register with the calc_tree_ if finished
   1.523 +            // specifying a SUBPROBLEM
   1.524 +            //calc_tree_.addDataChangeListener(this);//WN050420-->startCalculation
   1.525 +
   1.526 +            phase_ = DIALOGPHASE_SOLVE;//FIXXXME.WN050428
   1.527 +        // fall through to calculate
   1.528 +
   1.529 +        case UI_SOLVE_CALCULATE_1:
   1.530 +        //WN050420 why not at (*) here ?
   1.531 +        case UI_SOLVE_CALCULATE_ALL:
   1.532 +            switch (request) {
   1.533 +            case UI_SPECIFY_CALCULATE_ALL:
   1.534 +            case UI_SOLVE_CALCULATE_ALL:
   1.535 +                calc_tree_.autoCalculate(IToCalc.SCOPE_CALCULATION, 0);
   1.536 +                break;
   1.537 +            case UI_SPECIFY_TO_SOLVE://WN050420 ???
   1.538 +            // break;
   1.539 +            default:
   1.540 +                calc_tree_.autoCalculate(IToCalc.SCOPE_CALCULATION, 1);
   1.541 +                //why not at (*) above ?
   1.542 +                break;
   1.543 +            }
   1.544 +            break;
   1.545 +
   1.546 +        case UI_SOLVE_CALCULATE_SUBPROBLEM:
   1.547 +            calc_tree_.autoCalculate(IToCalc.SCOPE_SUBPROBLEM, 0);
   1.548 +            break;
   1.549 +
   1.550 +        case UI_SOLVE_EDIT_ACTIVE_FORMULA:
   1.551 +            ui_control_listener_.doUIAction(new UserAction(UI_DO_EDIT_FORMULA));
   1.552 +            break;
   1.553 +
   1.554 +        case UI_SOLVE_EDIT_ACTIVE_FORMULA_COMPLETE:
   1.555 +            CalcFormula formula = (CalcFormula) ((UserActionOnCalcElement) action)
   1.556 +                    .getCalcElement();
   1.557 +            // if the position is null, the formula did not exist, so we try to
   1.558 +            // append a new formula
   1.559 +            if (formula.getPosition() == null) {
   1.560 +                calc_tree_.appendFormula(formula);
   1.561 +            } else {
   1.562 +                calc_tree_.replaceFormula(formula);
   1.563 +            }
   1.564 +            break;
   1.565 +
   1.566 +        case UI_SOLVE_APPEND_USER_FORMULA:
   1.567 +            // appendFormula((Formula) ((UserActionOnCalcElement)
   1.568 +            // action).getCalcElement());
   1.569 +            ui_control_listener_
   1.570 +                    .doUIAction(new UserAction(UI_DO_APPEND_FORMULA));
   1.571 +            break;
   1.572 +
   1.573 +        case UI_SOLVE_MOVE_ACTIVE_FORMULA:
   1.574 +            calc_tree_.moveActiveFormula(((UserActionOnIterator) action)
   1.575 +                    .getPosition());
   1.576 +            break;
   1.577 +
   1.578 +        case UI_SOLVE_GET_PROPOSED_TACTIC:
   1.579 +            throw new DialogNotImplementedException(request, phase_);
   1.580 +
   1.581 +        case UI_SOLVE_GET_APPLICABLE_TACTICS:
   1.582 +            throw new DialogNotImplementedException(request, phase_);
   1.583 +
   1.584 +        case UI_SOLVE_SET_NEXT_TACTIC:
   1.585 +            calc_tree_
   1.586 +                    .setNextTactic((Tactic) ((UserActionOnCalcElement) action)
   1.587 +                            .getCalcElement());
   1.588 +            //WN041126 extracted from isac.bridge.CalcTree#setNextTactic @@@
   1.589 +            //autoCalculate(SCOPE_CALCULATION, 1);
   1.590 +            break;
   1.591 +
   1.592 +        case UI_SOLVE_HELP_ENTERING_FORMULA:
   1.593 +            throw new DialogNotImplementedException(request, phase_);
   1.594 +
   1.595 +        case UI_SOLVE_SHOW_ASSUMPTIONS:
   1.596 +            throw new DialogNotImplementedException(request, phase_);
   1.597 +
   1.598 +        case UI_SOLVE_SHOW_DETAILS:
   1.599 +            throw new DialogNotImplementedException(request, phase_);
   1.600 +
   1.601 +        default:
   1.602 +            throw new DialogUnknownActionException(request, phase_);
   1.603 +        }
   1.604 +        return true;
   1.605 +    }
   1.606 +
   1.607 +    private void rmiBind() {
   1.608 +        if (System.getSecurityManager() == null) {
   1.609 +            System.setSecurityManager(new RMISecurityManager());
   1.610 +        }
   1.611 +
   1.612 +        try {
   1.613 +            LocateRegistry.createRegistry(1099);
   1.614 +        } catch (java.rmi.RemoteException exc2) {
   1.615 +            System.err.println("can not create registry: " + exc2.getMessage());
   1.616 +        }
   1.617 +
   1.618 +        String name = "//localhost/isac-DialogGuide";
   1.619 +        try {
   1.620 +            System.out.println("try to bind as " + name);
   1.621 +            Naming.rebind(name, this);
   1.622 +            System.out.println("Dialog Guide bound to " + name);
   1.623 +            //WN040906 was Object Manager ...
   1.624 +        } catch (java.rmi.ConnectException e) {
   1.625 +            System.err.println("failed to contact as " + name
   1.626 +                    + " (creating RMI-Server on localhost: 1099)");
   1.627 +        } catch (RemoteException e) {
   1.628 +            // TODO Auto-generated catch block
   1.629 +            e.printStackTrace();
   1.630 +        } catch (MalformedURLException e) {
   1.631 +            // TODO Auto-generated catch block
   1.632 +            e.printStackTrace();
   1.633 +        }
   1.634 +    }
   1.635 +
   1.636 +    //	public static void main(String[] args) {
   1.637 +    //		try {
   1.638 +    //			new DialogGuide(args[0]);
   1.639 +    //
   1.640 +    //		} catch (RemoteException e) {
   1.641 +    //			e.printStackTrace();
   1.642 +    //		}
   1.643 +    //	}
   1.644 +
   1.645 +    //	/**
   1.646 +    //	 * @see
   1.647 +    // isac.util.interfaces.IToCalc#completeCalcHead(isac.util.formulae.CalcHead)
   1.648 +    //	 * @deprecated Use {@link #notifyUserAction(IUserAction)}instead
   1.649 +    //	 */
   1.650 +    //	public void completeCalcHead(CalcHead calcHead) {
   1.651 +    //		// TODO Auto-generated method stub
   1.652 +    //
   1.653 +    //	}
   1.654 +    //
   1.655 +    //	/**
   1.656 +    //	 * @see
   1.657 +    // isac.util.interfaces.IToCalc#completeCalcHead(isac.util.formulae.CalcHead,
   1.658 +    //	 * int)
   1.659 +    //	 * @deprecated Use {@link #notifyUserAction(IUserAction)}instead
   1.660 +    //	 */
   1.661 +    //	public void completeCalcHead(CalcHead calcHead, int completeItem) {
   1.662 +    //		// TODO Auto-generated method stub
   1.663 +    //
   1.664 +    //	}
   1.665 +    //
   1.666 +    //	/**
   1.667 +    //	 * (non-Javadoc)
   1.668 +    //	 *
   1.669 +    //	 * @see isac.util.interfaces.IToCalc#completeCalcHead()
   1.670 +    //	 * @deprecated Use {@link #notifyUserAction(IUserAction)}instead
   1.671 +    //	 */
   1.672 +    //	public void completeCalcHead() throws RemoteException {
   1.673 +    //		// TODO Auto-generated method stub WN050223
   1.674 +    //
   1.675 +    //	}
   1.676 +    //
   1.677 +    //	/**
   1.678 +    //	 * @deprecated Use {@link #notifyUserAction(IUserAction)}instead
   1.679 +    //	 *
   1.680 +    //	 * @see
   1.681 +    // isac.util.interfaces.IToCalc#intermediateSteps(isac.util.interfaces.ICalcIterator)
   1.682 +    //	 */
   1.683 +    //	public int intermediateSteps(ICalcIterator i) throws RemoteException {
   1.684 +    //		// TODO Auto-generated method stub
   1.685 +    //		return 0;
   1.686 +    //	}
   1.687 +    //
   1.688 +    //	/**
   1.689 +    //	 * @see
   1.690 +    // isac.util.interfaces.IToCalc#getElementsFromTo(isac.util.interfaces.ICalcIterator,
   1.691 +    //	 * isac.util.interfaces.ICalcIterator, java.lang.Integer, boolean)
   1.692 +    //	 * @deprecated Use {@link #notifyUserAction(IUserAction)}instead
   1.693 +    //	 */
   1.694 +    //	public Vector getElementsFromTo(ICalcIterator iterator_from,
   1.695 +    //			ICalcIterator iterator_to, Integer level,
   1.696 +    //			boolean result_includes_tactics) throws RemoteException {
   1.697 +    //		// TODO Auto-generated method stub
   1.698 +    //		return null;
   1.699 +    //	}
   1.700 +
   1.701 +}
   1.702 \ No newline at end of file