List of usage examples for com.vaadin.ui AbstractOrderedLayout setSpacing
@Override public void setSpacing(boolean spacing)
From source file:com.expressui.core.view.form.TypedForm.java
License:Open Source License
/** * Makes the component collapsible by wrapping it with a layout and button for toggling * the component's visibility. This allows the user to expand/collapse the given component in order * to free space for viewing other components. * * @param component component to show/hide * @param useVerticalLayout true if toggle button should be laid out vertically next to animated component * @return the newly created layout that contains the toggle button and animated component */// ww w. j a v a 2 s . c om protected Component makeCollapsible(String caption, Component component, boolean useVerticalLayout) { formAnimator = new Animator(component); formAnimator.setSizeUndefined(); AbstractOrderedLayout animatorLayout; if (useVerticalLayout) { animatorLayout = new VerticalLayout(); } else { animatorLayout = new HorizontalLayout(); } setDebugId(animatorLayout, "animatorLayout"); animatorLayout.setMargin(false, false, false, false); animatorLayout.setSpacing(false); toggleFormCollapseButton = new Button(null, new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { setFormVisible(!isFormVisible()); } }); toggleFormCollapseButton.setDescription(uiMessageSource.getToolTip("typedForm.toggleSearchForm.toolTip")); toggleFormCollapseButton.setIcon(new ThemeResource("../expressui/icons/collapse-icon.png")); toggleFormCollapseButton.addStyleName("borderless"); if (useVerticalLayout) { HorizontalLayout toggleFormButtonAndCaption = new HorizontalLayout(); setDebugId(toggleFormButtonAndCaption, "toggleFormButtonAndCaption"); toggleFormButtonAndCaption.setSizeUndefined(); toggleFormButtonAndCaption.addComponent(toggleFormCollapseButton); Label label = new Label(caption); label.setSizeUndefined(); toggleFormButtonAndCaption.addComponent(label); animatorLayout.addComponent(toggleFormButtonAndCaption); animatorLayout.addComponent(formAnimator); } else { animatorLayout.addComponent(toggleFormCollapseButton); animatorLayout.addComponent(formAnimator); } return animatorLayout; }
From source file:com.haulmont.cuba.web.gui.components.WebGroupBox.java
License:Apache License
@Override public void add(Component childComponent, int index) { if (childComponent.getParent() != null && childComponent.getParent() != this) { throw new IllegalStateException("Component already has parent"); }/* ww w. ja v a2 s. c om*/ AbstractOrderedLayout newContent = null; if (orientation == Orientation.VERTICAL && !(component.getContent() instanceof CubaVerticalActionsLayout)) { newContent = new CubaVerticalActionsLayout(); } else if (orientation == Orientation.HORIZONTAL && !(component.getContent() instanceof CubaHorizontalActionsLayout)) { newContent = new CubaHorizontalActionsLayout(); } if (newContent != null) { newContent.setStyleName("c-groupbox-inner"); component.setContent(newContent); CubaOrderedActionsLayout currentContent = (CubaOrderedActionsLayout) component.getContent(); newContent.setMargin(currentContent.getMargin()); newContent.setSpacing(currentContent.isSpacing()); } if (ownComponents.contains(childComponent)) { int existingIndex = getComponentContent() .getComponentIndex(WebComponentsHelper.getComposition(childComponent)); if (index > existingIndex) { index--; } remove(childComponent); } com.vaadin.ui.Component vComponent = WebComponentsHelper.getComposition(childComponent); getComponentContent().addComponent(vComponent, index); getComponentContent().setComponentAlignment(vComponent, WebWrapperUtils.toVaadinAlignment(childComponent.getAlignment())); if (frame != null) { if (childComponent instanceof BelongToFrame && ((BelongToFrame) childComponent).getFrame() == null) { ((BelongToFrame) childComponent).setFrame(frame); } else { frame.registerComponent(childComponent); } } if (index == ownComponents.size()) { ownComponents.add(childComponent); } else { ownComponents.add(index, childComponent); } childComponent.setParent(this); }
From source file:com.haulmont.cuba.web.gui.components.WebScrollBoxLayout.java
License:Apache License
@Override public void add(Component childComponent, int index) { if (childComponent.getParent() != null && childComponent.getParent() != this) { throw new IllegalStateException("Component already has parent"); }//from w w w. j a va 2s .c o m AbstractOrderedLayout newContent = null; if (orientation == Orientation.VERTICAL && !(getContent() instanceof CubaVerticalActionsLayout)) { newContent = new CubaVerticalActionsLayout(); newContent.setWidth("100%"); } else if (orientation == Orientation.HORIZONTAL && !(getContent() instanceof CubaHorizontalActionsLayout)) { newContent = new CubaHorizontalActionsLayout(); } if (newContent != null) { newContent.setMargin((getContent()).getMargin()); newContent.setSpacing((getContent()).isSpacing()); newContent.setStyleName(SCROLLBOX_CONTENT_STYLENAME); com.vaadin.ui.Component oldContent = component.getComponent(0); newContent.setWidth(oldContent.getWidth(), oldContent.getWidthUnits()); newContent.setHeight(oldContent.getHeight(), oldContent.getHeightUnits()); component.removeAllComponents(); component.addComponent(newContent); applyScrollBarsPolicy(scrollBarPolicy); } if (ownComponents.contains(childComponent)) { int existingIndex = getContent().getComponentIndex(WebComponentsHelper.getComposition(childComponent)); if (index > existingIndex) { index--; } remove(childComponent); } com.vaadin.ui.Component vComponent = WebComponentsHelper.getComposition(childComponent); getContent().addComponent(vComponent, index); getContent().setComponentAlignment(vComponent, WebWrapperUtils.toVaadinAlignment(childComponent.getAlignment())); if (frame != null) { if (childComponent instanceof BelongToFrame && ((BelongToFrame) childComponent).getFrame() == null) { ((BelongToFrame) childComponent).setFrame(frame); } else { frame.registerComponent(childComponent); } } if (index == ownComponents.size()) { ownComponents.add(childComponent); } else { ownComponents.add(index, childComponent); } childComponent.setParent(this); }
From source file:com.purebred.core.view.FormComponent.java
License:Open Source License
/** * Animate the component by visually wrapping it with a layout and button for toggling * the component's visibility. This allows the user to expand/collapse the given component in order * to free space for viewing other components. * * @param component component to show/hide * @param useVerticalLayout true if toggle button should be laid out vertically next to animated component * * @return the newly created layout that contains the toggle button and animated component *///from ww w.j a v a 2s .c o m protected Component animate(Component component, boolean useVerticalLayout) { final Animator formAnimator = new Animator(component); formAnimator.setSizeUndefined(); AbstractOrderedLayout animatorLayout; if (useVerticalLayout) { animatorLayout = new VerticalLayout(); } else { animatorLayout = new HorizontalLayout(); } animatorLayout.setMargin(false, false, false, false); animatorLayout.setSpacing(false); toggleFormVisibilityButton = new Button(null, new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { formAnimator.setRolledUp(!formAnimator.isRolledUp()); if (formAnimator.isRolledUp()) { event.getButton().setIcon(new ThemeResource("../pureCrudTheme/icons/expand-icon.png")); } else { event.getButton().setIcon(new ThemeResource("../pureCrudTheme/icons/collapse-icon.png")); } } }); toggleFormVisibilityButton .setDescription(uiMessageSource.getMessage("entryPoint.toggleSearchForm.description")); toggleFormVisibilityButton.setIcon(new ThemeResource("../pureCrudTheme/icons/collapse-icon.png")); toggleFormVisibilityButton.addStyleName("borderless"); if (useVerticalLayout) { HorizontalLayout toggleFormButtonAndCaption = new HorizontalLayout(); toggleFormButtonAndCaption.setSizeUndefined(); toggleFormButtonAndCaption.addComponent(toggleFormVisibilityButton); toggleFormButtonAndCaption.addComponent(new Label(getEntityCaption())); animatorLayout.addComponent(toggleFormButtonAndCaption); animatorLayout.addComponent(formAnimator); } else { animatorLayout.addComponent(toggleFormVisibilityButton); animatorLayout.addComponent(formAnimator); } return animatorLayout; }
From source file:de.symeda.sormas.ui.dashboard.map.DashboardMapComponent.java
License:Open Source License
public static AbstractOrderedLayout buildRegionLegend(boolean vertical, CaseMeasure caseMeasure, boolean emptyPopulationDistrictPresent, BigDecimal districtShapesLowerQuartile, BigDecimal districtShapesMedian, BigDecimal districtShapesUpperQuartile) { AbstractOrderedLayout regionLegendLayout = vertical ? new VerticalLayout() : new HorizontalLayout(); regionLegendLayout.setSpacing(true); CssStyles.style(regionLegendLayout, CssStyles.LAYOUT_MINIMAL); regionLegendLayout.setSizeUndefined(); HorizontalLayout legendEntry;//from w ww. jav a2s. c om switch (caseMeasure) { case CASE_COUNT: legendEntry = buildMapIconLegendEntry("lowest-region-small", districtShapesLowerQuartile.compareTo(BigDecimal.ONE) > 0 ? "1 - " + districtShapesLowerQuartile + " " + I18nProperties.getString(Strings.entityCases) : "1 " + I18nProperties.getString(Strings.entityCase)); break; case CASE_INCIDENCE: legendEntry = buildMapIconLegendEntry("lowest-region-small", "<= " + DataHelper.getTruncatedBigDecimal(districtShapesLowerQuartile) + " " + I18nProperties.getString(Strings.entityCases) + " / " + DistrictDto.CASE_INCIDENCE_DIVISOR); break; default: throw new IllegalArgumentException(caseMeasure.toString()); } regionLegendLayout.addComponent(legendEntry); if (districtShapesLowerQuartile.compareTo(districtShapesMedian) < 0) { switch (caseMeasure) { case CASE_COUNT: legendEntry = buildMapIconLegendEntry("low-region-small", districtShapesMedian.compareTo(districtShapesLowerQuartile.add(BigDecimal.ONE)) > 0 ? districtShapesLowerQuartile.add(BigDecimal.ONE) + " - " + districtShapesMedian + " " + I18nProperties.getString(Strings.entityCases) : districtShapesMedian + " " + I18nProperties.getString(Strings.entityCases)); break; case CASE_INCIDENCE: legendEntry = buildMapIconLegendEntry("low-region-small", DataHelper .getTruncatedBigDecimal(districtShapesLowerQuartile.add(new BigDecimal(0.1)) .setScale(1, RoundingMode.HALF_UP)) + " - " + DataHelper.getTruncatedBigDecimal(districtShapesMedian) + " " + I18nProperties.getString(Strings.entityCases) + " / " + DistrictDto.CASE_INCIDENCE_DIVISOR); break; default: throw new IllegalArgumentException(caseMeasure.toString()); } regionLegendLayout.addComponent(legendEntry); } if (districtShapesMedian.compareTo(districtShapesUpperQuartile) < 0) { switch (caseMeasure) { case CASE_COUNT: legendEntry = buildMapIconLegendEntry("high-region-small", districtShapesUpperQuartile.compareTo(districtShapesMedian.add(BigDecimal.ONE)) > 0 ? districtShapesMedian.add(BigDecimal.ONE) + " - " + districtShapesUpperQuartile + " " + I18nProperties.getString(Strings.entityCases) : districtShapesUpperQuartile + " " + I18nProperties.getString(Strings.entityCases)); break; case CASE_INCIDENCE: legendEntry = buildMapIconLegendEntry("high-region-small", DataHelper.getTruncatedBigDecimal( districtShapesMedian.add(new BigDecimal(0.1)).setScale(1, RoundingMode.HALF_UP)) + " - " + DataHelper.getTruncatedBigDecimal(districtShapesUpperQuartile) + " " + I18nProperties.getString(Strings.entityCases) + " / " + DistrictDto.CASE_INCIDENCE_DIVISOR); break; default: throw new IllegalArgumentException(caseMeasure.toString()); } regionLegendLayout.addComponent(legendEntry); } switch (caseMeasure) { case CASE_COUNT: legendEntry = buildMapIconLegendEntry("highest-region-small", "> " + districtShapesUpperQuartile + " " + I18nProperties.getString(Strings.entityCases)); break; case CASE_INCIDENCE: legendEntry = buildMapIconLegendEntry("highest-region-small", "> " + DataHelper.getTruncatedBigDecimal(districtShapesUpperQuartile) + " " + I18nProperties.getString(Strings.entityCases) + " / " + DistrictDto.CASE_INCIDENCE_DIVISOR); break; default: throw new IllegalArgumentException(caseMeasure.toString()); } regionLegendLayout.addComponent(legendEntry); if (caseMeasure == CaseMeasure.CASE_INCIDENCE && emptyPopulationDistrictPresent) { legendEntry = buildMapIconLegendEntry("no-population-region-small", I18nProperties.getCaption(Captions.dashboardNoPopulationData)); regionLegendLayout.addComponent(legendEntry); } return regionLegendLayout; }
From source file:de.unioninvestment.eai.portal.portlet.crud.mvp.views.DefaultPanelContentView.java
License:Apache License
@Override public void initialize(boolean useHorizontalLayout) { AbstractOrderedLayout layout = useHorizontalLayout ? new HorizontalLayout() : new VerticalLayout(); setCompositionRoot(layout);// w ww .jav a 2s . c om layout.setSpacing(true); layout.setMargin(true); }
From source file:edu.nps.moves.mmowgliMobile.ui.CardRenderer2.java
License:Open Source License
public void setMessage(FullEntryView2 mView, ListEntry message, ListView2 messageList, AbstractOrderedLayout layout) { Object key = HSess.checkInit(); CardListEntry wc = (CardListEntry) message; Card c = wc.getCard();//from w ww .j a v a 2 s. c om CardType typ = c.getCardType(); layout.removeAllComponents(); layout.setSpacing(true); VerticalLayout cardLay = new VerticalLayout(); cardLay.addStyleName("m-card-render"); cardLay.setWidth("98%"); //100%"); cardLay.setSpacing(true); layout.addComponent(cardLay); HorizontalLayout horl = new HorizontalLayout(); horl.addStyleName("m-card-header"); String stl = CardStyler.getCardBaseStyle(typ); horl.addStyleName(stl); horl.addStyleName(CardStyler.getCardTextColorOverBaseStyle(typ)); horl.setMargin(true); horl.setWidth("100%"); Label lbl = new Label(typ.getTitle());//c.getText()); horl.addComponent(lbl); lbl = new Label("" + getPojoId(message)); lbl.addStyleName("m-text-align-right"); horl.addComponent(lbl); cardLay.addComponent(horl); horl = new HorizontalLayout(); horl.setWidth("100%"); horl.setMargin(true); cardLay.addComponent(horl); lbl = new Label(c.getText()); horl.addComponent(lbl); horl = new HorizontalLayout(); horl.addStyleName("m-card-footer"); horl.setMargin(true); horl.setWidth("100%"); horl.addComponent(lbl = new Label("")); lbl.setWidth("5px"); Image img = new Image(); img.setSource(mediaLocator.locate(c.getAuthor().getAvatar().getMedia())); img.setWidth("30px"); img.setHeight("30px"); horl.addComponent(img); // horl.addComponent(lbl=new Label(c.getAuthorName())); // lbl.setWidth("100%"); // lbl.addStyleName("m-text-align-center"); // horl.setComponentAlignment(lbl, Alignment.MIDDLE_CENTER); // horl.setExpandRatio(lbl, 1.0f); Button authButt = new MyButton(c.getAuthorName(), c, mView); authButt.setStyleName(BaseTheme.BUTTON_LINK); authButt.setWidth("100%"); horl.addComponent(authButt); horl.setComponentAlignment(authButt, Alignment.MIDDLE_CENTER); horl.setExpandRatio(authButt, 1.0f); horl.addComponent(lbl = new HtmlLabel(formatter.format(message.getTimestamp()))); lbl.setWidth("115px"); ; lbl.addStyleName("m-text-align-right"); horl.setComponentAlignment(lbl, Alignment.MIDDLE_CENTER); cardLay.addComponent(horl); // lbl = new Hr(); // layout.addComponent(lbl); lbl = new Label("Child Cards"); layout.addComponent(lbl); lbl.addStyleName("m-text-center"); // lbl = new Hr(); // layout.addComponent(lbl); horl = new HorizontalLayout(); horl.setSpacing(true); horl.setMargin(true); horl.setWidth("100%"); layout.addComponent(horl); horl.addComponent( makeChildGroupButton("Expand", (CardListEntry) message, CardType.getExpandTypeTL(), messageList)); horl.addComponent( makeChildGroupButton("Counter", (CardListEntry) message, CardType.getCounterTypeTL(), messageList)); horl.addComponent( makeChildGroupButton("Adapt", (CardListEntry) message, CardType.getAdaptTypeTL(), messageList)); horl.addComponent( makeChildGroupButton("Explore", (CardListEntry) message, CardType.getExploreTypeTL(), messageList)); HSess.checkClose(key); }
From source file:org.eclipse.emf.ecp.view.core.vaadin.AbstractContainerRendererVaadin.java
License:Open Source License
@Override protected Component render() { final T renderable = getVElement(); final AbstractOrderedLayout layout = getAbstractOrderedLayout(); for (final VContainedElement composite : renderable.getChildren()) { final Component renderResult = getRendererFactory().render(composite, getViewModelContext()); layout.addComponent(renderResult); }//from w w w.ja v a 2 s. c om final Component renderComponent = getRenderComponent(layout); renderComponent.setWidth(100, Unit.PERCENTAGE); if (renderComponent instanceof AbstractOrderedLayout) { final AbstractOrderedLayout abstractOrderedLayout = (AbstractOrderedLayout) renderComponent; abstractOrderedLayout.setMargin(isMargin()); abstractOrderedLayout.setSpacing(isSpacing()); } return renderComponent; }
From source file:org.eclipse.emf.ecp.view.group.vaadin.GroupLayoutRendererVaadin.java
License:Open Source License
@Override protected Component getRenderComponent(final AbstractOrderedLayout orderedLayout) { if (GroupType.COLLAPSIBLE.equals(getVElement().getGroupType())) { final VerticalLayout mainLayout = new VerticalLayout(); final NativeButton collapseButton = new NativeButton(StringUtils.EMPTY, new Button.ClickListener() { @Override//from w ww.j av a 2 s.com public void buttonClick(ClickEvent event) { final boolean switchVisible = !orderedLayout.isVisible(); setCollapseStyle(event.getButton(), switchVisible); orderedLayout.setVisible(switchVisible); } }); collapseButton.setWidth(100, Unit.PERCENTAGE); mainLayout.addComponent(collapseButton); mainLayout.addComponent(orderedLayout); orderedLayout.setMargin(true); orderedLayout.setSpacing(true); orderedLayout.setVisible(getVElement().isCollapsed()); setCollapseStyle(collapseButton, getVElement().isCollapsed()); mainLayout.addStyleName(GROUP_STYLE_NAME); return mainLayout; } return super.getRenderComponent(orderedLayout); }
From source file:org.eclipse.emf.ecp.view.vaadin.ViewRendererVaadin.java
License:Open Source License
@Override public Component render() { final AbstractOrderedLayout layout = getLayout(); layout.setSpacing(true); layout.setMargin(true);//from w ww .j a v a 2 s . co m layout.setSizeFull(); for (final VContainedElement composite : getVElement().getChildren()) { final Component renderResult = getRendererFactory().render(composite, getViewModelContext()); layout.addComponent(renderResult); } final ECPVaadinViewComponent ecpVaadinViewComponent = new ECPVaadinViewComponent(); ecpVaadinViewComponent.addStyleName(BORDERLESS); ecpVaadinViewComponent.setContent(layout); return ecpVaadinViewComponent; }