Search in sources :

Example 31 with TableEvent

use of org.olat.core.gui.components.table.TableEvent in project OpenOLAT by OpenOLAT.

the class LockController method event.

/**
 * @see org.olat.core.gui.control.DefaultController#event(org.olat.core.gui.UserRequest,
 *      org.olat.core.gui.control.Controller, org.olat.core.gui.control.Event)
 */
public void event(UserRequest ureq, Controller source, Event event) {
    if (source == tableCtr) {
        if (event.getCommand().equals(Table.COMMANDLINK_ROWACTION_CLICKED)) {
            TableEvent te = (TableEvent) event;
            LockEntry lockToRelease = locksTableModel.getObject(te.getRowId());
            dialogController = activateYesNoDialog(ureq, null, translate("lock.release.sure"), dialogController);
            dialogController.setUserObject(lockToRelease);
        }
    } else if (source == dialogController) {
        if (DialogBoxUIFactory.isYesEvent(event)) {
            LockEntry lockToRelease = (LockEntry) dialogController.getUserObject();
            MultiUserEvent mue = new LockRemovedEvent(lockToRelease);
            OLATResourceable lockEntryOres = OresHelper.createOLATResourceableInstance(LockEntry.class, 0l);
            CoordinatorManager.getInstance().getCoordinator().getEventBus().fireEventToListenersOf(mue, lockEntryOres);
            CoordinatorManager.getInstance().getCoordinator().getLocker().releaseLockEntry(lockToRelease);
            lockToRelease = null;
            resetTableModel();
        }
    }
}
Also used : LockRemovedEvent(org.olat.core.util.coordinate.LockRemovedEvent) TableEvent(org.olat.core.gui.components.table.TableEvent) LockEntry(org.olat.core.util.coordinate.LockEntry) OLATResourceable(org.olat.core.id.OLATResourceable) MultiUserEvent(org.olat.core.util.event.MultiUserEvent)

Example 32 with TableEvent

use of org.olat.core.gui.components.table.TableEvent in project OpenOLAT by OpenOLAT.

the class UserSessionController method event.

/**
 * @see org.olat.core.gui.control.DefaultController#event(org.olat.core.gui.UserRequest,
 *      org.olat.core.gui.control.Controller, org.olat.core.gui.control.Event)
 */
public void event(UserRequest ureq, Controller source, Event event) {
    if (source == tableCtr) {
        if (event.getCommand().equals(Table.COMMANDLINK_ROWACTION_CLICKED)) {
            TableEvent te = (TableEvent) event;
            int selRow = te.getRowId();
            // session info (we only have authenticated sessions here
            UserSessionView usessw = (UserSessionView) tableCtr.getTableDataModel().getObject(selRow);
            if ("sess.chat".equals(te.getActionId())) {
                Buddy buddy = imService.getBuddyById(usessw.getIdentityKey());
                OpenInstantMessageEvent e = new OpenInstantMessageEvent(ureq, buddy);
                ureq.getUserSession().getSingleUserEventCenter().fireEventToListenersOf(e, InstantMessagingService.TOWER_EVENT_ORES);
            } else if ("sess.details".equals(te.getActionId())) {
                UserSession usess = usessw.getUserSession();
                UserSessionDetailsController detailsCtrl = new UserSessionDetailsController(ureq, getWindowControl(), usess);
                listenTo(detailsCtrl);
                String username = usess.getIdentity() == null ? "-" : UserManager.getInstance().getUserDisplayName(usess.getIdentity());
                stackController.pushController(username, detailsCtrl);
            }
        }
    }
}
Also used : TableEvent(org.olat.core.gui.components.table.TableEvent) UserSession(org.olat.core.util.UserSession) OpenInstantMessageEvent(org.olat.instantMessaging.OpenInstantMessageEvent) UserSessionView(org.olat.admin.sysinfo.model.UserSessionView) Buddy(org.olat.instantMessaging.model.Buddy)

