Beispiel #1
0
  /**
   * Controls locks in admin view.
   *
   * @param ureq
   * @param wControl
   */
  public LockController(UserRequest ureq, WindowControl wControl) {
    super(ureq, wControl);

    myContent = createVelocityContainer("locks");

    TableGuiConfiguration tableConfig = new TableGuiConfiguration();
    tableConfig.setDownloadOffered(false);
    tableCtr = new TableController(tableConfig, ureq, getWindowControl(), getTranslator());
    tableCtr.addColumnDescriptor(
        new DefaultColumnDescriptor("lock.key", Cols.key.ordinal(), null, getLocale()));

    BaseSecurityModule securityModule = CoreSpringFactory.getImpl(BaseSecurityModule.class);
    if (securityModule.isUserAllowedAdminProps(ureq.getUserSession().getRoles())) {
      tableCtr.addColumnDescriptor(
          new DefaultColumnDescriptor("lock.owner", Cols.ownerName.ordinal(), null, getLocale()));
    }
    tableCtr.addColumnDescriptor(
        new DefaultColumnDescriptor("lock.owner", Cols.ownerFullname.ordinal(), null, getLocale()));
    tableCtr.addColumnDescriptor(
        new DefaultColumnDescriptor(
            "lock.aquiretime", Cols.acquiredTime.ordinal(), null, getLocale()));
    tableCtr.addColumnDescriptor(
        new StaticColumnDescriptor("lock.release", "lock.release", translate("lock.release")));
    listenTo(tableCtr);
    resetTableModel();
    myContent.put("locktable", tableCtr.getInitialComponent());
    putInitialPanel(myContent);
  }
  /**
   * @param ureq
   * @param wControl
   * @param fallBackTranslator
   * @param tableDataModel => See class-description!
   * @param sortedItems
   */
  public PortletManualSortingConfigurator(
      UserRequest ureq,
      WindowControl wControl,
      Translator fallBackTranslator,
      PortletDefaultTableDataModel<T> tableDataModel,
      List<PortletEntry<T>> sortedItems) {
    super(ureq, wControl, fallBackTranslator);
    this.tableDataModel = tableDataModel;
    this.sortedItems = sortedItems; // select the items in table!!!

    mainVC = createVelocityContainer("manualSorting");
    tablePanel = new Panel("table");
    mainVC.put("table", tablePanel);

    TableGuiConfiguration tableConfig = new TableGuiConfiguration();
    tableConfig.setMultiSelect(true);
    tableConfig.setSortingEnabled(true);
    tableConfig.setTableEmptyMessage("manual.sorting.no.entries.found");
    tableController = new TableController(tableConfig, ureq, getWindowControl(), getTranslator());
    listenTo(tableController);
    int maxNumColumns = tableDataModel.getColumnCount();
    int columnCounter = 0;
    tableController.addColumnDescriptor(
        new DefaultColumnDescriptor(
            "table.manual.sorting.title", columnCounter++, null, getLocale()));
    if (maxNumColumns == 2) {
      tableController.addColumnDescriptor(
          new DefaultColumnDescriptor(
              "table.manual.sorting.date", columnCounter++, null, getLocale()));
    } else {
      DefaultColumnDescriptor descCol =
          new DefaultColumnDescriptor(
              "table.manual.sorting.description", columnCounter++, null, getLocale());
      descCol.setEscapeHtml(EscapeMode.antisamy);
      tableController.addColumnDescriptor(descCol);
    }
    if (maxNumColumns == 4) {
      tableController.addColumnDescriptor(
          new DefaultColumnDescriptor(
              "table.manual.sorting.type", columnCounter++, null, getLocale()));
    }
    tableController.addMultiSelectAction("action.choose", ACTION_MULTISELECT_CHOOSE);
    tableController.addMultiSelectAction("action.cancel", ACTION_MULTISELECT_CANCEL);
    tableController.setTableDataModel(tableDataModel);
    tablePanel.setContent(tableController.getInitialComponent());

    putInitialPanel(mainVC);
  }
  /**
   * Constructor
   *
   * @param ureq
   * @param component
   */
  public NotificationsPortletRunController(
      WindowControl wControl,
      UserRequest ureq,
      Translator trans,
      String portletName,
      int defaultMaxEntries) {
    super(wControl, ureq, trans, portletName, defaultMaxEntries);

    sortingTermsList.add(SortingCriteria.TYPE_SORTING);
    sortingTermsList.add(SortingCriteria.ALPHABETICAL_SORTING);
    sortingTermsList.add(SortingCriteria.DATE_SORTING);

    this.notificationsVC = this.createVelocityContainer("notificationsPortlet");
    showAllLink = LinkFactory.createLink("notificationsPortlet.showAll", notificationsVC, this);
    showAllLink.setIconRightCSS("o_icon o_icon_start");

    TableGuiConfiguration tableConfig = new TableGuiConfiguration();
    tableConfig.setTableEmptyMessage(trans.translate("notificationsPortlet.nonotifications"));
    tableConfig.setDisplayTableHeader(false);
    tableConfig.setCustomCssClass("o_portlet_table");
    tableConfig.setDisplayRowCount(false);
    tableConfig.setPageingEnabled(false);
    tableConfig.setDownloadOffered(false);
    // disable the default sorting for this table
    tableConfig.setSortingEnabled(false);
    tableCtr = new TableController(tableConfig, ureq, getWindowControl(), trans);
    listenTo(tableCtr);

    // dummy header key, won't be used since setDisplayTableHeader is set to false
    tableCtr.addColumnDescriptor(
        new DefaultColumnDescriptor(
            "notificationsPortlet.bgname", 0, CMD_LAUNCH, trans.getLocale()));
    tableCtr.addColumnDescriptor(
        new DefaultColumnDescriptor(
            "notificationsPortlet.type",
            1,
            null,
            trans.getLocale(),
            ColumnDescriptor.ALIGNMENT_RIGHT));

    this.sortingCriteria = getPersistentSortingConfiguration(ureq);
    man = NotificationsManager.getInstance();
    // default use the interval
    compareDate = man.getCompareDateFromInterval(man.getUserIntervalOrDefault(ureq.getIdentity()));
    reloadModel(sortingCriteria);

    this.notificationsVC.put("table", tableCtr.getInitialComponent());
    // notify us whenever we will be shown on screen shortly, so that we can reload the model if we
    // received a subscription changed event in the meantime
    ComponentUtil.registerForValidateEvents(notificationsVC, this);

    putInitialPanel(notificationsVC);

    man.registerAsListener(this, ureq.getIdentity());
  }
  private void initializeTableController(UserRequest ureq) {
    TableGuiConfiguration tableConfig = new TableGuiConfiguration();
    tableConfig.setTableEmptyMessage(translate("error.no.user.found"));
    tableConfig.setShowAllLinkEnabled(false);

    removeAsListenerAndDispose(tableCtr);
    tableCtr =
        new TableController(tableConfig, ureq, getWindowControl(), this.propertyHandlerTranslator);
    listenTo(tableCtr);

    List<Identity> l =
        UserDeletionManager.getInstance()
            .getIdentitiesInDeletionProcess(
                UserDeletionManager.getInstance().getDeleteEmailDuration());
    tdm = new UserDeleteTableModel(l, getLocale(), isAdministrativeUser);
    tdm.addColumnDescriptors(tableCtr, null, "table.identity.deleteEmail");
    tableCtr.addColumnDescriptor(
        new StaticColumnDescriptor(
            ACTION_SINGLESELECT_CHOOSE, "table.header.action", translate("action.activate")));
    tableCtr.addMultiSelectAction("action.ready.to.delete", ACTION_MULTISELECT_CHOOSE);
    tableCtr.setMultiSelect(true);
    tableCtr.setTableDataModel(tdm);
  }