List of usage examples for com.vaadin.ui HorizontalLayout setExpandRatio
public void setExpandRatio(Component component, float ratio)
This method is used to control how excess space in layout is distributed among components.
From source file:com.skysql.manager.ui.UsersSettings.java
License:Open Source License
/** * Removes the user./* www. ja va 2 s . c om*/ * * @param event the event */ public void removeUser(Button.ClickEvent event) { secondaryDialog = new ModalWindow("Delete User", null); UI.getCurrent().addWindow(secondaryDialog); secondaryDialog.addCloseListener(this); final VerticalLayout formContainer = new VerticalLayout(); formContainer.setMargin(new MarginInfo(true, true, false, true)); formContainer.setSpacing(false); final Form form = new Form(); formContainer.addComponent(form); form.setFooter(null); form.setDescription("Delete user " + userInfo.completeNamesByID(selectedUserID) + " from the system"); HorizontalLayout buttonsBar = new HorizontalLayout(); buttonsBar.setStyleName("buttonsBar"); buttonsBar.setSizeFull(); buttonsBar.setSpacing(true); buttonsBar.setMargin(true); buttonsBar.setHeight("49px"); Label filler = new Label(); buttonsBar.addComponent(filler); buttonsBar.setExpandRatio(filler, 1.0f); Button cancelButton = new Button("Cancel"); buttonsBar.addComponent(cancelButton); buttonsBar.setComponentAlignment(cancelButton, Alignment.MIDDLE_RIGHT); cancelButton.addClickListener(new Button.ClickListener() { private static final long serialVersionUID = 0x4C656F6E6172646FL; public void buttonClick(ClickEvent event) { form.discard(); secondaryDialog.close(); } }); Button okButton = new Button("Delete User"); okButton.addClickListener(new Button.ClickListener() { private static final long serialVersionUID = 0x4C656F6E6172646FL; public void buttonClick(ClickEvent event) { try { form.setComponentError(null); form.commit(); boolean success = userInfo.deleteUser(selectedUserID); if (success) { select.removeItem(selectedUserID); } else { return; } } catch (EmptyValueException e) { return; } catch (Exception e) { ManagerUI.error(e.getMessage()); return; } secondaryDialog.close(); } }); buttonsBar.addComponent(okButton); buttonsBar.setComponentAlignment(okButton, Alignment.MIDDLE_RIGHT); VerticalLayout windowLayout = (VerticalLayout) secondaryDialog.getContent(); windowLayout.setSpacing(false); windowLayout.setMargin(false); windowLayout.addComponent(formContainer); windowLayout.addComponent(buttonsBar); }
From source file:com.skysql.manager.ui.WarningWindow.java
License:Open Source License
/** * Instantiates a new warning window.//from ww w .j a va 2s. co m * * @param caption the caption * @param message the message * @param label the label * @param okListener the ok listener */ public WarningWindow(String caption, String message, String label, Button.ClickListener okListener) { super(caption, "60%"); HorizontalLayout wrapper = new HorizontalLayout(); wrapper.setWidth("100%"); wrapper.setMargin(true); VerticalLayout iconLayout = new VerticalLayout(); iconLayout.setWidth("100px"); wrapper.addComponent(iconLayout); Embedded image = new Embedded(null, new ThemeResource("img/warning.png")); iconLayout.addComponent(image); VerticalLayout textLayout = new VerticalLayout(); textLayout.setSizeFull(); wrapper.addComponent(textLayout); wrapper.setExpandRatio(textLayout, 1.0f); Label msgLabel = new Label(message); msgLabel.addStyleName("warning"); textLayout.addComponent(msgLabel); textLayout.setComponentAlignment(msgLabel, Alignment.MIDDLE_CENTER); HorizontalLayout buttonsBar = new HorizontalLayout(); buttonsBar.setStyleName("buttonsBar"); buttonsBar.setSizeFull(); buttonsBar.setSpacing(true); buttonsBar.setMargin(true); buttonsBar.setHeight("49px"); Label filler = new Label(); buttonsBar.addComponent(filler); buttonsBar.setExpandRatio(filler, 1.0f); Button cancelButton = new Button("Cancel"); buttonsBar.addComponent(cancelButton); buttonsBar.setComponentAlignment(cancelButton, Alignment.MIDDLE_RIGHT); cancelButton.addClickListener(new Button.ClickListener() { private static final long serialVersionUID = 0x4C656F6E6172646FL; public void buttonClick(Button.ClickEvent event) { warningWindow.close(); } }); Button okButton = new Button(label); okButton.addClickListener(okListener); buttonsBar.addComponent(okButton); buttonsBar.setComponentAlignment(okButton, Alignment.MIDDLE_RIGHT); VerticalLayout windowLayout = (VerticalLayout) this.getContent(); windowLayout.setSpacing(false); windowLayout.setMargin(false); windowLayout.addComponent(wrapper); windowLayout.addComponent(buttonsBar); }
From source file:com.snowy.Chat.java
public Chat(int id, data d) { this.d = d;//from w w w . j a va 2 s .c o m this.id = id; tf.setSizeFull(); //ts = d.getCurrentSqlTimestamp(); //Logger.getLogger(Chat.class).info(ts.toString()); //tA.setValue("hello\n"); lastMessageId = d.lastMessageIdFromCurrent(id); HorizontalLayout fl = new HorizontalLayout(); fl.addComponent(tf); Button b = new Button("Send"); fl.addComponent(b); tf.setSizeFull(); fl.setExpandRatio(tf, 1); b.addClickListener(e -> { if (tf.getValue().length() != 0) { d.sendMessage(id, (tf.getValue().length() < 200 ? tf.getValue() : tf.getValue().substring(0, 199))); tf.clear(); } }); /*tf.addTextChangeListener(e->{ Logger.getLogger(Chat.class).info(e.getText().charAt(e.getText().length()-1)+""); if(e.getText().charAt(e.getText().length()-1)==10){ b.click(); } });*/ tf.addFocusListener(new FocusListener() { @Override public void focus(final FocusEvent event) { b.setClickShortcut(KeyCode.ENTER); } }); tf.addBlurListener(new BlurListener() { @Override public void blur(final BlurEvent event) { b.removeClickShortcut(); } }); fl.setSizeFull(); fl.setHeightUndefined(); tA.setSizeFull(); //tA.setReadOnly(true); tf.setHeightUndefined(); tA.setWordwrap(true); tA.setImmediate(true); this.addComponent(tA); this.addComponent(fl); this.setExpandRatio(tA, 2); tA.setReadOnly(true); //this.setExpandRatio(fl, 0); this.setSizeFull(); }
From source file:com.snowy.PostLoginView.java
@PostConstruct void init() {/*from w w w . j av a2s . co m*/ //Logger.getLogger(PostLoginView.class.getName()).info(d); d = ((MyVaadinUI) UI.getCurrent()).getDataObject(); //Logger.getLogger(PostLoginView.class.getName()).info(d); g = new GameWindow(d); c = new ChatWindow(d); HorizontalLayout hl = new HorizontalLayout(); setMargin(true); /*this.getUI().addPollListener(new UIEvents.PollListener(){ @Override public void poll(UIEvents.PollEvent event) { c.getUsersList().retrieveActiveUsers(); } });*/ this.setSizeFull(); Button b = new Button("Logout"); b.addClickListener(e -> { d.logout(VaadinSession.getCurrent().getCsrfToken()); VaadinSession.getCurrent().close(); Page.getCurrent().setLocation("/"); }); Button ccc = new Button("Unpause polling"); ccc.setEnabled(false); Button cc = new Button("Pause polling"); cc.addClickListener(e -> { if (ccc.isEnabled() == false) { UI.getCurrent().setPollInterval(1000000000); cc.setEnabled(false); ccc.setEnabled(true); } }); ccc.addClickListener(e -> { if (cc.isEnabled() == false) { UI.getCurrent().setPollInterval(1000); cc.setEnabled(true); ccc.setEnabled(false); } }); hl.setSizeFull(); hl.setSpacing(true); //whdjwandjawd //this.addComponent(cc); //this.addComponent(ccc); this.addComponent(b); //this.setHeightUndefined(); this.setSpacing(true); this.setComponentAlignment(b, Alignment.TOP_RIGHT); //this.addComponent(c); //this.addComponent(ul); hl.addComponent(g); hl.addComponent(c); //this.addComponent(c); hl.setExpandRatio(c, 1); hl.setExpandRatio(g, 3); g.setSizeFull(); c.setSizeFull(); this.addComponent(hl); //this.setExpandRatio(g, 2); this.setExpandRatio(hl, 1); }
From source file:com.squadd.chat.ChatController.java
public HorizontalLayout createChatLineFrom(ChatMessage message) { HorizontalLayout chatLine = new HorizontalLayout(); Panel messagePanel = createMessagePanel(message); Panel photoPanel = createPhotoPanel(userFromImageEmbedded); //FormLayout photoPanel = createPhotoLayout(userFromImageEmbedded); HorizontalLayout dateLayout = createDateLayout(message); chatLine.addComponents(photoPanel, messagePanel, dateLayout); chatLine.setExpandRatio(messagePanel, 1); chatLine.setComponentAlignment(dateLayout, Alignment.BOTTOM_CENTER); //chatLine.setWidth("900px"); //chatLine.setMargin(true); return chatLine; }
From source file:com.squadd.chat.ChatController.java
public HorizontalLayout createChatLineTo(ChatMessage message) { HorizontalLayout chatLine = new HorizontalLayout(); Panel messagePanel = createMessagePanel(message); Panel photoPanel = createPhotoPanel(userToImageEmbedded); //FormLayout photoPanel = createPhotoLayout(userToImageEmbedded); HorizontalLayout dateLayout = createDateLayout(message); chatLine.addComponents(dateLayout, messagePanel, photoPanel); chatLine.setExpandRatio(messagePanel, 1); //chatLine.setWidth("900px"); chatLine.setComponentAlignment(dateLayout, Alignment.BOTTOM_CENTER); //chatLine.setMargin(false); return chatLine; }
From source file:com.squadd.javaBeans.ChatMessage.java
public static HorizontalLayout createChatLine2(ChatMessage message, ChatView view) { Integer from = message.getIdFrom(); Integer to = message.getIdTo(); String body = message.getBody(); HorizontalLayout chatLine = new HorizontalLayout(); String formattedDate = message.getFormattedDate(); Label timeLabel = new Label(formattedDate); timeLabel.setWidth("10%"); chatLine.addComponent(timeLabel);//from w ww. j av a 2s .c o m Label nameLabel = new Label(from + ": "); nameLabel.setWidth("15%"); chatLine.addComponent(nameLabel); Label messageLabel = new Label(body); chatLine.addComponent(messageLabel); chatLine.setExpandRatio(messageLabel, 1); return chatLine; }
From source file:com.studiodojo.qwikinvoice.QwikInvoiceApplication.java
License:Apache License
@Override public void init() { this.mainWindow = new Window( "QwikInvoice CRM Tools - Developed by StudioDojo. Engineered by Vaadin. Powered by Google."); setMainWindow(mainWindow);/* w ww . j av a2 s .co m*/ // // Check if a user is logged in // UserService us = UserServiceFactory.getUserService(); this.logoutURL = us.createLogoutURL(super.getURL().toExternalForm()); if (us.getCurrentUser() == null || us.getCurrentUser().getEmail() == null) { super.setLogoutURL(logoutURL); super.close(); return; } String login = us.getCurrentUser().getEmail(); this.userKey = KeyFactory.createKey(TokenBean.class.getSimpleName(), us.getCurrentUser().getEmail()); // Key ucKey = KeyFactory.createKey(UserCompanyBean.class.getSimpleName(), us.getCurrentUser().getEmail()); UserCompanyBean ucBean = UserDAO.getUserCompanyBean(us.getCurrentUser().getEmail()); this.theSession = new SessionBean(login, ucBean); // // SETUP WORKING AREA // HorizontalLayout appLayout = new HorizontalLayout(); appLayout.setSizeFull(); // The Main Layout VerticalLayout mainLayout = new VerticalLayout(); mainLayout.setWidth(APP_WIDTH); mainLayout.setHeight(APP_HEIGHT); appLayout.addComponent(mainLayout); appLayout.setComponentAlignment(mainLayout, Alignment.TOP_CENTER); appLayout.setExpandRatio(mainLayout, 2); // // Setup Header (Welcome Message) // Label welcome = new Label( "<h1>QWIK!NVOICE</h1> You are " + (us.isUserLoggedIn() ? "logged in" : "logged out") + " as <b>" + us.getCurrentUser().getNickname() + "</b>", Label.CONTENT_XHTML); mainLayout.addComponent(welcome); mainLayout.setComponentAlignment(welcome, Alignment.TOP_LEFT); // // Menu Bar // MenuBar menuBar = new MenuBar(); menuBar.setWidth(APP_WIDTH); MenuBar.MenuItem fileMenuItem = menuBar.addItem("File", null, null); MenuItem newMenuItem = fileMenuItem.addItem("New...", null, null); newMenuItem.addItem("Invoice/Quote", new MenuBar.Command() { public void menuSelected(MenuItem selectedItem) { try { QwikInvoiceApplication.this.showPanel(InvoiceApplicationPanel.class); } catch (Exception e) { Log.log(Level.SEVERE, "Error loading panel", e); QwikInvoiceApplication.this.mainWindow.showNotification("Error", e.getMessage(), Notification.TYPE_ERROR_MESSAGE); } } }); newMenuItem.addItem("Order", new MenuBar.Command() { public void menuSelected(MenuItem selectedItem) { try { QwikInvoiceApplication.this.showPanel(FFOrderApplicationPanel.class); } catch (Exception e) { Log.log(Level.SEVERE, "Error loading panel", e); QwikInvoiceApplication.this.mainWindow.showNotification("Error", e.getMessage(), Notification.TYPE_ERROR_MESSAGE); } } }); /** SAVE */ fileMenuItem.addItem("Save", new MenuBar.Command() { public void menuSelected(MenuItem selectedItem) { try { TokenBean userTokenBean = TokenStore.getToken(QwikInvoiceApplication.this.userKey); // User must have an OAuth AUTH Token to access Google Doc service if (userTokenBean != null) { /* GDocFileWindow saveWindow = new GDocFileWindow("Save As..."); saveWindow.init(QwikInvoiceApplication.this, PdfWriter.getFilename(QwikInvoiceApplication.this.theSession)); QwikInvoiceApplication.this.mainWindow.addWindow(saveWindow); */ QwikInvoiceApplication.this.activePanel.validate(); QwikInvoiceApplication.this.activePanel.onSave(); } else { AuthSubWindow authsubWindow = new AuthSubWindow("Service Authorization Required"); authsubWindow.init(QwikInvoiceApplication.this.userKey); QwikInvoiceApplication.this.mainWindow.addWindow(authsubWindow); } } catch (Exception e) { Log.log(Level.SEVERE, "Error Saving file", e); QwikInvoiceApplication.this.mainWindow.showNotification("Error", e.getMessage(), Notification.TYPE_ERROR_MESSAGE); } } }); /** * SETTINGS */ fileMenuItem.addSeparator(); MenuItem settingsMenuItem = fileMenuItem.addItem("Settings...", null, null); settingsMenuItem.addItem("Profile", new MenuBar.Command() { public void menuSelected(MenuItem selectedItem) { try { UserCompanySetupWindow aWindow = new UserCompanySetupWindow(); aWindow.init(QwikInvoiceApplication.this); QwikInvoiceApplication.this.mainWindow.addWindow(aWindow); } catch (Exception e) { Log.log(Level.SEVERE, "Error Saving Profile", e); QwikInvoiceApplication.this.mainWindow.showNotification("Error", e.getMessage(), Notification.TYPE_ERROR_MESSAGE); } } }); fileMenuItem.addSeparator(); fileMenuItem.addItem("Logout", new MenuBar.Command() { public void menuSelected(MenuItem selectedItem) { QwikInvoiceApplication.this.setLogoutURL(logoutURL); QwikInvoiceApplication.this.close(); } }); /** * Products */ MenuBar.MenuItem productsMenuItem = menuBar.addItem("Products", null, null); productsMenuItem.addItem("Products", null, new MenuBar.Command() { public void menuSelected(MenuItem selectedItem) { try { QwikInvoiceApplication.this.showPanel(ProductApplicationPanel.class); } catch (Exception e) { Log.log(Level.SEVERE, "Error loading products", e); QwikInvoiceApplication.this.mainWindow.showNotification("Error", e.getMessage(), Notification.TYPE_ERROR_MESSAGE); } } }); productsMenuItem.addItem("Categories", null, new MenuBar.Command() { public void menuSelected(MenuItem selectedItem) { try { ProductCategorySettingsWindow window = new ProductCategorySettingsWindow(); window.setCaption("Product Category"); window.init(QwikInvoiceApplication.this.theSession, QwikInvoiceApplication.this); QwikInvoiceApplication.this.mainWindow.addWindow(window); } catch (Exception e) { Log.log(Level.SEVERE, "Error Loading Products", e); QwikInvoiceApplication.this.mainWindow.showNotification("Error", e.getMessage(), Notification.TYPE_ERROR_MESSAGE); } } }); productsMenuItem.addItem("Catalogs", null, new MenuBar.Command() { public void menuSelected(MenuItem selectedItem) { try { QwikInvoiceApplication.this.showPanel(CatalogApplicationPanel.class); } catch (Exception e) { Log.log(Level.SEVERE, "Error loading catalogs", e); QwikInvoiceApplication.this.mainWindow.showNotification("Error", e.getMessage(), Notification.TYPE_ERROR_MESSAGE); } } }); /** * Help */ MenuBar.MenuItem helpMenuItem = menuBar.addItem("Help", null, new MenuBar.Command() { public void menuSelected(MenuItem selectedItem) { AboutWindow aboutWindow = new AboutWindow(); aboutWindow.init(); QwikInvoiceApplication.this.mainWindow.addWindow(aboutWindow); } }); helpMenuItem.addItem("About...", null, null); mainLayout.addComponent(menuBar); mainLayout.setComponentAlignment(menuBar, Alignment.TOP_CENTER); // // Load Main Panel // IApplicationPanel invoiceApplicationPanel = (IApplicationPanel) this.map.get(InvoiceApplicationPanel.class); try { invoiceApplicationPanel.init(this.theSession, this); mainLayout.addComponent((Component) invoiceApplicationPanel); mainLayout.setComponentAlignment((Component) invoiceApplicationPanel, Alignment.TOP_CENTER); this.activePanel = invoiceApplicationPanel; } catch (Exception e) { } // // Setup Footer // //Label footerMessage = new Label("QwikInvoice <b>version "+_VERSION_+"</b>. This service is provided as is. E&O accepted. Developed by <a href='mailto:public@studiodojo.com?subject=QwikInvoice' target='_blank'>StudioDojo</a>. Engineered by Vaadin. Powered by Google. Apache License 2.0", Label.CONTENT_XHTML); //mainLayout.addComponent(footerMessage); //mainLayout.setComponentAlignment(footerMessage, Alignment.TOP_CENTER); Panel mainPanel = new Panel(); mainPanel.setScrollable(true); mainPanel.setContent(appLayout); this.mainWindow.setContent(mainPanel); }
From source file:com.tapas.evidence.fe.child.ChildPresenter.java
License:Apache License
@Override public void bind() { final HorizontalLayout buttonBar = this.view.getButtonBar(); buttonBar.setExpandRatio(this.getView().getExpander(), 1.0f); final Table childList = this.view.getChildList(); container = new BeanItemContainer<ChildDTO>(ChildDTO.class); childList.setContainerDataSource(container); childList.setColumnHeader("fullName", this.getMessage("child.list.header.fullName", this.getLocale())); //childList.setColumnHeader("fullAddress", this.getMessage("child.list.header.fullAddress", this.getLocale())); childList.setVisibleColumns(new String[] { "fullName" }); loadChildList();//w w w .j a va 2 s. c o m }
From source file:com.tapas.evidence.fe.kindergarten.KindergartenPresenter.java
License:Apache License
@Override public void bind() { final HorizontalLayout buttonBar = this.view.getButtonBar(); buttonBar.setExpandRatio(this.getView().getExpander(), 1.0f); final Table kindergartenList = this.view.getKindergartenList(); container = new BeanItemContainer<KindergartenDTO>(KindergartenDTO.class); kindergartenList.setContainerDataSource(container); kindergartenList.setColumnHeader("name", this.getMessage("kindergarten.list.header.name", this.getLocale())); kindergartenList.setColumnHeader("fullAddress", this.getMessage("kindergarten.list.header.fullAddress", this.getLocale())); kindergartenList.setVisibleColumns(new String[] { "name", "fullAddress" }); loadKindergartenList();/*from w ww . j a va 2 s .c o m*/ }