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();
}
}
}
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);
}
}
}
}
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);
}
}
}
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);
}
}
}
}
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");
}
}
}
}
Aggregations