Hello everyone!
How can I switch to a tab if it is already open? At the moment I override isSame() method as it is described in the documentation.
https://docs.jmix.ru/jmix/ui/screens/annotations.html?roistat_visit=227700
But in this way the tab is closed and reopened again. But I need to switch to the open tab without closing it.
Any ideas?
Hi,
You can determine what closes the screen and prevent closing. The code below, checks that the screen is closing by main menu item, prevent closing and makes this screen active:
public class UserBrowse extends StandardLookup<User> {
@Autowired
private Screens screens;
@Subscribe
public void onBeforeClose(BeforeCloseEvent event) {
StandardCloseAction closeAction = ((StandardCloseAction) event.getCloseAction());
if ("mainMenu".equals(closeAction.getActionId())) {
event.preventWindowClose();
// Select a tab that contains this screen
Collection<WindowStack> workAreaStacks = screens.getOpenedScreens().getWorkAreaStacks();
for (WindowStack windowStack : workAreaStacks) {
if (windowStack.getBreadcrumbs().contains(this)) {
windowStack.select();
}
}
}
}
}
Regards,
Gleb