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"));
}
}
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());
}
}
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());
}
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());
}
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);
}
}
});
}
Aggregations