List of usage examples for com.vaadin.ui VerticalLayout 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:ru.codeinside.gses.webui.supervisor.SupervisorWorkplace.java
License:Mozilla Public License
private void buildMainLayout() { int mainLayoutWidth = 100; int filterPanelHeight = 100; int filterPanelWidth = 100; int infoPanelWidth = 100; int infoPanelHeight = 100; int listPanelHeight = 100; float listPanelRatio = 0.4f; float infoPanelRatio = 0.6f; setSizeFull();//from ww w . j av a 2 s .c om setMargin(true); VerticalLayout rightLayout = new VerticalLayout(); filterPanel = new Panel(); infoPanel = new Panel(); listPanel = new Panel(); setFirstComponent(filterPanel); setSecondComponent(rightLayout); setSplitPosition(35); rightLayout.addComponent(infoPanel); rightLayout.addComponent(listPanel); infoPanel.setSizeFull(); listPanel.setSizeFull(); rightLayout.setSpacing(true); rightLayout.setSizeFull(); setHeight(mainLayoutWidth, UNITS_PERCENTAGE); filterPanel.setHeight(filterPanelHeight, UNITS_PERCENTAGE); filterPanel.setWidth(filterPanelWidth, UNITS_PERCENTAGE); infoPanel.setWidth(infoPanelWidth, UNITS_PERCENTAGE); infoPanel.setHeight(infoPanelHeight, UNITS_PERCENTAGE); listPanel.setHeight(listPanelHeight, UNITS_PERCENTAGE); listPanel.setWidth(listPanelHeight, UNITS_PERCENTAGE); rightLayout.setExpandRatio(listPanel, listPanelRatio); rightLayout.setExpandRatio(infoPanel, infoPanelRatio); }
From source file:ru.codeinside.gses.webui.wizard.Wizard.java
License:Mozilla Public License
private void replaceContent(WizardStep step) { contentPanel.removeAllComponents();/*from ww w. j a va2s . c om*/ Component c = step.getContent(); contentPanel.addComponent(c); if (c instanceof ExpandRequired) { // ?? ? ?? ? VerticalLayout vl = (VerticalLayout) contentPanel.getContent(); vl.setSizeFull(); vl.setExpandRatio(c, 1f); } if (c instanceof Form) { accumulator.addForm((Form) c); } }
From source file:ru.vist.stat.forms.precept.PreceptTable.java
public PreceptTable(Date dateStart, Date dateEnd) { this.dateEnd = dateEnd; this.dateStart = dateStart; FilterTable filterTreeTable = buildFilterTreeTable(); final VerticalLayout mainLayout = new VerticalLayout(); mainLayout.setSizeFull();/*www . j a va2 s . c om*/ mainLayout.setSpacing(true); mainLayout.setMargin(true); mainLayout.addComponent(filterTreeTable); mainLayout.setExpandRatio(filterTreeTable, 1); // mainLayout.addComponent(Util.buildButtons((FilterTable)filterTreeTable)); setStyleName(Reindeer.PANEL_LIGHT); setSizeFull(); setContent(mainLayout); }
From source file:se.natusoft.osgi.aps.apsconfigadminweb.gui.vaadin.components.ConfigEditor.java
License:Open Source License
/** * Builds the gui of this component./* www . ja va2 s.c om*/ * <p/> * The code in this method builds the base gui, the static parts that is only created once. It ends by calling * loadCurrentNodeData() to do a first time load of the root node of the ConfigNavigator. */ private void setupGUI() { this.setStyleName(CSS.APS_CONFIGID_LABEL); setSizeFull(); VerticalLayout mainLayout = new VerticalLayout(); { mainLayout.setSpacing(true); mainLayout.setMargin(true); mainLayout.setStyleName(CSS.APS_CONTENT_PANEL); mainLayout.setSizeFull(); this.editForConfigEnvSelect = new ConfigEnvSelector(); this.editForConfigEnvSelect.setDataSource(this.configAdminService.getConfigEnvAdmin()); this.editForConfigEnvSelect.addListener(new ConfigEnvChangeListener() { @Override public void configEnvironmentChanged(ConfigEnvChangeEvent event) { handleChangedConfigEnv(event.getSelectedConfigEnvironment()); } }); mainLayout.addComponent(this.editForConfigEnvSelect); mainLayout.setExpandRatio(this.editForConfigEnvSelect, 1.0f); HorizontalLine hr = new HorizontalLine(); mainLayout.addComponent(hr); mainLayout.setExpandRatio(hr, 1.0f); HorizontalLayout contentLayout = new HorizontalLayout(); { contentLayout.setSpacing(true); contentLayout.setSizeFull(); ConfigNode configNode = new ConfigNode(this.editedConfigAdmin.getConfigModel()); if (!configNode.getNodeChildren().isEmpty()) { VerticalLayout nodesAndButtonsLayout = new VerticalLayout(); { nodesAndButtonsLayout.setWidth(null); nodesAndButtonsLayout.setHeight("100%"); nodesAndButtonsLayout.setMargin(false); nodesAndButtonsLayout.setSpacing(false); this.nodeSelector = new NodeSelector(); this.nodeSelector.setHeight("100%"); this.nodeSelector.setWidth(null); this.nodeSelector.setScrollable(true); this.nodeSelector.setDataSource(this.nodeSelectorDataSource); this.nodeSelector.addListener(new NodeSelectionListener() { @Override public void nodeSelected(NodeSelectedEvent event) { selectCurrentNode(event.getSelectedModel(), event.getIndex()); } }); nodesAndButtonsLayout.addComponent(this.nodeSelector); nodesAndButtonsLayout.setExpandRatio(this.nodeSelector, 92.0f); // This works for iPad screen // size and upp. HorizontalLayout buttonsLayout = new HorizontalLayout(); { buttonsLayout.setMargin(false); buttonsLayout.setSpacing(false); buttonsLayout.setHeight("100%"); this.addNodeButton = new Button(" + "); this.addNodeButton.setEnabled(false); this.addNodeButton.addListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { addNodeInstance(); } }); buttonsLayout.addComponent(this.addNodeButton); this.removeNodeButton = new Button(" - "); this.removeNodeButton.setEnabled(false); this.removeNodeButton.addListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { removeNodeInstance(); } }); buttonsLayout.addComponent(this.removeNodeButton); } nodesAndButtonsLayout.addComponent(buttonsLayout); nodesAndButtonsLayout.setExpandRatio(buttonsLayout, 8.0f); } contentLayout.addComponent(nodesAndButtonsLayout); contentLayout.setExpandRatio(nodesAndButtonsLayout, 1.0f); } this.configNodeValuesEditor = new ConfigNodeValuesEditor(); { this.configNodeValuesEditor.setScrollable(true); this.configNodeValuesEditor.setWidth("100%"); this.configNodeValuesEditor.setHeight("100%"); this.configNodeValuesEditor.setDataSource(this.configNodeValueEditorDataSource); } contentLayout.addComponent(this.configNodeValuesEditor); contentLayout.setExpandRatio(this.configNodeValuesEditor, 99.0f); } mainLayout.addComponent(contentLayout); mainLayout.setExpandRatio(contentLayout, 96.0f); hr = new HorizontalLine(); mainLayout.addComponent(hr); mainLayout.setExpandRatio(hr, 1.0f); HorizontalLayout saveCancelButtonsLayout = new HorizontalLayout(); { saveCancelButtonsLayout.setSpacing(true); Button saveButton = new Button("Save"); saveButton.addListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { saveEdit(); } }); saveCancelButtonsLayout.addComponent(saveButton); Button cancelButton = new Button("Cancel"); cancelButton.addListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { cancelEdit(); } }); saveCancelButtonsLayout.addComponent(cancelButton); } mainLayout.addComponent(saveCancelButtonsLayout); mainLayout.setExpandRatio(saveCancelButtonsLayout, 1.0f); } setContent(mainLayout); refresh(); if (this.nodeSelector != null) { this.nodeSelector.refreshData(); } }
From source file:se.natusoft.osgi.aps.tools.web.vaadin.components.SidesAndCenterLayout.java
License:Open Source License
/** * Does the actual layout adding the provided component to the layout. This must be called after the components have been set. * <p/>//w w w.j a va2 s . c om * It starts by removing all components so if this has already been setup and this method called, it can be called again with new * components added or components replaced with other components. */ public void doLayout() { removeAllComponents(); setSizeFull(); if (this.left != null) { this.left.setHeight("100%"); this.left.setWidth(null); addComponent(left); } VerticalLayout middleLayout = new VerticalLayout(); middleLayout.setMargin(false); middleLayout.setSizeFull(); addComponent(middleLayout); setExpandRatio(middleLayout, 1.0f); if (this.top != null) { this.top.setWidth("100%"); this.top.setHeight(null); middleLayout.addComponent(this.top); } if (this.center != null) { this.center.setWidth("100%"); this.center.setHeight("100%"); middleLayout.addComponent(this.center); middleLayout.setExpandRatio(this.center, 1.0f); } if (this.bottom != null) { this.bottom.setWidth("100%"); this.bottom.setHeight(null); middleLayout.addComponent(this.bottom); } if (this.right != null) { this.right.setHeight("100%"); this.right.setWidth(null); addComponent(this.right); } this.layedOut = true; }
From source file:v7cr.TopPageWindow.java
License:Open Source License
private void initUI(V7CR app) { VerticalLayout vl = new VerticalLayout(); vl.setSizeFull();// w w w . j a v a2 s. c o m vl.addComponent(createToolbar(app)); TabSheet main = new TabSheet(); vl.addComponent(main); vl.setExpandRatio(main, 1); Map<String, Role> roles = app.getRoles(); if (roles.containsKey("admin")) { main.addTab(new RoleEditor(app)); main.addTab(new UserEditor(app)); main.addTab(new ProjectEditor(app)); } for (String r : roles.keySet()) { if (r.startsWith("project:")) { String p = r.substring(8); main.addTab(new ReviewList(p)); } } addComponent(vl); }
From source file:VaadinIRC.GUI.channelGUI.java
License:Open Source License
/** * Creates the GUI for a channel.// w w w . j a v a2 s . c om */ public void createChannelGUI() { panel = new Panel(); panel.setCaption(channelName); panel.setSizeFull(); panel.getContent().setSizeFull(); AbstractLayout panelLayout = (AbstractLayout) panel.getContent(); panelLayout.setMargin(false); panel.setImmediate(true); labelTitle.setValue("<b>" + channelName + "</b>"); VerticalLayout mainVerticalLayout = new VerticalLayout(); mainVerticalLayout.setSizeFull(); // Top bar containing channel title & topright buttons GridLayout topGrid = new GridLayout(2, 1); topGrid.setStyleName("topBar"); topGrid.addComponent(labelTitle); topGrid.setSizeFull(); labelTitle.setSizeFull(); HorizontalLayout hori = new HorizontalLayout(); hori.setStyleName("rightTopBar"); hori.setWidth(100, Sizeable.UNITS_PIXELS); hori.addComponent(buttonSettings); hori.addComponent(buttonChangeNick); hori.addComponent(buttonRefreshUsernames); topGrid.addComponent(hori); topGrid.setComponentAlignment(hori, Alignment.TOP_RIGHT); mainVerticalLayout.addComponent(topGrid); mainVerticalLayout.setExpandRatio(topGrid, 0.05f); // Message area & table of nicknames HorizontalLayout horizontal = new HorizontalLayout(); horizontal.setSpacing(false); horizontal.setMargin(false); horizontal.setSizeFull(); horizontal.addComponent(panelMessages); mainVerticalLayout.addComponent(horizontal); mainVerticalLayout.setExpandRatio(horizontal, 0.90f); if (channelName.startsWith("#")) { horizontal.addComponent(tableNicknames); horizontal.setExpandRatio(panelMessages, 0.8f); horizontal.setExpandRatio(tableNicknames, 0.2f); } // Send message textfield & send button HorizontalLayout bottomBar = new HorizontalLayout(); //bottomBar.setWidth(100, Sizeable.UNITS_PERCENTAGE); bottomBar.setSizeFull(); //bottomBar.setSpacing(true); //bottomBar.setMargin(true, false, false, false); bottomBar.addComponent(textfieldMessagefield); bottomBar.addComponent(buttonSendMessage); bottomBar.setExpandRatio(textfieldMessagefield, 1f); bottomBar.setExpandRatio(buttonSendMessage, 0f); mainVerticalLayout.addComponent(bottomBar); mainVerticalLayout.setExpandRatio(bottomBar, 0.05f); horizontal.setImmediate(true); panelMessages.setImmediate(true); tableNicknames.setImmediate(true); textfieldMessagefield.setImmediate(true); tableNicknames.addContainerProperty("Rights", String.class, null); tableNicknames.addContainerProperty("Nicknames", String.class, null); tableNicknames.setSelectable(true); textfieldMessagefield.focus(); //mainVerticalLayout.setSizeFull(); panel.addComponent(mainVerticalLayout); }
From source file:xyz.iipster.ui.ChangePasswordComponent.java
License:Apache License
@Override public void attach() { super.attach(); setModal(true);//from w w w . j a va2 s.c o m setClosable(false); setResizable(false); setCaption(i18N.get("iipster.changePassword.title")); oldPasswordField.setCaption(i18N.get("iipster.changePassword.oldPassword.label")); newPasswordField1.setCaption(i18N.get("iipster.changePassword.newPassword1.label")); newPasswordField2.setCaption(i18N.get("iipster.changePassword.newPassword2.label")); VerticalLayout vl = new VerticalLayout(); vl.setSizeUndefined(); vl.setMargin(true); if (currentPassword != null) { // currentPassowrd is not null, that means we are on login screen and the password is expired Label expiredLabel = new Label(i18N.get("iipster.changePassword.expired.text")); vl.addComponent(expiredLabel); } FormLayout fl = new FormLayout(); fl.setSizeUndefined(); fl.addComponents(oldPasswordField, newPasswordField1, newPasswordField2); vl.addComponent(fl); vl.setExpandRatio(fl, 1F); okButton.setCaption(i18N.get("iipster.ok")); okButton.addStyleName(ValoTheme.BUTTON_PRIMARY); okButton.setClickShortcut(ShortcutAction.KeyCode.ENTER); okButton.addClickListener(e -> { try { ibmiService.changePassword( securityUtils.getAuthentication() == null ? userName : securityUtils.getAuthentication().getPrincipal().toString(), oldPasswordField.getValue(), newPasswordField1.getValue()); close(); eventBus.post(new PasswordChangedEvent(newPasswordField1.getValue())); } catch (BadCredentialsException e1) { Notification.show(i18N.get("iipster.changePassword.oldPassword.error"), Notification.Type.WARNING_MESSAGE); oldPasswordField.focus(); } catch (IOException e1) { Notification.show("Error while changing password", Notification.Type.ERROR_MESSAGE); } catch (NewPasswordInvalidException e1) { Notification.show(i18N.get(e1.getMessageId()), Notification.Type.WARNING_MESSAGE); newPasswordField1.focus(); } }); cancelButton.setCaption(i18N.get("iipster.cancel")); cancelButton.setClickShortcut(ShortcutAction.KeyCode.F12); cancelButton.addClickListener(e -> { close(); }); HorizontalLayout hl = new HorizontalLayout(); hl.setSizeUndefined(); hl.setSpacing(true); hl.addComponents(okButton, cancelButton); vl.addComponent(hl); vl.setComponentAlignment(hl, Alignment.MIDDLE_CENTER); setContent(vl); if (currentPassword == null) { // currentPassword is null so we are not forced to change password during login oldPasswordField.setValue(""); oldPasswordField.setEnabled(true); oldPasswordField.focus(); } else { oldPasswordField.setValue(currentPassword); oldPasswordField.setEnabled(false); newPasswordField1.focus(); } newPasswordField1.setValue(""); newPasswordField2.setValue(""); }
From source file:xyz.iipster.ui.DefaultIbmiLoginComponent.java
License:Apache License
@Override public void attach() { super.attach(); final FormLayout fl = new FormLayout(); fl.setSizeUndefined();/*w ww . j a va 2s. c o m*/ userNameTF.setCaption(i18N.get("iipster.login.username.label")); // userNameTF.setRequired(true); userNameTF.addStyleName("upper-case"); userNameTF.setMaxLength(10); passwordPF.setCaption(i18N.get("iipster.login.password.label")); // passwordPF.setRequired(true); fl.addComponent(userNameTF); fl.addComponent(passwordPF); final VerticalLayout vl = new VerticalLayout(); vl.setSizeUndefined(); vl.addComponent(fl); vl.setExpandRatio(fl, 1F); vl.setComponentAlignment(fl, Alignment.MIDDLE_CENTER); final HorizontalLayout hl = new HorizontalLayout(); hl.setSizeUndefined(); loginButton.setCaption(i18N.get("iipster.login.loginButton.label")); loginButton.addStyleName(ValoTheme.BUTTON_PRIMARY); loginButton.setClickShortcut(ShortcutAction.KeyCode.ENTER); loginButton.addClickListener(event -> { if (userNameTF.isEmpty()) { Notification.show(i18N.get("iipster.login.username.missing"), Notification.Type.WARNING_MESSAGE); userNameTF.focus(); return; } if (passwordPF.isEmpty()) { Notification.show(i18N.get("iipster.login.password.missing"), Notification.Type.WARNING_MESSAGE); passwordPF.focus(); return; } try { Authentication auth = securityUtils.login(userNameTF.getValue(), passwordPF.getValue()); eventBus.post(new LoginEvent(auth.getPrincipal().toString())); } catch (BadCredentialsException e) { Notification.show(i18N.get("iipster.login.bad.credential"), Notification.Type.WARNING_MESSAGE); } catch (DisabledException e) { Notification.show(i18N.get("iipster.login.disabled"), Notification.Type.WARNING_MESSAGE); } catch (CredentialsExpiredException e) { changePasswordComponent.setUserName(userNameTF.getValue()); changePasswordComponent.setCurrentPassword(passwordPF.getValue()); UI.getCurrent().addWindow(changePasswordComponent); } catch (Exception e) { Notification.show(i18N.get("iipster.login.error"), Notification.Type.WARNING_MESSAGE); } }); hl.addComponent(loginButton); vl.addComponent(hl); vl.setComponentAlignment(hl, Alignment.MIDDLE_CENTER); vl.setSizeUndefined(); vl.setMargin(true); final Panel panel = new Panel(i18N.get("iipster.login.panel.title"), vl); panel.setSizeUndefined(); rootLayout.addComponent(panel); rootLayout.setSizeFull(); rootLayout.setComponentAlignment(panel, Alignment.MIDDLE_CENTER); setCompositionRoot(rootLayout); setSizeFull(); }
From source file:your.company.MyVaadinApplication.java
License:Apache License
private void buildMainLayout() { //setTheme("contacts"); setMainWindow(new Window("My Demo Application")); setMainComponent(getListView());// w ww .j av a2 s . c o m horizontalSplit.setFirstComponent(tree); VerticalLayout layout = new VerticalLayout(); layout.setSizeFull(); getMainWindow().addWindow(getHelpWindow()); //getMainWindow().addWindow(getSharingOptions()); layout.addComponent(createToolbar()); layout.addComponent(horizontalSplit); /* Allocate all available extra space to the horizontal split panel */ layout.setExpandRatio(horizontalSplit, 1); /* Set the initial split position so we can have a 200 pixel menu to the left */ horizontalSplit.setSplitPosition(200, SplitPanel.UNITS_PIXELS); getMainWindow().setContent(layout); }