Search in sources :

Example 26 with Configuration

use of com.haulmont.cuba.core.global.Configuration in project cuba by cuba-platform.

the class SwingXTableSettings method apply.

@Override
public void apply(Element element, boolean sortable) {
    String horizontalScroll = element.attributeValue("horizontalScroll");
    if (!StringUtils.isBlank(horizontalScroll)) {
        table.setHorizontalScrollEnabled(Boolean.valueOf(horizontalScroll));
    }
    loadFontPreferences(element);
    final Element columnsElem = element.element("columns");
    if (columnsElem == null) {
        return;
    }
    Collection<String> modelIds = new LinkedList<>();
    for (TableColumn modelColumn : table.getColumns(true)) {
        modelIds.add(String.valueOf(modelColumn.getIdentifier()));
    }
    Collection<String> loadedIds = new LinkedList<>();
    for (Element colElem : Dom4j.elements(columnsElem, "column")) {
        String id = colElem.attributeValue("id");
        loadedIds.add(id);
    }
    Configuration configuration = AppBeans.get(Configuration.NAME);
    ClientConfig clientConfig = configuration.getConfig(ClientConfig.class);
    if (clientConfig.getLoadObsoleteSettingsForTable() || CollectionUtils.isEqualCollection(modelIds, loadedIds)) {
        applyColumnSettings(element, sortable);
    }
}
Also used : Configuration(com.haulmont.cuba.core.global.Configuration) Element(org.dom4j.Element) ClientConfig(com.haulmont.cuba.client.ClientConfig) TableColumn(javax.swing.table.TableColumn)

Example 27 with Configuration

use of com.haulmont.cuba.core.global.Configuration in project cuba by cuba-platform.

the class RemotingServlet method checkConfiguration.

/**
 * Check correctness of some configuration parameters and log the warning if necessary.
 */
protected void checkConfiguration(HttpServletRequest request) {
    if (!checkCompleted) {
        GlobalConfig config = AppBeans.get(Configuration.class).getConfig(GlobalConfig.class);
        if (config.getLogIncorrectWebAppPropertiesEnabled()) {
            StringBuilder sb = new StringBuilder();
            if (!request.getServerName().equals(config.getWebHostName())) {
                sb.append("***** cuba.webHostName=").append(config.getWebHostName()).append(", actual=").append(request.getServerName()).append("\n");
            }
            if (request.getServerPort() != Integer.parseInt(config.getWebPort())) {
                sb.append("***** cuba.webPort=").append(config.getWebPort()).append(", actual=").append(request.getServerPort()).append("\n");
            }
            String contextPath = request.getContextPath();
            if (contextPath.startsWith("/"))
                contextPath = contextPath.substring(1);
            if (!contextPath.equals(config.getWebContextName())) {
                sb.append("***** cuba.webContextName=").append(config.getWebContextName()).append(", actual=").append(contextPath).append("\n");
            }
            if (sb.length() > 0) {
                sb.insert(0, "\n*****\n");
                sb.append("*****");
                log.warn(" Invalid configuration parameters that may cause problems:" + sb.toString());
            }
        }
        checkCompleted = true;
    }
}
Also used : Configuration(com.haulmont.cuba.core.global.Configuration) GlobalConfig(com.haulmont.cuba.core.global.GlobalConfig)

Example 28 with Configuration

use of com.haulmont.cuba.core.global.Configuration in project cuba by cuba-platform.

the class Connection method setCredentialsParams.

protected void setCredentialsParams(AbstractClientCredentials credentials, Map<String, Object> loginParams) {
    credentials.setClientInfo(makeClientInfo());
    credentials.setClientType(ClientType.DESKTOP);
    Optional<InetAddress> address = Optional.empty();
    try {
        address = Optional.ofNullable(InetAddress.getLocalHost());
    } catch (UnknownHostException e) {
        log.warn("Unable to obtain local IP address", e);
    }
    if (address.isPresent()) {
        credentials.setIpAddress(address.get().getHostAddress());
        credentials.setHostName(address.get().getHostName());
    }
    credentials.setParams(loginParams);
    Configuration configuration = AppBeans.get(Configuration.class);
    GlobalConfig globalConfig = configuration.getConfig(GlobalConfig.class);
    if (!globalConfig.getLocaleSelectVisible()) {
        credentials.setOverrideLocale(false);
    }
}
Also used : UnknownHostException(java.net.UnknownHostException) Configuration(com.haulmont.cuba.core.global.Configuration) GlobalConfig(com.haulmont.cuba.core.global.GlobalConfig) InetAddress(java.net.InetAddress)

