use of io.jmix.ui.Notifications in project jmix-docs by Haulmont.
the class ShowSelectedAction method actionPerform.
@Override
public void actionPerform(Component component) {
if (getTarget() != null) {
Object selected = getTarget().getSingleSelected();
if (selected != null) {
Notifications notifications = ComponentsHelper.getScreenContext(target).getNotifications();
notifications.create().withType(Notifications.NotificationType.TRAY).withDescription(description).withCaption(metadataTools.getInstanceName(selected)).show();
}
}
}
use of io.jmix.ui.Notifications in project jmix by jmix-framework.
the class FilteringLookupAction method afterLookupWindowOpened.
@Override
protected void afterLookupWindowOpened(Window lookupWindow) {
boolean found = ComponentsHelper.walkComponents(lookupWindow, screenComponent -> {
if (!(screenComponent instanceof Filter)) {
return false;
} else {
MetaClass actualMetaClass = ((FilterImplementation) screenComponent).getEntityMetaClass();
MetaClass propertyMetaClass = extendedEntities.getEffectiveMetaClass(pickerField.getMetaClass());
if (Objects.equals(actualMetaClass, propertyMetaClass)) {
applyFilter(((Filter) screenComponent));
return true;
}
return false;
}
});
if (!found) {
Notifications notifications = ComponentsHelper.getScreenContext(pickerField).getNotifications();
notifications.create(Notifications.NotificationType.WARNING).withCaption(messages.getMainMessage("dynamicAttributes.entity.filter.filterNotFound")).show();
}
AbstractWindow controller = (AbstractWindow) (lookupWindow).getFrameOwner();
((DsContextImplementation) controller.getDsContext()).resumeSuspended();
}
use of io.jmix.ui.Notifications in project jmix by jmix-framework.
the class AppFolderEditWindow method commit.
@Override
protected void commit() {
AppUI appUI = AppUI.getCurrent();
if (appUI == null) {
return;
}
Notifications notifications = appUI.getNotifications();
AppFolder folder = (AppFolder) AppFolderEditWindow.this.folder;
if (StringUtils.trimToNull(nameField.getValue()) == null) {
String msg = messages.getMessage(messagesPack, "folders.folderEditWindow.emptyName");
notifications.create(Notifications.NotificationType.TRAY).withCaption(msg).show();
return;
}
folder.setName(nameField.getValue());
folder.setTabName(tabNameField.getValue());
if (sortOrderField.getValue() == null || "".equals(sortOrderField.getValue())) {
folder.setSortOrder(null);
} else {
String value = sortOrderField.getValue();
int sortOrder;
try {
sortOrder = Integer.parseInt(value);
} catch (NumberFormatException e) {
String msg = messages.getMessage(messagesPack, "folders.folderEditWindow.invalidSortOrder");
notifications.create(Notifications.NotificationType.TRAY).withCaption(msg).show();
return;
}
folder.setSortOrder(sortOrder);
}
Object parent = parentSelect.getValue();
if (parent instanceof Folder) {
folder.setParent((Folder) parent);
} else {
folder.setParent(null);
}
if (visibilityScriptField != null) {
String scriptText = visibilityScriptField.getValue();
folder.setVisibilityScript(scriptText);
}
if (quantityScriptField != null) {
String scriptText = quantityScriptField.getValue();
folder.setQuantityScript(scriptText);
}
folder.setApplyDefault(Boolean.valueOf(applyDefaultCb.getValue().toString()));
AppFolderEditWindow.this.commitHandler.run();
forceClose();
}
use of io.jmix.ui.Notifications in project jmix by jmix-framework.
the class SearchFieldImpl method performSearch.
public void performSearch() {
Screen frameOwner = ComponentsHelper.getWindowNN(this).getFrameOwner();
String searchText = getValue();
ScreenContext screenContext = getScreenContext(frameOwner);
if (StringUtils.isBlank(searchText)) {
Notifications notifications = screenContext.getNotifications();
notifications.create(HUMANIZED).withCaption(messages.getMessage("io.jmix.searchui.noSearchText")).show();
} else {
String preparedSearchText = searchText.trim();
SearchContext searchContext = new SearchContext(preparedSearchText).setSize(searchProperties.getSearchResultPageSize()).setEntities(getEntities());
SearchResult searchResult = entitySearcher.search(searchContext, searchStrategy);
if (searchCompletedHandler != null) {
searchCompletedHandler.accept(new SearchCompletedEvent(this, searchResult));
}
}
}
use of io.jmix.ui.Notifications in project jmix by jmix-framework.
the class BulkEditAction method execute.
/**
* Executes the action.
*/
@SuppressWarnings("unchecked")
@Override
public void execute() {
if (!(target.getItems() instanceof EntityDataUnit)) {
throw new IllegalStateException("BulkEditAction target Items is null " + "or does not implement EntityDataUnit");
}
MetaClass metaClass = ((EntityDataUnit) target.getItems()).getEntityMetaClass();
if (metaClass == null) {
throw new IllegalStateException("Target is not bound to entity");
}
UiBulkEditContext context = new UiBulkEditContext();
accessManager.applyRegisteredConstraints(context);
if (!context.isPermitted()) {
if (target.getFrame() != null) {
Notifications notifications = getScreenContext(target.getFrame()).getNotifications();
notifications.create(NotificationType.ERROR).withCaption(messages.getMessage("accessDenied.message")).show();
}
return;
}
if (target.getSelected().isEmpty() && target.getFrame() != null) {
Notifications notifications = getScreenContext(target.getFrame()).getNotifications();
notifications.create(NotificationType.ERROR).withCaption(messages.getMessage("actions.BulkEdit.emptySelection")).show();
return;
}
Window window = ComponentsHelper.getWindowNN(target);
BulkEditorBuilder<?> builder = bulkEditors.builder(metaClass, target.getSelected(), window.getFrameOwner()).withListComponent(target);
if (columnsMode != null) {
builder = builder.withColumnsMode(columnsMode);
}
if (exclude != null) {
builder = builder.withExclude(exclude);
}
if (fieldSorter != null) {
builder = builder.withFieldSorter(fieldSorter);
}
if (includeProperties != null) {
builder = builder.withIncludeProperties(includeProperties);
}
if (openMode != null) {
builder = builder.withOpenMode(openMode);
}
if (useConfirmDialog != null) {
builder = builder.withUseConfirmDialog(useConfirmDialog);
}
builder.create().show();
}
Aggregations