Search in sources :

Example 1 with ScreenFragment

use of io.jmix.ui.screen.ScreenFragment in project jmix-docs by Haulmont.

the class VisitScheduleAssistant method dashboardEventListener.

@EventListener
public void dashboardEventListener(DashboardUpdatedEvent event) {
    // <4>
    // <5>
    ScreenFragment widget = dashboard.getWidget("visits-calendar");
    if (widget instanceof VisitsCalendarWidget) {
        // <6>
        VisitsCalendarWidget visitsCalendarWidget = (VisitsCalendarWidget) widget;
        visitsCalendarWidget.reloadSchedule();
    }
}
Also used : VisitsCalendarWidget(dashboards.ex1.screen.widgets.VisitsCalendarWidget) ScreenFragment(io.jmix.ui.screen.ScreenFragment) EventListener(org.springframework.context.event.EventListener)

Example 2 with ScreenFragment

use of io.jmix.ui.screen.ScreenFragment in project jmix by jmix-framework.

the class AbstractLookup method initLookupLayout.

@Override
public void initLookupLayout() {
    Action selectAction = getAction(LOOKUP_SELECT_ACTION_ID);
    if (selectAction != null && selectAction.getOwner() == null) {
        Fragments fragments = UiControllerUtils.getScreenContext(this).getFragments();
        ScreenFragment lookupWindowActions = fragments.create(this, "lookupWindowActions");
        lookupWindowActions.getFragment().setId("lookupWindowActions");
        lookupWindowActions.getFragment().setVisible(false);
        getFrame().add(lookupWindowActions.getFragment());
    }
    Element element = ((Component.HasXmlDescriptor) getFrame()).getXmlDescriptor();
    if (element != null) {
        String lookupComponent = element.attributeValue("lookupComponent");
        if (StringUtils.isNotEmpty(lookupComponent)) {
            Component component = getFrame().getComponent(lookupComponent);
            setLookupComponent(component);
        }
    }
    Component lookupComponent = getLookupComponent();
    if (lookupComponent instanceof LookupComponent.LookupSelectionChangeNotifier) {
        LookupComponent.LookupSelectionChangeNotifier selectionNotifier = (LookupComponent.LookupSelectionChangeNotifier) lookupComponent;
        if (selectAction != null) {
            // noinspection unchecked
            selectionNotifier.addLookupValueChangeListener(valueChangeEvent -> selectAction.setEnabled(!selectionNotifier.getLookupSelectedItems().isEmpty()));
            selectAction.setEnabled(!selectionNotifier.getLookupSelectedItems().isEmpty());
        }
    }
}
Also used : Action(io.jmix.ui.action.Action) BaseAction(io.jmix.ui.action.BaseAction) ScreenFragment(io.jmix.ui.screen.ScreenFragment) Element(org.dom4j.Element) Fragments(io.jmix.ui.Fragments) Component(io.jmix.ui.component.Component)

Example 3 with ScreenFragment

use of io.jmix.ui.screen.ScreenFragment in project jmix by jmix-framework.

the class DataLoadCoordinatorImpl method configureAutomatically.

private void configureAutomatically(DataLoader loader, FrameOwner frameOwner) {
    List<String> queryParameters = DataLoadersHelper.getQueryParameters(loader);
    List<String> allParameters = new ArrayList<>(queryParameters);
    allParameters.addAll(getConditionParameters(loader));
    // add triggers on container/component events
    for (String parameter : allParameters) {
        if (parameter.startsWith(containerPrefix)) {
            InstanceContainer container = UiControllerUtils.getScreenData(frameOwner).getContainer(parameter.substring(containerPrefix.length()));
            addOnContainerItemChangedLoadTrigger(loader, container, parameter);
        } else if (parameter.startsWith(componentPrefix)) {
            String componentId = parameter.substring(componentPrefix.length());
            Component component = frameOwner instanceof Screen ? ((Screen) frameOwner).getWindow().getComponentNN(componentId) : ((ScreenFragment) frameOwner).getFragment().getComponentNN(componentId);
            LikeClause likeClause = findLikeClause(loader, parameter);
            addOnComponentValueChangedLoadTrigger(loader, component, parameter, likeClause);
        }
    }
    // if the loader has no parameters in query, add trigger on BeforeShowEvent/AttachEvent
    if (queryParameters.isEmpty()) {
        Class eventClass = frameOwner instanceof Screen ? Screen.BeforeShowEvent.class : ScreenFragment.AttachEvent.class;
        addOnFrameOwnerEventLoadTrigger(loader, eventClass);
    }
}
Also used : ScreenFragment(io.jmix.ui.screen.ScreenFragment) Screen(io.jmix.ui.screen.Screen) ArrayList(java.util.ArrayList) InstanceContainer(io.jmix.ui.model.InstanceContainer) Component(io.jmix.ui.component.Component)

