Exemplo n.º 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);
  }
  /**
   * 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());
  }