use of com.haulmont.cuba.gui.config.WindowInfo in project cuba by cuba-platform.
the class App method afterLoggedIn.
/**
* Perform actions after success login
*/
protected void afterLoggedIn() {
UserSessionSource sessionSource = AppBeans.get(UserSessionSource.NAME);
User user = sessionSource.getUserSession().getUser();
// Change password on logon
if (Boolean.TRUE.equals(user.getChangePasswordAtNextLogon())) {
mainFrame.deactivate("");
final DesktopWindowManager wm = mainFrame.getWindowManager();
for (Window window : wm.getOpenWindows()) {
window.setEnabled(false);
}
WindowConfig windowConfig = AppBeans.get(WindowConfig.NAME);
WindowInfo changePasswordDialog = windowConfig.getWindowInfo("sec$User.changePassword");
Window changePasswordWindow = wm.openWindow(changePasswordDialog, OpenType.DIALOG.closeable(false), ParamsMap.of("cancelEnabled", false));
changePasswordWindow.addCloseListener(actionId -> {
for (Window window : wm.getOpenWindows()) {
window.setEnabled(true);
}
});
}
}
use of com.haulmont.cuba.gui.config.WindowInfo in project cuba by cuba-platform.
the class ScreensLinkHandlerProcessor method handle.
@Override
public void handle(ExternalLinkContext linkContext) {
String screenName = linkContext.getRequestParams().get("screen");
App app = linkContext.getApp();
final WindowInfo windowInfo = windowConfig.getWindowInfo(screenName);
if (windowInfo == null) {
log.warn("WindowInfo not found for screen: {}", screenName);
return;
}
try {
openWindow(windowInfo, linkContext);
} catch (EntityAccessException e) {
entityAccessExceptionHandler.handle(e, app.getWindowManager());
} catch (AccessDeniedException e) {
accessDeniedHandler.handle(e, app.getWindowManager());
} catch (NoSuchScreenException e) {
noSuchScreenHandler.handle(e, app.getWindowManager());
}
}
use of com.haulmont.cuba.gui.config.WindowInfo in project cuba by cuba-platform.
the class WebRelatedEntities method addNavigationAction.
protected void addNavigationAction(MetaClass metaClass, MetaProperty metaProperty) {
// check if browse screen available
PropertyOption propertyOption = propertyOptions.get(metaProperty.getName());
WindowInfo defaultScreen = screensHelper.getDefaultBrowseScreen(metaProperty.getRange().asClass());
if (defaultScreen != null || (propertyOption != null && StringUtils.isNotEmpty(propertyOption.getScreen()))) {
RelatedAction relatedAction = RelatedAction.create("related" + actionOrder.size(), listComponent, metaClass, metaProperty);
relatedAction.setOpenType(openType);
if (defaultScreen != null) {
relatedAction.setScreen(defaultScreen.getId());
}
if (propertyOption != null) {
if (StringUtils.isNotEmpty(propertyOption.getCaption())) {
relatedAction.setCaption(propertyOption.getCaption());
}
if (StringUtils.isNotEmpty(propertyOption.getFilterCaption())) {
relatedAction.setFilterCaption(propertyOption.getFilterCaption());
}
if (StringUtils.isNotEmpty(propertyOption.getScreen())) {
relatedAction.setScreen(propertyOption.getScreen());
}
}
addAction(relatedAction);
}
}
use of com.haulmont.cuba.gui.config.WindowInfo in project cuba by cuba-platform.
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];
WindowConfig windowConfig = AppBeans.get(WindowConfig.NAME);
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());
com.haulmont.cuba.gui.components.Window window = App.getInstance().getWindowManager().openWindow(windowInfo, 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) {
final SearchFolder searchFolder = (SearchFolder) folder;
if (searchFolder.getPresentation() != null) {
((com.haulmont.cuba.gui.components.Component.HasPresentations) filterComponent.getApplyTo()).applyPresentation(searchFolder.getPresentation().getId());
}
}
((DsContextImplementation) window.getDsContext()).resumeSuspended();
}
use of com.haulmont.cuba.gui.config.WindowInfo in project cuba by cuba-platform.
the class WebFrame method openLookup.
@Override
public Window.Lookup openLookup(Class<? extends Entity> entityClass, Window.Lookup.Handler handler, WindowManager.OpenType openType, Map<String, Object> params) {
WindowConfig windowConfig = AppBeans.get(WindowConfig.NAME);
WindowInfo lookupScreen = windowConfig.getLookupScreen(entityClass);
WebWindowManager wm = App.getInstance().getWindowManager();
return wm.openLookup(lookupScreen, handler, openType, params);
}
Aggregations