Example 4 with ScreenFragment

use of io.jmix.ui.screen.ScreenFragment in project jmix by jmix-framework.

the class EntitySuggestionFieldImpl method showSuggestions.

protected void showSuggestions(List<V> suggestions, boolean userOriginated) {
    FrameOwner frameOwner = getFrame().getFrameOwner();
    Collection<Screen> dialogScreens = UiControllerUtils.getScreenContext(frameOwner).getScreens().getOpenedScreens().getDialogScreens();
    Screen lastDialog = null;
    for (Screen dialogScreen : dialogScreens) {
        lastDialog = dialogScreen;
    }
    if (frameOwner instanceof ScreenFragment) {
        frameOwner = ComponentsHelper.getScreen((ScreenFragment) frameOwner);
    }
    if (lastDialog == null || Objects.equals(frameOwner, lastDialog)) {
        getComponent().showSuggestions(suggestions, userOriginated);
    }
}
Also used : FrameOwner(io.jmix.ui.screen.FrameOwner) ScreenFragment(io.jmix.ui.screen.ScreenFragment) Screen(io.jmix.ui.screen.Screen)

Example 5 with ScreenFragment

use of io.jmix.ui.screen.ScreenFragment in project jmix by jmix-framework.

the class AbstractSuggestionField method showSuggestions.

protected void showSuggestions(List<I> suggestions, boolean userOriginated) {
    FrameOwner frameOwner = getFrame().getFrameOwner();
    Collection<Screen> dialogScreens = UiControllerUtils.getScreenContext(frameOwner).getScreens().getOpenedScreens().getDialogScreens();
    Screen lastDialog = null;
    for (Screen dialogScreen : dialogScreens) {
        lastDialog = dialogScreen;
    }
    if (frameOwner instanceof ScreenFragment) {
        frameOwner = ComponentsHelper.getScreen((ScreenFragment) frameOwner);
    }
    if (lastDialog == null || Objects.equals(frameOwner, lastDialog)) {
        component.showSuggestions(suggestions, userOriginated);
    }
}
Also used : FrameOwner(io.jmix.ui.screen.FrameOwner) ScreenFragment(io.jmix.ui.screen.ScreenFragment) Screen(io.jmix.ui.screen.Screen)

Aggregations

ScreenFragment (io.jmix.ui.screen.ScreenFragment)13 Component (io.jmix.ui.component.Component)5 FrameOwner (io.jmix.ui.screen.FrameOwner)5 Screen (io.jmix.ui.screen.Screen)5 Fragment (io.jmix.ui.component.Fragment)4 WindowInfo (io.jmix.ui.WindowInfo)3 Messages (io.jmix.core.Messages)2 Widget (io.jmix.dashboards.model.Widget)2 WidgetRepository (io.jmix.dashboardsui.repository.WidgetRepository)2 WidgetTypeInfo (io.jmix.dashboardsui.repository.WidgetTypeInfo)2 MapScreenOptions (io.jmix.ui.screen.MapScreenOptions)2 StringUtils (org.apache.commons.lang3.StringUtils)2 Element (org.dom4j.Element)2 Logger (org.slf4j.Logger)2 LoggerFactory (org.slf4j.LoggerFactory)2 Autowired (org.springframework.beans.factory.annotation.Autowired)2 UiComponents (com.haulmont.cuba.gui.UiComponents)1 LegacyFragmentAdapter (com.haulmont.cuba.gui.components.compatibility.LegacyFragmentAdapter)1 LegacyFrame (com.haulmont.cuba.gui.screen.compatibility.LegacyFrame)1 ScreenFragmentWrapper (com.haulmont.cuba.gui.screen.compatibility.ScreenFragmentWrapper)1