Search in sources :

Example 31 with ClientConfig

use of com.haulmont.cuba.client.ClientConfig in project cuba by cuba-platform.

the class MismatchedUserSessionHandler method showMismatchedSessionDialog.

protected void showMismatchedSessionDialog(AppUI ui) {
    Messages messages = beanLocator.get(Messages.class);
    Connection connection = ui.getApp().getConnection();
    // noinspection ConstantConditions
    Locale locale = connection.getSession().getLocale();
    Window dialog = new MismatchedUserSessionExceptionDialog();
    dialog.setStyleName("c-sessionchanged-dialog");
    dialog.setCaption(messages.getMainMessage("dialogs.Information", locale));
    dialog.setClosable(false);
    dialog.setResizable(false);
    dialog.setModal(true);
    CubaLabel messageLab = new CubaLabel();
    messageLab.setWidthUndefined();
    messageLab.setValue(messages.getMainMessage("sessionChangedMsg", locale));
    VerticalLayout layout = new VerticalLayout();
    layout.setSpacing(true);
    layout.setMargin(false);
    layout.setWidthUndefined();
    layout.setStyleName("c-sessionchanged-dialog-layout");
    layout.setSpacing(true);
    dialog.setContent(layout);
    CubaButton reloginBtn = new CubaButton();
    reloginBtn.addStyleName(WebButton.PRIMARY_ACTION_STYLENAME);
    reloginBtn.setCaption(messages.getMainMessage(DialogAction.Type.OK.getMsgKey(), locale));
    reloginBtn.addClickListener(event -> ui.getApp().recreateUi(ui));
    String iconName = beanLocator.get(Icons.class).get(DialogAction.Type.OK.getIconKey());
    reloginBtn.setIcon(beanLocator.get(IconResolver.class).getIconResource(iconName));
    ClientConfig clientConfig = beanLocator.get(Configuration.class).getConfig(ClientConfig.class);
    setClickShortcut(reloginBtn, clientConfig.getCommitShortcut());
    reloginBtn.focus();
    layout.addComponent(messageLab);
    layout.addComponent(reloginBtn);
    layout.setComponentAlignment(reloginBtn, Alignment.BOTTOM_RIGHT);
    ui.addWindow(dialog);
    dialog.center();
    if (ui.isTestMode()) {
        dialog.setCubaId("optionDialog");
        reloginBtn.setCubaId("reloginBtn");
    }
    if (ui.isPerformanceTestMode()) {
        dialog.setId(ui.getTestIdManager().getTestId("optionDialog"));
        reloginBtn.setId(ui.getTestIdManager().getTestId("reloginBtn"));
    }
}
Also used : Locale(java.util.Locale) Window(com.vaadin.ui.Window) CubaWindow(com.haulmont.cuba.web.widgets.CubaWindow) Messages(com.haulmont.cuba.core.global.Messages) CubaLabel(com.haulmont.cuba.web.widgets.CubaLabel) Configuration(com.haulmont.cuba.core.global.Configuration) CubaButton(com.haulmont.cuba.web.widgets.CubaButton) Connection(com.haulmont.cuba.web.Connection) VerticalLayout(com.vaadin.ui.VerticalLayout) Icons(com.haulmont.cuba.gui.icons.Icons) ClientConfig(com.haulmont.cuba.client.ClientConfig)

Example 32 with ClientConfig

use of com.haulmont.cuba.client.ClientConfig in project cuba by cuba-platform.

the class AbstractTableLoader method addDynamicAttributeColumn.

protected void addDynamicAttributeColumn(Table component, CategoryAttribute attribute, MetaPropertyPath metaPropertyPath) {
    Table.Column column = new Table.Column(metaPropertyPath);
    column.setCaption(getDynamicAttributesGuiTools().getColumnCapture(attribute));
    column.setDescription(attribute.getLocaleDescription());
    if (attribute.getDataType().equals(PropertyType.STRING)) {
        ClientConfig clientConfig = getConfiguration().getConfig(ClientConfig.class);
        column.setMaxTextLength(clientConfig.getDynamicAttributesTableColumnMaxTextLength());
    }
    if (attribute.getDataType().equals(PropertyType.ENUMERATION) && BooleanUtils.isNotTrue(attribute.getIsCollection())) {
        column.setFormatter(value -> LocaleHelper.getEnumLocalizedValue((String) value, attribute.getEnumerationLocales()));
    }
    if (!Strings.isNullOrEmpty(attribute.getConfiguration().getColumnAlignment())) {
        column.setAlignment(Table.ColumnAlignment.valueOf(attribute.getConfiguration().getColumnAlignment()));
    }
    DecimalFormat formatter = getDynamicAttributesGuiTools().getDecimalFormat(attribute);
    if (formatter != null) {
        column.setFormatter(obj -> {
            if (obj == null) {
                return null;
            }
            if (obj instanceof Number) {
                return formatter.format(obj);
            }
            return obj.toString();
        });
    }
    column.setSortable(false);
    // noinspection unchecked
    component.addColumn(column);
    if (attribute.getConfiguration().getColumnWidth() != null) {
        column.setWidth(attribute.getConfiguration().getColumnWidth());
    }
}
Also used : DecimalFormat(java.text.DecimalFormat) ClientConfig(com.haulmont.cuba.client.ClientConfig)

