List of usage examples for com.vaadin.ui GridLayout addComponent
@Override public void addComponent(Component component)
From source file:org.sensorhub.ui.SensorAdminPanel.java
License:Mozilla Public License
@Override public void build(final MyBeanItem<ModuleConfig> beanItem, final ISensorModule<?> module) { super.build(beanItem, module); // add section label final GridLayout form = new GridLayout(); form.setWidth(100.0f, Unit.PERCENTAGE); form.setMargin(false);// w w w . j a va 2s .c o m form.setSpacing(true); // section title form.addComponent(new Label("")); HorizontalLayout titleBar = new HorizontalLayout(); titleBar.setSpacing(true); Label sectionLabel = new Label("Inputs/Outputs"); sectionLabel.addStyleName(STYLE_H3); sectionLabel.addStyleName(STYLE_COLORED); titleBar.addComponent(sectionLabel); titleBar.setComponentAlignment(sectionLabel, Alignment.MIDDLE_LEFT); // refresh button to show latest record Button refreshButton = new Button("Refresh"); refreshButton.setDescription("Load latest data from sensor"); refreshButton.setIcon(REFRESH_ICON); refreshButton.addStyleName(STYLE_QUIET); titleBar.addComponent(refreshButton); titleBar.setComponentAlignment(refreshButton, Alignment.MIDDLE_LEFT); refreshButton.addClickListener(new ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(ClickEvent event) { rebuildSwePanels(form, module); } }); form.addComponent(titleBar); // add I/O panel rebuildSwePanels(form, module); addComponent(form); }
From source file:org.sensorhub.ui.SensorAdminPanel.java
License:Mozilla Public License
protected void rebuildSwePanels(GridLayout form, ISensorModule<?> module) { if (module != null) { Panel oldPanel;/*from w w w . j a v a2s . c o m*/ // measurement outputs oldPanel = obsPanel; obsPanel = newPanel("Observation Outputs"); for (ISensorDataInterface output : module.getObservationOutputs().values()) { DataComponent dataStruct = output.getRecordDescription().copy(); DataBlock latestRecord = output.getLatestRecord(); if (latestRecord != null) dataStruct.setData(latestRecord); // data structure Component sweForm = new SWECommonForm(dataStruct); ((Layout) obsPanel.getContent()).addComponent(sweForm); } if (oldPanel != null) form.replaceComponent(oldPanel, obsPanel); else form.addComponent(obsPanel); // status outputs oldPanel = statusPanel; statusPanel = newPanel("Status Outputs"); for (ISensorDataInterface output : module.getStatusOutputs().values()) { Component sweForm = new SWECommonForm(output.getRecordDescription()); ((Layout) statusPanel.getContent()).addComponent(sweForm); } if (oldPanel != null) form.replaceComponent(oldPanel, statusPanel); else form.addComponent(statusPanel); // command inputs oldPanel = commandsPanel; commandsPanel = newPanel("Command Inputs"); for (ISensorControlInterface input : module.getCommandInputs().values()) { Component sweForm = new SWECommonForm(input.getCommandDescription()); ((Layout) commandsPanel.getContent()).addComponent(sweForm); } if (oldPanel != null) form.replaceComponent(oldPanel, commandsPanel); else form.addComponent(commandsPanel); } }
From source file:org.sensorhub.ui.StorageAdminPanel.java
License:Mozilla Public License
@Override public void build(final MyBeanItem<ModuleConfig> beanItem, final IRecordStorageModule<?> storage) { super.build(beanItem, storage); if (storage != null) { // section layout final GridLayout form = new GridLayout(); form.setWidth(100.0f, Unit.PERCENTAGE); form.setMargin(false);/*w w w . j av a2s . co m*/ form.setSpacing(true); // section title form.addComponent(new Label("")); HorizontalLayout titleBar = new HorizontalLayout(); titleBar.setSpacing(true); Label sectionLabel = new Label("Data Store Content"); sectionLabel.addStyleName(STYLE_H3); sectionLabel.addStyleName(STYLE_COLORED); titleBar.addComponent(sectionLabel); titleBar.setComponentAlignment(sectionLabel, Alignment.MIDDLE_LEFT); // refresh button to show latest record Button refreshButton = new Button("Refresh"); refreshButton.setDescription("Reload data from storage"); refreshButton.setIcon(REFRESH_ICON); refreshButton.addStyleName(STYLE_QUIET); titleBar.addComponent(refreshButton); titleBar.setComponentAlignment(refreshButton, Alignment.MIDDLE_LEFT); refreshButton.addClickListener(new ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(ClickEvent event) { buildDataPanel(form, storage); } }); form.addComponent(titleBar); // add I/O panel buildDataPanel(form, storage); addComponent(form); } }
From source file:org.vaadin.spinkit.demo.DemoUI.java
License:Apache License
private Component spinnersContainer(String primaryStyleName) { int types = SpinnerType.values().length; GridLayout spinners = new GridLayout(4, (types / 4 + types % 4)); spinners.setSizeFull();/*from w w w.j a va 2 s. co m*/ spinners.setDefaultComponentAlignment(Alignment.MIDDLE_CENTER); spinners.setSpacing(true); spinners.setWidth(100, Unit.PERCENTAGE); StringToEnumConverter converter = new StringToEnumConverter(); for (SpinnerType type : SpinnerType.values()) { Spinner spinner = new Spinner(type); spinner.setCaption(converter.convertToPresentation(type, String.class, getLocale())); if (primaryStyleName != null) { spinner.setPrimaryStyleName(primaryStyleName); } spinners.addComponent(spinner); } return spinners; }
From source file:org.vaadin.spinkit.demo.DemoUI.java
License:Apache License
private Component spinnerSizesContainer() { int types = SpinnerSize.values().length; GridLayout spinners = new GridLayout(4, (types / 4 + types % 4)); spinners.setSizeFull();//from w w w. j av a2s . c om spinners.setDefaultComponentAlignment(Alignment.MIDDLE_CENTER); spinners.setSpacing(true); ComboBox selector = new ComboBox("Select spinner type", Arrays.asList(SpinnerType.values())); selector.setNullSelectionAllowed(false); selector.setPageLength(0); selector.setValue(SpinnerType.ROTATING_PLANE); selector.addValueChangeListener(e -> { for (Component c : spinners) { if (c instanceof Spinner) { ((Spinner) c).setType((SpinnerType) selector.getValue()); } } }); StringToEnumConverter converter = new StringToEnumConverter(); for (SpinnerSize size : SpinnerSize.values()) { Spinner spinner = new Spinner(SpinnerType.ROTATING_PLANE); spinner.setSize(size); spinner.setCaption(converter.convertToPresentation(size, String.class, getLocale())); spinners.addComponent(spinner); } VerticalLayout l = new VerticalLayout(); l.setDefaultComponentAlignment(Alignment.TOP_CENTER); l.setSizeFull(); l.setMargin(false); l.setSpacing(true); l.addComponents(selector, spinners); l.setExpandRatio(spinners, 1); return l; }
From source file:probe.com.view.core.SingleStudyFilterLayout.java
/** * * @param dataset//from w ww .j av a 2s . co m * @param datasetIndex * @param uniqueAttr * @param view */ public SingleStudyFilterLayout(QuantDatasetObject dataset, int datasetIndex, boolean[] uniqueAttr, boolean view) { init(); this.setMargin(new MarginInfo(false, false, false, false)); VerticalLayout miniLayout = new VerticalLayout(); Label miniAttrLabel = new Label(); if (!dataset.getUniqueValues().equalsIgnoreCase("")) { miniAttrLabel.setValue("[ " + dataset.getUniqueValues() + "]"); } miniLayout.addComponent(miniAttrLabel); GridLayout studyInfo = new GridLayout(); studyInfo.setColumns(3); studyInfo.setWidth("100%"); SubTreeHideOnClick layout = new SubTreeHideOnClick("Dataset " + datasetIndex, studyInfo, miniLayout, view); this.addComponent(layout); this.setComponentAlignment(layout, Alignment.MIDDLE_CENTER); for (int i = 0; i < uniqueAttr.length; i++) { boolean check = uniqueAttr[i]; if (check) { if (!dataset.getProperty(i).toString().trim().equalsIgnoreCase("Not Available") && !dataset.getProperty(i).toString().trim().equalsIgnoreCase("0") && !dataset.getProperty(i).toString().trim().equalsIgnoreCase("-1")) { if (publicationInfoLayoutComponents[i] != null) { studyInfo.addComponent(publicationInfoLayoutComponents[i]); ((InformationField) publicationInfoLayoutComponents[i]) .setValue(dataset.getProperty(i).toString(), null); } } } } Button btn = new Button("Load Dataset"); btn.setStyleName(Reindeer.BUTTON_SMALL); VerticalLayout btnLayout = new VerticalLayout(); btnLayout.setMargin(true); btnLayout.setHeight("30px"); btnLayout.addComponent(btn); int rowNum = studyInfo.getRows(); if (studyInfo.getComponentCount() % 3 != 0) { studyInfo.addComponent(btnLayout, 2, rowNum - 1); } else { studyInfo.setRows(rowNum + 1); studyInfo.addComponent(btnLayout, 2, rowNum); } studyInfo.setComponentAlignment(btnLayout, Alignment.BOTTOM_LEFT); }
From source file:VaadinIRC.GUI.channelGUI.java
License:Open Source License
/** * Creates the GUI for a channel.//w w w . j a v a 2 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); }