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.ripla.web.RiplaApplication.java
License:Open Source License
private boolean initializeLayout(final IAppConfiguration inConfiguration) { setStyleName("ripla-window"); //$NON-NLS-1$ requestHandler = setRequestHandler(); SkinRegistry.INSTANCE.setDefaultSkin(inConfiguration.getDftSkinID()); final ISkin lSkin = SkinRegistry.INSTANCE.getActiveSkin(); final VerticalLayout lLayout = new VerticalLayout(); lLayout.setSizeFull();/* w w w .j a va 2 s. c om*/ lLayout.setStyleName("ripla-main"); setContent(lLayout); bodyView = createBody(); lLayout.addComponent(bodyView); lLayout.setExpandRatio(bodyView, 1); if (!beforeLogin(this)) { return false; } if (inConfiguration.getLoginAuthenticator() == null) { bodyView.addComponent(createBodyView(lSkin)); } else { bodyView.addComponent(createLoginView(inConfiguration, lSkin)); } if (lSkin.hasFooter()) { final Component lFooter = lSkin.getFooter(); lLayout.addComponent(lFooter); lLayout.setExpandRatio(lFooter, 0); } return true; }
From source file:org.ripla.web.RiplaApplication.java
License:Open Source License
/** * Creates the application's login view.<br /> * Subclasses may override.//from w ww. java 2s.com * * @param inConfiguration * {@link IAppConfiguration} the application's configuration * object * @param inSkin * {@link ISkin} the actual application skin * @return {@link Component} the application's login view */ private Component createLoginView(final IAppConfiguration inConfiguration, final ISkin inSkin) { final VerticalLayout out = new VerticalLayout(); out.setStyleName("ripla-body"); out.setSizeFull(); if (inSkin.hasHeader()) { final Component lHeader = inSkin.getHeader(inConfiguration.getAppName()); out.addComponent(lHeader); out.setExpandRatio(lHeader, 0); } final RiplaLogin lLogin = new RiplaLogin(inConfiguration, this, UseCaseRegistry.INSTANCE.getUserAdmin()); out.addComponent(lLogin); out.setExpandRatio(lLogin, 1); return out; }
From source file:org.semanticsoft.vaaclipse.presentation.renderers.PartRenderer.java
License:Open Source License
@Override public void createWidget(MUIElement element, MElementContainer<MUIElement> parent) { VerticalLayout pane = new VerticalLayout(); pane.setSizeFull();// ww w . ja v a2s . com final MPart part = (MPart) element; CssLayout toolbarArea = new CssLayout(); toolbarArea.setStyleName("mparttoolbararea"); toolbarArea.setSizeUndefined(); toolbarArea.setWidth("100%"); pane.addComponent(toolbarArea); //create toolbar MToolBar toolbar = part.getToolbar(); if (toolbar != null && toolbar.isToBeRendered()) { Component toolbarWidget = (Component) renderingEngine.createGui(toolbar); ((AbstractLayout) toolbarWidget).setSizeUndefined(); toolbarWidget.setStyleName("mparttoolbar"); toolbarArea.addComponent(toolbarWidget); } VerticalLayout contributionArea = new VerticalLayout(); contributionArea.setSizeFull(); pane.addComponent(contributionArea); pane.setExpandRatio(contributionArea, 100); pane.setStyleName("part"); element.setWidget(pane); IEclipseContext localContext = part.getContext(); localContext.set(Component.class, contributionArea); localContext.set(ComponentContainer.class, contributionArea); localContext.set(VerticalLayout.class, contributionArea); localContext.set(MPart.class, part); SavePromptSetup savePromptProvider = new SavePromptSetup(); savePrompts.put(part, savePromptProvider); localContext.set(SavePromptSetup.class, savePromptProvider); if (part instanceof MInputPart) localContext.set(MInputPart.class, (MInputPart) part); IContributionFactory contributionFactory = (IContributionFactory) localContext .get(IContributionFactory.class.getName()); Object newPart = contributionFactory.create(part.getContributionURI(), localContext); part.setObject(newPart); }
From source file:org.sensorhub.ui.AdminUI.java
License:Mozilla Public License
@Override protected void init(VaadinRequest request) { String configClass = null;/*from ww w . ja v a 2 s .c o m*/ moduleConfigLists.clear(); // retrieve module config try { Properties initParams = request.getService().getDeploymentConfiguration().getInitParameters(); String moduleID = initParams.getProperty(AdminUIModule.SERVLET_PARAM_MODULE_ID); uiConfig = (AdminUIConfig) SensorHub.getInstance().getModuleRegistry().getModuleById(moduleID) .getConfiguration(); } catch (Exception e) { throw new RuntimeException("Cannot get UI module configuration", e); } try { // load default form builders customForms.put(HttpServerConfig.class.getCanonicalName(), HttpServerConfigForm.class); customForms.put(StreamStorageConfig.class.getCanonicalName(), GenericStorageConfigForm.class); customForms.put(CommConfig.class.getCanonicalName(), CommConfigForm.class); customForms.put(SOSConfigForm.SOS_PACKAGE + "SOSServiceConfig", SOSConfigForm.class); customForms.put(SOSConfigForm.SOS_PACKAGE + "SOSProviderConfig", SOSConfigForm.class); // load custom form builders defined in config for (CustomUIConfig customForm : uiConfig.customForms) { configClass = customForm.configClass; Class<?> clazz = Class.forName(customForm.uiClass); customForms.put(configClass, (Class<IModuleConfigForm>) clazz); log.debug("Loaded custom form for " + configClass); } } catch (Exception e) { log.error("Error while instantiating form builder for config class " + configClass, e); } try { // load default panel builders customPanels.put(SensorConfig.class.getCanonicalName(), SensorAdminPanel.class); customPanels.put(StorageConfig.class.getCanonicalName(), StorageAdminPanel.class); // load custom panel builders defined in config for (CustomUIConfig customPanel : uiConfig.customPanels) { configClass = customPanel.configClass; Class<?> clazz = Class.forName(customPanel.uiClass); customPanels.put(configClass, (Class<IModuleAdminPanel<?>>) clazz); log.debug("Loaded custom panel for " + configClass); } } catch (Exception e) { log.error("Error while instantiating panel builder for config class " + configClass, e); } // register new field converter for interger numbers @SuppressWarnings("serial") ConverterFactory converterFactory = new DefaultConverterFactory() { @Override protected <PRESENTATION, MODEL> Converter<PRESENTATION, MODEL> findConverter( Class<PRESENTATION> presentationType, Class<MODEL> modelType) { // Handle String <-> Integer/Short/Long if (presentationType == String.class && (modelType == Long.class || modelType == Integer.class || modelType == Short.class)) { return (Converter<PRESENTATION, MODEL>) new StringToIntegerConverter() { @Override protected NumberFormat getFormat(Locale locale) { NumberFormat format = super.getFormat(Locale.US); format.setGroupingUsed(false); return format; } }; } // Let default factory handle the rest return super.findConverter(presentationType, modelType); } }; VaadinSession.getCurrent().setConverterFactory(converterFactory); // init main panels HorizontalSplitPanel splitPanel = new HorizontalSplitPanel(); splitPanel.setMinSplitPosition(300.0f, Unit.PIXELS); splitPanel.setMaxSplitPosition(30.0f, Unit.PERCENTAGE); splitPanel.setSplitPosition(350.0f, Unit.PIXELS); setContent(splitPanel); // build left pane VerticalLayout leftPane = new VerticalLayout(); leftPane.setSizeFull(); // header image and title Component header = buildHeader(); leftPane.addComponent(header); leftPane.setExpandRatio(header, 0); // toolbar Component toolbar = buildToolbar(); leftPane.addComponent(toolbar); leftPane.setExpandRatio(toolbar, 0); // accordion with several sections Accordion stack = new Accordion(); stack.setSizeFull(); VerticalLayout layout; Tab tab; layout = new VerticalLayout(); tab = stack.addTab(layout, "Sensors"); tab.setIcon(ACC_TAB_ICON); buildModuleList(layout, SensorConfig.class); layout = new VerticalLayout(); tab = stack.addTab(layout, "Storage"); tab.setIcon(ACC_TAB_ICON); buildModuleList(layout, StorageConfig.class); layout = new VerticalLayout(); tab = stack.addTab(layout, "Processing"); tab.setIcon(ACC_TAB_ICON); buildModuleList(layout, ProcessConfig.class); layout = new VerticalLayout(); tab = stack.addTab(layout, "Services"); tab.setIcon(ACC_TAB_ICON); buildModuleList(layout, ServiceConfig.class); layout = new VerticalLayout(); tab = stack.addTab(layout, "Clients"); tab.setIcon(ACC_TAB_ICON); buildModuleList(layout, ClientConfig.class); layout = new VerticalLayout(); tab = stack.addTab(layout, "Network"); tab.setIcon(ACC_TAB_ICON); buildNetworkConfig(layout); leftPane.addComponent(stack); leftPane.setExpandRatio(stack, 1); splitPanel.addComponent(leftPane); // init config area configArea = new VerticalLayout(); configArea.setMargin(true); splitPanel.addComponent(configArea); }
From source file:org.tltv.gantt.demo.DemoUI.java
License:Apache License
@Override protected void init(VaadinRequest request) { ganttListener = null;/*w w w .jav a 2 s . c o m*/ createGantt(); MenuBar menu = controlsMenuBar(); Panel controls = createControls(); TabSheet tabsheet = new TabSheet(); tabsheet.setSizeFull(); Component wrapper = UriFragmentWrapperFactory.wrapByUriFragment(UI.getCurrent().getPage().getUriFragment(), gantt); if (wrapper instanceof GanttListener) { ganttListener = (GanttListener) wrapper; } final VerticalLayout layout = new VerticalLayout(); layout.setStyleName("demoContentLayout"); layout.setSizeFull(); layout.addComponent(menu); layout.addComponent(controls); layout.addComponent(wrapper); layout.setExpandRatio(wrapper, 1); setContent(layout); }
From source file:org.vaadin.addon.borderlayout.BorderlayoutUI.java
private Component getSimpleExamle() { VerticalLayout vlo = new VerticalLayout(); vlo.setHeight("100%"); vlo.setWidth("100%"); vlo.setSpacing(true);/* www . j a v a 2s. c om*/ vlo.addComponent(getTestButtons()); for (int i = 0; i < components.length; i++) { components[i] = new TextArea(); ((TextArea) components[i]).setValue(texts[i]); components[i].setSizeFull(); } bl = new BorderLayout(); vlo.addComponent(bl); vlo.setExpandRatio(bl, 1); bl.addComponent(components[0], BorderLayout.Constraint.NORTH); bl.addComponent(components[1], BorderLayout.Constraint.SOUTH); bl.addComponent(components[2], BorderLayout.Constraint.CENTER); bl.addComponent(components[3], BorderLayout.Constraint.EAST); bl.addComponent(components[4], BorderLayout.Constraint.WEST); return vlo; }
From source file:org.vaadin.addon.borderlayout.BorderlayoutUI.java
private Component getAnotherExample() { VerticalLayout vlo = new VerticalLayout(); vlo.setSpacing(true);//w ww . j a v a 2s. c o m HorizontalLayout hlo1 = new HorizontalLayout(); hlo1.setSpacing(true); vlo.addComponent(hlo1); bl2 = new BorderLayout(); vlo.addComponent(bl2); vlo.setExpandRatio(bl2, 1); final Button button1 = new Button("call addComponent(new TextField(\"test\"))"); button1.addClickListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { try { bl2.addComponent(new TextField("test")); } catch (Exception e) { Notification.show(e.toString()); } } }); final Button button2 = new Button("Remove north"); final Button button3 = new Button("Remove west"); final Button button4 = new Button("Remove center"); final Button button5 = new Button("Remove east"); final Button button6 = new Button("Remove south"); button2.addClickListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { bl2.removeComponent(Constraint.NORTH); } }); button3.addClickListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { bl2.removeComponent(Constraint.WEST); } }); button4.addClickListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { bl2.removeComponent(Constraint.CENTER); } }); button5.addClickListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { bl2.removeComponent(Constraint.EAST); } }); button6.addClickListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { bl2.removeComponent(Constraint.SOUTH); } }); hlo1.addComponents(button1, button2, button3, button4, button5, button6); return vlo; }
From source file:org.vaadin.addonhelpers.TListUi.java
License:Apache License
private void loadTestClasses(TListUi aThis) { if (testClassess != null) { return;/* w ww. jav a 2 s. c om*/ } testClassess = listTestClasses(); Table table = new Table("Test cases", testClassess); table.setVisibleColumns("name", "description"); table.addGeneratedColumn("name", new Table.ColumnGenerator() { public Object generateCell(Table source, Object itemId, Object columnId) { String name = (String) source.getItem(itemId).getItemProperty(columnId).getValue(); Class clazz = (Class) source.getItem(itemId).getItemProperty("clazz").getValue(); Link link = new Link(); link.setResource(new ExternalResource("/" + clazz.getName())); link.setCaption(name); link.setTargetName("_new"); return link; } }); table.addGeneratedColumn("description", new Table.ColumnGenerator() { public Object generateCell(Table source, Object itemId, Object columnId) { String description = (String) source.getItem(itemId).getItemProperty(columnId).getValue(); return new Label(description); } }); table.setSizeFull(); table.setColumnExpandRatio("description", 1); VerticalLayout verticalLayout = new VerticalLayout(); TextField filter = new TextField(); filter.setInputPrompt("Filter list"); filter.addTextChangeListener(new TextChangeListener() { @Override public void textChange(TextChangeEvent event) { String text = event.getText(); testClassess.removeAllContainerFilters(); testClassess.addContainerFilter("name", text, true, false); } }); verticalLayout.addComponent(filter); filter.focus(); verticalLayout.addComponent(table); verticalLayout.setSizeFull(); verticalLayout.setExpandRatio(table, 1); verticalLayout.setMargin(true); setContent(verticalLayout); }
From source file:org.vaadin.addons.criteriacontainersample.AbstractEntityApplication.java
License:Apache License
@Override public void init() { Window mainWindow = new Window("Lazycontainer Application"); VerticalLayout mainLayout = new VerticalLayout(); mainLayout.setSizeFull();/*from w w w . ja v a 2 s. c om*/ mainLayout.setMargin(true); mainLayout.setSpacing(true); createFilterPanel(mainLayout); entityManager = ENTITY_MANAGER_FACTORY.createEntityManager(); criteriaContainer = createTaskContainer(); int size = criteriaContainer.size(); if (size == 0 && TESTING) { createEntities(); criteriaContainer.refresh(); size = criteriaContainer.size(); } createTable(criteriaContainer); table.setPageLength(0); table.setSizeUndefined(); table.setHeight("100%"); mainLayout.addComponent(table); mainLayout.setExpandRatio(table, 100.0F); mainWindow.setContent(mainLayout); setMainWindow(mainWindow); }
From source file:org.vaadin.addons.filterbuilder.FilterBuilderUI.java
License:Apache License
@Override protected void init(VaadinRequest request) { getPage().setTitle("FilterBuilder demo"); HorizontalSplitPanel content = new HorizontalSplitPanel(); content.setSizeFull();/*w ww .ja v a 2s.co m*/ // Left pane leftPane = new VerticalLayout(); { leftPane.setSizeFull(); leftPane.setMargin(true); leftPane.setSpacing(true); filterField = new TextField(); filterField.setInputPrompt("Write your filter here"); filterField.setIcon(FontAwesome.SEARCH); filterField.addStyleName("filter-field inline-icon"); filterField.setWidth(100, Unit.PERCENTAGE); filterField.setTextChangeEventMode(TextField.TextChangeEventMode.LAZY); filterField.setTextChangeTimeout(1000); filterField.addTextChangeListener(this); leftPane.addComponent(filterField); filterLabel = new Label(); filterLabel.setWidth(100, Unit.PERCENTAGE); try { dataSource = new BeanItemContainer<>(TestCaseBean.class, TestCaseBean.loadMockData()); dataSource.removeContainerProperty("address"); dataSource.addNestedContainerProperty("address.country"); dataSource.addNestedContainerProperty("address.city"); dataSource.addNestedContainerProperty("address.street"); dataSource.addNestedContainerProperty("address.address"); } catch (Exception e) { logger.error("Could not load mock data"); } table = new Table(null, dataSource); table.setSizeFull(); table.setVisibleColumns("id", "firstName", "lastName", "jobTitle", "dob", "salary", "address.country", "address.city", "address.street", "address.address", "unemployed"); table.setSelectable(true); leftPane.addComponent(table); leftPane.setExpandRatio(table, 1); } content.setFirstComponent(leftPane); // Right pane rightPane = new TabSheet(); { rightPane.setSizeFull(); VerticalLayout lastUsedFiltersPane = new VerticalLayout(); lastUsedFiltersPane.setSizeFull(); lastUsedFiltersPane.setMargin(true); lastUsedFiltersPane.setSpacing(true); lastUsedFilters = new IndexedContainer(); lastUsedFilters.addContainerProperty("filter", String.class, null); lastUsedFiltersTable = new Table(); lastUsedFiltersTable.setSizeFull(); lastUsedFiltersTable.setContainerDataSource(lastUsedFilters); lastUsedFiltersTable.setSortEnabled(false); lastUsedFiltersTable.setSelectable(true); lastUsedFiltersTable.setColumnHeaderMode(Table.ColumnHeaderMode.HIDDEN); lastUsedFiltersTable.addItemClickListener(this); final Button removeFilterButton = new Button("Remove", new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { if (lastUsedFiltersTable.getValue() != null) { lastUsedFilters.removeItem(lastUsedFiltersTable.getValue()); lastUsedFiltersTable.setValue(null); } } }); removeFilterButton.setEnabled(false); lastUsedFiltersTable.addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(Property.ValueChangeEvent event) { removeFilterButton.setEnabled(lastUsedFiltersTable.getValue() != null); } }); lastUsedFiltersPane.addComponents(lastUsedFiltersTable, removeFilterButton); lastUsedFiltersPane.setExpandRatio(lastUsedFiltersTable, 1); rightPane.addTab(lastUsedFiltersPane).setCaption("Last used filters"); VerticalLayout dateFormatsPane = new VerticalLayout(); dateFormatsPane.setMargin(true); dateFormats = new IndexedContainer(); dateFormats.addContainerProperty("format", String.class, null); for (SimpleDateFormat dateFormat : FilterBuilder.DATE_FORMATS) { final Item item = dateFormats.addItem(dateFormat.toPattern()); item.getItemProperty("format").setValue(dateFormat.toPattern()); } dateFormatsTable = new Table(); dateFormatsTable.setWidth(100, Unit.PERCENTAGE); dateFormatsTable.setContainerDataSource(dateFormats); dateFormatsTable.setSortEnabled(false); dateFormatsTable.setSelectable(true); dateFormatsTable.setColumnHeaderMode(Table.ColumnHeaderMode.HIDDEN); dateFormatsPane.addComponent(dateFormatsTable); rightPane.addTab(dateFormatsPane).setCaption("Known date formats"); } VerticalLayout layout = new VerticalLayout(); layout.setMargin(true); content.setSecondComponent(rightPane); content.setSplitPosition(80, Unit.PERCENTAGE); setContent(content); logger.debug("UI initialized"); }