List of usage examples for com.vaadin.ui Notification Notification
public Notification(String caption, String description, Type type)
From source file:fi.aalto.drumbeat.drumbeatUI.DrumbeatFileHandler.java
License:Open Source License
private boolean convertIFC2RDFDefault(File file, String name) { try {// w ww .j a va2 s. com IfcModel model = IfcParserUtil.parseModel(file.getAbsolutePath()); ComplexProcessorConfiguration groundingConfiguration = IfcModelAnalyser.getDefaultGroundingRuleSets(); IfcModelAnalyser modelAnalyser = new IfcModelAnalyser(model); modelAnalyser.groundNodes(groundingConfiguration); OntModel modelExport = ModelFactory.createOntologyModel(OntModelSpec.RDFS_MEM_TRANS_INF); Ifc2RdfExportUtil.exportModelToJenaModel(modelExport, model); RdfUtils.exportJenaModelToRdfFile(modelExport, DrumbeatConstants.marmotta_import_directory + file.getName(), RDFFormat.TURTLE, false); JenaModelFactoryBase jenaModelFactory = new MemoryJenaModelFactory(); try { Model metaModelGraph = jenaModelFactory.createModel(); try { metaModelGraph.read(DrumbeatConstants.metadata_location, "TURTLE"); } catch (Exception e) { e.printStackTrace(); } Ifc2RdfExportUtil.exportMetaModelToJenaModel(DrumbeatConstants.metadata_base + name, metaModelGraph, model); FileOutputStream fout = new FileOutputStream(new File(DrumbeatConstants.metadata_location)); RDFDataMgr.write(fout, metaModelGraph, RDFFormat.TURTLE_PRETTY); fout.close(); } catch (Exception e) { e.printStackTrace(); } } catch (Exception e) { e.printStackTrace(); Notification n = new Notification("Default IFC2RDF export error ", e.getMessage(), Notification.Type.ERROR_MESSAGE); n.setDelayMsec(5000); n.show(Page.getCurrent()); return false; } return true; }
From source file:fr.amapj.view.engine.ui.AmapUI.java
License:Open Source License
@Override public void receiveBroadcast(final String message) { access(new Runnable() { @Override//from ww w . j a va 2 s . c o m public void run() { Notification n = new Notification("Message recu", message, Type.WARNING_MESSAGE); n.show(getPage()); } }); }
From source file:net.anthavio.vinbudin.vui.ChatUI.java
License:Open Source License
@Logged //@EventBusListenerMethod public void onChatMessage(ChatMessage message) { //Push magic happens here access(new Runnable() { @Override/*from w w w . j a va 2 s. c om*/ public void run() { try { if (message.getAuthor() != getMe()) { Notification n = new Notification("Message from " + message.getAuthor().getName(), message.getText(), Type.TRAY_NOTIFICATION); n.show(getPage()); } refreshMessageBoard(); } catch (Exception x) { logger.warn("onChatMessage push failed", x); } } }); }
From source file:org.dussan.vaadin.dcharts.test.DChartsTestUI.java
License:Apache License
private void showEventNotification(String event, Object chartObject) { String caption = "<span style='color:#ff6600'>Event: " + event + "</span>"; StringBuilder description = new StringBuilder(); if (chartObject instanceof ChartData) { ChartData chartData = (ChartData) chartObject; description.append("<b>Chart id:</b> " + chartData.getChartId()); if (chartData.getSeriesIndex() != null) { description.append("<br /><b>Series index:</b> " + chartData.getSeriesIndex()); }/*from w w w.j av a 2 s . c om*/ if (chartData.getPointIndex() != null) { description.append("<br /><b>Point index:</b> " + chartData.getPointIndex()); } if (chartData.getData() != null) { description.append("<br /><b>Chart data:</b> " + Arrays.toString(chartData.getData())); } if (chartData.getOriginData() != null) { if (chartData.getOriginData() instanceof Object[]) { description.append( "<br /><b>Origin data:</b> " + Arrays.toString((Object[]) chartData.getOriginData())); } else { description.append("<br /><b>Origin data:</b> " + chartData.getOriginData().toString()); } } } else if (chartObject instanceof BufferedImage) { BufferedImage chartImage = (BufferedImage) chartObject; description.append("<b>Chart image width:</b> " + chartImage.getWidth() + "px"); description.append("<br /><b>Chart image height:</b> " + chartImage.getHeight() + "px"); } Notification notification = new Notification(caption, description.toString(), Type.TRAY_NOTIFICATION); notification.setDelayMsec(3000); notification.setHtmlContentAllowed(true); notification.show(Page.getCurrent()); }
From source file:org.esn.esobase.view.tab.ChangePasswordTab.java
private void changePasswordAction() { sysAccountService.updateUserPassword(SpringSecurityHelper.getSysAccount(), password.getValue()); Notification n = new Notification(" ?", " ? ", Notification.Type.HUMANIZED_MESSAGE); n.setDelayMsec(2000);//from ww w. j a v a2s . c o m n.show(getUI().getPage()); TabSheet tabs = (TabSheet) this.getParent(); tabs.removeTab(tabs.getTab(this)); }
From source file:org.freakz.hokan_ng_springboot.bot.SingleSecuredUI.java
License:Apache License
@Override public void receiveBroadcast(String message) { access(new Runnable() { @Override// w w w . j ava 2s . c om public void run() { Notification n = new Notification("IRC message", message, Notification.Type.TRAY_NOTIFICATION); n.show(getPage()); } }); }
From source file:org.groom.shell.Shell.java
License:Apache License
/** * Executes requested shell command.//from ww w.j av a2s .c o m * * @param cmd the shell command to execute */ public static String execute(final String cmd, final String path) { LOGGER.debug("Executing shell command: " + cmd); try { if (UI.getCurrent() != null) { Notification.show(cmd, Notification.Type.TRAY_NOTIFICATION); } List<String> commands = new ArrayList<String>(); if (PropertiesUtil.getProperty("groom", "os").equals("windows")) { commands.add("cmd"); commands.add("/c"); commands.add(cmd); } else { commands.add("/bin/sh"); commands.add("-c"); commands.add(cmd); } SystemCommandExecutor commandExecutor = new SystemCommandExecutor(path, commands); commandExecutor.executeCommand(); StringBuilder errorOutput = commandExecutor.getErrorOutput(); if (errorOutput.length() > 0) { LOGGER.error(errorOutput); { if (UI.getCurrent() != null) { final Notification notification = new Notification("Shell", errorOutput.toString(), Notification.Type.WARNING_MESSAGE); notification.setDelayMsec(5000); notification.setPosition(Position.BOTTOM_RIGHT); notification.show(Page.getCurrent()); } } } StringBuilder standardOutput = commandExecutor.getStandardOutput(); if (standardOutput == null) { return ""; } return standardOutput.toString(); } catch (final Throwable t) { LOGGER.error("Error executing shell command: " + cmd, t); return ""; } }
From source file:org.ikasan.dashboard.ui.administration.panel.PlatformConfigurationPanel.java
License:BSD License
protected Panel createMapPanel(final ConfigurationParameterMapImpl parameter) { Panel paramPanel = new Panel(); paramPanel.setStyleName("dashboard"); paramPanel.setWidth("100%"); GridLayout paramLayout = new GridLayout(2, 3); paramLayout.setSpacing(true);/*w w w . java 2 s . com*/ paramLayout.setSizeFull(); paramLayout.setMargin(true); paramLayout.setColumnExpandRatio(0, .25f); paramLayout.setColumnExpandRatio(1, .75f); Label label = new Label("Platform Configuration"); label.addStyleName(ValoTheme.LABEL_HUGE); label.setSizeUndefined(); paramLayout.addComponent(label, 0, 0, 1, 0); paramLayout.setComponentAlignment(label, Alignment.TOP_LEFT); final Map<String, String> valueMap = parameter.getValue(); final GridLayout mapLayout = new GridLayout(5, (valueMap.size() != 0 ? valueMap.size() : 1) + 1); mapLayout.setColumnExpandRatio(0, .05f); mapLayout.setColumnExpandRatio(1, .425f); mapLayout.setColumnExpandRatio(2, .05f); mapLayout.setColumnExpandRatio(3, .425f); mapLayout.setColumnExpandRatio(4, .05f); mapLayout.setMargin(true); mapLayout.setSpacing(true); mapLayout.setWidth("100%"); int i = 0; for (final String key : valueMap.keySet()) { final Label keyLabel = new Label("Name:"); final Label valueLabel = new Label("Value:"); final TextField keyField = new TextField(); keyField.setValue(key); keyField.setWidth("100%"); keyField.setNullSettingAllowed(false); keyField.addValidator( new NonZeroLengthStringValidator("Then configuration value name cannot be empty!")); keyField.setValidationVisible(false); final TextField valueField = new TextField(); valueField.setWidth("100%"); valueField.setValue(valueMap.get(key)); valueField.setNullSettingAllowed(false); valueField.addValidator(new NonZeroLengthStringValidator("Then configuration value cannot be empty!")); valueField.setValidationVisible(false); mapLayout.addComponent(keyLabel, 0, i); mapLayout.setComponentAlignment(keyLabel, Alignment.MIDDLE_RIGHT); mapLayout.addComponent(keyField, 1, i); mapLayout.addComponent(valueLabel, 2, i); mapLayout.setComponentAlignment(valueLabel, Alignment.MIDDLE_RIGHT); mapLayout.addComponent(valueField, 3, i); final String mapKey = parameter.getName() + i; TextFieldKeyValuePair pair = new TextFieldKeyValuePair(); pair.key = keyField; pair.value = valueField; this.mapTextFields.put(mapKey, pair); final Button removeButton = new Button("remove"); removeButton.setStyleName(ValoTheme.BUTTON_LINK); removeButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { valueMap.remove(key); mapLayout.removeComponent(keyLabel); mapLayout.removeComponent(valueLabel); mapLayout.removeComponent(keyField); mapLayout.removeComponent(valueField); mapLayout.removeComponent(removeButton); mapTextFields.remove(mapKey); } }); mapLayout.addComponent(removeButton, 4, i); i++; } final Button addButton = new Button("add"); addButton.setStyleName(ValoTheme.BUTTON_LINK); addButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { final Label keyLabel = new Label("Name:"); final Label valueLabel = new Label("Value:"); final TextField keyField = new TextField(); keyField.setWidth("100%"); keyField.setNullSettingAllowed(false); keyField.addValidator( new NonZeroLengthStringValidator("Then configuration value name cannot be empty!")); keyField.setValidationVisible(false); final TextField valueField = new TextField(); valueField.setWidth("100%"); valueField.setNullSettingAllowed(false); valueField.addValidator( new NonZeroLengthStringValidator("Then configuration value cannot be empty!")); valueField.setValidationVisible(false); mapLayout.insertRow(mapLayout.getRows()); mapLayout.removeComponent(addButton); mapLayout.addComponent(keyLabel, 0, mapLayout.getRows() - 2); mapLayout.setComponentAlignment(keyLabel, Alignment.MIDDLE_RIGHT); mapLayout.addComponent(keyField, 1, mapLayout.getRows() - 2); mapLayout.addComponent(valueLabel, 2, mapLayout.getRows() - 2); mapLayout.setComponentAlignment(valueLabel, Alignment.MIDDLE_RIGHT); mapLayout.addComponent(valueField, 3, mapLayout.getRows() - 2); final String mapKey = parameter.getName() + mapTextFields.size(); TextFieldKeyValuePair pair = new TextFieldKeyValuePair(); pair.key = keyField; pair.value = valueField; mapTextFields.put(mapKey, pair); final Button removeButton = new Button("remove"); removeButton.setStyleName(ValoTheme.BUTTON_LINK); removeButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { mapLayout.removeComponent(keyLabel); mapLayout.removeComponent(valueLabel); mapLayout.removeComponent(keyField); mapLayout.removeComponent(valueField); mapLayout.removeComponent(removeButton); mapTextFields.remove(mapKey); } }); mapLayout.addComponent(removeButton, 4, mapLayout.getRows() - 2); mapLayout.addComponent(addButton, 0, mapLayout.getRows() - 1); } }); mapLayout.addComponent(addButton, 0, mapLayout.getRows() - 1); Panel mapPanel = new Panel(); mapPanel.setStyleName(ValoTheme.PANEL_BORDERLESS); mapPanel.setContent(mapLayout); Button saveButton = new Button("Save"); saveButton.addStyleName(ValoTheme.BUTTON_SMALL); saveButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { try { for (TextFieldKeyValuePair textField : mapTextFields.values()) { textField.key.validate(); textField.value.validate(); } } catch (InvalidValueException e) { for (TextFieldKeyValuePair textField : mapTextFields.values()) { textField.key.setValidationVisible(true); textField.value.setValidationVisible(true); } Notification.show("Validation errors have occurred!", Type.ERROR_MESSAGE); return; } HashMap<String, String> map = new HashMap<String, String>(); logger.info("Saving map: " + mapTextFields.size()); for (String key : mapTextFields.keySet()) { if (key.startsWith(parameter.getName())) { TextFieldKeyValuePair pair = mapTextFields.get(key); logger.info("Saving for key: " + key); if (pair.key.getValue() != "") { map.put(pair.key.getValue(), pair.value.getValue()); } } } parameter.setValue(map); PlatformConfigurationPanel.this.configurationManagement.saveConfiguration(platformConfiguration); Notification notification = new Notification("Saved", "The configuration has been saved successfully!", Type.HUMANIZED_MESSAGE); notification.setStyleName(ValoTheme.NOTIFICATION_CLOSABLE); notification.show(Page.getCurrent()); } }); paramLayout.addComponent(mapPanel, 0, 1, 1, 1); paramLayout.setComponentAlignment(mapPanel, Alignment.TOP_CENTER); paramLayout.addComponent(saveButton, 0, 2, 1, 2); paramLayout.setComponentAlignment(saveButton, Alignment.TOP_CENTER); paramPanel.setContent(paramLayout); return paramPanel; }
From source file:org.ikasan.dashboard.ui.topology.window.ComponentConfigurationWindow.java
License:BSD License
@SuppressWarnings("unchecked") public void populate(Component component) { configuration = this.configurationManagement.getConfiguration(component.getConfigurationId()); if (configuration == null) { Server server = component.getFlow().getModule().getServer(); String url = "http://" + server.getUrl() + ":" + server.getPort() + component.getFlow().getModule().getContextRoot() + "/rest/configuration/createConfiguration/" + component.getFlow().getModule().getName() + "/" + component.getFlow().getName() + "/" + component.getName();//from w ww.j a v a2 s. c o m logger.info("Configuration Url: " + url); IkasanAuthentication authentication = (IkasanAuthentication) VaadinService.getCurrentRequest() .getWrappedSession().getAttribute(DashboardSessionValueConstants.USER); HttpAuthenticationFeature feature = HttpAuthenticationFeature.basic(authentication.getName(), (String) authentication.getCredentials()); ClientConfig clientConfig = new ClientConfig(); clientConfig.register(feature); Client client = ClientBuilder.newClient(clientConfig); ObjectMapper mapper = new ObjectMapper(); WebTarget webTarget = client.target(url); Response response = webTarget.request().get(); if (response.getStatus() != 200) { response.bufferEntity(); String responseMessage = response.readEntity(String.class); Notification.show("An error was received trying to create configured resource '" + component.getConfigurationId() + "': " + responseMessage, Type.ERROR_MESSAGE); } configuration = this.configurationManagement.getConfiguration(component.getConfigurationId()); } final List<ConfigurationParameter> parameters = (List<ConfigurationParameter>) configuration .getParameters(); this.layout = new GridLayout(2, parameters.size() + 6); this.layout.setSpacing(true); this.layout.setColumnExpandRatio(0, .25f); this.layout.setColumnExpandRatio(1, .75f); this.layout.setWidth("95%"); this.layout.setMargin(true); Label configurationParametersLabel = new Label("Configuration Parameters"); configurationParametersLabel.setStyleName(ValoTheme.LABEL_HUGE); this.layout.addComponent(configurationParametersLabel, 0, 0); GridLayout paramLayout = new GridLayout(2, 2); paramLayout.setSpacing(true); paramLayout.setSizeFull(); paramLayout.setMargin(true); paramLayout.setColumnExpandRatio(0, .25f); paramLayout.setColumnExpandRatio(1, .75f); Label configuredResourceIdLabel = new Label("Configured Resource Id"); configuredResourceIdLabel.addStyleName(ValoTheme.LABEL_LARGE); configuredResourceIdLabel.addStyleName(ValoTheme.LABEL_BOLD); Label configuredResourceIdValueLabel = new Label(configuration.getConfigurationId()); configuredResourceIdValueLabel.addStyleName(ValoTheme.LABEL_LARGE); configuredResourceIdValueLabel.addStyleName(ValoTheme.LABEL_BOLD); paramLayout.addComponent(configuredResourceIdLabel, 0, 0); paramLayout.setComponentAlignment(configuredResourceIdLabel, Alignment.TOP_RIGHT); paramLayout.addComponent(configuredResourceIdValueLabel, 1, 0); Label configurationDescriptionLabel = new Label("Description:"); configurationDescriptionLabel.setSizeUndefined(); paramLayout.addComponent(configurationDescriptionLabel, 0, 1); paramLayout.setComponentAlignment(configurationDescriptionLabel, Alignment.TOP_RIGHT); TextArea conmfigurationDescriptionTextField = new TextArea(); conmfigurationDescriptionTextField.setRows(4); conmfigurationDescriptionTextField.setWidth("80%"); paramLayout.addComponent(conmfigurationDescriptionTextField, 1, 1); this.layout.addComponent(paramLayout, 0, 1, 1, 1); int i = 2; for (ConfigurationParameter parameter : parameters) { if (parameter instanceof ConfigurationParameterIntegerImpl) { this.layout.addComponent( this.createTextAreaPanel(parameter, new IntegerValidator("Must be a valid number")), 0, i, 1, i); } else if (parameter instanceof ConfigurationParameterStringImpl) { this.layout.addComponent(this.createTextAreaPanel(parameter, new StringValidator()), 0, i, 1, i); } else if (parameter instanceof ConfigurationParameterBooleanImpl) { this.layout.addComponent(this.createTextAreaPanel(parameter, new BooleanValidator()), 0, i, 1, i); } else if (parameter instanceof ConfigurationParameterLongImpl) { this.layout.addComponent(this.createTextAreaPanel(parameter, new LongValidator()), 0, i, 1, i); } else if (parameter instanceof ConfigurationParameterMapImpl) { this.layout.addComponent(this.createMapPanel((ConfigurationParameterMapImpl) parameter), 0, i, 1, i); } else if (parameter instanceof ConfigurationParameterListImpl) { this.layout.addComponent(this.createListPanel((ConfigurationParameterListImpl) parameter), 0, i, 1, i); } i++; } Button saveButton = new Button("Save"); saveButton.addStyleName(ValoTheme.BUTTON_SMALL); saveButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { try { for (TextArea textField : textFields.values()) { textField.validate(); } } catch (InvalidValueException e) { e.printStackTrace(); for (TextArea textField : textFields.values()) { textField.setValidationVisible(true); } Notification.show("There are errors on the form above", Type.ERROR_MESSAGE); return; } for (ConfigurationParameter parameter : parameters) { TextArea textField = ComponentConfigurationWindow.this.textFields.get(parameter.getName()); TextArea descriptionTextField = ComponentConfigurationWindow.this.descriptionTextFields .get(parameter.getName()); if (parameter != null && descriptionTextField != null) { parameter.setDescription(descriptionTextField.getValue()); } if (parameter instanceof ConfigurationParameterIntegerImpl) { logger.info("Setting Integer value: " + textField.getValue()); if (textField.getValue() != null && textField.getValue().length() > 0) parameter.setValue(new Integer(textField.getValue())); } else if (parameter instanceof ConfigurationParameterStringImpl) { logger.info("Setting String value: " + textField.getValue()); if (textField.getValue() != null && textField.getValue().length() > 0) parameter.setValue(textField.getValue()); } else if (parameter instanceof ConfigurationParameterBooleanImpl) { logger.info("Setting Boolean value: " + textField.getValue()); if (textField.getValue() != null && textField.getValue().length() > 0) parameter.setValue(new Boolean(textField.getValue())); } else if (parameter instanceof ConfigurationParameterLongImpl) { logger.info("Setting Boolean value: " + textField.getValue()); if (textField.getValue() != null && textField.getValue().length() > 0) parameter.setValue(new Long(textField.getValue())); } else if (parameter instanceof ConfigurationParameterMapImpl) { ConfigurationParameterMapImpl mapParameter = (ConfigurationParameterMapImpl) parameter; HashMap<String, String> map = new HashMap<String, String>(); logger.info("Saving map: " + mapTextFields.size()); for (String key : mapTextFields.keySet()) { if (key.startsWith(parameter.getName())) { TextFieldKeyValuePair pair = mapTextFields.get(key); logger.info("Saving for key: " + key); if (pair.key.getValue() != "") { map.put(pair.key.getValue(), pair.value.getValue()); } } } parameter.setValue(map); } else if (parameter instanceof ConfigurationParameterListImpl) { ConfigurationParameterListImpl mapParameter = (ConfigurationParameterListImpl) parameter; ArrayList<String> map = new ArrayList<String>(); for (String key : valueTextFields.keySet()) { if (key.startsWith(parameter.getName())) { map.add(valueTextFields.get(key).getValue()); } } parameter.setValue(map); } } ComponentConfigurationWindow.this.configurationManagement.saveConfiguration(configuration); Notification notification = new Notification("Saved", "The configuration has been saved successfully!", Type.HUMANIZED_MESSAGE); notification.setStyleName(ValoTheme.NOTIFICATION_CLOSABLE); notification.show(Page.getCurrent()); } }); Button deleteButton = new Button("Delete"); deleteButton.addStyleName(ValoTheme.BUTTON_SMALL); deleteButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { DeleteConfigurationAction action = new DeleteConfigurationAction(configuration, configurationManagement, ComponentConfigurationWindow.this); IkasanMessageDialog dialog = new IkasanMessageDialog("Delete configuration", "Are you sure you would like to delete this configuration?", action); UI.getCurrent().addWindow(dialog); } }); GridLayout buttonLayout = new GridLayout(2, 1); buttonLayout.setSpacing(true); buttonLayout.addComponent(saveButton, 0, 0); buttonLayout.addComponent(deleteButton, 1, 0); this.layout.addComponent(buttonLayout, 0, i, 1, i); this.layout.setComponentAlignment(buttonLayout, Alignment.MIDDLE_CENTER); Panel configurationPanel = new Panel(); configurationPanel.setContent(this.layout); this.setContent(configurationPanel); }
From source file:org.jumpmind.vaadin.ui.common.CommonUiUtils.java
License:Open Source License
public static void notify(String caption, String message, Throwable ex, Type type) { Page page = Page.getCurrent();/*w w w . ja va 2 s . c om*/ if (page != null) { Notification notification = new Notification(caption, contactWithLineFeed(FormatUtils.wordWrap(message, 150)), Type.HUMANIZED_MESSAGE); notification.setPosition(Position.MIDDLE_CENTER); notification.setDelayMsec(-1); String style = ValoTheme.NOTIFICATION_SUCCESS; if (type == Type.ERROR_MESSAGE) { style = ValoTheme.NOTIFICATION_FAILURE; } else if (type == Type.WARNING_MESSAGE) { style = ValoTheme.NOTIFICATION_WARNING; } notification.setStyleName( notification.getStyleName() + " " + ValoTheme.NOTIFICATION_CLOSABLE + " " + style); notification.show(Page.getCurrent()); } }