コード例 #1
0
  public CourseGlossaryToolLinkController(
      WindowControl wControl,
      UserRequest ureq,
      ICourse course,
      Translator translator,
      boolean allowGlossaryEditing,
      CourseEnvironment courseEnvironment,
      GlossaryMarkupItemController glossMarkupItmCtr) {
    super(ureq, wControl, translator);
    setBasePackage(RunMainController.class);
    this.allowGlossaryEditing = allowGlossaryEditing;
    courseEnvir = courseEnvironment;
    guiPrefsKey = CourseGlossaryFactory.createGuiPrefsKey(course);

    mainVC = createVelocityContainer("glossaryToolLink");

    Preferences prefs = ureq.getUserSession().getGuiPreferences();
    Boolean state = (Boolean) prefs.get(CourseGlossaryToolLinkController.class, guiPrefsKey);
    if (state == null || !state.booleanValue()) {
      onCommand = LinkFactory.createLink("command.glossary.on", mainVC, this);
      onCommand.setTitle("command.glossary.on.alt");
      onCommand.setCustomEnabledLinkCSS("b_toolbox_toggle");
    } else {
      offCommand = LinkFactory.createLink("command.glossary.off", mainVC, this);
      offCommand.setTitle("command.glossary.off.alt");
      offCommand.setCustomEnabledLinkCSS("b_toolbox_toggle");
    }

    // keep reference to textMarkerContainerCtr for later enabling/disabling
    this.glossMarkupItmCtr = glossMarkupItmCtr;

    putInitialPanel(mainVC);
  }
  /**
   * @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(final UserRequest ureq, final Component source, final Event event) {
    if (source == myEntriesLink) {
      searchCtr.doSearchByOwnerLimitType(ureq.getIdentity(), limitTypes);
      mainVC.contextPut("subtitle", translate("referencableSearch." + CMD_MY_ENTRIES));
      myEntriesLink.setCustomEnabledLinkCSS("b_selected");
      allEntriesLink.removeCSS();
      searchEntriesLink.removeCSS();
    }
    if (source == allEntriesLink) {
      searchCtr.doSearchForReferencableResourcesLimitType(
          ureq.getIdentity(), limitTypes, ureq.getUserSession().getRoles());
      mainVC.contextPut("subtitle", translate("referencableSearch." + CMD_ALL_ENTRIES));
      allEntriesLink.setCustomEnabledLinkCSS("b_selected");
      myEntriesLink.removeCSS();
      searchEntriesLink.removeCSS();
    }
    if (source == searchEntriesLink) {
      mainVC.contextPut("subtitle", translate("referencableSearch." + CMD_SEARCH_ENTRIES));
      // start with search view
      searchCtr.displaySearchForm();
      mainVC.contextPut("subtitle", translate("referencableSearch." + CMD_SEARCH));

      searchEntriesLink.setCustomEnabledLinkCSS("b_selected");
      myEntriesLink.removeCSS();
      allEntriesLink.removeCSS();
    }
    if (source == createRessourceButton) {

      removeAsListenerAndDispose(addController);
      addController =
          new RepositoryAddController(ureq, getWindowControl(), getAction(ACTION_CREATE));
      listenTo(addController);

      removeAsListenerAndDispose(cmc);
      cmc =
          new CloseableModalController(
              getWindowControl(), translate("close"), addController.getInitialComponent());
      listenTo(cmc);

      cmc.activate();
    }
    if (source == importRessourceButton) {

      removeAsListenerAndDispose(addController);
      addController =
          new RepositoryAddController(ureq, getWindowControl(), getAction(ACTION_IMPORT));
      listenTo(addController);

      removeAsListenerAndDispose(cmc);
      cmc =
          new CloseableModalController(
              getWindowControl(), translate("close"), addController.getInitialComponent());
      listenTo(cmc);

      cmc.activate();
    }
  }
コード例 #3
0
  private void setLinks() {
    importLink =
        LinkFactory.createCustomLink(
            "cptreecontroller.importlink",
            "cptreecontroller.importlink",
            null,
            Link.NONTRANSLATED,
            contentVC,
            this);
    importLink.setCustomEnabledLinkCSS("o_cpeditor_import");
    importLink.setTooltip(translate("cptreecontroller.importlink_title"), false);
    importLink.setTitle(translate("cptreecontroller.importlink_title"));

    newLink =
        LinkFactory.createCustomLink(
            "cptreecontroller.newlink",
            "cptreecontroller.newlink",
            null,
            Link.NONTRANSLATED,
            contentVC,
            this);
    newLink.setCustomEnabledLinkCSS("o_cpeditor_new");
    newLink.setTooltip(translate("cptreecontroller.newlink_title"), false);
    newLink.setTitle(translate("cptreecontroller.newlink_title"));

    copyLink =
        LinkFactory.createCustomLink(
            "cptreecontroller.copylink",
            "cptreecontroller.copylink",
            null,
            Link.NONTRANSLATED,
            contentVC,
            this);
    copyLink.setTooltip(translate("cptreecontroller.copylink_title"), false);
    copyLink.setTitle(translate("cptreecontroller.copylink_title"));
    copyLink.setCustomEnabledLinkCSS("o_cpeditor_copy");

    deleteLink =
        LinkFactory.createCustomLink(
            "cptreecontroller.deletelink",
            "cptreecontroller.deletelink",
            null,
            Link.NONTRANSLATED,
            contentVC,
            this);
    deleteLink.setTooltip(translate("cptreecontroller.deletelink_title"), false);
    deleteLink.setTitle(translate("cptreecontroller.deletelink_title"));
    deleteLink.setCustomEnabledLinkCSS("o_cpeditor_delete");
  }
コード例 #4
0
  public MoveCopySubtreeController(
      UserRequest ureq,
      WindowControl wControl,
      OLATResourceable ores,
      CourseEditorTreeNode moveCopyFrom,
      boolean copy) {
    super(ureq, wControl);
    this.ores = ores;
    this.moveCopyFrom = moveCopyFrom;
    this.copy = copy;

    ICourse course = CourseFactory.getCourseEditSession(ores.getResourceableId());
    addLoggingResourceable(LoggingResourceable.wrap(course));
    addLoggingResourceable(LoggingResourceable.wrap(moveCopyFrom.getCourseNode()));

    insertTree = new MenuTree(null, "copy_node_selection", this);
    insertTree.enableInsertTool(true);
    insertModel = new InsertTreeModel(course.getEditorTreeModel().getRootNode(), moveCopyFrom);
    insertTree.setTreeModel(insertModel);

    VelocityContainer mainVC = createVelocityContainer("moveCopyNode");

    selectButton = LinkFactory.createButton("insertAtSelectedTreepos", mainVC, this);
    selectButton.setCustomEnabledLinkCSS("btn btn-primary");
    selectButton.setCustomDisabledLinkCSS("btn btn-default");
    selectButton.setEnabled(false);
    cancelButton = LinkFactory.createButton("cancel", mainVC, this);

    int numOfNodes = TreeHelper.totalNodeCount(insertModel.getRootNode());
    if (numOfNodes > CourseModule.getCourseNodeLimit()) {
      String msg =
          getTranslator()
              .translate(
                  "warning.containsXXXormore.nodes",
                  new String[] {
                    String.valueOf(numOfNodes),
                    String.valueOf(CourseModule.getCourseNodeLimit() + 1)
                  });
      Controller tmp = MessageUIFactory.createWarnMessage(ureq, wControl, null, msg);
      listenTo(tmp);
      mainVC.put("nodelimitexceededwarning", tmp.getInitialComponent());
    }

    mainVC.put("selection", insertTree);
    putInitialPanel(mainVC);
  }
コード例 #5
0
  /**
   * @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!
      }
    }
  }