/** * @deprecated Simply use {@link Frame#getFrameOwner()} call. */ @Deprecated public static FrameOwner getFrameController(Frame frame) { return frame.getFrameOwner(); }
protected boolean isLegacyFrame() { return context.getFrame().getFrameOwner() instanceof LegacyFrame; }
protected void callControllerInvoke(Entity rowItem, String columnId, String invokeMethodName) { FrameOwner controller = table.getFrame().getFrameOwner(); Method method; method = findLinkInvokeMethod(controller.getClass(), invokeMethodName); if (method != null) { try { method.invoke(controller, rowItem, columnId); } catch (Exception e) { throw new RuntimeException("Unable to cal linkInvoke method for table column", e); } } else { try { method = controller.getClass().getMethod(invokeMethodName); try { method.invoke(controller); } catch (Exception e1) { throw new RuntimeException("Unable to call linkInvoke method for table column", e1); } } catch (NoSuchMethodException e1) { throw new IllegalStateException(String.format("No suitable methods named %s for invoke", invokeMethodName)); } } }
@Nullable protected CollectionContainer findOptionsContainer(Table.Column columnConf) { String optDcName = columnConf.getXmlDescriptor() != null ? columnConf.getXmlDescriptor().attributeValue("optionsContainer") : null; if (Strings.isNullOrEmpty(optDcName)) { return null; } else { ScreenData screenData = UiControllerUtils.getScreenData(webTable.getFrame().getFrameOwner()); InstanceContainer container = screenData.getContainer(optDcName); if (container instanceof CollectionContainer) { return (CollectionContainer) container; } throw new IllegalStateException( String.format("'%s' is not an instance of CollectionContainer", optDcName)); } }
@Override public Map<String, Object> getParams() { ScreenContext screenContext = UiControllerUtils.getScreenContext(frame.getFrameOwner()); if (screenContext.getScreenOptions() instanceof MapScreenOptions) { return ((MapScreenOptions) screenContext.getScreenOptions()).getParams(); } return Collections.emptyMap(); }
protected void loadDataContainer(Form resultComponent, Element element) { String containerId = element.attributeValue("dataContainer"); if (!Strings.isNullOrEmpty(containerId)) { FrameOwner frameOwner = context.getFrame().getFrameOwner(); ScreenData screenData = UiControllerUtils.getScreenData(frameOwner); InstanceContainer container = screenData.getContainer(containerId); //noinspection unchecked resultComponent.setValueSourceProvider(new ContainerValueSourceProvider(container)); } }
protected String getWindowId(Context context) { Frame frame = context.getFrame(); Screen screen = UiControllerUtils.getScreen(frame.getFrameOwner()); return screen.getId(); }
protected MessageBundle createMessageBundle(@SuppressWarnings("unused") AnnotatedElement element, Frame frame) { MessageBundle messageBundle = beanLocator.getPrototype(MessageBundle.NAME); Class<? extends FrameOwner> screenClass = frame.getFrameOwner().getClass(); String packageName = UiControllerUtils.getPackage(screenClass); messageBundle.setMessagesPack(packageName); if (frame instanceof Component.HasXmlDescriptor) { Element xmlDescriptor = ((Component.HasXmlDescriptor) frame).getXmlDescriptor(); if (xmlDescriptor != null) { String messagePack = xmlDescriptor.attributeValue("messagesPack"); if (messagePack != null) { messageBundle.setMessagesPack(messagePack); } } } return messageBundle; }
@Override public void accept(SideMenu.MenuItem menuItem) { SideMenu menu = menuItem.getMenu(); FrameOwner frameOwner = menu.getFrame().getFrameOwner(); MenuItemCommand command = menuItemCommands.create(frameOwner, item); command.run(); } }
@Override public void accept(AppMenu.MenuItem menuItem) { AppMenu menu = menuItem.getMenu(); FrameOwner frameOwner = menu.getFrame().getFrameOwner(); MenuItemCommand command = menuItemCommands.create(frameOwner, item); command.run(); } }
protected void loadDataContainer(Calendar component, Element element) { String containerId = element.attributeValue("dataContainer"); FrameOwner frameOwner = context.getFrame().getFrameOwner(); ScreenData screenData = UiControllerUtils.getScreenData(frameOwner); InstanceContainer container = screenData.getContainer(containerId); if (!(container instanceof CollectionContainer)) { throw new GuiDevelopmentException("Not a CollectionContainer: " + containerId, context.getCurrentFrameId()); } component.setEventProvider(new ContainerCalendarEventProvider<>(((CollectionContainer) container))); }
protected void loadDataContainer(PivotTable pivotTable, Element element) { String dataContainerId = element.attributeValue("dataContainer"); if (StringUtils.isNotEmpty(dataContainerId)) { FrameOwner frameOwner = context.getFrame().getFrameOwner(); ScreenData screenData = UiControllerUtils.getScreenData(frameOwner); CollectionContainer dataContainer; InstanceContainer container = screenData.getContainer(dataContainerId); if (container instanceof CollectionContainer) { dataContainer = (CollectionContainer) container; } else { throw new GuiDevelopmentException("Not a CollectionContainer: " + dataContainerId, context.getCurrentFrameId()); } pivotTable.setDataProvider(new ContainerDataProvider(dataContainer)); } else { loadDatasource(pivotTable, element); } }
protected void loadOptionsContainer(TwinColumn component, Element element) { String containerId = element.attributeValue("optionsContainer"); if (containerId != null) { FrameOwner frameOwner = context.getFrame().getFrameOwner(); ScreenData screenData = UiControllerUtils.getScreenData(frameOwner); InstanceContainer container = screenData.getContainer(containerId); if (!(container instanceof CollectionContainer)) { throw new GuiDevelopmentException("Not a CollectionContainer: " + containerId, context.getCurrentFrameId()); } //noinspection unchecked component.setOptions(new ContainerOptions((CollectionContainer) container)); } } }
protected void loadDataContainer(Chart chart, Element element) { String dataContainerId = element.attributeValue("dataContainer"); if (StringUtils.isNotEmpty(dataContainerId)) { FrameOwner frameOwner = context.getFrame().getFrameOwner(); ScreenData screenData = UiControllerUtils.getScreenData(frameOwner); CollectionContainer dataContainer; InstanceContainer container = screenData.getContainer(dataContainerId); if (container instanceof CollectionContainer) { dataContainer = (CollectionContainer) container; } else { throw new GuiDevelopmentException("Not a CollectionContainer: " + dataContainerId, context.getCurrentFrameId()); } chart.setDataProvider(new ContainerDataProvider(dataContainer)); } else { loadDatasource(resultComponent, element); } }
protected void loadOptionsContainer(TokenList component, Element element) { String containerId = element.attributeValue("optionsContainer"); if (containerId != null) { FrameOwner frameOwner = context.getFrame().getFrameOwner(); ScreenData screenData = UiControllerUtils.getScreenData(frameOwner); InstanceContainer container = screenData.getContainer(containerId); if (!(container instanceof CollectionContainer)) { throw new GuiDevelopmentException("Not a CollectionContainer: " + containerId, context.getCurrentFrameId()); } //noinspection unchecked component.setOptions(new ContainerOptions((CollectionContainer) container)); } } }
/** * Creates a remove builder using list component, e.g. {@link Table} or {@link DataGrid}. * * @param listComponent list component * @param <E> type of entity */ public <E extends Entity> RemoveBuilder<E> builder(ListComponent<E> listComponent) { checkNotNullArgument(listComponent); checkNotNullArgument(listComponent.getFrame()); FrameOwner frameOwner = listComponent.getFrame().getFrameOwner(); Class<E> entityClass; DataUnit items = listComponent.getItems(); if (items instanceof ContainerDataUnit) { entityClass = ((ContainerDataUnit) items).getEntityMetaClass().getJavaClass(); } else { throw new IllegalStateException(String.format("Component %s is not bound to data", listComponent)); } return builder(entityClass, frameOwner) .withListComponent(listComponent); }
protected void showParseErrorNotification(String message) { ScreenContext screenContext = UiControllerUtils.getScreenContext(getFrame().getFrameOwner()); screenContext.getNotifications().create(Notifications.NotificationType.TRAY) .withDescription(message) .show(); } }
@SuppressWarnings("unchecked") @Override protected void loadContainer(LookupField component, Element element) { super.loadContainer(component, element); String containerId = element.attributeValue("optionsContainer"); if (containerId != null) { FrameOwner frameOwner = context.getFrame().getFrameOwner(); ScreenData screenData = UiControllerUtils.getScreenData(frameOwner); InstanceContainer container = screenData.getContainer(containerId); if (!(container instanceof CollectionContainer)) { throw new GuiDevelopmentException("Not a CollectionContainer: " + containerId, context.getCurrentFrameId()); } component.setOptions(new ContainerOptions((CollectionContainer) container)); } }
@SuppressWarnings("unchecked") @Override protected void loadContainer(T component, Element element) { super.loadContainer(component, element); String containerId = element.attributeValue("optionsContainer"); if (containerId != null) { FrameOwner frameOwner = context.getFrame().getFrameOwner(); ScreenData screenData = UiControllerUtils.getScreenData(frameOwner); InstanceContainer container = screenData.getContainer(containerId); if (!(container instanceof CollectionContainer)) { throw new GuiDevelopmentException("Not a CollectionContainer: " + containerId, context.getCurrentFrameId()); } component.setOptions(new ContainerOptions((CollectionContainer) container)); } } }
protected AbstractCondition createCondition(ConditionType type, Element element, Filter filter, String xml) { String filterComponentName = filter.getId(); Class<? extends FrameOwner> controllerClass = filter.getFrame().getFrameOwner().getClass(); String messagesPack = UiControllerUtils.getPackage(controllerClass); // todo rework switch (type) { case GROUP: return new GroupCondition(element, filterComponentName); case PROPERTY: return new PropertyCondition(element, messagesPack, filterComponentName, ((FilterImplementation) filter).getEntityMetaClass()); case CUSTOM: return new CustomCondition(element, messagesPack, filterComponentName, ((FilterImplementation) filter).getEntityMetaClass()); case RUNTIME_PROPERTY: return new DynamicAttributesCondition(element, messagesPack, filterComponentName, ((FilterImplementation) filter).getEntityMetaClass()); case FTS: return new FtsCondition(element, messagesPack, filterComponentName, ((FilterImplementation) filter).getEntityMetaClass()); default: throw new IllegalStateException(String.format("Unknown condition type: %s in %s", type, xml)); } }