Example 33 with ClientConfig

use of com.haulmont.cuba.client.ClientConfig in project cuba by cuba-platform.

the class WebLookupField method afterPropertiesSet.

@Override
public void afterPropertiesSet() {
    initComponent(component);
    Configuration configuration = beanLocator.get(Configuration.NAME);
    ClientConfig clientConfig = configuration.getConfig(ClientConfig.class);
    setPageLength(clientConfig.getLookupFieldPageLength());
}
Also used : Configuration(com.haulmont.cuba.core.global.Configuration) ClientConfig(com.haulmont.cuba.client.ClientConfig)

Example 34 with ClientConfig

use of com.haulmont.cuba.client.ClientConfig in project cuba by cuba-platform.

the class WebLookupPickerField method afterPropertiesSet.

@Override
public void afterPropertiesSet() {
    super.afterPropertiesSet();
    Configuration configuration = beanLocator.get(Configuration.NAME);
    ClientConfig clientConfig = configuration.getConfig(ClientConfig.class);
    setPageLength(clientConfig.getLookupFieldPageLength());
}
Also used : Configuration(com.haulmont.cuba.core.global.Configuration) ClientConfig(com.haulmont.cuba.client.ClientConfig)

Example 35 with ClientConfig

use of com.haulmont.cuba.client.ClientConfig in project cuba by cuba-platform.

the class WebDialogWindow method setupDialogShortcuts.

protected void setupDialogShortcuts() {
    ClientConfig clientConfig = getClientConfig();
    String closeShortcut = clientConfig.getCloseShortcut();
    KeyCombination closeCombination = KeyCombination.create(closeShortcut);
    ShortcutListenerDelegate exitAction = new ShortcutListenerDelegate("closeShortcutAction", closeCombination.getKey().getCode(), KeyCombination.Modifier.codes(closeCombination.getModifiers()));
    exitAction.withHandler(this::onCloseShortcutTriggered);
    dialogWindow.addActionHandler(new com.vaadin.event.Action.Handler() {

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

        @Override
        public void handleAction(com.vaadin.event.Action action, Object sender, Object target) {
            if (action == exitAction) {
                exitAction.handleAction(sender, target);
            }
        }
    });
}
Also used : StandardCloseAction(com.haulmont.cuba.gui.screen.StandardCloseAction) ShortcutAction(com.vaadin.event.ShortcutAction) Action(com.vaadin.event.Action) Action(com.vaadin.event.Action) ShortcutListenerDelegate(com.haulmont.cuba.web.gui.components.util.ShortcutListenerDelegate) ClientConfig(com.haulmont.cuba.client.ClientConfig)

Aggregations

ClientConfig (com.haulmont.cuba.client.ClientConfig)40 Configuration (com.haulmont.cuba.core.global.Configuration)14 Messages (com.haulmont.cuba.core.global.Messages)6 Inject (javax.inject.Inject)6 Icons (com.haulmont.cuba.gui.icons.Icons)5 Element (org.dom4j.Element)5 com.haulmont.cuba.gui.components (com.haulmont.cuba.gui.components)3 AbstractAction (com.haulmont.cuba.gui.components.AbstractAction)3 Component (com.haulmont.cuba.gui.components.Component)3 ShortcutListenerDelegate (com.haulmont.cuba.web.gui.components.util.ShortcutListenerDelegate)3 EventRouter (com.haulmont.bali.events.EventRouter)2 Preconditions (com.haulmont.bali.util.Preconditions)2 Preconditions.checkNotNullArgument (com.haulmont.bali.util.Preconditions.checkNotNullArgument)2 MetaClass (com.haulmont.chile.core.model.MetaClass)2 Entity (com.haulmont.cuba.core.entity.Entity)2 AppBeans (com.haulmont.cuba.core.global.AppBeans)2 TopLevelFrame (com.haulmont.cuba.desktop.TopLevelFrame)2 com.haulmont.cuba.gui (com.haulmont.cuba.gui)2 LayoutAnalyzer (com.haulmont.cuba.gui.app.core.dev.LayoutAnalyzer)2 Action (com.haulmont.cuba.gui.components.Action)2