List of usage examples for com.vaadin.ui Label setWidth
@Override public void setWidth(String width)
From source file:org.processbase.ui.bpm.admin.UserWindow.java
License:Open Source License
private void addTableMembershipRow(Membership membership) throws Exception { String uuid = membership != null ? membership.getUUID() : "NEW_MEMBERSHIP_UUID_" + UUID.randomUUID().toString(); Item woItem = tableMembership.addItem(uuid); if (membership != null) { Label groups = new Label(getGroups() .getItem(membership != null ? membership.getGroup().getUUID() : null).getItemProperty("path")); woItem.getItemProperty("group").setValue(groups); Label roles = new Label(getRoles().getItem(membership != null ? membership.getRole().getUUID() : null) .getItemProperty("name")); woItem.getItemProperty("role").setValue(roles); } else {/*from w w w .ja va2 s . com*/ ComboBox groups = new ComboBox(); groups.setWidth("100%"); groups.setContainerDataSource(getGroups()); groups.setItemCaptionPropertyId("path"); groups.setFilteringMode(ComboBox.FILTERINGMODE_CONTAINS); groups.setValue(membership != null ? membership.getGroup().getUUID() : null); woItem.getItemProperty("group").setValue(groups); ComboBox roles = new ComboBox(); roles.setWidth("100%"); roles.setContainerDataSource(getRoles()); roles.setItemCaptionPropertyId("name"); roles.setFilteringMode(ComboBox.FILTERINGMODE_CONTAINS); roles.setValue(membership != null ? membership.getRole().getUUID() : null); woItem.getItemProperty("role").setValue(roles); } TableLinkButton tlb = new TableLinkButton(ProcessbaseApplication.getString("btnDelete"), "icons/cancel.png", uuid, this, Constants.ACTION_DELETE); woItem.getItemProperty("actions").setValue(tlb); }
From source file:org.processbase.ui.core.template.DefaultConfirmDialogFactory.java
License:Open Source License
public ConfirmDialog create(final String caption, final String message, final String okCaption, final String cancelCaption) { // Create a confirm dialog final ConfirmDialog confirm = new ConfirmDialog(); confirm.setCaption(caption != null ? caption : DEFAULT_CAPTION); // Close listener implementation confirm.addListener(new Window.CloseListener() { private static final long serialVersionUID = 1971800928047045825L; public void windowClose(CloseEvent ce) { confirm.setConfirmed(false); if (confirm.getListener() != null) { confirm.getListener().onClose(confirm); }/*from w w w . j ava 2s . co m*/ } }); // Create content VerticalLayout c = (VerticalLayout) confirm.getContent(); c.setSizeFull(); c.setSpacing(true); // Panel for scrolling lengthty messages. Panel scroll = new Panel(new VerticalLayout()); scroll.setScrollable(true); c.addComponent(scroll); scroll.setWidth("100%"); scroll.setHeight("100%"); scroll.setStyleName(Reindeer.PANEL_LIGHT); c.setExpandRatio(scroll, 1f); // Always HTML, but escape Label text = new Label("", Label.CONTENT_RAW); scroll.addComponent(text); confirm.setMessageLabel(text); confirm.setMessage(message); HorizontalLayout buttons = new HorizontalLayout(); c.addComponent(buttons); buttons.setSpacing(true); buttons.setHeight(format(BUTTON_HEIGHT) + "em"); buttons.setWidth("100%"); Label spacer = new Label(""); buttons.addComponent(spacer); spacer.setWidth("100%"); buttons.setExpandRatio(spacer, 1f); final Button cancel = new Button(cancelCaption != null ? cancelCaption : DEFAULT_CANCEL_CAPTION); cancel.setData(false); cancel.setClickShortcut(KeyCode.ESCAPE, null); buttons.addComponent(cancel); buttons.setComponentAlignment(cancel, Alignment.MIDDLE_RIGHT); confirm.setCancelButton(cancel); final Button ok = new Button(okCaption != null ? okCaption : DEFAULT_OK_CAPTION); ok.setData(true); ok.setClickShortcut(KeyCode.ENTER, null); ok.setStyleName(Reindeer.BUTTON_DEFAULT); ok.focus(); buttons.addComponent(ok); buttons.setComponentAlignment(ok, Alignment.MIDDLE_RIGHT); confirm.setOkButton(ok); // Create a listener for buttons Button.ClickListener cb = new Button.ClickListener() { private static final long serialVersionUID = 3525060915814334881L; public void buttonClick(ClickEvent event) { // Copy the button date to window for passing through either // "OK" or "CANCEL" confirm.setConfirmed(event.getButton() == ok); // This has to be invoked as the window.close // event is not fired when removed. if (confirm.getListener() != null) { confirm.getListener().onClose(confirm); } confirm.close(); } }; cancel.addListener(cb); ok.addListener(cb); // Approximate the size of the dialog double[] dim = getDialogDimensions(message, ConfirmDialog.CONTENT_TEXT_WITH_NEWLINES); confirm.setWidth(format(dim[0]) + "em"); confirm.setHeight(format(dim[1]) + "em"); confirm.setResizable(false); return confirm; }
From source file:org.ripla.web.controllers.RiplaBody.java
License:Open Source License
private Component createToolbar(final Label inSeparator) { final HorizontalLayout outToolbar = new HorizontalLayout(); outToolbar.setStyleName("ripla-toolbar"); //$NON-NLS-1$ outToolbar.setWidth("100%"); //$NON-NLS-1$ outToolbar.setSpacing(true);/*from w ww .ja v a 2 s .c o m*/ outToolbar.setMargin(new MarginInfo(false, true, false, true)); outToolbar.setHeight(22, Unit.PIXELS); final Label lExpand = new Label(" ", ContentMode.HTML); lExpand.setWidth("100%"); outToolbar.addComponent(lExpand); outToolbar.setExpandRatio(lExpand, 1); final Iterator<IToolbarItem> lItems = ToolbarItemRegistry.INSTANCE.getSortedItems().iterator(); boolean lFirst = true; while (lItems.hasNext()) { final IToolbarItem lItem = lItems.next(); final IToolbarItemCreator lFactory = lItem.getCreator(); final Component lComponent = lFactory == null ? lItem.getComponent() : lFactory.createToolbarItem(application, getUser()); if (lComponent == null) { continue; } if (!lFirst) { final Label lSeparator = getSeparator(inSeparator); outToolbar.addComponent(lSeparator); outToolbar.setComponentAlignment(lSeparator, Alignment.MIDDLE_CENTER); } lFirst = false; outToolbar.addComponent(lComponent); outToolbar.setComponentAlignment(lComponent, Alignment.MIDDLE_CENTER); lItem.registerToolbarActionListener(new IToolbarActionListener() { // NOPMD @Override public void processAction(final IToolbarAction inAction) { inAction.run(); } }); } return outToolbar; }
From source file:org.ripla.web.util.LabelValueTable.java
License:Open Source License
private Label createLabel(final String inStyle, final String inCaption) { final Label out = new Label(String.format(inStyle, inCaption), ContentMode.HTML); out.setWidth(null); return out;//from w w w.j a v a 2s . co m }
From source file:org.ripla.web.util.LabelValueTable.java
License:Open Source License
/** * Convenience method to create a plain label. * /*from www .j av a 2 s . co m*/ * @param inCaption * String the label's caption * @return {@link Label} */ public static Label createPlainLabel(final String inCaption) { final Label out = new Label(String.format(STYLE_LABEL, inCaption), ContentMode.HTML); out.setWidth(null); return out; }
From source file:org.rubicone.poc.vpush.uil.receiving.ReceivingUI.java
License:Apache License
private Panel createInstructionsPanel() { Panel instructionsPanel = new Panel("instructions"); VerticalLayout instructionsLayout = new VerticalLayout(); instructionsPanel.setContent(instructionsLayout); Label instructionsLabel = new Label( "the received messages should automatically appear in the below panel without requiring any user interaction/server round trip"); instructionsLayout.addComponent(instructionsLabel); Label a = new Label("<hr/>", ContentMode.HTML); a.setWidth("100%"); a.addStyleName(ValoTheme.LABEL_TINY); instructionsLayout.addComponent(a);/*from ww w . j a v a 2 s . c om*/ Button refreshButton = new Button("refresh", VaadinIcons.REFRESH); refreshButton .addClickListener(event -> log.debug("manual refresh of received messages with server roundtrip")); instructionsLayout.addComponent(refreshButton); Label noteLabel = new Label("<i>" + VaadinIcons.INFO_CIRCLE_O.getHtml() + "note: dummy refresh button to perform server round trip to synchronize with server" + " side status of UI (to check for message -> in case visible after and not prior then the push does not work)</i>", ContentMode.HTML); noteLabel.addStyleName(ValoTheme.LABEL_TINY); instructionsLayout.addComponent(noteLabel); return instructionsPanel; }
From source file:org.semanticsoft.vaaclipse.presentation.utils.GuiUtils.java
License:Open Source License
public static Component createSeparator(MTrimElement trimElement) { if ((MElementContainer<?>) trimElement.getParent() instanceof MTrimBar) { Label separator = new Label(); separator.setSizeUndefined();/* w w w. j a v a 2s .co m*/ MTrimBar parentTrimBar = (MTrimBar) (MElementContainer<?>) trimElement.getParent(); int orientation = parentTrimBar.getSide().getValue(); if (orientation == SideValue.TOP_VALUE || orientation == SideValue.BOTTOM_VALUE) { separator.addStyleName("horizontalseparator"); separator.setHeight("100%"); } else { separator.addStyleName("verticalseparator"); separator.setWidth("100%"); } return separator; } else return null; }
From source file:org.sensorhub.ui.AdminUI.java
License:Mozilla Public License
protected Component buildHeader() { HorizontalLayout header = new HorizontalLayout(); header.setMargin(false);//w w w .j a va 2s. c o m header.setHeight(100.0f, Unit.PIXELS); header.setWidth(100.0f, Unit.PERCENTAGE); Image img = new Image(null, LOGO_ICON); img.setHeight(90, Unit.PIXELS); img.setStyleName(STYLE_LOGO); header.addComponent(img); Label title = new Label("SensorHub"); title.addStyleName(UIConstants.STYLE_H1); title.addStyleName(STYLE_LOGO); title.setWidth(null); header.addComponent(title); header.setExpandRatio(img, 0); header.setExpandRatio(title, 1); header.setComponentAlignment(img, Alignment.MIDDLE_LEFT); header.setComponentAlignment(title, Alignment.MIDDLE_RIGHT); return header; }
From source file:org.vaadin.addons.javaee.form.LabelCreator.java
License:Apache License
public Label createLabel(String sectionName, FieldSpecification fieldSpec) { Label label = new Label(translationService.getText(sectionName + "." + fieldSpec.getName()) + ":"); label.addStyleName("rightalign"); label.addStyleName(Reindeer.LABEL_SMALL); if (fieldSpec.getLabelWidth() != null) { label.setWidth(fieldSpec.getLabelWidth()); }/*from w ww.ja v a2 s . co m*/ return label; }
From source file:org.vaadin.dialogs.DefaultConfirmDialogFactory.java
License:Mozilla Public License
public ConfirmDialog create(final String caption, final String message, final String okCaption, final String cancelCaption) { // Create a confirm dialog final ConfirmDialog confirm = new ConfirmDialog(); confirm.setCaption(caption != null ? caption : DEFAULT_CAPTION); // Close listener implementation confirm.addListener(new Window.CloseListener() { private static final long serialVersionUID = 1971800928047045825L; public void windowClose(CloseEvent ce) { // Only process if still enabled if (confirm.isEnabled()) { confirm.setEnabled(false); // avoid double processing confirm.setConfirmed(false); if (confirm.getListener() != null) { confirm.getListener().onClose(confirm); }/*from w w w . jav a 2 s. c o m*/ } } }); // Create content VerticalLayout c = (VerticalLayout) confirm.getContent(); c.setSizeFull(); c.setSpacing(true); // Panel for scrolling lengthty messages. Panel scroll = new Panel(new VerticalLayout()); scroll.setScrollable(true); c.addComponent(scroll); scroll.setWidth("100%"); scroll.setHeight("100%"); scroll.setStyleName(Reindeer.PANEL_LIGHT); c.setExpandRatio(scroll, 1f); // Always HTML, but escape Label text = new Label("", Label.CONTENT_RAW); scroll.addComponent(text); confirm.setMessageLabel(text); confirm.setMessage(message); HorizontalLayout buttons = new HorizontalLayout(); c.addComponent(buttons); buttons.setSpacing(true); buttons.setHeight(format(BUTTON_HEIGHT) + "em"); buttons.setWidth("100%"); Label spacerLeft = new Label(""); buttons.addComponent(spacerLeft); spacerLeft.setWidth("100%"); buttons.setExpandRatio(spacerLeft, 1f); final Button cancel = new Button(cancelCaption != null ? cancelCaption : DEFAULT_CANCEL_CAPTION); cancel.setData(false); cancel.setClickShortcut(KeyCode.ESCAPE, null); buttons.addComponent(cancel); confirm.setCancelButton(cancel); final Button ok = new Button(okCaption != null ? okCaption : DEFAULT_OK_CAPTION); ok.setData(true); ok.setClickShortcut(KeyCode.ENTER, null); ok.focus(); buttons.addComponent(ok); confirm.setOkButton(ok); Label spacerRight = new Label(""); buttons.addComponent(spacerRight); spacerRight.setWidth("100%"); buttons.setExpandRatio(spacerRight, 1f); // Create a listener for buttons Button.ClickListener cb = new Button.ClickListener() { private static final long serialVersionUID = 3525060915814334881L; public void buttonClick(ClickEvent event) { // Copy the button date to window for passing through either // "OK" or "CANCEL". Only process id still enabled. if (confirm.isEnabled()) { confirm.setEnabled(false); // Avoid double processing confirm.setConfirmed(event.getButton() == ok); // We need to cast this way, because of the backward // compatibility issue in 6.4 series. Component parent = confirm.getParent(); if (parent instanceof Window) { try { Method m = Window.class.getDeclaredMethod("removeWindow", Window.class); m.invoke(parent, confirm); } catch (Exception e) { throw new RuntimeException( "Failed to remove confirmation dialog from the parent window.", e); } } // This has to be invoked as the window.close // event is not fired when removed. if (confirm.getListener() != null) { confirm.getListener().onClose(confirm); } } } }; cancel.addListener(cb); ok.addListener(cb); // Approximate the size of the dialog double[] dim = getDialogDimensions(message, ConfirmDialog.CONTENT_TEXT_WITH_NEWLINES); confirm.setWidth(format(dim[0]) + "em"); confirm.setHeight(format(dim[1]) + "em"); confirm.setResizable(false); return confirm; }