use of io.jmix.ui.screen.Screen in project jmix by jmix-framework.
the class AppWorkAreaImpl method getCurrentBreadcrumbs.
@Override
public Collection<Screen> getCurrentBreadcrumbs() {
TabWindowContainer layout = getCurrentWindowContainer();
if (layout != null) {
WindowBreadCrumbs breadCrumbs = layout.getBreadCrumbs();
List<Screen> screens = new ArrayList<>(breadCrumbs.getWindows().size());
Iterator<Window> windowIterator = breadCrumbs.getWindows().descendingIterator();
while (windowIterator.hasNext()) {
Screen frameOwner = windowIterator.next().getFrameOwner();
screens.add(frameOwner);
}
return screens;
}
return Collections.emptyList();
}
use of io.jmix.ui.screen.Screen in project jmix by jmix-framework.
the class AppWorkAreaImpl method reflectTabChangeToUrl.
protected void reflectTabChangeToUrl(boolean userOriginated) {
if (!userOriginated) {
return;
}
Component selectedTab = tabbedContainer.getTabSheetBehaviour().getSelectedTab();
if (selectedTab == null) {
return;
}
Window selectedWindow = ((TabWindowContainer) selectedTab).getBreadCrumbs().getCurrentWindow();
WindowImpl windowImpl = (WindowImpl) selectedWindow;
if (windowImpl != null) {
NavigationState resolvedState = windowImpl.getResolvedState();
if (resolvedState != null) {
int stateMark = generateUrlStateMark();
NavigationState newState = new NavigationState(resolvedState.getRoot(), String.valueOf(stateMark), resolvedState.getNestedRoute(), resolvedState.getParams());
windowImpl.setResolvedState(newState);
Screen screen = selectedWindow.getFrameOwner();
UrlRouting urlRouting = UiControllerUtils.getScreenContext(screen).getUrlRouting();
urlRouting.pushState(screen, newState.getParams());
}
}
}
use of io.jmix.ui.screen.Screen in project jmix by jmix-framework.
the class AppWorkAreaImpl method closeWindowStack.
protected boolean closeWindowStack(WindowStack windowStack) {
boolean closed = true;
Collection<Screen> tabScreens = windowStack.getBreadcrumbs();
for (Screen screen : tabScreens) {
if (isNotCloseable(screen.getWindow())) {
continue;
}
if (isWindowClosePrevented(screen.getWindow(), CloseOriginType.CLOSE_BUTTON)) {
closed = false;
// focus tab
windowStack.select();
break;
}
OperationResult closeResult = screen.close(FrameOwner.WINDOW_CLOSE_ACTION);
if (closeResult.getStatus() != OperationResult.Status.SUCCESS) {
closed = false;
// focus tab
windowStack.select();
break;
}
}
return closed;
}
use of io.jmix.ui.screen.Screen 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);
}
}
use of io.jmix.ui.screen.Screen in project jmix by jmix-framework.
the class DropLayoutTools method addComponent.
public void addComponent(DashboardLayout layout, UUID targetLayoutUuid, WidgetDropLocation location) {
DashboardLayout targetLayout = findLayout(getDashboard().getVisualModel(), targetLayoutUuid);
if (layout instanceof CssLayout) {
Screen screen = createScreen(CssLayoutCreationDialog.class);
screen.addAfterCloseListener(e -> {
StandardCloseAction closeAction = (StandardCloseAction) e.getCloseAction();
if (Window.COMMIT_ACTION_ID.equals(closeAction.getActionId())) {
CssLayoutCreationDialog dialog = (CssLayoutCreationDialog) e.getSource();
CssLayout cssLayout = layoutManager.createCssLayout(dialog.getResponsive(), dialog.getCssStyleName());
reorderWidgetsAndPushEvents(cssLayout, targetLayout, location);
}
});
}
if (layout instanceof GridLayout) {
Screen screen = createScreen(GridCreationDialog.class);
screen.addAfterCloseListener(e -> {
StandardCloseAction closeAction = (StandardCloseAction) e.getCloseAction();
if (Window.COMMIT_ACTION_ID.equals(closeAction.getActionId())) {
GridCreationDialog dialog = (GridCreationDialog) e.getSource();
GridLayout gridLayout = layoutManager.createGridLayout(dialog.getCols(), dialog.getRows());
reorderWidgetsAndPushEvents(gridLayout, targetLayout, location);
}
});
} else if (layout instanceof WidgetTemplateLayout) {
WidgetLayout widgetLayout = layoutManager.createWidgetLayout(((WidgetTemplateLayout) layout).getWidget(), true);
reorderWidgetsAndPushEvents(widgetLayout, targetLayout, location);
} else if (layout instanceof WidgetLayout) {
WidgetLayout widgetLayout = layoutManager.createWidgetLayout(((WidgetLayout) layout).getWidget(), false);
screenBuilders.editor(Widget.class, dashboardEdit).newEntity(widgetLayout.getWidget()).withOpenMode(OpenMode.DIALOG).build().show().addAfterCloseListener(e -> {
StandardCloseAction closeAction = (StandardCloseAction) e.getCloseAction();
if (Window.COMMIT_ACTION_ID.equals(closeAction.getActionId())) {
widgetLayout.setWidget(((WidgetEdit) e.getSource()).getEditedEntity());
reorderWidgetsAndPushEvents(widgetLayout, targetLayout, location);
}
});
} else if (layout instanceof VerticalLayout) {
reorderWidgetsAndPushEvents(metadata.create(VerticalLayout.class), targetLayout, location);
} else if (layout instanceof HorizontalLayout) {
reorderWidgetsAndPushEvents(metadata.create(HorizontalLayout.class), targetLayout, location);
} else if (layout instanceof ResponsiveLayout) {
Screen screen = createScreen(ResponsiveCreationDialog.class);
screen.addAfterCloseListener(e -> {
StandardCloseAction closeAction = (StandardCloseAction) e.getCloseAction();
ResponsiveCreationDialog dialog = (ResponsiveCreationDialog) e.getSource();
if (Window.COMMIT_ACTION_ID.equals(closeAction.getActionId())) {
ResponsiveLayout responsiveLayout = layoutManager.createResponsiveLayout(dialog.getXs(), dialog.getSm(), dialog.getMd(), dialog.getLg());
reorderWidgetsAndPushEvents(responsiveLayout, targetLayout, location);
}
});
}
}
Aggregations