akremp@861
|
1 |
package isac.wsdialog;
|
akremp@861
|
2 |
|
wneuper@3922
|
3 |
import isac.bridge.*;
|
wneuper@3922
|
4 |
import isac.session.SDialog;
|
akremp@958
|
5 |
import isac.util.*;
|
wneuper@3922
|
6 |
import isac.util.formulae.*;
|
wneuper@3922
|
7 |
import isac.util.interfaces.*;
|
wneuper@3922
|
8 |
import isac.util.tactics.*;
|
wneuper@3922
|
9 |
import isac.util.users.IUserSettings;
|
wneuper@3922
|
10 |
import isac.util.users.User;
|
wneuper@3922
|
11 |
import isac.util.users.UserSettings;
|
mhochrei@939
|
12 |
|
akremp@945
|
13 |
import java.io.Serializable;
|
mhochrei@954
|
14 |
import java.net.MalformedURLException;
|
mhochrei@954
|
15 |
import java.rmi.*;
|
mhochrei@954
|
16 |
import java.rmi.registry.LocateRegistry;
|
mhochrei@952
|
17 |
import java.rmi.server.UnicastRemoteObject;
|
wneuper@3922
|
18 |
import java.util.Vector;
|
wneuper@3922
|
19 |
|
wneuper@3922
|
20 |
import org.apache.log4j.Logger;
|
akremp@867
|
21 |
|
akremp@861
|
22 |
/**
|
wneuper@3922
|
23 |
* The DialogGuide moderates the communication between two instances working on
|
wneuper@3922
|
24 |
* the same CalcTree object. One of these instances is the user, the other a
|
wneuper@3922
|
25 |
* math engine. Most probably, the user's GUI, the DialogGuide and the math
|
wneuper@3922
|
26 |
* engine reside on different machines and communicate with each other by means
|
wneuper@3922
|
27 |
* of RMI.
|
wneuper@3922
|
28 |
*
|
akremp@945
|
29 |
* @author Alan Krempler
|
akremp@867
|
30 |
*/
|
wneuper@3922
|
31 |
public class DialogGuide extends UnicastRemoteObject implements DGuide,
|
wneuper@3922
|
32 |
IToUser, Serializable {
|
akremp@861
|
33 |
|
wneuper@3922
|
34 |
static Logger logger_ = Logger.getLogger(BridgeRMI.class.getName());
|
akremp@861
|
35 |
|
wneuper@3922
|
36 |
protected MathEngine math_engine_;
|
mhochrei@952
|
37 |
|
wneuper@3922
|
38 |
//the calc_tree_ is also known by the DialogIterators -- remove AK?LK?
|
wneuper@3922
|
39 |
//WN0505 only needed by getElementsFromTo !! move method to Iterator?
|
wneuper@3922
|
40 |
protected CalcTree calc_tree_;
|
akremp@861
|
41 |
|
wneuper@3922
|
42 |
//protected CalcHead calc_head_;
|
akremp@861
|
43 |
|
wneuper@3922
|
44 |
//protected CalcHead calc_head_sub_;
|
akremp@899
|
45 |
|
wneuper@3922
|
46 |
protected int phase_;
|
akremp@899
|
47 |
|
wneuper@3922
|
48 |
private Vector datachange_listeners_;
|
akremp@899
|
49 |
|
wneuper@3922
|
50 |
private IToWorksheet ui_control_listener_;
|
wneuper@3922
|
51 |
|
wneuper@3922
|
52 |
//protected String session_id_;WN0503
|
wneuper@3922
|
53 |
|
wneuper@3922
|
54 |
protected UserSettings user_settings_;//hold whole hashmap locally
|
wneuper@3922
|
55 |
|
wneuper@3922
|
56 |
/**
|
wneuper@3922
|
57 |
* @param ME_path
|
wneuper@3922
|
58 |
* URL of the math engine to be used
|
wneuper@3922
|
59 |
* @param user_path
|
wneuper@3922
|
60 |
* path(without URL) to UserSettings, UserModel
|
wneuper@3922
|
61 |
* @param session_dialog
|
wneuper@3922
|
62 |
* @param session_id
|
wneuper@3922
|
63 |
* which create the DialogGuide and Worksheet
|
wneuper@3922
|
64 |
* @throws RemoteException
|
wneuper@3922
|
65 |
*/
|
wneuper@3922
|
66 |
public DialogGuide(String ME_path, String user_path,
|
wneuper@3922
|
67 |
SDialog session_dialog, String session_id) throws RemoteException {
|
wneuper@3922
|
68 |
super();
|
wneuper@3922
|
69 |
this.rmiBind();
|
wneuper@3922
|
70 |
datachange_listeners_ = new Vector();
|
wneuper@3922
|
71 |
MathEngine.init(ME_path);
|
wneuper@3922
|
72 |
math_engine_ = MathEngine.getMathEngine();
|
wneuper@3922
|
73 |
phase_ = DIALOGPHASE_IDLE;
|
wneuper@3922
|
74 |
|
wneuper@3922
|
75 |
User user = null;
|
wneuper@3922
|
76 |
try {
|
wneuper@3922
|
77 |
user = session_dialog.getUser(session_id);
|
wneuper@3922
|
78 |
} catch (RemoteException e1) {
|
wneuper@3922
|
79 |
e1.printStackTrace();
|
wneuper@3922
|
80 |
}
|
wneuper@3922
|
81 |
user_settings_ = new UserSettings(user_path, user.getUsername());
|
mhochrei@939
|
82 |
}
|
wneuper@3922
|
83 |
|
wneuper@3922
|
84 |
/**
|
wneuper@3922
|
85 |
* start a calculation
|
wneuper@3922
|
86 |
*/
|
wneuper@3922
|
87 |
public CalcTree startCalculation(int user_id, Formalization f,
|
wneuper@3922
|
88 |
int start_from/* WN050421 , int requested_calchead_view */) {
|
wneuper@3922
|
89 |
|
wneuper@3922
|
90 |
phase_ = DIALOGPHASE_SOLVE;
|
wneuper@3922
|
91 |
calc_tree_ = math_engine_.startCalculation(f);
|
wneuper@3922
|
92 |
calc_tree_.addDataChangeListener(this);
|
wneuper@3922
|
93 |
return calc_tree_;
|
mhochrei@954
|
94 |
}
|
wneuper@3922
|
95 |
|
wneuper@3922
|
96 |
/**
|
wneuper@3922
|
97 |
* at the beginning of a calculation as well as of a subproblem;
|
wneuper@3922
|
98 |
*
|
wneuper@3922
|
99 |
* @return CalcHead eg. for providing CalcHead#VIEWSTYLE_*
|
wneuper@3922
|
100 |
*
|
wneuper@3922
|
101 |
* @see isac.wsdialog.DGuide#startSpecifying()
|
wneuper@3922
|
102 |
*/
|
wneuper@3922
|
103 |
public CalcHead startSpecifying() {
|
wneuper@3922
|
104 |
ICalcIterator it = null;
|
wneuper@3922
|
105 |
CalcHead calc_head = null;
|
wneuper@3922
|
106 |
int calchead_view;
|
wneuper@3922
|
107 |
try {
|
wneuper@3922
|
108 |
it = calc_tree_.iterator();
|
wneuper@3922
|
109 |
// WN0504DI it = this.iterator();//WN050421 NEW...
|
wneuper@3922
|
110 |
it.moveRoot();
|
wneuper@3922
|
111 |
//WN0504DI ...error DialogGuide_Stub.startSpecifying(Unknown
|
wneuper@3922
|
112 |
//WN0504DI Source) with ...NEW
|
wneuper@3922
|
113 |
calc_head = (CalcHead) it.getFormula();
|
wneuper@3922
|
114 |
} catch (RemoteException e) {
|
wneuper@3922
|
115 |
e.printStackTrace();
|
wneuper@3922
|
116 |
}
|
wneuper@3922
|
117 |
|
wneuper@3922
|
118 |
//AK set viewstyle according to user settings
|
wneuper@3922
|
119 |
switch (user_settings_.getValue(IUserSettings.KEY1_START_SPECIFY)) {
|
wneuper@3922
|
120 |
//________________________________________________________
|
wneuper@3922
|
121 |
case IUserSettings.VAL1_SKIP_SPECIFY_TO_START_SOLVE:
|
wneuper@3922
|
122 |
calc_tree_.completeCalcHead();
|
wneuper@3922
|
123 |
calchead_view = CalcHead.VIEWSTYLE_SINGLELINE;
|
wneuper@3922
|
124 |
phase_ = DIALOGPHASE_SOLVE;
|
wneuper@3922
|
125 |
break;
|
wneuper@3922
|
126 |
//________________________________________________________
|
wneuper@3922
|
127 |
case IUserSettings.VAL1_POP_CALCHEAD_WITH_DESCRIPTIONS:
|
wneuper@3922
|
128 |
calc_tree_.autoCalculate(IToCalc.SCOPE_CALCULATION, 1);
|
wneuper@3922
|
129 |
//...applies the Tactic Model_Problem which generates descriptions
|
wneuper@3922
|
130 |
calchead_view = CalcHead.VIEWSTYLE_FULL;
|
wneuper@3922
|
131 |
phase_ = DIALOGPHASE_SPECIFY;
|
wneuper@3922
|
132 |
break;
|
wneuper@3922
|
133 |
//________________________________________________________
|
wneuper@3922
|
134 |
default:
|
wneuper@3922
|
135 |
//=case IUserSettings.VAL1_SKIP_SPECIFY_TO_START_SOLVE:
|
wneuper@3922
|
136 |
calc_tree_.completeCalcHead();
|
wneuper@3922
|
137 |
calchead_view = CalcHead.VIEWSTYLE_SINGLELINE;
|
wneuper@3922
|
138 |
phase_ = DIALOGPHASE_SOLVE;
|
wneuper@3922
|
139 |
break;
|
wneuper@3922
|
140 |
}
|
wneuper@3922
|
141 |
calc_head.setViewStyle(calchead_view);
|
wneuper@3922
|
142 |
return calc_head;
|
mhochrei@954
|
143 |
}
|
wneuper@3922
|
144 |
|
wneuper@3922
|
145 |
// /**
|
wneuper@3922
|
146 |
// * @deprecated Use {@link #notifyUserAction(IUserAction)}instead
|
wneuper@3922
|
147 |
// */
|
wneuper@3922
|
148 |
// public void modifyCalcHead(CalcHead calc_head) {
|
wneuper@3922
|
149 |
// // MathEngine.getMathEngine().modifyCalcHead(calc_head);
|
wneuper@3922
|
150 |
// calc_tree_.modifyCalcHead(calc_head);
|
wneuper@3922
|
151 |
// }
|
wneuper@3922
|
152 |
|
wneuper@3922
|
153 |
/**
|
wneuper@3922
|
154 |
* dismiss the CalcHeadPanel and start DGuide#DIALOGPHASE_SOLVE
|
wneuper@3922
|
155 |
*
|
wneuper@3922
|
156 |
* @see isac.util.interfaces.IToCalc#startSolving()
|
wneuper@3922
|
157 |
*/
|
wneuper@3922
|
158 |
public void startSolving() throws Exception {
|
wneuper@3922
|
159 |
calc_tree_.startSolving();
|
wneuper@3922
|
160 |
|
mhochrei@954
|
161 |
}
|
wneuper@3922
|
162 |
|
wneuper@3922
|
163 |
/**
|
wneuper@3922
|
164 |
* accept the changes in a calculation reported by the bridge ..............
|
wneuper@3922
|
165 |
* TODO handle these changes according to UserSettings and UserModel
|
wneuper@3922
|
166 |
*
|
wneuper@3922
|
167 |
* ... and pass them to the Worksheet
|
wneuper@3922
|
168 |
*
|
wneuper@3922
|
169 |
* @see isac.wsdialog.IToUser#calcChanged(isac.wsdialog.CalcChangedEvent)
|
wneuper@3922
|
170 |
*/
|
wneuper@3922
|
171 |
public void calcChanged(CalcChangedEvent event) throws RemoteException {
|
wneuper@3922
|
172 |
logger_.fatal(" WS<-. . : calcChanged (unc="
|
wneuper@3922
|
173 |
+ event.getLastUnchangedFormula().toSMLString() + ", del="
|
wneuper@3922
|
174 |
+ event.getLastDeletedFormula().toSMLString() + ", gen="
|
wneuper@3922
|
175 |
+ event.getLastGeneratedFormula().toSMLString());
|
wneuper@3922
|
176 |
try {
|
wneuper@3922
|
177 |
for (int i = 0; i < datachange_listeners_.size(); i++) {
|
wneuper@3922
|
178 |
((IToUser) datachange_listeners_.elementAt(i))
|
wneuper@3922
|
179 |
.calcChanged(event);//WN050513GOON
|
wneuper@3922
|
180 |
// .calcChanged(event.createDialogIterators(this));
|
wneuper@3922
|
181 |
}
|
wneuper@3922
|
182 |
} catch (Exception e) {
|
wneuper@3922
|
183 |
e.printStackTrace();
|
wneuper@3922
|
184 |
}
|
mhochrei@954
|
185 |
}
|
wneuper@3922
|
186 |
|
wneuper@3922
|
187 |
/**
|
wneuper@3922
|
188 |
* @see isac.wsdialog.DGuide#iterator(CalcIterator, DGuide)
|
wneuper@3922
|
189 |
* @see isac.util.interfaces.IToCalc#iterator()
|
wneuper@3922
|
190 |
*/
|
wneuper@3922
|
191 |
public ICalcIterator iterator(CalcIterator it, DGuide dg) {
|
wneuper@3922
|
192 |
//WN050512...was before:
|
wneuper@3922
|
193 |
//public ICalcIterator iterator() {
|
wneuper@3922
|
194 |
// try {
|
wneuper@3922
|
195 |
// return new DialogIterator((CalcIterator) calc_tree_.iterator(),
|
wneuper@3922
|
196 |
// this);
|
wneuper@3922
|
197 |
// } catch (Exception e) {
|
wneuper@3922
|
198 |
// e.printStackTrace();
|
wneuper@3922
|
199 |
// }
|
wneuper@3922
|
200 |
// return null;
|
wneuper@3922
|
201 |
try {
|
wneuper@3922
|
202 |
return new DialogIterator(it, dg);
|
wneuper@3922
|
203 |
} catch (RemoteException e) {
|
wneuper@3922
|
204 |
e.printStackTrace();
|
wneuper@3922
|
205 |
}
|
wneuper@3922
|
206 |
return null;
|
wneuper@3922
|
207 |
}
|
wneuper@3922
|
208 |
|
wneuper@3922
|
209 |
/**
|
wneuper@3922
|
210 |
* @see isac.wsdialog.IToCalc#addListener(isac.wsdialog.IToUser)
|
wneuper@3922
|
211 |
*/
|
wneuper@3922
|
212 |
public boolean addDataChangeListener(IToUser listener)
|
wneuper@3922
|
213 |
throws RemoteException {
|
wneuper@3922
|
214 |
if (datachange_listeners_.contains(listener)) {
|
wneuper@3922
|
215 |
return false;
|
wneuper@3922
|
216 |
} else {
|
wneuper@3922
|
217 |
datachange_listeners_.add(listener);
|
wneuper@3922
|
218 |
}
|
wneuper@3922
|
219 |
return true;
|
wneuper@3922
|
220 |
}
|
wneuper@3922
|
221 |
|
wneuper@3922
|
222 |
public boolean registerUIControlListener(IToWorksheet listener)
|
wneuper@3922
|
223 |
throws RemoteException {
|
wneuper@3922
|
224 |
//WN0504 ???
|
wneuper@3922
|
225 |
// if (ui_control_listener_ != null) {
|
wneuper@3922
|
226 |
// ui_control_listener_.doUIAction(new UserAction(UI_DO_DETACH));
|
wneuper@3922
|
227 |
// }
|
wneuper@3922
|
228 |
ui_control_listener_ = listener;
|
wneuper@3922
|
229 |
return true;
|
wneuper@3922
|
230 |
}
|
wneuper@3922
|
231 |
|
wneuper@3922
|
232 |
// /**
|
wneuper@3922
|
233 |
// * @see isac.wsdialog.IToCalc#fetchProposedTactic
|
wneuper@3922
|
234 |
// * @deprecated Use {@link #notifyUserAction(IUserAction)}instead
|
wneuper@3922
|
235 |
// */
|
wneuper@3922
|
236 |
// public Tactic fetchProposedTactic() {
|
wneuper@3922
|
237 |
// return calc_tree_.fetchProposedTactic();
|
wneuper@3922
|
238 |
// }
|
wneuper@3922
|
239 |
//
|
wneuper@3922
|
240 |
//
|
wneuper@3922
|
241 |
// /**
|
wneuper@3922
|
242 |
// * @deprecated Use {@link #notifyUserAction(IUserAction)}instead
|
wneuper@3922
|
243 |
// */
|
wneuper@3922
|
244 |
// public int setNextTactic(Tactic tactic) {
|
wneuper@3922
|
245 |
// return calc_tree_.setNextTactic(tactic);
|
wneuper@3922
|
246 |
// }
|
wneuper@3922
|
247 |
//
|
wneuper@3922
|
248 |
// /**
|
wneuper@3922
|
249 |
// * @deprecated Use {@link #notifyUserAction(IUserAction)}instead
|
wneuper@3922
|
250 |
// */
|
wneuper@3922
|
251 |
// public int autoCalculate(int scope, int nSteps) {
|
wneuper@3922
|
252 |
// return calc_tree_.autoCalculate(scope, nSteps);
|
wneuper@3922
|
253 |
// }
|
wneuper@3922
|
254 |
//
|
wneuper@3922
|
255 |
// /**
|
wneuper@3922
|
256 |
// * @deprecated Use {@link #notifyUserAction(IUserAction)}instead
|
wneuper@3922
|
257 |
// */
|
wneuper@3922
|
258 |
// public void tryMatch(CalcHead ch, CalcHeadCompoundID problemID)
|
wneuper@3922
|
259 |
// throws NotInSpecificationPhaseException {
|
wneuper@3922
|
260 |
//
|
wneuper@3922
|
261 |
// // MathEngine.getMathEngine().tryMatch(ch, problemID);
|
wneuper@3922
|
262 |
// math_engine_.tryMatch(ch, problemID);
|
wneuper@3922
|
263 |
// }
|
wneuper@3922
|
264 |
//
|
wneuper@3922
|
265 |
// /**
|
wneuper@3922
|
266 |
// * @deprecated Use {@link #notifyUserAction(IUserAction)}instead
|
wneuper@3922
|
267 |
// */
|
wneuper@3922
|
268 |
// public void tryRefine(CalcHead ch, CalcHeadCompoundID problemID)
|
wneuper@3922
|
269 |
// throws NotInSpecificationPhaseException {
|
wneuper@3922
|
270 |
//
|
wneuper@3922
|
271 |
// // MathEngine.getMathEngine().tryRefine(ch , problemID);
|
wneuper@3922
|
272 |
// math_engine_.tryRefine(ch, problemID);
|
wneuper@3922
|
273 |
// }
|
wneuper@3922
|
274 |
//
|
wneuper@3922
|
275 |
// /**
|
wneuper@3922
|
276 |
// * @deprecated Use {@link #notifyUserAction(IUserAction)}instead
|
wneuper@3922
|
277 |
// */
|
wneuper@3922
|
278 |
// public ICalcIterator getActiveFormula() {
|
wneuper@3922
|
279 |
// return calc_tree_.getActiveFormula();
|
wneuper@3922
|
280 |
// }
|
wneuper@3922
|
281 |
//
|
wneuper@3922
|
282 |
// /**
|
wneuper@3922
|
283 |
// * @throws RemoteException
|
wneuper@3922
|
284 |
// * @deprecated Use {@link #notifyUserAction(IUserAction)}instead
|
wneuper@3922
|
285 |
// */
|
wneuper@3922
|
286 |
// public int replaceFormula(CalcFormula newFormula) throws RemoteException
|
wneuper@3922
|
287 |
// {
|
wneuper@3922
|
288 |
// return calc_tree_.replaceFormula(newFormula);
|
wneuper@3922
|
289 |
// }
|
wneuper@3922
|
290 |
//
|
wneuper@3922
|
291 |
// /**
|
wneuper@3922
|
292 |
// * @throws RemoteException
|
wneuper@3922
|
293 |
// * @deprecated Use {@link #notifyUserAction(IUserAction)}instead
|
wneuper@3922
|
294 |
// */
|
wneuper@3922
|
295 |
// public int appendFormula(CalcFormula newFormula) throws RemoteException {
|
wneuper@3922
|
296 |
// return calc_tree_.appendFormula(newFormula);
|
wneuper@3922
|
297 |
// }
|
wneuper@3922
|
298 |
//
|
wneuper@3922
|
299 |
// /**
|
wneuper@3922
|
300 |
// * @deprecated Use {@link #notifyUserAction(IUserAction)}instead
|
wneuper@3922
|
301 |
// */
|
wneuper@3922
|
302 |
// public void moveActiveFormula(ICalcIterator newActiveFormula) {
|
wneuper@3922
|
303 |
// calc_tree_.moveActiveFormula(newActiveFormula);
|
wneuper@3922
|
304 |
// }
|
wneuper@3922
|
305 |
//
|
wneuper@3922
|
306 |
/**
|
wneuper@3922
|
307 |
* Notify the Dialog Guide about interaction from the User
|
wneuper@3922
|
308 |
*
|
wneuper@3922
|
309 |
* @param action
|
wneuper@3922
|
310 |
* @return true, if the action has been processed, false if the processing
|
wneuper@3922
|
311 |
* the action has been denied
|
wneuper@3922
|
312 |
* @throws RemoteException
|
wneuper@3922
|
313 |
*
|
wneuper@3922
|
314 |
*/
|
wneuper@3922
|
315 |
public boolean notifyUserAction(IUserAction action)
|
wneuper@3922
|
316 |
throws DialogProtocolException, RemoteException {
|
wneuper@3922
|
317 |
int request = action.getActionID();
|
wneuper@3922
|
318 |
logger_.fatal(" WS->DG: notifyUserAction request= " + request);
|
wneuper@3922
|
319 |
|
wneuper@3922
|
320 |
// two userActions dont care about the dialogphase
|
wneuper@3922
|
321 |
//WN050420 would be nicer, if DialogGuide would set the Buttons
|
wneuper@3922
|
322 |
switch (request) {
|
wneuper@3922
|
323 |
case (UI_CALCULATE_1):
|
wneuper@3922
|
324 |
if (phase_ == DIALOGPHASE_SPECIFY)
|
wneuper@3922
|
325 |
request = UI_SPECIFY_TO_SOLVE;//WN#####################
|
wneuper@3922
|
326 |
else
|
wneuper@3922
|
327 |
request = UI_SOLVE_CALCULATE_1;
|
wneuper@3922
|
328 |
break;
|
wneuper@3922
|
329 |
case (UI_CALCULATE_ALL):
|
wneuper@3922
|
330 |
if (phase_ == DIALOGPHASE_SPECIFY)
|
wneuper@3922
|
331 |
request = UI_SPECIFY_CALCULATE_ALL;
|
wneuper@3922
|
332 |
else
|
wneuper@3922
|
333 |
request = UI_SOLVE_CALCULATE_ALL;
|
wneuper@3922
|
334 |
}
|
wneuper@3922
|
335 |
// all other userActions belong to a certain dialogphase
|
wneuper@3922
|
336 |
|
wneuper@3922
|
337 |
switch (phase_) {
|
wneuper@3922
|
338 |
case DIALOGPHASE_IDLE:
|
wneuper@3922
|
339 |
throw new DialogProtocolException(request, phase_);
|
wneuper@3922
|
340 |
case DIALOGPHASE_SPECIFY:
|
wneuper@3922
|
341 |
if (request < UI_DUMMY_FIRST_SPECIFY
|
wneuper@3922
|
342 |
|| request > UI_DUMMY_LAST_SPECIFY)
|
wneuper@3922
|
343 |
throw new DialogProtocolException(request, phase_);
|
wneuper@3922
|
344 |
break;
|
wneuper@3922
|
345 |
case DIALOGPHASE_SOLVE:
|
wneuper@3922
|
346 |
if (request < UI_DUMMY_FIRST_SOLVE || request > UI_DUMMY_LAST_SOLVE)
|
wneuper@3922
|
347 |
throw new DialogProtocolException(request, phase_);
|
wneuper@3922
|
348 |
break;
|
wneuper@3922
|
349 |
}
|
wneuper@3922
|
350 |
|
wneuper@3922
|
351 |
//*********** handle IUserAction's **********************
|
wneuper@3922
|
352 |
CalcHead calc_head = new CalcHead();//WN0502023?????????
|
wneuper@3922
|
353 |
try {
|
wneuper@3922
|
354 |
calc_head = (CalcHead) calc_tree_.iterator().getFormula();
|
wneuper@3922
|
355 |
} catch (Exception e) {
|
wneuper@3922
|
356 |
e.printStackTrace();
|
wneuper@3922
|
357 |
}
|
wneuper@3922
|
358 |
switch (request) {
|
wneuper@3922
|
359 |
case UI_SPECIFY_TRY_MATCH:
|
wneuper@3922
|
360 |
throw new DialogNotImplementedException(request, phase_);
|
wneuper@3922
|
361 |
// try {
|
wneuper@3922
|
362 |
// tryMatch(calc_head, ((UserActionOnCalcHeadCompoundID) action)
|
wneuper@3922
|
363 |
// .getObjectID());
|
wneuper@3922
|
364 |
// } catch (NotInSpecificationPhaseException e) {
|
wneuper@3922
|
365 |
// throw new DialogMathException(request, phase_, e);
|
wneuper@3922
|
366 |
// }
|
wneuper@3922
|
367 |
// break;
|
wneuper@3922
|
368 |
|
wneuper@3922
|
369 |
case UI_SPECIFY_TRY_REFINE:
|
wneuper@3922
|
370 |
throw new DialogNotImplementedException(request, phase_);
|
wneuper@3922
|
371 |
// try {
|
wneuper@3922
|
372 |
// tryRefine(calc_head, ((UserActionOnCalcHeadCompoundID) action)
|
wneuper@3922
|
373 |
// .getObjectID());
|
wneuper@3922
|
374 |
// } catch (NotInSpecificationPhaseException e) {
|
wneuper@3922
|
375 |
// throw new DialogMathException(request, phase_, e);
|
wneuper@3922
|
376 |
// }
|
wneuper@3922
|
377 |
// break;
|
wneuper@3922
|
378 |
|
wneuper@3922
|
379 |
case UI_SPECIFY_CHANGE_VIEW:
|
wneuper@3922
|
380 |
calc_head.setViewStyle(((UserActionOnInt) action).getInt());
|
wneuper@3922
|
381 |
break;
|
wneuper@3922
|
382 |
|
wneuper@3922
|
383 |
case UI_SPECIFY_COMPLETE_CALCHEAD:
|
wneuper@3922
|
384 |
calc_tree_.completeCalcHead();
|
wneuper@3922
|
385 |
// old-style filling the fields of the calc-head by setting
|
wneuper@3922
|
386 |
// the HELP_ME flag
|
wneuper@3922
|
387 |
// calc_head_.setCalcHeadStatus(CalcHead.MODEL_ITEM_HELP_ME);
|
wneuper@3922
|
388 |
// modifyCalcHead(calc_head_);
|
wneuper@3922
|
389 |
break;
|
wneuper@3922
|
390 |
case UI_SPECIFY_COMPLETE_METHOD:
|
wneuper@3922
|
391 |
case UI_SPECIFY_COMPLETE_THEORY:
|
wneuper@3922
|
392 |
case UI_SPECIFY_COMPLETE_PROBLEM:
|
wneuper@3922
|
393 |
case UI_SPECIFY_COMPLETE_GIVEN:
|
wneuper@3922
|
394 |
case UI_SPECIFY_COMPLETE_FIND:
|
wneuper@3922
|
395 |
case UI_SPECIFY_COMPLETE_RELATE:
|
wneuper@3922
|
396 |
throw new DialogNotImplementedException(request, phase_);
|
wneuper@3922
|
397 |
|
wneuper@3922
|
398 |
case UI_SPECIFY_CHECK_CALCHEAD:
|
wneuper@3922
|
399 |
calc_tree_.modifyCalcHead(calc_head);
|
wneuper@3922
|
400 |
break;
|
wneuper@3922
|
401 |
|
wneuper@3922
|
402 |
// was: startCalculation() WN050428 ? really ?
|
wneuper@3922
|
403 |
case UI_SPECIFY_TO_SOLVE:
|
wneuper@3922
|
404 |
case UI_SPECIFY_CALCULATE_ALL:
|
wneuper@3922
|
405 |
//if (user_settings_.getValue(""))
|
wneuper@3922
|
406 |
if (true)
|
wneuper@3922
|
407 |
calc_tree_.completeCalcHead();
|
wneuper@3922
|
408 |
else
|
wneuper@3922
|
409 |
calc_tree_.modifyCalcHead(calc_head);
|
wneuper@3922
|
410 |
|
wneuper@3922
|
411 |
if (calc_head.getCalcHeadStatus() != CalcHead.MODEL_ITEM_CORRECT)
|
wneuper@3922
|
412 |
return false;
|
wneuper@3922
|
413 |
|
wneuper@3922
|
414 |
try {
|
wneuper@3922
|
415 |
calc_tree_.startSolving();
|
wneuper@3922
|
416 |
} catch (Exception e) {
|
wneuper@3922
|
417 |
// TODO Auto-generated catch block
|
wneuper@3922
|
418 |
e.printStackTrace();
|
wneuper@3922
|
419 |
}
|
wneuper@3922
|
420 |
// calc_tree_ = MathEngine.getMathEngine().startSolving(calcHead);
|
wneuper@3922
|
421 |
// FIXME: AK020224: do not register with the calc_tree_ if finished
|
wneuper@3922
|
422 |
// specifying a SUBPROBLEM
|
wneuper@3922
|
423 |
//calc_tree_.addDataChangeListener(this);//WN050420-->startCalculation
|
wneuper@3922
|
424 |
|
wneuper@3922
|
425 |
phase_ = DIALOGPHASE_SOLVE;//FIXXXME.WN050428
|
wneuper@3922
|
426 |
// fall through to calculate
|
wneuper@3922
|
427 |
|
wneuper@3922
|
428 |
case UI_SOLVE_CALCULATE_1:
|
wneuper@3922
|
429 |
//WN050420 why not at (*) here ?
|
wneuper@3922
|
430 |
case UI_SOLVE_CALCULATE_ALL:
|
wneuper@3922
|
431 |
switch (request) {
|
wneuper@3922
|
432 |
case UI_SPECIFY_CALCULATE_ALL:
|
wneuper@3922
|
433 |
case UI_SOLVE_CALCULATE_ALL:
|
wneuper@3922
|
434 |
calc_tree_.autoCalculate(IToCalc.SCOPE_CALCULATION, 0);
|
wneuper@3922
|
435 |
break;
|
wneuper@3922
|
436 |
case UI_SPECIFY_TO_SOLVE://WN050420 ???
|
wneuper@3922
|
437 |
// break;
|
wneuper@3922
|
438 |
default:
|
wneuper@3922
|
439 |
calc_tree_.autoCalculate(IToCalc.SCOPE_CALCULATION, 1);
|
wneuper@3922
|
440 |
//why not at (*) above ?
|
wneuper@3922
|
441 |
break;
|
wneuper@3922
|
442 |
}
|
wneuper@3922
|
443 |
break;
|
wneuper@3922
|
444 |
|
wneuper@3922
|
445 |
case UI_SOLVE_CALCULATE_SUBPROBLEM:
|
wneuper@3922
|
446 |
calc_tree_.autoCalculate(IToCalc.SCOPE_SUBPROBLEM, 0);
|
wneuper@3922
|
447 |
break;
|
wneuper@3922
|
448 |
|
wneuper@3922
|
449 |
case UI_SOLVE_EDIT_ACTIVE_FORMULA:
|
wneuper@3922
|
450 |
ui_control_listener_.doUIAction(new UserAction(UI_DO_EDIT_FORMULA));
|
wneuper@3922
|
451 |
break;
|
wneuper@3922
|
452 |
|
wneuper@3922
|
453 |
case UI_SOLVE_EDIT_ACTIVE_FORMULA_COMPLETE:
|
wneuper@3922
|
454 |
CalcFormula formula = (CalcFormula) ((UserActionOnCalcElement) action)
|
wneuper@3922
|
455 |
.getCalcElement();
|
wneuper@3922
|
456 |
// if the position is null, the formula did not exist, so we try to
|
wneuper@3922
|
457 |
// append a new formula
|
wneuper@3922
|
458 |
if (formula.getPosition() == null) {
|
wneuper@3922
|
459 |
calc_tree_.appendFormula(formula);
|
wneuper@3922
|
460 |
} else {
|
wneuper@3922
|
461 |
calc_tree_.replaceFormula(formula);
|
wneuper@3922
|
462 |
}
|
wneuper@3922
|
463 |
break;
|
wneuper@3922
|
464 |
|
wneuper@3922
|
465 |
case UI_SOLVE_APPEND_USER_FORMULA:
|
wneuper@3922
|
466 |
// appendFormula((Formula) ((UserActionOnCalcElement)
|
wneuper@3922
|
467 |
// action).getCalcElement());
|
wneuper@3922
|
468 |
ui_control_listener_
|
wneuper@3922
|
469 |
.doUIAction(new UserAction(UI_DO_APPEND_FORMULA));
|
wneuper@3922
|
470 |
break;
|
wneuper@3922
|
471 |
|
wneuper@3922
|
472 |
case UI_SOLVE_MOVE_ACTIVE_FORMULA:
|
wneuper@3922
|
473 |
calc_tree_.moveActiveFormula(((UserActionOnIterator) action)
|
wneuper@3922
|
474 |
.getPosition());
|
wneuper@3922
|
475 |
break;
|
wneuper@3922
|
476 |
|
wneuper@3922
|
477 |
case UI_SOLVE_GET_PROPOSED_TACTIC:
|
wneuper@3922
|
478 |
throw new DialogNotImplementedException(request, phase_);
|
wneuper@3922
|
479 |
|
wneuper@3922
|
480 |
case UI_SOLVE_GET_APPLICABLE_TACTICS:
|
wneuper@3922
|
481 |
throw new DialogNotImplementedException(request, phase_);
|
wneuper@3922
|
482 |
|
wneuper@3922
|
483 |
case UI_SOLVE_SET_NEXT_TACTIC:
|
wneuper@3922
|
484 |
calc_tree_
|
wneuper@3922
|
485 |
.setNextTactic((Tactic) ((UserActionOnCalcElement) action)
|
wneuper@3922
|
486 |
.getCalcElement());
|
wneuper@3922
|
487 |
//WN041126 extracted from isac.bridge.CalcTree#setNextTactic @@@
|
wneuper@3922
|
488 |
//autoCalculate(SCOPE_CALCULATION, 1);
|
wneuper@3922
|
489 |
break;
|
wneuper@3922
|
490 |
|
wneuper@3922
|
491 |
case UI_SOLVE_HELP_ENTERING_FORMULA:
|
wneuper@3922
|
492 |
throw new DialogNotImplementedException(request, phase_);
|
wneuper@3922
|
493 |
|
wneuper@3922
|
494 |
case UI_SOLVE_SHOW_ASSUMPTIONS:
|
wneuper@3922
|
495 |
throw new DialogNotImplementedException(request, phase_);
|
wneuper@3922
|
496 |
|
wneuper@3922
|
497 |
case UI_SOLVE_SHOW_DETAILS:
|
wneuper@3922
|
498 |
throw new DialogNotImplementedException(request, phase_);
|
wneuper@3922
|
499 |
|
wneuper@3922
|
500 |
default:
|
wneuper@3922
|
501 |
throw new DialogUnknownActionException(request, phase_);
|
wneuper@3922
|
502 |
}
|
wneuper@3922
|
503 |
return true;
|
wneuper@3922
|
504 |
}
|
wneuper@3922
|
505 |
|
wneuper@3922
|
506 |
private void rmiBind() {
|
wneuper@3922
|
507 |
if (System.getSecurityManager() == null) {
|
wneuper@3922
|
508 |
System.setSecurityManager(new RMISecurityManager());
|
wneuper@3922
|
509 |
}
|
wneuper@3922
|
510 |
|
wneuper@3922
|
511 |
try {
|
wneuper@3922
|
512 |
LocateRegistry.createRegistry(1099);
|
wneuper@3922
|
513 |
} catch (java.rmi.RemoteException exc2) {
|
wneuper@3922
|
514 |
System.err.println("can not create registry: " + exc2.getMessage());
|
wneuper@3922
|
515 |
}
|
wneuper@3922
|
516 |
|
wneuper@3922
|
517 |
String name = "//localhost/isac-DialogGuide";
|
wneuper@3922
|
518 |
try {
|
wneuper@3922
|
519 |
System.out.println("try to bind as " + name);
|
wneuper@3922
|
520 |
Naming.rebind(name, this);
|
wneuper@3922
|
521 |
System.out.println("Dialog Guide bound to " + name);
|
wneuper@3922
|
522 |
//WN040906 was Object Manager ...
|
wneuper@3922
|
523 |
} catch (java.rmi.ConnectException e) {
|
wneuper@3922
|
524 |
System.err.println("failed to contact as " + name
|
wneuper@3922
|
525 |
+ " (creating RMI-Server on localhost: 1099)");
|
wneuper@3922
|
526 |
} catch (RemoteException e) {
|
wneuper@3922
|
527 |
// TODO Auto-generated catch block
|
wneuper@3922
|
528 |
e.printStackTrace();
|
wneuper@3922
|
529 |
} catch (MalformedURLException e) {
|
wneuper@3922
|
530 |
// TODO Auto-generated catch block
|
wneuper@3922
|
531 |
e.printStackTrace();
|
wneuper@3922
|
532 |
}
|
wneuper@3922
|
533 |
}
|
wneuper@3922
|
534 |
|
wneuper@3922
|
535 |
// public static void main(String[] args) {
|
wneuper@3922
|
536 |
// try {
|
wneuper@3922
|
537 |
// new DialogGuide(args[0]);
|
wneuper@3922
|
538 |
//
|
wneuper@3922
|
539 |
// } catch (RemoteException e) {
|
wneuper@3922
|
540 |
// e.printStackTrace();
|
wneuper@3922
|
541 |
// }
|
wneuper@3922
|
542 |
// }
|
wneuper@3922
|
543 |
|
wneuper@3922
|
544 |
// /**
|
wneuper@3922
|
545 |
// * @see
|
wneuper@3922
|
546 |
// isac.util.interfaces.IToCalc#completeCalcHead(isac.util.formulae.CalcHead)
|
wneuper@3922
|
547 |
// * @deprecated Use {@link #notifyUserAction(IUserAction)}instead
|
wneuper@3922
|
548 |
// */
|
wneuper@3922
|
549 |
// public void completeCalcHead(CalcHead calcHead) {
|
wneuper@3922
|
550 |
// // TODO Auto-generated method stub
|
wneuper@3922
|
551 |
//
|
wneuper@3922
|
552 |
// }
|
wneuper@3922
|
553 |
//
|
wneuper@3922
|
554 |
// /**
|
wneuper@3922
|
555 |
// * @see
|
wneuper@3922
|
556 |
// isac.util.interfaces.IToCalc#completeCalcHead(isac.util.formulae.CalcHead,
|
wneuper@3922
|
557 |
// * int)
|
wneuper@3922
|
558 |
// * @deprecated Use {@link #notifyUserAction(IUserAction)}instead
|
wneuper@3922
|
559 |
// */
|
wneuper@3922
|
560 |
// public void completeCalcHead(CalcHead calcHead, int completeItem) {
|
wneuper@3922
|
561 |
// // TODO Auto-generated method stub
|
wneuper@3922
|
562 |
//
|
wneuper@3922
|
563 |
// }
|
wneuper@3922
|
564 |
//
|
wneuper@3922
|
565 |
// /**
|
wneuper@3922
|
566 |
// * (non-Javadoc)
|
wneuper@3922
|
567 |
// *
|
wneuper@3922
|
568 |
// * @see isac.util.interfaces.IToCalc#completeCalcHead()
|
wneuper@3922
|
569 |
// * @deprecated Use {@link #notifyUserAction(IUserAction)}instead
|
wneuper@3922
|
570 |
// */
|
wneuper@3922
|
571 |
// public void completeCalcHead() throws RemoteException {
|
wneuper@3922
|
572 |
// // TODO Auto-generated method stub WN050223
|
wneuper@3922
|
573 |
//
|
wneuper@3922
|
574 |
// }
|
wneuper@3922
|
575 |
//
|
wneuper@3922
|
576 |
// /**
|
wneuper@3922
|
577 |
// * @deprecated Use {@link #notifyUserAction(IUserAction)}instead
|
wneuper@3922
|
578 |
// *
|
wneuper@3922
|
579 |
// * @see
|
wneuper@3922
|
580 |
// isac.util.interfaces.IToCalc#intermediateSteps(isac.util.interfaces.ICalcIterator)
|
wneuper@3922
|
581 |
// */
|
wneuper@3922
|
582 |
// public int intermediateSteps(ICalcIterator i) throws RemoteException {
|
wneuper@3922
|
583 |
// // TODO Auto-generated method stub
|
wneuper@3922
|
584 |
// return 0;
|
wneuper@3922
|
585 |
// }
|
wneuper@3922
|
586 |
//
|
wneuper@3922
|
587 |
// /**
|
wneuper@3922
|
588 |
// * @see
|
wneuper@3922
|
589 |
// isac.util.interfaces.IToCalc#getElementsFromTo(isac.util.interfaces.ICalcIterator,
|
wneuper@3922
|
590 |
// * isac.util.interfaces.ICalcIterator, java.lang.Integer, boolean)
|
wneuper@3922
|
591 |
// * @deprecated Use {@link #notifyUserAction(IUserAction)}instead
|
wneuper@3922
|
592 |
// */
|
wneuper@3922
|
593 |
// public Vector getElementsFromTo(ICalcIterator iterator_from,
|
wneuper@3922
|
594 |
// ICalcIterator iterator_to, Integer level,
|
wneuper@3922
|
595 |
// boolean result_includes_tactics) throws RemoteException {
|
wneuper@3922
|
596 |
// // TODO Auto-generated method stub
|
wneuper@3922
|
597 |
// return null;
|
wneuper@3922
|
598 |
// }
|
wneuper@3922
|
599 |
|
wneuper@3922
|
600 |
} |