use of org.olat.core.gui.components.table.TableEvent in project OpenOLAT by OpenOLAT.
the class WikiMainController method event.
@Override
public void event(UserRequest ureq, Controller source, Event event) {
Wiki wiki = getWiki();
if (wiki == null) {
mainPanel.setContent(createVelocityContainer("deleted"));
return;
}
// reload page from cache
WikiPage page = wiki.getPage(pageId, true);
// set recent page id to the page currently used
this.pageId = page.getPageId();
if (event instanceof TreeEvent) {
TreeEvent te = (TreeEvent) event;
String nodeId = te.getNodeId();
if (navAZNode.getIdent().equals(nodeId)) {
openAtoZPage(ureq, wiki);
} else if (navChangesNode.getIdent().equals(nodeId)) {
openLastChangesPage(ureq, wiki);
} else if (navMainPageNode.getIdent().equals(nodeId)) {
page = openIndexPage(ureq, wiki);
} else if (wikiMenuNode.getIdent().equals(nodeId)) {
page = openPage(ureq, WikiPage.WIKI_MENU_PAGE, wiki);
} else {
TreeNode node = wikiMenuModel.getNodeById(nodeId);
if (node != null && node.getUserObject() instanceof String) {
String link = (String) node.getUserObject();
page = openPage(ureq, link, wiki);
}
}
if (page != null) {
this.pageId = page.getPageId();
}
} else if (source == versioningTableCtr) {
/**
***********************************************************************
* history table events
***********************************************************************
*/
if (event.getCommand().equals(Table.COMMANDLINK_ROWACTION_CLICKED)) {
TableEvent te = (TableEvent) event;
if (te.getActionId().equals(ACTION_COMPARE)) {
selectedPage = versioningTableModel.getObject(te.getRowId());
diffs = wiki.getDiff(page, selectedPage.getVersion() - 1, selectedPage.getVersion());
versioningContent.contextPut("diffs", diffs);
versioningContent.remove(wikiVersionDisplayComp);
versioningContent.contextPut("page", selectedPage);
} else if (te.getActionId().equals(ACTION_SHOW)) {
versioningContent.contextRemove("diffs");
selectedPage = versioningTableModel.getObject(te.getRowId());
selectedPage = wiki.loadVersion(selectedPage, selectedPage.getVersion());
wikiVersionDisplayComp.setWikiContent(selectedPage.getContent());
wikiVersionDisplayComp.setImageMapperUri(ureq, wikiContainer);
versioningContent.put("versionDisplay", wikiVersionDisplayComp);
versioningContent.contextPut("page", selectedPage);
}
}
} else if (source == wikiUploadFileCtr) {
if (event.getCommand().equals(FolderEvent.UPLOAD_EVENT)) {
FolderEvent fEvent = (FolderEvent) event;
createMediaMetadataFile(fEvent.getFilename(), ureq.getIdentity().getKey());
updateFileAndLinkList(wiki);
}
cmc.deactivate();
cleanUp();
} else if (source == removePageDialogCtr) {
if (DialogBoxUIFactory.isOkEvent(event)) {
wiki.removePage(page);
breadcrumpDropdown.removeComponent(page.getPageName());
WikiManager.getInstance().deleteWikiPage(ores, page);
page = wiki.getPage(WikiPage.WIKI_INDEX_PAGE);
updatePageContext(ureq, page);
tabs.setSelectedPane(ureq, 0);
}
} else if (source == mediaTableCtr) {
if (event.getCommand().equals(Table.COMMANDLINK_ROWACTION_CLICKED)) {
TableEvent te = (TableEvent) event;
if (te.getActionId().equals(ACTION_DELETE_MEDIA)) {
List<MediaFileElement> list = new ArrayList<MediaFileElement>(1);
list.add(mediaFilesTableModel.getObject(te.getRowId()));
deleteMediaFile(list, ureq);
} else if (te.getActionId().equals(ACTION_SHOW_MEDIA)) {
// show a selected file from the media folder
MediaFileElement element = mediaFilesTableModel.getObject(te.getRowId());
if (isImage(element.getFilename())) {
// show images inline
// as modal overlay
imageDisplay.contextPut("mediaElement", element);
imageDisplay.contextPut("imageUri", wikiArticleComp.getImageBaseUri());
removeAsListenerAndDispose(cmc);
cmc = new CloseableModalController(getWindowControl(), translate("close"), imageDisplay);
listenTo(cmc);
cmc.activate();
} else {
deliverMediaFile(ureq, element.getFilename());
}
}
} else if (event.getCommand().equals(Table.COMMAND_MULTISELECT)) {
TableMultiSelectEvent tmse = (TableMultiSelectEvent) event;
if (tmse.getAction().equals(ACTION_DELETE_MEDIAS)) {
deleteMediaFile(mediaFilesTableModel.getObjects(tmse.getSelection()), ureq);
updateFileAndLinkList(wiki);
}
}
} else if (source == archiveWikiDialogCtr) {
if (DialogBoxUIFactory.isOkEvent(event)) {
WikiToCPResource rsrc = new WikiToCPResource(ores, getIdentity(), getTranslator());
ureq.getDispatchResult().setResultingMediaResource(rsrc);
}
} else if (source == createArticleForm) {
calloutCtrl.deactivate();
String query = createArticleForm.getQuery();
if (!StringHelper.containsNonWhitespace(query)) {
query = WikiPage.WIKI_INDEX_PAGE;
}
page = wiki.findPage(query);
pageId = page.getPageId();
if (page.getPageName().equals(Wiki.NEW_PAGE)) {
setTabsEnabled(false);
}
page.incrementViewCount();
updatePageContext(ureq, page);
if (!page.getPageName().startsWith("O_")) {
Link pageLink = LinkFactory.createToolLink(page.getPageName(), "select-page", page.getPageName(), this);
breadcrumpDropdown.addComponent(pageLink);
}
tabs.setSelectedPane(ureq, 0);
} else if (source == wikiEditForm) {
// set recent page id to the page currently used
this.pageId = page.getPageId();
boolean wantPreview = false;
boolean wantSave = false;
boolean wantClose = false;
if (event == Event.CANCELLED_EVENT) {
wantClose = true;
} else if (event == Event.DONE_EVENT) {
wantSave = true;
} else if (event.getCommand().equals("save.and.close")) {
wantClose = true;
wantSave = true;
event = Event.DONE_EVENT;
} else if (event.getCommand().equals("preview")) {
wantPreview = true;
event = Event.DONE_EVENT;
} else if (event.getCommand().equals("delete.page")) {
String msg = translate("question", page.getPageName());
removePageDialogCtr = activateOkCancelDialog(ureq, null, msg, removePageDialogCtr);
return;
} else if (event.getCommand().equals("media.upload")) {
doUploadFiles(ureq);
return;
} else if (event.getCommand().equals("manage.media")) {
doManageMedias(ureq, wiki);
return;
}
boolean dirty = !wikiEditForm.getWikiContent().equals(page.getContent());
if (wantPreview) {
WikiPage preview = new WikiPage("temp");
preview.setContent(wikiEditForm.getWikiContent());
wikiVersionDisplayComp.setWikiContent(preview.getContent());
editContent.put("versionDisplay", wikiVersionDisplayComp);
}
if (wantSave && dirty) {
editContent.contextPut("isDirty", Boolean.valueOf(false));
page.setContent(wikiEditForm.getWikiContent());
page.setModifyAuthor(getIdentity().getKey().longValue());
page.setUpdateComment(wikiEditForm.getUpdateComment());
if (page.getInitalAuthor() == 0)
page.setInitalAuthor(getIdentity().getKey().longValue());
// changed
if (page.getPageName().equals(WikiPage.WIKI_MENU_PAGE)) {
updateWikiMenu(wiki);
}
WikiManager.getInstance().saveWikiPage(ores, page, true, wiki);
// inform subscription context about changes
NotificationsManager.getInstance().markPublisherNews(subsContext, ureq.getIdentity(), true);
updatePageContext(ureq, page);
}
if (dirty && wantPreview && !wantSave) {
// wikiEditForm.setDirty(true);
editContent.contextPut("isDirty", Boolean.valueOf(dirty));
}
if (wantClose) {
tabs.setSelectedPane(ureq, 0);
doReleaseEditLock();
return;
}
}
}
use of org.olat.core.gui.components.table.TableEvent in project OpenOLAT by OpenOLAT.
the class NotesPortletRunController method event.
/**
* @see org.olat.core.gui.control.ControllerEventListener#dispatchEvent(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) {
super.event(ureq, source, event);
if (source == tableCtr) {
if (event.getCommand().equals(Table.COMMANDLINK_ROWACTION_CLICKED)) {
TableEvent te = (TableEvent) event;
String actionid = te.getActionId();
if (actionid.equals(CMD_LAUNCH)) {
int rowid = te.getRowId();
final NotePortletEntry pe = (NotePortletEntry) notesListModel.getObject(rowid);
final Note note = pe.getValue();
// will not be disposed on course run dispose, popus up as new browserwindow
ControllerCreator ctrlCreator = new ControllerCreator() {
public Controller createController(UserRequest lureq, WindowControl lwControl) {
Controller nc = new NoteController(lureq, lwControl, note);
// use on column layout
LayoutMain3ColsController layoutCtr = new LayoutMain3ColsController(lureq, lwControl, nc);
// dispose content on layout dispose
layoutCtr.addDisposableChildController(nc);
return layoutCtr;
}
};
// wrap the content controller into a full header layout
ControllerCreator layoutCtrlr = BaseFullWebappPopupLayoutFactory.createAuthMinimalPopupLayout(ureq, ctrlCreator);
// open in new browser window
PopupBrowserWindow pbw = getWindowControl().getWindowBackOffice().getWindowManager().createNewPopupBrowserWindowFor(ureq, layoutCtrlr);
pbw.open(ureq);
//
}
}
}
}
use of org.olat.core.gui.components.table.TableEvent in project OpenOLAT by OpenOLAT.
the class GroupController 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)
*/
@Override
public void event(UserRequest ureq, Controller sourceController, Event event) {
if (sourceController == tableCtr) {
if (event.getCommand().equals(Table.COMMANDLINK_ROWACTION_CLICKED)) {
// Single row selects
TableEvent te = (TableEvent) event;
String actionid = te.getActionId();
final Identity identity = identitiesTableModel.getObject(te.getRowId()).getIdentity();
if (actionid.equals(COMMAND_VCARD)) {
// get identity and open new visiting card controller in new window
ControllerCreator userInfoMainControllerCreator = new ControllerCreator() {
@Override
public Controller createController(UserRequest lureq, WindowControl lwControl) {
return new UserInfoMainController(lureq, lwControl, identity, true, false);
}
};
// wrap the content controller into a full header layout
ControllerCreator layoutCtrlr = BaseFullWebappPopupLayoutFactory.createAuthMinimalPopupLayout(ureq, userInfoMainControllerCreator);
// open in new browser window
PopupBrowserWindow pbw = getWindowControl().getWindowBackOffice().getWindowManager().createNewPopupBrowserWindowFor(ureq, layoutCtrlr);
pbw.open(ureq);
//
} else if (actionid.equals(COMMAND_SELECTUSER)) {
fireEvent(ureq, new SingleIdentityChosenEvent(identity));
} else if (COMMAND_IM.equals(actionid)) {
doIm(ureq, identity);
}
} else if (event.getCommand().equals(Table.COMMAND_MULTISELECT)) {
// Multiselect events
TableMultiSelectEvent tmse = (TableMultiSelectEvent) event;
if (tmse.getAction().equals(COMMAND_REMOVEUSER)) {
if (tmse.getSelection().isEmpty()) {
// empty selection
showWarning("msg.selectionempty");
return;
}
int size = identitiesTableModel.getObjects().size();
toRemove = identitiesTableModel.getIdentities(tmse.getSelection());
// list is never null, but can be empty
if (keepAtLeastOne && (size == 1 || size - toRemove.size() == 0)) {
// at least one must be kept
// do not delete the last one => ==1
// do not allow to delete all => size - selectedCnt == 0
showError("msg.atleastone");
} else {
// valid selection to be deleted.
if (removeUserMailDefaultTempl == null) {
doBuildConfirmDeleteDialog(ureq);
} else {
removeAsListenerAndDispose(removeUserMailCtr);
removeUserMailCtr = new MailNotificationEditController(getWindowControl(), ureq, removeUserMailDefaultTempl, true, false, true);
listenTo(removeUserMailCtr);
removeAsListenerAndDispose(cmc);
cmc = new CloseableModalController(getWindowControl(), translate("close"), removeUserMailCtr.getInitialComponent());
listenTo(cmc);
cmc.activate();
}
}
}
}
} else if (sourceController == removeUserMailCtr) {
if (event == Event.DONE_EVENT) {
removeUserMailCustomTempl = removeUserMailCtr.getMailTemplate();
cmc.deactivate();
doBuildConfirmDeleteDialog(ureq);
} else {
cmc.deactivate();
}
} else if (sourceController == usc) {
if (event == Event.CANCELLED_EVENT) {
cmc.deactivate();
} else {
if (event instanceof SingleIdentityChosenEvent) {
SingleIdentityChosenEvent singleEvent = (SingleIdentityChosenEvent) event;
Identity choosenIdentity = singleEvent.getChosenIdentity();
if (choosenIdentity == null) {
showError("msg.selectionempty");
return;
}
toAdd = new ArrayList<Identity>();
toAdd.add(choosenIdentity);
} else if (event instanceof MultiIdentityChosenEvent) {
MultiIdentityChosenEvent multiEvent = (MultiIdentityChosenEvent) event;
toAdd = multiEvent.getChosenIdentities();
if (toAdd.size() == 0) {
showError("msg.selectionempty");
return;
}
} else {
throw new RuntimeException("unknown event ::" + event.getCommand());
}
if (toAdd.size() == 1) {
// check if already in group [makes only sense for a single choosen identity]
if (groupDao.hasRole(group, toAdd.get(0), role)) {
String fullName = userManager.getUserDisplayName(toAdd.get(0));
getWindowControl().setInfo(translate("msg.subjectalreadyingroup", new String[] { fullName }));
return;
}
} else if (toAdd.size() > 1) {
// check if already in group
List<Identity> alreadyInGroup = new ArrayList<Identity>();
for (int i = 0; i < toAdd.size(); i++) {
if (groupDao.hasRole(group, toAdd.get(i), role)) {
tableCtr.setMultiSelectSelectedAt(i, false);
alreadyInGroup.add(toAdd.get(i));
}
}
if (!alreadyInGroup.isEmpty()) {
StringBuilder names = new StringBuilder();
for (Identity ident : alreadyInGroup) {
if (names.length() > 0)
names.append(", ");
names.append(userManager.getUserDisplayName(ident));
toAdd.remove(ident);
}
getWindowControl().setInfo(translate("msg.subjectsalreadyingroup", names.toString()));
}
if (toAdd.isEmpty()) {
return;
}
}
// in both cases continue adding the users or asking for the mail
// template if available (=not null)
cmc.deactivate();
if (addUserMailDefaultTempl == null) {
doAddIdentitiesToGroup(ureq, toAdd, null);
} else {
removeAsListenerAndDispose(addUserMailCtr);
addUserMailCtr = new MailNotificationEditController(getWindowControl(), ureq, addUserMailDefaultTempl, true, mandatoryEmail, true);
listenTo(addUserMailCtr);
removeAsListenerAndDispose(cmc);
cmc = new CloseableModalController(getWindowControl(), translate("close"), addUserMailCtr.getInitialComponent());
listenTo(cmc);
cmc.activate();
}
}
// in any case cleanup this controller, not used anymore
usc.dispose();
usc = null;
} else if (sourceController == addUserMailCtr) {
if (event == Event.DONE_EVENT) {
MailTemplate customTemplate = addUserMailCtr.getMailTemplate();
doAddIdentitiesToGroup(ureq, toAdd, customTemplate);
cmc.deactivate();
} else if (event == Event.CANCELLED_EVENT) {
cmc.deactivate();
} else {
throw new RuntimeException("unknown event ::" + event.getCommand());
}
} else if (sourceController == confirmDelete) {
if (DialogBoxUIFactory.isYesEvent(event)) {
// before deleting, assure it is allowed
if (!mayModifyMembers)
throw new AssertException("not allowed to remove member!");
// list is never null, but can be empty
// TODO: Theoretically it can happen that the table model here is not accurate!
// the 'keep at least one' should be handled by the security manager that should
// synchronizes the method on the group
int size = identitiesTableModel.getObjects().size();
if (keepAtLeastOne && (size - toRemove.size() == 0)) {
showError("msg.atleastone");
} else {
doRemoveIdentitiesFromGroup(ureq, toRemove, removeUserMailCustomTempl);
}
}
} else if (sourceController == userToGroupWizard) {
if (event == Event.CANCELLED_EVENT || event == Event.DONE_EVENT || event == Event.CHANGED_EVENT) {
getWindowControl().pop();
removeAsListenerAndDispose(userToGroupWizard);
userToGroupWizard = null;
if (event == Event.DONE_EVENT || event == Event.CHANGED_EVENT) {
reloadData();
}
}
}
}
use of org.olat.core.gui.components.table.TableEvent in project OpenOLAT by OpenOLAT.
the class ScormResultDetailsController method event.
@Override
public void event(UserRequest ureq, Controller source, Event event) {
if (source == summaryTableCtr) {
TableEvent tEvent = (TableEvent) event;
if (tEvent.getActionId().equals("sel")) {
TableGuiConfiguration tableConfig = new TableGuiConfiguration();
tableConfig.setPreferencesOffered(true, "scormAssessmentDetails");
removeAsListenerAndDispose(cmiTableCtr);
cmiTableCtr = new TableController(tableConfig, ureq, getWindowControl(), getTranslator());
listenTo(cmiTableCtr);
cmiTableCtr.addColumnDescriptor(new DefaultColumnDescriptor("cmis.column.header.itemId", 0, null, ureq.getLocale()));
cmiTableCtr.addColumnDescriptor(new DefaultColumnDescriptor("cmis.column.header.translatedKey", 1, null, ureq.getLocale()));
cmiTableCtr.addColumnDescriptor(new DefaultColumnDescriptor("cmis.column.header.key", 2, null, ureq.getLocale()));
cmiTableCtr.addColumnDescriptor(new DefaultColumnDescriptor("cmis.column.header.value", 3, null, ureq.getLocale()));
// <BPS-252> BPS-252_3
int rowId = tEvent.getRowId();
List<CmiData> data = ((SummaryTableDataModelMultiResults) summaryTableCtr.getTableDataModel()).getObject(rowId);
cmiTableCtr.setTableDataModel(new CmiTableDataModel(getTranslator(), data));
// </BPS-252> BPS-252_3
removeAsListenerAndDispose(cmc);
cmc = new CloseableModalController(getWindowControl(), translate("close"), cmiTableCtr.getInitialComponent());
listenTo(cmc);
cmc.activate();
}
} else if (source == resetConfirmationBox) {
if (DialogBoxUIFactory.isOkEvent(event)) {
// delete scorm
String username = assessedUserCourseEnv.getIdentityEnvironment().getIdentity().getName();
CourseEnvironment courseEnv = assessedUserCourseEnv.getCourseEnvironment();
ScormAssessmentManager.getInstance().deleteResults(username, courseEnv, node);
fireEvent(ureq, Event.DONE_EVENT);
}
}
}
use of org.olat.core.gui.components.table.TableEvent in project OpenOLAT by OpenOLAT.
the class ViteroUserToGroupController method event.
@Override
protected void event(UserRequest ureq, Controller source, Event event) {
if (source == tableCtr) {
if (event instanceof TableEvent) {
TableEvent e = (TableEvent) event;
int row = e.getRowId();
Identity identity = (Identity) tableCtr.getTableDataModel().getObject(row);
if ("signin".equals(e.getActionId())) {
signIn(Collections.singletonList(identity));
} else if ("signout".equals(e.getActionId())) {
signOut(Collections.singletonList(identity));
}
} else if (event instanceof TableMultiSelectEvent) {
TableMultiSelectEvent e = (TableMultiSelectEvent) event;
List<Identity> identities = new ArrayList<Identity>();
for (int i = e.getSelection().nextSetBit(0); i >= 0; i = e.getSelection().nextSetBit(i + 1)) {
Identity identity = (Identity) tableCtr.getTableDataModel().getObject(i);
identities.add(identity);
}
if ("signin".equals(e.getAction())) {
signIn(identities);
} else if ("signout".equals(e.getAction())) {
signOut(identities);
} else if ("reload".equals(e.getAction())) {
loadModel();
}
}
}
super.event(ureq, source, event);
}
Aggregations