use of io.jmix.core.Messages in project jmix by jmix-framework.
the class BulkEditAction method actionPerform.
@Override
public void actionPerform(Component component) {
if (beforeActionPerformedHandler != null && !beforeActionPerformedHandler.beforeActionPerformed()) {
return;
}
Security security = AppBeans.get(Security.class);
if (!security.isSpecificPermitted(BulkEditor.PERMISSION)) {
Messages messages = AppBeans.get(Messages.class);
Notifications notifications = getScreenContext(target.getFrame()).getNotifications();
notifications.create(NotificationType.ERROR).withCaption(messages.getMessage("accessDenied.message")).show();
return;
}
if (target.getSelected().isEmpty()) {
Messages messages = AppBeans.get(Messages.class);
Notifications notifications = getScreenContext(target.getFrame()).getNotifications();
notifications.create(NotificationType.HUMANIZED).withCaption(messages.getMessage("actions.BulkEdit.emptySelection")).show();
return;
}
OpenType openType = this.openType;
if (openType.getOpenMode() == OpenMode.DIALOG) {
ThemeConstantsManager themeManager = AppBeans.get(ThemeConstantsManager.class);
ThemeConstants theme = themeManager.getConstants();
openType = openType.copy().width(theme.get("cuba.gui.BulkEditAction.editorDialog.width")).height(theme.get("cuba.gui.BulkEditAction.editorDialog.height")).resizable(true);
}
Map<String, Object> params = ParamsMap.of().pair("metaClass", target.getDatasource().getMetaClass()).pair("selected", target.getSelected()).pair("exclude", exclude).pair("includeProperties", includeProperties != null ? includeProperties : Collections.EMPTY_LIST).pair("fieldValidators", fieldValidators).pair("modelValidators", modelValidators).pair("loadDynamicAttributes", loadDynamicAttributes).pair("useConfirmDialog", useConfirmDialog).pair("columnsMode", columnsMode).create();
WindowManager wm = ((WindowManager) getScreenContext(target.getFrame()).getScreens());
WindowInfo windowInfo = AppBeans.get(WindowConfig.class).getWindowInfo("bulkEditor");
Window bulkEditor = wm.openWindow(windowInfo, openType, params);
bulkEditor.addCloseListener(actionId -> {
if (Window.COMMIT_ACTION_ID.equals(actionId)) {
target.getDatasource().refresh();
}
if (target instanceof Component.Focusable) {
((Component.Focusable) target).focus();
}
});
}
use of io.jmix.core.Messages in project jmix by jmix-framework.
the class WindowBreadCrumbs method setApplicationContext.
public void setApplicationContext(ApplicationContext applicationContext) {
setWidth(100, Unit.PERCENTAGE);
setHeightUndefined();
setPrimaryStyleName(C_HEADLINE_CONTAINER);
if (workAreaMode == Mode.TABBED) {
super.setVisible(false);
}
Layout logoLayout = createLogoLayout();
linksLayout = createLinksLayout();
linksLayout.setSizeUndefined();
if (workAreaMode == Mode.SINGLE) {
Messages messages = applicationContext.getBean(Messages.class);
JmixButton closeBtn = new JmixButton("");
closeBtn.setDescription(messages.getMessage("windowBreadCrumbs.closeButton.description"));
closeBtn.setClickHandler(this::onCloseWindowButtonClick);
closeBtn.setIcon(resolveIcon(applicationContext, JmixIcon.CLOSE));
closeBtn.setStyleName("jmix-closetab-button");
this.closeBtn = closeBtn;
}
Layout enclosingLayout = createEnclosingLayout();
enclosingLayout.addComponent(linksLayout);
addComponent(logoLayout);
addComponent(enclosingLayout);
boolean controlsVisible = applicationContext.getBean(UiProperties.class).isShowBreadCrumbs();
enclosingLayout.setVisible(controlsVisible);
if (closeBtn != null) {
addComponent(closeBtn);
}
}
use of io.jmix.core.Messages in project jmix by jmix-framework.
the class TextFieldImpl method convertToPresentation.
@SuppressWarnings("unchecked")
@Override
protected String convertToPresentation(@Nullable V modelValue) throws ConversionException {
if (formatter != null) {
return nullToEmpty(formatter.apply(modelValue));
}
if (datatype != null) {
return nullToEmpty(datatype.format(modelValue, locale));
}
if (valueBinding != null && valueBinding.getSource() instanceof EntityValueSource) {
EntityValueSource entityValueSource = (EntityValueSource) valueBinding.getSource();
Range range = entityValueSource.getMetaPropertyPath().getRange();
if (range.isDatatype()) {
Datatype<V> propertyDataType = range.asDatatype();
return nullToEmpty(propertyDataType.format(modelValue, locale));
} else {
setEditable(false);
if (modelValue == null)
return "";
if (range.isClass()) {
MetadataTools metadataTools = applicationContext.getBean(MetadataTools.class);
if (range.getCardinality().isMany()) {
return ((Collection<Object>) modelValue).stream().map(metadataTools::getInstanceName).collect(Collectors.joining(", "));
} else {
return metadataTools.getInstanceName(modelValue);
}
} else if (range.isEnum()) {
Messages messages = applicationContext.getBean(Messages.class);
return messages.getMessage((Enum) modelValue);
}
}
}
return nullToEmpty(super.convertToPresentation(modelValue));
}
use of io.jmix.core.Messages in project jmix by jmix-framework.
the class ShowLinkAction method compileLink.
protected String compileLink(CollectionDatasource ds) {
StringBuilder sb = new StringBuilder();
Messages messages = AppBeans.get(Messages.class);
sb.append(messages.getMessage("table.showLinkAction.link")).append("<br/>");
sb.append("<textarea class=\"jmix-table-showlink-textarea\" autofocus=\"true\" readonly=\"true\">").append(handler.makeLink(ds.getItem()).replace("&", "&")).append("</textarea>");
return sb.toString();
}
use of io.jmix.core.Messages in project jmix by jmix-framework.
the class AbstractLookup method initLookupActions.
protected void initLookupActions(@SuppressWarnings("unused") InitEvent event) {
addAction(new SelectAction(this));
Messages messages = getApplicationContext().getBean(Messages.class);
addAction(new BaseAction(LOOKUP_CANCEL_ACTION_ID).withCaption(messages.getMessage("actions.Cancel")).withHandler(e -> close("cancel")));
}
Aggregations