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:org.activiti.explorer.ui.management.job.JobDetailPanel.java
License:Apache License
protected void addJobState() { Label processDefinitionHeader = new Label(i18nManager.getMessage(Messages.JOB_HEADER_EXECUTION)); processDefinitionHeader.addStyleName(ExplorerLayout.STYLE_H3); processDefinitionHeader.addStyleName(ExplorerLayout.STYLE_DETAIL_BLOCK); processDefinitionHeader.setWidth(100, UNITS_PERCENTAGE); addComponent(processDefinitionHeader); VerticalLayout layout = new VerticalLayout(); layout.setSpacing(true);/*from w w w .j a v a2 s . c o m*/ layout.setSizeFull(); layout.setMargin(true, false, true, false); addDetailComponent(layout); setDetailExpandRatio(layout, 1.0f); // Exceptions if (job.getExceptionMessage() != null) { // Number of retries Label retrieslabel = new Label(getRetriesLabel(job)); layout.addComponent(retrieslabel); // Exception Label exceptionMessageLabel = new Label( i18nManager.getMessage(Messages.JOB_ERROR) + ": " + job.getExceptionMessage()); exceptionMessageLabel.addStyleName(ExplorerLayout.STYLE_JOB_EXCEPTION_MESSAGE); layout.addComponent(exceptionMessageLabel); // Add Exception stacktrace String stack = managementService.getJobExceptionStacktrace(job.getId()); Label stackTraceLabel = new Label(stack); stackTraceLabel.setContentMode(Label.CONTENT_PREFORMATTED); stackTraceLabel.addStyleName(ExplorerLayout.STYLE_JOB_EXCEPTION_TRACE); stackTraceLabel.setSizeFull(); Panel stackPanel = new Panel(); stackPanel.setWidth(100, UNITS_PERCENTAGE); stackPanel.setSizeFull(); stackPanel.setScrollable(true); stackPanel.addComponent(stackTraceLabel); layout.addComponent(stackPanel); layout.setExpandRatio(stackPanel, 1.0f); } else { if (job.getProcessDefinitionId() != null) { // This is a hack .. need to cleanify this in the engine JobEntity jobEntity = (JobEntity) job; if (jobEntity.getJobHandlerType().equals(TimerSuspendProcessDefinitionHandler.TYPE)) { addLinkToProcessDefinition(layout, i18nManager.getMessage(Messages.JOB_SUSPEND_PROCESSDEFINITION), false); } else if (jobEntity.getJobHandlerType().equals(TimerActivateProcessDefinitionHandler.TYPE)) { addLinkToProcessDefinition(layout, i18nManager.getMessage(Messages.JOB_ACTIVATE_PROCESSDEFINITION), true); } else { addNotYetExecutedLabel(layout); } } else { addNotYetExecutedLabel(layout); } } }
From source file:org.activiti.explorer.ui.management.job.JobDetailPanel.java
License:Apache License
private void addNotYetExecutedLabel(VerticalLayout layout) { Label noException = new Label(i18nManager.getMessage(Messages.JOB_NOT_EXECUTED)); layout.addComponent(noException);// ww w . j a va 2 s.c om layout.setExpandRatio(noException, 1.0f); }
From source file:org.agocontrol.site.viewlet.dashboard.BuildingControlPanel.java
License:Apache License
/** * Default constructor./*from ww w.ja v a 2s .c o m*/ */ public BuildingControlPanel() { site = ((AgoControlSiteUI) UI.getCurrent()).getSite(); siteContext = site.getSiteContext(); entityManager = siteContext.getObject(EntityManager.class); layout = new VerticalLayout(); layout.setSpacing(true); layout.setMargin(true); layout.setSizeFull(); layout.setStyleName(Reindeer.LAYOUT_WHITE); final Label title = new Label("Control Panel"); title.setIcon(getSite().getIcon("inventory")); title.setStyleName(Reindeer.LABEL_H2); layout.addComponent(title); layout.setExpandRatio(title, 0); elementLayout = new VerticalLayout(); elementLayout.setSpacing(true); elementLayout.setMargin(false); layout.addComponent(elementLayout); layout.setExpandRatio(elementLayout, 1); roomIcon = site.getIcon("room"); deviceIcon = site.getIcon("device"); temperatureIcon = site.getIcon("temperature"); brightnessIcon = site.getIcon("brightness"); humidityIcon = site.getIcon("humidity"); eventIcon = site.getIcon("event"); setCompositionRoot(layout); // the Refresher polls automatically final Refresher refresher = new Refresher(); refresher.setRefreshInterval(200); refresher.addListener(new Refresher.RefreshListener() { @Override public void refresh(final Refresher refresher) { while (!recordsQueue.isEmpty()) { final List<Record> records = recordsQueue.remove(); if (records.size() > 0) { final Record record = records.get(0); final RecordSet recordSet = record.getRecordSet(); final Element element = recordSet.getElement(); final GridLayout recordsLayout = recordsLayouts.get(element.getElementId()); if (recordsLayout == null) { continue; } final int columnIndex = recordSet.getType().ordinal(); final int rowIndex = 0; if (recordsLayout.getComponent(columnIndex, rowIndex) != null) { continue; } final VerticalLayout recordLayout = new VerticalLayout(); recordLayout.setSpacing(true); final Resource recordIcon; switch (recordSet.getType()) { case TEMPERATURE: recordIcon = temperatureIcon; break; case BRIGHTNESS: recordIcon = brightnessIcon; break; case HUMIDITY: recordIcon = humidityIcon; break; default: recordIcon = eventIcon; break; } final Embedded embedded = new Embedded(null, recordIcon); recordLayout.addComponent(embedded); recordLayout.setExpandRatio(embedded, 0.1f); embedded.setWidth(32, Unit.PIXELS); embedded.setHeight(32, Unit.PIXELS); final Label label = new Label(); recordLayout.addComponent(label); recordLayout.setComponentAlignment(label, Alignment.MIDDLE_LEFT); final String recordUnit = recordSet.getUnit(); final String displayUnit = DisplayValueConversionUtil.getDisplayUnit(recordSet.getType(), recordUnit); final double displayValue = DisplayValueConversionUtil.convertValue(recordSet.getType(), recordUnit, displayUnit, record.getValue()); final String displayValueString = DisplayValueConversionUtil.formatDouble(displayValue); label.setValue(displayValueString + " " + displayUnit); label.setDescription(record.getCreated().toString()); recordsLayout.addComponent(recordLayout, columnIndex, rowIndex); } } } }); addExtension(refresher); }
From source file:org.agocontrol.site.viewlet.dashboard.EventPanel.java
License:Apache License
/** * Default constructor which constructs components. *//*from ww w . jav a 2 s. co m*/ public EventPanel() { final VerticalLayout layout = new VerticalLayout(); setCompositionRoot(layout); layout.setMargin(true); layout.setSpacing(true); layout.setSizeFull(); layout.setStyleName(Reindeer.LAYOUT_WHITE); final Label title = new Label("Events"); title.setIcon(getSite().getIcon("event")); title.setStyleName(Reindeer.LABEL_H2); layout.addComponent(title); layout.setExpandRatio(title, 0); final List<FieldDescriptor> fieldDescriptors = AgoControlSiteFields .getFieldDescriptors(org.agocontrol.model.Event.class); final List<FilterDescriptor> filterDefinitions = new ArrayList<FilterDescriptor>(); final Site site = ((AgoControlSiteUI) UI.getCurrent()).getSite(); final EntityManager entityManager = site.getSiteContext().getObject(EntityManager.class); container = new LazyEntityContainer<org.agocontrol.model.Event>(entityManager, true, false, false, org.agocontrol.model.Event.class, 50, new String[] { "created" }, new boolean[] { false }, "eventId"); ContainerUtil.addContainerProperties(container, fieldDescriptors); final Table table = new FormattingTable(); grid = new Grid(table, container, false); layout.addComponent(grid); layout.setExpandRatio(grid, 1); grid.setFields(fieldDescriptors); grid.setFilters(filterDefinitions); //grid.setSizeUndefined(); //grid.setSizeUndefined(); table.setColumnCollapsed("eventId", true); table.setColumnCollapsed("modified", true); table.setColumnCollapsed("processed", true); table.setColumnCollapsed("processingError", true); final Company company = site.getSiteContext().getObject(Company.class); container.removeDefaultFilters(); container.addDefaultFilter(new Compare.Equal("owner.companyId", company.getCompanyId())); }
From source file:org.apache.ace.useradmin.ui.vaadin.UserAdminWindow.java
License:Apache License
/** * Creates a new {@link UserAdminWindow} instance. *//*from w w w . j a v a 2s . c o m*/ public UserAdminWindow() { setCaption("Manage users"); setWidth("30%"); m_userTable = new Table(); m_userTable.setSizeFull(); m_userTable.setImmediate(true); m_userTable.setSelectable(true); m_userTable.setSortDisabled(false); m_userTable.addContainerProperty("User", UserDTO.class, null); m_userTable.addListener(new ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { selectUser((UserDTO) m_userTable.getValue()); } }); VerticalLayout usersList = new VerticalLayout(); usersList.setSizeFull(); usersList.addComponent(m_userTable); Button addUserButton = new Button("+"); addUserButton.setStyleName(Reindeer.BUTTON_SMALL); addUserButton.addListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { prepareForNewUser(); } }); m_removeUserButton = new Button(); m_removeUserButton.setStyleName(Reindeer.BUTTON_SMALL); m_removeUserButton.setCaption("-"); m_removeUserButton.addListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { removeSelectedUser((UserDTO) m_userTable.getValue()); } }); HorizontalLayout addRemoveUserButtons = new HorizontalLayout(); addRemoveUserButtons.setMargin(true, false, false, false); addRemoveUserButtons.setSpacing(true); addRemoveUserButtons.addComponent(addUserButton); addRemoveUserButtons.addComponent(m_removeUserButton); usersList.addComponent(addRemoveUserButtons); usersList.setExpandRatio(m_userTable, 1.0f); usersList.setExpandRatio(addRemoveUserButtons, 0.0f); ValueChangeListener changeListener = new ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { m_applyButton.setEnabled(isCurrentFormValid()); m_cancelButton.setEnabled(true); } }; m_usernameTextField = new TextField(); m_usernameTextField.setCaption("Username"); m_usernameTextField.setImmediate(true); m_usernameTextField.setRequired(true); m_usernameTextField.addListener(changeListener); m_passwordTextField = new PasswordField(); m_passwordTextField.setCaption("Password"); m_passwordTextField.setImmediate(true); m_passwordTextField.setRequired(true); m_passwordTextField.addListener(changeListener); m_groupSelect = new Select(); m_groupSelect.setCaption("Role"); m_groupSelect.setImmediate(true); m_groupSelect.setNullSelectionAllowed(false); m_groupSelect.setRequired(true); m_groupSelect.addListener(changeListener); FormLayout formLayout = new FormLayout(); formLayout.addComponent(m_usernameTextField); formLayout.addComponent(m_passwordTextField); formLayout.addComponent(m_groupSelect); m_applyButton = new Button(); m_applyButton.setCaption("Apply changes"); m_applyButton.addListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { storeUserInfo(); } }); m_cancelButton = new Button(); m_cancelButton.setEnabled(false); m_cancelButton.setCaption("Cancel"); m_cancelButton.addListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { selectUser((UserDTO) m_userTable.getValue()); } }); HorizontalLayout addUserButtons = new HorizontalLayout(); addUserButtons.setMargin(true, false, false, false); addUserButtons.setSpacing(true); addUserButtons.addComponent(m_applyButton); addUserButtons.addComponent(m_cancelButton); formLayout.addComponent(addUserButtons); HorizontalLayout horizontalLayout = new HorizontalLayout(); horizontalLayout.setSizeFull(); horizontalLayout.setSpacing(true); horizontalLayout.addComponent(usersList); horizontalLayout.addComponent(formLayout); horizontalLayout.setExpandRatio(usersList, 0.35f); horizontalLayout.setExpandRatio(formLayout, 0.65f); addComponent(horizontalLayout); updateState(null, false /* editAllowed */); }
From source file:org.apache.usergrid.chop.webapp.view.user.GroupSubwindow.java
License:Apache License
private void initLayout() { /* Root of the user interface component tree is set */ HorizontalSplitPanel splitPanel = new HorizontalSplitPanel(); setContent(splitPanel);/*ww w . j a v a2 s . c o m*/ /* Build the component tree */ VerticalLayout leftLayout = new VerticalLayout(); splitPanel.addComponent(leftLayout); splitPanel.addComponent(editorLayout); leftLayout.addComponent(groupList); HorizontalLayout bottomLeftLayout = new HorizontalLayout(); leftLayout.addComponent(bottomLeftLayout); bottomLeftLayout.addComponent(searchField); bottomLeftLayout.addComponent(addNewGroupButton); bottomLeftLayout.addComponent(saveButton); bottomLeftLayout.addComponent(cancelButton); /* Set the contents in the left of the split panel to use all the space */ leftLayout.setSizeFull(); /* * On the left side, expand the size of the userList so that it uses * all the space left after from bottomLeftLayout */ leftLayout.setExpandRatio(groupList, 1); groupList.setSizeFull(); /* * In the bottomLeftLayout, searchField takes all the width there is * after adding addNewUserButton. The height of the layout is defined * by the tallest component. */ bottomLeftLayout.setWidth("100%"); searchField.setWidth("100%"); bottomLeftLayout.setExpandRatio(searchField, 1); /* Put a little margin around the fields in the right side editor */ editorLayout.setMargin(true); editorLayout.setVisible(false); }
From source file:org.apache.usergrid.chop.webapp.view.user.UserSubwindow.java
License:Apache License
private void initLayout() { // Root of the user interface component tree is set HorizontalSplitPanel splitPanel = new HorizontalSplitPanel(); setContent(splitPanel);// w w w .j a v a2s .co m // Build the component tree VerticalLayout leftLayout = new VerticalLayout(); splitPanel.addComponent(leftLayout); splitPanel.addComponent(userEditLayout); leftLayout.addComponent(userList); HorizontalLayout buttonsLayout = new HorizontalLayout(); buttonsLayout.addComponent(addNewUserButton); buttonsLayout.addComponent(saveButton); buttonsLayout.addComponent(closeButton); leftLayout.addComponent(buttonsLayout); // Set the contents in the left of the split panel to use all the space leftLayout.setSizeFull(); // On the left side, expand the size of userList so that it uses all the space left after from bottomLeftLayout leftLayout.setExpandRatio(userList, 1); userList.setSizeFull(); // Put a little margin around the fields in the right side editor userEditLayout.setMargin(true); userEditLayout.setVisible(false); }
From source file:org.axonframework.examples.addressbook.vaadin.AddressbookApplication.java
License:Apache License
private void buildMainLayout() { setMainWindow(new Window("Address Book Demo application")); VerticalLayout verticalLayout = new VerticalLayout(); verticalLayout.setSizeFull();// w ww . j av a2s . co m verticalLayout.addComponent(createToolbar()); verticalLayout.addComponent(horizontalSplit); verticalLayout.setExpandRatio(horizontalSplit, 1); horizontalSplit.setSplitPosition(150, HorizontalSplitPanel.UNITS_PIXELS); horizontalSplit.setFirstComponent(tree); tree.addListener((ItemClickEvent.ItemClickListener) this); getMainWindow().setContent(verticalLayout); setMainComponent(getListView()); }
From source file:org.eclipse.hawkbit.ui.AbstractHawkbitUI.java
License:Open Source License
@Override protected void init(final VaadinRequest vaadinRequest) { LOG.info("ManagementUI init starts uiid - {}", getUI().getUIId()); if (pushStrategy != null) { pushStrategy.init(getUI());//from ww w. j ava 2 s .c o m } addDetachListener(this); SpringContextHelper.setContext(context); Responsive.makeResponsive(this); addStyleName(ValoTheme.UI_WITH_MENU); setResponsive(Boolean.TRUE); final HorizontalLayout rootLayout = new HorizontalLayout(); rootLayout.setSizeFull(); HawkbitCommonUtil.initLocalization(this, uiProperties.getLocalization(), i18n); dashboardMenu.init(); dashboardMenu.setResponsive(true); final VerticalLayout contentVerticalLayout = new VerticalLayout(); contentVerticalLayout.setSizeFull(); contentVerticalLayout.setStyleName("main-content"); contentVerticalLayout.addComponent(buildHeader()); contentVerticalLayout.addComponent(buildViewTitle()); final Panel content = buildContent(); contentVerticalLayout.addComponent(content); contentVerticalLayout.setExpandRatio(content, 1); rootLayout.addComponent(dashboardMenu); rootLayout.addComponent(contentVerticalLayout); rootLayout.setExpandRatio(contentVerticalLayout, 1); setContent(rootLayout); final Navigator navigator = new Navigator(this, content); navigator.addViewChangeListener(new ViewChangeListener() { private static final long serialVersionUID = 1L; @Override public boolean beforeViewChange(final ViewChangeEvent event) { return true; } @Override public void afterViewChange(final ViewChangeEvent event) { final DashboardMenuItem view = dashboardMenu.getByViewName(event.getViewName()); dashboardMenu.postViewChange(new PostViewChangeEvent(view)); if (view == null) { viewTitle.setCaption(null); return; } viewTitle.setCaption(view.getDashboardCaptionLong()); notificationUnreadButton.setCurrentView(event.getNewView()); } }); navigator.setErrorView(errorview); navigator.addProvider(new ManagementViewProvider()); setNavigator(navigator); navigator.addView(EMPTY_VIEW, new Navigator.EmptyView()); if (UI.getCurrent().getErrorHandler() == null) { UI.getCurrent().setErrorHandler(new HawkbitUIErrorHandler()); } LOG.info("Current locale of the application is : {}", getLocale()); }
From source file:org.eclipse.hawkbit.ui.common.AbstractMetadataPopupLayout.java
License:Open Source License
private void buildLayout() { final HorizontalLayout headerLayout = new HorizontalLayout(); headerLayout.addStyleName(SPUIStyleDefinitions.WIDGET_TITLE); headerLayout.setSpacing(false);/*from w w w . j a v a 2 s . com*/ headerLayout.setMargin(false); headerLayout.setSizeFull(); headerLayout.addComponent(headerCaption); if (hasCreatePermission()) { headerLayout.addComponents(addIcon); headerLayout.setComponentAlignment(addIcon, Alignment.MIDDLE_RIGHT); } headerLayout.setExpandRatio(headerCaption, 1.0F); final HorizontalLayout headerWrapperLayout = new HorizontalLayout(); headerWrapperLayout .addStyleName("bordered-layout" + " " + "no-border-bottom" + " " + "metadata-table-margin"); headerWrapperLayout.addComponent(headerLayout); headerWrapperLayout.setWidth("100%"); headerLayout.setHeight("30px"); final VerticalLayout tableLayout = new VerticalLayout(); tableLayout.setSizeFull(); tableLayout.setHeight("100%"); tableLayout.addComponent(headerWrapperLayout); tableLayout.addComponent(metaDataGrid); tableLayout.addStyleName("table-layout"); tableLayout.setExpandRatio(metaDataGrid, 1.0F); final VerticalLayout metadataFieldsLayout = createMetadataFieldsLayout(); mainLayout = new HorizontalLayout(); mainLayout.addComponent(tableLayout); mainLayout.addComponent(metadataFieldsLayout); mainLayout.setExpandRatio(tableLayout, 0.5F); mainLayout.setExpandRatio(metadataFieldsLayout, 0.5F); mainLayout.setSizeFull(); mainLayout.setSpacing(true); setCompositionRoot(mainLayout); setSizeFull(); }