/**
   * Create a new instance of LearnController, let the view set up the data, show all the phrases.
   * Initially the view is visible.
   *
   * @param lesson
   */
  public LearnController(Lesson lesson) {
    selectedLesson = lesson;
    view = LearnFrame.getLearnFrame();
    view.clearAllPhraseItem();

    initAllPhrases();
    addAllListener();

    view.setVisible(true);
  }
  /** Add some listeners to the view */
  private void addAllListener() {

    // finish listener
    view.getFinishButton()
        .addActionListener(
            new ActionListener() {
              public void actionPerformed(ActionEvent e) {
                MainController main = MainController.getMainController();
                main.getLessonController().initAllPhrases();
                main.setVisible(true);

                view.setVisible(false);
                view.dispose();
                selectedLesson = null;
              }
            });

    // when exiting, back to main frame
    view.addExitingReturnToMainController();
  }
 /** show all the phrase in the view */
 private void initAllPhrases() {
   for (Phrase p : selectedLesson.getAllPhrases()) {
     view.addPhraseItem(p);
   }
 }