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()); } } }
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), '.'); }
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; }
public static String getFilterComponentPath(Filter filter) { StringBuilder sb = new StringBuilder(filter.getId() != null ? filter.getId() : "filterWithoutId"); Frame frame = filter.getFrame(); while (frame != null) { sb.insert(0, "."); String s = frame.getId() != null ? frame.getId() : "frameWithoutId"; if (s.contains(".")) { s = "[" + s + "]"; } sb.insert(0, s); if (frame instanceof Window) { break; } frame = frame.getFrame(); } return sb.toString(); }
@Override public void setFrame(Frame frame) { super.setFrame(frame); ComponentContainer layout = delegate.getLayout(); if (layout instanceof BelongToFrame) { ((BelongToFrame) layout).setFrame(frame); } if (frame != null && frame.getId() == null) { LoggerFactory.getLogger(WebFilter.class).warn("Filter is embedded in a frame without ID"); } }
public static String getComponentPath(Component c) { StringBuilder sb = new StringBuilder(c.getId() == null ? "" : c.getId()); if (c instanceof Component.BelongToFrame) { Frame frame = ((Component.BelongToFrame) c).getFrame(); while (frame != null) { sb.insert(0, "."); String s = frame.getId(); if (s.contains(".")) { s = "[" + s + "]"; } sb.insert(0, s); if (frame instanceof Window) { break; } frame = frame.getFrame(); } } return sb.toString(); }
/** * Apply UI permissions to a frame. * * @param container frame */ public void applyUiPermissions(Frame container) { Window window = container instanceof Window ? (Window) container : ComponentsHelper.getWindow(container); if (window == null) { log.warn(String.format("Unable to find window for container %s with id '%s'", container.getClass(), container.getId())); return; } UserSession userSession = sessionSource.getUserSession(); String screenId = window.getId(); Map<String, Integer> uiPermissions = userSession.getPermissionsByType(PermissionType.UI); for (Map.Entry<String, Integer> permissionEntry : uiPermissions.entrySet()) { String target = permissionEntry.getKey(); String targetComponentId = getTargetComponentId(target, screenId); if (targetComponentId != null) { if (targetComponentId.contains("[")) { applyCompositeComponentPermission(window, screenId, permissionEntry.getValue(), targetComponentId); } else if (targetComponentId.contains(">")) { applyComponentActionPermission(window, screenId, permissionEntry.getValue(), targetComponentId); } else { applyComponentPermission(window, screenId, permissionEntry.getValue(), targetComponentId); } } } }
@Override public void setExpandRatio(Component component, float ratio) { if (ratio < 0) { throw new GuiDevelopmentException( String.format("Expand ratio must be greater than or equal to 0 in component: %s.", component.getId()), getFrame().getId()); } com.vaadin.ui.Component vComponent = component.unwrapComposition(com.vaadin.ui.Component.class); this.component.setExpandRatio(vComponent, ratio); }
protected Datasource getDatasourceInternal() { Datasource ds = null; Element element = ((Component.HasXmlDescriptor) getFrame()).getXmlDescriptor(); String datasourceName = element.attributeValue("datasource"); if (!StringUtils.isEmpty(datasourceName)) { DsContext context = getDsContext(); if (context != null) { ds = context.get(datasourceName); } } if (ds == null) { throw new GuiDevelopmentException("Can't find main datasource", getFrame().getId()); } return ds; }
} else { throw new DevelopmentException( String.format("Unable to determine @Install subject of %s in %s", provideMethod, frame.getId()) );
throw new DevelopmentException( String.format("Screen %s cannot use @Install with target = PARENT_CONTROLLER", frame.getId()) );
protected Resource createImageResource(final Object resourceObject) { if (resourceObject == null) { return null; } if (resourceObject instanceof FileDescriptor) { FileDescriptorResource imageResource = createResource(FileDescriptorResource.class); imageResource.setFileDescriptor((FileDescriptor) resourceObject); return imageResource; } if (resourceObject instanceof byte[]) { StreamResource imageResource = createResource(StreamResource.class); Supplier<InputStream> streamSupplier = () -> new ByteArrayDataProvider((byte[]) resourceObject).provide(); imageResource.setStreamSupplier(streamSupplier); return imageResource; } throw new GuiDevelopmentException( "The Image component supports only FileDescriptor and byte[] datasource property value binding", getFrame().getId()); }
if (dynamicAttributesGuiTools.screenContainsDynamicAttributes(ds.getView(), getFrame().getId())) { ds.setLoadDynamicAttributes(true);