public static boolean hasFullHeight(Component c) { return (int) c.getHeight() == 100 && c.getHeightSizeUnit() == SizeUnit.PERCENTAGE; }
@Nonnull @Override public List<LayoutTip> analyze(Component c, String path) { if (c instanceof Table || c instanceof Tree || c instanceof ScrollBoxLayout) { String componentClass = c.getClass().getSimpleName(); if (c.getWidth() < 0 && c.getHeight() < 0) { return Collections.singletonList(warn("Component '" + path + "'", componentClass + " should not have undefined size")); } else if (c.getWidth() < 0) { return Collections.singletonList(warn("Component '" + path + "'", componentClass + " should not have undefined width")); } else if (c.getHeight() < 0) { return Collections.singletonList(warn("Component '" + path + "'", componentClass + " should not have undefined height")); } } return Collections.emptyList(); } }
public static String getComponentHeight(Component c) { float height = c.getHeight(); SizeUnit heightUnit = c.getHeightSizeUnit(); return height + heightUnit.getSymbol(); }
@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(); } }
@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(); } }
private boolean isSizeIgnored(ExpandingLayout container, Component component) { return container.getExpandDirection() == ExpandDirection.HORIZONTAL && component.getWidthSizeUnit() == SizeUnit.PERCENTAGE && component.getWidth() > 0 || container.getExpandDirection() == ExpandDirection.VERTICAL && component.getHeightSizeUnit() == SizeUnit.PERCENTAGE && component.getHeight() > 0; } }
if (c.getHeight() < 0) { for (Component component : container.getOwnComponents()) { if (component.getHeightSizeUnit() == SizeUnit.PERCENTAGE && component.getHeight() > 0) { if (tips == null) { tips = new ArrayList<>(); tips.add(error("Container '" + path + "', nested component '" + id + "'", "Nested component has relative height %s%% inside container with undefined height", component.getHeight()));
if (component.getHeight() > 0 && component.getHeightSizeUnit() == SizeUnit.PERCENTAGE) { if (tips == null) { tips = new ArrayList<>(); tips.add(error("Scrollbox '" + path + "', nested component '" + id + "'", "ScrollBox has VERTICAL orientation, nested component should not have relative height %s%%", component.getHeight()));