/** * Open a simple screen. * * @param windowAlias screen ID as defined in {@code screens.xml} * @param openType how to open the screen * @return created window * * @deprecated Use {@link Screens} bean instead. */ @Deprecated default AbstractWindow openWindow(String windowAlias, WindowManager.OpenType openType) { WindowConfig windowConfig = AppBeans.get(WindowConfig.NAME); WindowInfo windowInfo = windowConfig.getWindowInfo(windowAlias); return (AbstractWindow) getWindowManager().openWindow(windowInfo, openType); }
/** * Open a simple screen. * * @param windowAlias screen ID as defined in {@code screens.xml} * @param openType how to open the screen * @param params parameters to pass to {@code init()} method of the screen's controller * @return created window * * @deprecated Use {@link Screens} bean instead. */ @Deprecated default AbstractWindow openWindow(String windowAlias, WindowManager.OpenType openType, Map<String, Object> params) { WindowConfig windowConfig = AppBeans.get(WindowConfig.NAME); WindowInfo windowInfo = windowConfig.getWindowInfo(windowAlias); return (AbstractWindow) getWindowManager().openWindow(windowInfo, openType, params); }
protected void openReportParamsDialog(FrameOwner screen, Report report, @Nullable Map<String, Object> parameters, @Nullable ReportInputParameter inputParameter, @Nullable String templateCode, @Nullable String outputFileName, boolean bulkPrint) { Map<String, Object> params = ParamsMap.of( REPORT_PARAMETER, report, PARAMETERS_PARAMETER, parameters, INPUT_PARAMETER, inputParameter, TEMPLATE_CODE_PARAMETER, templateCode, OUTPUT_FILE_NAME_PARAMETER, outputFileName, BULK_PRINT, bulkPrint ); ScreenContext screenContext = UiControllerUtils.getScreenContext(screen); WindowManager wm = (WindowManager) screenContext.getScreens(); WindowInfo windowInfo = AppBeans.get(WindowConfig.class).getWindowInfo("report$inputParameters"); wm.openWindow(windowInfo, OpenType.DIALOG, params); }
/** * Show modal window with message which will last until task completes. * Optionally cancel button can be displayed. By pressing cancel button user can cancel task execution. * * @param task background task containing long operation * @param title window title, optional * @param message window message, optional * @param total total number of items, that will be processed * @param cancelAllowed show or not cancel button * @param percentProgress show progress in percents * @param <V> task result type */ public static <T extends Number, V> void show(BackgroundTask<T, V> task, @Nullable String title, @Nullable String message, Number total, boolean cancelAllowed, boolean percentProgress) { if (task.getOwnerScreen() == null) { throw new IllegalArgumentException("Task without owner cannot be run"); } Map<String, Object> params = new HashMap<>(); params.put("task", task); params.put("title", title); params.put("message", message); params.put("total", total); params.put("cancelAllowed", cancelAllowed); params.put("percentProgress", percentProgress); Screens screens = UiControllerUtils.getScreenContext(task.getOwnerScreen()).getScreens(); WindowInfo windowInfo = AppBeans.get(WindowConfig.class).getWindowInfo("backgroundWorkProgressWindow"); ((WindowManager)screens).openWindow(windowInfo, OpenType.DIALOG, params); }
/** * Show modal window with message which will last until task completes. * Optionally cancel button can be displayed. By pressing cancel button user can cancel task execution. * * @param task background task containing long operation * @param title window title, optional * @param message window message, optional * @param cancelAllowed show or not cancel button * @param <T> task progress unit * @param <V> task result type */ public static <T, V> void show(BackgroundTask<T, V> task, @Nullable String title, @Nullable String message, boolean cancelAllowed) { if (task.getOwnerScreen() == null) { throw new IllegalArgumentException("Task without owner cannot be run"); } Map<String, Object> params = new HashMap<>(); params.put("task", task); params.put("title", title); params.put("message", message); params.put("cancelAllowed", cancelAllowed); Screens screens = UiControllerUtils.getScreenContext(task.getOwnerScreen()).getScreens(); WindowInfo windowInfo = AppBeans.get(WindowConfig.class).getWindowInfo("backgroundWorkWindow"); ((WindowManager)screens).openWindow(windowInfo, OpenType.DIALOG, params); }
protected void _addCondition(AbstractConditionDescriptor descriptor, ConditionsTree conditionsTree) { final AbstractCondition condition = descriptor.createCondition(); if (descriptor instanceof CustomConditionCreator) { WindowInfo windowInfo = windowConfig.getWindowInfo("customConditionEditor"); Map<String, Object> params = new HashMap<>(); params.put("condition", condition); params.put("conditionsTree", conditionsTree); final CustomConditionEditor window = (CustomConditionEditor) windowManager.openWindow(windowInfo, OpenType.DIALOG, params); window.addCloseListener(actionId -> { if (Window.COMMIT_ACTION_ID.equals(actionId)) { handler.handle(condition); } }); } else if (descriptor instanceof DynamicAttributesConditionCreator) { WindowInfo windowInfo = windowConfig.getWindowInfo("dynamicAttributesConditionEditor"); Map<String, Object> params = new HashMap<>(); params.put("condition", condition); DynamicAttributesConditionEditor window = (DynamicAttributesConditionEditor) windowManager.openWindow(windowInfo, OpenType.DIALOG, params); window.addCloseListener(actionId -> { if (Window.COMMIT_ACTION_ID.equals(actionId)) { handler.handle(condition); } }); } else { handler.handle(condition); } } }
@Override public void actionPerform(Component component) { WindowInfo windowInfo = windowConfig.getWindowInfo("filterSelect"); FilterSelectWindow window = (FilterSelectWindow) windowManager.openWindow(windowInfo, OpenType.DIALOG, ParamsMap.of("filterEntities", filterEntities)); window.addCloseListener(actionId -> { if (Window.COMMIT_ACTION_ID.equals(actionId)) { FilterEntity selectedEntity = window.getFilterEntity(); setFilterEntity(selectedEntity); } }); }
/** * Opens AddCondition window. When condition is selected/created a {@code Handler#handle} method will be called * * @param conditionsTree conditions tree is necessary for custom condition editing. It is used for suggestion of * other component names in 'param where' field. */ public void addCondition(final ConditionsTree conditionsTree) { Map<String, Object> params = new HashMap<>(); ConditionDescriptorsTreeBuilderAPI descriptorsTreeBuilder = AppBeans.getPrototype(ConditionDescriptorsTreeBuilderAPI.NAME, filter, PROPERTIES_HIERARCHY_DEPTH, hideDynamicAttributes, hideCustomConditions, conditionsTree); Tree<AbstractConditionDescriptor> descriptorsTree = descriptorsTreeBuilder.build(); params.put("descriptorsTree", descriptorsTree); WindowInfo windowInfo = windowConfig.getWindowInfo("addCondition"); AddConditionWindow window = (AddConditionWindow) windowManager.openWindow(windowInfo, OpenType.DIALOG, params); window.addCloseListener(actionId -> { if (Window.COMMIT_ACTION_ID.equals(actionId)) { Collection<AbstractConditionDescriptor> descriptors = window.getDescriptors(); if (descriptors != null) { for (AbstractConditionDescriptor descriptor : descriptors) { _addCondition(descriptor, conditionsTree); } } } }); }
public void showInfo(Entity entity, MetaClass metaClass, Component.BelongToFrame component) { WindowManager wm = (WindowManager) ComponentsHelper.getScreenContext(component).getScreens(); WindowInfo windowInfo = AppBeans.get(WindowConfig.class).getWindowInfo("sysInfoWindow"); wm.openWindow(windowInfo, OpenType.DIALOG, ParamsMap.of( "metaClass", metaClass, "item", entity)); } }
protected void openReportParamsDialog(Report report, FrameOwner screen) { ScreenContext screenContext = UiControllerUtils.getScreenContext(screen); WindowManager wm = (WindowManager) screenContext.getScreens(); WindowInfo windowInfo = AppBeans.get(WindowConfig.class).getWindowInfo("report$inputParameters"); wm.openWindow(windowInfo, OpenType.DIALOG, ParamsMap.of("report", report)); }
@Override public void actionPerform(Component component) { Set<Entity> ownerSelection = target.getSelected(); if (!ownerSelection.isEmpty()) { String entityType; if (target.getItems() instanceof EntityDataUnit) { MetaClass metaClass = ((EntityDataUnit) target.getItems()).getEntityMetaClass(); entityType = metaClass.getName(); } else { throw new UnsupportedOperationException("Unsupported data unit " + target.getItems()); } String[] strings = ValuePathHelper.parse(ComponentsHelper.getFilterComponentPath(filter)); String componentId = ValuePathHelper.format(Arrays.copyOfRange(strings, 1, strings.length)); Map<String, Object> params = new HashMap<>(); params.put("entityType", entityType); params.put("items", ownerSelection); params.put("componentPath", ComponentsHelper.getFilterComponentPath(filter)); params.put("componentId", componentId); params.put("foldersPane", filterHelper.getFoldersPane()); params.put("entityClass", adapter.getMetaClass().getJavaClass().getName()); params.put("query", adapter.getQuery()); WindowManager wm = (WindowManager) ComponentsHelper.getScreenContext(filter).getScreens(); WindowInfo windowInfo = windowConfig.getWindowInfo("saveSetInFolder"); wm.openWindow(windowInfo, OpenType.DIALOG, params); } } }
@Override public void actionPerform(Component component) { WindowManager windowManager = windowManagerProvider.get(); WindowInfo windowInfo = windowConfig.getWindowInfo("date-interval-editor"); DateIntervalEditor editor = (DateIntervalEditor) windowManager.openWindow(windowInfo, OpenType.DIALOG, Collections.singletonMap("dateIntervalDescription", value.getDescription())); editor.addListener(actionId -> { if (Window.COMMIT_ACTION_ID.equals(actionId)) { value = editor.getDateIntervalValue(); textField.setValue(value.getLocalizedValue()); fireValueChangeListeners(value); } }); }
params.put("conditions", conditions); FilterEditor window = (FilterEditor) windowManager.openWindow(windowInfo, OpenType.DIALOG, params); window.addCloseListener(actionId -> { if (Window.COMMIT_ACTION_ID.equals(actionId)) {
Window window = wm.openWindow(windowInfo, OpenType.DIALOG, params);
@Override public void perform(final Folder folder) { WindowConfig windowConfig = AppBeans.get(WindowConfig.NAME); WindowManager wm = App.getInstance().getWindowManager(); WindowInfo windowInfo = windowConfig.getWindowInfo("fileUploadDialog"); FileUploadDialog dialog = (FileUploadDialog) wm.openWindow(windowInfo, OpenType.DIALOG); dialog.addCloseListener(actionId -> { if (COMMIT_ACTION_ID.equals(actionId)) { try { FileUploadingAPI fileUploading = AppBeans.get(FileUploadingAPI.NAME); byte[] data = FileUtils.readFileToByteArray(fileUploading.getFile(dialog.getFileId())); fileUploading.deleteFile(dialog.getFileId()); foldersService.importFolder(folder, data); } catch (AccessDeniedException ex) { throw ex; } catch (Exception ex) { dialog.showNotification( messages.getMainMessage("folders.importFailedNotification"), ex.getMessage(), Frame.NotificationType.ERROR ); } refreshFolders(); } }); } }
protected void analyzeLayout(Object target) { Window window = findWindow((Layout) target); if (window != null) { LayoutAnalyzer analyzer = new LayoutAnalyzer(); List<LayoutTip> tipsList = analyzer.analyze(window); if (tipsList.isEmpty()) { Notifications notifications = ComponentsHelper.getScreenContext(window).getNotifications(); notifications.create(NotificationType.HUMANIZED) .withCaption("No layout problems found") .show(); } else { WindowManager wm = (WindowManager) ComponentsHelper.getScreenContext(window).getScreens(); WindowInfo windowInfo = AppBeans.get(WindowConfig.class).getWindowInfo("layoutAnalyzer"); wm.openWindow(windowInfo, WindowManager.OpenType.DIALOG, ParamsMap.of("tipsList", tipsList)); } } }
@Override public void handleAction(com.vaadin.event.Action action, Object sender, Object target) { if (initialized) { if (saveSettingsAction == action) { Screen screen = getFrameOwner(); UiControllerUtils.saveSettings(screen); } else if (restoreToDefaultsAction == action) { Screen screen = getFrameOwner(); UiControllerUtils.deleteSettings(screen); } else if (analyzeAction == action) { LayoutAnalyzer analyzer = new LayoutAnalyzer(); List<LayoutTip> tipsList = analyzer.analyze(WebDialogWindow.this); if (tipsList.isEmpty()) { getWindowManager().showNotification("No layout problems found", Frame.NotificationType.HUMANIZED); } else { WindowConfig windowConfig = beanLocator.get(WindowConfig.NAME); WindowInfo windowInfo = windowConfig.getWindowInfo("layoutAnalyzer"); getWindowManager().openWindow(windowInfo, WindowManager.OpenType.DIALOG, ParamsMap.of("tipsList", tipsList)); } } } } }
wm.openWindow(windowInfo, OpenType.NEW_TAB, ParamsMap.of(
@Override public void onApplicationEvent(AppLoggedInEvent event) { App app = event.getApp(); Connection connection = app.getConnection(); if (connection.isAuthenticated() && !isLoggedInWithExternalAuth(connection.getSessionNN())) { User user = connection.getSessionNN().getUser(); // Change password on logon if (Boolean.TRUE.equals(user.getChangePasswordAtNextLogon())) { WindowManager wm = app.getWindowManager(); for (Window window : wm.getOpenWindows()) { window.setEnabled(false); } WindowInfo changePasswordDialog = windowConfig.getWindowInfo("sec$User.changePassword"); Window changePasswordWindow = wm.openWindow(changePasswordDialog, WindowManager.OpenType.DIALOG.closeable(false), ParamsMap.of("cancelEnabled", Boolean.FALSE)); changePasswordWindow.addCloseListener(actionId -> { for (Window window : wm.getOpenWindows()) { window.setEnabled(true); } }); } } } }
protected void showPivotTable(ShowPivotMode mode) { ParamsMap paramsMap = ParamsMap.of(); if (mode == ALL_ROWS) { paramsMap.pair("dataItems", convertEntitiesToDataItems(target.getDatasource().getItems())); } else { paramsMap.pair("dataItems", convertEntitiesToDataItems(target.getSelected())); } paramsMap.pair("properties", getPropertiesWithLocale()); paramsMap.pair("nativeJson", nativeJson); WindowManager wm = target.getFrame().getWindowManager(); WindowConfig windowConfig = AppBeans.get(WindowConfig.NAME); wm.openWindow(windowConfig.getWindowInfo(SCREEN_ID), WindowManager.OpenType.NEW_TAB, paramsMap.create()); }