1.1 --- a/src/java/isac/browserdialog/ExampleDialog.java Thu Sep 13 19:02:52 2007 +0200
1.2 +++ b/src/java/isac/browserdialog/ExampleDialog.java Fri Sep 14 19:59:16 2007 +0200
1.3 @@ -100,7 +100,7 @@
1.4 if (super.notifyUserAction(action))
1.5 return true;
1.6
1.7 - isac_logger_.logUserAction("exp",action);
1.8 + isac_logger_.logUserAction("exp", action);
1.9
1.10 switch (action.getActionID()) {
1.11 case UI_MINIBROWSER_LINK: {
2.1 --- a/src/java/isac/browserdialog/MethodDialog.java Thu Sep 13 19:02:52 2007 +0200
2.2 +++ b/src/java/isac/browserdialog/MethodDialog.java Fri Sep 14 19:59:16 2007 +0200
2.3 @@ -39,204 +39,199 @@
2.4 */
2.5 public class MethodDialog extends BrowserDialog {
2.6
2.7 - /**
2.8 - * For serialization, see corresponding API Documentation; value generated
2.9 - * by eclipse to avoid a warning
2.10 - */
2.11 - private static final long serialVersionUID = 6479711601158544388L;
2.12 + /**
2.13 + * For serialization, see corresponding API Documentation; value generated
2.14 + * by eclipse to avoid a warning
2.15 + */
2.16 + private static final long serialVersionUID = 6479711601158544388L;
2.17
2.18 - /** true if the <To Worksheet> button is visible * */
2.19 - private boolean to_worksheet_visible_;
2.20 + /** true if the <To Worksheet> button is visible * */
2.21 + private boolean to_worksheet_visible_;
2.22
2.23 - /** true if the <Context On> button is visible* */
2.24 - //private boolean context_on_visible_;
2.25 -
2.26 - /** true if the calc head of the active worksheet is open
2.27 - * this flag is updated in updateState()
2.28 - */
2.29 - private boolean calc_head_open_;
2.30 + /** true if the <Context On> button is visible* */
2.31 + // private boolean context_on_visible_;
2.32 + /**
2.33 + * true if the calc head of the active worksheet is open this flag is
2.34 + * updated in updateState()
2.35 + */
2.36 + private boolean calc_head_open_;
2.37
2.38 - /**
2.39 - * The constructor of this class which is given the session the
2.40 - * MethodDialog is instanciated for. We need the session to get the correct
2.41 - * WSDialogManager (and also the active WSDialog) for this BrowserDialog.
2.42 - *
2.43 - * @param session
2.44 - * @throws RemoteException
2.45 - */
2.46 - public MethodDialog(Session session) throws RemoteException {
2.47 - super(session);
2.48 - context_type_ = ContextType.CONTEXT_METHODS;
2.49 -
2.50 - hierarchy_ = loadHierarchy(context_type_);
2.51 - //System.out.println("Method hierarchy:");
2.52 - //System.out.println(hierarchy_.toString());
2.53 - current_context_ = new ContextUnknown();
2.54 - }
2.55 + /**
2.56 + * The constructor of this class which is given the session the MethodDialog
2.57 + * is instanciated for. We need the session to get the correct
2.58 + * WSDialogManager (and also the active WSDialog) for this BrowserDialog.
2.59 + *
2.60 + * @param session
2.61 + * @throws RemoteException
2.62 + */
2.63 + public MethodDialog(Session session) throws RemoteException {
2.64 + super(session);
2.65 + context_type_ = ContextType.CONTEXT_METHODS;
2.66
2.67 - /**
2.68 - * Notify the MethodDialog about events or requests triggered by the user.
2.69 - * The MethodBrowser calls this method over RMI.
2.70 - *
2.71 - * @param action
2.72 - * What's new from the UI
2.73 - * @return true, if the event is being processed, false if processing is
2.74 - * denied or impossible
2.75 - * @throws RemoteException
2.76 - * @throws DialogProtocolException
2.77 - */
2.78 - public boolean notifyUserAction(IUserAction action)
2.79 - throws DialogProtocolException, RemoteException {
2.80 - System.out.println("MethodDialog::notifyUserAction() action="
2.81 - + action.getActionID());
2.82 -
2.83 - if( super.notifyUserAction( action ) )
2.84 - return true;
2.85 -
2.86 - isac_logger_.logUserAction("met",action);
2.87 -
2.88 - switch (action.getActionID()) {
2.89 - case UI_BROWSER_MATCH_ON: {
2.90 - context_on_ = true;
2.91 - drawButtons();
2.92 - sendInitContextToBrowser();
2.93 - return true;
2.94 - }
2.95 - case UI_BROWSER_MATCH_OFF: {
2.96 - context_on_ = false;
2.97 - drawButtons();
2.98 - ContextUnknown new_context= new ContextUnknown();
2.99 - new_context.setHierarchyKey(current_context_.getHierarchyKey());
2.100 - new_context.setKEStoreKey(current_context_.getKEStoreKey());
2.101 - sendContextToBrowser(new_context);
2.102 - sendLinkToMiniBrowser(new_context,context_type_);
2.103 - return true;
2.104 - }
2.105 - case UI_BROWSER_TO_WORKSHEET: {
2.106 - setCurrentContextToWorksheet();
2.107 - return true;
2.108 - }
2.109 - case UI_MINIBROWSER_LINK: {
2.110 - URL receivedLink = ((UserActionOnLink) action).getLink();
2.111 - try {
2.112 - interpretLink(receivedLink);
2.113 - return true;
2.114 - } catch (RemoteException e) {
2.115 - e.printStackTrace();
2.116 - return false;
2.117 - }
2.118 - }
2.119 - }
2.120 - return false;
2.121 - }
2.122 + hierarchy_ = loadHierarchy(context_type_);
2.123 + // System.out.println("Method hierarchy:");
2.124 + // System.out.println(hierarchy_.toString());
2.125 + current_context_ = new ContextUnknown();
2.126 + }
2.127
2.128 - /**
2.129 - * removes the button for To Worksheet. If the button does not
2.130 - * exist so far, nothing happens.
2.131 - */
2.132 - private void removeButtonToWorksheet() {
2.133 - if (!to_worksheet_visible_)
2.134 - return;
2.135 - try {
2.136 - browser_frame_rmi_.removeUIElement(new UIAction(
2.137 - EUIElement.UI_BROWSER_TO_WORKSHEET,
2.138 - EUIContext.UI_CONTEXT_BROWSER, user_language_));
2.139 - } catch (RemoteException e) {
2.140 - e.printStackTrace();
2.141 - }
2.142 - to_worksheet_visible_ = false;
2.143 - }
2.144 + /**
2.145 + * Notify the MethodDialog about events or requests triggered by the user.
2.146 + * The MethodBrowser calls this method over RMI.
2.147 + *
2.148 + * @param action
2.149 + * What's new from the UI
2.150 + * @return true, if the event is being processed, false if processing is
2.151 + * denied or impossible
2.152 + * @throws RemoteException
2.153 + * @throws DialogProtocolException
2.154 + */
2.155 + public boolean notifyUserAction(IUserAction action)
2.156 + throws DialogProtocolException, RemoteException {
2.157 + System.out.println("MethodDialog::notifyUserAction() action="
2.158 + + action.getActionID());
2.159
2.160 - /**
2.161 - * generates the button for To Worksheet. If the button does
2.162 - * already exist, nothing happens.
2.163 - */
2.164 - private void drawButtonToWorksheet() {
2.165 - if (to_worksheet_visible_)
2.166 - return;
2.167 - try {
2.168 - browser_frame_rmi_.addUIElement(new UIAction(
2.169 - EUIElement.UI_BROWSER_TO_WORKSHEET,
2.170 - EUIContext.UI_CONTEXT_BROWSER, user_language_));
2.171 - } catch (RemoteException e) {
2.172 - e.printStackTrace();
2.173 - }
2.174 - to_worksheet_visible_ = true;
2.175 - }
2.176 + if (super.notifyUserAction(action))
2.177 + return true;
2.178
2.179 - /**
2.180 - * This method overrides the method in the base class and
2.181 - * calls the method of the base class. This is done, as some
2.182 - * additional initialisations have to be done with the buttons
2.183 - * and the context.
2.184 - *
2.185 - * @param browser_frame
2.186 - * the browser frame to register
2.187 - */
2.188 - public void registerBrowserFrame(IToGUI browser_frame)
2.189 - throws RemoteException {
2.190 - super.registerBrowserFrame(browser_frame);
2.191 - initButtons();
2.192 - }
2.193 -
2.194 - private void initButtons() {
2.195 - context_on_visible_ = false;
2.196 - to_worksheet_visible_ = false;
2.197 - context_on_ = true;
2.198 - try {
2.199 - browser_frame_rmi_.addUIElement(new UIAction(
2.200 - EUIElement.UI_BROWSER_MATCH_OFF,
2.201 - EUIContext.UI_CONTEXT_BROWSER, user_language_));
2.202 - } catch (RemoteException e) {
2.203 - e.printStackTrace();
2.204 - }
2.205 - }
2.206 + isac_logger_.logUserAction("met", action);
2.207
2.208 - /**
2.209 - * This method draws the buttons of the browser. Which buttons need
2.210 - * to be shown depends on three flags:
2.211 - * context_on_ calc_head_open_ | Buttons to show:
2.212 - * -----------------------------------------------------------------
2.213 - * F X | <Context Off>
2.214 - * T F | <Context On>
2.215 - * T T | <Context On> <ToWorksheet>
2.216 - *
2.217 - */
2.218 + switch (action.getActionID()) {
2.219 + case UI_BROWSER_MATCH_ON: {
2.220 + context_on_ = true;
2.221 + drawButtons();
2.222 + sendInitContextToBrowser();
2.223 + return true;
2.224 + }
2.225 + case UI_BROWSER_MATCH_OFF: {
2.226 + context_on_ = false;
2.227 + drawButtons();
2.228 + ContextUnknown new_context = new ContextUnknown();
2.229 + new_context.setHierarchyKey(current_context_.getHierarchyKey());
2.230 + new_context.setKEStoreKey(current_context_.getKEStoreKey());
2.231 + sendContextToBrowser(new_context);
2.232 + sendLinkToMiniBrowser(new_context, context_type_);
2.233 + return true;
2.234 + }
2.235 + case UI_BROWSER_TO_WORKSHEET: {
2.236 + setCurrentContextToWorksheet();
2.237 + return true;
2.238 + }
2.239 + case UI_MINIBROWSER_LINK: {
2.240 + URL receivedLink = ((UserActionOnLink) action).getLink();
2.241 + try {
2.242 + interpretLink(receivedLink);
2.243 + return true;
2.244 + } catch (RemoteException e) {
2.245 + e.printStackTrace();
2.246 + return false;
2.247 + }
2.248 + }
2.249 + }
2.250 + return false;
2.251 + }
2.252
2.253 - protected void drawButtons() {
2.254 - if (!context_on_) {
2.255 - drawButtonContextOn();
2.256 - removeButtonToWorksheet();
2.257 - } else {
2.258 - if (!calc_head_open_) {
2.259 - drawButtonContextOff();
2.260 - removeButtonToWorksheet();
2.261 - }
2.262 - else {
2.263 - drawButtonContextOff();
2.264 - drawButtonToWorksheet();
2.265 - }
2.266 - }
2.267 - }
2.268 - /**
2.269 - * This method does the update for the two variables:
2.270 - * worksheet_open_ and calc_head_open_. An interface to the
2.271 - * active worksheet is fetched from the session. If no active
2.272 - * worksheet exists (and null is returned) there is no open
2.273 - * worksheet. The interface returns a WorksheetState which is
2.274 - * able to tell us, if the CalcHead is open.
2.275 - */
2.276 - public void updateState() {
2.277 - try {
2.278 - IContextProvider context_provider = session_.getContextProvider();
2.279 - if(context_provider == null) {
2.280 - calc_head_open_ = false;
2.281 - return;
2.282 - }
2.283 - WorksheetState state = context_provider.getWorksheetState();
2.284 - calc_head_open_ = state.isCalcHeadOpen();
2.285 - }catch(RemoteException e) {
2.286 - e.printStackTrace();
2.287 - }
2.288 - }
2.289 + /**
2.290 + * removes the button for To Worksheet. If the button does not exist so far,
2.291 + * nothing happens.
2.292 + */
2.293 + private void removeButtonToWorksheet() {
2.294 + if (!to_worksheet_visible_)
2.295 + return;
2.296 + try {
2.297 + browser_frame_rmi_.removeUIElement(new UIAction(
2.298 + EUIElement.UI_BROWSER_TO_WORKSHEET,
2.299 + EUIContext.UI_CONTEXT_BROWSER, user_language_));
2.300 + } catch (RemoteException e) {
2.301 + e.printStackTrace();
2.302 + }
2.303 + to_worksheet_visible_ = false;
2.304 + }
2.305 +
2.306 + /**
2.307 + * generates the button for To Worksheet. If the button does already exist,
2.308 + * nothing happens.
2.309 + */
2.310 + private void drawButtonToWorksheet() {
2.311 + if (to_worksheet_visible_)
2.312 + return;
2.313 + try {
2.314 + browser_frame_rmi_.addUIElement(new UIAction(
2.315 + EUIElement.UI_BROWSER_TO_WORKSHEET,
2.316 + EUIContext.UI_CONTEXT_BROWSER, user_language_));
2.317 + } catch (RemoteException e) {
2.318 + e.printStackTrace();
2.319 + }
2.320 + to_worksheet_visible_ = true;
2.321 + }
2.322 +
2.323 + /**
2.324 + * This method overrides the method in the base class and calls the method
2.325 + * of the base class. This is done, as some additional initialisations have
2.326 + * to be done with the buttons and the context.
2.327 + *
2.328 + * @param browser_frame
2.329 + * the browser frame to register
2.330 + */
2.331 + public void registerBrowserFrame(IToGUI browser_frame)
2.332 + throws RemoteException {
2.333 + super.registerBrowserFrame(browser_frame);
2.334 + initButtons();
2.335 + }
2.336 +
2.337 + private void initButtons() {
2.338 + context_on_visible_ = false;
2.339 + to_worksheet_visible_ = false;
2.340 + context_on_ = true;
2.341 + try {
2.342 + browser_frame_rmi_.addUIElement(new UIAction(
2.343 + EUIElement.UI_BROWSER_MATCH_OFF,
2.344 + EUIContext.UI_CONTEXT_BROWSER, user_language_));
2.345 + } catch (RemoteException e) {
2.346 + e.printStackTrace();
2.347 + }
2.348 + }
2.349 +
2.350 + /**
2.351 + * This method draws the buttons of the browser. Which buttons need to be
2.352 + * shown depends on three flags: context_on_ calc_head_open_ | Buttons to
2.353 + * show: ----------------------------------------------------------------- F
2.354 + * X | <Context Off> T F | <Context On> T T | <Context On> <ToWorksheet>
2.355 + *
2.356 + */
2.357 +
2.358 + protected void drawButtons() {
2.359 + if (!context_on_) {
2.360 + drawButtonContextOn();
2.361 + removeButtonToWorksheet();
2.362 + } else {
2.363 + if (!calc_head_open_) {
2.364 + drawButtonContextOff();
2.365 + removeButtonToWorksheet();
2.366 + } else {
2.367 + drawButtonContextOff();
2.368 + drawButtonToWorksheet();
2.369 + }
2.370 + }
2.371 + }
2.372 +
2.373 + /**
2.374 + * This method does the update for the two variables: worksheet_open_ and
2.375 + * calc_head_open_. An interface to the active worksheet is fetched from the
2.376 + * session. If no active worksheet exists (and null is returned) there is no
2.377 + * open worksheet. The interface returns a WorksheetState which is able to
2.378 + * tell us, if the CalcHead is open.
2.379 + */
2.380 + public void updateState() {
2.381 + try {
2.382 + IContextProvider context_provider = session_.getContextProvider();
2.383 + if (context_provider == null) {
2.384 + calc_head_open_ = false;
2.385 + return;
2.386 + }
2.387 + WorksheetState state = context_provider.getWorksheetState();
2.388 + calc_head_open_ = state.isCalcHeadOpen();
2.389 + } catch (RemoteException e) {
2.390 + e.printStackTrace();
2.391 + }
2.392 + }
2.393 }
2.394 \ No newline at end of file
3.1 --- a/src/java/isac/browserdialog/ProblemDialog.java Thu Sep 13 19:02:52 2007 +0200
3.2 +++ b/src/java/isac/browserdialog/ProblemDialog.java Fri Sep 14 19:59:16 2007 +0200
3.3 @@ -39,330 +39,307 @@
3.4 */
3.5 public class ProblemDialog extends BrowserDialog {
3.6
3.7 - /**
3.8 - * For serialization, see corresponding API Documentation; value generated
3.9 - * by eclipse to avoid a warning
3.10 - */
3.11 - private static final long serialVersionUID = 6479711601158544388L;
3.12 + /**
3.13 + * For serialization, see corresponding API Documentation; value generated
3.14 + * by eclipse to avoid a warning
3.15 + */
3.16 + private static final long serialVersionUID = 6479711601158544388L;
3.17
3.18 - /** true if the refine button is visible * */
3.19 - private boolean refine_visible_;
3.20 + /** true if the refine button is visible * */
3.21 + private boolean refine_visible_;
3.22
3.23 - /** true if the to worksheet button is visible * */
3.24 - private boolean to_worksheet_visible_;
3.25 + /** true if the to worksheet button is visible * */
3.26 + private boolean to_worksheet_visible_;
3.27
3.28 - /** true if the Context On button is visible* */
3.29 - //private boolean context_on_visible_;
3.30 -
3.31 - /** true if a worksheet is open
3.32 - * this flag is updated in updateState()
3.33 - */
3.34 - private boolean worksheet_open_;
3.35 + /** true if the Context On button is visible* */
3.36 + // private boolean context_on_visible_;
3.37 + /**
3.38 + * true if a worksheet is open this flag is updated in updateState()
3.39 + */
3.40 + private boolean worksheet_open_;
3.41
3.42 - /** true if the calc head of the active worksheet is open
3.43 - * this flag is updated in updateState()
3.44 - */
3.45 - private boolean calc_head_open_;
3.46 + /**
3.47 + * true if the calc head of the active worksheet is open this flag is
3.48 + * updated in updateState()
3.49 + */
3.50 + private boolean calc_head_open_;
3.51
3.52 - /** true if the context updating is on * */
3.53 - //private boolean context_on_;
3.54 + /** true if the context updating is on * */
3.55 + // private boolean context_on_;
3.56 + /**
3.57 + * The constructor of this class which is given the session the
3.58 + * ProblemDialog is instanciated for. We need the session to get the correct
3.59 + * WSDialogManager (and also the active WSDialog) for this BrowserDialog.
3.60 + *
3.61 + * @param session
3.62 + * @throws RemoteException
3.63 + */
3.64 + public ProblemDialog(Session session) throws RemoteException {
3.65 + super(session);
3.66 + context_type_ = ContextType.CONTEXT_PROBLEMS;
3.67
3.68 - /**
3.69 - * The constructor of this class which is given the session the
3.70 - * ProblemDialog is instanciated for. We need the session to get the correct
3.71 - * WSDialogManager (and also the active WSDialog) for this BrowserDialog.
3.72 - *
3.73 - * @param session
3.74 - * @throws RemoteException
3.75 - */
3.76 - public ProblemDialog(Session session) throws RemoteException {
3.77 - super(session);
3.78 - context_type_ = ContextType.CONTEXT_PROBLEMS;
3.79 -
3.80 - hierarchy_ = loadHierarchy(context_type_);
3.81 - current_context_ = new ContextUnknown();
3.82 - }
3.83 + hierarchy_ = loadHierarchy(context_type_);
3.84 + current_context_ = new ContextUnknown();
3.85 + }
3.86
3.87 - /**
3.88 - * Notify the ProblemDialog about events or requests triggered by the user.
3.89 - * The ProblemBrowser calls this method over RMI.
3.90 - *
3.91 - * @param action
3.92 - * What's new from the UI
3.93 - * @return true, if the event is being processed, false if processing is
3.94 - * denied or impossible
3.95 - * @throws RemoteException
3.96 - * @throws DialogProtocolException
3.97 - */
3.98 - public boolean notifyUserAction(IUserAction action)
3.99 - throws DialogProtocolException, RemoteException {
3.100 - System.out.println("ProblemDialog::notifyUserAction() action="
3.101 - + action.getActionID());
3.102 -
3.103 - if( super.notifyUserAction( action ) )
3.104 - return true;
3.105 -
3.106 - isac_logger_.logUserAction("pbl",action);
3.107 -
3.108 - switch (action.getActionID()) {
3.109 - case UI_BROWSER_MATCH_ON: {
3.110 - context_on_ = true;
3.111 - drawButtons();
3.112 - sendInitContextToBrowser();
3.113 - return true;
3.114 - }
3.115 - case UI_BROWSER_MATCH_OFF: {
3.116 - context_on_ = false;
3.117 - drawButtons();
3.118 - ContextUnknown new_context= new ContextUnknown();
3.119 - new_context.setHierarchyKey(current_context_.getHierarchyKey());
3.120 - new_context.setKEStoreKey(current_context_.getKEStoreKey());
3.121 - sendContextToBrowser(new_context);
3.122 - sendLinkToMiniBrowser(new_context,context_type_);
3.123 - return true;
3.124 - }
3.125 - case UI_PROBLEMBROWSER_REFINE: {
3.126 - sendRefinedCurrentContext();
3.127 - return true;
3.128 - }
3.129 - case UI_BROWSER_TO_WORKSHEET: {
3.130 - setCurrentContextToWorksheet();
3.131 - return true;
3.132 - }
3.133 - case UI_MINIBROWSER_LINK: {
3.134 - URL receivedLink = ((UserActionOnLink) action).getLink();
3.135 - try {
3.136 - interpretLink(receivedLink);
3.137 - return true;
3.138 - } catch (RemoteException e) {
3.139 - e.printStackTrace();
3.140 - return false;
3.141 - }
3.142 - }
3.143 - }
3.144 - return false;
3.145 - }
3.146 + /**
3.147 + * Notify the ProblemDialog about events or requests triggered by the user.
3.148 + * The ProblemBrowser calls this method over RMI.
3.149 + *
3.150 + * @param action
3.151 + * What's new from the UI
3.152 + * @return true, if the event is being processed, false if processing is
3.153 + * denied or impossible
3.154 + * @throws RemoteException
3.155 + * @throws DialogProtocolException
3.156 + */
3.157 + public boolean notifyUserAction(IUserAction action)
3.158 + throws DialogProtocolException, RemoteException {
3.159 + System.out.println("ProblemDialog::notifyUserAction() action="
3.160 + + action.getActionID());
3.161
3.162 + if (super.notifyUserAction(action))
3.163 + return true;
3.164
3.165 - /**
3.166 - * removes the button for Refine. If the button does not
3.167 - * exist so far, nothing happens.
3.168 - */
3.169 - private void removeButtonRefine() {
3.170 - if (!refine_visible_)
3.171 - return;
3.172 - try {
3.173 - browser_frame_rmi_.removeUIElement(new UIAction(
3.174 - EUIElement.UI_PROBLEMBROWSER_REFINE,
3.175 - EUIContext.UI_CONTEXT_BROWSER, user_language_));
3.176 - } catch (RemoteException e) {
3.177 - e.printStackTrace();
3.178 - }
3.179 - refine_visible_ = false;
3.180 - }
3.181 + isac_logger_.logUserAction("pbl", action);
3.182
3.183 - /**
3.184 - * creates the button for Refine. If the button does already
3.185 - * exist, nothing happens.
3.186 - */
3.187 - private void drawButtonRefine() {
3.188 - if (refine_visible_)
3.189 - return;
3.190 - try {
3.191 - browser_frame_rmi_.addUIElement(new UIAction(
3.192 - EUIElement.UI_PROBLEMBROWSER_REFINE,
3.193 - EUIContext.UI_CONTEXT_BROWSER, user_language_));
3.194 - } catch (RemoteException e) {
3.195 - e.printStackTrace();
3.196 - }
3.197 - refine_visible_ = true;
3.198 - }
3.199 + switch (action.getActionID()) {
3.200 + case UI_BROWSER_MATCH_ON: {
3.201 + context_on_ = true;
3.202 + drawButtons();
3.203 + sendInitContextToBrowser();
3.204 + return true;
3.205 + }
3.206 + case UI_BROWSER_MATCH_OFF: {
3.207 + context_on_ = false;
3.208 + drawButtons();
3.209 + ContextUnknown new_context = new ContextUnknown();
3.210 + new_context.setHierarchyKey(current_context_.getHierarchyKey());
3.211 + new_context.setKEStoreKey(current_context_.getKEStoreKey());
3.212 + sendContextToBrowser(new_context);
3.213 + sendLinkToMiniBrowser(new_context, context_type_);
3.214 + return true;
3.215 + }
3.216 + case UI_PROBLEMBROWSER_REFINE: {
3.217 + sendRefinedCurrentContext();
3.218 + return true;
3.219 + }
3.220 + case UI_BROWSER_TO_WORKSHEET: {
3.221 + setCurrentContextToWorksheet();
3.222 + return true;
3.223 + }
3.224 + case UI_MINIBROWSER_LINK: {
3.225 + URL receivedLink = ((UserActionOnLink) action).getLink();
3.226 + try {
3.227 + interpretLink(receivedLink);
3.228 + return true;
3.229 + } catch (RemoteException e) {
3.230 + e.printStackTrace();
3.231 + return false;
3.232 + }
3.233 + }
3.234 + }
3.235 + return false;
3.236 + }
3.237
3.238 - /**
3.239 - * removes the button for To Worksheet. If the button does not
3.240 - * exist so far, nothing happens.
3.241 - */
3.242 - private void removeButtonToWorksheet() {
3.243 - if (!to_worksheet_visible_)
3.244 - return;
3.245 - try {
3.246 - browser_frame_rmi_.removeUIElement(new UIAction(
3.247 - EUIElement.UI_BROWSER_TO_WORKSHEET,
3.248 - EUIContext.UI_CONTEXT_BROWSER, user_language_));
3.249 - } catch (RemoteException e) {
3.250 - e.printStackTrace();
3.251 - }
3.252 - to_worksheet_visible_ = false;
3.253 - }
3.254 + /**
3.255 + * removes the button for Refine. If the button does not exist so far,
3.256 + * nothing happens.
3.257 + */
3.258 + private void removeButtonRefine() {
3.259 + if (!refine_visible_)
3.260 + return;
3.261 + try {
3.262 + browser_frame_rmi_.removeUIElement(new UIAction(
3.263 + EUIElement.UI_PROBLEMBROWSER_REFINE,
3.264 + EUIContext.UI_CONTEXT_BROWSER, user_language_));
3.265 + } catch (RemoteException e) {
3.266 + e.printStackTrace();
3.267 + }
3.268 + refine_visible_ = false;
3.269 + }
3.270
3.271 - /**
3.272 - * generates the button for To Worksheet. If the button does
3.273 - * already exist, nothing happens.
3.274 - */
3.275 - private void drawButtonToWorksheet() {
3.276 - if (to_worksheet_visible_)
3.277 - return;
3.278 - try {
3.279 - browser_frame_rmi_.addUIElement(new UIAction(
3.280 - EUIElement.UI_BROWSER_TO_WORKSHEET,
3.281 - EUIContext.UI_CONTEXT_BROWSER, user_language_));
3.282 - } catch (RemoteException e) {
3.283 - e.printStackTrace();
3.284 - }
3.285 - to_worksheet_visible_ = true;
3.286 - }
3.287 + /**
3.288 + * creates the button for Refine. If the button does already exist, nothing
3.289 + * happens.
3.290 + */
3.291 + private void drawButtonRefine() {
3.292 + if (refine_visible_)
3.293 + return;
3.294 + try {
3.295 + browser_frame_rmi_.addUIElement(new UIAction(
3.296 + EUIElement.UI_PROBLEMBROWSER_REFINE,
3.297 + EUIContext.UI_CONTEXT_BROWSER, user_language_));
3.298 + } catch (RemoteException e) {
3.299 + e.printStackTrace();
3.300 + }
3.301 + refine_visible_ = true;
3.302 + }
3.303
3.304 - /**
3.305 - * This method overrides the method in the base class and
3.306 - * calls the method of the base class. This is done, as some
3.307 - * additional initialisations have to be done with the buttons
3.308 - * and the context.
3.309 - *
3.310 - * @param browser_frame
3.311 - * the browser frame to register
3.312 - */
3.313 - public void registerBrowserFrame(IToGUI browser_frame)
3.314 - throws RemoteException {
3.315 - super.registerBrowserFrame(browser_frame);
3.316 - initButtons();
3.317 - }
3.318 -
3.319 -
3.320 - private void initButtons() {
3.321 - context_on_visible_ = false;
3.322 - to_worksheet_visible_ = false;
3.323 - refine_visible_ = false;
3.324 - context_on_ = true;
3.325 - try {
3.326 - browser_frame_rmi_.addUIElement(new UIAction(
3.327 - EUIElement.UI_BROWSER_MATCH_OFF,
3.328 - EUIContext.UI_CONTEXT_BROWSER, user_language_));
3.329 - } catch (RemoteException e) {
3.330 - e.printStackTrace();
3.331 - }
3.332 - }
3.333 -
3.334 -
3.335 -
3.336 -
3.337 -
3.338 -
3.339 -
3.340 + /**
3.341 + * removes the button for To Worksheet. If the button does not exist so far,
3.342 + * nothing happens.
3.343 + */
3.344 + private void removeButtonToWorksheet() {
3.345 + if (!to_worksheet_visible_)
3.346 + return;
3.347 + try {
3.348 + browser_frame_rmi_.removeUIElement(new UIAction(
3.349 + EUIElement.UI_BROWSER_TO_WORKSHEET,
3.350 + EUIContext.UI_CONTEXT_BROWSER, user_language_));
3.351 + } catch (RemoteException e) {
3.352 + e.printStackTrace();
3.353 + }
3.354 + to_worksheet_visible_ = false;
3.355 + }
3.356
3.357 - /**
3.358 - * This method draws the buttons of the browser. Which buttons need
3.359 - * to be shown depends on three flags:
3.360 - * context_on_ worksheet_open_ calc_head_open_ | Buttons to show:
3.361 - * -----------------------------------------------------------------
3.362 - * F X X | <Context On>
3.363 - * T F F | <Context Off>
3.364 - * T F T | impossible
3.365 - * T T F | <Context Off> <Refine>
3.366 - * T T T | <Context Off> <Refine> <ToWorksheet>
3.367 - *
3.368 - */
3.369 + /**
3.370 + * generates the button for To Worksheet. If the button does already exist,
3.371 + * nothing happens.
3.372 + */
3.373 + private void drawButtonToWorksheet() {
3.374 + if (to_worksheet_visible_)
3.375 + return;
3.376 + try {
3.377 + browser_frame_rmi_.addUIElement(new UIAction(
3.378 + EUIElement.UI_BROWSER_TO_WORKSHEET,
3.379 + EUIContext.UI_CONTEXT_BROWSER, user_language_));
3.380 + } catch (RemoteException e) {
3.381 + e.printStackTrace();
3.382 + }
3.383 + to_worksheet_visible_ = true;
3.384 + }
3.385
3.386 - protected void drawButtons() {
3.387 - if (!context_on_) {
3.388 - drawButtonContextOn();
3.389 - removeButtonRefine();
3.390 - removeButtonToWorksheet();
3.391 - } else {
3.392 - if (!worksheet_open_ && !calc_head_open_) {
3.393 - drawButtonContextOff();
3.394 - removeButtonRefine();
3.395 - removeButtonToWorksheet();
3.396 - }
3.397 - if (worksheet_open_ && !calc_head_open_) {
3.398 - drawButtonContextOff();
3.399 - drawButtonRefine();
3.400 - removeButtonToWorksheet();
3.401 - }
3.402 - if (worksheet_open_ && calc_head_open_) {
3.403 - drawButtonContextOff();
3.404 - drawButtonRefine();
3.405 - drawButtonToWorksheet();
3.406 - }
3.407 - }
3.408 - }
3.409 - /**
3.410 - * This method does the update for the two variables:
3.411 - * worksheet_open_ and calc_head_open_. An interface to the
3.412 - * active worksheet is fetched from the session. If no active
3.413 - * worksheet exists (and null is returned) there is no open
3.414 - * worksheet. The interface returns a WorksheetState which is
3.415 - * able to tell us, if the CalcHead is open.
3.416 - */
3.417 - public void updateState() {
3.418 + /**
3.419 + * This method overrides the method in the base class and calls the method
3.420 + * of the base class. This is done, as some additional initialisations have
3.421 + * to be done with the buttons and the context.
3.422 + *
3.423 + * @param browser_frame
3.424 + * the browser frame to register
3.425 + */
3.426 + public void registerBrowserFrame(IToGUI browser_frame)
3.427 + throws RemoteException {
3.428 + super.registerBrowserFrame(browser_frame);
3.429 + initButtons();
3.430 + }
3.431
3.432 - try {
3.433 - IContextProvider context_provider = session_.getContextProvider();
3.434 - if(context_provider == null) {
3.435 - worksheet_open_ = false;
3.436 - calc_head_open_ = false;
3.437 - return;
3.438 - }
3.439 - worksheet_open_ = true;
3.440 - WorksheetState state = context_provider.getWorksheetState();
3.441 - calc_head_open_ = state.isCalcHeadOpen();
3.442 - }catch(RemoteException e) {
3.443 - e.printStackTrace();
3.444 - }
3.445 - }
3.446 -
3.447 + private void initButtons() {
3.448 + context_on_visible_ = false;
3.449 + to_worksheet_visible_ = false;
3.450 + refine_visible_ = false;
3.451 + context_on_ = true;
3.452 + try {
3.453 + browser_frame_rmi_.addUIElement(new UIAction(
3.454 + EUIElement.UI_BROWSER_MATCH_OFF,
3.455 + EUIContext.UI_CONTEXT_BROWSER, user_language_));
3.456 + } catch (RemoteException e) {
3.457 + e.printStackTrace();
3.458 + }
3.459 + }
3.460
3.461 + /**
3.462 + * This method draws the buttons of the browser. Which buttons need to be
3.463 + * shown depends on three flags: context_on_ worksheet_open_ calc_head_open_ |
3.464 + * Buttons to show:
3.465 + * ----------------------------------------------------------------- F X X |
3.466 + * <Context On> T F F | <Context Off> T F T | impossible T T F | <Context
3.467 + * Off> <Refine> T T T | <Context Off> <Refine> <ToWorksheet>
3.468 + *
3.469 + */
3.470
3.471 - /**
3.472 - * This method takes the current context and asks the active Worksheet
3.473 - * to refine it. This is done over the IContextProvider interface.
3.474 - * The active Worksheet returns a refined context, which is then
3.475 - * shown in the browser. There must be a ContextProvider when this
3.476 - * method is called. If there would not be any active worksheet, the
3.477 - * button <Refine> would not be available.
3.478 - */
3.479 - private void sendRefinedCurrentContext() {
3.480 - //real implementation:
3.481 -
3.482 - Context refined_context = current_context_;
3.483 - try {
3.484 - IContextProvider context_provider = session_.getContextProvider();
3.485 - if(context_provider == null)
3.486 - return;
3.487 - refined_context = context_provider.refineContext(current_context_);
3.488 - sendContextToBrowser(refined_context);
3.489 - sendLinkToMiniBrowser(refined_context,context_type_);
3.490 - }catch(RemoteException e) {
3.491 - e.printStackTrace();
3.492 - }
3.493 + protected void drawButtons() {
3.494 + if (!context_on_) {
3.495 + drawButtonContextOn();
3.496 + removeButtonRefine();
3.497 + removeButtonToWorksheet();
3.498 + } else {
3.499 + if (!worksheet_open_ && !calc_head_open_) {
3.500 + drawButtonContextOff();
3.501 + removeButtonRefine();
3.502 + removeButtonToWorksheet();
3.503 + }
3.504 + if (worksheet_open_ && !calc_head_open_) {
3.505 + drawButtonContextOff();
3.506 + drawButtonRefine();
3.507 + removeButtonToWorksheet();
3.508 + }
3.509 + if (worksheet_open_ && calc_head_open_) {
3.510 + drawButtonContextOff();
3.511 + drawButtonRefine();
3.512 + drawButtonToWorksheet();
3.513 + }
3.514 + }
3.515 + }
3.516
3.517 - // dummy implementation for test purposes while initContext() is not
3.518 - //implemented in WorksheetDialog:
3.519 - /*
3.520 - HierarchyKey item_to_select = new HierarchyKey();
3.521 + /**
3.522 + * This method does the update for the two variables: worksheet_open_ and
3.523 + * calc_head_open_. An interface to the active worksheet is fetched from the
3.524 + * session. If no active worksheet exists (and null is returned) there is no
3.525 + * open worksheet. The interface returns a WorksheetState which is able to
3.526 + * tell us, if the CalcHead is open.
3.527 + */
3.528 + public void updateState() {
3.529
3.530 - item_to_select.addString("rat");
3.531 - item_to_select.addString("sq");
3.532 - item_to_select.addString("root");
3.533 - item_to_select.addString("univariate");
3.534 - item_to_select.addString("equation");
3.535 + try {
3.536 + IContextProvider context_provider = session_.getContextProvider();
3.537 + if (context_provider == null) {
3.538 + worksheet_open_ = false;
3.539 + calc_head_open_ = false;
3.540 + return;
3.541 + }
3.542 + worksheet_open_ = true;
3.543 + WorksheetState state = context_provider.getWorksheetState();
3.544 + calc_head_open_ = state.isCalcHeadOpen();
3.545 + } catch (RemoteException e) {
3.546 + e.printStackTrace();
3.547 + }
3.548 + }
3.549
3.550 - TreePath tree_path = hierarchy_.getPath(item_to_select.getID());
3.551 - HierarchyNode node_to_select = (HierarchyNode) tree_path
3.552 - .getLastPathComponent();
3.553 - Random a = new Random();
3.554 - Context context = null;
3.555 - int rand = a.nextInt(5);
3.556 - if (rand > 2) {
3.557 - context = current_context_;
3.558 - } else {
3.559 - context = new Context();
3.560 - context.setHierarchyKey(item_to_select);
3.561 - context.setHierarchyNode(node_to_select);
3.562 - }
3.563 - sendContextToBrowser(context);
3.564 - sendLinkToMiniBrowser(context,context_type_);
3.565 - */
3.566 - //end Experimantation:
3.567 - }
3.568 + /**
3.569 + * This method takes the current context and asks the active Worksheet to
3.570 + * refine it. This is done over the IContextProvider interface. The active
3.571 + * Worksheet returns a refined context, which is then shown in the browser.
3.572 + * There must be a ContextProvider when this method is called. If there
3.573 + * would not be any active worksheet, the button <Refine> would not be
3.574 + * available.
3.575 + */
3.576 + private void sendRefinedCurrentContext() {
3.577 + // real implementation:
3.578 +
3.579 + Context refined_context = current_context_;
3.580 + try {
3.581 + IContextProvider context_provider = session_.getContextProvider();
3.582 + if (context_provider == null)
3.583 + return;
3.584 + refined_context = context_provider.refineContext(current_context_);
3.585 + sendContextToBrowser(refined_context);
3.586 + sendLinkToMiniBrowser(refined_context, context_type_);
3.587 + } catch (RemoteException e) {
3.588 + e.printStackTrace();
3.589 + }
3.590 +
3.591 + // dummy implementation for test purposes while initContext() is not
3.592 + // implemented in WorksheetDialog:
3.593 + /*
3.594 + * HierarchyKey item_to_select = new HierarchyKey();
3.595 + *
3.596 + * item_to_select.addString("rat"); item_to_select.addString("sq");
3.597 + * item_to_select.addString("root");
3.598 + * item_to_select.addString("univariate");
3.599 + * item_to_select.addString("equation");
3.600 + *
3.601 + * TreePath tree_path = hierarchy_.getPath(item_to_select.getID());
3.602 + * HierarchyNode node_to_select = (HierarchyNode) tree_path
3.603 + * .getLastPathComponent(); Random a = new Random(); Context context =
3.604 + * null; int rand = a.nextInt(5); if (rand > 2) { context =
3.605 + * current_context_; } else { context = new Context();
3.606 + * context.setHierarchyKey(item_to_select);
3.607 + * context.setHierarchyNode(node_to_select); }
3.608 + * sendContextToBrowser(context);
3.609 + * sendLinkToMiniBrowser(context,context_type_);
3.610 + */
3.611 + // end Experimantation:
3.612 + }
3.613
3.614 }
4.1 --- a/src/java/isac/browserdialog/TheoryDialog.java Thu Sep 13 19:02:52 2007 +0200
4.2 +++ b/src/java/isac/browserdialog/TheoryDialog.java Fri Sep 14 19:59:16 2007 +0200
4.3 @@ -38,213 +38,207 @@
4.4 */
4.5 public class TheoryDialog extends BrowserDialog {
4.6
4.7 - /**
4.8 - * For serialization, see corresponding API Documentation; value generated
4.9 - * by eclipse to avoid a warning
4.10 - */
4.11 - private static final long serialVersionUID = 6479711601158544388L;
4.12 + /**
4.13 + * For serialization, see corresponding API Documentation; value generated
4.14 + * by eclipse to avoid a warning
4.15 + */
4.16 + private static final long serialVersionUID = 6479711601158544388L;
4.17
4.18 - /** true if the <To Worksheet> button is visible * */
4.19 - private boolean to_worksheet_visible_;
4.20 + /** true if the <To Worksheet> button is visible * */
4.21 + private boolean to_worksheet_visible_;
4.22
4.23 - /** true if the <Context On> button is visible* */
4.24 - //private boolean context_on_visible_;
4.25 -
4.26 - /** true if the calc head of the active worksheet is open
4.27 - * this flag is updated in updateState()
4.28 - */
4.29 - private boolean calc_head_open_;
4.30 -
4.31 - /** true if a worksheet is open
4.32 - * this flag is updated in updateState()
4.33 - */
4.34 - private boolean worksheet_open_;
4.35 + /** true if the <Context On> button is visible* */
4.36 + // private boolean context_on_visible_;
4.37 + /**
4.38 + * true if the calc head of the active worksheet is open this flag is
4.39 + * updated in updateState()
4.40 + */
4.41 + private boolean calc_head_open_;
4.42
4.43 - /**
4.44 - * The constructor of this class which is given the session the
4.45 - * TheoryDialog is instanciated for. We need the session to get the correct
4.46 - * WSDialogManager (and also the active WSDialog) for this BrowserDialog.
4.47 - *
4.48 - * @param session
4.49 - * @throws RemoteException
4.50 - */
4.51 - public TheoryDialog(Session session) throws RemoteException {
4.52 - super(session);
4.53 - context_type_ = ContextType.CONTEXT_THEORIES;
4.54 -
4.55 - hierarchy_ = loadHierarchy(context_type_);
4.56 - current_context_ = new ContextUnknown();
4.57 - }
4.58 + /**
4.59 + * true if a worksheet is open this flag is updated in updateState()
4.60 + */
4.61 + private boolean worksheet_open_;
4.62
4.63 - /**
4.64 - * Notify the TheoryDialog about events or requests triggered by the user.
4.65 - * The TheoryBrowser calls this method over RMI.
4.66 - *
4.67 - * @param action
4.68 - * What's new from the UI
4.69 - * @return true, if the event is being processed, false if processing is
4.70 - * denied or impossible
4.71 - * @throws RemoteException
4.72 - * @throws DialogProtocolException
4.73 - */
4.74 - public boolean notifyUserAction(IUserAction action)
4.75 - throws DialogProtocolException, RemoteException {
4.76 - System.out.println("TheoryDialog::notifyUserAction() action="
4.77 - + action.getActionID());
4.78 - if( super.notifyUserAction( action ) )
4.79 - return true;
4.80 -
4.81 - isac_logger_.logUserAction("thy",action);
4.82 + /**
4.83 + * The constructor of this class which is given the session the TheoryDialog
4.84 + * is instanciated for. We need the session to get the correct
4.85 + * WSDialogManager (and also the active WSDialog) for this BrowserDialog.
4.86 + *
4.87 + * @param session
4.88 + * @throws RemoteException
4.89 + */
4.90 + public TheoryDialog(Session session) throws RemoteException {
4.91 + super(session);
4.92 + context_type_ = ContextType.CONTEXT_THEORIES;
4.93
4.94 - switch (action.getActionID()) {
4.95 - case UI_BROWSER_MATCH_ON: {
4.96 - context_on_ = true;
4.97 - drawButtons();
4.98 - sendInitContextToBrowser();
4.99 - return true;
4.100 - }
4.101 - case UI_BROWSER_MATCH_OFF: {
4.102 - context_on_ = false;
4.103 - drawButtons();
4.104 - ContextUnknown new_context= new ContextUnknown();
4.105 - new_context.setHierarchyKey(current_context_.getHierarchyKey());
4.106 - new_context.setKEStoreKey(current_context_.getKEStoreKey());
4.107 - sendContextToBrowser(new_context);
4.108 - sendLinkToMiniBrowser(new_context,context_type_);
4.109 - return true;
4.110 - }
4.111 - case UI_BROWSER_TO_WORKSHEET: {
4.112 - setCurrentContextToWorksheet();
4.113 - return true;
4.114 - }
4.115 - case UI_MINIBROWSER_LINK: {
4.116 - URL receivedLink = ((UserActionOnLink) action).getLink();
4.117 - try {
4.118 - interpretLink(receivedLink);
4.119 - return true;
4.120 - } catch (RemoteException e) {
4.121 - e.printStackTrace();
4.122 - return false;
4.123 - }
4.124 - }
4.125 - }
4.126 - return false;
4.127 - }
4.128 + hierarchy_ = loadHierarchy(context_type_);
4.129 + current_context_ = new ContextUnknown();
4.130 + }
4.131
4.132 + /**
4.133 + * Notify the TheoryDialog about events or requests triggered by the user.
4.134 + * The TheoryBrowser calls this method over RMI.
4.135 + *
4.136 + * @param action
4.137 + * What's new from the UI
4.138 + * @return true, if the event is being processed, false if processing is
4.139 + * denied or impossible
4.140 + * @throws RemoteException
4.141 + * @throws DialogProtocolException
4.142 + */
4.143 + public boolean notifyUserAction(IUserAction action)
4.144 + throws DialogProtocolException, RemoteException {
4.145 + System.out.println("TheoryDialog::notifyUserAction() action="
4.146 + + action.getActionID());
4.147 + if (super.notifyUserAction(action))
4.148 + return true;
4.149
4.150 - /**
4.151 - * removes the button for To Worksheet. If the button does not
4.152 - * exist so far, nothing happens.
4.153 - */
4.154 - private void removeButtonToWorksheet() {
4.155 - if (!to_worksheet_visible_)
4.156 - return;
4.157 - try {
4.158 - browser_frame_rmi_.removeUIElement(new UIAction(
4.159 - EUIElement.UI_BROWSER_TO_WORKSHEET,
4.160 - EUIContext.UI_CONTEXT_BROWSER, user_language_));
4.161 - } catch (RemoteException e) {
4.162 - e.printStackTrace();
4.163 - }
4.164 - to_worksheet_visible_ = false;
4.165 - }
4.166 + isac_logger_.logUserAction("thy", action);
4.167
4.168 - /**
4.169 - * generates the button for To Worksheet. If the button does
4.170 - * already exist, nothing happens.
4.171 - */
4.172 - private void drawButtonToWorksheet() {
4.173 - if (to_worksheet_visible_)
4.174 - return;
4.175 - try {
4.176 - browser_frame_rmi_.addUIElement(new UIAction(
4.177 - EUIElement.UI_BROWSER_TO_WORKSHEET,
4.178 - EUIContext.UI_CONTEXT_BROWSER, user_language_));
4.179 - } catch (RemoteException e) {
4.180 - e.printStackTrace();
4.181 - }
4.182 - to_worksheet_visible_ = true;
4.183 - }
4.184 + switch (action.getActionID()) {
4.185 + case UI_BROWSER_MATCH_ON: {
4.186 + context_on_ = true;
4.187 + drawButtons();
4.188 + sendInitContextToBrowser();
4.189 + return true;
4.190 + }
4.191 + case UI_BROWSER_MATCH_OFF: {
4.192 + context_on_ = false;
4.193 + drawButtons();
4.194 + ContextUnknown new_context = new ContextUnknown();
4.195 + new_context.setHierarchyKey(current_context_.getHierarchyKey());
4.196 + new_context.setKEStoreKey(current_context_.getKEStoreKey());
4.197 + sendContextToBrowser(new_context);
4.198 + sendLinkToMiniBrowser(new_context, context_type_);
4.199 + return true;
4.200 + }
4.201 + case UI_BROWSER_TO_WORKSHEET: {
4.202 + setCurrentContextToWorksheet();
4.203 + return true;
4.204 + }
4.205 + case UI_MINIBROWSER_LINK: {
4.206 + URL receivedLink = ((UserActionOnLink) action).getLink();
4.207 + try {
4.208 + interpretLink(receivedLink);
4.209 + return true;
4.210 + } catch (RemoteException e) {
4.211 + e.printStackTrace();
4.212 + return false;
4.213 + }
4.214 + }
4.215 + }
4.216 + return false;
4.217 + }
4.218
4.219 - /**
4.220 - * This method overrides the method in the base class and
4.221 - * calls the method of the base class. This is done, as some
4.222 - * additional initialisations have to be done with the buttons
4.223 - * and the context.
4.224 - *
4.225 - * @param browser_frame
4.226 - * the browser frame to register
4.227 - */
4.228 - public void registerBrowserFrame(IToGUI browser_frame)
4.229 - throws RemoteException {
4.230 - super.registerBrowserFrame(browser_frame);
4.231 - initButtons();
4.232 - }
4.233 -
4.234 - private void initButtons() {
4.235 - context_on_visible_ = false;
4.236 - to_worksheet_visible_ = false;
4.237 - context_on_ = true;
4.238 - try {
4.239 - browser_frame_rmi_.addUIElement(new UIAction(
4.240 - EUIElement.UI_BROWSER_MATCH_OFF,
4.241 - EUIContext.UI_CONTEXT_BROWSER, user_language_));
4.242 - } catch (RemoteException e) {
4.243 - e.printStackTrace();
4.244 - }
4.245 - }
4.246 + /**
4.247 + * removes the button for To Worksheet. If the button does not exist so far,
4.248 + * nothing happens.
4.249 + */
4.250 + private void removeButtonToWorksheet() {
4.251 + if (!to_worksheet_visible_)
4.252 + return;
4.253 + try {
4.254 + browser_frame_rmi_.removeUIElement(new UIAction(
4.255 + EUIElement.UI_BROWSER_TO_WORKSHEET,
4.256 + EUIContext.UI_CONTEXT_BROWSER, user_language_));
4.257 + } catch (RemoteException e) {
4.258 + e.printStackTrace();
4.259 + }
4.260 + to_worksheet_visible_ = false;
4.261 + }
4.262
4.263 - /**
4.264 - * This method draws the buttons of the browser. Which buttons need
4.265 - * to be shown depends on three flags:
4.266 - * context_on_ worksheet_open_ calc_head_open_ | Buttons to show:
4.267 - * -----------------------------------------------------------------
4.268 - * F X X | <Context Off>
4.269 - * T F F | <Context On>
4.270 - * T F T | impossible
4.271 - * T T F | <Context On> <ToWorksheet>
4.272 - * T T T | <Context On>
4.273 - *
4.274 - */
4.275 + /**
4.276 + * generates the button for To Worksheet. If the button does already exist,
4.277 + * nothing happens.
4.278 + */
4.279 + private void drawButtonToWorksheet() {
4.280 + if (to_worksheet_visible_)
4.281 + return;
4.282 + try {
4.283 + browser_frame_rmi_.addUIElement(new UIAction(
4.284 + EUIElement.UI_BROWSER_TO_WORKSHEET,
4.285 + EUIContext.UI_CONTEXT_BROWSER, user_language_));
4.286 + } catch (RemoteException e) {
4.287 + e.printStackTrace();
4.288 + }
4.289 + to_worksheet_visible_ = true;
4.290 + }
4.291
4.292 - protected void drawButtons() {
4.293 - if (!context_on_) {
4.294 - drawButtonContextOn();
4.295 - removeButtonToWorksheet();
4.296 - } else {
4.297 - if (worksheet_open_ && !calc_head_open_) {
4.298 - drawButtonContextOff();
4.299 - drawButtonToWorksheet();
4.300 - }
4.301 - else {
4.302 - drawButtonContextOff();
4.303 - removeButtonToWorksheet();
4.304 - }
4.305 - }
4.306 - }
4.307 - /**
4.308 - * This method does the update for the two variables:
4.309 - * worksheet_open_ and calc_head_open_. An interface to the
4.310 - * active worksheet is fetched from the session. If no active
4.311 - * worksheet exists (and null is returned) there is no open
4.312 - * worksheet. The interface returns a WorksheetState which is
4.313 - * able to tell us, if the CalcHead is open.
4.314 - */
4.315 - public void updateState() {
4.316 + /**
4.317 + * This method overrides the method in the base class and calls the method
4.318 + * of the base class. This is done, as some additional initialisations have
4.319 + * to be done with the buttons and the context.
4.320 + *
4.321 + * @param browser_frame
4.322 + * the browser frame to register
4.323 + */
4.324 + public void registerBrowserFrame(IToGUI browser_frame)
4.325 + throws RemoteException {
4.326 + super.registerBrowserFrame(browser_frame);
4.327 + initButtons();
4.328 + }
4.329
4.330 - try {
4.331 - IContextProvider context_provider = session_.getContextProvider();
4.332 - if(context_provider == null) {
4.333 - worksheet_open_ = false;
4.334 - calc_head_open_ = false;
4.335 - return;
4.336 - }
4.337 - worksheet_open_ = true;
4.338 - WorksheetState state = context_provider.getWorksheetState();
4.339 - calc_head_open_ = state.isCalcHeadOpen();
4.340 - }catch(RemoteException e) {
4.341 - e.printStackTrace();
4.342 - }
4.343 - }
4.344 -
4.345 + private void initButtons() {
4.346 + context_on_visible_ = false;
4.347 + to_worksheet_visible_ = false;
4.348 + context_on_ = true;
4.349 + try {
4.350 + browser_frame_rmi_.addUIElement(new UIAction(
4.351 + EUIElement.UI_BROWSER_MATCH_OFF,
4.352 + EUIContext.UI_CONTEXT_BROWSER, user_language_));
4.353 + } catch (RemoteException e) {
4.354 + e.printStackTrace();
4.355 + }
4.356 + }
4.357 +
4.358 + /**
4.359 + * This method draws the buttons of the browser. Which buttons need to be
4.360 + * shown depends on three flags: context_on_ worksheet_open_ calc_head_open_ |
4.361 + * Buttons to show:
4.362 + * ----------------------------------------------------------------- F X X |
4.363 + * <Context Off> T F F | <Context On> T F T | impossible T T F | <Context
4.364 + * On> <ToWorksheet> T T T | <Context On>
4.365 + *
4.366 + */
4.367 +
4.368 + protected void drawButtons() {
4.369 + if (!context_on_) {
4.370 + drawButtonContextOn();
4.371 + removeButtonToWorksheet();
4.372 + } else {
4.373 + if (worksheet_open_ && !calc_head_open_) {
4.374 + drawButtonContextOff();
4.375 + drawButtonToWorksheet();
4.376 + } else {
4.377 + drawButtonContextOff();
4.378 + removeButtonToWorksheet();
4.379 + }
4.380 + }
4.381 + }
4.382 +
4.383 + /**
4.384 + * This method does the update for the two variables: worksheet_open_ and
4.385 + * calc_head_open_. An interface to the active worksheet is fetched from the
4.386 + * session. If no active worksheet exists (and null is returned) there is no
4.387 + * open worksheet. The interface returns a WorksheetState which is able to
4.388 + * tell us, if the CalcHead is open.
4.389 + */
4.390 + public void updateState() {
4.391 +
4.392 + try {
4.393 + IContextProvider context_provider = session_.getContextProvider();
4.394 + if (context_provider == null) {
4.395 + worksheet_open_ = false;
4.396 + calc_head_open_ = false;
4.397 + return;
4.398 + }
4.399 + worksheet_open_ = true;
4.400 + WorksheetState state = context_provider.getWorksheetState();
4.401 + calc_head_open_ = state.isCalcHeadOpen();
4.402 + } catch (RemoteException e) {
4.403 + e.printStackTrace();
4.404 + }
4.405 + }
4.406 +
4.407 }
4.408 \ No newline at end of file
5.1 --- a/src/java/isac/users/UserLogger.java Thu Sep 13 19:02:52 2007 +0200
5.2 +++ b/src/java/isac/users/UserLogger.java Fri Sep 14 19:59:16 2007 +0200
5.3 @@ -162,12 +162,12 @@
5.4 * This works under the assumption that there is <em>no</em> overlap
5.5 * between UserActions on different <code>Worksheets</code>.
5.6 *
5.7 - * @param <paramname>
5.8 - * <paramdescription>
5.9 - * @return <return value>
5.10 - * @exception <exception>
5.11 - * <description when it is thrown>
5.12 - * @see <fully.qualified.Classname#methodName(param-classes)>
5.13 + * @param dialog
5.14 + * "worksheet" | "exp" | "thy" | "pbl" | "met"
5.15 + * @param worksheet_id
5.16 + * is "" for "exp" & "thy" & "pbl" & "met"
5.17 + * @param action
5.18 + * IUserAction | "LO_START_SESSION" ... | "LO_OPEN_WORKSHEET"
5.19 */
5.20 public void logUserAction(String dialog, IUserAction action) {
5.21 switch (action.getActionID()) {
5.22 @@ -177,12 +177,13 @@
5.23 String action_name;
5.24 String argument;
5.25 if (isStartExp((UserActionOnLink) action)) {
5.26 - action_name = "LO_START_EXAMPLE";
5.27 + action_name = "LO_OPEN_WORKSHEET";
5.28 } else {
5.29 action_name = action.getActionID().name();
5.30 }
5.31 current_step_.setAction(user_.getUsername(), session_id_, dialog,
5.32 - action_name, "TODO link.xml", null/* subst */);
5.33 + action_name, kestoreKeyOf(((UserActionOnLink) action).getLink()
5.34 + .toString()), null/* subst */);
5.35 // TOOODO if context then current_step_ completed in
5.36 // UserLogger#logContext???
5.37 // else currentStepToDatabase() !
5.38 @@ -202,6 +203,23 @@
5.39 }
5.40 }
5.41
5.42 + public void logCloseWorksheet(String worksheet_id,
5.43 + boolean calculation_finished_successfully) {
5.44 + if (!calculation_finished_successfully) {
5.45 + current_step_.setAction(user_.getUsername(), session_id_,
5.46 + "worksheet", "LO_STOP_EXAMPLE", null, null);
5.47 + current_step_.setResult(worksheet_id, null, null, null, new Float(
5.48 + 0.0));
5.49 + currentStepToDatabase();
5.50 + current_step_.reset();
5.51 + }
5.52 + current_step_.setAction(user_.getUsername(), session_id_, "worksheet",
5.53 + isac.useractions.EUIElement.UI_CLOSE_WORKSHEET.name(), null,
5.54 + null);
5.55 + current_step_.setResult(worksheet_id, null, null, null, null);
5.56 + currentStepToDatabase();
5.57 + }
5.58 +
5.59 /**
5.60 * Complete a <code>UserRecord</code> initialized in
5.61 * <code>logUserAction</code> with the related data returned from the
5.62 @@ -253,8 +271,8 @@
5.63 if (end_of_calculation) {
5.64 current_step_.setAction(user_.getUsername(), session_id_,
5.65 "worksheet", "LO_STOP_EXAMPLE", null, null);
5.66 - current_step_.setResult(worksheet_id, null, null, formula_to,
5.67 - new Float(1.0));// TODO use SuccessInfo not 1.0
5.68 + current_step_.setResult(worksheet_id, null, null, null, new Float(
5.69 + 1.0));// TODO use SuccessInfo not 1.0
5.70 currentStepToDatabase();
5.71 }
5.72 }
6.1 --- a/src/java/isac/wsdialog/WorksheetDialog.java Thu Sep 13 19:02:52 2007 +0200
6.2 +++ b/src/java/isac/wsdialog/WorksheetDialog.java Fri Sep 14 19:59:16 2007 +0200
6.3 @@ -49,1044 +49,1108 @@
6.4 * @author Manuel Koschuch
6.5 */
6.6 public class WorksheetDialog extends UnicastRemoteObject implements
6.7 - IWorksheetDialog, IToUser, Serializable,IContextProvider {
6.8 + IWorksheetDialog, IToUser, Serializable, IContextProvider {
6.9
6.10 - static final long serialVersionUID = 4952921581668118572L;
6.11 -
6.12 - private static final Logger logger = Logger.getLogger(WorksheetDialog.class.getName());
6.13 + static final long serialVersionUID = 4952921581668118572L;
6.14
6.15 - protected MathEngine math_engine_;
6.16 + private static final Logger logger = Logger.getLogger(WorksheetDialog.class
6.17 + .getName());
6.18
6.19 - protected CalcTree calc_tree_;
6.20 + protected MathEngine math_engine_;
6.21
6.22 - /**
6.23 - * The active formula in the mathematic engine
6.24 - */
6.25 - protected ICalcIterator active_formula_;
6.26 -
6.27 - /**
6.28 - * Represents the formula on which the context depends.
6.29 - * It is the last selected formula in the worksheet or
6.30 - * the active formula from the mathematic engine
6.31 - *
6.32 - */
6.33 - protected ICalcIterator context_formula_;
6.34 -
6.35 - protected Session session_;
6.36 + protected CalcTree calc_tree_;
6.37
6.38 - /**
6.39 - * determines if the calculation on the worksheet is ready
6.40 - */
6.41 - protected boolean worksheet_ready_;
6.42 + /**
6.43 + * The active formula in the mathematic engine
6.44 + */
6.45 + protected ICalcIterator active_formula_;
6.46
6.47 - protected int phase_;
6.48 + /**
6.49 + * Represents the formula on which the context depends. It is the last
6.50 + * selected formula in the worksheet or the active formula from the
6.51 + * mathematic engine
6.52 + *
6.53 + */
6.54 + protected ICalcIterator context_formula_;
6.55
6.56 - private Vector<IToUser> datachange_listeners_;
6.57 + protected Session session_;
6.58
6.59 - private IToGUI ui_control_listener_;
6.60 + /**
6.61 + * determines if the calculation on the worksheet is ready
6.62 + */
6.63 + protected boolean worksheet_ready_;
6.64
6.65 - protected String worksheet_id_;
6.66 + protected int phase_;
6.67
6.68 - protected UserSettings user_settings_;// hold whole hashmap locally
6.69 + private boolean calculation_finished_successfully_;
6.70
6.71 - protected ISessionManager session_manager_;
6.72 + private Vector<IToUser> datachange_listeners_;
6.73
6.74 - protected UserLanguage user_language_;
6.75 -
6.76 - protected UserLogger isac_logger_;
6.77 -
6.78 - /**
6.79 - * @param ME_path
6.80 - * URL of the math engine to be used
6.81 - * @param user_path
6.82 - * path(without URL) to UserSettings, UserModel
6.83 - * @param session_dialog
6.84 - * @param session_id
6.85 - * which create the WorksheetDialog and Worksheet
6.86 - * @throws RemoteException
6.87 - */
6.88 - public WorksheetDialog(String ME_path, Session session, String worksheet_id, Formalization f)
6.89 - throws RemoteException {
6.90 - initialise( ME_path, session, worksheet_id, f );
6.91 - }
6.92 -
6.93 - public WorksheetDialog(String ME_path, Session session, String worksheet_id)
6.94 - throws RemoteException {
6.95 - initialise( ME_path, session, worksheet_id, new Formalization() );
6.96 - }
6.97 -
6.98 - void initialise( String ME_path, Session session, String worksheet_id, Formalization f ) throws RemoteException {
6.99 - this.rmiBind();
6.100 - datachange_listeners_ = new Vector<IToUser>();
6.101 -
6.102 - MathEngine.init(ME_path);
6.103 - math_engine_ = MathEngine.getMathEngine();
6.104 -
6.105 - phase_ = DIALOGPHASE_IDLE;
6.106 + private IToGUI ui_control_listener_;
6.107
6.108 - session_ = session;
6.109 -
6.110 - User user = null;
6.111 -
6.112 - user = UserManager.getInstance().getUser(session.getId());
6.113 -
6.114 - user_settings_ = user.getUserSettings();
6.115 - user_language_ = user.getLanguage();
6.116 -
6.117 - worksheet_id_ = worksheet_id;
6.118 + protected String worksheet_id_;
6.119
6.120 - session_manager_ = SessionManager.getInstance();
6.121 -
6.122 - isac_logger_ = session_.getIsacLogger();
6.123 -
6.124 - getCalcTree( f );
6.125 - }
6.126 + protected UserSettings user_settings_;// hold whole hashmap locally
6.127
6.128 - public String getWorksheetID() {
6.129 - return worksheet_id_;
6.130 - }
6.131 + protected ISessionManager session_manager_;
6.132
6.133 - public CalcTree getCalcTree() {
6.134 - return calc_tree_;
6.135 - }
6.136 -
6.137 - /**
6.138 - * start a calculation
6.139 - */
6.140 - public void getCalcTree( Formalization f ) {
6.141 - // do administrative stuff
6.142 - calc_tree_ = math_engine_.getCalcTree(f);
6.143 - calc_tree_.addDataChangeListener(this);
6.144 + protected UserLanguage user_language_;
6.145
6.146 - switch (user_settings_.getValue(IUserSettings.KEY1_START_SPECIFY)) {
6.147 - case IUserSettings.VAL1_SKIP_SPECIFY_TO_START_SOLVE:
6.148 - phase_ = DIALOGPHASE_SOLVE;
6.149 - break;
6.150 - case IUserSettings.VAL1_POP_CALCHEAD_WITH_DESCRIPTIONS:
6.151 - phase_ = DIALOGPHASE_SPECIFY;
6.152 - break;
6.153 - }
6.154 + protected UserLogger isac_logger_;
6.155
6.156 - return;
6.157 - }
6.158 + /**
6.159 + * @param ME_path
6.160 + * URL of the math engine to be used
6.161 + * @param user_path
6.162 + * path(without URL) to UserSettings, UserModel
6.163 + * @param session_dialog
6.164 + * @param session_id
6.165 + * which create the WorksheetDialog and Worksheet
6.166 + * @throws RemoteException
6.167 + */
6.168 + public WorksheetDialog(String ME_path, Session session,
6.169 + String worksheet_id, Formalization f) throws RemoteException {
6.170 + initialise(ME_path, session, worksheet_id, f);
6.171 + }
6.172
6.173 - /**
6.174 - * enter the specifying-phase; 2 cases: (1) at the beginning of a
6.175 - * calculation as well as of a subproblem; sets the Descriptions in the
6.176 - * Model (to support user-input) and in CAS-commands completes the Model.
6.177 - * (2) for inspection of a "correct" CalcHead somewhere above the
6.178 - * activeFormula; in this case the CalcHead is not updated, it is just the
6.179 - * starting point into the math-knowledge.
6.180 - *
6.181 - * @return CalcHead eg. for providing CalcHead#VIEWSTYLE_*
6.182 - *
6.183 - * @see isac.wsdialog.IWorksheetDialog#startSpecifying()
6.184 - */
6.185 - private void startSpecifying(CalcHead calc_head) {
6.186 - phase_ = DIALOGPHASE_SPECIFY;
6.187 - try {
6.188 - // remove solving buttons
6.189 - removeNextAndAutoButtonForWorksheet();
6.190 - if (calc_head.getStatusString().equals("incorrect")) {
6.191 - // case (1)
6.192 - // -----------------------------------------------------------
6.193 - // if you think, modelProblem should only set the descriptions
6.194 - // in the Model (and NOT complete it for CAS-commands)
6.195 - // search the sml-code for WN060225-modelProblem
6.196 - calc_head = calc_tree_.modelProblem();
6.197 - // -----------------------------------------------------------
6.198 - doUIAction(new UIActionOnCalcElement(EUIElement.UI_SPECIFY_OPEN_CALCHEAD,
6.199 - EUIContext.UI_CONTEXT_SWITCH_PHASES, user_language_, calc_head));
6.200 - addCalcHeadPanelButtons();
6.201 - addNextAndAutoButtonsForCalchead();
6.202 + public WorksheetDialog(String ME_path, Session session, String worksheet_id)
6.203 + throws RemoteException {
6.204 + initialise(ME_path, session, worksheet_id, new Formalization());
6.205 + }
6.206
6.207 - } else {// case (2)
6.208 - // only Button Close
6.209 - doUIAction(new UIActionOnCalcElement(EUIElement.UI_SPECIFY_OPEN_CALCHEAD,
6.210 - EUIContext.UI_CONTEXT_SWITCH_PHASES, user_language_, calc_head));
6.211 - ui_control_listener_.addUIElement(new UIAction(
6.212 - EUIElement.UI_SPECIFY_CLOSE_CALCHEAD,
6.213 - EUIContext.UI_CONTEXT_CALCHEAD, user_language_));
6.214 - addNextAndAutoButtonForWorksheet();
6.215 - }
6.216 + void initialise(String ME_path, Session session, String worksheet_id,
6.217 + Formalization f) throws RemoteException {
6.218 + this.rmiBind();
6.219 + datachange_listeners_ = new Vector<IToUser>();
6.220
6.221 - } catch (RemoteException e) {
6.222 - e.printStackTrace();
6.223 - }
6.224 + MathEngine.init(ME_path);
6.225 + math_engine_ = MathEngine.getMathEngine();
6.226
6.227 - }
6.228 + phase_ = DIALOGPHASE_IDLE;
6.229
6.230 - /**
6.231 - * @see isac.wsdialog.IWorksheetDialog#startCalculate()
6.232 - */
6.233 - public void startCalculate() {
6.234 - calc_tree_.startCalculate();
6.235 - }
6.236 + session_ = session;
6.237
6.238 - /**
6.239 - * dismiss the CalcHeadPanel and start WorksheetDialog#DIALOGPHASE_SOLVE
6.240 - *
6.241 - * @see isac.interfaces.IToCalc#startSolving()
6.242 - */
6.243 - private void startSolving() {
6.244 - try {
6.245 - removeCalcHeadPanelButtons();
6.246 - removeNextAndAutoButtonsForCalchead();
6.247 - addNextAndAutoButtonForWorksheet();
6.248 + User user = null;
6.249
6.250 - } catch (RemoteException e) {
6.251 - e.printStackTrace();
6.252 - }
6.253 - phase_ = DIALOGPHASE_SOLVE;
6.254 - }
6.255 + user = UserManager.getInstance().getUser(session.getId());
6.256
6.257 - private void buildUIElementsContextCalcElements() {
6.258 - try {
6.259 - // ui_control_listener_.addUIElement(new UIAction(
6.260 - // UI_SOLVE_GET_APPLICABLE_TACTICS,
6.261 - // EUIContext.UI_CONTEXT_CALCELEMENTS));
6.262 - ui_control_listener_.addUIElement(new UIAction(EUIElement.UI_SOLVE_SHOW_ASSUMPTIONS,
6.263 - EUIContext.UI_CONTEXT_CALCELEMENTS, user_language_));
6.264 - ui_control_listener_
6.265 - .addUIElement(new UIAction(EUIElement.UI_SOLVE_TACTIC_APPLIED,
6.266 - EUIContext.UI_CONTEXT_CALCELEMENTS, user_language_));
6.267 - ui_control_listener_.addUIElement(new UIAction(EUIElement.UI_SOLVE_SHOW_INTERMEDIATE_STEPS,
6.268 - EUIContext.UI_CONTEXT_CALCELEMENTS, user_language_));
6.269 - } catch (RemoteException e) {
6.270 - e.printStackTrace();
6.271 - }
6.272 - }
6.273 + user_settings_ = user.getUserSettings();
6.274 + user_language_ = user.getLanguage();
6.275
6.276 - private void addNextAndAutoButtonForWorksheet() throws RemoteException {
6.277 - // Button next
6.278 - ui_control_listener_.addUIElement(new UIAction(EUIElement.UI_SOLVE_CALCULATE_1,
6.279 - EUIContext.UI_CONTEXT_CALCULATION, user_language_));
6.280 - // Button auto
6.281 - ui_control_listener_.addUIElement(new UIAction(EUIElement.UI_SOLVE_CALCULATE_ALL,
6.282 - EUIContext.UI_CONTEXT_CALCULATION, user_language_));
6.283 - }
6.284 + worksheet_id_ = worksheet_id;
6.285
6.286 - private void removeNextAndAutoButtonForWorksheet() throws RemoteException {
6.287 - // Button next
6.288 - ui_control_listener_.removeUIElement(new UIAction(EUIElement.UI_SOLVE_CALCULATE_1,
6.289 - EUIContext.UI_CONTEXT_CALCULATION, user_language_));
6.290 - // Button auto
6.291 - ui_control_listener_.removeUIElement(new UIAction(EUIElement.UI_SOLVE_CALCULATE_ALL, EUIContext.UI_CONTEXT_CALCULATION, user_language_));
6.292 + session_manager_ = SessionManager.getInstance();
6.293
6.294 - }
6.295 + isac_logger_ = session_.getIsacLogger();
6.296
6.297 - private void addCalcHeadPanelButtons() throws RemoteException {
6.298 - // Button Complete
6.299 - ui_control_listener_.addUIElement(new UIAction(EUIElement.UI_SPECIFY_COMPLETE_CALCHEAD, EUIContext.UI_CONTEXT_CALCHEAD, user_language_));
6.300 - // // Button Check
6.301 - // ui_control_listener_.addUIElement(new UIAction(
6.302 - // UI_SPECIFY_CHECK_CALCHEAD, EUIContext.UI_CONTEXT_CALCHEAD));
6.303 - // Button reset
6.304 - ui_control_listener_.addUIElement(new UIAction(EUIElement.UI_SPECIFY_RESET,
6.305 - EUIContext.UI_CONTEXT_CALCHEAD, user_language_));
6.306 - // Button Start Solving
6.307 - ui_control_listener_.addUIElement(new UIAction(EUIElement.UI_SPECIFY_TO_SOLVE,
6.308 - EUIContext.UI_CONTEXT_CALCHEAD, user_language_));
6.309 + getCalcTree(f);
6.310 + }
6.311
6.312 - }
6.313 + public String getWorksheetID() {
6.314 + return worksheet_id_;
6.315 + }
6.316
6.317 - private void removeCalcHeadPanelButtons() throws RemoteException {
6.318 - // Button Complete
6.319 - ui_control_listener_.removeUIElement(new UIAction(EUIElement.UI_SPECIFY_COMPLETE_CALCHEAD, EUIContext.UI_CONTEXT_CALCHEAD,user_language_));
6.320 - // Button Start Solving
6.321 - ui_control_listener_.removeUIElement(new UIAction(EUIElement.UI_SPECIFY_TO_SOLVE,
6.322 - EUIContext.UI_CONTEXT_CALCHEAD,user_language_));
6.323 - // // Button Check
6.324 - // ui_control_listener_.removeUIElement(new UIAction(
6.325 - // UI_SPECIFY_CHECK_CALCHEAD, EUIContext.UI_CONTEXT_CALCHEAD));
6.326 - // Button reset
6.327 - ui_control_listener_.removeUIElement(new UIAction(EUIElement.UI_SPECIFY_RESET,
6.328 - EUIContext.UI_CONTEXT_CALCHEAD,user_language_));
6.329 - }
6.330 + public CalcTree getCalcTree() {
6.331 + return calc_tree_;
6.332 + }
6.333
6.334 - /**
6.335 - * add next and auto Button to WindowApplication
6.336 - */
6.337 - // Context Calculation is used instead of context calchead,
6.338 - // because buttons have to be added to windowapplication and not to
6.339 - // calcheadpanel
6.340 - private void addNextAndAutoButtonsForCalchead() {
6.341 - try {
6.342 - // add next Button
6.343 - ui_control_listener_.addUIElement(new UIAction(EUIElement.UI_SPECIFY_COMPLETE_STEPWISE,
6.344 - EUIContext.UI_CONTEXT_CALCULATION, user_language_ ) );
6.345 - // add auto Button
6.346 - ui_control_listener_
6.347 - .addUIElement(new UIAction(EUIElement.UI_SPECIFY_CALCULATE_ALL,
6.348 - EUIContext.UI_CONTEXT_CALCULATION, user_language_ ) );
6.349 - } catch (RemoteException e) {
6.350 - e.printStackTrace();
6.351 - }
6.352 - }
6.353 + /**
6.354 + * start a calculation
6.355 + */
6.356 + public void getCalcTree(Formalization f) {
6.357 + // do administrative stuff
6.358 + calc_tree_ = math_engine_.getCalcTree(f);
6.359 + calc_tree_.addDataChangeListener(this);
6.360
6.361 - /**
6.362 - *
6.363 - */
6.364 - private void removeNextAndAutoButtonsForCalchead() {
6.365 + switch (user_settings_.getValue(IUserSettings.KEY1_START_SPECIFY)) {
6.366 + case IUserSettings.VAL1_SKIP_SPECIFY_TO_START_SOLVE:
6.367 + phase_ = DIALOGPHASE_SOLVE;
6.368 + break;
6.369 + case IUserSettings.VAL1_POP_CALCHEAD_WITH_DESCRIPTIONS:
6.370 + phase_ = DIALOGPHASE_SPECIFY;
6.371 + break;
6.372 + }
6.373
6.374 - // Context Calculation is used instead of context calchead,
6.375 - // because buttons have to be added to windowapplication and not to
6.376 - // calcheadpanel
6.377 - try {
6.378 - // add next Button
6.379 - ui_control_listener_.removeUIElement(new UIAction(EUIElement.UI_SPECIFY_COMPLETE_STEPWISE,
6.380 - EUIContext.UI_CONTEXT_CALCULATION, user_language_) );
6.381 - // add auto Button
6.382 - ui_control_listener_
6.383 - .removeUIElement(new UIAction(EUIElement.UI_SPECIFY_CALCULATE_ALL,
6.384 - EUIContext.UI_CONTEXT_CALCULATION, user_language_ ) );
6.385 - } catch (RemoteException e) {
6.386 - e.printStackTrace();
6.387 - }
6.388 - }
6.389 + return;
6.390 + }
6.391
6.392 - /**
6.393 - * accept the changes in a calculation reported by the bridge
6.394 - *
6.395 - * ... and pass them to the Worksheet
6.396 - *
6.397 - * @see isac.wsdialog.IToUser#calcChanged(isac.wsdialog.CalcChangedEvent)
6.398 - */
6.399 - public void calcChanged(CalcChangedEvent event) throws RemoteException {
6.400 - worksheet_ready_ = false;
6.401 - if(logger.isInfoEnabled())
6.402 - logger.info(" WS<-. . : calcChanged (unc="
6.403 - + event.getLastUnchangedFormula().toSMLString() + ", del="
6.404 - + event.getLastDeletedFormula().toSMLString() + ", gen="
6.405 - + event.getLastGeneratedFormula().toSMLString());
6.406 - try {
6.407 - for (int i = 0; i < datachange_listeners_.size(); i++) {
6.408 - CalcChangedEvent wrappedEvent = new CalcChangedEvent(event
6.409 - .getTransactionId(), event.isCompleted(),
6.410 - new DialogIterator((CalcIterator) event
6.411 - .getLastUnchangedFormula(), this),
6.412 - new DialogIterator((CalcIterator) event
6.413 - .getLastDeletedFormula(), this),
6.414 - new DialogIterator((CalcIterator) event
6.415 - .getLastGeneratedFormula(), this));
6.416 - ((IToUser) datachange_listeners_.elementAt(i))
6.417 - .calcChanged(wrappedEvent);
6.418 - }
6.419 - } catch (Exception e) {
6.420 - e.printStackTrace();
6.421 - }
6.422 - addUIElementsContextOneElement(event);
6.423 -
6.424 - active_formula_ = event.getLastGeneratedFormula();
6.425 -
6.426 - context_formula_ = (ICalcIterator) event.getLastGeneratedFormula().cloneIterator();
6.427 -
6.428 - isac_logger_.logCalcChanged(worksheet_id_, event);
6.429 -
6.430 - updateContextFormulaOnWorksheet( context_formula_ );
6.431 -
6.432 - notifyContextPresenter();
6.433 -
6.434 - if (active_formula_.onCalcHead()) {
6.435 - switch (user_settings_.getValue("KEY1_START_SPECIFY")) {
6.436 - case IUserSettings.VAL1_SKIP_SPECIFY_TO_START_SOLVE:
6.437 - // WN050728
6.438 - // instead calc_tree_.autoCalculate(IToCalc.SCOPE_CALCULATION,
6.439 - // 1);
6.440 - // ...NEW Model_Problem (inserting Descriptions into the Model)
6.441 - // without causing CalcChangedEvent (would loop in calcChanged!)
6.442 - startSolving();
6.443 - break;
6.444 - case IUserSettings.VAL1_POP_CALCHEAD_WITH_DESCRIPTIONS:
6.445 - startSpecifying((CalcHead) active_formula_.getElement());
6.446 - break;
6.447 - default:
6.448 - try {
6.449 - throw new Exception("WorksheetDialog#calcChanged:switch"
6.450 - + " (user_settings_.getValue(KEY1_START_SPECIFY)");
6.451 - } catch (Exception e1) {
6.452 - e1.printStackTrace();
6.453 - }
6.454 - }
6.455 - }
6.456 - }
6.457 + /**
6.458 + * enter the specifying-phase; 2 cases: (1) at the beginning of a
6.459 + * calculation as well as of a subproblem; sets the Descriptions in the
6.460 + * Model (to support user-input) and in CAS-commands completes the Model.
6.461 + * (2) for inspection of a "correct" CalcHead somewhere above the
6.462 + * activeFormula; in this case the CalcHead is not updated, it is just the
6.463 + * starting point into the math-knowledge.
6.464 + *
6.465 + * @return CalcHead eg. for providing CalcHead#VIEWSTYLE_*
6.466 + *
6.467 + * @see isac.wsdialog.IWorksheetDialog#startSpecifying()
6.468 + */
6.469 + private void startSpecifying(CalcHead calc_head) {
6.470 + phase_ = DIALOGPHASE_SPECIFY;
6.471 + try {
6.472 + // remove solving buttons
6.473 + removeNextAndAutoButtonForWorksheet();
6.474 + if (calc_head.getStatusString().equals("incorrect")) {
6.475 + // case (1)
6.476 + // -----------------------------------------------------------
6.477 + // if you think, modelProblem should only set the descriptions
6.478 + // in the Model (and NOT complete it for CAS-commands)
6.479 + // search the sml-code for WN060225-modelProblem
6.480 + calc_head = calc_tree_.modelProblem();
6.481 + // -----------------------------------------------------------
6.482 + doUIAction(new UIActionOnCalcElement(
6.483 + EUIElement.UI_SPECIFY_OPEN_CALCHEAD,
6.484 + EUIContext.UI_CONTEXT_SWITCH_PHASES, user_language_,
6.485 + calc_head));
6.486 + addCalcHeadPanelButtons();
6.487 + addNextAndAutoButtonsForCalchead();
6.488
6.489 - /**
6.490 - * construct the context-menu on one specific calcelement (e.g. with
6.491 - * 'Calchead' and without)
6.492 - *
6.493 - */
6.494 - private void addUIElementsContextOneElement(CalcChangedEvent event) {
6.495 - ICalcIterator from = event.getLastUnchangedFormula();
6.496 - ICalcIterator to = event.getLastGeneratedFormula();
6.497 -
6.498 - Vector calc_formulae = null;
6.499 + } else {// case (2)
6.500 + // only Button Close
6.501 + doUIAction(new UIActionOnCalcElement(
6.502 + EUIElement.UI_SPECIFY_OPEN_CALCHEAD,
6.503 + EUIContext.UI_CONTEXT_SWITCH_PHASES, user_language_,
6.504 + calc_head));
6.505 + ui_control_listener_.addUIElement(new UIAction(
6.506 + EUIElement.UI_SPECIFY_CLOSE_CALCHEAD,
6.507 + EUIContext.UI_CONTEXT_CALCHEAD, user_language_));
6.508 + addNextAndAutoButtonForWorksheet();
6.509 + }
6.510
6.511 - try {
6.512 - calc_formulae = from.getFormulaeFromTo( to, new Integer(0), false );
6.513 - } catch (RemoteException e1) {
6.514 - e1.printStackTrace();
6.515 - }
6.516 + } catch (RemoteException e) {
6.517 + e.printStackTrace();
6.518 + }
6.519
6.520 - if( calc_formulae == null )
6.521 - return;
6.522 -
6.523 - Iterator vector_it = calc_formulae.iterator();
6.524 -
6.525 - while( vector_it.hasNext() ) {
6.526 - CalcFormula cf = (CalcFormula) vector_it.next();
6.527 -
6.528 - if( cf.getPosition().getKind().equals("Pbl")
6.529 - || cf.getPosition().getKind().equals("Met") ) {
6.530 - try {
6.531 - ui_control_listener_.addUIElement(new UIAction(
6.532 - EUIElement.UI_SOLVE_SHOW_CALCHEAD,
6.533 - EUIContext.UI_CONTEXT_ONEELEMENT,
6.534 - cf.getPosition(), user_language_
6.535 - )
6.536 - );
6.537 - } catch (RemoteException e) {
6.538 - e.printStackTrace();
6.539 - }
6.540 - }
6.541 - }
6.542 - }
6.543 + }
6.544
6.545 - /***
6.546 - * This method sends the applicable tactics to the specific item
6.547 - * in the worksheet determined by the Position of the iterator
6.548 - *
6.549 - * @param it
6.550 - */
6.551 - private void sendApplicableTacticsToWorksheet(ICalcIterator it) {
6.552 - try {
6.553 - Vector tactics = it.getApplicableTactics(ICalcIterator.TACTICS_ALL);
6.554 + /**
6.555 + * @see isac.wsdialog.IWorksheetDialog#startCalculate()
6.556 + */
6.557 + public void startCalculate() {
6.558 + calc_tree_.startCalculate();
6.559 + }
6.560
6.561 - if (tactics != null) {
6.562 - for (int i = 0; i < tactics.size(); i++)
6.563 - ui_control_listener_
6.564 - .addUIElement(new UIActionOnCalcElement(EUIElement.UI_SOLVE_SET_NEXT_TACTIC,
6.565 - EUIContext.UI_CONTEXT_APPLICABLE_TACTIC, user_language_, it
6.566 - .getPosition(), (Tactic) tactics
6.567 - .get(i)));
6.568 - }
6.569 - } catch (RemoteException e) {
6.570 - e.printStackTrace();
6.571 - }
6.572 - }
6.573 -
6.574 - private void updateContextFormulaOnWorksheet(ICalcIterator it) {
6.575 - if (ui_control_listener_ != null)
6.576 - try {
6.577 - ui_control_listener_.doUIAction(
6.578 - new UIAction(
6.579 - EUIElement.UI_SOLVE_CHANGE_CONTEXT_FORMULA,
6.580 - EUIContext.UI_CONTEXT_ONEELEMENT,
6.581 - it.getPosition(), user_language_
6.582 - )
6.583 - );
6.584 - } catch (RemoteException e) {
6.585 - e.printStackTrace();
6.586 - }
6.587 - }
6.588 + /**
6.589 + * dismiss the CalcHeadPanel and start WorksheetDialog#DIALOGPHASE_SOLVE
6.590 + *
6.591 + * @see isac.interfaces.IToCalc#startSolving()
6.592 + */
6.593 + private void startSolving() {
6.594 + try {
6.595 + removeCalcHeadPanelButtons();
6.596 + removeNextAndAutoButtonsForCalchead();
6.597 + addNextAndAutoButtonForWorksheet();
6.598
6.599 - /**
6.600 - * @see isac.wsdialog.IWorksheetDialog#iterator(CalcIterator,
6.601 - * IWorksheetDialog)
6.602 - * @see isac.interfaces.IToCalc#iterator()
6.603 - */
6.604 - public ICalcIterator iterator(CalcIterator it, IWorksheetDialog dg) {
6.605 - try {
6.606 - return new DialogIterator(it, dg);
6.607 - } catch (RemoteException e) {
6.608 - e.printStackTrace();
6.609 - }
6.610 - return null;
6.611 - }
6.612 + } catch (RemoteException e) {
6.613 + e.printStackTrace();
6.614 + }
6.615 + phase_ = DIALOGPHASE_SOLVE;
6.616 + }
6.617
6.618 - /**
6.619 - * @see isac.wsdialog.IToCalc#addListener(isac.wsdialog.IToUser)
6.620 - */
6.621 - public boolean addDataChangeListener(IToUser listener)
6.622 - throws RemoteException {
6.623 - if (datachange_listeners_.contains(listener)) {
6.624 - return false;
6.625 - } else {
6.626 - datachange_listeners_.add(listener);
6.627 - }
6.628 - return true;
6.629 - }
6.630 + private void buildUIElementsContextCalcElements() {
6.631 + try {
6.632 + // ui_control_listener_.addUIElement(new UIAction(
6.633 + // UI_SOLVE_GET_APPLICABLE_TACTICS,
6.634 + // EUIContext.UI_CONTEXT_CALCELEMENTS));
6.635 + ui_control_listener_.addUIElement(new UIAction(
6.636 + EUIElement.UI_SOLVE_SHOW_ASSUMPTIONS,
6.637 + EUIContext.UI_CONTEXT_CALCELEMENTS, user_language_));
6.638 + ui_control_listener_.addUIElement(new UIAction(
6.639 + EUIElement.UI_SOLVE_TACTIC_APPLIED,
6.640 + EUIContext.UI_CONTEXT_CALCELEMENTS, user_language_));
6.641 + ui_control_listener_.addUIElement(new UIAction(
6.642 + EUIElement.UI_SOLVE_SHOW_INTERMEDIATE_STEPS,
6.643 + EUIContext.UI_CONTEXT_CALCELEMENTS, user_language_));
6.644 + } catch (RemoteException e) {
6.645 + e.printStackTrace();
6.646 + }
6.647 + }
6.648
6.649 - public boolean registerUIControlListener(IToGUI listener)
6.650 - throws RemoteException {
6.651 - ui_control_listener_ = listener;
6.652 - buildUIElementsContextCalcElements();
6.653 - return true;
6.654 - }
6.655 + private void addNextAndAutoButtonForWorksheet() throws RemoteException {
6.656 + // Button next
6.657 + ui_control_listener_.addUIElement(new UIAction(
6.658 + EUIElement.UI_SOLVE_CALCULATE_1,
6.659 + EUIContext.UI_CONTEXT_CALCULATION, user_language_));
6.660 + // Button auto
6.661 + ui_control_listener_.addUIElement(new UIAction(
6.662 + EUIElement.UI_SOLVE_CALCULATE_ALL,
6.663 + EUIContext.UI_CONTEXT_CALCULATION, user_language_));
6.664 + }
6.665
6.666 - /**
6.667 - * Notify the Dialog Guide about interaction from the User DO NOT MODIFY THE
6.668 - * SEQUENCE OF THE CASE BLOCKS IN THE SWITCH STATEMENTS!!
6.669 - *
6.670 - * @param action
6.671 - * @return true, if the action has been processed, false if the processing
6.672 - * the action has been denied
6.673 - * @throws RemoteException
6.674 - *
6.675 - */
6.676 - public boolean notifyUserAction(IUserAction action)
6.677 - throws DialogProtocolException, RemoteException {
6.678 - EUIElement request = action.getActionID();
6.679 - CalcHead calc_head = new CalcHead();
6.680 - CalcHead ch_to_check = new CalcHead();
6.681 + private void removeNextAndAutoButtonForWorksheet() throws RemoteException {
6.682 + // Button next
6.683 + ui_control_listener_.removeUIElement(new UIAction(
6.684 + EUIElement.UI_SOLVE_CALCULATE_1,
6.685 + EUIContext.UI_CONTEXT_CALCULATION, user_language_));
6.686 + // Button auto
6.687 + ui_control_listener_.removeUIElement(new UIAction(
6.688 + EUIElement.UI_SOLVE_CALCULATE_ALL,
6.689 + EUIContext.UI_CONTEXT_CALCULATION, user_language_));
6.690
6.691 - if(logger.isInfoEnabled())
6.692 - logger.info(" WS->DG: notifyUserAction request= " + request);
6.693 - System.out.println(" WS->DG: notifyUserAction request= " + request);
6.694 + }
6.695
6.696 - isac_logger_.logUserAction("worksheet",action);
6.697 -
6.698 - /// the requests that do not depend on the phase
6.699 - switch( request ) {
6.700 - case UI_CLOSE_WORKSHEET:
6.701 - calc_tree_.destruct();
6.702 - session_.getWSDialogManager().closeWSDialog(worksheet_id_);
6.703 - if( session_.getWSDialogManager().numberOpenedWSDialoges() == 0 )
6.704 - removeNextAndAutoButtonForWorksheet();
6.705 - IContextPresenter bdg = session_.getContextPresenter();
6.706 - ContextUnknown context_unknown = new ContextUnknown();
6.707 - bdg.presentContext( context_unknown );
6.708 - return true;
6.709 - case UI_ACTIVE_WORKSHEET:
6.710 - session_.getWSDialogManager().setActiveWSDialog( worksheet_id_ );
6.711 - notifyContextPresenter();
6.712 - return true;
6.713 - }
6.714 + private void addCalcHeadPanelButtons() throws RemoteException {
6.715 + // Button Complete
6.716 + ui_control_listener_.addUIElement(new UIAction(
6.717 + EUIElement.UI_SPECIFY_COMPLETE_CALCHEAD,
6.718 + EUIContext.UI_CONTEXT_CALCHEAD, user_language_));
6.719 + // // Button Check
6.720 + // ui_control_listener_.addUIElement(new UIAction(
6.721 + // UI_SPECIFY_CHECK_CALCHEAD, EUIContext.UI_CONTEXT_CALCHEAD));
6.722 + // Button reset
6.723 + ui_control_listener_.addUIElement(new UIAction(
6.724 + EUIElement.UI_SPECIFY_RESET, EUIContext.UI_CONTEXT_CALCHEAD,
6.725 + user_language_));
6.726 + // Button Start Solving
6.727 + ui_control_listener_.addUIElement(new UIAction(
6.728 + EUIElement.UI_SPECIFY_TO_SOLVE, EUIContext.UI_CONTEXT_CALCHEAD,
6.729 + user_language_));
6.730
6.731 - switch (phase_) {
6.732 - case DIALOGPHASE_IDLE:
6.733 - throw new DialogProtocolException(request, phase_);
6.734 - case DIALOGPHASE_SPECIFY:
6.735 - if (request.ordinal() < EUIElement.UI_DUMMY_FIRST_SPECIFY.ordinal()
6.736 - || request.ordinal() > EUIElement.UI_DUMMY_LAST_SPECIFY.ordinal())
6.737 - throw new DialogProtocolException(request, phase_);
6.738 - break;
6.739 - case DIALOGPHASE_SOLVE:
6.740 - if (request.ordinal() < EUIElement.UI_DUMMY_FIRST_SOLVE.ordinal()
6.741 - || request.ordinal() > EUIElement.UI_DUMMY_LAST_SOLVE.ordinal() )
6.742 - throw new DialogProtocolException(request, phase_);
6.743 - break;
6.744 - }
6.745 + }
6.746
6.747 - // *********** handle IUserAction's **********************
6.748 + private void removeCalcHeadPanelButtons() throws RemoteException {
6.749 + // Button Complete
6.750 + ui_control_listener_.removeUIElement(new UIAction(
6.751 + EUIElement.UI_SPECIFY_COMPLETE_CALCHEAD,
6.752 + EUIContext.UI_CONTEXT_CALCHEAD, user_language_));
6.753 + // Button Start Solving
6.754 + ui_control_listener_.removeUIElement(new UIAction(
6.755 + EUIElement.UI_SPECIFY_TO_SOLVE, EUIContext.UI_CONTEXT_CALCHEAD,
6.756 + user_language_));
6.757 + // // Button Check
6.758 + // ui_control_listener_.removeUIElement(new UIAction(
6.759 + // UI_SPECIFY_CHECK_CALCHEAD, EUIContext.UI_CONTEXT_CALCHEAD));
6.760 + // Button reset
6.761 + ui_control_listener_.removeUIElement(new UIAction(
6.762 + EUIElement.UI_SPECIFY_RESET, EUIContext.UI_CONTEXT_CALCHEAD,
6.763 + user_language_));
6.764 + }
6.765
6.766 - switch (request) {
6.767 - // in solve-phase request open a CalcHead by context-menu
6.768 - case UI_SOLVE_SHOW_CALCHEAD:
6.769 - calc_head = (CalcHead) context_formula_.getElement();
6.770 - // calc_head = (CalcHead) ((UserActionOnIterator) action)
6.771 - // .getPosition().getElement();
6.772 - startSpecifying(calc_head);
6.773 - //FIXXME RK 060712 here was: problem_browser_dialog_.setContext(worksheet_id_);
6.774 - break;
6.775 + /**
6.776 + * add next and auto Button to WindowApplication
6.777 + */
6.778 + // Context Calculation is used instead of context calchead,
6.779 + // because buttons have to be added to windowapplication and not to
6.780 + // calcheadpanel
6.781 + private void addNextAndAutoButtonsForCalchead() {
6.782 + try {
6.783 + // add next Button
6.784 + ui_control_listener_.addUIElement(new UIAction(
6.785 + EUIElement.UI_SPECIFY_COMPLETE_STEPWISE,
6.786 + EUIContext.UI_CONTEXT_CALCULATION, user_language_));
6.787 + // add auto Button
6.788 + ui_control_listener_.addUIElement(new UIAction(
6.789 + EUIElement.UI_SPECIFY_CALCULATE_ALL,
6.790 + EUIContext.UI_CONTEXT_CALCULATION, user_language_));
6.791 + } catch (RemoteException e) {
6.792 + e.printStackTrace();
6.793 + }
6.794 + }
6.795
6.796 - // Enter pressed after typing formula
6.797 - case UI_SPECIFY_EDIT_ACTIVE_FORMULA_COMPLETE:
6.798 - ch_to_check = (CalcHead) ((UserActionOnCalcElement) action)
6.799 - .getCalcElement();
6.800 - calc_head = calc_tree_.checkCalcHead(ch_to_check);
6.801 - doUIAction(new UIActionOnCalcElement(EUIElement.UI_SPECIFY_CHECK_CALCHEAD,
6.802 - EUIContext.UI_CONTEXT_CALCHEAD, user_language_, calc_head));
6.803 - break;
6.804 + /**
6.805 + *
6.806 + */
6.807 + private void removeNextAndAutoButtonsForCalchead() {
6.808
6.809 - // Complete pressed
6.810 - case UI_SPECIFY_COMPLETE_CALCHEAD:
6.811 - if (!calc_head.isComplete()) {
6.812 - calc_head = calc_tree_.completeCalcHead();
6.813 - doUIAction(new UIActionOnCalcElement(EUIElement.UI_SPECIFY_COMPLETE_CALCHEAD,
6.814 - EUIContext.UI_CONTEXT_CALCHEAD, user_language_, calc_head));
6.815 - }
6.816 - break;
6.817 - // Radiobutton for Method/Problem clicked
6.818 -// case UI_SPECIFY_TOGGLE_METHOD_PROBLEM:
6.819 -// System.out.println("toggle");
6.820 -// // WN050830 use UI_SPECIFY_SWITCH_TO_GUARD and
6.821 -// // UI_SPECIFY_SWITCH_TO_MODEL instead,
6.822 -// // and use some of this code ...
6.823 -// // ICalcIterator ci = calc_tree_.getActiveFormula();
6.824 -// // ci.switchToGuard();
6.825 -// // CalcHead ch = (CalcHead) ci.getElement();
6.826 -// //
6.827 -// // TODO MK add code here to get new CalcHead with either Met or Pbl
6.828 -// // Elements
6.829 -//
6.830 -// // ch_to_check = (CalcHead) ((UserActionOnCalcElement) action)
6.831 -// // .getCalcElement();
6.832 -// // calc_head = calc_tree_.checkCalcHead(ch_to_check);
6.833 -// // doUIAction(new UIActionOnCalcElement(EUIElement.UI_SPECIFY_CHECK_CALCHEAD,
6.834 -// // EUIContext.UI_CONTEXT_CALCHEAD, user_language_, user_language_, calc_head));
6.835 -// break;
6.836 + // Context Calculation is used instead of context calchead,
6.837 + // because buttons have to be added to windowapplication and not to
6.838 + // calcheadpanel
6.839 + try {
6.840 + // add next Button
6.841 + ui_control_listener_.removeUIElement(new UIAction(
6.842 + EUIElement.UI_SPECIFY_COMPLETE_STEPWISE,
6.843 + EUIContext.UI_CONTEXT_CALCULATION, user_language_));
6.844 + // add auto Button
6.845 + ui_control_listener_.removeUIElement(new UIAction(
6.846 + EUIElement.UI_SPECIFY_CALCULATE_ALL,
6.847 + EUIContext.UI_CONTEXT_CALCULATION, user_language_));
6.848 + } catch (RemoteException e) {
6.849 + e.printStackTrace();
6.850 + }
6.851 + }
6.852
6.853 - case UI_SPECIFY_METHOD:
6.854 - case UI_SPECIFY_THEORY:
6.855 - case UI_SPECIFY_PROBLEM:
6.856 - case UI_SPECIFY_COMPLETE_GIVEN:
6.857 - case UI_SPECIFY_COMPLETE_FIND:
6.858 - case UI_SPECIFY_COMPLETE_RELATE:
6.859 - throw new DialogNotImplementedException(request, phase_);
6.860 + /**
6.861 + * accept the changes in a calculation reported by the bridge
6.862 + *
6.863 + * ... and pass them to the Worksheet
6.864 + *
6.865 + * @see isac.wsdialog.IToUser#calcChanged(isac.wsdialog.CalcChangedEvent)
6.866 + */
6.867 + public void calcChanged(CalcChangedEvent event) throws RemoteException {
6.868 + worksheet_ready_ = false;
6.869 + if (logger.isInfoEnabled())
6.870 + logger.info(" WS<-. . : calcChanged (unc="
6.871 + + event.getLastUnchangedFormula().toSMLString() + ", del="
6.872 + + event.getLastDeletedFormula().toSMLString() + ", gen="
6.873 + + event.getLastGeneratedFormula().toSMLString());
6.874 + try {
6.875 + for (int i = 0; i < datachange_listeners_.size(); i++) {
6.876 + CalcChangedEvent wrappedEvent = new CalcChangedEvent(event
6.877 + .getTransactionId(), event.isCompleted(),
6.878 + new DialogIterator((CalcIterator) event
6.879 + .getLastUnchangedFormula(), this),
6.880 + new DialogIterator((CalcIterator) event
6.881 + .getLastDeletedFormula(), this),
6.882 + new DialogIterator((CalcIterator) event
6.883 + .getLastGeneratedFormula(), this));
6.884 + ((IToUser) datachange_listeners_.elementAt(i))
6.885 + .calcChanged(wrappedEvent);
6.886 + }
6.887 + } catch (Exception e) {
6.888 + e.printStackTrace();
6.889 + }
6.890 + addUIElementsContextOneElement(event);
6.891
6.892 - // check pressed
6.893 - case UI_SPECIFY_CHECK_CALCHEAD:
6.894 - ch_to_check = (CalcHead) ((UserActionOnCalcElement) action)
6.895 - .getCalcElement();
6.896 - calc_head = calc_tree_.checkCalcHead(ch_to_check);
6.897 - doUIAction(new UIActionOnCalcElement(EUIElement.UI_SPECIFY_CHECK_CALCHEAD,
6.898 - EUIContext.UI_CONTEXT_CALCHEAD, user_language_, calc_head));
6.899 - break;
6.900 + active_formula_ = event.getLastGeneratedFormula();
6.901 + if (!event.getLastGeneratedFormula().onCalcHead())
6.902 + //a calculation cannot finish with a CalcHead
6.903 + calculation_finished_successfully_ = ((CalcFormula) (event
6.904 + .getLastGeneratedFormula().getElement())).getPosition()
6.905 + .onEndOfCalculation();
6.906
6.907 - // next pressed
6.908 - case UI_SPECIFY_COMPLETE_STEPWISE:
6.909 - if (!calc_head.isComplete()) {
6.910 - calc_head = calc_tree_.nextSpecify();
6.911 - doUIAction(new UIActionOnCalcElement(EUIElement.UI_SPECIFY_COMPLETE_STEPWISE,
6.912 - EUIContext.UI_CONTEXT_CALCHEAD, user_language_, calc_head));
6.913 - }
6.914 - break;
6.915 + context_formula_ = (ICalcIterator) event.getLastGeneratedFormula()
6.916 + .cloneIterator();
6.917
6.918 - // close pressed
6.919 - case UI_SPECIFY_CLOSE_CALCHEAD:
6.920 - // this action is enabled _ONLY_ if the Panel was opened read-only
6.921 - // on a complete CalcHead just for inspection
6.922 - doUIAction(new UIAction(EUIElement.UI_SPECIFY_CLOSE_CALCHEAD,
6.923 - EUIContext.UI_CONTEXT_SWITCH_PHASES, user_language_ ));
6.924 - phase_ = DIALOGPHASE_SOLVE;
6.925 - //FIXXME RK 060712 here was: problem_browser_dialog_.setContext("");
6.926 - break;
6.927 + isac_logger_.logCalcChanged(worksheet_id_, event);
6.928
6.929 - // reset pressed
6.930 - case UI_SPECIFY_RESET:
6.931 - calc_tree_.resetCalcHead();
6.932 - calc_head = calc_tree_.modelProblem();
6.933 - doUIAction(new UIActionOnCalcElement(EUIElement.UI_SPECIFY_RESET,
6.934 - EUIContext.UI_CONTEXT_CALCHEAD, user_language_, calc_head));
6.935 - break;
6.936 + updateContextFormulaOnWorksheet(context_formula_);
6.937
6.938 - // start solving pressed
6.939 - case UI_SPECIFY_TO_SOLVE:
6.940 - //FIXXME RK 060712 here was: problem_browser_dialog_.setContext("");
6.941 -
6.942 - // ch_to_check = (CalcHead) ((UserActionOnCalcElement) action)
6.943 - // .getCalcElement();
6.944 - // calc_head = calc_tree_.checkCalcHead(ch_to_check);
6.945 - // if (!calc_head.isComplete()) {
6.946 - // calc_head = calc_tree_.completeCalcHead();
6.947 - // doUIAction(new UIActionOnCalcElement(EUIElement.UI_SPECIFY_CHECK_CALCHEAD,
6.948 - // EUIContext.UI_CONTEXT_CALCHEAD, user_language_, user_language_, calc_head));
6.949 - // break;
6.950 - // }
6.951 + notifyContextPresenter();
6.952
6.953 - // auto pressed
6.954 - case UI_SPECIFY_CALCULATE_ALL:
6.955 - if (!calc_head.isComplete()) {
6.956 - calc_head = calc_tree_.completeCalcHead();
6.957 - if (!calc_head.isComplete()) {
6.958 - calc_tree_.resetCalcHead();
6.959 - calc_head = calc_tree_.completeCalcHead();
6.960 - }
6.961 - }
6.962 + if (active_formula_.onCalcHead()) {
6.963 + switch (user_settings_.getValue("KEY1_START_SPECIFY")) {
6.964 + case IUserSettings.VAL1_SKIP_SPECIFY_TO_START_SOLVE:
6.965 + // WN050728
6.966 + // instead calc_tree_.autoCalculate(IToCalc.SCOPE_CALCULATION,
6.967 + // 1);
6.968 + // ...NEW Model_Problem (inserting Descriptions into the Model)
6.969 + // without causing CalcChangedEvent (would loop in calcChanged!)
6.970 + startSolving();
6.971 + break;
6.972 + case IUserSettings.VAL1_POP_CALCHEAD_WITH_DESCRIPTIONS:
6.973 + startSpecifying((CalcHead) active_formula_.getElement());
6.974 + break;
6.975 + default:
6.976 + try {
6.977 + throw new Exception("WorksheetDialog#calcChanged:switch"
6.978 + + " (user_settings_.getValue(KEY1_START_SPECIFY)");
6.979 + } catch (Exception e1) {
6.980 + e1.printStackTrace();
6.981 + }
6.982 + }
6.983 + }
6.984 + }
6.985
6.986 - doUIAction(new UIActionOnCalcElement(EUIElement.UI_SPECIFY_CALCULATE_ALL,
6.987 - EUIContext.UI_CONTEXT_CALCHEAD, user_language_, calc_head));
6.988 - doUIAction(new UIAction(EUIElement.UI_SPECIFY_CLOSE_CALCHEAD,
6.989 - EUIContext.UI_CONTEXT_SWITCH_PHASES, user_language_ ));
6.990 - startSolving();
6.991 + /**
6.992 + * construct the context-menu on one specific calcelement (e.g. with
6.993 + * 'Calchead' and without)
6.994 + *
6.995 + */
6.996 + private void addUIElementsContextOneElement(CalcChangedEvent event) {
6.997 + ICalcIterator from = event.getLastUnchangedFormula();
6.998 + ICalcIterator to = event.getLastGeneratedFormula();
6.999
6.1000 - // --------------solving phase------------------------------------
6.1001 - case UI_SOLVE_CALCULATE_1:
6.1002 - // handle the CalcHead such that its HeadLine can be
6.1003 - // presented like a CalcFormula
6.1004 - if (active_formula_.onCalcHead()) {
6.1005 - calc_tree_.completeCalcHead();
6.1006 - try {
6.1007 - calc_tree_.startSolving();
6.1008 - } catch (AutoCalculateException e1) {
6.1009 - e1.printStackTrace();
6.1010 - }
6.1011 - } else {
6.1012 - calc_tree_.autoCalculate(IToCalc.SCOPE_CALCULATION, 1);
6.1013 - }
6.1014 - break;
6.1015 -
6.1016 - case UI_SOLVE_CALCULATE_ALL:
6.1017 - switch (request) {
6.1018 - case UI_SPECIFY_CALCULATE_ALL:
6.1019 - case UI_SOLVE_CALCULATE_ALL:
6.1020 - calc_tree_.autoCalculate(IToCalc.SCOPE_CALCULATION, 0);
6.1021 - break;
6.1022 - case UI_SPECIFY_TO_SOLVE:
6.1023 - default:
6.1024 - }
6.1025 - break;
6.1026 + Vector calc_formulae = null;
6.1027
6.1028 - case UI_SOLVE_CALCULATE_SUBPROBLEM:
6.1029 - calc_tree_.autoCalculate(IToCalc.SCOPE_SUBPROBLEM, 0);
6.1030 - break;
6.1031 + try {
6.1032 + calc_formulae = from.getFormulaeFromTo(to, new Integer(0), false);
6.1033 + } catch (RemoteException e1) {
6.1034 + e1.printStackTrace();
6.1035 + }
6.1036
6.1037 - case UI_SOLVE_EDIT_ACTIVE_FORMULA:
6.1038 - ui_control_listener_.doUIAction(new UIAction(EUIElement.UI_DO_EDIT_FORMULA, EUIContext.UI_CONTEXT_ONEELEMENT, user_language_ ));
6.1039 - break;
6.1040 + if (calc_formulae == null)
6.1041 + return;
6.1042
6.1043 - case UI_SOLVE_EDIT_ACTIVE_FORMULA_COMPLETE:
6.1044 - System.out.println("**********XXX****************");
6.1045 - CalcFormula formula = (CalcFormula) ((UserActionOnCalcElement) action).getCalcElement();
6.1046 - // if the position is null, the formula did not exist, so we try to
6.1047 - // append a new formula
6.1048 - if (formula.getPosition() == null) {
6.1049 - calc_tree_.appendFormula(formula);
6.1050 - } else {
6.1051 - active_formula_ = new CalcIterator(calc_tree_, formula
6.1052 - .getPosition());
6.1053 - calc_tree_.replaceFormula(formula);
6.1054 - }
6.1055 - break;
6.1056 + Iterator vector_it = calc_formulae.iterator();
6.1057
6.1058 - case UI_SOLVE_APPEND_USER_FORMULA:
6.1059 - ui_control_listener_.doUIAction(new UIAction(EUIElement.UI_DO_APPEND_FORMULA, EUIContext.UI_CONTEXT_ONEELEMENT, user_language_ ));
6.1060 - break;
6.1061 + while (vector_it.hasNext()) {
6.1062 + CalcFormula cf = (CalcFormula) vector_it.next();
6.1063
6.1064 - case UI_SOLVE_MOVE_ACTIVE_FORMULA: {
6.1065 - UserActionOnPosition uaop = (UserActionOnPosition) action;
6.1066 - Position activePosition = uaop.getPosition();
6.1067 - ICalcIterator iterator = new CalcIterator( calc_tree_, activePosition );
6.1068 - calc_tree_.moveActiveFormula(iterator);
6.1069 - }
6.1070 - break;
6.1071 -
6.1072 - case UI_SOLVE_CHANGE_CONTEXT_FORMULA: {
6.1073 - UserActionOnPosition uaop = (UserActionOnPosition) action;
6.1074 - Position activePosition = uaop.getPosition();
6.1075 - if( activePosition != null ) {
6.1076 - context_formula_ = new CalcIterator( calc_tree_, activePosition );
6.1077 - notifyContextPresenter();
6.1078 - }
6.1079 - }
6.1080 - break;
6.1081 + if (cf.getPosition().getKind().equals("Pbl")
6.1082 + || cf.getPosition().getKind().equals("Met")) {
6.1083 + try {
6.1084 + ui_control_listener_.addUIElement(new UIAction(
6.1085 + EUIElement.UI_SOLVE_SHOW_CALCHEAD,
6.1086 + EUIContext.UI_CONTEXT_ONEELEMENT, cf.getPosition(),
6.1087 + user_language_));
6.1088 + } catch (RemoteException e) {
6.1089 + e.printStackTrace();
6.1090 + }
6.1091 + }
6.1092 + }
6.1093 + }
6.1094
6.1095 - case UI_SOLVE_GET_PROPOSED_TACTIC:
6.1096 - throw new DialogNotImplementedException(request, phase_);
6.1097 + /***************************************************************************
6.1098 + * This method sends the applicable tactics to the specific item in the
6.1099 + * worksheet determined by the Position of the iterator
6.1100 + *
6.1101 + * @param it
6.1102 + */
6.1103 + private void sendApplicableTacticsToWorksheet(ICalcIterator it) {
6.1104 + try {
6.1105 + Vector tactics = it.getApplicableTactics(ICalcIterator.TACTICS_ALL);
6.1106
6.1107 - case UI_SOLVE_GET_APPLICABLE_TACTICS:
6.1108 - sendApplicableTacticsToWorksheet( context_formula_ );
6.1109 - doUIAction(new UIAction(EUIElement.UI_SOLVE_SHOW_APPLICABLE_TACTICS,
6.1110 - EUIContext.UI_CONTEXT_ONEELEMENT, user_language_ ));
6.1111 - break;
6.1112 + if (tactics != null) {
6.1113 + for (int i = 0; i < tactics.size(); i++)
6.1114 + ui_control_listener_
6.1115 + .addUIElement(new UIActionOnCalcElement(
6.1116 + EUIElement.UI_SOLVE_SET_NEXT_TACTIC,
6.1117 + EUIContext.UI_CONTEXT_APPLICABLE_TACTIC,
6.1118 + user_language_, it.getPosition(),
6.1119 + (Tactic) tactics.get(i)));
6.1120 + }
6.1121 + } catch (RemoteException e) {
6.1122 + e.printStackTrace();
6.1123 + }
6.1124 + }
6.1125
6.1126 - case UI_SOLVE_SET_NEXT_TACTIC:
6.1127 - UserActionOnCalcElement uaoce = (UserActionOnCalcElement) action;
6.1128 + private void updateContextFormulaOnWorksheet(ICalcIterator it) {
6.1129 + if (ui_control_listener_ != null)
6.1130 + try {
6.1131 + ui_control_listener_.doUIAction(new UIAction(
6.1132 + EUIElement.UI_SOLVE_CHANGE_CONTEXT_FORMULA,
6.1133 + EUIContext.UI_CONTEXT_ONEELEMENT, it.getPosition(),
6.1134 + user_language_));
6.1135 + } catch (RemoteException e) {
6.1136 + e.printStackTrace();
6.1137 + }
6.1138 + }
6.1139
6.1140 - calc_tree_.moveActiveFormula(new CalcIterator(calc_tree_, uaoce.getPosition()));
6.1141 - calc_tree_.setNextTactic((Tactic) uaoce.getCalcElement());
6.1142 - calc_tree_.autoCalculate(IToCalc.SCOPE_CALCULATION, 1);
6.1143 - break;
6.1144 + /**
6.1145 + * @see isac.wsdialog.IWorksheetDialog#iterator(CalcIterator,
6.1146 + * IWorksheetDialog)
6.1147 + * @see isac.interfaces.IToCalc#iterator()
6.1148 + */
6.1149 + public ICalcIterator iterator(CalcIterator it, IWorksheetDialog dg) {
6.1150 + try {
6.1151 + return new DialogIterator(it, dg);
6.1152 + } catch (RemoteException e) {
6.1153 + e.printStackTrace();
6.1154 + }
6.1155 + return null;
6.1156 + }
6.1157
6.1158 - case UI_SOLVE_HELP_ENTERING_FORMULA:
6.1159 - throw new DialogNotImplementedException(request, phase_);
6.1160 + /**
6.1161 + * @see isac.wsdialog.IToCalc#addListener(isac.wsdialog.IToUser)
6.1162 + */
6.1163 + public boolean addDataChangeListener(IToUser listener)
6.1164 + throws RemoteException {
6.1165 + if (datachange_listeners_.contains(listener)) {
6.1166 + return false;
6.1167 + } else {
6.1168 + datachange_listeners_.add(listener);
6.1169 + }
6.1170 + return true;
6.1171 + }
6.1172
6.1173 - case UI_SOLVE_SHOW_ASSUMPTIONS: {
6.1174 - Assumptions asm = context_formula_.getAssumptions();
6.1175 - System.out.println("in WSDialog: asm = " + asm.toSMLString());
6.1176 - doUIAction(new UIActionOnCalcElement(EUIElement.UI_SOLVE_SHOW_ASSUMPTIONS,
6.1177 - EUIContext.UI_CONTEXT_CALCELEMENTS, user_language_, asm) );
6.1178 - }
6.1179 - break;
6.1180 + public boolean registerUIControlListener(IToGUI listener)
6.1181 + throws RemoteException {
6.1182 + ui_control_listener_ = listener;
6.1183 + buildUIElementsContextCalcElements();
6.1184 + return true;
6.1185 + }
6.1186
6.1187 - case UI_SOLVE_SHOW_INTERMEDIATE_STEPS: {
6.1188 - calc_tree_.intermediateSteps(context_formula_);
6.1189 - }
6.1190 - break;
6.1191 + /**
6.1192 + * Notify the Dialog Guide about interaction from the User DO NOT MODIFY THE
6.1193 + * SEQUENCE OF THE CASE BLOCKS IN THE SWITCH STATEMENTS!!
6.1194 + *
6.1195 + * @param action
6.1196 + * @return true, if the action has been processed, false if the processing
6.1197 + * the action has been denied
6.1198 + * @throws RemoteException
6.1199 + *
6.1200 + */
6.1201 + public boolean notifyUserAction(IUserAction action)
6.1202 + throws DialogProtocolException, RemoteException {
6.1203 + EUIElement request = action.getActionID();
6.1204 + CalcHead calc_head = new CalcHead();
6.1205 + CalcHead ch_to_check = new CalcHead();
6.1206
6.1207 - case UI_SOLVE_TACTIC_APPLIED: {
6.1208 - Tactic ta = context_formula_.getTactic();
6.1209 - doUIAction(new UIActionOnCalcElement(EUIElement.UI_SOLVE_TACTIC_APPLIED,
6.1210 - EUIContext.UI_CONTEXT_CALCELEMENTS, user_language_, ta));
6.1211 - break;
6.1212 - }
6.1213 + if (logger.isInfoEnabled())
6.1214 + logger.info(" WS->DG: notifyUserAction request= " + request);
6.1215 + System.out.println(" WS->DG: notifyUserAction request= " + request);
6.1216
6.1217 - case UI_SPECIFY_OPEN_CALCHEAD:
6.1218 - System.out.println("Pressed!");
6.1219 - break;
6.1220 + if (request == EUIElement.UI_CLOSE_WORKSHEET)
6.1221 + isac_logger_.logCloseWorksheet(worksheet_id_,
6.1222 + calculation_finished_successfully_);
6.1223 + else
6.1224 + isac_logger_.logUserAction("worksheet", action);
6.1225
6.1226 - default:
6.1227 - throw new DialogUnknownActionException(request, phase_);
6.1228 - }
6.1229 - return true;
6.1230 - }
6.1231 + // / the requests that do not depend on the phase
6.1232 + switch (request) {
6.1233 + case UI_CLOSE_WORKSHEET:
6.1234 + calc_tree_.destruct();
6.1235 + session_.getWSDialogManager().closeWSDialog(worksheet_id_);
6.1236 + if (session_.getWSDialogManager().numberOpenedWSDialoges() == 0)
6.1237 + removeNextAndAutoButtonForWorksheet();
6.1238 + IContextPresenter bdg = session_.getContextPresenter();
6.1239 + ContextUnknown context_unknown = new ContextUnknown();
6.1240 + bdg.presentContext(context_unknown);
6.1241 + return true;
6.1242 + case UI_ACTIVE_WORKSHEET:
6.1243 + session_.getWSDialogManager().setActiveWSDialog(worksheet_id_);
6.1244 + notifyContextPresenter();
6.1245 + return true;
6.1246 + }
6.1247
6.1248 - private void rmiBind() {
6.1249 - if (System.getSecurityManager() == null) {
6.1250 - System.setSecurityManager(new RMISecurityManager());
6.1251 - }
6.1252 + switch (phase_) {
6.1253 + case DIALOGPHASE_IDLE:
6.1254 + throw new DialogProtocolException(request, phase_);
6.1255 + case DIALOGPHASE_SPECIFY:
6.1256 + if (request.ordinal() < EUIElement.UI_DUMMY_FIRST_SPECIFY.ordinal()
6.1257 + || request.ordinal() > EUIElement.UI_DUMMY_LAST_SPECIFY
6.1258 + .ordinal())
6.1259 + throw new DialogProtocolException(request, phase_);
6.1260 + break;
6.1261 + case DIALOGPHASE_SOLVE:
6.1262 + if (request.ordinal() < EUIElement.UI_DUMMY_FIRST_SOLVE.ordinal()
6.1263 + || request.ordinal() > EUIElement.UI_DUMMY_LAST_SOLVE
6.1264 + .ordinal())
6.1265 + throw new DialogProtocolException(request, phase_);
6.1266 + break;
6.1267 + }
6.1268
6.1269 - try {
6.1270 - LocateRegistry
6.1271 - .createRegistry(ObjectManagerPaths.OBJECT_MANAGER_PORT);
6.1272 - } catch (java.rmi.RemoteException exc2) {
6.1273 - System.err.println("can not create registry: " + exc2.getMessage());
6.1274 - }
6.1275 + // *********** handle IUserAction's **********************
6.1276
6.1277 - // fixed path name =
6.1278 - // //localhost/isac-WorksheetDialog...Naming.rebind(name, this);
6.1279 - String name = ObjectManagerPaths.WORKSHEET_DIALOG_PATH; // "//localhost/isac-WorksheetDialog";
6.1280 - try {
6.1281 - System.out.println("try to bind as " + name);
6.1282 - Naming.rebind(name, this);
6.1283 - System.out.println("Dialog Guide bound to " + name);
6.1284 - // WN040906 was Object Manager ...
6.1285 - } catch (java.rmi.ConnectException e) {
6.1286 - System.err.println("failed to contact as " + name
6.1287 - + " (creating RMI-Server on localhost: 1099)");
6.1288 - } catch (RemoteException e) {
6.1289 - e.printStackTrace();
6.1290 - } catch (MalformedURLException e) {
6.1291 - e.printStackTrace();
6.1292 - }
6.1293 - }
6.1294 + switch (request) {
6.1295 + // in solve-phase request open a CalcHead by context-menu
6.1296 + case UI_SOLVE_SHOW_CALCHEAD:
6.1297 + calc_head = (CalcHead) context_formula_.getElement();
6.1298 + // calc_head = (CalcHead) ((UserActionOnIterator) action)
6.1299 + // .getPosition().getElement();
6.1300 + startSpecifying(calc_head);
6.1301 + // FIXXME RK 060712 here was:
6.1302 + // problem_browser_dialog_.setContext(worksheet_id_);
6.1303 + break;
6.1304
6.1305 - /**
6.1306 - * @see isac.wsdialog.IWorksheetDialog#notifyGUIReady()
6.1307 - */
6.1308 - public void notifyGUIReady() throws RemoteException {
6.1309 - worksheet_ready_ = true;
6.1310 - }
6.1311 + // Enter pressed after typing formula
6.1312 + case UI_SPECIFY_EDIT_ACTIVE_FORMULA_COMPLETE:
6.1313 + ch_to_check = (CalcHead) ((UserActionOnCalcElement) action)
6.1314 + .getCalcElement();
6.1315 + calc_head = calc_tree_.checkCalcHead(ch_to_check);
6.1316 + doUIAction(new UIActionOnCalcElement(
6.1317 + EUIElement.UI_SPECIFY_CHECK_CALCHEAD,
6.1318 + EUIContext.UI_CONTEXT_CALCHEAD, user_language_, calc_head));
6.1319 + break;
6.1320
6.1321 - /**
6.1322 - * @see isac.interfaces.IToGUI#doUIAction(isac.wsdialog.EUIContext)
6.1323 - * LK introduced worksheet_ready_ which required new Runnable
6.1324 - */
6.1325 - public synchronized void doUIAction(final IUIAction action)
6.1326 - throws RemoteException {
6.1327 - Thread t = new Thread(new Runnable() {
6.1328 + // Complete pressed
6.1329 + case UI_SPECIFY_COMPLETE_CALCHEAD:
6.1330 + if (!calc_head.isComplete()) {
6.1331 + calc_head = calc_tree_.completeCalcHead();
6.1332 + doUIAction(new UIActionOnCalcElement(
6.1333 + EUIElement.UI_SPECIFY_COMPLETE_CALCHEAD,
6.1334 + EUIContext.UI_CONTEXT_CALCHEAD, user_language_,
6.1335 + calc_head));
6.1336 + }
6.1337 + break;
6.1338 + // Radiobutton for Method/Problem clicked
6.1339 + // case UI_SPECIFY_TOGGLE_METHOD_PROBLEM:
6.1340 + // System.out.println("toggle");
6.1341 + // // WN050830 use UI_SPECIFY_SWITCH_TO_GUARD and
6.1342 + // // UI_SPECIFY_SWITCH_TO_MODEL instead,
6.1343 + // // and use some of this code ...
6.1344 + // // ICalcIterator ci = calc_tree_.getActiveFormula();
6.1345 + // // ci.switchToGuard();
6.1346 + // // CalcHead ch = (CalcHead) ci.getElement();
6.1347 + // //
6.1348 + // // TODO MK add code here to get new CalcHead with either Met or Pbl
6.1349 + // // Elements
6.1350 + //
6.1351 + // // ch_to_check = (CalcHead) ((UserActionOnCalcElement) action)
6.1352 + // // .getCalcElement();
6.1353 + // // calc_head = calc_tree_.checkCalcHead(ch_to_check);
6.1354 + // // doUIAction(new
6.1355 + // UIActionOnCalcElement(EUIElement.UI_SPECIFY_CHECK_CALCHEAD,
6.1356 + // // EUIContext.UI_CONTEXT_CALCHEAD, user_language_, user_language_,
6.1357 + // calc_head));
6.1358 + // break;
6.1359
6.1360 - public void run() {
6.1361 - try {
6.1362 - while (worksheet_ready_ == false) {
6.1363 - try {
6.1364 - Thread.sleep(1000);
6.1365 - } catch (InterruptedException e1) {
6.1366 - e1.printStackTrace();
6.1367 - }
6.1368 - }
6.1369 - ui_control_listener_.doUIAction(action);
6.1370 - } catch (RemoteException e) {
6.1371 - e.printStackTrace();
6.1372 - }
6.1373 - }
6.1374 - });
6.1375 - t.run();
6.1376 - }
6.1377 + case UI_SPECIFY_METHOD:
6.1378 + case UI_SPECIFY_THEORY:
6.1379 + case UI_SPECIFY_PROBLEM:
6.1380 + case UI_SPECIFY_COMPLETE_GIVEN:
6.1381 + case UI_SPECIFY_COMPLETE_FIND:
6.1382 + case UI_SPECIFY_COMPLETE_RELATE:
6.1383 + throw new DialogNotImplementedException(request, phase_);
6.1384
6.1385 - /**
6.1386 - * request the gui to add an interactive element
6.1387 - *
6.1388 - * @see isac.interfaces.IToGUI#addUIElement(isac.wsdialog.IUIAction)
6.1389 - */
6.1390 - public synchronized void addUIElement(final IUIAction action)
6.1391 - throws RemoteException {
6.1392 - Thread t = new Thread(new Runnable() {
6.1393 + // check pressed
6.1394 + case UI_SPECIFY_CHECK_CALCHEAD:
6.1395 + ch_to_check = (CalcHead) ((UserActionOnCalcElement) action)
6.1396 + .getCalcElement();
6.1397 + calc_head = calc_tree_.checkCalcHead(ch_to_check);
6.1398 + doUIAction(new UIActionOnCalcElement(
6.1399 + EUIElement.UI_SPECIFY_CHECK_CALCHEAD,
6.1400 + EUIContext.UI_CONTEXT_CALCHEAD, user_language_, calc_head));
6.1401 + break;
6.1402
6.1403 - public void run() {
6.1404 - try {
6.1405 - while (worksheet_ready_ == false) {
6.1406 - try {
6.1407 - Thread.sleep(1000);
6.1408 - } catch (InterruptedException e1) {
6.1409 - e1.printStackTrace();
6.1410 - }
6.1411 - }
6.1412 - ui_control_listener_.addUIElement(action);
6.1413 - } catch (RemoteException e) {
6.1414 - e.printStackTrace();
6.1415 - }
6.1416 - }
6.1417 - });
6.1418 - t.run();
6.1419 - }
6.1420 + // next pressed
6.1421 + case UI_SPECIFY_COMPLETE_STEPWISE:
6.1422 + if (!calc_head.isComplete()) {
6.1423 + calc_head = calc_tree_.nextSpecify();
6.1424 + doUIAction(new UIActionOnCalcElement(
6.1425 + EUIElement.UI_SPECIFY_COMPLETE_STEPWISE,
6.1426 + EUIContext.UI_CONTEXT_CALCHEAD, user_language_,
6.1427 + calc_head));
6.1428 + }
6.1429 + break;
6.1430
6.1431 - /**
6.1432 - * request the gui to remove an interactive element
6.1433 - *
6.1434 - * @see isac.interfaces.IToGUI#removeUIElement(isac.wsdialog.IUIAction)
6.1435 - */
6.1436 - public synchronized void removeUIElement(final IUIAction action)
6.1437 - throws RemoteException {
6.1438 - Thread t = new Thread(new Runnable() {
6.1439 + // close pressed
6.1440 + case UI_SPECIFY_CLOSE_CALCHEAD:
6.1441 + // this action is enabled _ONLY_ if the Panel was opened read-only
6.1442 + // on a complete CalcHead just for inspection
6.1443 + doUIAction(new UIAction(EUIElement.UI_SPECIFY_CLOSE_CALCHEAD,
6.1444 + EUIContext.UI_CONTEXT_SWITCH_PHASES, user_language_));
6.1445 + phase_ = DIALOGPHASE_SOLVE;
6.1446 + // FIXXME RK 060712 here was:
6.1447 + // problem_browser_dialog_.setContext("");
6.1448 + break;
6.1449
6.1450 - public void run() {
6.1451 - try {
6.1452 - while (worksheet_ready_ == false) {
6.1453 - try {
6.1454 - Thread.sleep(1000);
6.1455 - } catch (InterruptedException e1) {
6.1456 - e1.printStackTrace();
6.1457 - }
6.1458 - }
6.1459 - ui_control_listener_.removeUIElement(action);
6.1460 - // ???worksheet_ready_ = false;
6.1461 - } catch (RemoteException e) {
6.1462 - e.printStackTrace();
6.1463 - }
6.1464 - }
6.1465 - });
6.1466 - t.run();
6.1467 - }
6.1468 + // reset pressed
6.1469 + case UI_SPECIFY_RESET:
6.1470 + calc_tree_.resetCalcHead();
6.1471 + calc_head = calc_tree_.modelProblem();
6.1472 + doUIAction(new UIActionOnCalcElement(EUIElement.UI_SPECIFY_RESET,
6.1473 + EUIContext.UI_CONTEXT_CALCHEAD, user_language_, calc_head));
6.1474 + break;
6.1475
6.1476 -
6.1477 - /***
6.1478 - * TODO: notify the active context presenter that something happened
6.1479 - */
6.1480 - private void notifyContextPresenter() {
6.1481 - System.out.println( "In WorksheetDialog::notifyContextPresenter !!" );
6.1482 -
6.1483 - Context current_context = new ContextUnknown();
6.1484 - IContextPresenter bdg = session_.getContextPresenter();
6.1485 -
6.1486 - if( bdg == null ) {
6.1487 - System.out.println("No dialog");
6.1488 - return;
6.1489 - }
6.1490 -
6.1491 - if( bdg instanceof ExampleDialog ) {
6.1492 - System.out.println("Example dialog");
6.1493 - current_context = initContext( ContextType.CONTEXT_EXAMPLES );
6.1494 - } else if( bdg instanceof ProblemDialog ) {
6.1495 - System.out.println("Problem dialog");
6.1496 - current_context = initContext( ContextType.CONTEXT_PROBLEMS );
6.1497 - } else if( bdg instanceof MethodDialog ) {
6.1498 - System.out.println("Method dialog");
6.1499 - current_context = initContext( ContextType.CONTEXT_METHODS );
6.1500 - } else if( bdg instanceof TheoryDialog ) {
6.1501 - System.out.println("Theory dialog");
6.1502 - current_context = initContext( ContextType.CONTEXT_THEORIES );
6.1503 - }
6.1504 -
6.1505 - bdg.presentContext( current_context );
6.1506 - }
6.1507 -
6.1508 - /**
6.1509 - * @see isac.wsdialog.IContextProvider#initContext(ContextMethod)
6.1510 - *
6.1511 - * @throws RemoteException
6.1512 - *
6.1513 - */
6.1514 - public Context initContext( ContextType type ) {
6.1515 - System.out.println("In WorksheetDialog::initContext() : type is " + type );
6.1516 -
6.1517 - Context current_context = new ContextUnknown();
6.1518 -
6.1519 - switch( type ) {
6.1520 - case CONTEXT_EXAMPLES:
6.1521 - current_context = new ContextExample();
6.1522 - current_context.setKEStoreKey( session_.getExampleOfWorksheet( worksheet_id_ ) );
6.1523 - break;
6.1524 - case CONTEXT_METHODS:
6.1525 - case CONTEXT_PROBLEMS:
6.1526 - case CONTEXT_THEORIES:
6.1527 - try {
6.1528 - current_context = context_formula_.initContext( type );
6.1529 - } catch (RemoteException e) {
6.1530 - e.printStackTrace();
6.1531 - }
6.1532 - break;
6.1533 - }
6.1534 + // start solving pressed
6.1535 + case UI_SPECIFY_TO_SOLVE:
6.1536 + // FIXXME RK 060712 here was: problem_browser_dialog_.setContext("");
6.1537
6.1538 - System.out.println("current context:"+current_context);
6.1539 -
6.1540 - if( current_context == null )
6.1541 - return new ContextUnknown();
6.1542 - else
6.1543 - return current_context;
6.1544 - }
6.1545 -
6.1546 - /* (non-Javadoc)
6.1547 - * @see isac.wsdialog.IContextProvider#refineContext(isac.util.formulae.Context)
6.1548 - */
6.1549 - public Context refineContext(Context context) {
6.1550 + // ch_to_check = (CalcHead) ((UserActionOnCalcElement) action)
6.1551 + // .getCalcElement();
6.1552 + // calc_head = calc_tree_.checkCalcHead(ch_to_check);
6.1553 + // if (!calc_head.isComplete()) {
6.1554 + // calc_head = calc_tree_.completeCalcHead();
6.1555 + // doUIAction(new
6.1556 + // UIActionOnCalcElement(EUIElement.UI_SPECIFY_CHECK_CALCHEAD,
6.1557 + // EUIContext.UI_CONTEXT_CALCHEAD, user_language_, user_language_,
6.1558 + // calc_head));
6.1559 + // break;
6.1560 + // }
6.1561
6.1562 - Context current_context = null;
6.1563 -
6.1564 - try {
6.1565 - current_context = context_formula_.refineProblem( context );
6.1566 - } catch (RemoteException e) {
6.1567 - e.printStackTrace();
6.1568 - }
6.1569 -
6.1570 - if( current_context == null )
6.1571 - return new ContextUnknown();
6.1572 - else
6.1573 - return current_context;
6.1574 - }
6.1575 -
6.1576 - public void setContext(Context context) {
6.1577 - CalcHead ch = null;
6.1578 -
6.1579 - try {
6.1580 - if( context instanceof ContextTheory ) {
6.1581 - System.out.println("In WSDialog::setContext() : Theory");
6.1582 - context_formula_.setContext( (ContextTheory) context );
6.1583 - return;
6.1584 - } else if ( context instanceof ContextMethod ) {
6.1585 - System.out.println("In WSDialog::setContext() : Method");
6.1586 - ch = context_formula_.setContext( (ContextMethod) context );
6.1587 - } else if ( context instanceof ContextProblem ) {
6.1588 - System.out.println("In WSDialog::setContext() : Problem");
6.1589 - ch = context_formula_.setContext( (ContextProblem) context );
6.1590 - } else {
6.1591 - System.out.println("Can not set this context (Basis class, ContextExample or ContextUnknown)");
6.1592 - return;
6.1593 - }
6.1594 -
6.1595 - if( ch != null ) {
6.1596 - doUIAction(new UIActionOnCalcElement(EUIElement.UI_SPECIFY_CHECK_CALCHEAD,
6.1597 - EUIContext.UI_CONTEXT_CALCHEAD, user_language_, ch ));
6.1598 - }
6.1599 -
6.1600 - } catch (RemoteException e) {
6.1601 - e.printStackTrace();
6.1602 - }
6.1603 -
6.1604 - return;
6.1605 - }
6.1606 -
6.1607 - /* (non-Javadoc)
6.1608 - * @see isac.wsdialog.IContextProvider#checkContext(isac.util.formulae.Context)
6.1609 - */
6.1610 - public Context checkContext(Context context) {
6.1611 - Context current_context = null;
6.1612 -
6.1613 - try {
6.1614 - current_context = context_formula_.checkContext( context );
6.1615 - } catch (RemoteException e) {
6.1616 - e.printStackTrace();
6.1617 - }
6.1618 -
6.1619 - if( current_context == null )
6.1620 - return new ContextUnknown();
6.1621 - else
6.1622 - return current_context;
6.1623 - }
6.1624 + // auto pressed
6.1625 + case UI_SPECIFY_CALCULATE_ALL:
6.1626 + if (!calc_head.isComplete()) {
6.1627 + calc_head = calc_tree_.completeCalcHead();
6.1628 + if (!calc_head.isComplete()) {
6.1629 + calc_tree_.resetCalcHead();
6.1630 + calc_head = calc_tree_.completeCalcHead();
6.1631 + }
6.1632 + }
6.1633
6.1634 - /**
6.1635 - * @see isac.wsdialog.IContextProvider#getWorksheetState()
6.1636 - */
6.1637 - public WorksheetState getWorksheetState() {
6.1638 -// try {
6.1639 -// WorksheetState wsstate = new WorksheetState( context_formula_.onCalcHead() );
6.1640 -// return wsstate;
6.1641 -// } catch (RemoteException e) {
6.1642 -// e.printStackTrace();
6.1643 -// }
6.1644 -
6.1645 - return new WorksheetState( phase_ == DIALOGPHASE_SPECIFY );
6.1646 - }
6.1647 + doUIAction(new UIActionOnCalcElement(
6.1648 + EUIElement.UI_SPECIFY_CALCULATE_ALL,
6.1649 + EUIContext.UI_CONTEXT_CALCHEAD, user_language_, calc_head));
6.1650 + doUIAction(new UIAction(EUIElement.UI_SPECIFY_CLOSE_CALCHEAD,
6.1651 + EUIContext.UI_CONTEXT_SWITCH_PHASES, user_language_));
6.1652 + startSolving();
6.1653 +
6.1654 + // --------------solving phase------------------------------------
6.1655 + case UI_SOLVE_CALCULATE_1:
6.1656 + // handle the CalcHead such that its HeadLine can be
6.1657 + // presented like a CalcFormula
6.1658 + if (active_formula_.onCalcHead()) {
6.1659 + calc_tree_.completeCalcHead();
6.1660 + try {
6.1661 + calc_tree_.startSolving();
6.1662 + } catch (AutoCalculateException e1) {
6.1663 + e1.printStackTrace();
6.1664 + }
6.1665 + } else {
6.1666 + calc_tree_.autoCalculate(IToCalc.SCOPE_CALCULATION, 1);
6.1667 + }
6.1668 + break;
6.1669 +
6.1670 + case UI_SOLVE_CALCULATE_ALL:
6.1671 + switch (request) {
6.1672 + case UI_SPECIFY_CALCULATE_ALL:
6.1673 + case UI_SOLVE_CALCULATE_ALL:
6.1674 + calc_tree_.autoCalculate(IToCalc.SCOPE_CALCULATION, 0);
6.1675 + break;
6.1676 + case UI_SPECIFY_TO_SOLVE:
6.1677 + default:
6.1678 + }
6.1679 + break;
6.1680 +
6.1681 + case UI_SOLVE_CALCULATE_SUBPROBLEM:
6.1682 + calc_tree_.autoCalculate(IToCalc.SCOPE_SUBPROBLEM, 0);
6.1683 + break;
6.1684 +
6.1685 + case UI_SOLVE_EDIT_ACTIVE_FORMULA:
6.1686 + ui_control_listener_.doUIAction(new UIAction(
6.1687 + EUIElement.UI_DO_EDIT_FORMULA,
6.1688 + EUIContext.UI_CONTEXT_ONEELEMENT, user_language_));
6.1689 + break;
6.1690 +
6.1691 + case UI_SOLVE_EDIT_ACTIVE_FORMULA_COMPLETE:
6.1692 + System.out.println("**********XXX****************");
6.1693 + CalcFormula formula = (CalcFormula) ((UserActionOnCalcElement) action)
6.1694 + .getCalcElement();
6.1695 + // if the position is null, the formula did not exist, so we try to
6.1696 + // append a new formula
6.1697 + if (formula.getPosition() == null) {
6.1698 + calc_tree_.appendFormula(formula);
6.1699 + } else {
6.1700 + active_formula_ = new CalcIterator(calc_tree_, formula
6.1701 + .getPosition());
6.1702 + calc_tree_.replaceFormula(formula);
6.1703 + }
6.1704 + break;
6.1705 +
6.1706 + case UI_SOLVE_APPEND_USER_FORMULA:
6.1707 + ui_control_listener_.doUIAction(new UIAction(
6.1708 + EUIElement.UI_DO_APPEND_FORMULA,
6.1709 + EUIContext.UI_CONTEXT_ONEELEMENT, user_language_));
6.1710 + break;
6.1711 +
6.1712 + case UI_SOLVE_MOVE_ACTIVE_FORMULA: {
6.1713 + UserActionOnPosition uaop = (UserActionOnPosition) action;
6.1714 + Position activePosition = uaop.getPosition();
6.1715 + ICalcIterator iterator = new CalcIterator(calc_tree_,
6.1716 + activePosition);
6.1717 + calc_tree_.moveActiveFormula(iterator);
6.1718 + }
6.1719 + break;
6.1720 +
6.1721 + case UI_SOLVE_CHANGE_CONTEXT_FORMULA: {
6.1722 + UserActionOnPosition uaop = (UserActionOnPosition) action;
6.1723 + Position activePosition = uaop.getPosition();
6.1724 + if (activePosition != null) {
6.1725 + context_formula_ = new CalcIterator(calc_tree_, activePosition);
6.1726 + notifyContextPresenter();
6.1727 + }
6.1728 + }
6.1729 + break;
6.1730 +
6.1731 + case UI_SOLVE_GET_PROPOSED_TACTIC:
6.1732 + throw new DialogNotImplementedException(request, phase_);
6.1733 +
6.1734 + case UI_SOLVE_GET_APPLICABLE_TACTICS:
6.1735 + sendApplicableTacticsToWorksheet(context_formula_);
6.1736 + doUIAction(new UIAction(
6.1737 + EUIElement.UI_SOLVE_SHOW_APPLICABLE_TACTICS,
6.1738 + EUIContext.UI_CONTEXT_ONEELEMENT, user_language_));
6.1739 + break;
6.1740 +
6.1741 + case UI_SOLVE_SET_NEXT_TACTIC:
6.1742 + UserActionOnCalcElement uaoce = (UserActionOnCalcElement) action;
6.1743 +
6.1744 + calc_tree_.moveActiveFormula(new CalcIterator(calc_tree_, uaoce
6.1745 + .getPosition()));
6.1746 + calc_tree_.setNextTactic((Tactic) uaoce.getCalcElement());
6.1747 + calc_tree_.autoCalculate(IToCalc.SCOPE_CALCULATION, 1);
6.1748 + break;
6.1749 +
6.1750 + case UI_SOLVE_HELP_ENTERING_FORMULA:
6.1751 + throw new DialogNotImplementedException(request, phase_);
6.1752 +
6.1753 + case UI_SOLVE_SHOW_ASSUMPTIONS: {
6.1754 + Assumptions asm = context_formula_.getAssumptions();
6.1755 + System.out.println("in WSDialog: asm = " + asm.toSMLString());
6.1756 + doUIAction(new UIActionOnCalcElement(
6.1757 + EUIElement.UI_SOLVE_SHOW_ASSUMPTIONS,
6.1758 + EUIContext.UI_CONTEXT_CALCELEMENTS, user_language_, asm));
6.1759 + }
6.1760 + break;
6.1761 +
6.1762 + case UI_SOLVE_SHOW_INTERMEDIATE_STEPS: {
6.1763 + calc_tree_.intermediateSteps(context_formula_);
6.1764 + }
6.1765 + break;
6.1766 +
6.1767 + case UI_SOLVE_TACTIC_APPLIED: {
6.1768 + Tactic ta = context_formula_.getTactic();
6.1769 + doUIAction(new UIActionOnCalcElement(
6.1770 + EUIElement.UI_SOLVE_TACTIC_APPLIED,
6.1771 + EUIContext.UI_CONTEXT_CALCELEMENTS, user_language_, ta));
6.1772 + break;
6.1773 + }
6.1774 +
6.1775 + case UI_SPECIFY_OPEN_CALCHEAD:
6.1776 + System.out.println("Pressed!");
6.1777 + break;
6.1778 +
6.1779 + default:
6.1780 + throw new DialogUnknownActionException(request, phase_);
6.1781 + }
6.1782 + return true;
6.1783 + }
6.1784 +
6.1785 + private void rmiBind() {
6.1786 + if (System.getSecurityManager() == null) {
6.1787 + System.setSecurityManager(new RMISecurityManager());
6.1788 + }
6.1789 +
6.1790 + try {
6.1791 + LocateRegistry
6.1792 + .createRegistry(ObjectManagerPaths.OBJECT_MANAGER_PORT);
6.1793 + } catch (java.rmi.RemoteException exc2) {
6.1794 + System.err.println("can not create registry: " + exc2.getMessage());
6.1795 + }
6.1796 +
6.1797 + // fixed path name =
6.1798 + // //localhost/isac-WorksheetDialog...Naming.rebind(name, this);
6.1799 + String name = ObjectManagerPaths.WORKSHEET_DIALOG_PATH; // "//localhost/isac-WorksheetDialog";
6.1800 + try {
6.1801 + System.out.println("try to bind as " + name);
6.1802 + Naming.rebind(name, this);
6.1803 + System.out.println("Dialog Guide bound to " + name);
6.1804 + // WN040906 was Object Manager ...
6.1805 + } catch (java.rmi.ConnectException e) {
6.1806 + System.err.println("failed to contact as " + name
6.1807 + + " (creating RMI-Server on localhost: 1099)");
6.1808 + } catch (RemoteException e) {
6.1809 + e.printStackTrace();
6.1810 + } catch (MalformedURLException e) {
6.1811 + e.printStackTrace();
6.1812 + }
6.1813 + }
6.1814 +
6.1815 + /**
6.1816 + * @see isac.wsdialog.IWorksheetDialog#notifyGUIReady()
6.1817 + */
6.1818 + public void notifyGUIReady() throws RemoteException {
6.1819 + worksheet_ready_ = true;
6.1820 + }
6.1821 +
6.1822 + /**
6.1823 + * @see isac.interfaces.IToGUI#doUIAction(isac.wsdialog.EUIContext) LK
6.1824 + * introduced worksheet_ready_ which required new Runnable
6.1825 + */
6.1826 + public synchronized void doUIAction(final IUIAction action)
6.1827 + throws RemoteException {
6.1828 + Thread t = new Thread(new Runnable() {
6.1829 +
6.1830 + public void run() {
6.1831 + try {
6.1832 + while (worksheet_ready_ == false) {
6.1833 + try {
6.1834 + Thread.sleep(1000);
6.1835 + } catch (InterruptedException e1) {
6.1836 + e1.printStackTrace();
6.1837 + }
6.1838 + }
6.1839 + ui_control_listener_.doUIAction(action);
6.1840 + } catch (RemoteException e) {
6.1841 + e.printStackTrace();
6.1842 + }
6.1843 + }
6.1844 + });
6.1845 + t.run();
6.1846 + }
6.1847 +
6.1848 + /**
6.1849 + * request the gui to add an interactive element
6.1850 + *
6.1851 + * @see isac.interfaces.IToGUI#addUIElement(isac.wsdialog.IUIAction)
6.1852 + */
6.1853 + public synchronized void addUIElement(final IUIAction action)
6.1854 + throws RemoteException {
6.1855 + Thread t = new Thread(new Runnable() {
6.1856 +
6.1857 + public void run() {
6.1858 + try {
6.1859 + while (worksheet_ready_ == false) {
6.1860 + try {
6.1861 + Thread.sleep(1000);
6.1862 + } catch (InterruptedException e1) {
6.1863 + e1.printStackTrace();
6.1864 + }
6.1865 + }
6.1866 + ui_control_listener_.addUIElement(action);
6.1867 + } catch (RemoteException e) {
6.1868 + e.printStackTrace();
6.1869 + }
6.1870 + }
6.1871 + });
6.1872 + t.run();
6.1873 + }
6.1874 +
6.1875 + /**
6.1876 + * request the gui to remove an interactive element
6.1877 + *
6.1878 + * @see isac.interfaces.IToGUI#removeUIElement(isac.wsdialog.IUIAction)
6.1879 + */
6.1880 + public synchronized void removeUIElement(final IUIAction action)
6.1881 + throws RemoteException {
6.1882 + Thread t = new Thread(new Runnable() {
6.1883 +
6.1884 + public void run() {
6.1885 + try {
6.1886 + while (worksheet_ready_ == false) {
6.1887 + try {
6.1888 + Thread.sleep(1000);
6.1889 + } catch (InterruptedException e1) {
6.1890 + e1.printStackTrace();
6.1891 + }
6.1892 + }
6.1893 + ui_control_listener_.removeUIElement(action);
6.1894 + // ???worksheet_ready_ = false;
6.1895 + } catch (RemoteException e) {
6.1896 + e.printStackTrace();
6.1897 + }
6.1898 + }
6.1899 + });
6.1900 + t.run();
6.1901 + }
6.1902 +
6.1903 + /***************************************************************************
6.1904 + * TODO: notify the active context presenter that something happened
6.1905 + */
6.1906 + private void notifyContextPresenter() {
6.1907 + System.out.println("In WorksheetDialog::notifyContextPresenter !!");
6.1908 +
6.1909 + Context current_context = new ContextUnknown();
6.1910 + IContextPresenter bdg = session_.getContextPresenter();
6.1911 +
6.1912 + if (bdg == null) {
6.1913 + System.out.println("No dialog");
6.1914 + return;
6.1915 + }
6.1916 +
6.1917 + if (bdg instanceof ExampleDialog) {
6.1918 + System.out.println("Example dialog");
6.1919 + current_context = initContext(ContextType.CONTEXT_EXAMPLES);
6.1920 + } else if (bdg instanceof ProblemDialog) {
6.1921 + System.out.println("Problem dialog");
6.1922 + current_context = initContext(ContextType.CONTEXT_PROBLEMS);
6.1923 + } else if (bdg instanceof MethodDialog) {
6.1924 + System.out.println("Method dialog");
6.1925 + current_context = initContext(ContextType.CONTEXT_METHODS);
6.1926 + } else if (bdg instanceof TheoryDialog) {
6.1927 + System.out.println("Theory dialog");
6.1928 + current_context = initContext(ContextType.CONTEXT_THEORIES);
6.1929 + }
6.1930 +
6.1931 + bdg.presentContext(current_context);
6.1932 + }
6.1933 +
6.1934 + /**
6.1935 + * @see isac.wsdialog.IContextProvider#initContext(ContextMethod)
6.1936 + *
6.1937 + * @throws RemoteException
6.1938 + *
6.1939 + */
6.1940 + public Context initContext(ContextType type) {
6.1941 + System.out.println("In WorksheetDialog::initContext() : type is "
6.1942 + + type);
6.1943 +
6.1944 + Context current_context = new ContextUnknown();
6.1945 +
6.1946 + switch (type) {
6.1947 + case CONTEXT_EXAMPLES:
6.1948 + current_context = new ContextExample();
6.1949 + current_context.setKEStoreKey(session_
6.1950 + .getExampleOfWorksheet(worksheet_id_));
6.1951 + break;
6.1952 + case CONTEXT_METHODS:
6.1953 + case CONTEXT_PROBLEMS:
6.1954 + case CONTEXT_THEORIES:
6.1955 + try {
6.1956 + current_context = context_formula_.initContext(type);
6.1957 + } catch (RemoteException e) {
6.1958 + e.printStackTrace();
6.1959 + }
6.1960 + break;
6.1961 + }
6.1962 +
6.1963 + System.out.println("current context:" + current_context);
6.1964 +
6.1965 + if (current_context == null)
6.1966 + return new ContextUnknown();
6.1967 + else
6.1968 + return current_context;
6.1969 + }
6.1970 +
6.1971 + /*
6.1972 + * (non-Javadoc)
6.1973 + *
6.1974 + * @see isac.wsdialog.IContextProvider#refineContext(isac.util.formulae.Context)
6.1975 + */
6.1976 + public Context refineContext(Context context) {
6.1977 +
6.1978 + Context current_context = null;
6.1979 +
6.1980 + try {
6.1981 + current_context = context_formula_.refineProblem(context);
6.1982 + } catch (RemoteException e) {
6.1983 + e.printStackTrace();
6.1984 + }
6.1985 +
6.1986 + if (current_context == null)
6.1987 + return new ContextUnknown();
6.1988 + else
6.1989 + return current_context;
6.1990 + }
6.1991 +
6.1992 + public void setContext(Context context) {
6.1993 + CalcHead ch = null;
6.1994 +
6.1995 + try {
6.1996 + if (context instanceof ContextTheory) {
6.1997 + System.out.println("In WSDialog::setContext() : Theory");
6.1998 + context_formula_.setContext((ContextTheory) context);
6.1999 + return;
6.2000 + } else if (context instanceof ContextMethod) {
6.2001 + System.out.println("In WSDialog::setContext() : Method");
6.2002 + ch = context_formula_.setContext((ContextMethod) context);
6.2003 + } else if (context instanceof ContextProblem) {
6.2004 + System.out.println("In WSDialog::setContext() : Problem");
6.2005 + ch = context_formula_.setContext((ContextProblem) context);
6.2006 + } else {
6.2007 + System.out
6.2008 + .println("Can not set this context (Basis class, ContextExample or ContextUnknown)");
6.2009 + return;
6.2010 + }
6.2011 +
6.2012 + if (ch != null) {
6.2013 + doUIAction(new UIActionOnCalcElement(
6.2014 + EUIElement.UI_SPECIFY_CHECK_CALCHEAD,
6.2015 + EUIContext.UI_CONTEXT_CALCHEAD, user_language_, ch));
6.2016 + }
6.2017 +
6.2018 + } catch (RemoteException e) {
6.2019 + e.printStackTrace();
6.2020 + }
6.2021 +
6.2022 + return;
6.2023 + }
6.2024 +
6.2025 + /*
6.2026 + * (non-Javadoc)
6.2027 + *
6.2028 + * @see isac.wsdialog.IContextProvider#checkContext(isac.util.formulae.Context)
6.2029 + */
6.2030 + public Context checkContext(Context context) {
6.2031 + Context current_context = null;
6.2032 +
6.2033 + try {
6.2034 + current_context = context_formula_.checkContext(context);
6.2035 + } catch (RemoteException e) {
6.2036 + e.printStackTrace();
6.2037 + }
6.2038 +
6.2039 + if (current_context == null)
6.2040 + return new ContextUnknown();
6.2041 + else
6.2042 + return current_context;
6.2043 + }
6.2044 +
6.2045 + /**
6.2046 + * @see isac.wsdialog.IContextProvider#getWorksheetState()
6.2047 + */
6.2048 + public WorksheetState getWorksheetState() {
6.2049 + // try {
6.2050 + // WorksheetState wsstate = new WorksheetState(
6.2051 + // context_formula_.onCalcHead() );
6.2052 + // return wsstate;
6.2053 + // } catch (RemoteException e) {
6.2054 + // e.printStackTrace();
6.2055 + // }
6.2056 +
6.2057 + return new WorksheetState(phase_ == DIALOGPHASE_SPECIFY);
6.2058 + }
6.2059
6.2060 }