/** * Focuses the first {@link Focusable} component, if present. */ default void focusFirstComponent() { ComponentsHelper.walkComponents(this, component -> { if (component instanceof Focusable) { ((Focusable) component).focus(); return true; } return false; }); } }
public List<LayoutTip> analyze(Window window) { final List<LayoutTip> errors = new ArrayList<>(); for (Inspection inspection : rootInspections) { errors.addAll(inspection.analyze(window, "window")); } ComponentsHelper.walkComponents(window, new ComponentVisitor() { @Override public void visit(Component component, String name) { for (Inspection inspection : inspections) { errors.addAll(inspection.analyze(component, name)); } } }); return errors; }
/** * Apply attribute access rules to a given frame. It means that all components bound to datasources will adjust * their visible/read-only/required state according to security state of entity instances contained in the datasources. * * @param frameOwner frame or screen * @param reset whether to reset the components to the default state specified by role-based security and model * annotations. If you invoke this method to apply attribute access to already opened screen, set * the parameter to true, but keep in mind that previous programmatic changes in the components * visible/read-only/required state will be lost. */ public void applyAttributeAccess(FrameOwner frameOwner, boolean reset) { ComponentContainer componentContainer; if (frameOwner instanceof Screen) { componentContainer = ((Screen) frameOwner).getWindow(); } else { componentContainer = (Window) frameOwner; } ComponentsHelper.walkComponents(componentContainer, (component, name) -> visitComponent(component, reset)); }
/** * Apply settings for screen. * * @param screen screen * @param settings settings */ public void applySettings(Screen screen, Settings settings) { checkNotNullArgument(screen); checkNotNullArgument(settings); walkComponents( screen.getWindow(), (component, name) -> { if (component.getId() != null && component instanceof HasSettings) { log.trace("Applying settings for {} : {} ", name, component); Element e = settings.get(name); ((HasSettings) component).applySettings(e); if (component instanceof HasPresentations && e.attributeValue("presentation") != null) { String def = e.attributeValue("presentation"); if (!StringUtils.isEmpty(def)) { UUID defaultId = UUID.fromString(def); ((HasPresentations) component).applyPresentationAsDefault(defaultId); } } } } ); }
protected void showRootWindow(Screen screen) { if (screen instanceof MainScreen) { MainScreen mainScreen = (MainScreen) screen; // bind system UI components to AbstractMainWindow walkComponents(screen.getWindow(), component -> { if (component instanceof AppWorkArea) { mainScreen.setWorkArea((AppWorkArea) component); } else if (component instanceof UserIndicator) { mainScreen.setUserIndicator((UserIndicator) component); } else if (component instanceof FoldersPane) { mainScreen.setFoldersPane((FoldersPane) component); } return false; }); } ui.setTopLevelWindow((RootWindow) screen.getWindow()); }
/** * Initializes edit controls, depending on if they should be enabled or disabled. * @param enabled if true - enables edit controls and disables controls on the left side of the splitter * if false - vice versa */ protected void initEditComponents(boolean enabled) { TabSheet tabSheet = getTabSheet(); if (tabSheet != null) { ComponentsHelper.walkComponents(tabSheet, (component, name) -> { if (component instanceof FieldGroup) { ((FieldGroup) component).setEditable(enabled); } else if (component instanceof Table) { ((Table) component).getActions().forEach(action -> action.setEnabled(enabled)); } else if (!(component instanceof ComponentContainer)) { component.setEnabled(enabled); } }); } else { getForm().setEditable(enabled); } getActionsPane().setVisible(enabled); getLookupBox().setEnabled(!enabled); }
/** * Initializes edit controls, depending on if they should be enabled or disabled. * @param enabled if true - enables edit controls and disables controls on the left side of the splitter * if false - vice versa */ protected void initEditComponents(boolean enabled) { TabSheet tabSheet = getTabSheet(); if (tabSheet != null) { ComponentsHelper.walkComponents(tabSheet, (component, name) -> { if (component instanceof FieldGroup) { ((FieldGroup) component).setEditable(enabled); } else if (component instanceof Table) { ((Table) component).getActions().forEach(action -> action.setEnabled(enabled)); } else if (!(component instanceof ComponentContainer)) { component.setEnabled(enabled); } }); } else { getFieldGroup().setEditable(enabled); } getActionsPane().setVisible(enabled); getLookupBox().setEnabled(!enabled); }
checkNotNullArgument(settings); walkComponents( screen.getWindow(), (component, name) -> {
Settings settings = UiControllerUtils.getSettings(window.getFrameOwner()); if (settings != null) { walkComponents(tabContent, (settingsComponent, name) -> { if (settingsComponent.getId() != null && settingsComponent instanceof HasSettings) {
walkComponents(tabContent, (settingsComponent, name) -> { if (settingsComponent.getId() != null && settingsComponent instanceof HasSettings) {
@Override protected void afterLookupWindowOpened(Window lookupWindow) { boolean found = ComponentsHelper.walkComponents(lookupWindow, screenComponent -> { if (!(screenComponent instanceof Filter)) { return false; } else { MetaClass actualMetaClass = ((FilterImplementation) screenComponent).getEntityMetaClass(); MetaClass propertyMetaClass = extendedEntities.getEffectiveMetaClass(pickerField.getMetaClass()); if (Objects.equals(actualMetaClass, propertyMetaClass)) { applyFilter(((Filter) screenComponent)); return true; } return false; } }); if (!found) { Notifications notifications = getScreenContext(pickerField).getNotifications(); notifications.create(NotificationType.WARNING) .withCaption(messages.getMainMessage("dynamicAttributes.entity.filter.filterNotFound")) .show(); } AbstractWindow controller = (AbstractWindow) (lookupWindow).getFrameOwner(); ((DsContextImplementation) controller.getDsContext()).resumeSuspended(); }
new MapScreenOptions(params)); boolean found = ComponentsHelper.walkComponents(screen.getWindow(), screenComponent -> { if (!(screenComponent instanceof Filter)) { return false;
Collections.emptyList() : builder.getSelectedEntities(); boolean found = ComponentsHelper.walkComponents(screen.getWindow(), screenComponent -> { if (!(screenComponent instanceof Filter)) { return false;