List of usage examples for com.vaadin.ui Notification Notification
public Notification(String caption, String description, Type type)
From source file:org.sensorhub.ui.DefaultModulePanel.java
License:Mozilla Public License
@Override @SuppressWarnings("serial") public void build(final MyBeanItem<ModuleConfig> beanItem, final ModuleType module) { setSizeUndefined();//from ww w . ja v a2s . c o m setWidth(100.0f, Unit.PERCENTAGE); setMargin(false); setSpacing(true); // label with module name String moduleName = getTitle(beanItem.getBean()); Label title = new Label(moduleName); title.setStyleName(STYLE_H2); addComponent(title); // apply changes button Button applyButton = new Button("Apply Changes"); applyButton.setIcon(APPLY_ICON); applyButton.addStyleName("apply-button"); addComponent(applyButton); // config form final IModuleConfigForm form = getConfigForm(beanItem, module); addComponent(form); // apply button action applyButton.addClickListener(new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { try { form.commit(); if (module != null) ((IModule<ModuleConfig>) module).updateConfig(beanItem.getBean()); } catch (Exception e) { String msg = "Error while updating module configuration"; Page page = AdminUI.getInstance().getPage(); new Notification("Error", msg + '\n' + e.getMessage(), Notification.Type.ERROR_MESSAGE) .show(page); //Notification.show("Error", msg + '\n' + e.getMessage(), Notification.Type.ERROR_MESSAGE); AdminUI.log.error(msg, e); } } }); }
From source file:org.sensorhub.ui.NetworkAdminPanel.java
License:Mozilla Public License
@SuppressWarnings("serial") protected void addScannedDevices(final GridLayout form, final ICommNetwork<?> module) { // section title Label sectionLabel = new Label("Detected Devices"); sectionLabel.addStyleName(STYLE_H3); sectionLabel.addStyleName(STYLE_COLORED); form.addComponent(sectionLabel);// w w w .j a v a 2s. c o m // scan button scanButton = new Button("Start Scan"); scanButton.setIcon(REFRESH_ICON); scanButton.addStyleName("scan-button"); scanButton.setEnabled(module.isStarted()); form.addComponent(scanButton); // device table final Table table = new Table(); table.setWidth(100.0f, Unit.PERCENTAGE); table.setPageLength(10); table.setSelectable(true); table.setImmediate(true); table.setColumnReorderingAllowed(false); table.addContainerProperty("Name", String.class, null); table.addContainerProperty("Type", String.class, null); table.addContainerProperty("Address", String.class, null); table.addContainerProperty("Signal Level", String.class, null); // scan button handler scanButton.addClickListener(new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { try { if (!scanning) { scanning = true; scanButton.setCaption("Stop Scan"); table.clear(); module.getDeviceScanner().startScan(new IDeviceScanCallback() { @Override public void onDeviceFound(final IDeviceInfo info) { AdminUI.getInstance().access(new Runnable() { @Override public void run() { String itemId = info.getAddress() + '/' + info.getType(); // if address was already detected, refresh info if (table.containsId(itemId)) { table.getContainerProperty(itemId, "Name").setValue(info.getName()); table.getContainerProperty(itemId, "Type").setValue(info.getType()); table.getContainerProperty(itemId, "Signal Level") .setValue(info.getSignalLevel()); } else { table.addItem(new Object[] { info.getName(), info.getType(), info.getAddress(), info.getSignalLevel() }, itemId); } AdminUI.getInstance().push(); } }); } @Override public void onScanError(Throwable e) { String msg = "Error during device scan"; Page page = AdminUI.getInstance().getPage(); new Notification("Error", msg + '\n' + e.getMessage(), Notification.Type.ERROR_MESSAGE).show(page); AdminUI.log.error(msg, e); } }); // automatically stop scan after 30s new Timer().schedule(new TimerTask() { @Override public void run() { stopScan(module); } }, 30000); } else { stopScan(module); } } catch (Exception e) { String msg = "Error scanning for devices"; Page page = AdminUI.getInstance().getPage(); new Notification("Error", msg + '\n' + e.getMessage(), Notification.Type.ERROR_MESSAGE) .show(page); //Notification.show("Error", msg + '\n' + e.getMessage(), Notification.Type.ERROR_MESSAGE); AdminUI.log.error(msg, e); } } }); form.addComponent(table); }