use of org.olat.core.gui.control.generic.modal.DialogBoxController in project OpenOLAT by OpenOLAT.
the class EPMultipleMapController 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
protected void event(UserRequest ureq, Controller source, Event event) {
super.event(ureq, source, event);
if (source == delMapCtrl) {
if (DialogBoxUIFactory.isYesEvent(event)) {
PortfolioStructure mapToDel = (PortfolioStructure) ((DialogBoxController) source).getUserObject();
String title = mapToDel.getTitle();
ePFMgr.deletePortfolioStructure(mapToDel);
showInfo("delete.map.success", title);
ThreadLocalUserActivityLogger.addLoggingResourceInfo(LoggingResourceable.wrapPortfolioOres(mapToDel));
ThreadLocalUserActivityLogger.log(EPLoggingAction.EPORTFOLIO_MAP_REMOVED, getClass());
initOrUpdateMaps(ureq);
}
} else if (source == copyMapCtrl) {
if (event.equals(Event.CANCELLED_EVENT)) {
fireEvent(ureq, Event.CANCELLED_EVENT);
return;
}
int pos = DialogBoxUIFactory.getButtonPos(event);
boolean withArtefacts = false;
PortfolioStructure mapToCopy = (PortfolioStructure) ((DialogBoxController) source).getUserObject();
// shift clicked pos, when "with artefacts" was hidden before
if (!ePFMgr.isMapOwner(getIdentity(), mapToCopy))
pos++;
if (pos == 2) {
// clicked cancel button
fireEvent(ureq, Event.CANCELLED_EVENT);
return;
} else if (pos == 0)
withArtefacts = true;
PortfolioStructureMap targetMap = ePFMgr.createAndPersistPortfolioDefaultMap(getIdentity(), translate("map.copy.of", mapToCopy.getTitle()), mapToCopy.getDescription());
ePFMgr.copyStructureRecursively(mapToCopy, targetMap, withArtefacts);
// open the map
String title = targetMap.getTitle();
showInfo("copy.map.success", title);
initOrUpdateMaps(ureq);
String businessPath = "[" + targetMap.getClass().getSimpleName() + ":" + targetMap.getResourceableId() + "]";
NewControllerFactory.getInstance().launch(businessPath, ureq, getWindowControl());
} else if (source == mapViewCtrl) {
if (EPStructureEvent.CLOSE.equals(event.getCommand())) {
myPanel.popContent();
fireEvent(ureq, event);
removeAsListenerAndDispose(mapViewCtrl);
mapViewCtrl = null;
// refresh on close (back-link) to prevent stale object errors, when map got changed meanwhile
initOrUpdateMaps(ureq);
addToHistory(ureq);
} else if (EPStructureEvent.SUBMIT.equals(event.getCommand()) || event.equals(Event.CHANGED_EVENT)) {
// refresh on submission of a map or on any other changes which needs an ui-update
initOrUpdateMaps(ureq);
}
} else if (source == shareListController) {
shareBox.deactivate();
removeAsListenerAndDispose(shareListController);
initOrUpdateMaps(ureq);
}
if (event instanceof EPStructureChangeEvent) {
// event from child
String evCmd = event.getCommand();
if (evCmd.equals(EPStructureChangeEvent.ADDED) || evCmd.equals(EPStructureChangeEvent.CHANGED)) {
initOrUpdateMaps(ureq);
}
}
}
use of org.olat.core.gui.control.generic.modal.DialogBoxController in project OpenOLAT by OpenOLAT.
the class DropboxController 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 source, Event event) {
if (source == fileChooserController) {
cmc.deactivate();
if (event.equals(Event.DONE_EVENT)) {
boolean success = false;
File fIn = fileChooserController.getUploadFile();
VFSContainer fDropbox = getDropBox(ureq.getIdentity());
String filename = fileChooserController.getUploadFileName();
VFSLeaf fOut;
if (fDropbox.resolve(filename) != null) {
// FIXME ms: check if dropbox quota is exceeded -> clarify with customers
fOut = fDropbox.createChildLeaf(getNewUniqueName(filename));
} else {
fOut = fDropbox.createChildLeaf(filename);
}
try {
InputStream in = new FileInputStream(fIn);
OutputStream out = new BufferedOutputStream(fOut.getOutputStream(false));
success = FileUtils.copy(in, out);
FileUtils.closeSafely(in);
FileUtils.closeSafely(out);
} catch (FileNotFoundException e) {
logError("", e);
return;
}
if (fOut instanceof MetaTagged) {
MetaInfo info = ((MetaTagged) fOut).getMetaInfo();
if (info != null) {
info.setAuthor(ureq.getIdentity());
info.write();
}
}
if (success) {
int numFiles = fDropbox.getItems().size();
myContent.contextPut("numfiles", new String[] { Integer.toString(numFiles) });
// assemble confirmation
String confirmation = getConfirmation(ureq, fOut.getName());
// send email if necessary
Boolean sendEmail = (Boolean) config.get(TACourseNode.CONF_DROPBOX_ENABLEMAIL);
if (sendEmail == null)
sendEmail = Boolean.FALSE;
boolean sendMailError = false;
if (sendEmail.booleanValue()) {
// send mail
MailContext context = new MailContextImpl(getWindowControl().getBusinessControl().getAsString());
MailBundle bundle = new MailBundle();
bundle.setContext(context);
bundle.setToId(ureq.getIdentity());
bundle.setContent(translate("conf.mail.subject"), confirmation);
MailerResult result = CoreSpringFactory.getImpl(MailManager.class).sendMessage(bundle);
if (result.getFailedIdentites().size() > 0) {
List<Identity> disabledIdentities = new ArrayList<Identity>();
disabledIdentities = result.getFailedIdentites();
// show error that message can not be sent
ArrayList<String> myButtons = new ArrayList<String>();
myButtons.add(translate("back"));
String title = MailHelper.getTitleForFailedUsersError(ureq.getLocale());
String message = MailHelper.getMessageForFailedUsersError(ureq.getLocale(), disabledIdentities);
// add dropbox specific error message
message += "\n<br />" + translate("conf.mail.error");
// FIXME:FG:6.2: fix problem in info message, not here
message += "\n<br />\n<br />" + confirmation.replace("\n", " ").replace("\r", " ").replace("\u2028", " ");
DialogBoxController noUsersErrorCtr = null;
noUsersErrorCtr = activateGenericDialog(ureq, title, message, myButtons, noUsersErrorCtr);
sendMailError = true;
} else if (result.getReturnCode() > 0) {
// show error that message can not be sent
ArrayList<String> myButtons = new ArrayList<String>();
myButtons.add(translate("back"));
DialogBoxController noUsersErrorCtr = null;
String message = translate("conf.mail.error");
// FIXME:FG:6.2: fix problem in info message, not here
message += "\n<br />\n<br />" + confirmation.replace("\n", " ").replace("\r", " ").replace("\u2028", " ");
noUsersErrorCtr = activateGenericDialog(ureq, translate("error.header"), message, myButtons, noUsersErrorCtr);
sendMailError = true;
}
}
// inform subscription manager about new element
if (subsContext != null) {
NotificationsManager.getInstance().markPublisherNews(subsContext, ureq.getIdentity(), true);
}
// FIXME:FG:6.2: fix problem in info message, not here
if (!sendMailError) {
getWindowControl().setInfo(confirmation.replace("\n", " ").replace("\r", " ").replace("\u2028", " "));
}
} else {
showInfo("dropbox.upload.failed");
}
}
}
}
use of org.olat.core.gui.control.generic.modal.DialogBoxController in project openolat by klemens.
the class UsrPropCfgResetController method formOK.
/**
* form is ok<br/>
* load the selected preset.properties file and reset userProperties.<br />
* show dialog on error
*/
@Override
protected void formOK(UserRequest ureq) {
String propertyFileName = "_static/" + resetDropdown.getSelectedKey() + ".properties";
InputStream is = this.getClass().getResourceAsStream(propertyFileName);
try {
Properties p = new Properties();
p.load(is);
usrPropCfgMng.resetToPresetConfig(p);
fireEvent(ureq, Event.DONE_EVENT);
} catch (IOException e) {
DialogBoxController dBox = null;
List<String> buttonLabels = Collections.singletonList(translate("ok"));
activateGenericDialog(ureq, "ERROR", "Sorry, Preset-File was not found: " + propertyFileName, buttonLabels, dBox);
} catch (Exception ex) {
DialogBoxController dBox = null;
List<String> buttonLabels = Collections.singletonList(translate("ok"));
StringBuilder sbError = new StringBuilder();
sbError.append("Sorry, there was an error while loading the preset file: ");
sbError.append(propertyFileName);
sbError.append("<br /><br />");
sbError.append(ex.getClass().getSimpleName()).append(" ").append(ex.getMessage());
activateGenericDialog(ureq, "ERROR", sbError.toString(), buttonLabels, dBox);
}
}
Aggregations