Example 33 with TableEvent

use of org.olat.core.gui.components.table.TableEvent in project OpenOLAT by OpenOLAT.

the class UserSearchController method event.

/**
 * @see org.olat.core.gui.control.DefaultController#event(org.olat.core.gui.UserRequest,
 *      org.olat.core.gui.control.Controller, org.olat.core.gui.control.Event)
 */
public void event(UserRequest ureq, Controller source, Event event) {
    if (source == tableCtr) {
        if (event.getCommand().equals(Table.COMMANDLINK_ROWACTION_CLICKED)) {
            TableEvent te = (TableEvent) event;
            if (te.getActionId().equals(ACTION_SINGLESELECT_CHOOSE)) {
                int rowid = te.getRowId();
                Identity foundIdentity = tdm.getObject(rowid);
                foundIdentities.add(foundIdentity);
                // Tell parentController that a subject has been found
                fireEvent(ureq, new SingleIdentityChosenEvent(foundIdentity));
            }
        } else if (event.getCommand().equals(Table.COMMAND_MULTISELECT)) {
            TableMultiSelectEvent tmse = (TableMultiSelectEvent) event;
            if (tmse.getAction().equals(ACTION_MULTISELECT_CHOOSE)) {
                foundIdentities = tdm.getObjects(tmse.getSelection());
                fireEvent(ureq, new MultiIdentityChosenEvent(foundIdentities));
            }
        }
    } else if (source == autocompleterC) {
        if (event instanceof EntriesChosenEvent) {
            EntriesChosenEvent ece = (EntriesChosenEvent) event;
            List<String> res = ece.getEntries();
            // if we get the event, we have a result or an incorrect selection see OLAT-5114 -> check for empty
            String mySel = res.isEmpty() ? null : (String) res.get(0);
            if ((mySel == null) || mySel.trim().equals("")) {
                getWindowControl().setWarning(translate("error.search.form.notempty"));
                return;
            }
            // default not found
            Long key = -1l;
            try {
                key = Long.valueOf(mySel);
                if (key > 0) {
                    Identity chosenIdent = BaseSecurityManager.getInstance().loadIdentityByKey(key);
                    // No need to check for null, exception is thrown when identity does not exist which really
                    // should not happen at all.
                    // Tell that an identity has been chosen
                    fireEvent(ureq, new SingleIdentityChosenEvent(chosenIdent));
                }
            } catch (NumberFormatException e) {
                getWindowControl().setWarning(translate("error.no.user.found"));
                return;
            }
        }
    } else if (source == searchform) {
        if (event == Event.DONE_EVENT) {
            // form validation was ok
            doSearch(ureq);
        } else if (event == Event.CANCELLED_EVENT) {
            fireEvent(ureq, Event.CANCELLED_EVENT);
        }
    }
}
Also used : TableEvent(org.olat.core.gui.components.table.TableEvent) TableMultiSelectEvent(org.olat.core.gui.components.table.TableMultiSelectEvent) SingleIdentityChosenEvent(org.olat.basesecurity.events.SingleIdentityChosenEvent) ArrayList(java.util.ArrayList) List(java.util.List) Identity(org.olat.core.id.Identity) MultiIdentityChosenEvent(org.olat.basesecurity.events.MultiIdentityChosenEvent) EntriesChosenEvent(org.olat.core.gui.control.generic.ajax.autocompletion.EntriesChosenEvent)

Example 34 with TableEvent

use of org.olat.core.gui.components.table.TableEvent in project OpenOLAT by OpenOLAT.

the class AllCachesController method event.

