Search in sources :

Example 16 with Screen

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);
    }
}
Also used : Frame(io.jmix.ui.component.Frame) MasterDetailScreen(io.jmix.ui.screen.MasterDetailScreen) Screen(io.jmix.ui.screen.Screen) EventHub(io.jmix.core.common.event.EventHub) StandardEditor(io.jmix.ui.screen.StandardEditor) MasterDetailScreen(io.jmix.ui.screen.MasterDetailScreen)

Example 17 with Screen

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();
}
Also used : MetaClass(io.jmix.core.metamodel.model.MetaClass) MultiSelectLookupScreen(io.jmix.ui.screen.MultiSelectLookupScreen) Screen(io.jmix.ui.screen.Screen) MultiSelectLookupScreen(io.jmix.ui.screen.MultiSelectLookupScreen) LookupBuilder(io.jmix.ui.builder.LookupBuilder)

Example 18 with Screen

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();
        }
    }
}
Also used : EditorScreen(io.jmix.ui.screen.EditorScreen) FilterCondition(io.jmix.ui.entity.FilterCondition) PropertyFilterCondition(io.jmix.ui.entity.PropertyFilterCondition) LogicalFilterCondition(io.jmix.ui.entity.LogicalFilterCondition) EditorScreen(io.jmix.ui.screen.EditorScreen) Screen(io.jmix.ui.screen.Screen) LogicalFilterCondition(io.jmix.ui.entity.LogicalFilterCondition)

Example 19 with Screen

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;
}
Also used : DataLoader(io.jmix.ui.model.DataLoader) ScreenContext(io.jmix.ui.screen.ScreenContext) MetaClass(io.jmix.core.metamodel.model.MetaClass) JpqlFilter(io.jmix.ui.component.JpqlFilter) Filter(io.jmix.ui.component.Filter) Screen(io.jmix.ui.screen.Screen) JpqlFilter(io.jmix.ui.component.JpqlFilter) DesignTimeConfiguration(io.jmix.ui.component.filter.configuration.DesignTimeConfiguration) Collection(java.util.Collection) MetaProperty(io.jmix.core.metamodel.model.MetaProperty)

Example 20 with 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();
}
Also used : EditorScreen(io.jmix.ui.screen.EditorScreen) Screen(io.jmix.ui.screen.Screen) NotFoundScreen(io.jmix.ui.app.navigation.notfoundwindow.NotFoundScreen) Preconditions.checkNotEmptyString(io.jmix.core.common.util.Preconditions.checkNotEmptyString)

Aggregations

Screen (io.jmix.ui.screen.Screen)82 EditorScreen (io.jmix.ui.screen.EditorScreen)20 LookupScreen (io.jmix.ui.screen.LookupScreen)15 MapScreenOptions (io.jmix.ui.screen.MapScreenOptions)11 Nullable (javax.annotation.Nullable)9 Messages (io.jmix.core.Messages)6 WindowImpl (io.jmix.ui.component.impl.WindowImpl)6 Screens (io.jmix.ui.Screens)5 io.jmix.ui.component (io.jmix.ui.component)5 NavigationState (io.jmix.ui.navigation.NavigationState)5 FrameOwner (io.jmix.ui.screen.FrameOwner)5 UiControllerUtils (io.jmix.ui.screen.UiControllerUtils)5 java.util (java.util)5 Collectors (java.util.stream.Collectors)5 LoggerFactory (org.slf4j.LoggerFactory)5 Autowired (org.springframework.beans.factory.annotation.Autowired)5 LegacyFrame (com.haulmont.cuba.gui.screen.compatibility.LegacyFrame)4 ScreenEditorWrapper (com.haulmont.cuba.gui.screen.compatibility.ScreenEditorWrapper)4 MetaClass (io.jmix.core.metamodel.model.MetaClass)4 BaseAction (io.jmix.ui.action.BaseAction)4