use of com.haulmont.cuba.core.global.Configuration in project cuba by cuba-platform.
the class ControllerUtils method getControllerURL.
public static String getControllerURL(String mapping) {
if (mapping == null)
throw new IllegalArgumentException("Mapping cannot be null");
Configuration configuration = AppBeans.get(Configuration.NAME);
GlobalConfig globalConfig = configuration.getConfig(GlobalConfig.class);
StringBuilder sb = new StringBuilder(globalConfig.getWebAppUrl()).append(getControllerPrefix());
if (!mapping.startsWith("/")) {
sb.append("/");
}
sb.append(mapping);
return sb.toString();
}
use of com.haulmont.cuba.core.global.Configuration in project cuba by cuba-platform.
the class SiteSettings method composeFullRelativePath.
/**
* Basically this method prepends webapp's prefix to the path
*
* @param path path relative to the root of webapp
* @return Full relative path on server
*/
public String composeFullRelativePath(String path) {
Configuration configuration = AppBeans.get(Configuration.NAME);
GlobalConfig globalConfig = configuration.getConfig(GlobalConfig.class);
String webAppPrefix = "/".concat(globalConfig.getWebContextName().intern());
return path.startsWith("/") ? webAppPrefix.concat(path) : webAppPrefix.concat("/").concat(path);
}
use of com.haulmont.cuba.core.global.Configuration in project cuba by cuba-platform.
the class SiteSettings method getFreeMarkerSettings.
public Properties getFreeMarkerSettings() {
Configuration configuration = AppBeans.get(Configuration.NAME);
GlobalConfig globalConfig = configuration.getConfig(GlobalConfig.class);
Map<String, Locale> availableLocales = globalConfig.getAvailableLocales();
if (availableLocales.isEmpty())
throw new IllegalStateException("Property cuba.availableLocales is not configured");
Locale locale = availableLocales.values().iterator().next();
FormatStrings formatStrings = Datatypes.getFormatStrings(locale);
final Properties freemarkerSettings = new Properties();
freemarkerSettings.setProperty("number_format", "#");
freemarkerSettings.setProperty("datetime_format", formatStrings.getDateTimeFormat());
freemarkerSettings.setProperty("date_format", formatStrings.getDateFormat());
freemarkerSettings.setProperty("template_exception_handler", "rethrow");
return freemarkerSettings;
}
use of com.haulmont.cuba.core.global.Configuration in project cuba by cuba-platform.
the class WebWindow method close.
@Override
public boolean close(final String actionId) {
if (!forceClose) {
if (!delegate.preClose(actionId))
return false;
}
if (closing) {
return true;
}
Configuration configuration = AppBeans.get(Configuration.NAME);
ClientConfig clientConfig = configuration.getConfig(ClientConfig.class);
if (!forceClose && isModified()) {
final Committable committable = (getWrapper() instanceof Committable) ? (Committable) getWrapper() : (this instanceof Committable) ? (Committable) this : null;
if ((committable != null) && clientConfig.getUseSaveConfirmation()) {
windowManager.showOptionDialog(messages.getMainMessage("closeUnsaved.caption"), messages.getMainMessage("saveUnsaved"), MessageType.WARNING, new Action[] { new DialogAction(Type.OK, Status.PRIMARY).withCaption(messages.getMainMessage("closeUnsaved.save")).withHandler(event -> {
committable.commitAndClose();
}), new BaseAction("discard").withIcon(icons.get(CubaIcon.DIALOG_CANCEL)).withCaption(messages.getMainMessage("closeUnsaved.discard")).withHandler(event -> {
committable.close(actionId, true);
}), new DialogAction(Type.CANCEL).withIcon(null).withHandler(event -> {
doAfterClose = null;
// try to move focus back
findAndFocusChildComponent();
}) });
} else {
windowManager.showOptionDialog(messages.getMainMessage("closeUnsaved.caption"), messages.getMainMessage("closeUnsaved"), MessageType.WARNING, new Action[] { new DialogAction(Type.YES).withHandler(event -> getWrapper().close(actionId, true)), new DialogAction(Type.NO, Status.PRIMARY).withHandler(event -> {
doAfterClose = null;
// try to move focus back
findAndFocusChildComponent();
}) });
}
closing = false;
return false;
}
if (!clientConfig.getManualScreenSettingsSaving()) {
if (getWrapper() != null) {
getWrapper().saveSettings();
} else {
saveSettings();
}
}
delegate.disposeComponents();
windowManager.close(this);
boolean res = onClose(actionId);
if (res && doAfterClose != null) {
doAfterClose.run();
}
closing = res;
return res;
}
Aggregations