use of io.jmix.ui.component.Window 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.Window in project jmix by jmix-framework.
the class NotFoundScreen method onInit.
@Subscribe
protected void onInit(InitEvent event) {
Window window = getWindow();
Label<String> msgLabel = uiComponents.create(Label.TYPE_STRING);
msgLabel.setAlignment(Component.Alignment.TOP_CENTER);
msgLabel.addStyleName(ThemeClassNames.LABEL_H1);
msgLabel.setValue(messages.formatMessage("", "notAssociatedRoute", requestedRoute));
window.add(msgLabel);
window.setCaption(messages.formatMessage("", "tabCaption", requestedRoute));
}
use of io.jmix.ui.component.Window in project jmix by jmix-framework.
the class SideMenuBuilder method build.
protected void build(SideMenu menu, List<MenuItem> rootItems) {
Window window = ComponentsHelper.getWindowImplementation(menu);
if (window == null) {
throw new IllegalStateException("SideMenu is not belong to Window");
}
for (MenuItem menuItem : rootItems) {
// AppMenu does not support separators
UiMenuContext menuItemContext = new UiMenuContext(menuItem);
accessManager.applyRegisteredConstraints(menuItemContext);
if (menuItemContext.isPermitted() && !menuItem.isSeparator()) {
createMenuBarItem(window, menu, menuItem);
}
}
removeExtraSeparators(menu);
}
use of io.jmix.ui.component.Window in project jmix by jmix-framework.
the class FoldersBean method openFolder.
@Override
public void openFolder(AbstractSearchFolder folder) {
if (StringUtils.isBlank(folder.getFilterComponentId())) {
log.warn("Unable to open folder: componentId is blank");
return;
}
String[] strings = ValuePathHelper.parse(folder.getFilterComponentId());
String screenId = strings[0];
WindowInfo windowInfo = windowConfig.getWindowInfo(screenId);
Map<String, Object> params = new HashMap<>();
WindowParams.DISABLE_AUTO_REFRESH.set(params, true);
WindowParams.DISABLE_RESUME_SUSPENDED.set(params, true);
if (!StringUtils.isBlank(folder.getTabName())) {
WindowParams.DESCRIPTION.set(params, messages.getMainMessage(folder.getTabName()));
} else {
WindowParams.DESCRIPTION.set(params, messages.getMainMessage(folder.getName()));
}
WindowParams.FOLDER_ID.set(params, folder.getId());
WindowManager wm = windowManagerProvider.get();
Window window = wm.openWindow(windowInfo, WindowManager.OpenType.NEW_TAB, params);
Filter filterComponent = null;
if (strings.length > 1) {
String filterComponentId = StringUtils.join(Arrays.copyOfRange(strings, 1, strings.length), '.');
filterComponent = (Filter) window.getComponentNN(filterComponentId);
FilterEntity filterEntity = metadata.create(FilterEntity.class);
filterEntity.setFolder(folder);
filterEntity.setComponentId(folder.getFilterComponentId());
filterEntity.setName(folder.getLocName());
filterEntity.setXml(folder.getFilterXml());
filterEntity.setApplyDefault(BooleanUtils.isNotFalse(folder.getApplyDefault()));
if (folder instanceof SearchFolder) {
filterEntity.setIsSet(((SearchFolder) folder).getIsSet());
}
filterComponent.setFilterEntity(filterEntity);
filterComponent.switchFilterMode(FilterDelegate.FilterMode.GENERIC_MODE);
}
if (filterComponent != null && folder instanceof SearchFolder) {
SearchFolder searchFolder = (SearchFolder) folder;
if (searchFolder.getPresentationId() != null) {
((HasTablePresentations) filterComponent.getApplyTo()).applyPresentation(searchFolder.getPresentationId());
}
}
if (window.getFrameOwner() instanceof LegacyFrame) {
DsContext dsContext = ((LegacyFrame) window.getFrameOwner()).getDsContext();
if (dsContext != null) {
((DsContextImplementation) dsContext).resumeSuspended();
}
}
}
use of io.jmix.ui.component.Window in project jmix by jmix-framework.
the class RoleAssignmentScreen method initScreenActions.
protected void initScreenActions() {
Window window = getWindow();
Messages messages = getApplicationContext().getBean(Messages.class);
Icons icons = getApplicationContext().getBean(Icons.class);
String commitShortcut = getApplicationContext().getBean(UiScreenProperties.class).getCommitShortcut();
Action commitAndCloseAction = new BaseAction(Window.COMMIT_ACTION_ID).withCaption(messages.getMessage("actions.Ok")).withIcon(icons.get(JmixIcon.EDITOR_OK)).withPrimary(true).withShortcut(commitShortcut).withHandler(actionPerformedEvent -> {
// noinspection ConstantConditions
getScreenData().getDataContext().commit();
close(new StandardCloseAction(Window.COMMIT_ACTION_ID));
});
window.addAction(commitAndCloseAction);
Action closeAction = new BaseAction(Window.CLOSE_ACTION_ID).withIcon(icons.get(JmixIcon.EDITOR_CANCEL)).withCaption(messages.getMessage("actions.Cancel")).withHandler(actionPerformedEvent -> {
if (dataContext.hasChanges()) {
screenValidation.showUnsavedChangesDialog(this, WINDOW_CLOSE_ACTION).onDiscard(() -> close(WINDOW_CLOSE_ACTION));
} else {
close(WINDOW_CLOSE_ACTION);
}
});
window.addAction(closeAction);
}
Aggregations