protected Window findWindow(Component frame) { Component parent = frame; while (parent != null) { if (parent instanceof Window) { return (Window) parent; } else { parent = parent.getParent(); } } log.error(messages.getMessage(getClass(), "dashboard.noWindow")); return null; }
@Nonnull @Override public List<LayoutTip> analyze(Component c, String path) { if (c instanceof ComponentContainer) { if (c.getWidth() < 0 && c.getHeight() < 0) { List<LayoutTip> tips = null; ComponentContainer container = (ComponentContainer) c; for (Component component : container.getOwnComponents()) { if (tips == null) { tips = new ArrayList<>(); } if (component.getAlignment() != null && component.getAlignment() != Component.Alignment.TOP_LEFT) { if (component instanceof Label) { // ignore align for labels continue; } String id = component.getId() != null ? component.getId() : component.getClass().getSimpleName(); tips.add(warn("Container '" + path + "', nested component '" + id + "'", "Nested component has align %s inside container with undefined size", component.getAlignment())); } } return tips != null ? tips : Collections.<LayoutTip>emptyList(); } } return Collections.emptyList(); } }
protected void toggleSidePanel() { if (sidePanel != null) { if (sidePanel.getStyleName().contains(HaloTheme.SIDEMENU_PANEL_OPEN)) { sidePanel.removeStyleName(HaloTheme.SIDEMENU_PANEL_OPEN); } else { sidePanel.addStyleName(HaloTheme.SIDEMENU_PANEL_OPEN); } } }
@Override public void add(Component childComponent, int col, int row, int col2, int row2) { if (childComponent.getParent() != null && childComponent.getParent() != this) { throw new IllegalStateException("Component already has parent"); } com.vaadin.ui.Component vComponent = childComponent.unwrapComposition(com.vaadin.ui.Component.class); component.addComponent(vComponent, col, row, col2, row2); component.setComponentAlignment(vComponent, toVaadinAlignment(childComponent.getAlignment())); if (frame != null) { if (childComponent instanceof BelongToFrame && ((BelongToFrame) childComponent).getFrame() == null) { ((BelongToFrame) childComponent).setFrame(frame); } else { ((FrameImplementation) frame).registerComponent(childComponent); } } ownComponents.add(childComponent); childComponent.setParent(this); }
@Override public void add(Component childComponent) { if (childComponent.getParent() != null && childComponent.getParent() != this) { throw new IllegalStateException("Component already has parent"); } final com.vaadin.ui.Component vComponent = WebComponentsHelper.getComposition(childComponent); component.addComponent(vComponent); component.setComponentAlignment(vComponent, WebWrapperUtils.toVaadinAlignment(childComponent.getAlignment())); if (frame != null) { if (childComponent instanceof BelongToFrame && ((BelongToFrame) childComponent).getFrame() == null) { ((BelongToFrame) childComponent).setFrame(frame); } else if (frame instanceof FrameImplementation) { ((FrameImplementation) frame).registerComponent(childComponent); } } ownComponents.add(childComponent); childComponent.setParent(this); }
@Override public void add(Component childComponent) { if (childComponent.getParent() != null && childComponent.getParent() != this) { throw new IllegalStateException("Component already has parent"); } final com.vaadin.ui.Component vComponent = WebComponentsHelper.getComposition(childComponent); if (childComponent.getId() != null) { component.addComponent(vComponent, childComponent.getId()); } else { component.addComponent(vComponent); } if (frame != null) { if (childComponent instanceof BelongToFrame && ((BelongToFrame) childComponent).getFrame() == null) { ((BelongToFrame) childComponent).setFrame(frame); } else { ((FrameImplementation) frame).registerComponent(childComponent); } } ownComponents.add(childComponent); childComponent.setParent(this); }
@Override public void add(Component childComponent) { if (childComponent.getParent() != null && childComponent.getParent() != this) { throw new IllegalStateException("Component already has parent"); } if (component == null) { createComponentImpl(); } com.vaadin.ui.Component vComponent = childComponent.unwrapComposition(com.vaadin.ui.Component.class); component.addComponent(vComponent); if (frame != null) { if (childComponent instanceof BelongToFrame && ((BelongToFrame) childComponent).getFrame() == null) { ((BelongToFrame) childComponent).setFrame(frame); } else { ((FrameImplementation) frame).registerComponent(childComponent); } } ownComponents.add(childComponent); childComponent.setParent(this); }
if (c.getWidth() < 0) { for (Component component : container.getOwnComponents()) { if (component.getWidthSizeUnit() == SizeUnit.PERCENTAGE && component.getWidth() > 0) { if (tips == null) { tips = new ArrayList<>(); String id = component.getId() != null ? component.getId() : component.getClass().getSimpleName(); tips.add(error("Container '" + path + "', nested component '" + id + "'", "Nested component has relative width %s%% inside container with undefined width", component.getWidth())); if (c.getHeight() < 0) { for (Component component : container.getOwnComponents()) { if (component.getHeightSizeUnit() == SizeUnit.PERCENTAGE && component.getHeight() > 0) { if (tips == null) { tips = new ArrayList<>(); String id = component.getId() != null ? component.getId() : component.getClass().getSimpleName(); tips.add(error("Container '" + path + "', nested component '" + id + "'", "Nested component has relative height %s%% inside container with undefined height", component.getHeight()));
@Override protected void postValidate(ValidationErrors errors) { super.postValidate(errors); //remove errors from widget frames errors.getAll().removeIf(error -> !"dashboard$dashboardEditFieldGroup1".equals(error.component.getParent().getId())); List<Widget> dashboardWidgets = dashboardDs.getItem().getWidgets(); Map<String, Long> widgetsCount = dashboardWidgets.stream() .collect(Collectors.groupingBy(Widget::getWidgetId, Collectors.counting())); List<String> nonUniqueIds = widgetsCount.entrySet().stream() .filter(es -> es.getValue() > 1) .map(Map.Entry::getKey) .collect(toList()); if (nonUniqueIds.size() > 0) { errors.add(null, formatMessage("uniqueWidgetId", String.join(",", nonUniqueIds))); } }
if (component.isVisible() && component.isEnabled()) { if (component.getParent() instanceof SupportsChildrenSelection) { reachable = ((SupportsChildrenSelection) component.getParent()).isChildSelected(component); } else if (component.getParent() instanceof Collapsable) { reachable = ((Collapsable) component.getParent()).isExpanded();
@Override public void removeAll() { getContainer().removeAllComponents(); for (Component childComponent : ownComponents) { if (childComponent.getId() != null) { allComponents.remove(childComponent.getId()); } } Component[] childComponents = ownComponents.toArray(new Component[0]); ownComponents.clear(); for (Component ownComponent : childComponents) { ownComponent.setParent(null); } }
@Override public void add(Component childComponent, int index) { if (childComponent.getParent() != null && childComponent.getParent() != this) { throw new IllegalStateException("Component already has parent"); } if (ownComponents.contains(childComponent)) { int existingIndex = component.getComponentIndex(WebComponentsHelper.getComposition(childComponent)); if (index > existingIndex) { index--; } remove(childComponent); } com.vaadin.ui.Component vComponent = WebComponentsHelper.getComposition(childComponent); component.addComponent(vComponent, index); if (frame != null) { if (childComponent instanceof BelongToFrame && ((BelongToFrame) childComponent).getFrame() == null) { ((BelongToFrame) childComponent).setFrame(frame); } else { ((FrameImplementation) frame).registerComponent(childComponent); } } if (index == ownComponents.size()) { ownComponents.add(childComponent); } else { ownComponents.add(index, childComponent); } childComponent.setParent(this); }
@Nonnull @Override public List<LayoutTip> analyze(Component c, String path) { if (c instanceof Window && c.getHeight() < 0) { List<LayoutTip> tips = null; ComponentContainer container = (ComponentContainer) c; for (Component component : container.getOwnComponents()) { if (tips == null) { tips = new ArrayList<>(); } if (component.getHeightSizeUnit() == SizeUnit.PERCENTAGE && component.getHeight() > 0) { String id = component.getId() != null ? component.getId() : component.getClass().getSimpleName(); tips.add(warn("Nested component '" + id + "'", "Nested component has relative height %s%% inside window with undefined height", component.getHeight())); } } return tips != null ? tips : Collections.<LayoutTip>emptyList(); } return Collections.emptyList(); } }
@Nonnull @Override public List<LayoutTip> analyze(Component c, String path) { if (c instanceof Window && c.getWidth() < 0) { List<LayoutTip> tips = null; ComponentContainer container = (ComponentContainer) c; for (Component component : container.getOwnComponents()) { if (tips == null) { tips = new ArrayList<>(); } if (component.getWidthSizeUnit() == SizeUnit.PERCENTAGE && component.getWidth() > 0) { String id = component.getId() != null ? component.getId() : component.getClass().getSimpleName(); tips.add(warn("Nested component '" + id + "'", "Nested component has relative width %s%% inside window with undefined width", component.getWidth())); } } return tips != null ? tips : Collections.<LayoutTip>emptyList(); } return Collections.emptyList(); } }
@Nonnull @Override public List<LayoutTip> analyze(Component component, String path) { if (component instanceof ExpandingLayout) { ExpandingLayout container = (ExpandingLayout) component; List<LayoutTip> tips = null; Collection<Component> components = container.getOwnComponents(); Component expanded = getExpandedComponent(container); if (components.size() > 1 && expanded != null) { tips = new ArrayList<>(); String expandedId = expanded.getId() != null ? expanded.getId() : expanded.getClass().getSimpleName(); for (Component innerComponent : components) { if (innerComponent != expanded && innerComponent.isVisibleRecursive() && isSizeIgnored(container, innerComponent)) { String id = innerComponent.getId() != null ? innerComponent.getId() : innerComponent.getClass().getSimpleName(); tips.add(warn("Container '" + path + "', nested component '" + id + "'", "Relative size of nested component was ignored because of '%s' expanded inside container", expandedId)); } } } return tips != null ? tips : Collections.<LayoutTip>emptyList(); } return Collections.emptyList(); }
@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); }
@Override public void setWidth(String width) { if (component != null) { component.setWidth(width); } else { targetWidth = width; } }