use of io.jmix.ui.component.Frame in project jmix by jmix-framework.
the class FilteringLookupAction method getFilterComponentPath.
public static String getFilterComponentPath(Filter filter) {
StringBuilder sb = new StringBuilder(filter.getId() != null ? filter.getId() : "filterWithoutId");
Frame frame = filter.getFrame();
while (frame != null) {
sb.insert(0, ".");
String s = frame.getId() != null ? frame.getId() : "frameWithoutId";
if (s.contains(".")) {
s = "[" + s + "]";
}
sb.insert(0, s);
if (frame instanceof Window) {
break;
}
frame = frame.getFrame();
}
return sb.toString();
}
use of io.jmix.ui.component.Frame in project jmix by jmix-framework.
the class DsContextImpl method get.
@Override
public Datasource get(String id) {
checkNotNullArgument(id, "Null datasource ID");
id = aliasesMap.getOrDefault(id, id);
Datasource ds = null;
if (!id.contains(".")) {
ds = datasourceMap.get(id);
if (ds == null && parent != null) {
ds = parent.get(id);
}
} else {
if (windowContext != null) {
String nestedFramePath = id.substring(0, id.indexOf("."));
Component nestedFrame = getFrameContext().getFrame().getComponent(nestedFramePath);
if (nestedFrame instanceof Frame) {
String nestedDsId = id.substring(id.indexOf(".") + 1);
FrameOwner frameOwner = ((Frame) nestedFrame).getFrameOwner();
if (frameOwner instanceof LegacyFrame) {
ds = ((LegacyFrame) frameOwner).getDsContext().get(nestedDsId);
}
}
}
}
return ds;
}
use of io.jmix.ui.component.Frame in project jmix by jmix-framework.
the class HasWindowManager method openFrame.
/**
* Load a frame registered in {@code screens.xml} and optionally show it inside a parent component of this
* frame. <br> It is recommended to use {@link Fragments} bean instead.
*
* @param parent if specified, all parent's sub components will be removed and the frame will be added
* @param windowAlias frame ID as defined in {@code screens.xml}
* @param params parameters to be passed into the frame's controller {@code init} method
* @return frame's controller instance
*/
@Deprecated
default Frame openFrame(@Nullable Component parent, String windowAlias, Map<String, Object> params) {
WindowConfig windowConfig = AppBeans.get(WindowConfig.class);
WindowInfo windowInfo = windowConfig.getWindowInfo(windowAlias);
Frame parentFrame;
if (this instanceof LegacyFrame) {
parentFrame = ((LegacyFrame) this).getWrappedFrame();
} else {
parentFrame = ((Frame) this);
}
return getWindowManager().openFrame(parentFrame, parent, windowInfo, params);
}
use of io.jmix.ui.component.Frame in project jmix by jmix-framework.
the class DateIntervalAction method actionPerform.
@Override
public void actionPerform(Component component) {
super.actionPerform(component);
if (component instanceof Component.BelongToFrame) {
Frame frame = ((Component.BelongToFrame) component).getFrame();
if (frame == null) {
throw new IllegalStateException("Component is not attached to the frame");
}
screenBuilders.screen(frame.getFrameOwner()).withScreenClass(DateIntervalDialog.class).withOpenMode(OpenMode.DIALOG).withAfterCloseListener(this::onDateIntervalDialogCloseEvent).build().withValue(valuePicker.getValue()).withMetaPropertyPath(metaPropertyPath).show();
}
}
use of io.jmix.ui.component.Frame in project jmix by jmix-framework.
the class FragmentsImpl method createFragment.
protected <T extends ScreenFragment> T createFragment(FrameOwner parent, WindowInfo windowInfo, ScreenOptions options) {
if (windowInfo.getType() != WindowInfo.Type.FRAGMENT) {
throw new IllegalArgumentException(String.format("Unable to create fragment %s it is a screen: %s", windowInfo.getId(), windowInfo.getControllerClass()));
}
Timer.Sample createSample = Timer.start(meterRegistry);
Fragment fragment = createFragmentInternal();
ScreenFragment controller = fragmentHelper.createController(windowInfo, fragment);
// setup screen and controller
setHostController(controller, parent);
setWindowId(controller, windowInfo.getId());
setFrame(controller, fragment);
setScreenContext(controller, new ScreenContextImpl(windowInfo, options, getScreenContext(parent)));
setScreenData(controller, applicationContext.getBean(ScreenData.class));
FragmentImplementation fragmentImpl = (FragmentImplementation) fragment;
fragmentImpl.setFrameOwner(controller);
fragmentImpl.setId(controller.getId());
createSample.stop(createScreenTimer(meterRegistry, ScreenLifeCycle.CREATE, windowInfo.getId()));
Timer.Sample loadSample = Timer.start(meterRegistry);
Frame parentFrame = getFrame(parent);
// fake parent loader context
ComponentLoaderContext loaderContext = createComponentLoaderContext(options);
FragmentContextImpl frameContext = new FragmentContextImpl(fragment, loaderContext);
frameContext.setManualInitRequired(true);
((FrameImplementation) fragment).setContext(frameContext);
loaderContext.setCurrentFrameId(windowInfo.getId());
loaderContext.setFullFrameId(windowInfo.getId());
loaderContext.setFrame(fragment);
loaderContext.setParent(null);
loaderContext.setScreenData(UiControllerUtils.getScreenData(parent));
// load XML if needed
if (windowInfo.getTemplate() != null) {
ComponentLoaderContext innerContext = createComponentLoaderContext(options);
innerContext.setCurrentFrameId(windowInfo.getId());
innerContext.setFullFrameId(windowInfo.getId());
innerContext.setFrame(fragment);
innerContext.setParent(loaderContext);
LayoutLoader layoutLoader = applicationContext.getBean(LayoutLoader.class, innerContext);
Element rootElement = screenXmlLoader.load(windowInfo.getTemplate(), windowInfo.getId(), emptyMap());
innerContext.setMessageGroup(fragmentHelper.findMessageGroup(rootElement, windowInfo.getTemplate()));
loadAdditionalData(rootElement, innerContext);
ComponentLoader<Fragment> fragmentLoader = layoutLoader.createFragmentContent(fragment, rootElement);
fragmentLoader.loadComponent();
loaderContext.getInjectTasks().addAll(innerContext.getInjectTasks());
loaderContext.getInitTasks().addAll(innerContext.getInitTasks());
loaderContext.getPostInitTasks().addAll(innerContext.getPostInitTasks());
}
loaderContext.addInjectTask(new FragmentLoaderInjectTask(fragment, options, applicationContext));
loaderContext.addInitTask(new FragmentLoaderInitTask(fragment, options, loaderContext, applicationContext));
loadSample.stop(createScreenTimer(meterRegistry, ScreenLifeCycle.LOAD, windowInfo.getId()));
loaderContext.executeInjectTasks();
fragmentImpl.setFrame(parentFrame);
// noinspection unchecked
return (T) controller;
}
Aggregations