use of io.jmix.ui.screen.EditorScreen 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, Datasource parentDs) {
Map<String, Object> params = createParametersMap(windowInfo, Collections.singletonMap(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.EditorScreen 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.EditorScreen 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.EditorScreen in project jmix by jmix-framework.
the class ScreenToolsImpl method openDefaultScreen.
@Override
public void openDefaultScreen(Screens screens) {
String defaultScreenId = uiProperties.getDefaultScreenId();
if (StringUtils.isEmpty(defaultScreenId)) {
return;
}
if (!windowConfig.hasWindow(defaultScreenId)) {
log.info("Can't find default screen: {}", defaultScreenId);
return;
}
Screen screen = screens.create(defaultScreenId, OpenMode.NEW_TAB);
if (screen instanceof EditorScreen) {
((EditorScreen) screen).setEntityToEdit(getEntityToEdit(defaultScreenId));
}
screen.show();
Window window = screen.getWindow();
setDefaultScreenWindow(window);
if (!uiProperties.isDefaultScreenCanBeClosed()) {
window.setCloseable(false);
}
}
use of io.jmix.ui.screen.EditorScreen in project jmix by jmix-framework.
the class WebUrlRouting method buildParams.
protected Map<String, String> buildParams(Screen screen, Map<String, String> urlParams) {
String route = getRoute(screen);
if (StringUtils.isEmpty(route) && (isEditor(screen) || MapUtils.isNotEmpty(urlParams))) {
log.debug("There's no route for screen \"{}\". URL params will be ignored", screen.getId());
return Collections.emptyMap();
}
if (omitParams(screen)) {
return Collections.emptyMap();
}
Map<String, String> params = new LinkedHashMap<>();
if (isEditor(screen)) {
Object editedEntity = ((EditorScreen) screen).getEditedEntity();
if (editedEntity != null) {
if (!entityStates.isNew(editedEntity)) {
Object entityId = EntityValues.getId(editedEntity);
if (entityId != null) {
String serializedId = UrlIdSerializer.serializeId(entityId);
if (!"".equals(serializedId)) {
params.put("id", serializedId);
}
}
}
}
}
params.putAll(urlParams != null ? urlParams : Collections.emptyMap());
return params;
}
Aggregations