use of com.haulmont.cuba.gui.config.WindowInfo in project cuba by cuba-platform.
the class DesktopFrame method openFrame.
@Override
public Frame openFrame(Component parent, String windowAlias) {
WindowInfo windowInfo = windowConfig.getWindowInfo(windowAlias);
Frame wrappedFrame = ((Frame.Wrapper) wrapper).getWrappedFrame();
return getWindowManager().openFrame(wrappedFrame, parent, windowInfo);
}
use of com.haulmont.cuba.gui.config.WindowInfo in project cuba by cuba-platform.
the class ScreensHelper method getAvailableScreensMap.
protected Map<String, Object> getAvailableScreensMap(Class entityClass, ScreenType filterScreenType) {
String key = getScreensCacheKey(entityClass.getName(), getUserLocale(), filterScreenType);
Map<String, Object> screensMap = availableScreensCache.get(key);
if (screensMap != null) {
return screensMap;
}
Collection<WindowInfo> windowInfoCollection = windowConfig.getWindows();
screensMap = new TreeMap<>();
Set<String> visitedWindowIds = new HashSet<>();
for (WindowInfo windowInfo : windowInfoCollection) {
String windowId = windowInfo.getId();
// just skip for now, we assume all versions of screen can operate with the same entity
if (visitedWindowIds.contains(windowId)) {
continue;
}
String src = windowInfo.getTemplate();
if (StringUtils.isNotEmpty(src)) {
try {
Element windowElement = getWindowElement(src);
if (windowElement != null) {
if (isEntityAvailable(windowElement, entityClass, filterScreenType)) {
String caption = getScreenCaption(windowElement, src);
caption = getDetailedScreenCaption(caption, windowId);
screensMap.put(caption, windowId);
}
} else {
screensMap.put(windowId, windowId);
}
} catch (FileNotFoundException e) {
log.error(e.getMessage());
}
}
visitedWindowIds.add(windowId);
}
screensMap = Collections.unmodifiableMap(screensMap);
cacheScreens(key, screensMap);
return screensMap;
}
use of com.haulmont.cuba.gui.config.WindowInfo in project cuba by cuba-platform.
the class ScreensHelper method getDefaultBrowseScreen.
@Nullable
public WindowInfo getDefaultBrowseScreen(MetaClass metaClass) {
WindowInfo browseWindow = windowConfig.findWindowInfo(windowConfig.getBrowseScreenId(metaClass));
if (browseWindow != null && userSessionSource.getUserSession().isScreenPermitted(browseWindow.getId())) {
return browseWindow;
}
WindowInfo lookupWindow = windowConfig.findWindowInfo(windowConfig.getLookupScreenId(metaClass));
if (lookupWindow != null && userSessionSource.getUserSession().isScreenPermitted(lookupWindow.getId())) {
return lookupWindow;
}
return null;
}
use of com.haulmont.cuba.gui.config.WindowInfo in project cuba by cuba-platform.
the class UiPermissionsFrame method init.
@Override
public void init(Map<String, Object> params) {
super.init(params);
WindowConfig windowConfig = AppBeans.get(WindowConfig.NAME);
Collection<WindowInfo> windows = sortWindowInfos(windowConfig.getWindows());
Map<String, Object> screens = new LinkedHashMap<>();
for (WindowInfo windowInfo : windows) {
String id = windowInfo.getId();
String menuId = "menu-config." + id;
String localeMsg = messages.getMessage(AppConfig.getMessagesPack(), menuId);
String title = menuId.equals(localeMsg) ? id : localeMsg + " (" + id + ")";
screens.put(title, id);
}
screenFilter.setOptionsMap(screens);
companion.initPermissionsColoredColumns(uiPermissionsTable);
uiPermissionTargetsDs.addItemChangeListener(e -> {
if (!selectedComponentPanel.isVisible() && (e.getItem() != null)) {
selectedComponentPanel.setVisible(true);
}
if (selectedComponentPanel.isVisible() && (e.getItem() == null)) {
selectedComponentPanel.setVisible(false);
}
updateCheckBoxes(e.getItem());
});
uiPermissionTargetsDs.addItemPropertyChangeListener(e -> {
if ("permissionVariant".equals(e.getProperty())) {
updateCheckBoxes(uiPermissionsTable.getSingleSelected());
}
});
attachCheckBoxListener(readOnlyCheckBox, UiPermissionVariant.READ_ONLY);
attachCheckBoxListener(hideCheckBox, UiPermissionVariant.HIDE);
attachCheckBoxListener(showCheckBox, UiPermissionVariant.SHOW);
uiPermissionTargetsDs.setPermissionDs(uiPermissionsDs);
uiPermissionsDs.refresh();
uiPermissionTargetsDs.refresh();
boolean isCreatePermitted = security.isEntityOpPermitted(Permission.class, EntityOp.CREATE);
boolean isDeletePermitted = security.isEntityOpPermitted(Permission.class, EntityOp.DELETE);
boolean isRoleEditPermitted = security.isEntityOpPermitted(metadata.getClass(Role.class), EntityOp.UPDATE);
final boolean hasPermissionsToModifyPermission = isCreatePermitted && isDeletePermitted && isRoleEditPermitted;
RemoveAction removeAction = new RemoveAction(uiPermissionsTable, false);
removeAction.setAfterRemoveHandler(removedItems -> {
if (!removedItems.isEmpty()) {
UiPermissionTarget removedPermission = (UiPermissionTarget) removedItems.iterator().next();
markItemPermission(UiPermissionVariant.NOTSET, removedPermission);
}
});
removeAction.setEnabled(hasPermissionsToModifyPermission);
removeAction.setIcon(null);
removeAction.setCaption(getMessage("actions.RemoveSelected"));
removePermissionBtn.setAction(removeAction);
uiPermissionsTable.addAction(removeAction);
editPane.setEnabled(security.isEntityOpPermitted(Role.class, EntityOp.UPDATE));
applyPermissions(hasPermissionsToModifyPermission);
}
use of com.haulmont.cuba.gui.config.WindowInfo in project cuba by cuba-platform.
the class WindowDelegate method openFrame.
public Frame openFrame(Component parent, String windowAlias, Map<String, Object> params) {
WindowInfo windowInfo = windowConfig.getWindowInfo(windowAlias);
Frame wrappedFrame = ((Frame.Wrapper) wrapper).getWrappedFrame();
return window.getWindowManager().openFrame(wrappedFrame, parent, windowInfo, params);
}
Aggregations