List of usage examples for com.vaadin.ui GridLayout replaceComponent
@Override public void replaceComponent(Component oldComponent, Component newComponent)
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 av a 2s . c om*/ // 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
protected void buildDataPanel(GridLayout form, IRecordStorageModule<?> storage) { // measurement outputs int i = 1;//from w w w . j ava2 s.c o m if (storage.isEnabled()) { for (IRecordStoreInfo dsInfo : storage.getRecordStores().values()) { Panel panel = newPanel("Stream #" + i++); GridLayout panelLayout = ((GridLayout) panel.getContent()); panelLayout.setSpacing(true); // stored time period double[] timeRange = storage.getRecordsTimeRange(dsInfo.getName()); Label l = new Label("<b>Time Range:</b> " + new DateTimeFormat().formatIso(timeRange[0], 0) + " / " + new DateTimeFormat().formatIso(timeRange[1], 0)); l.setContentMode(ContentMode.HTML); panelLayout.addComponent(l, 0, 0, 1, 0); // time line panelLayout.addComponent(buildGantt(storage, dsInfo), 0, 1, 1, 1); // data structure DataComponent dataStruct = dsInfo.getRecordDescription(); Component sweForm = new SWECommonForm(dataStruct); panelLayout.addComponent(sweForm); // data table panelLayout.addComponent(buildTable(storage, dsInfo)); if (oldPanel != null) form.replaceComponent(oldPanel, panel); else form.addComponent(panel); oldPanel = panel; } } }