use of io.jmix.ui.screen.MapScreenOptions in project jmix by jmix-framework.
the class CubaScreens method openFrame.
@Override
public Frame openFrame(Frame parentFrame, Component parent, @Nullable String id, WindowInfo windowInfo, Map<String, Object> params) {
ScreenFragment screenFragment;
Fragments fragments = ui.getFragments();
if (params != null && !params.isEmpty()) {
screenFragment = fragments.create(parentFrame.getFrameOwner(), windowInfo.getId(), new MapScreenOptions(params));
} else {
screenFragment = fragments.create(parentFrame.getFrameOwner(), windowInfo.getId());
}
if (id != null) {
screenFragment.getFragment().setId(id);
}
fragments.init(screenFragment);
if (parent instanceof ComponentContainer) {
ComponentContainer container = (ComponentContainer) parent;
for (Component c : container.getComponents()) {
if (c instanceof Component.Disposable) {
Component.Disposable disposable = (Component.Disposable) c;
if (!disposable.isDisposed()) {
disposable.dispose();
}
}
container.remove(c);
}
container.add(screenFragment.getFragment());
}
if (screenFragment instanceof LegacyFragmentAdapter) {
return ((LegacyFragmentAdapter) screenFragment).getRealScreen();
}
return screenFragment instanceof Frame ? (Frame) screenFragment : new ScreenFragmentWrapper(screenFragment);
}
use of io.jmix.ui.screen.MapScreenOptions in project jmix by jmix-framework.
the class CubaScreens method openLookup.
@Override
public com.haulmont.cuba.gui.components.Window.Lookup openLookup(WindowInfo windowInfo, com.haulmont.cuba.gui.components.Window.Lookup.Handler handler, OpenType openType, Map<String, Object> params) {
params = createParametersMap(windowInfo, params);
MapScreenOptions options = new MapScreenOptions(params);
Screen screen = createScreen(windowInfo, openType.getOpenMode(), options);
applyOpenTypeParameters(screen.getWindow(), openType);
((LookupScreen) screen).setSelectHandler(new SelectHandlerAdapter(handler));
show(screen);
return screen instanceof com.haulmont.cuba.gui.components.Window.Lookup ? (com.haulmont.cuba.gui.components.Window.Lookup) screen : new ScreenLookupWrapper(screen);
}
use of io.jmix.ui.screen.MapScreenOptions in project jmix by jmix-framework.
the class CubaScreens method openEditor.
@Override
public com.haulmont.cuba.gui.components.Window.Editor openEditor(WindowInfo windowInfo, Entity item, OpenType openType, @Nullable Map<String, Object> params, Datasource parentDs) {
params = createParametersMap(windowInfo, params);
params.put(WindowParams.ITEM.name(), item);
MapScreenOptions options = new MapScreenOptions(params);
Screen screen = createScreen(windowInfo, openType.getOpenMode(), options);
applyOpenTypeParameters(screen.getWindow(), openType);
EditorScreen editorScreen = (EditorScreen) screen;
if (editorScreen instanceof AbstractEditor) {
((AbstractEditor) editorScreen).setParentDs(parentDs);
}
editorScreen.setEntityToEdit(item);
show(screen);
return screen instanceof com.haulmont.cuba.gui.components.Window.Editor ? (com.haulmont.cuba.gui.components.Window.Editor) screen : new ScreenEditorWrapper(screen);
}
use of io.jmix.ui.screen.MapScreenOptions in project jmix by jmix-framework.
the class ScreensLinkHandlerProcessor method openWindow.
protected void openWindow(WindowInfo windowInfo, ExternalLinkContext linkContext) {
Map<String, String> requestParams = linkContext.getRequestParams();
App app = linkContext.getApp();
String itemStr = requestParams.get("item");
String openTypeParam = requestParams.get("openType");
OpenType openType = OpenType.NEW_TAB;
if (StringUtils.isNotEmpty(openTypeParam)) {
try {
openType = OpenType.valueOf(openTypeParam);
} catch (IllegalArgumentException e) {
log.warn("Unknown open type ({}) in request parameters", openTypeParam);
}
}
Screens screens = AppUI.getCurrent().getScreens();
if (itemStr == null) {
Screen screen = screens.create(windowInfo.getId(), openType.getOpenMode(), new MapScreenOptions(getParamsMap(requestParams)));
screen.show();
} else {
EntityLoadInfo info = EntityLoadInfo.parse(itemStr);
if (info == null) {
log.warn("Invalid item definition: {}", itemStr);
} else {
Entity entity = loadEntityInstance(info);
if (entity == null) {
throw new EntityAccessException();
}
Screen screen = screens.create(windowInfo.getId(), openType.getOpenMode(), new MapScreenOptions(getParamsMap(requestParams)));
EditorScreen editorScreen = (EditorScreen) screen;
editorScreen.setEntityToEdit(entity);
screen.show();
}
}
}
use of io.jmix.ui.screen.MapScreenOptions in project jmix by jmix-framework.
the class CanvasUiComponentsFactory method createCanvasWidgetLayout.
@Override
public CanvasWidgetLayout createCanvasWidgetLayout(CanvasFragment canvasFragment, WidgetLayout widgetLayout) {
Widget widget = widgetLayout.getWidget();
Optional<WidgetTypeInfo> widgetTypeOpt = widgetRepository.getWidgetTypesInfo().stream().filter(widgetType -> StringUtils.equals(widget.getFragmentId(), widgetType.getFragmentId())).findFirst();
if (!widgetTypeOpt.isPresent()) {
CanvasWidgetLayout layout = components.create(CanvasWidgetLayout.class).init(widgetLayout);
Label<String> label = components.create(Label.class);
String message = messages.formatMessage(CanvasUiComponentsFactory.class, "widgetNotFound", widget.getCaption(), widget.getName());
label.setValue(message);
layout.addComponent(label);
log.error(message);
return layout;
}
widget.setDashboard(canvasFragment.getDashboardModel());
String fragmentId = widgetTypeOpt.get().getFragmentId();
Map<String, Object> params = new HashMap<>(ParamsMap.of(WIDGET, widget, DASHBOARD_MODEL, canvasFragment.getDashboardModel(), DASHBOARD, canvasFragment.getDashboard()));
params.putAll(widgetRepository.getWidgetParams(widget));
ScreenFragment screenFragment = AppUI.getCurrent().getFragments().create(canvasFragment, fragmentId, new MapScreenOptions(params)).init();
Fragment fragment = screenFragment.getFragment();
fragment.setSizeFull();
Component widgetComponent = fragment;
if (BooleanUtils.isTrue(widget.getShowWidgetCaption())) {
VBoxLayout vBoxLayout = components.create(VBoxLayout.class);
vBoxLayout.setSpacing(true);
vBoxLayout.setMargin(true);
vBoxLayout.setSizeFull();
Label<String> label = components.create(Label.class);
label.setValue(widget.getCaption());
label.setStyleName("h2");
vBoxLayout.add(label);
vBoxLayout.add(fragment);
vBoxLayout.expand(fragment);
widgetComponent = vBoxLayout;
} else {
fragment.setMargin(true);
}
CanvasWidgetLayout layout = components.create(CanvasWidgetLayout.class).init(widgetLayout);
layout.setUuid(UUID.randomUUID());
layout.addComponent(widgetComponent);
layout.setWidgetComponent(screenFragment);
layout.setInnerLayout(widgetComponent);
layout.setWidget(widget);
layout.getDelegate().expand(widgetComponent);
layout.setSizeFull();
return layout;
}
Aggregations