@Override
  protected void event(UserRequest ureq, Controller source, Event event) {
    if (event instanceof OpenAuthorProfilEvent) {
      OpenAuthorProfilEvent uriEvent = (OpenAuthorProfilEvent) event;
      Long identityKey = uriEvent.getKey();
      if (identityKey == null) return;
      final Identity identity =
          BaseSecurityManager.getInstance().loadIdentityByKey(identityKey, false);
      if (identity == null) return;
      final HomePageConfig homePageConfig =
          HomePageConfigManagerImpl.getInstance().loadConfigFor(identity.getName());

      ControllerCreator ctrlCreator =
          new ControllerCreator() {
            public Controller createController(UserRequest lureq, WindowControl lwControl) {
              HomePageDisplayController homePageCtrl =
                  new HomePageDisplayController(lureq, lwControl, identity, homePageConfig);
              LayoutMain3ColsController layoutCtr =
                  new LayoutMain3ColsController(
                      lureq, lwControl, null, null, homePageCtrl.getInitialComponent(), null);
              // dispose glossary on layout dispose
              layoutCtr.addDisposableChildController(homePageCtrl);
              return layoutCtr;
            }
          };

      ControllerCreator layoutCtrlr =
          BaseFullWebappPopupLayoutFactory.createAuthMinimalPopupLayout(ureq, ctrlCreator);
      // open in new browser window
      openInNewBrowserWindow(ureq, layoutCtrlr);
      return; // immediate return after opening new browser window!
    } else {
      super.event(ureq, source, event);
    }
  }
Пример #2
0
  private void doJoin(UserRequest ureq) {
    boolean join = false;
    GoToError error = new GoToError();
    if (registrant == null) {
      registrant = meetingMgr.registerTraining(meeting, getIdentity(), error);
    }
    if (registrant != null) {
      String joinUrl = registrant.getJoinUrl();
      if (joinUrl != null) {
        RedirectMediaResource redirect = new RedirectMediaResource(joinUrl);
        ureq.getDispatchResult().setResultingMediaResource(redirect);
        join = true;
      }
    }
    if (!join) {
      final String errorMessage;
      if (error.hasError()) {
        if (error.getError() != null) {
          errorMessage = translate(error.getError().i18nKey());
        } else {
          errorMessage = translate("error.code.unkown");
        }
      } else {
        errorMessage = translate("error.code.unkown");
      }

      ControllerCreator creator =
          BaseFullWebappPopupLayoutFactory.createAuthMinimalPopupLayout(
              ureq,
              new ControllerCreator() {
                @Override
                public Controller createController(UserRequest lureq, WindowControl lwControl) {
                  // Wrap in column layout, popup window needs a layout controller
                  String title = "";
                  String text = errorMessage;
                  Controller ctr =
                      MessageUIFactory.createErrorMessage(lureq, lwControl, title, text);
                  LayoutMain3ColsController layoutCtr =
                      new LayoutMain3ColsController(lureq, lwControl, ctr);
                  layoutCtr.addDisposableChildController(ctr);
                  return layoutCtr;
                }
              });

      openInNewBrowserWindow(ureq, creator);
    }
    updateButtons();
  }
  /**
   * @see org.olat.core.gui.control.DefaultController#event(org.olat.core.gui.UserRequest,
   *     org.olat.core.gui.components.Component, org.olat.core.gui.control.Event)
   */
  @Override
  public void event(UserRequest ureq, Component source, Event event) {
    if (source == onCommand) {
      // toggle on
      Preferences prefs = ureq.getUserSession().getGuiPreferences();
      prefs.put(CourseGlossaryToolLinkController.class, guiPrefsKey, Boolean.TRUE);
      prefs.save();
      // update gui
      mainVC.remove(onCommand);
      offCommand = LinkFactory.createLink("command.glossary.off", mainVC, this);
      offCommand.setTitle("command.glossary.off.alt");
      offCommand.setCustomEnabledLinkCSS("b_toolbox_toggle");
      // notify textmarker controller
      glossMarkupItmCtr.setTextMarkingEnabled(true);
      fireEvent(ureq, new Event("glossaryOn"));

    } else if (source == offCommand) {
      // toggle off
      Preferences prefs = ureq.getUserSession().getGuiPreferences();
      prefs.put(CourseGlossaryToolLinkController.class, guiPrefsKey, Boolean.FALSE);
      prefs.save();
      // update gui
      mainVC.remove(offCommand);
      onCommand = LinkFactory.createLink("command.glossary.on", mainVC, this);
      onCommand.setTitle("command.glossary.on.alt");
      onCommand.setCustomEnabledLinkCSS("b_toolbox_toggle");
      // notify textmarker controller
      glossMarkupItmCtr.setTextMarkingEnabled(false);
      fireEvent(ureq, new Event("glossaryOff"));
    } else if (source == mainVC && event.getCommand().equals("command.glossary")) {
      // start glossary in window
      final CourseConfig cc = courseEnvir.getCourseConfig(); // do not cache cc, not save

      // if glossary had been opened from LR as Tab before, warn user:
      DTabs dts = Windows.getWindows(ureq).getWindow(ureq).getDTabs();
      RepositoryEntry repoEntry =
          RepositoryManager.getInstance()
              .lookupRepositoryEntryBySoftkey(cc.getGlossarySoftKey(), false);
      DTab dt = dts.getDTab(repoEntry.getOlatResource());
      if (dt != null) {
        List<ContextEntry> entries =
            BusinessControlFactory.getInstance()
                .createCEListFromResourceType(allowGlossaryEditing ? "true" : "false");
        dts.activate(ureq, dt, entries);
      } else {
        ControllerCreator ctrlCreator =
            new ControllerCreator() {
              public Controller createController(UserRequest lureq, WindowControl lwControl) {
                GlossaryMainController glossaryController =
                    CourseGlossaryFactory.createCourseGlossaryMainRunController(
                        lwControl, lureq, cc, allowGlossaryEditing);
                listenTo(glossaryController);
                if (glossaryController == null) {
                  // happens in the unlikely event of a user who is in a course and
                  // now
                  // tries to access the glossary
                  String text = translate("error.noglossary");
                  return MessageUIFactory.createInfoMessage(lureq, lwControl, null, text);
                } else {
                  // use a one-column main layout
                  LayoutMain3ColsController layoutCtr =
                      new LayoutMain3ColsController(
                          lureq,
                          lwControl,
                          null,
                          null,
                          glossaryController.getInitialComponent(),
                          null);
                  // dispose glossary on layout dispose
                  layoutCtr.addDisposableChildController(glossaryController);
                  return layoutCtr;
                }
              }
            };

        ControllerCreator layoutCtrlr =
            BaseFullWebappPopupLayoutFactory.createAuthMinimalPopupLayout(ureq, ctrlCreator);
        // open in new browser window
        openInNewBrowserWindow(ureq, layoutCtrlr);
        return; // immediate return after opening new browser window!
      }
    }
  }