Ejemplo n.º 1
0
  @Override
  protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    setFormTitle("rest.title");
    setFormContextHelp("REST API");

    if (formLayout instanceof FormLayoutContainer) {
      FormLayoutContainer layoutContainer = (FormLayoutContainer) formLayout;

      boolean restEnabled = restModule.isEnabled();
      docLinkFlc =
          FormLayoutContainer.createCustomFormLayout(
              "doc_link", getTranslator(), velocity_root + "/docLink.html");
      layoutContainer.add(docLinkFlc);
      docLinkFlc.setVisible(restEnabled);

      String link =
          Settings.getServerContextPathURI() + RestSecurityHelper.SUB_CONTEXT + "/api/doc";
      docLinkFlc.contextPut("docLink", link);

      FormLayoutContainer accessDataFlc =
          FormLayoutContainer.createDefaultFormLayout("flc_access_data", getTranslator());
      layoutContainer.add(accessDataFlc);

      String[] values = new String[] {getTranslator().translate("rest.on")};
      enabled = uifactory.addCheckboxesHorizontal("rest.enabled", accessDataFlc, keys, values);
      enabled.select(keys[0], restEnabled);
      enabled.addActionListener(FormEvent.ONCHANGE);

      accessDataFlc.setVisible(true);
      formLayout.add(accessDataFlc);

      FormLayoutContainer managedFlc =
          FormLayoutContainer.createDefaultFormLayout("flc_managed", getTranslator());
      layoutContainer.add(managedFlc);

      String[] valueGrps = new String[] {getTranslator().translate("rest.on")};
      managedGroupsEl =
          uifactory.addCheckboxesHorizontal("managed.group", managedFlc, keys, valueGrps);
      managedGroupsEl.addActionListener(FormEvent.ONCHANGE);
      managedGroupsEl.select(keys[0], groupModule.isManagedBusinessGroups());

      String[] valueRes = new String[] {getTranslator().translate("rest.on")};
      managedRepoEl = uifactory.addCheckboxesHorizontal("managed.repo", managedFlc, keys, valueRes);
      managedRepoEl.addActionListener(FormEvent.ONCHANGE);
      managedRepoEl.select(keys[0], repositoryModule.isManagedRepositoryEntries());

      String[] valueCal = new String[] {getTranslator().translate("rest.on")};
      managedCalendarEl =
          uifactory.addCheckboxesHorizontal("managed.cal", managedFlc, keys, valueCal);
      managedCalendarEl.addActionListener(FormEvent.ONCHANGE);
      managedCalendarEl.select(keys[0], calendarModule.isManagedCalendars());
    }
  }
Ejemplo n.º 2
0
 @Override
 protected void formInnerEvent(UserRequest ureq, FormItem source, FormEvent event) {
   if (source == enabled) {
     boolean on = enabled.isAtLeastSelected(1);
     restModule.setEnabled(on);
     docLinkFlc.setVisible(on);
     getWindowControl().setInfo("saved");
   } else if (source == managedGroupsEl) {
     boolean enable = managedGroupsEl.isAtLeastSelected(1);
     groupModule.setManagedBusinessGroups(enable);
   } else if (source == managedRepoEl) {
     boolean enable = managedRepoEl.isAtLeastSelected(1);
     repositoryModule.setManagedRepositoryEntries(enable);
   } else if (source == managedCalendarEl) {
     boolean enable = managedCalendarEl.isAtLeastSelected(1);
     calendarModule.setManagedCalendars(enable);
   }
   super.formInnerEvent(ureq, source, event);
 }