@Override
protected void event(UserRequest ureq, Controller source, Event event) {
    if (source == tableCtr) {
        if (event.getCommand().equals(Table.COMMANDLINK_ROWACTION_CLICKED)) {
            TableEvent te = (TableEvent) event;
            String actionid = te.getActionId();
            if (actionid.equals("empty")) {
                Object cacheInfos = tableCtr.getTableDataModel().getObject(te.getRowId());
                dc = activateYesNoDialog(ureq, null, translate("confirm.emptycache"), dc);
                dc.setUserObject(cacheInfos);
            }
        }
    } else if (source == dc) {
        if (DialogBoxUIFactory.isYesEvent(event)) {
            String cacheName = null;
            try {
                CacheInfos cacheInfos = (CacheInfos) dc.getUserObject();
                cacheInfos.clear();
                loadModel();
            } catch (IllegalStateException e) {
                log.error("Cannot remove Cache:" + cacheName, e);
            }
        }
    }
}
Also used : TableEvent(org.olat.core.gui.components.table.TableEvent)

Example 35 with TableEvent

use of org.olat.core.gui.components.table.TableEvent in project OpenOLAT by OpenOLAT.

the class QuotaController method event.

@Override
public void event(UserRequest ureq, Controller source, Event event) {
    if (source == quotaEditCtr) {
        if (event == Event.CHANGED_EVENT) {
            quotaTableModel.refresh();
            tableCtr.setTableDataModel(quotaTableModel);
        }
        // else cancel event. in any case set content to list
        main.setContent(myContent);
    }
    if (source == tableCtr && event.getCommand().equals(Table.COMMANDLINK_ROWACTION_CLICKED)) {
        TableEvent te = (TableEvent) event;
        Quota q = quotaTableModel.getRowData(te.getRowId());
        if (te.getActionId().equals("qf.edit")) {
            // clean up old controller first
            // start edit workflow in dedicated quota edit controller
            removeAsListenerAndDispose(quotaEditCtr);
            quotaEditCtr = new GenericQuotaEditController(ureq, getWindowControl(), q);
            listenTo(quotaEditCtr);
            main.setContent(quotaEditCtr.getInitialComponent());
        } else if (te.getActionId().equals("qf.del")) {
            // try to delete quota
            boolean deleted = QuotaManager.getInstance().deleteCustomQuota(q);
            if (deleted) {
                quotaTableModel.refresh();
                tableCtr.setTableDataModel(quotaTableModel);
                showInfo("qf.deleted", q.getPath());
            } else {
                // default quotas can not be deleted
                showError("qf.cannot.del.default");
            }
        }
    }
}
Also used : TableEvent(org.olat.core.gui.components.table.TableEvent) Quota(org.olat.core.util.vfs.Quota)

Aggregations

TableEvent (org.olat.core.gui.components.table.TableEvent)114 ArrayList (java.util.ArrayList)42 List (java.util.List)40 TableMultiSelectEvent (org.olat.core.gui.components.table.TableMultiSelectEvent)40 CloseableModalController (org.olat.core.gui.control.generic.closablewrapper.CloseableModalController)16 Identity (org.olat.core.id.Identity)16 BitSet (java.util.BitSet)12 WindowControl (org.olat.core.gui.control.WindowControl)12 SingleIdentityChosenEvent (org.olat.basesecurity.events.SingleIdentityChosenEvent)10 UserRequest (org.olat.core.gui.UserRequest)10 ControllerCreator (org.olat.core.gui.control.creator.ControllerCreator)10 PopupBrowserWindow (org.olat.core.gui.control.generic.popup.PopupBrowserWindow)10 MultiIdentityChosenEvent (org.olat.basesecurity.events.MultiIdentityChosenEvent)8 BusinessGroup (org.olat.group.BusinessGroup)8 RepositoryEntry (org.olat.repository.RepositoryEntry)8 AssertException (org.olat.core.logging.AssertException)6 UserInfoMainController (org.olat.user.UserInfoMainController)6 KalendarEvent (org.olat.commons.calendar.model.KalendarEvent)4 LayoutMain3ColsController (org.olat.core.commons.fullWebApp.LayoutMain3ColsController)4 Subscriber (org.olat.core.commons.services.notifications.Subscriber)4