View Javadoc

1   /* ===================================================================
2    * Copyright 2002-05 SRI International.
3    * Released under the MOZILLA PUBLIC LICENSE Version 1.1
4    * which can be obtained at http://www.mozilla.org/MPL/MPL-1.1.html
5    * This software is distributed on an "AS IS"
6    * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
7    * See the License for the specific language governing rights and
8    * limitations under the License.
9    * =================================================================== */
10  package com.sri.emo.wizard.creation.management;
11  
12  import com.jcorporate.expresso.core.controller.Controller;
13  import com.jcorporate.expresso.core.controller.ControllerException;
14  import com.jcorporate.expresso.core.controller.ExpressoRequest;
15  import com.jcorporate.expresso.core.controller.ExpressoResponse;
16  import com.jcorporate.expresso.core.controller.Transition;
17  import com.jcorporate.expresso.core.db.DBException;
18  import com.sri.common.controller.StateHandler;
19  import com.sri.emo.wizard.wizardgateway.ListWizards;
20  import com.sri.emo.wizard.wizardgateway.WizardGatewayController;
21  
22  
23  /***
24   * @author Michael Rimov
25   */
26  public class PromptChooseNode implements StateHandler {
27  
28      /***
29       * The name of this state as referred to by the Expresso Controller
30       */
31      public static final String STATE_NAME = "promptChooseNode";
32  
33      /***
34       * The description of this state as referred to by the Expresso Controller.
35       */
36      public static final String STATE_DESCRIPTION = "Choose A Node";
37  
38      /***
39       * Parent controller backreference.
40       */
41      private final Controller owner;
42  
43      /***
44       * Delegating helper methods.
45       */
46      private final CreationBeanManager beanManager;
47  
48      /***
49       * Constructor that takes the owner controller as a paramter.
50       *
51       * @param stateOwner Controller the owning controller.
52       */
53      public PromptChooseNode(Controller stateOwner) {
54          this.owner = stateOwner;
55          beanManager = new CreationBeanManager();
56      }
57  
58      /***
59       * Called to handle the request.
60       *
61       * @param request  ControllerRequest The Function's ControllerRequest
62       *                 object.
63       * @param response ControllerResponse The Function's ControllerResponse
64       *                 object.
65       * @throws DBException         upon underlying database exception error.
66       * @throws ControllerException upon underlying ControllerException error.
67       */
68      public void handleRequest(final ExpressoRequest request, final ExpressoResponse response) throws DBException,
69              ControllerException {
70  
71          //Creates the action form
72          beanManager.createOrRetrieveActionForm(request);
73  
74          response.setTitle("Creation Wiz Creator, Part 1");
75  
76          Transition next = new Transition(DoChooseNodeStep.STATE_NAME, owner);
77          next.setName("next");
78          next.setLabel("Next");
79          response.add(next);
80  
81          response.add(new Transition("cancel", "Cancel", WizardGatewayController.class, ListWizards.STATE_NAME));
82  
83      }
84  }