use of io.jmix.ui.screen.ScreenContext in project jmix by jmix-framework.
the class LinkCellClickListener method accept.
@Override
public void accept(Table.Column.ClickEvent clickEvent) {
if (!clickEvent.isText()) {
return;
}
Table.Column<?> column = clickEvent.getSource();
Table owner = column.getOwner();
if (owner == null || owner.getFrame() == null) {
return;
}
Object rowItem = clickEvent.getItem();
MetaPropertyPath mpp = column.getMetaPropertyPathNN();
Object item = EntityValues.getValueEx(rowItem, mpp);
Entity entity;
if (EntityValues.isEntity(item)) {
entity = (Entity) item;
} else {
entity = (Entity) rowItem;
}
if (EntityValues.isSoftDeleted(entity)) {
ScreenContext context = ComponentsHelper.getScreenContext(owner);
context.getNotifications().create(Notifications.NotificationType.HUMANIZED).withCaption(applicationContext.getBean(Messages.class).getMessage("OpenAction.objectIsDeleted")).show();
return;
}
entity = loadEntity(entity);
MetaClass metaClass = applicationContext.getBean(Metadata.class).getClass(entity);
String linkScreenId = loadLinkScreenId(column, metaClass);
OpenMode openMode = loadLinkScreenOpenMode(column);
Screen editor = applicationContext.getBean(ScreenBuilders.class).editor(metaClass.getJavaClass(), owner.getFrame().getFrameOwner()).withScreenId(linkScreenId).editEntity(entity).withOpenMode(openMode).build();
editor.addAfterCloseListener(afterCloseEvent -> {
// move focus to component
owner.focus();
if (afterCloseEvent.closedWith(StandardOutcome.COMMIT) && editor instanceof EditorScreen) {
onEditScreenAfterCommit(mpp, rowItem, (EditorScreen) editor, owner);
}
});
editor.show();
}
use of io.jmix.ui.screen.ScreenContext 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.screen.ScreenContext in project jmix by jmix-framework.
the class AbstractTable method showParseErrorNotification.
protected void showParseErrorNotification(String message) {
ScreenContext screenContext = UiControllerUtils.getScreenContext(getFrame().getFrameOwner());
screenContext.getNotifications().create(Notifications.NotificationType.TRAY).withDescription(message).show();
}
use of io.jmix.ui.screen.ScreenContext in project jmix by jmix-framework.
the class RelatedEntitiesSupportImpl method buildScreen.
protected Screen buildScreen(RelatedEntitiesBuilder builder) {
MetaClass metaClass = getMetaClass(builder);
MetaProperty metaProperty = getMetaProperty(builder, metaClass);
Screen screen = createScreen(builder, metaClass, metaProperty);
boolean found = ComponentsHelper.walkComponents(screen.getWindow(), screenComponent -> {
if (screenComponent instanceof Filter) {
Filter filter = (Filter) screenComponent;
DataLoader dataLoader = filter.getDataLoader();
MetaClass actualMetaClass = dataLoader.getContainer().getEntityMetaClass();
MetaClass relatedMetaClass = metaProperty.getRange().asClass();
MetaClass effectiveMetaClass = extendedEntities.getEffectiveMetaClass(relatedMetaClass);
if (Objects.equals(actualMetaClass, effectiveMetaClass)) {
Collection selectedEntities = builder.getSelectedEntities() == null ? Collections.emptyList() : builder.getSelectedEntities();
String configurationName = generateConfigurationName(builder, metaProperty);
DesignTimeConfiguration configuration = createFilterConfiguration((Filter) screenComponent, configurationName);
JpqlFilter jpqlFilter = createJpqlFilter(filter.getDataLoader(), metaProperty, metaClass, selectedEntities);
configuration.getRootLogicalFilterComponent().add(jpqlFilter);
configuration.setFilterComponentDefaultValue(jpqlFilter.getParameterName(), jpqlFilter.getValue());
filter.setCurrentConfiguration(configuration);
return true;
}
}
return false;
});
if (!found) {
screen.addAfterShowListener(event -> {
ScreenContext screenContext = UiControllerUtils.getScreenContext(event.getSource());
screenContext.getNotifications().create(Notifications.NotificationType.WARNING).withCaption(messages.getMessage("actions.Related.FilterNotFound")).show();
});
}
return screen;
}
use of io.jmix.ui.screen.ScreenContext in project jmix by jmix-framework.
the class FilterRemoveAction method execute.
@Override
public void execute() {
ScreenContext screenContext = ComponentsHelper.getScreenContext(filter);
Dialogs dialogs = screenContext.getDialogs();
dialogs.createOptionDialog().withCaption(messages.getMessage(FilterRemoveAction.class, "confirmationDialog.caption")).withMessage(messages.getMessage(FilterRemoveAction.class, "confirmationDialog.message")).withActions(new DialogAction(DialogAction.Type.YES).withHandler(actionPerformedEvent -> filterSupport.removeCurrentFilterConfiguration(filter)), new DialogAction(DialogAction.Type.NO)).show();
}
Aggregations