/** * @deprecated Simply use {@link Frame#getFrameOwner()} call. */ @Deprecated public static FrameOwner getFrameController(Frame frame) { return frame.getFrameOwner(); }
@Override public Datasource get(String id) { checkNotNullArgument(id, "Null datasource ID"); id = aliasesMap.getOrDefault(id, id); Datasource ds = null; if (!id.contains(".")) { ds = datasourceMap.get(id); if (ds == null && parent != null) { ds = parent.get(id); } } else { if (windowContext != null) { String nestedFramePath = id.substring(0, id.indexOf(".")); Component nestedFrame = getFrameContext().getFrame().getComponent(nestedFramePath); if (nestedFrame instanceof Frame) { String nestedDsId = id.substring(id.indexOf(".") + 1); FrameOwner frameOwner = ((Frame) nestedFrame).getFrameOwner(); if (frameOwner instanceof LegacyFrame) { ds = ((LegacyFrame) frameOwner).getDsContext().get(nestedDsId); } } } } return ds; }
/** * Searches for a component by identifier, down by the hierarchy of frames. * * @param frame frame to start from * @param id component identifier * @return component instance or null if not found */ @Nullable public static Component findComponent(Frame frame, String id) { Component find = frame.getComponent(id); if (find != null) { return find; } else { for (Component c : frame.getComponents()) { if (c instanceof Frame) { Component nestedComponent = findComponent((Frame) c, id); if (nestedComponent != null) { return nestedComponent; } } } } return null; }
public static String getFullFrameId(Frame frame) { if (frame instanceof Window) { return frame.getId(); } List<String> frameIds = new ArrayList<>(4); frameIds.add(frame.getId()); while (frame != null && !(frame instanceof Window) && frame != frame.getFrame()) { frame = frame.getFrame(); if (frame != null) { frameIds.add(frame.getId()); } } return StringUtils.join(new ReverseListIterator<>(frameIds), '.'); }
String[] path = elements; Component component = frame.getComponent(property); while (component == null && path.length > 1) { component = frame.getComponent(ValuePathHelper.format(path)); if (frame.getFrame() != null && frame.getFrame() != frame) return frame.getFrame().getContext().getValue(property); else return null;
@Nullable @Override public Component getComponent(int index) { return frame.getComponent(index); }
Component fragment = frame.getComponent(name); if (fragment == null) { return null; Component component = frame.getComponent(name); if (component instanceof Fragment && ((Fragment) component).getFrameOwner() instanceof LegacyFrame) { return ((LegacyFrame) frame.getFrameOwner()).getDsContext().get(name); if (frame.getFrameOwner() instanceof LegacyFrame) { return ((LegacyFrame) frame.getFrameOwner()).getDsContext(); } else { throw new DevelopmentException("DsContext can be injected only into LegacyFrame inheritors"); if (frame.getFrameOwner() instanceof LegacyFrame) { return ((LegacyFrame) frame.getFrameOwner()).getDsContext().getDataSupplier(); } else { throw new DevelopmentException("DataSupplier can be injected only into LegacyFrame inheritors"); return frame.getContext();
protected void checkGeneratorMethodResultType(Method method, Frame frame) { if (!Component.class.isAssignableFrom(method.getReturnType())) { throw new GuiDevelopmentException(String.format("Method '%s' returns incorrect type", methodName), frame.getId()); } } }
if (dynamicAttributesGuiTools.screenContainsDynamicAttributes(ds.getView(), getFrame().getId())) { ds.setLoadDynamicAttributes(true); UserSessionSource userSessionSource = getBeanLocator().get(UserSessionSource.NAME); getFrame().getWindowManager().showNotification( messages.getMainMessage("entityLocked.msg"), String.format(messages.getMainMessage("entityLocked.desc"), Frame.NotificationType.HUMANIZED ); Action action = getFrame().getAction(WINDOW_COMMIT); if (action != null) action.setEnabled(false); action = getFrame().getAction(WINDOW_COMMIT_AND_CLOSE); if (action != null) action.setEnabled(false);
@Nullable protected Object findInstallTarget(String target, Frame frame) { String[] elements = ValuePathHelper.parse(target); if (elements.length == 1) { Object part = frame.getSubPart(target); if (part != null) { return part; } Component component = frame.getComponent(target); if (component != null) { return component; } } else if (elements.length > 1) { String id = elements[elements.length - 1]; String[] subPath = ArrayUtils.subarray(elements, 0, elements.length - 1); Component component = frame.getComponent(ValuePathHelper.format(subPath)); if (component != null) { if (component instanceof HasSubParts) { Object part = ((HasSubParts) component).getSubPart(id); if (part != null) { return part; } } if (component instanceof ComponentContainer) { return ((ComponentContainer) component).getComponent(id); } } } return null; }
Component component = frame.getComponent(ValuePathHelper.format(subPath)); if (component != null) { if (component instanceof ActionsHolder) { return frame.getAction(id); } else { throw new IllegalArgumentException("Invalid action name: " + actionName);
@Nullable public static Component getFrameComponent(Frame frame, String id) { FrameImplementation frameImpl = (FrameImplementation) frame; String[] elements = ValuePathHelper.parse(id); if (elements.length == 1) { Component component = frameImpl.getRegisteredComponent(id); if (component == null && frame.getFrame() != null && frame.getFrame() != frame) { component = frame.getFrame().getComponent(id); } return component; } else { Component innerComponent = frameImpl.getRegisteredComponent(elements[0]); if (innerComponent instanceof FieldGroup) { List<String> subList = Arrays.asList(elements).subList(1, elements.length); String subPath = ValuePathHelper.format(subList.toArray(new String[0])); FieldGroup fieldGroup = (FieldGroup) innerComponent; FieldGroup.FieldConfig field = fieldGroup.getField(subPath); return field != null ? field.getComponent() : null; } else if (innerComponent instanceof ComponentContainer) { List<String> subList = Arrays.asList(elements).subList(1, elements.length); String subPath = ValuePathHelper.format(subList.toArray(new String[0])); return ((ComponentContainer) innerComponent).getComponent(subPath); } else if (innerComponent instanceof HasNamedComponents) { List<String> subList = Arrays.asList(elements).subList(1, elements.length); String subPath = ValuePathHelper.format(subList.toArray(new String[0])); return ((HasNamedComponents) innerComponent).getComponent(subPath); } return null; } }
@Override public void setVisible(boolean visible) { frame.setVisible(visible); }
@Override public Collection<Component> getComponents() { return frame.getComponents(); }
@Override public void initLookupLayout() { Action selectAction = getAction(LOOKUP_SELECT_ACTION_ID); if (selectAction != null && selectAction.getOwner() == null) { Fragments fragments = UiControllerUtils.getScreenContext(this).getFragments(); ScreenFragment lookupWindowActions = fragments.create(this, "lookupWindowActions"); lookupWindowActions.getFragment().setId("lookupWindowActions"); lookupWindowActions.getFragment().setVisible(false); getFrame().add(lookupWindowActions.getFragment()); lookupWindowActions.init(); } Element element = ((Component.HasXmlDescriptor) getFrame()).getXmlDescriptor(); if (element != null) { String lookupComponent = element.attributeValue("lookupComponent"); if (StringUtils.isNotEmpty(lookupComponent)) { Component component = getFrame().getComponent(lookupComponent); setLookupComponent(component); } } Component lookupComponent = getLookupComponent(); if (lookupComponent instanceof LookupSelectionChangeNotifier) { LookupSelectionChangeNotifier selectionNotifier = (LookupSelectionChangeNotifier) lookupComponent; if (selectAction != null) { //noinspection unchecked selectionNotifier.addLookupValueChangeListener(valueChangeEvent -> selectAction.setEnabled(!selectionNotifier.getLookupSelectedItems().isEmpty())); selectAction.setEnabled(!selectionNotifier.getLookupSelectedItems().isEmpty()); } } }
@Override public void setHeight(String height) { frame.setHeight(height); }
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()); }
@Override public boolean isVisible() { return frame.isVisible(); }
@Nullable @Override public Component getComponent(String id) { return frame.getComponent(id); }
protected Map<String, Object> getLookupScreenParamsInternal() { // we create mutable map only for compatibilty with legacy code Map<String, Object> params = new HashMap<>(); params.put("windowOpener", getFrame().getId()); if (isMultiSelect()) { WindowParams.MULTI_SELECT.set(params, true); // for backward compatibility params.put("multiSelect", "true"); } if (lookupScreenParams != null) { params.putAll(lookupScreenParams); } return params; }