List of usage examples for com.vaadin.ui HorizontalLayout setMargin
@Override public void setMargin(boolean enabled)
From source file:org.investovator.ui.nngaming.DashboardPlayingView.java
License:Open Source License
private void createUI() { //Setup Layout content = new VerticalLayout(); content.setDefaultComponentAlignment(Alignment.MIDDLE_CENTER); HorizontalLayout row1 = new HorizontalLayout(); HorizontalLayout row2 = new HorizontalLayout(); HorizontalLayout row3 = new HorizontalLayout(); row1.setWidth("100%"); row2.setWidth("100%"); row3.setWidth("100%"); row1.setHeight(50, Unit.PERCENTAGE); row2.setHeight(20, Unit.PERCENTAGE); row3.setHeight(30, Unit.PERCENTAGE); row1.setMargin(new MarginInfo(true, true, false, true)); row2.setMargin(new MarginInfo(true, true, false, true)); row3.setMargin(new MarginInfo(true, true, true, true)); content.addComponent(row1);//from www. j a va2s . c o m content.addComponent(row2); content.addComponent(row3); currentPriceChart = new BasicChart(); quantityChart = new QuantityChart(); orderBookSell = getSellSideTable(); orderBookSell.addStyleName("center-caption"); orderBookBuy = getBuySideTable(); orderBookBuy.addStyleName("center-caption"); quoteUI = new QuoteUI(); userPortfolio = new UserPortfolio(); HorizontalLayout orderBookLayout = new HorizontalLayout(); orderBookLayout.setWidth("100%"); orderBookLayout.addComponent(orderBookSell); orderBookLayout.addComponent(orderBookBuy); orderBookLayout.setComponentAlignment(orderBookSell, Alignment.MIDDLE_RIGHT); orderBookLayout.setComponentAlignment(orderBookBuy, Alignment.MIDDLE_LEFT); VerticalLayout orderBook = new VerticalLayout(); orderBook.addComponent(orderBookLayout); orderBook.setCaption("Order Book"); quoteUI.setCaption("Quote UI"); userPortfolio.setCaption(Session.getCurrentUser().toUpperCase(Locale.US) + " - Portfolio Summary"); orderBook.addStyleName("center-caption"); quoteUI.addStyleName("center-caption"); userPortfolio.addStyleName("center-caption"); row1.addComponent(currentPriceChart); row2.addComponent(quantityChart); row3.setSpacing(true); row3.addComponent(orderBook); row3.addComponent(quoteUI); row3.addComponent(userPortfolio); row3.setExpandRatio(orderBook, 1.2f); row3.setExpandRatio(quoteUI, 1.0f); row3.setExpandRatio(userPortfolio, 1.0f); row1.setComponentAlignment(currentPriceChart, Alignment.MIDDLE_CENTER); row2.setComponentAlignment(quantityChart, Alignment.MIDDLE_CENTER); content.setSizeFull(); this.setContent(content); }
From source file:org.investovator.ui.utils.dashboard.dataplayback.BasicMainView.java
License:Open Source License
public void setupPanel() { //clear everything // content.removeAllComponents(); //add components only if components have not already been added if (content.getComponentCount() == 0) { //Main chart HorizontalLayout chartContainer = new HorizontalLayout(); chartContainer.setWidth(95, Unit.PERCENTAGE); chartContainer.setMargin(true); // chartContainer.setHeight(30,Unit.PERCENTAGE); mainChart = buildMainChart();//w w w . j av a 2 s.c om chartContainer.addComponent(mainChart); chartContainer.setComponentAlignment(mainChart, Alignment.MIDDLE_CENTER); chartContainer.setCaption(mainChart.getCaption()); // chartContainer.setCaption("Price"); // chartContainer.addStyleName("center-caption"); content.addComponent(chartContainer); content.setExpandRatio(chartContainer, 1.3f); content.setComponentAlignment(chartContainer, Alignment.MIDDLE_CENTER); //Quantity chart HorizontalLayout quantityChartContainer = new HorizontalLayout(); quantityChartContainer.setWidth(95, Unit.PERCENTAGE); // quantityChartContainer.setMargin(true); quantityChartContainer.setMargin(new MarginInfo(true, true, false, true)); // quantityChartContainer.setHeight(30,Unit.PERCENTAGE); quantityChart = buildQuantityChart(); quantityChartContainer.addComponent(quantityChart); quantityChartContainer.setComponentAlignment(quantityChart, Alignment.MIDDLE_CENTER); // quantityChartContainer.setCaption("Quantity"); // quantityChartContainer.addStyleName("center-caption"); content.addComponent(quantityChartContainer); content.setExpandRatio(quantityChartContainer, 1.0f); content.setComponentAlignment(quantityChartContainer, Alignment.MIDDLE_CENTER); //bottom row conatainer HorizontalLayout bottowRow = new HorizontalLayout(); bottowRow.setWidth(100, Unit.PERCENTAGE); content.addComponent(bottowRow); content.setExpandRatio(bottowRow, 1.0f); //Stock price table GridLayout stockPriceTableContainer = new GridLayout(1, 2); //add a caption to the table // Label tableCaption=new Label("Stock Price Table"); // stockPriceTableContainer.addComponent(tableCaption, 0, 0); // stockPriceTableContainer.setComponentAlignment(tableCaption,Alignment.MIDDLE_RIGHT); stockPriceTable = setupStockPriceTable(); stockPriceTableContainer.addComponent(stockPriceTable, 0, 1); stockPriceTableContainer.setMargin(new MarginInfo(false, true, true, true)); stockPriceTableContainer.setCaption("Stock Price Table"); stockPriceTableContainer.addStyleName("center-caption"); stockPriceTableContainer.setComponentAlignment(stockPriceTable, Alignment.MIDDLE_CENTER); bottowRow.addComponent(stockPriceTableContainer); // bottowRow.setExpandRatio(stockPriceTableContainer,1.0f); //buy-sell window GridLayout buySellWindowContainer = new GridLayout(1, 2); // //add a caption to the table // Label buySellWindowCaption=new Label("Buy/Sell Stocks"); // buySellWindowContainer.addComponent(buySellWindowCaption,0,0); // buySellWindowContainer.setComponentAlignment(buySellWindowCaption,Alignment.MIDDLE_CENTER); Component buySellWindow = setupBuySellForm(); buySellWindowContainer.addComponent(buySellWindow, 0, 1); buySellWindowContainer.setMargin(new MarginInfo(false, false, true, false)); buySellWindowContainer.setCaption("Buy/Sell Stocks"); buySellWindowContainer.addStyleName("center-caption"); buySellWindowContainer.setComponentAlignment(buySellWindow, Alignment.MIDDLE_CENTER); bottowRow.addComponent(buySellWindowContainer); // bottowRow.setExpandRatio(buySellWindowContainer,1.0f); //portfolio data // VerticalLayout myPortfolioLayout=new VerticalLayout(); // myPortfolioLayout.setMargin(new MarginInfo(false,true,true,true)); // bottowRow.addComponent(myPortfolioLayout); //add a caption to the table // Label portfolioCaption=new Label("My Portfolio"); // myPortfolioLayout.addComponent(portfolioCaption); // myPortfolioLayout.setComponentAlignment(portfolioCaption,Alignment.MIDDLE_CENTER); HorizontalLayout portfolioContainer = new HorizontalLayout(); portfolioContainer.setMargin(new MarginInfo(false, true, true, true)); portfolioContainer.setCaption("My Portfolio"); portfolioContainer.addStyleName("center-caption"); bottowRow.addComponent(portfolioContainer); // bottowRow.setExpandRatio(portfolioContainer,1.0f); //portfolio table portfolioTable = setupPortfolioTable(); portfolioContainer.addComponent(portfolioTable); // portfolioContainer.setExpandRatio(portfolioTable,1.0f); //profit chart // HorizontalLayout profitContainer = new HorizontalLayout(); // bottowRow.addComponent(profitContainer); profitChart = setupProfitChart(); profitChart.setCaption("Profit Chart"); profitChart.addStyleName("center-caption"); bottowRow.addComponent(profitChart); bottowRow.setExpandRatio(profitChart, 1.3f); // Component accountInfo=setUpAccountInfoForm(); // accountInfo.setCaption("Profit Chart"); // accountInfo.addStyleName("center-caption"); // // bottowRow.addComponent(accountInfo); // bottowRow.setExpandRatio(accountInfo,1.3f); this.setContent(content); } }
From source file:org.jdal.vaadin.auth.LoginView.java
License:Apache License
@Override protected Component buildPanel() { Label greeting = new Label(getMessage("loginView.greeting")); greeting.addStyleName("jd-login-greeting"); greeting.addStyleName(Reindeer.LABEL_H2); Label applicationNameLabel = new Label(getMessage(applicationName)); applicationNameLabel.addStyleName("jd-login-appname"); applicationNameLabel.addStyleName(Reindeer.LABEL_H2); applicationNameLabel.setSizeUndefined(); loginButton.addClickListener(this); loginButton.setCaption(getMessage("loginView.loginButtonCaption")); loginButton.addStyleName("jd-login-button"); // add shortcut listener for enter key loginButton.addShortcutListener(new ShortcutListener("Sign In", KeyCode.ENTER, null) { @Override//from www .j a v a2s .c o m public void handleAction(Object sender, Object target) { loginButton.click(); } }); Image image = null; HorizontalLayout imageWrapper = null; if (applicationIcon != null) { image = new Image(null, applicationIcon); image.setSizeUndefined(); image.setStyleName("jd-login-icon"); imageWrapper = new HorizontalLayout(); imageWrapper.setMargin(false); imageWrapper.addComponent(image); imageWrapper.setComponentAlignment(image, Alignment.MIDDLE_CENTER); } BoxFormBuilder fb = new BoxFormBuilder(); fb.setDefaultWidth(BoxFormBuilder.SIZE_FULL); fb.row(); fb.startBox(); fb.setFixedHeight(); fb.row(false); fb.add(greeting, Alignment.TOP_LEFT); fb.add(applicationNameLabel, Alignment.TOP_RIGHT); fb.endBox(); // add application icon if (image != null) { fb.row(BoxFormBuilder.SIZE_FULL); fb.add(imageWrapper, BoxFormBuilder.SIZE_FULL, Alignment.MIDDLE_CENTER); } fb.row(); fb.startBox(); fb.row(30); fb.add(errorLabel, BoxFormBuilder.SIZE_FULL, Alignment.BOTTOM_CENTER); fb.endBox(); fb.row(); fb.startBox(); fb.setFixedHeight(); fb.row(); fb.add(username, getMessage("loginView.username"), Alignment.BOTTOM_CENTER); fb.add(password, getMessage("loginView.password"), Alignment.BOTTOM_CENTER); fb.add(loginButton, 100, Alignment.BOTTOM_CENTER); fb.endBox(); Component form = fb.getForm(); form.setWidth(this.getWidth(), Unit.PIXELS); form.setHeight(getHeight(), Unit.PIXELS); form.setStyleName("jd-login"); return form; }
From source file:org.jdal.vaadin.ui.form.BoxFormBuilder.java
License:Apache License
/** * @return the form//from www .ja v a 2 s.co m */ public Component getForm() { HorizontalLayout form = (HorizontalLayout) builder.getForm(); form.setMargin(margin); return form; }
From source file:org.jpos.qi.ConfirmDialog.java
License:Open Source License
public ConfirmDialog(String caption, String question, String confirm, String cancel, Callback callback) { super(caption); setModal(true);/*w ww. ja va 2 s . co m*/ setResizable(false); VerticalLayout content = new VerticalLayout(); content.setMargin(true); content.setSpacing(true); setContent(content); this.yes.setCaption(confirm); this.yes.addStyleName(ValoTheme.BUTTON_PRIMARY); this.no.setCaption(cancel); this.callback = callback; // HTML is safe to assume and allows for line breaks and other stuff // We can always escape HTML special chars Label questionLabel = new Label(question, ContentMode.HTML); questionLabel.setCaptionAsHtml(true); if (question != null) { content.addComponent(questionLabel); } HorizontalLayout hl = new HorizontalLayout(); hl.setMargin(new MarginInfo(true, false, false, false)); hl.setSpacing(true); hl.setWidth("100%"); hl.addComponent(yes); hl.setComponentAlignment(yes, Alignment.MIDDLE_CENTER); hl.addComponent(no); hl.setComponentAlignment(no, Alignment.MIDDLE_CENTER); content.addComponent(hl); }
From source file:org.jpos.qi.eeuser.ConsumersView.java
License:Open Source License
private HorizontalLayout createUserPanel() { HorizontalLayout hl = new HorizontalLayout(); hl.setMargin(new MarginInfo(false, true, true, true)); hl.setSpacing(true);// w w w. j av a 2 s . c o m userComboBox = createUserBox(); userComboBox.setStyleName(ValoTheme.COMBOBOX_SMALL); userComboBox.addValueChangeListener(listener -> { ConfigurableFilterDataProvider wrapper = (ConfigurableFilterDataProvider) getGrid().getDataProvider(); wrapper.setFilter(listener.getValue()); this.selectedUser = listener.getValue(); wrapper.refreshAll(); }); hl.addComponent(userComboBox); return hl; }
From source file:org.jpos.qi.login.LoginView.java
License:Open Source License
private HorizontalLayout createTitle() { HorizontalLayout labels = new HorizontalLayout(); labels.setWidth("100%"); labels.setMargin(new MarginInfo(false, false, true, false)); labels.addStyleName("labels"); Label title = new Label(app.getMessage("login.title")); title.setSizeUndefined();//from w w w. j av a 2 s. c om title.addStyleName(ValoTheme.LABEL_H4); title.addStyleName(ValoTheme.LABEL_COLORED); labels.addComponent(title); labels.setComponentAlignment(title, Alignment.BOTTOM_LEFT); Embedded logo = new Embedded("", QIResources.JPOS_LOGO); logo.setHeight("80px"); labels.addComponent(logo); labels.setComponentAlignment(logo, Alignment.TOP_RIGHT); return labels; }
From source file:org.jpos.qi.minigl.TransactionsView.java
License:Open Source License
private HorizontalLayout createFilters() { HorizontalLayout controls = new HorizontalLayout(); controls.setWidth("100%"); journals = new JournalsCombo(true); journals.setValue(journals.getDataProvider().fetch(new Query<>()).findFirst().orElse(null)); controls.addComponents(journals, dateRangeComponent); controls.setComponentAlignment(dateRangeComponent, Alignment.MIDDLE_LEFT); controls.setComponentAlignment(journals, Alignment.MIDDLE_RIGHT); controls.setExpandRatio(journals, 0f); controls.setExpandRatio(dateRangeComponent, 1f); controls.setMargin(new MarginInfo(false, true, true, true)); controls.setSpacing(true);// ww w. j a v a2s . com return controls; }
From source file:org.jpos.qi.QIEntityView.java
License:Open Source License
protected HorizontalLayout createHeader(String title) { HorizontalLayout header = new HorizontalLayout(); header.setWidth("100%"); header.setSpacing(false);//from ww w. j a v a 2 s.co m header.setMargin(new MarginInfo(false, true, false, true)); Label lbl = new Label(title); lbl.addStyleName("h2"); lbl.setSizeUndefined(); lbl.setContentMode(ContentMode.HTML); header.addComponent(lbl); header.setComponentAlignment(lbl, Alignment.MIDDLE_LEFT); if (isGeneralView() && canAdd()) { Button addBtn = new Button(getApp().getMessage("add")); addBtn.addStyleName("borderless-colored"); addBtn.setIcon(VaadinIcons.PLUS); addBtn.addClickListener(event -> navigateToNewRoute()); header.addComponent(addBtn); header.setComponentAlignment(addBtn, Alignment.BOTTOM_RIGHT); } return header; }
From source file:org.jpos.qi.QIEntityView.java
License:Open Source License
public Layout createForm(final Object entity, String[] params, boolean isNew) { VerticalLayout profileLayout = new VerticalLayout(); profileLayout.setMargin(true);//from ww w . ja va 2s.c om profileLayout.setSpacing(true); //Add Back Button if (params.length <= 1 || !"profile".equals(params[1])) { Button back = new Button(getApp().getMessage("back")); back.addStyleName("borderless-colored"); back.setIcon(VaadinIcons.ARROW_LEFT); back.addClickListener(event -> app.getNavigator().navigateTo(getGeneralRoute())); profileLayout.addComponent(back); profileLayout.setComponentAlignment(back, Alignment.MIDDLE_LEFT); } binder = new Binder<T>(clazz) { @Override public void setReadOnly(boolean readOnly) { super.setReadOnly(readOnly); if (readOnlyFields != null) { for (String fieldId : readOnlyFields) { if (binder.getBinding(fieldId).isPresent()) { HasValue field = binder.getBinding(fieldId).get().getField(); if ((field != null && !field.isEmpty()) || !field.isRequiredIndicatorVisible()) { field.setReadOnly(true); binder.bind(field, fieldId); } } } } } }; bean = (T) entity; final Layout formLayout = createLayout(); getHelper().setOriginalEntity(bean); binder.readBean((T) entity); binder.setReadOnly(true); profileLayout.addComponent(formLayout); HorizontalLayout footer = new HorizontalLayout(); footer.addStyleName("footer"); footer.setMargin(new MarginInfo(true, false, false, false)); footer.setSpacing(true); formLayout.addComponent(footer); //Add Save, Remove & Cancel Buttons editBtn = new Button(app.getMessage("edit")); removeBtn = new Button(app.getMessage("remove")); saveBtn = new Button(app.getMessage("save")); cancelBtn = new Button(app.getMessage("cancel")); editBtn.addClickListener(event -> editClick(event, formLayout)); editBtn.addStyleName("icon-edit"); saveBtn.addClickListener(event -> saveClick(event, formLayout)); saveBtn.setVisible(false); saveBtn.setStyleName("icon-ok"); saveBtn.setClickShortcut(ShortcutAction.KeyCode.ENTER); removeBtn.addClickListener(event -> app.addWindow(new ConfirmDialog(app.getMessage("confirmTitle"), app.getMessage("removeConfirmationMessage"), confirm -> { if (confirm) { removeEntity(); } }))); removeBtn.addStyleName("icon-trash"); cancelBtn.addClickListener(event -> { if (isNew) { app.getNavigator().navigateTo(getGeneralRoute()); } else { cancelClick(event, formLayout); } }); cancelBtn.setClickShortcut(ShortcutAction.KeyCode.ESCAPE); cancelBtn.setVisible(false); cancelBtn.addStyleName("icon-cancel"); if (canEdit()) { footer.addComponent(editBtn); footer.addComponent(saveBtn); footer.addComponent(cancelBtn); footer.setComponentAlignment(editBtn, Alignment.MIDDLE_RIGHT); footer.setComponentAlignment(saveBtn, Alignment.MIDDLE_RIGHT); footer.setComponentAlignment(cancelBtn, Alignment.MIDDLE_RIGHT); } if (canRemove()) { footer.addComponent(removeBtn); footer.setComponentAlignment(removeBtn, Alignment.MIDDLE_RIGHT); } if (isNew) { editBtn.click(); } errorLabel = new Label(); errorLabel.setVisible(false); errorLabel.setStyleName(ValoTheme.LABEL_FAILURE); profileLayout.addComponent(errorLabel); return profileLayout; }