@Override
 protected void event(UserRequest ureq, Controller source, Event event) {
   if (newMethodCtrl == source) {
     if (event.equals(Event.DONE_EVENT)) {
       OfferAccess newLink = newMethodCtrl.commitChanges();
       newLink = acService.saveOfferAccess(newLink);
       addConfiguration(newLink);
       fireEvent(ureq, Event.CHANGED_EVENT);
     }
     cmc.deactivate();
     cleanUp();
   } else if (editMethodCtrl == source) {
     if (event.equals(Event.DONE_EVENT)) {
       OfferAccess newLink = editMethodCtrl.commitChanges();
       newLink = acService.saveOfferAccess(newLink);
       replace(newLink);
       fireEvent(ureq, Event.CHANGED_EVENT);
     }
     cmc.deactivate();
     cleanUp();
   } else if (cmc == source) {
     cleanUp();
   } else {
     super.event(ureq, source, event);
   }
 }
 /**
  * @see org.olat.core.gui.control.DefaultController#event(org.olat.core.gui.UserRequest,
  *     org.olat.core.gui.control.Controller, org.olat.core.gui.control.Event)
  */
 public void event(UserRequest ureq, Controller source, Event event) {
   if (source == assessmentOverviewCtr) {
     if (event.equals(IdentityAssessmentOverviewController.EVENT_NODE_SELECTED)) {
       AssessableCourseNode courseNode = assessmentOverviewCtr.getSelectedCourseNode();
       doEditNodeAssessment(ureq, courseNode);
     }
   } else if (source == assessmentEditCtr) {
     if (event.equals(Event.CANCELLED_EVENT)) {
       doIdentityAssessmentOverview(ureq, false);
     } else if (event.equals(Event.CHANGED_EVENT)) {
       doIdentityAssessmentOverview(ureq, true);
       fireEvent(ureq, Event.CHANGED_EVENT);
     }
   }
 }
