use of io.jmix.ui.screen.Screen in project jmix by jmix-framework.
the class DynAttrFacetImpl method subscribe.
private void subscribe() {
Frame frame = getOwner();
if (frame == null) {
throw new IllegalStateException("DynAttrFacet is not attached to Frame");
}
Screen screen = UiControllerUtils.getScreen(frame.getFrameOwner());
if (screen instanceof StandardEditor) {
EventHub screenEvents = UiControllerUtils.getEventHub(screen);
screenEvents.subscribe(StandardEditor.InitEntityEvent.class, this::initEntityInStandardEditor);
} else if (screen instanceof MasterDetailScreen) {
EventHub screenEvents = UiControllerUtils.getEventHub(screen);
screenEvents.subscribe(MasterDetailScreen.InitEntityEvent.class, this::initEntityInMasterDetailScreen);
}
}
use of io.jmix.ui.screen.Screen in project jmix by jmix-framework.
the class TagLookupAction method execute.
@SuppressWarnings("unchecked")
@Override
public void execute() {
if (tagPicker == null) {
throw new IllegalStateException("Action is not bound to a TagPicker");
}
MetaClass metaClass = tagPicker.getMetaClass();
if (metaClass == null) {
throw new DevelopmentException("Neither metaClass nor dataContainer/property is specified " + "for the TagPicker", "action ID", getId());
}
LookupBuilder builder = screenBuilders.lookup(tagPicker);
builder = screenInitializer.initBuilder(builder);
if (selectValidator != null) {
builder = builder.withSelectValidator(selectValidator);
}
if (transformation != null) {
builder = builder.withTransformation(transformation);
}
Screen lookupScreen = builder.build();
if (lookupScreen instanceof MultiSelectLookupScreen) {
((MultiSelectLookupScreen) lookupScreen).setLookupComponentMultiSelect(multiSelect);
}
screenInitializer.initScreen(lookupScreen);
lookupScreen.show();
}
use of io.jmix.ui.screen.Screen in project jmix by jmix-framework.
the class LogicalFilterConditionEdit method editActionAfterCloseHandler.
protected void editActionAfterCloseHandler(AfterCloseEvent afterCloseEvent) {
Screen screen = afterCloseEvent.getSource();
if (afterCloseEvent.closedWith(StandardOutcome.COMMIT) && screen instanceof EditorScreen && getListComponent() != null) {
FilterCondition singleSelected = logicalFilterSupport.findSelectedConditionFromRootFilterCondition(getEditedEntity(), getListComponent().getSingleSelected());
if (singleSelected != null && singleSelected.getParent() instanceof LogicalFilterCondition) {
LogicalFilterCondition parent = (LogicalFilterCondition) singleSelected.getParent();
int index = parent.getOwnFilterConditions().indexOf(singleSelected);
FilterCondition editedCondition = (FilterCondition) ((EditorScreen<?>) screen).getEditedEntity();
parent.getOwnFilterConditions().set(index, editedCondition);
editedCondition.setParent(parent);
refreshChildrenConditions();
expandItems();
}
}
}
use of io.jmix.ui.screen.Screen 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.Screen in project jmix by jmix-framework.
the class WebUrlRouting method buildScreenRoute.
protected String buildScreenRoute(Screen screen) {
List<Screen> screens = new ArrayList<>(ui.getScreens().getOpenedScreens().getCurrentBreadcrumbs());
if (screens.isEmpty() || screens.get(0) != screen) {
log.debug("Current breadcrumbs doesn't contain the given screen '{}'", screen.getId());
return "";
}
Collections.reverse(screens);
StringBuilder state = new StringBuilder();
String prevSubRoute = null;
for (int i = 0; i < screens.size() && i < MAX_NESTING; i++) {
String subRoute = buildSubRoute(prevSubRoute, screens.get(i));
if (StringUtils.isNotEmpty(state) && StringUtils.isNotEmpty(subRoute)) {
state.append('/');
}
state.append(subRoute);
prevSubRoute = subRoute;
}
return state.toString();
}
Aggregations