Search in sources :

Example 31 with Configuration

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();
}
Also used : Configuration(com.haulmont.cuba.core.global.Configuration) GlobalConfig(com.haulmont.cuba.core.global.GlobalConfig)

Example 32 with Configuration

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);
}
Also used : Configuration(com.haulmont.cuba.core.global.Configuration) GlobalConfig(com.haulmont.cuba.core.global.GlobalConfig)

Example 33 with Configuration

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;
}
Also used : Locale(java.util.Locale) Configuration(com.haulmont.cuba.core.global.Configuration) GlobalConfig(com.haulmont.cuba.core.global.GlobalConfig) FormatStrings(com.haulmont.chile.core.datatypes.FormatStrings) Properties(java.util.Properties)

Example 34 with Configuration

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;
}
Also used : StringUtils(org.apache.commons.lang.StringUtils) Datasource(com.haulmont.cuba.gui.data.Datasource) WindowMode(com.vaadin.shared.ui.window.WindowMode) LoggerFactory(org.slf4j.LoggerFactory) CubaIcon(com.haulmont.cuba.gui.icons.CubaIcon) Settings(com.haulmont.cuba.gui.settings.Settings) AppBeans(com.haulmont.cuba.core.global.AppBeans) Icons(com.haulmont.cuba.gui.icons.Icons) BooleanUtils(org.apache.commons.lang.BooleanUtils) IconResolver(com.haulmont.cuba.web.gui.icons.IconResolver) com.haulmont.cuba.gui(com.haulmont.cuba.gui) Window(com.haulmont.cuba.gui.components.Window) Configuration(com.haulmont.cuba.core.global.Configuration) Instance(com.haulmont.chile.core.model.Instance) AppUI(com.haulmont.cuba.web.AppUI) Page(com.vaadin.server.Page) EventRouter(com.haulmont.bali.events.EventRouter) BaseAction(com.haulmont.cuba.gui.components.actions.BaseAction) Preconditions.checkNotNullArgument(com.haulmont.bali.util.Preconditions.checkNotNullArgument) com.haulmont.cuba.gui.components(com.haulmont.cuba.gui.components) Status(com.haulmont.cuba.gui.components.Action.Status) MainTabSheetMode(com.haulmont.cuba.web.toolkit.ui.MainTabSheetMode) Messages(com.haulmont.cuba.core.global.Messages) ApplicationListener(org.springframework.context.ApplicationListener) MarginInfo(com.vaadin.shared.ui.MarginInfo) CubaSingleModeContainer(com.haulmont.cuba.web.toolkit.ui.CubaSingleModeContainer) WebWrapperUtils(com.haulmont.cuba.web.gui.components.WebWrapperUtils) TabSheet(com.vaadin.ui.TabSheet) WebConfig(com.haulmont.cuba.web.WebConfig) ClientConfig(com.haulmont.cuba.client.ClientConfig) WebAbstractComponent(com.haulmont.cuba.web.gui.components.WebAbstractComponent) WebWindowManager(com.haulmont.cuba.web.WebWindowManager) java.util(java.util) LookupSelectionChangeNotifier(com.haulmont.cuba.gui.components.LookupComponent.LookupSelectionChangeNotifier) Timer(com.haulmont.cuba.gui.components.Timer) MetaClass(com.haulmont.chile.core.model.MetaClass) CubaVerticalActionsLayout(com.haulmont.cuba.web.toolkit.ui.CubaVerticalActionsLayout) WebFrameActionsHolder(com.haulmont.cuba.web.gui.components.WebFrameActionsHolder) ClientConnector(com.vaadin.server.ClientConnector) Component(com.haulmont.cuba.gui.components.Component) DsContext(com.haulmont.cuba.gui.data.DsContext) Nullable(javax.annotation.Nullable) Logger(org.slf4j.Logger) Type(com.haulmont.cuba.gui.components.DialogAction.Type) Preconditions(com.haulmont.bali.util.Preconditions) Button(com.vaadin.ui.Button) UiEventsMulticaster(com.haulmont.cuba.gui.events.sys.UiEventsMulticaster) WebComponentsHelper(com.haulmont.cuba.web.gui.components.WebComponentsHelper) Element(org.dom4j.Element) Unit(com.vaadin.server.Sizeable.Unit) Entity(com.haulmont.cuba.core.entity.Entity) com.vaadin.ui(com.vaadin.ui) Configuration(com.haulmont.cuba.core.global.Configuration) BaseAction(com.haulmont.cuba.gui.components.actions.BaseAction) ClientConfig(com.haulmont.cuba.client.ClientConfig)

Aggregations

Configuration (com.haulmont.cuba.core.global.Configuration)34 ClientConfig (com.haulmont.cuba.client.ClientConfig)13 GlobalConfig (com.haulmont.cuba.core.global.GlobalConfig)9 WebConfig (com.haulmont.cuba.web.WebConfig)7 Messages (com.haulmont.cuba.core.global.Messages)4 File (java.io.File)4 IOException (java.io.IOException)4 DesktopConfig (com.haulmont.cuba.desktop.DesktopConfig)3 ThemeConstants (com.haulmont.cuba.gui.theme.ThemeConstants)3 VersionedThemeResource (com.haulmont.cuba.web.toolkit.VersionedThemeResource)3 AppBeans (com.haulmont.cuba.core.global.AppBeans)2 FileStorageException (com.haulmont.cuba.core.global.FileStorageException)2 FileUploadingAPI (com.haulmont.cuba.gui.upload.FileUploadingAPI)2 AppUI (com.haulmont.cuba.web.AppUI)2 WebWindowManager (com.haulmont.cuba.web.WebWindowManager)2 FileResource (com.vaadin.server.FileResource)2 Resource (com.vaadin.server.Resource)2 com.vaadin.ui (com.vaadin.ui)2 TextAttribute (java.awt.font.TextAttribute)2 FileOutputStream (java.io.FileOutputStream)2