List of usage examples for com.vaadin.ui HorizontalLayout setSpacing
@Override public void setSpacing(boolean spacing)
From source file:de.escidoc.admintool.view.util.LayoutHelper.java
License:Open Source License
/** * Helper method. Puts a blank in front of a component. * /*w ww . j a v a 2s . co m*/ * @param label * The label in front of the control. * @param accordion * The accordion to display. * @param width * the fixed size of the label. The parameter has to be in CSS style, i.e. 400px for instance. * @param height * @param required * should it be marked with an asterisk. * @return The component in an horizontal layout. A blank in front and afterwards is inserted. */ public static synchronized HorizontalLayout create(final String label, final Accordion accordion, final int width, final int height, final boolean required) { final HorizontalLayout hor = new HorizontalLayout(); hor.setHeight(height + Constants.PX); hor.addComponent(new Label(" ")); final String text = Constants.P_ALIGN_RIGHT + label + Constants.P; Label l; hor.addComponent(l = new Label(text, Label.CONTENT_XHTML)); l.setSizeUndefined(); l.setWidth(width + Constants.PX); hor.setComponentAlignment(l, Alignment.MIDDLE_RIGHT); if (required) { hor.addComponent(new Label( " <span style=\"color:red; position:relative; top:" + (height / 2 - 13) + "px;\">*</span>", Label.CONTENT_XHTML)); } else { hor.addComponent(new Label(" ", Label.CONTENT_XHTML)); } final Panel pan = new Panel(); pan.setSizeFull(); // Have it take all space available in the layout. accordion.setSizeFull(); // Some components to put in the Accordion. final String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<root>\n\t<X>\n\t\t<today>\n\t\t</today>\n\t\t<today/>\n\t\t<today/>\n\t</X>\n</root>"; for (int i = 0; i < 30; i++) { accordion.addTab(new Label(xml, Label.CONTENT_PREFORMATTED), "Tab" + i, null); } pan.addComponent(accordion); // pan.setSizeUndefined(); pan.setWidth(accordion.getWidth() + Constants.PX); // pan.setHeight("500px"); pan.setStyleName(Reindeer.PANEL_LIGHT); hor.addComponent(pan); hor.setComponentAlignment(pan, Alignment.MIDDLE_RIGHT); hor.addComponent(new Label(" ")); hor.setSpacing(false); return hor; }
From source file:de.escidoc.admintool.view.util.LayoutHelper.java
License:Open Source License
/** * Helper method. Puts a blank in front of a component. Two labels with different size in front of two components. * /*from w w w.j ava 2s . c o m*/ * @param labelLeft * the left (leading) label. * @param labelRight * the right (leading) label. * @param compLeft * the left component. * @param compRight * the right component. * @param widthLeft * the width of the left label. * @param widthRight * the width of the right label. * @param required * true if the component is required, otherwise false. * @return the customized component placed in a horizontal layout. */ public static synchronized HorizontalLayout create(final String labelLeft, final String labelRight, final Component compLeft, final Component compRight, final int widthLeft, final int widthRight, final boolean required) { // foo final HorizontalLayout hor = new HorizontalLayout(); hor.setHeight(Constants.DEFAULT_HEIGHT); hor.addComponent(new Label(" ")); final String text = Constants.P_ALIGN_RIGHT + labelLeft + Constants.P; Label ll, lr; hor.addComponent(ll = new Label(text, Label.CONTENT_XHTML)); ll.setSizeUndefined(); ll.setWidth(widthLeft + Constants.PX); hor.setComponentAlignment(ll, Alignment.MIDDLE_RIGHT); if (required) { hor.addComponent(new Label(" <span style=\"color:red; position:relative; top:13px;\">*</span>", Label.CONTENT_XHTML)); } else { hor.addComponent(new Label(" ", Label.CONTENT_XHTML)); } hor.addComponent(compLeft); hor.setComponentAlignment(compLeft, Alignment.BOTTOM_RIGHT); hor.addComponent(new Label(" ", Label.CONTENT_XHTML)); final String text2 = Constants.P_ALIGN_RIGHT + labelRight + Constants.P; hor.addComponent(lr = new Label(text2, Label.CONTENT_XHTML)); lr.setSizeUndefined(); lr.setWidth(widthRight + Constants.PX); hor.setComponentAlignment(lr, Alignment.BOTTOM_RIGHT); if (required) { hor.addComponent(new Label(" <span style=\"color:red; position:relative; top:13px;\">*</span>", Label.CONTENT_XHTML)); } else { hor.addComponent(new Label(" ", Label.CONTENT_XHTML)); } hor.addComponent(compRight); hor.setComponentAlignment(compRight, Alignment.BOTTOM_RIGHT); hor.addComponent(new Label(" ")); hor.setSpacing(false); return hor; }
From source file:de.escidoc.admintool.view.util.LayoutHelper.java
License:Open Source License
/** * Helper method for placing components. * //from w ww. j a v a 2 s. com * @param labelLeft * the left (leading) label. * @param labelRight * the right (leading) label. * @param compLeft * the left component. * @param compRight * the right component. * @param width * the width of the label. * @param required * true if the component is required, otherwise false. * @return the customized component placed in a horizontal layout. */ public static synchronized HorizontalLayout create(final String labelLeft, final String labelRight, final Component compLeft, final Component compRight, final int width, final boolean required) { final HorizontalLayout hor = new HorizontalLayout(); hor.setHeight(Constants.DEFAULT_HEIGHT); hor.addComponent(new Label(" ")); final String text = Constants.P_ALIGN_RIGHT + labelLeft + Constants.P; Label ll, lr; hor.addComponent(ll = new Label(text, Label.CONTENT_XHTML)); ll.setSizeUndefined(); ll.setWidth(width + Constants.PX); hor.setComponentAlignment(ll, Alignment.MIDDLE_RIGHT); if (required) { hor.addComponent(new Label(" <span style=\"color:red; position:relative; top:13px;\">*</span>", Label.CONTENT_XHTML)); } else { hor.addComponent(new Label(" ", Label.CONTENT_XHTML)); } hor.addComponent(compLeft); hor.setComponentAlignment(compLeft, Alignment.MIDDLE_RIGHT); hor.addComponent(new Label(" ", Label.CONTENT_XHTML)); final String text2 = Constants.P_ALIGN_RIGHT + labelRight + Constants.P; hor.addComponent(lr = new Label(text2, Label.CONTENT_XHTML)); lr.setSizeUndefined(); lr.setWidth(width + Constants.PX); hor.setComponentAlignment(lr, Alignment.MIDDLE_RIGHT); if (required) { hor.addComponent(new Label(" <span style=\"color:red; position:relative; top:13px;\">*</span>", Label.CONTENT_XHTML)); } else { hor.addComponent(new Label(" ", Label.CONTENT_XHTML)); } hor.addComponent(compRight); hor.setComponentAlignment(compRight, Alignment.BOTTOM_RIGHT); hor.addComponent(new Label(" ")); hor.setSpacing(false); return hor; }
From source file:de.escidoc.admintool.view.util.LayoutHelper.java
License:Open Source License
public static Component foo(final String captionForleftLabel, final String captionForRightLabel, final Label leftLabel, final Label rightLabel, final int widthLeft, final int widthRight, final boolean required) { final HorizontalLayout hLayout = new HorizontalLayout(); hLayout.setHeight("30px"); hLayout.addComponent(new Label(" ")); final Label ll = new Label(Constants.P_ALIGN_RIGHT + captionForleftLabel + Constants.P, Label.CONTENT_XHTML); ll.setSizeUndefined();/* ww w . j a v a2 s . com*/ ll.setWidth(widthLeft + Constants.PX); hLayout.addComponent(ll); hLayout.setComponentAlignment(ll, Alignment.MIDDLE_RIGHT); if (required) { hLayout.addComponent(new Label(" <span style=\"color:red; position:relative; top:13px;\">*</span>", Label.CONTENT_XHTML)); } else { hLayout.addComponent(new Label(" ", Label.CONTENT_XHTML)); } hLayout.addComponent(leftLabel); hLayout.setComponentAlignment(leftLabel, Alignment.BOTTOM_RIGHT); hLayout.addComponent(new Label(" ", Label.CONTENT_XHTML)); Label lr; hLayout.addComponent( lr = new Label(Constants.P_ALIGN_RIGHT + captionForRightLabel + Constants.P, Label.CONTENT_XHTML)); lr.setSizeUndefined(); lr.setWidth(widthRight + Constants.PX); hLayout.setComponentAlignment(lr, Alignment.BOTTOM_RIGHT); if (required) { hLayout.addComponent(new Label(" <span style=\"color:red; position:relative; top:13px;\">*</span>", Label.CONTENT_XHTML)); } else { hLayout.addComponent(new Label(" ", Label.CONTENT_XHTML)); } hLayout.addComponent(rightLabel); hLayout.setComponentAlignment(rightLabel, Alignment.BOTTOM_RIGHT); hLayout.addComponent(new Label(" ")); hLayout.setSpacing(false); return hLayout; }
From source file:de.fatalix.bookery.view.common.BookDetailLayout.java
License:Open Source License
private HorizontalLayout createImageLayout() { image = new Image(); image.setImmediate(true);/*from w w w. j a v a2s . c o m*/ image.setHeight("200px"); image.setWidth("130px"); downloadButton = new Button("download", FontAwesome.DOWNLOAD); downloadButton.addStyleName(ValoTheme.BUTTON_FRIENDLY); downloadButton.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { try { loadData(presenter.updateShared(bookEntry, SecurityUtils.getSubject().getPrincipal().toString())); } catch (SolrServerException | IOException ex) { Notification.show("Unexpected Error!\n" + ex.getMessage(), Notification.Type.ERROR_MESSAGE); logger.error(ex, ex); } } }); fileDownloader = new FileDownloader(new StreamResource(new BookStreamSource(null), "blbla.epub")); fileDownloader.extend(downloadButton); sendToKindleButton = new Button("Kindle", FontAwesome.BOOK); sendToKindleButton.addStyleName(ValoTheme.BUTTON_FRIENDLY); sendToKindleButton.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { try { presenter.shareBookWithKindle(bookEntry, SecurityUtils.getSubject().getPrincipal().toString()); Notification.show("Book is sent to kindle", Notification.Type.HUMANIZED_MESSAGE); loadData(presenter.updateShared(bookEntry, SecurityUtils.getSubject().getPrincipal().toString())); } catch (SolrServerException | IOException | MessagingException ex) { Notification.show("Unexpected Error!\n" + ex.getMessage(), Notification.Type.ERROR_MESSAGE); logger.error(ex, ex); } } }); likeButton = new Button("0 likes", FontAwesome.THUMBS_O_UP); likeButton.addStyleName(ValoTheme.BUTTON_LINK); likeButton.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { try { BookEntry updatedEntry = presenter.updateLike(bookEntry, SecurityUtils.getSubject().getPrincipal().toString()); loadData(updatedEntry); } catch (SolrServerException | IOException ex) { Notification.show("Unexpected Error!\n" + ex.getMessage(), Notification.Type.ERROR_MESSAGE); logger.error(ex, ex); } } }); watchListButton = new Button("merken", FontAwesome.STAR_O); watchListButton.addStyleName(ValoTheme.BUTTON_LINK); watchListButton.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { presenter.addRemoveFromWatchList(bookEntry, SecurityUtils.getSubject().getPrincipal().toString()); loadData(bookEntry); } }); downloadCount = new Label("0 downloads"); VerticalLayout rightLayout = new VerticalLayout(sendToKindleButton, downloadButton, watchListButton, likeButton, downloadCount); rightLayout.setComponentAlignment(downloadCount, Alignment.MIDDLE_CENTER); rightLayout.setSpacing(true); HorizontalLayout layout = new HorizontalLayout(image, rightLayout); layout.setSpacing(true); return layout; }
From source file:de.fatalix.lighty.web.component.field.InlineEditField.java
@Override protected Component initContent() { HorizontalLayout fieldLayout = new HorizontalLayout(); fieldLayout.setSpacing(true); fieldLayout.addComponent(captionLabel); if (editable) { fieldLayout.addComponent(valueTextField); } else {/*from w w w .j a v a 2s . c o m*/ fieldLayout.addComponent(valueLabel); } return fieldLayout; }
From source file:de.gedoplan.webclients.vaadin.views.CustomerDetailView.java
public void init() { Double discount = customerService.calculateCustomerDiscount(customer.getCustomerID()).getDiscount(); Label name = new Label(new PropertyFormatter(form.getProperty(Customer_.companyName)) { @Override/* ww w . j a v a 2 s.com*/ public String format(Object value) { return value + " (" + customer.getCustomerID() + ")"; } @Override public Object parse(String formattedValue) throws Exception { throw new UnsupportedOperationException("Not supported yet."); } }); name.setStyleName(ValoTheme.LABEL_BOLD); Label rabattLabel = new Label(Messages.customer_discount.value()); rabattLabel.setStyleName(ValoTheme.LABEL_BOLD); rabattLabel.setSizeUndefined(); Label rabatt = new Label(new DecimalFormat("#0.00").format(discount) + "%"); rabatt.setSizeUndefined(); rabatt.addStyleName(ValoTheme.LABEL_COLORED); rabatt.addStyleName(ValoTheme.LABEL_BOLD); HorizontalLayout headline = new HorizontalLayout(name, rabattLabel, rabatt); headline.setComponentAlignment(rabatt, Alignment.TOP_RIGHT); headline.setExpandRatio(name, 1); headline.setWidth(100, Unit.PERCENTAGE); headline.setSpacing(true); headline.setStyleName(ValoTheme.LAYOUT_WELL); headline.setMargin(new MMarginInfo(false, true)); Panel panel = new Panel(); panel.setContent(form); setMargin(true); setSpacing(true); addComponents(headline, panel); }
From source file:de.informera.dev.nutchManager.MyVaadinApplication.java
License:Apache License
@Override public void init() { File settings_folder = new File(System.getProperty("user.home") + "/.nutchManager"); if (!settings_folder.isDirectory()) { settings_folder.mkdir();//from www . j a v a 2 s .c o m new File(settings_folder.getAbsolutePath() + "/backups").mkdir(); new File(settings_folder.getAbsolutePath() + "/instances").mkdir(); } window = new Window("nutchManager"); setMainWindow(window); this.setTheme("nutchManager"); final HorizontalLayout technologies = new HorizontalLayout(); technologies.setSpacing(true); technologies.addComponent(new Embedded("", new ThemeResource("images/nutch_logo_tm.gif"))); technologies.addComponent(new Embedded("", new ThemeResource("images/vaadin.png"))); final MenuBar mainMenu = new MenuBar(); mainMenu.setWidth("100%"); MenuItem menuFile = mainMenu.addItem("File", null, null); MenuItem subMenuFile = menuFile.addItem("Add new instance", null, null); // Define a common menu command for all the menu items. MenuBar.Command addNewInstanceFromMenu = new MenuBar.Command() { public void menuSelected(MenuItem selectedItem) { window.removeAllComponents(); window.addComponent(technologies); window.addComponent(mainMenu); window.addWindow(new AddInstanceDialog()); } }; subMenuFile.setCommand(addNewInstanceFromMenu); window.addComponent(technologies); window.addComponent(mainMenu); // Begin the checkout of an old configuration // Check waether configuration has entries for nutch instances or not // File settings_folder = new File( this.getClass().getClassLoader().getResource("/instance_conf").getPath() ); File instances_folder = new File(settings_folder + "/instances"); // If not: prompt to add an instance if (instances_folder.list().length < 1) { window.showNotification("ERROR", "No previous configuration found. Please add a nutch instance.", Notification.TYPE_ERROR_MESSAGE); Window addInstance = new AddInstanceDialog(); window.addWindow(addInstance); } else { window.addComponent(new InstanceSelectionView()); } }
From source file:de.kaiserpfalzEdv.vaadin.menu.impl.MenuImpl.java
License:Apache License
@Inject public MenuImpl(final Authenticator accessControl, final EventBus bus, final I18NHandler i18n, final List<View> allViews) { this.accessControl = accessControl; this.bus = bus; this.i18n = i18n; this.allViews = allViews; setPrimaryStyleName(ValoTheme.MENU_ROOT); menuPart = new CssLayout(); menuPart.addStyleName(ValoTheme.MENU_PART); // header of the menu final HorizontalLayout top = new HorizontalLayout(); top.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT); top.addStyleName(ValoTheme.MENU_TITLE); top.setSpacing(true); Label title = new Label(translate("application.name")); title.addStyleName(ValoTheme.LABEL_H3); title.setSizeUndefined();//from ww w.j a v a2 s . c om Image image = new Image(null, new ThemeResource("img/table-logo.png")); image.setStyleName("logo"); top.addComponent(image); top.addComponent(title); menuPart.addComponent(top); // logout menu item MenuBar logoutMenu = new MenuBar(); logoutMenu.addItem(translate("button.logout.caption"), FontAwesome.valueOf(translate("button.logout.icon")), selectedItem -> { VaadinSession.getCurrent().getSession().invalidate(); Page.getCurrent().reload(); }); logoutMenu.addStyleName("user-menu"); menuPart.addComponent(logoutMenu); // button for toggling the visibility of the menu when on a small screen final Button showMenu = new Button(translate("application.name"), new ClickListener() { @Override public void buttonClick(final ClickEvent event) { if (menuPart.getStyleName().contains(VALO_MENU_VISIBLE)) { menuPart.removeStyleName(VALO_MENU_VISIBLE); } else { menuPart.addStyleName(VALO_MENU_VISIBLE); } } }); showMenu.addStyleName(ValoTheme.BUTTON_PRIMARY); showMenu.addStyleName(ValoTheme.BUTTON_SMALL); showMenu.addStyleName(VALO_MENU_TOGGLE); showMenu.setIcon(FontAwesome.NAVICON); menuPart.addComponent(showMenu); // container for the navigation buttons, which are added by addView() menuItemsLayout = new CssLayout(); menuItemsLayout.setPrimaryStyleName(VALO_MENUITEMS); menuPart.addComponent(menuItemsLayout); addComponent(menuPart); }
From source file:de.pge.tutorial.vaadin.customer.CustomerForm.java
public CustomerForm(MyUI myUI) { this.myUI = myUI; status.addItems(CustomerStatus.values()); save.setStyleName(ValoTheme.BUTTON_PRIMARY); save.setClickShortcut(KeyCode.ENTER); setSizeUndefined();/*from ww w . j a va2 s . c om*/ HorizontalLayout buttons = new HorizontalLayout(save, delete); buttons.setSpacing(true); save.addClickListener(e -> this.save()); delete.addClickListener(e -> this.delete()); addComponents(firstName, lastName, email, status, birthdate, buttons); }