Example 29 with Configuration

use of com.haulmont.cuba.core.global.Configuration in project cuba by cuba-platform.

the class SessionMessagesNotifier method activate.

public void activate() {
    if (timer != null) {
        return;
    }
    Configuration configuration = AppBeans.get(Configuration.NAME);
    int timeout = configuration.getConfig(DesktopConfig.class).getSessionMessagesIntervalSec();
    if (timeout > 0) {
        timer = new Timer(timeout * 1000, new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                syncMessages();
            }
        });
        timer.start();
    }
}
Also used : Configuration(com.haulmont.cuba.core.global.Configuration) ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent) DesktopConfig(com.haulmont.cuba.desktop.DesktopConfig)

Example 30 with Configuration

use of com.haulmont.cuba.core.global.Configuration in project cuba by cuba-platform.

the class LogWindow method initUI.

private void initUI() {
    ClientConfig clientConfig = AppBeans.<Configuration>get(Configuration.NAME).getConfig(ClientConfig.class);
    String closeShortcut = clientConfig.getCloseShortcut();
    KeyCombination closeCombination = KeyCombination.create(closeShortcut);
    com.vaadin.event.ShortcutAction closeShortcutAction = new com.vaadin.event.ShortcutAction("closeShortcutAction", closeCombination.getKey().getCode(), KeyCombination.Modifier.codes(closeCombination.getModifiers()));
    addActionHandler(new com.vaadin.event.Action.Handler() {

        @Override
        public com.vaadin.event.Action[] getActions(Object target, Object sender) {
            return new com.vaadin.event.Action[] { closeShortcutAction };
        }

        @Override
        public void handleAction(com.vaadin.event.Action action, Object sender, Object target) {
            if (Objects.equals(action, closeShortcutAction)) {
                close();
            }
        }
    });
    VerticalLayout layout = new VerticalLayout();
    layout.setSpacing(true);
    layout.setSizeFull();
    setContent(layout);
    Panel scrollablePanel = new Panel();
    scrollablePanel.setSizeFull();
    VerticalLayout scrollContent = new VerticalLayout();
    scrollContent.setSizeUndefined();
    scrollablePanel.setContent(scrollContent);
    final Label label = new Label();
    label.setContentMode(ContentMode.HTML);
    label.setValue(writeLog());
    label.setSizeUndefined();
    label.setStyleName("c-log-content");
    ((Layout) scrollablePanel.getContent()).addComponent(label);
    HorizontalLayout topLayout = new HorizontalLayout();
    topLayout.setWidth("100%");
    topLayout.setHeightUndefined();
    Messages messages = AppBeans.get(Messages.NAME);
    Button refreshBtn = new CubaButton(messages.getMessage(getClass(), "logWindow.refreshBtn"), (Button.ClickListener) event -> label.setValue(writeLog()));
    topLayout.addComponent(refreshBtn);
    layout.addComponent(topLayout);
    layout.addComponent(scrollablePanel);
    layout.setExpandRatio(scrollablePanel, 1.0f);
}
Also used : CubaButton(com.haulmont.cuba.web.toolkit.ui.CubaButton) StringUtils(org.apache.commons.lang.StringUtils) ContentMode(com.vaadin.shared.ui.label.ContentMode) KeyCombination(com.haulmont.cuba.gui.components.KeyCombination) App(com.haulmont.cuba.web.App) Messages(com.haulmont.cuba.core.global.Messages) AppBeans(com.haulmont.cuba.core.global.AppBeans) DateFormatUtils(org.apache.commons.lang.time.DateFormatUtils) Objects(java.util.Objects) List(java.util.List) Configuration(com.haulmont.cuba.core.global.Configuration) CubaWindow(com.haulmont.cuba.web.toolkit.ui.CubaWindow) AppUI(com.haulmont.cuba.web.AppUI) ClientConfig(com.haulmont.cuba.client.ClientConfig) StringEscapeUtils(org.apache.commons.lang.StringEscapeUtils) com.vaadin.ui(com.vaadin.ui) Messages(com.haulmont.cuba.core.global.Messages) KeyCombination(com.haulmont.cuba.gui.components.KeyCombination) CubaButton(com.haulmont.cuba.web.toolkit.ui.CubaButton) CubaButton(com.haulmont.cuba.web.toolkit.ui.CubaButton) 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