예제 #3
0
  /**
   * @see org.olat.core.gui.control.DefaultController#event(org.olat.core.gui.UserRequest,
   *     org.olat.core.gui.control.Controller, org.olat.core.gui.control.Event)
   */
  public void event(UserRequest urequest, Controller source, Event event) {
    if (source == displayController) {
      if (event instanceof IQSubmittedEvent) {
        // Save results in case of test
        if (type.equals(AssessmentInstance.QMD_ENTRY_TYPE_ASSESS)) {
          exposeUserTestDataToVC(urequest);
        }
        // Save results in case of questionnaire
        else if (type.equals(AssessmentInstance.QMD_ENTRY_TYPE_SURVEY)) {
          exposeUserQuestionnaireDataToVC();

          if (displayContainerController != null) {
            displayContainerController.deactivate(urequest);
          } else {
            getWindowControl().pop();
          }
          OLATResourceable ores = OresHelper.createOLATResourceableInstance("test", -1l);
          addToHistory(urequest, ores, null);
        }
        // Don't save results in case of self-test
        // but do safe attempts !
        else if (type.equals(AssessmentInstance.QMD_ENTRY_TYPE_SELF)) {
          // am.incrementNodeAttempts(courseNode, urequest.getIdentity(), userCourseEnv);
        }
      } else if (event.equals(Event.DONE_EVENT)) {
        stopAssessment(urequest, event);
      } else if (IQEvent.TEST_PULLED.equals(event.getCommand())) {
        stopAssessment(urequest, event);
        showWarning("error.assessment.pulled");
      } else if (IQEvent.TEST_STOPPED.equals(event.getCommand())) {
        stopAssessment(urequest, event);
        showWarning("error.assessment.stopped");
      }
    }
  }
 @Override
 protected void event(UserRequest ureq, Controller source, Event event) {
   if (source == calloutCtrl
       && event.equals(CloseableCalloutWindowController.CLOSE_WINDOW_EVENT)) {
     removeAsListenerAndDispose(calloutCtrl);
     calloutCtrl = null;
   } else if (source == textEditCtrl && event == Event.DONE_EVENT) {
     // close callout, refresh artefact-details
     calloutCtrl.deactivate();
     removeAsListenerAndDispose(calloutCtrl);
     init(ureq);
   }
 }
  /** Event-handling from controllers */
  @Override
  protected void event(final UserRequest ureq, final Controller source, final Event event) {
    if (source == cmc) {
      if (event.equals(CloseableModalController.CLOSE_MODAL_EVENT)) {
        removeAsListenerAndDispose(cmc);
        cmc = null;
        removeAsListenerAndDispose(uploadCtr);
        uploadCtr = null;
      }
    } else if (source == uploadCtr) {
      if (event instanceof NewCPPageEvent) {
        // TODO:GW Is it necessary to set component dirty?
        // getInitialComponent().setDirty(true);
        fireEvent(ureq, event);
      }
      // Dispose the cmc and the podcastFormCtr.
      cmc.deactivate();
      removeAsListenerAndDispose(cmc);
      cmc = null;
      removeAsListenerAndDispose(uploadCtr);
      uploadCtr = null;
    } else if (source == treeCtr) {
      // event from extJSTree (TreeController)
      if (event instanceof MoveTreeNodeEvent) {
        /** move * */
        final MoveTreeNodeEvent moveEvent = (MoveTreeNodeEvent) event;
        final String selectedNodeID = treeModel.getIdentifierForNodeID(moveEvent.getNodeId());

        currentPage = new CPPage(selectedNodeID, cp);

        final MoveTreeNodeEvent newmoveEvent =
            new MoveTreeNodeEvent(
                treeModel.getIdentifierForNodeID(moveEvent.getNodeId()),
                treeModel.getIdentifierForNodeID(moveEvent.getOldParentNodeId()),
                treeModel.getIdentifierForNodeID(moveEvent.getNewParentNodeId()),
                moveEvent.getPosition());

        final boolean success = movePage(newmoveEvent);
        // setResult is important. If sucess is not true, the ajax tree will
        // popup a dialog with error-msg
        moveEvent.setResult(success, "Error", "Error while moving node");

      } else if (event instanceof TreeNodeClickedEvent) {
        /** click * */
        TreeNodeClickedEvent clickedEvent = (TreeNodeClickedEvent) event;
        final String selectedNodeID = treeModel.getIdentifierForNodeID(clickedEvent.getNodeId());

        currentPage = new CPPage(selectedNodeID, cp);

        clickedEvent = new TreeNodeClickedEvent(currentPage.getIdentifier());
        fireEvent(ureq, clickedEvent);
      } else if (event instanceof TreeNodeModifiedEvent) {
        /** a node (name) has been modified * */
        fireEvent(ureq, event);
      }
    } else if (source == dialogCtr) {
      // event from dialog (really-delete-dialog)
      if (event != Event.CANCELLED_EVENT) {
        final int position = DialogBoxUIFactory.getButtonPos(event);

        // 0 = delete with resource
        // 1 = delete without resource
        // 2 = cancel
        if (position == 0 || position == 1) {
          boolean deleteResource = false;
          if (position == 0) {
            // Delete element including files
            deleteResource = true;
          }
          final String parentIdentifier = getParentIdentifier();

          // finally delete the page
          deletePage(currentPage.getIdentifier(), deleteResource);

          if (parentIdentifier != null) {
            contentCtr.displayPage(ureq, parentIdentifier);
          }
        } else {
          // Cancel dialog and close window.
        }
      }
    }
  }
  /**
   * @see org.olat.core.gui.control.DefaultController#event(org.olat.core.gui.UserRequest,
   *     org.olat.core.gui.control.Controller, org.olat.core.gui.control.Event)
   */
  @Override
  public void event(final UserRequest ureq, final Controller source, final Event event) {
    final String cmd = event.getCommand();
    if (source == searchCtr) {
      if (cmd.equals(RepositoryTableModel.TABLE_ACTION_SELECT_ENTRY)) {
        // user selected entry to get a preview
        selectedRepositoryEntry = searchCtr.getSelectedEntry();
        final RepositoryEntry repositoryEntry = searchCtr.getSelectedEntry();
        final RepositoryHandler typeToLaunch =
            RepositoryHandlerFactory.getInstance().getRepositoryHandler(repositoryEntry);
        if (typeToLaunch == null) {
          final StringBuilder sb = new StringBuilder(translate("error.launch"));
          sb.append(": No launcher for repository entry: ");
          sb.append(repositoryEntry.getKey());
          throw new OLATRuntimeException(RepositoryDetailsController.class, sb.toString(), null);
        }
        // do skip the increment launch counter, this is only a preview!
        final OLATResourceable ores = repositoryEntry.getOlatResource();

        removeAsListenerAndDispose(previewCtr);
        previewCtr = typeToLaunch.createLaunchController(ores, null, ureq, getWindowControl());
        listenTo(previewCtr);

        removeAsListenerAndDispose(previewModalCtr);
        previewModalCtr =
            new CloseableModalController(
                getWindowControl(),
                translate("referencableSearch.preview.close"),
                previewCtr.getInitialComponent());
        listenTo(previewModalCtr);

        previewModalCtr.activate();

      } else if (cmd.equals(RepositoryTableModel.TABLE_ACTION_SELECT_LINK)) {
        // done, user selected a repo entry
        selectedRepositoryEntry = searchCtr.getSelectedEntry();
        fireEvent(ureq, EVENT_REPOSITORY_ENTRY_SELECTED);
      }
      initLinks();
    } else if (source == addController) {
      if (event.equals(Event.DONE_EVENT)) {
        cmc.deactivate();

        selectedRepositoryEntry = addController.getAddedEntry();
        fireEvent(ureq, EVENT_REPOSITORY_ENTRY_SELECTED);
        // info message
        final String message =
            translate(
                "message.entry.selected",
                new String[] {
                  addController.getAddedEntry().getDisplayname(),
                  addController.getAddedEntry().getResourcename()
                });
        getWindowControl().setInfo(message);
      } else if (event.equals(Event.CANCELLED_EVENT)) {
        cmc.deactivate();

      } else if (event.equals(Event.FAILED_EVENT)) {
        showError("add.failed");
      }
    }
  }