List of usage examples for com.vaadin.ui Label setWidth
@Override public void setWidth(float width, Unit unit)
From source file:org.lucidj.browser.AbstractCell.java
License:Apache License
private Component build_insert_here() { Label message = new Label("Drag or double-click any component to add one or more here"); // TODO: FIX WRONG TEXT-WRAPPING WHEN CELL TOO NARROW message.addStyleName("formula-insert-here"); message.setHeight(64, Sizeable.Unit.PIXELS); message.setWidth(100, Sizeable.Unit.PERCENTAGE); return (message); }
From source file:org.lucidj.vaadinui.BaseVaadinUI.java
License:Apache License
private void initSystemToolbar() { desktop_canvas.setSizeFull();/*from w w w.j av a 2s . co m*/ desktop_canvas.setWidth("100%"); ui_header = new HorizontalLayout(); { ui_header.setStyleName("ui-header-area"); ui_header.setWidth(100, Sizeable.Unit.PERCENTAGE); ui_header.setHeightUndefined(); ui_header.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT); Label logo = new Label(" ", ContentMode.HTML); { logo.addStyleName("ui-header-logo"); logo.setWidth(default_sidebar_width_pixels, Sizeable.Unit.PIXELS); } ui_header.addComponent(logo); HorizontalLayout header_components = new HorizontalLayout(); { header_components.setWidth(100, com.vaadin.server.Sizeable.Unit.PERCENTAGE); header_components.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT); header_components.setSpacing(true); // Search component CssLayout search_component = new CssLayout(); { search_component.setWidth(100, com.vaadin.server.Sizeable.Unit.PERCENTAGE); search_component.setWidthUndefined(); search_component.addStyleName("v-component-group"); search_component.addStyleName("ui-header-search"); final ComboBox search_text = new ComboBox(); { search_text.setInputPrompt("Search or paste URL..."); //combo.setContainerDataSource(StringGenerator.generateContainer(200, false)); search_text.setNullSelectionAllowed(true); search_text.setTextInputAllowed(true); search_text.setNewItemsAllowed(true); //combo.select(combo.getItemIds().iterator().next()); //combo.setItemCaptionPropertyId(StringGenerator.CAPTION_PROPERTY); //combo.setItemIconPropertyId(StringGenerator.ICON_PROPERTY); // TODO: SOMEDAY DISCOVER HOW TO EXPAND THIS GROUPED COMPONENT, AND THE CURE FOR CANCER search_text.setWidth("480px"); search_text.addStyleName("invisible-focus"); search_text.addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(Property.ValueChangeEvent valueChangeEvent) { String search_args = (String) search_text.getValue(); if (search_args != null) { fireEvent("search", search_text.getValue()); value_change_button_quirk = true; } } }); // Handles the Enter key by activating on focus and deactivating on blur final ShortcutListener handle_enter = new ShortcutListener("Enter", ShortcutAction.KeyCode.ENTER, null) { @Override public void handleAction(Object o, Object o1) { value_change_button_quirk = false; fireEvent("search", search_text.getValue()); } }; search_text.addFocusListener(new FieldEvents.FocusListener() { @Override public void focus(FieldEvents.FocusEvent focusEvent) { if (nested_focus_blur_bug_count++ == 0) { search_text.addShortcutListener(handle_enter); } } }); search_text.addBlurListener(new FieldEvents.BlurListener() { @Override public void blur(FieldEvents.BlurEvent blurEvent) { if (--nested_focus_blur_bug_count == 0) { search_text.removeShortcutListener(handle_enter); } } }); } search_component.addComponent(search_text); Button search_button = new Button(); { search_button.setIcon(FontAwesome.SEARCH); search_button.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent clickEvent) { if (!value_change_button_quirk) { fireEvent("search", search_text.getValue()); } value_change_button_quirk = false; } }); search_button.addStyleName("invisible-focus"); } search_component.addComponent(search_button); } header_components.addComponent(search_component); // User component user_component = new HorizontalLayout(); { user_component.setStyleName("ui-header-user"); user_component.setWidthUndefined(); } header_components.addComponent(user_component); // I swear someday I'll learn CSS, AFTER implementing my own distributed // operating system with augmented reality interface and a machine learning kernel, // all written in Z80 assembly, as a preparation for the task. Label spacer = new Label(); spacer.setWidthUndefined(); header_components.addComponent(spacer); // Search expands header_components.setExpandRatio(search_component, 1.0f); } ui_header.addComponent(header_components); ui_header.setExpandRatio(header_components, 1.0f); } desktop_canvas.addComponent(ui_header); desktop_canvas.addComponent(empty_desktop); desktop_canvas.setExpandRatio(empty_desktop, 1.0f); setContent(desktop_canvas); }
From source file:org.opennms.features.topology.api.support.DialogWindow.java
License:Open Source License
private Layout createMainArea(final String description) { HorizontalLayout layout = new HorizontalLayout(); layout.setSpacing(true);/*from w w w. ja v a 2s . c o m*/ layout.setMargin(true); layout.setWidth(100, Unit.PERCENTAGE); Label label = new Label(description, ContentMode.PREFORMATTED); label.setWidth(100, Unit.PERCENTAGE); layout.addComponent(label); return layout; }
From source file:org.opennms.features.topology.app.internal.ui.InfoPanel.java
License:Open Source License
private void refreshInfoArea() { infoArea.removeAllComponents();// w w w .ja v a2s .c o m if (expanded) { infoArea.removeAllComponents(); staticComponents.forEach(sc -> infoArea.addComponent(sc)); dynamicComponents.forEach(c -> infoArea.addComponent(c)); // Add an empty component with width = 350px to always force the max length // This is required as otherwise the left area of the info panel would be empty, even if the info panel // is not shown. Label label = new Label(); label.setWidth(350, Unit.PIXELS); infoArea.addComponent(label); } else { infoArea.addComponent(toggleButton); } }
From source file:org.opennms.features.vaadin.dashboard.dashlets.BSMConfigurationWindow.java
License:Open Source License
/** * Adds a component to a given vertical layout and applies some sizing and formatting options. * * @param verticalLayout the vertical layout * @param component the component to be added *///from ww w. j a v a 2s. c o m private void addToComponent(VerticalLayout verticalLayout, Component component) { HorizontalLayout horizontalLayout = new HorizontalLayout(); horizontalLayout.setWidth(100, Unit.PERCENTAGE); Label label = new Label(component.getCaption()); label.setWidth(200, Unit.PIXELS); component.setSizeFull(); component.setCaption(null); horizontalLayout.addComponent(label); horizontalLayout.addComponent(component); horizontalLayout.setExpandRatio(component, 1.0f); verticalLayout.addComponent(horizontalLayout); }
From source file:org.opennms.features.vaadin.dashboard.dashlets.SummaryDashlet.java
License:Open Source License
private Component getLegend(String entity) { HorizontalLayout horizontalLayout = new HorizontalLayout(); horizontalLayout.setSpacing(true);// ww w .ja v a 2 s . co m horizontalLayout.addStyleName("summary"); horizontalLayout.addStyleName("global"); Label labelx = new Label(entity); labelx.addStyleName("summary-font-legend"); Image ackdImage = new Image(null, new ThemeResource("img/acknowledged.png")); ackdImage.setWidth(16, Sizeable.Unit.PIXELS); Image unackdImage = new Image(null, new ThemeResource("img/unacknowledged.png")); unackdImage.setWidth(16, Sizeable.Unit.PIXELS); Label dummyLabel = new Label(); dummyLabel.setWidth(32, Sizeable.Unit.PIXELS); horizontalLayout.addComponent(labelx); horizontalLayout.addComponent(ackdImage); horizontalLayout.addComponent(unackdImage); horizontalLayout.addComponent(dummyLabel); horizontalLayout.setComponentAlignment(ackdImage, Alignment.TOP_RIGHT); horizontalLayout.setComponentAlignment(unackdImage, Alignment.TOP_RIGHT); horizontalLayout.setExpandRatio(labelx, 4.0f); horizontalLayout.setExpandRatio(ackdImage, 1.0f); horizontalLayout.setExpandRatio(unackdImage, 1.0f); horizontalLayout.setExpandRatio(dummyLabel, 1.0f); horizontalLayout.setWidth(375, Sizeable.Unit.PIXELS); return horizontalLayout; }
From source file:org.ripla.web.controllers.RiplaBody.java
License:Open Source License
/** * We have to clone the separator label defined in the skin. * //w ww . j ava2 s . c o m * @param inSeparator * Label * @return {@link Label} the cloned label */ private Label getSeparator(final Label inSeparator) { final Label out = new Label(inSeparator.getValue().toString(), inSeparator.getContentMode()); out.setWidth(inSeparator.getWidth(), inSeparator.getWidthUnits()); out.setStyleName(inSeparator.getStyleName()); return out; }
From source file:org.ripla.web.demo.skin.Skin.java
License:Open Source License
@Override public Label getToolbarSeparator() { final Label outSeparator = new Label("•", ContentMode.HTML); //$NON-NLS-1$ // outSeparator.setSizeUndefined(); outSeparator.setWidth(4, Unit.PIXELS); return outSeparator; }
From source file:org.ripla.web.demo.skin.stylish.Skin.java
License:Open Source License
private Label createMargin(final String inStyle, final int inWidth) { final Label out = new Label(" ", ContentMode.HTML); out.setStyleName(inStyle);//w w w . ja va 2 s . c o m out.setWidth(inWidth, Unit.PIXELS); out.setHeight(45, Unit.PIXELS); return out; }
From source file:org.ripla.web.util.RiplaViewHelper.java
License:Open Source License
/** * Convenience method to make a label width undefined. * //ww w .j a v a 2s.c o m * @param inLabel * {@link Label} to prepare * @return Label with width <code>SIZE_UNDEFINED</code> */ public static Label makeUndefinedWidth(final Label inLabel) { inLabel.setWidth(Sizeable.SIZE_UNDEFINED, Unit.PIXELS); return inLabel; }