use of io.jmix.ui.WindowInfo in project jmix by jmix-framework.
the class RuntimePropertiesFrameLoader method createComponent.
@Override
public void createComponent() {
String src = element.attributeValue("src");
String screenId = element.attributeValue("id");
if (src == null) {
src = DEFAULT_DESCRIPTOR;
}
String fragmentId = screenId != null ? screenId : src;
FragmentHelper fragmentHelper = getFragmentHelper();
FrameHelper frameHelper = getFrameHelper();
WindowInfo windowInfo = frameHelper.createFakeWindowInfo(src, fragmentId);
UiComponents uiComponents = applicationContext.getBean(UiComponents.class);
Fragment fragment = uiComponents.create(Fragment.NAME);
ScreenFragment controller = fragmentHelper.createController(windowInfo, fragment);
// setup screen and controller
ComponentLoaderContext parentContext = (ComponentLoaderContext) getContext();
FrameOwner hostController = parentContext.getFrame().getFrameOwner();
// setup screen and controller
setHostController(controller, hostController);
setWindowId(controller, windowInfo.getId());
setFrame(controller, fragment);
setScreenContext(controller, new ScreenContextImpl(windowInfo, parentContext.getOptions(), getScreenContext(hostController)));
setScreenData(controller, applicationContext.getBean(ScreenData.class));
FragmentImplementation fragmentImpl = (FragmentImplementation) fragment;
fragmentImpl.setFrameOwner(controller);
fragmentImpl.setId(fragmentId);
FragmentContextImpl frameContext = new FragmentContextImpl(fragment, innerContext);
((FrameImplementation) fragment).setContext(frameContext);
if (windowInfo.getTemplate() != null) {
String frameId = fragmentId;
if (parentContext.getFullFrameId() != null) {
frameId = parentContext.getFullFrameId() + "." + frameId;
}
innerContext = new ComponentLoaderContext(getContext().getOptions());
innerContext.setMessageGroup(fragmentHelper.getMessageGroup(windowInfo.getTemplate()));
innerContext.setCurrentFrameId(fragmentId);
innerContext.setFullFrameId(frameId);
innerContext.setFrame(fragment);
innerContext.setParent(parentContext);
LayoutLoader layoutLoader = getLayoutLoader(innerContext);
ScreenXmlLoader screenXmlLoader = applicationContext.getBean(ScreenXmlLoader.class);
Element rootElement = screenXmlLoader.load(windowInfo.getTemplate(), windowInfo.getId(), getContext().getParams());
String messagesPack = rootElement.attributeValue("messagesPack");
if (messagesPack != null) {
innerContext.setMessageGroup(messagesPack);
}
this.fragmentLoader = layoutLoader.createFragmentContent(fragment, rootElement);
}
this.resultComponent = fragment;
}
use of io.jmix.ui.WindowInfo in project jmix by jmix-framework.
the class WidgetRepositoryImpl method initializeWidgets.
protected void initializeWidgets() {
widgetTypeInfos = new ArrayList<>();
for (WindowInfo windowInfo : windowConfig.getWindows()) {
if (StringUtils.isNotBlank(windowInfo.getTemplate())) {
Class clazz = windowInfo.getControllerClass();
if (clazz.isAnnotationPresent(DashboardWidget.class)) {
DashboardWidget widgetAnnotation = (DashboardWidget) clazz.getAnnotation(DashboardWidget.class);
String editFragmentId = widgetAnnotation.editFragmentId();
if (StringUtils.isNotBlank(editFragmentId) && !windowConfig.hasWindow(editFragmentId)) {
log.error("Unable to find {} edit screen in screen config for widget {}", editFragmentId, widgetAnnotation.name());
throw new IllegalArgumentException(String.format("Unable to find %s edit screen in screen config for widget %s", editFragmentId, widgetAnnotation.name()));
}
widgetTypeInfos.add(new WidgetTypeInfo(widgetAnnotation.name(), windowInfo.getId(), editFragmentId));
}
}
}
}
use of io.jmix.ui.WindowInfo in project jmix by jmix-framework.
the class EditorBuilderProcessor method getOptionsForScreen.
@Override
protected <E> ScreenOptions getOptionsForScreen(String editorScreenId, E entity, EditorBuilder<E> builder) {
ScreenOptions options = super.getOptionsForScreen(editorScreenId, entity, builder);
WindowInfo windowInfo = windowConfig.getWindowInfo(editorScreenId);
if (LegacyFrame.class.isAssignableFrom(windowInfo.getControllerClass()) && options == FrameOwner.NO_OPTIONS) {
HashMap<String, Object> paramsMap = new HashMap<>();
paramsMap.put(WindowParams.ITEM.name(), entity);
options = new MapScreenOptions(paramsMap);
}
return options;
}
use of io.jmix.ui.WindowInfo in project jmix by jmix-framework.
the class BackgroundWorkWindow method show.
/**
* Show modal window with message which will last until task completes.
* Optionally cancel button can be displayed. By pressing cancel button user can cancel task execution.
*
* @param task background task containing long operation
* @param title window title, optional
* @param message window message, optional
* @param cancelAllowed show or not cancel button
* @param <T> task progress unit
* @param <V> task result type
*/
public static <T, V> void show(BackgroundTask<T, V> task, @Nullable String title, @Nullable String message, boolean cancelAllowed) {
if (task.getOwnerScreen() == null) {
throw new IllegalArgumentException("Task without owner cannot be run");
}
Map<String, Object> params = new HashMap<>();
params.put("task", task);
params.put("title", title);
params.put("message", message);
params.put("cancelAllowed", cancelAllowed);
Screens screens = UiControllerUtils.getScreenContext(task.getOwnerScreen()).getScreens();
WindowInfo windowInfo = AppBeans.get(WindowConfig.class).getWindowInfo("backgroundWorkWindow");
((WindowManager) screens).openWindow(windowInfo, OpenType.DIALOG, params);
}
Aggregations