@Override public void setHeight(String height) { getRootOrThrow().setHeight(height); }
@Override public void setHeight(float height, Unit unit) { super.setHeight(height, unit); if (getContent() != null) { if (height < 0) { getContent().setHeightUndefined(); } else { getContent().setHeight(100, Unit.PERCENTAGE); } } } }
@Override public void setHeight(float height, Unit unit) { getRootOrThrow().setHeight(height, unit); }
/** * Update root component size when component size changes */ protected void updateRootSize() { if (getCompositionRoot() != null) { if (getWidth() > -1) { getCompositionRoot().setWidth(100, Unit.PERCENTAGE); } else { getCompositionRoot().setWidthUndefined(); } if (getHeight() > -1) { getCompositionRoot().setHeight(100, Unit.PERCENTAGE); } else { getCompositionRoot().setHeightUndefined(); } } }
/** * Adds the given components to this layout and sets them as expanded. The * height of all added child components are set to 100% so that the * expansion will be effective. The height of this layout is also set to * 100% if it is currently undefined. * <p> * The components are added in the provided order to the end of this layout. * Any components that are already children of this layout will be moved to * new positions. * * @param components * the components to set, not <code>null</code> * @since 8.0 */ public void addComponentsAndExpand(Component... components) { addComponents(components); if (getHeight() < 0) { setHeight(100, Unit.PERCENTAGE); } for (Component child : components) { child.setHeight(100, Unit.PERCENTAGE); setExpandRatio(child, 1); } } }
/** * Update root component size when component size changes */ protected void updateRootSize() { if (getCompositionRoot() != null) { if (getWidth() > -1) { getCompositionRoot().setWidth(100, Unit.PERCENTAGE); } else { getCompositionRoot().setWidthUndefined(); } if (getHeight() > -1) { getCompositionRoot().setHeight(100, Unit.PERCENTAGE); } else { getCompositionRoot().setHeightUndefined(); } } }
@Override public void setHeight(String height) { // do not try to parse string if constant passed if (Component.AUTO_SIZE.equals(height)) { getComposition().setHeight(-1, Sizeable.Unit.PIXELS); } else if (Component.FULL_SIZE.equals(height)) { getComposition().setHeight(100, Sizeable.Unit.PERCENTAGE); } else { getComposition().setHeight(height); } }
public static void expand(AbstractOrderedLayout layout, Component component, String height, String width) { if (!isHorizontalLayout(layout) && (StringUtils.isEmpty(height) || AUTO_SIZE.equals(height) || height.endsWith("%"))) { component.setHeight(100, Sizeable.Unit.PERCENTAGE); } if (!isVerticalLayout(layout) && (StringUtils.isEmpty(width) || AUTO_SIZE.equals(width) || width.endsWith("%"))) { component.setWidth(100, Sizeable.Unit.PERCENTAGE); } layout.setExpandRatio(component, 1); }
@Override public void addComponent(Component c) { super.addComponent(c); c.setHeight(rowHeight, Sizeable.UNITS_PIXELS); updateHeight(); }
@Override public void setHeight(float height, Unit unit) { super.setHeight(height, unit); if (height > -1 && getCompositionRoot() != null) { getCompositionRoot().setHeight(100, Unit.PERCENTAGE); } }
@Override public void setHeight(float height, Unit unit) { super.setHeight(height, unit); if (height > -1 && getCompositionRoot() != null) { getCompositionRoot().setHeight(100, Unit.PERCENTAGE); } }
@Override protected Component initContent() { final Component content = getInternalField(); if (getWidth() > -1) { content.setWidth(100, Unit.PERCENTAGE); } if (getHeight() > -1) { content.setHeight(100, Unit.PERCENTAGE); } return content; }
protected void setupSearchFoldersPane(Component searchFoldersPane) { searchFoldersPane.setHeight(100, Unit.PERCENTAGE); searchFoldersPane.setWidth(100, Unit.PERCENTAGE); if (isNeedFoldersTitle()) { searchFoldersLabel = new Label(messages.getMainMessage("folders.searchFoldersRoot")); searchFoldersLabel.setStyleName("c-folders-pane-caption"); } else { searchFoldersLabel = null; } }
protected void setupAppFoldersPane(Component appFoldersPane) { appFoldersPane.setHeight("100%"); appFoldersPane.setWidth("100%"); if (isNeedFoldersTitle()) { appFoldersLabel = new Label(messages.getMainMessage("folders.appFoldersRoot")); appFoldersLabel.setStyleName("c-folders-pane-caption"); } else { appFoldersLabel = null; } }
/** * Sets an icon to the message dialog. * * @param icon An embedded resource * @param width The width i.e. "48px" * @param height The height i.e. "48px" * @return The {@link MessageBox} instance itself */ public MessageBox withIcon(Component icon, String width, String height) { if (this.icon != null) { contentLayout.removeComponent(this.icon); } this.icon = icon; if (icon != null) { contentLayout.addComponent(icon, 0); contentLayout.setComponentAlignment(icon, Alignment.MIDDLE_CENTER); icon.setWidth(width); icon.setHeight(height); } return this; }
/** * Expands selected components. Also adds to layout and sets the only sane * height for expanded components (100%) if needed. * * @param componentsToExpand components that should be expanded * @return the object itself for further configuration */ public MVerticalLayout expand(Component... componentsToExpand) { if (getHeight() < 0) { // Make full height if no other size is set withFullHeight(); } for (Component component : componentsToExpand) { if (component.getParent() != this) { addComponent(component); } setExpandRatio(component, 1); component.setHeight(100, Unit.PERCENTAGE); } return this; }
@Override public void toggle(int initialWidth, int initialHeight) { getState().isCollapsed = !getState().isCollapsed; final Component parent = (Component) getParent(); if (getState().isCollapsed) { // Restore size info from the state. parent.setWidth(getState().collapsedStateWidth); parent.setHeight(getState().collapsedStateHeight); } else { // We save the initial dimensions and clear size info from the state. getState().collapsedStateHeight = parent.getHeight() + parent.getHeightUnits().toString(); getState().collapsedStateWidth = parent.getWidth() + parent.getWidthUnits().toString(); parent.setWidth(""); parent.setHeight(""); } } });
protected void loadPicture() { Component pictureComponent = null; final Picture userPicture = identityService.getUserPicture(user.getId()); if (userPicture != null) { StreamResource imageresource = new StreamResource(new StreamSource() { private static final long serialVersionUID = 1L; public InputStream getStream() { return userPicture.getInputStream(); } }, user.getId() + "." + Constants.MIMETYPE_EXTENSION_MAPPING.get(userPicture.getMimeType()), ExplorerApp.get()); pictureComponent = new Embedded(null, imageresource); } else { pictureComponent = new Label(""); } pictureComponent.setHeight("200px"); pictureComponent.setWidth("200px"); pictureComponent.addStyleName(ExplorerLayout.STYLE_PROFILE_PICTURE); userDetailsLayout.addComponent(pictureComponent); userDetailsLayout.setComponentAlignment(pictureComponent, Alignment.MIDDLE_CENTER); }
public void addChart(String description, Component chart, String errorMessage) { addComponent(new Label(" ", Label.CONTENT_XHTML)); addComponent(new Label(" ", Label.CONTENT_XHTML)); // Description if (description != null) { Label label = new Label(description); label.addStyleName(Reindeer.LABEL_H2); addComponent(label); addComponent(new Label(" ", Label.CONTENT_XHTML)); } // Chart if (chart != null) { if (chart instanceof DCharts) { // DCharts doesn't know how to size itself chart.setWidth(600, UNITS_PIXELS); chart.setHeight(450, UNITS_PIXELS); ((DCharts) chart).show(); } addComponent(chart); } // Error message if (errorMessage != null) { Label errorLabel = new Label(errorMessage); addComponent(errorLabel); } }