/** * ClickListner Methode fuer die Reaktion auf Buttonclicks. Hier wird * entsprechend auf die Button-Clicks fuer das Erzeugen weiterer Projekte * reagiert, wie auch auf jene die Projekte loeschen. In der ersten * If-Abfrage werden die vom Hauptfenster ausgeloeten Clicks zum Hinzufuegen * eines neuen Objektes behandelt, in der zweiten If-Abfrage wird die im * Dialogfenster ausgeloesten Clickst behandelt (Hierbei wird noch geprueft * ob das auf "required" gesetzte Textfeld auch ausgefuellt wurde - falls * nicht wird eine Fehlermeldung angezeigt) und in der Else-Verzweigung dann * die Loesch-Clicks fuer das jeweilige Projekt behandelt. Hierbei wird * zunächst durch das Event in der Loesch-Buttonliste der Index * identifiziert, also welches Projekt zu loeschen ist. Die jeweils folgende * Logid ist in der je aufgerufen Methode des Presenters zu finden. * * @author Christian Scherer, Mirko Göpfrich * @param event * Klick-event des Buttons */ @Override public void buttonClick(ClickEvent event) { if (event.getButton() == addProjectBtn) { logger.debug("Projekt-hinzufügen Button aus dem Hauptfenster aufgerufen"); presenter.addProjectDialog(); } else if (event.getButton() == dialogAddBtn) { logger.debug("Projekt-hinzufügen Button aus dem Dialogfenster aufgerufen"); if (tfName.isValid()) { presenter.addProject((String) tfName.getValue(), (String) taDescription.getValue()); //TODO: Fenster nur schließen, wenn das Hinzufügen erfolgreich war (s. Projekt Bearbeiten). getWindow().removeWindow(addDialog); logger.debug("Projekt-hinzufügen Dialog geschlossen"); } else { getWindow() .showNotification( "", "Projektname ist ein Pflichtfeld. Bitte geben Sie einen Projektnamen an", Notification.TYPE_ERROR_MESSAGE); } } }
@Override public void handleError(IUnoVaadinApplication application, ErrorEvent errorEvent) { final Throwable t = errorEvent.getThrowable(); // Copyed from Application.handleError() if (t instanceof SocketException) { // Most likely client browser closed socket LOG.info("SocketException in CommunicationManager." + " Most likely client (browser) closed socket."); return; } // Shows the error in AbstractComponent // TODO Check ErrorMessage class to show error to the user String message = throwableToMessageService.resolveMessage(t); application.getMainWindow().showNotification("An unexpected error has occured", message, Notification.TYPE_ERROR_MESSAGE); LOG.error("An unexpected error has occured in vaadin", t); }
@Override protected void showEdit() { if (getActiveObject() == null) { List<UIBean> selectedObjects = getSelectedObjects(); if (selectedObjects.size() > 0) { this.setActiveObject(selectedObjects.get(0)); } else { //TODO i18n getMainContainer().getWindow().showNotification("Select an intem", "Please select an item to edit", Notification.TYPE_HUMANIZED_MESSAGE); showView(View.LIST); return; } } getMainContainer().addComponent(form); }
private void periodicRefresh() { //Logout if requested if (mKicker != null) { String kickMessage = KickoutMessageText + mKicker.getData().getName(); mKicker = null; logoutCore(); getMainWindow().showNotification(KickoutMessageTitle, kickMessage, Notification.TYPE_WARNING_MESSAGE); } //Refresh logged in users refreshLoggedInUsers(); //Refresh GPIO pin states refreshGPIOPinStates(); //Refresh animation status refreshAnimationStatus(); }
private void createLoginUI(final AbstractOrderedLayout parentLayout) { final Rpi_gpio_controllerApplication application = this; LoginForm loginForm = new LoginForm(); loginForm.addListener(new LoginForm.LoginListener() { Rpi_gpio_controllerApplication mApplication = application; public void onLogin(LoginEvent event) { String loginErrorMessage = new User(new UserData (event.getLoginParameter("username"), event.getLoginParameter("password")), mApplication).login(); if (loginErrorMessage != null) { Notification notification = new Notification(LoginErrorMessage, loginErrorMessage, Notification.TYPE_ERROR_MESSAGE); notification.setDelayMsec(1000); getMainWindow().showNotification(notification); } } }); Panel loginPanel = new Panel("Log in"); loginPanel.setWidth("200px"); loginPanel.setHeight("250px"); loginPanel.addComponent(loginForm); parentLayout.addComponent(loginPanel); parentLayout.setComponentAlignment(loginPanel, Alignment.MIDDLE_CENTER); }
/** * Shows the events window. * * @param logger the logger * @param fileName the file name * @param ueiBase the UEI base */ private void showEventsWindow(final Logger logger, final String fileName, final String ueiBase) { final Events events = mibParser.getEvents(ueiBase); if (events == null) { getApplication().getMainWindow().showNotification("The MIB couldn't be processed for events because: " + mibParser.getFormattedErrors(), Notification.TYPE_ERROR_MESSAGE); } else { if (events.getEventCount() > 0) { try { logger.info("Found " + events.getEventCount() + " events."); final String eventsFileName = fileName.replaceFirst("\\..*$", ".events.xml"); final File configDir = new File(ConfigFileConstants.getHome(), "etc/events/"); final File eventFile = new File(configDir, eventsFileName); final EventWindow w = new EventWindow(eventsDao, eventsProxy, eventFile, events, logger); getApplication().getMainWindow().addWindow(w); } catch (Throwable t) { getApplication().getMainWindow().showNotification(t.getMessage(), Notification.TYPE_ERROR_MESSAGE); } } else { getApplication().getMainWindow().showNotification("The MIB doesn't contain any notification/trap", Notification.TYPE_WARNING_MESSAGE); } } }
/** * Generate data collection. * * @param logger the logger * @param fileName the file name */ private void generateDataCollection(final Logger logger, final String fileName) { if (parseMib(logger, new File(MIBS_COMPILED_DIR, fileName))) { final DatacollectionGroup dcGroup = mibParser.getDataCollection(); if (dcGroup == null) { getApplication().getMainWindow().showNotification("The MIB couldn't be processed for data collection because: " + mibParser.getFormattedErrors(), Notification.TYPE_ERROR_MESSAGE); } else { if (dcGroup.getGroupCount() > 0) { try { final String dataFileName = fileName.replaceFirst("\\..*$", ".xml"); final DataCollectionWindow w = new DataCollectionWindow(mibParser, dataCollectionDao, dataFileName, dcGroup, logger); getApplication().getMainWindow().addWindow(w); } catch (Throwable t) { getApplication().getMainWindow().showNotification(t.getMessage(), Notification.TYPE_ERROR_MESSAGE); } } else { getApplication().getMainWindow().showNotification("The MIB doesn't contain any metric for data collection.", Notification.TYPE_WARNING_MESSAGE); } } } }
/** * Adds a data collection group panel. * * @param dataCollectionDao the OpenNMS data collection configuration DAO * @param file data collection group file name * @param dcGroup the data collection group object */ private void addDataCollectionGroupPanel(final DataCollectionConfigDao dataCollectionDao, final File file, final DatacollectionGroup dcGroup) { DataCollectionGroupPanel panel = new DataCollectionGroupPanel(dataCollectionDao, dcGroup, new SimpleLogger()) { @Override public void cancel() { this.setVisible(false); } @Override public void success() { getApplication().getMainWindow().showNotification("Data collection group file " + file.getName() + " has been successfuly saved."); this.setVisible(false); } @Override public void failure() { getApplication().getMainWindow().showNotification("Data collection group file " + file.getName() + " cannot be saved.", Notification.TYPE_ERROR_MESSAGE); } }; panel.setCaption("Data Collection from " + file.getName()); removeDataCollectionGroupPanel(); addComponent(panel); }
/** * Adds a new Events Panel. * * @param layout the layout * @param file the Events File Name * @param events the Events Object * @return a new Events Panel Object */ private void addEventPanel(final VerticalLayout layout, final File file, final Events events) { EventPanel eventPanel = new EventPanel(eventConfDao, eventProxy, file, events, new SimpleLogger()) { @Override public void cancel() { this.setVisible(false); } @Override public void success() { getMainWindow().showNotification("Event file " + file + " has been successfuly saved."); this.setVisible(false); } @Override public void failure() { getMainWindow().showNotification("Event file " + file + " cannot be saved.", Notification.TYPE_ERROR_MESSAGE); } }; eventPanel.setCaption("Events from " + file); removeEventPanel(layout); layout.addComponent(eventPanel); }
@Override public void recoverProtocolButtonClick(ClickNavigationEvent event) { Protocol editingProtocol = (Protocol) event.getRegister(); if (editingProtocol == null) return; File boxRecover = new File(boxImport); try { FileUtils.copyFileToDirectory(editingProtocol.getFile(), boxRecover); getApplication().getMainWindow().showNotification("Recuperación correcta", "", Notification.TYPE_HUMANIZED_MESSAGE); } catch (IOException e) { throw new RuntimeException( "¡No se pudo recuperar el protocolo!", e); } }
private void fillDataSource() { try { bcOrganization.removeAllItems(); bcOrganization.addAll(user.getOrganizations()); // set language selected languageField.addItem("Español"); languageField.addItem("English"); languageField.addItem("Française"); //languageField.addItem("简体中文"); } catch (Exception e) { getWindow().showNotification( "¡Error refrescando organizaciones!", "", Notification.TYPE_WARNING_MESSAGE); } if (user.getDefaultOrganization() != null) organizationField.setValue(user.getDefaultOrganization()); }
@Override public Object getConfig() { try { PoolPartyApiConfig apiConfig = apiPanel.getApiConfig(); URL url = PPTApi.getServiceUrl(apiConfig.getServer(), "PoolParty/sparql/" + apiConfig.getUriSupplement()+ "?query=" + URLEncoder.encode("ASK {?x a <http://www.w3.org/2004/02/skos/core#Concept> }", "UTF-8")); logger.info(url); Authentication authentication = apiConfig.getAuthentication(); HttpURLConnection con = (HttpURLConnection) url.openConnection(); authentication.visit(con); if (con.getResponseCode() != 200) { getWindow().showNotification("Unable to query SPARQL endpoint of project", "", Notification.TYPE_ERROR_MESSAGE); throw new RuntimeException("Response code: "+con.getResponseCode()); } config.setApiConfig(apiConfig); config.setLinkProperty(((LinkingProperty) linkProperty.getValue()).getUri()); } catch (Exception ex) { logger.error("Unable to query SPARQL endpoint of project", ex); } return config; }
public void buttonClick(ClickEvent event) { textArea.setComponentError(null); if(event.getButton().equals(sendButton)) { if(textArea.getValue() == null || textArea.getValue().toString().isEmpty()) { textArea.setComponentError(new UserError(CisConstants.uiRequiredField)); } else { try { MailSender.send(CisConstants.emailSuggestionBoxEmail, CisConstants.uiSuggestionBox, textArea.getValue().toString()); LoggerFactory.getLogger(SuggestionComponent.class).info(CisConstants.uiSuggestionBox + ": " + textArea.getValue().toString()); getApplication().getMainWindow().showNotification(CisConstants.uiSuggestionSent); } catch (MessagingException e) { LoggerFactory.getLogger(SuggestionComponent.class).error("Error sending email", e); getApplication().getMainWindow().showNotification(CisConstants.uiSuggestionNotSent, Notification.TYPE_ERROR_MESSAGE); } } } textArea.setValue(""); }
public void showWarningNotification(String captionKey, String descriptionKey) { Notification notification = new Notification(i18nManager.getMessage(captionKey), i18nManager.getMessage(descriptionKey), Notification.TYPE_WARNING_MESSAGE); notification.setDelayMsec(-1); // click to hide mainWindow.showNotification(notification); }
public void showWarningNotification(String captionKey, String descriptionKey, Object ... params) { Notification notification = new Notification(i18nManager.getMessage(captionKey) + "<br/>", MessageFormat.format(i18nManager.getMessage(descriptionKey), params), Notification.TYPE_WARNING_MESSAGE); notification.setDelayMsec(5000); // click to hide mainWindow.showNotification(notification); }
@Override protected void showEdit() { if (getActiveObject() == null) { List<UIBean> selectedObjects = getSelectedObjectsInList(); if (selectedObjects.size() > 0) { this.setActiveObject(selectedObjects.get(0)); } else { //TODO i18n getMainContainer().getWindow().showNotification("Select an intem", "Please select an item to edit", Notification.TYPE_HUMANIZED_MESSAGE); showView(View.LIST); return; } } Panel panel = new Panel(); panel.setSizeFull(); panel.setStyleName("background-default"); getMainContainer().addComponent(panel); if (getActiveObject().isNew()) { newForm.setValue(getActiveObject()); panel.addComponent(newForm.getImplementation()); } else { editForm.setValue(getActiveObject()); editForm.getBindingContext().updateFields(); panel.addComponent(editForm.getImplementation()); } modified = false; }
@Override public void windowClose(CloseEvent event) { Window source = event.getWindow(); if (source == confirmUpgrade) { if (confirmUpgrade.getDecision()) { try { UpgradeUtils.doSystemUpgrade(app, this, getLebSettingsAnlegen(LebSettingsContainer.getLebSettings())); } catch (Exception e) { e.printStackTrace(); app.getMainWindow().showNotification("Fehler beim L�schen! Bitte wenden Sie sich an den Administrator!", Notification.TYPE_ERROR_MESSAGE); } } } }
/** * Save SNMP collections. * * @param dataCollectionConfigDao the OpenNMS data collection configuration DAO * @param logger the logger */ public void saveSnmpCollections(final DataCollectionConfigDao dataCollectionConfigDao, Logger logger) { try { final DatacollectionConfig dataCollectionConfig = dataCollectionConfigDao.getRootDataCollection(); File file = ConfigFileConstants.getFile(ConfigFileConstants.DATA_COLLECTION_CONF_FILE_NAME); logger.info("Saving data colleciton configuration on " + file); dataCollectionConfig.setSnmpCollection(getSnmpCollections()); JaxbUtils.marshal(dataCollectionConfig, new FileWriter(file)); logger.info("The data collection configuration has been saved."); } catch (Exception e) { logger.error("An error ocurred while saving the data collection configuration, " + e.getMessage()); getApplication().getMainWindow().showNotification("Can't save data collection configuration. " + e.getMessage(), Notification.TYPE_ERROR_MESSAGE); } }
public void buttonClick(ClickEvent event) { Button source = event.getButton(); if (source == save) { if (isValid()) { commit(); setReadOnly(true); saveGroup(getGroup()); } else { getWindow().showNotification("There are errors on the MIB Groups", Notification.TYPE_WARNING_MESSAGE); } } if (source == cancel) { discard(); setReadOnly(true); } if (source == edit) { setReadOnly(false); } if (source == delete) { // FIXME You cannot delete a group if it is being used on any systemDef MessageBox mb = new MessageBox(getApplication().getMainWindow(), "Are you sure?", MessageBox.Icon.QUESTION, "Do you really want to remove the Group " + getGroup().getName() + "?<br/>This action cannot be undone.", new MessageBox.ButtonConfig(MessageBox.ButtonType.YES, "Yes"), new MessageBox.ButtonConfig(MessageBox.ButtonType.NO, "No")); mb.addStyleName(Runo.WINDOW_DIALOG); mb.show(new EventListener() { public void buttonClicked(ButtonType buttonType) { if (buttonType == MessageBox.ButtonType.YES) { setVisible(false); deleteGroup(getGroup()); } } }); } }
public VectorLayer shapeFileUploaded(String filename, ByteArrayInputStream input) { VectorLayer retval = null; File sessionShapeDir = getSessionShapeFileDir(); String basename = basename(filename); String extension = filename.substring(filename.lastIndexOf('.') + 1); String dstDir = sessionShapeDir + "/" + basename + "/"; if (!(new File(dstDir)).exists()) { if (!(new File(dstDir)).mkdirs()) { // TODO: permissions error? return null; } } ShapefileRefCountMap.put(basename, 1); // First reference is this session. if (extension.equalsIgnoreCase("zip")) { // Additional reference for each Job. if (extractZip(dstDir, input)) { File cropFile = new File(dstDir, basename + ".shp"); if (validateShapeFile(cropFile)) retval = new VectorLayer(new File(dstDir), basename); } else { ((ExpressZipWindow) parent.getApplication().getMainWindow()).showNotification("Not a valid ShapeFile", "Put at least a .shp, .shx, .dbf, and .prj files into a ZIP archive for upload.", Notification.TYPE_ERROR_MESSAGE); } } else if (extension.equalsIgnoreCase("shp")) { ((ExpressZipWindow) parent.getApplication().getMainWindow()).showNotification("Shapefiles must zipped", "Put at least the .shp, .shx, .dbf, and .prj files into a ZIP archive for upload.", Notification.TYPE_ERROR_MESSAGE); } else { ((ExpressZipWindow) parent.getApplication().getMainWindow()).showNotification("Only zipped shapefiles accepted", "Put at least a .shp, .shx, .dbf, and .prj files into a ZIP archive for upload.", Notification.TYPE_ERROR_MESSAGE); } return retval; }
public OutputStream receiveUpload(String filename, String mimeType) { // Create upload stream FileOutputStream fos = null; // Output stream to write to try { String basepath = application.getContext().getBaseDirectory().getAbsolutePath(); // Open the file for writing. file = new File(basepath + "/" + filename); fos = new FileOutputStream(file); } catch (final java.io.FileNotFoundException e) { getWindow().showNotification("Could not open file<br/>", e.getMessage(), Notification.TYPE_ERROR_MESSAGE); return null; } return fos; // Return the output stream to write to }
public void displayConfigWindow(final ConfigBeanProvider configBeanProvider, final ConfigSuccessHandler handler, Object config) { configWindow.removeAllComponents(); configWindow.setCaption("Configuration: " + ((UIComponent) configBeanProvider).getName()); VerticalLayout configWinLayout = new VerticalLayout(); Form form = new Form(new VerticalLayout()); if (config == null) { config = configBeanProvider.newDefaultConfig(); } final BeanItem beanItem = new BeanItem(config); form.setItemDataSource(beanItem); form.setImmediate(true); configWinLayout.addComponent(form); Button configureButton = new Button("Configure"); configureButton.addListener(new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { try { configBeanProvider.configure(beanItem.getBean()); handler.configured(); getMainWindow().removeWindow(configWindow); } catch (ConfigurationException ex) { getMainWindow().showNotification(ex.getMessage(), Notification.TYPE_ERROR_MESSAGE); logger.error("Unable to configure component", ex); } } }); Label configExplanation = new Label(CONFIG_INFO, Label.CONTENT_TEXT); configExplanation.addStyleName("lodms-config-info"); configWinLayout.addComponent(configExplanation); configWinLayout.addComponent(configureButton); configWinLayout.setComponentAlignment(configureButton, Alignment.BOTTOM_CENTER); configWindow.addComponent(configWinLayout); getMainWindow().addWindow(configWindow); }
private void sendNotifications(Project project) { project = CisContainerFactory.getProjectContainer().getEntity(project.getId()); for(User user : project.getUsers()) { if(project.getSendNewFileNotificationsToCustomers()) { try { MailSender.send(user.getEmail(), CisConstants.uiNewFileNotificationSubject, CisConstants.uiNewFileNotificationMessage); } catch (MessagingException e) { getApplication().getMainWindow().showNotification(CisConstants.uiNewFileNotificationNotSent(user.getEmail()), Notification.TYPE_ERROR_MESSAGE); e.printStackTrace(); } } } }
@Override public void showErrorMessge(String message) { getWindow().showNotification((String) "Berechnung fehlgeschlagen", message, Notification.TYPE_ERROR_MESSAGE); }
/**Methode zur Implementierung des Dialogfensters für Projekt-Änderungen. * */ @Override public void showEditProjectDialog(Project project) { editDialog = new Window("Projekt bearbeiten"); editDialog.setModal(true); editDialog.setWidth(410, UNITS_PIXELS); editDialog.setResizable(false); editDialog.setDraggable(false); VerticalLayout layout = new VerticalLayout(); layout.setSpacing(true); FormLayout formLayout = new FormLayout(); formLayout.setMargin(true); formLayout.setSpacing(true); //TextFeld für Name dem Formular hinzufügen tfName = new TextField("Name ändern:", project.getName()); tfName.setRequired(true); tfName.addValidator(new StringLengthValidator( "Der Projektname muss zwischen 2 und 20 Zeichen lang sein.", 2, 20, false)); tfName.setRequiredError("Pflichtfeld"); tfName.setSizeFull(); formLayout.addComponent(tfName); //TextArea für Beschreibung dem Formular hinzufügen taDescription = new TextArea("Beschreibung ändern:", project.getDescription()); taDescription.setSizeFull(); formLayout.addComponent(taDescription); //Formular dem Layout hinzufügen layout.addComponent(formLayout); //Speichern-Button erstllen und dem Layout hinzufügen //TODO: ist das korrekt? Gute Frage, I have no idea what u r doing dialogEditBtn = new Button("Speichern"); layout.addComponent(dialogEditBtn); dialogEditBtn.addListener(new Button.ClickListener() { private static final long serialVersionUID = 1L; public void buttonClick(ClickEvent event) { if (tfName.isValid()) { boolean succed = presenter.editProject(projects.get(indexEditBtn), (String) tfName.getValue(), (String) taDescription.getValue()); if (succed) { getWindow().removeWindow(editDialog); logger.debug("Projekt-bearbeiten Dialog geschlossen"); } } else { getWindow().showNotification( "", "Projektname ist ein Pflichtfeld. Bitte geben Sie einen Projektnamen an", Notification.TYPE_ERROR_MESSAGE); } } }); //Layout dem Dialog-Fenster hinzufügen editDialog.addComponent(layout); //Dialog dem Hauptfenster hinzufügen getWindow().addWindow(editDialog); logger.debug("Bearbeiten-Dialog erzeugt"); }
public void showErrorMessage(String message) { Window.Notification notif = new Notification((String) "", message, Notification.TYPE_WARNING_MESSAGE); notif.setPosition(Window.Notification.POSITION_CENTERED_TOP); getWindow().showNotification(notif); }
public void showErrorNotification(String captionKey, String description) { mainWindow.showNotification(i18nManager.getMessage(captionKey), "<br/>" + description, Notification.TYPE_ERROR_MESSAGE); }
public void showCustomNotification(String caption, String description) { mainWindow.showNotification(caption, "<br/>" + description, Notification.TYPE_ERROR_MESSAGE); }
public void showErrorNotification(String captionKey, Exception exception) { mainWindow.showNotification(i18nManager.getMessage(captionKey), "<br/>" + exception.getMessage(), Notification.TYPE_ERROR_MESSAGE); }
public void showInformationNotification(String key) { mainWindow.showNotification(i18nManager.getMessage(key), Notification.TYPE_HUMANIZED_MESSAGE); }
public void showInformationNotification(String key, Object ... params) { mainWindow.showNotification(MessageFormat.format(i18nManager.getMessage(key), params), Notification.TYPE_HUMANIZED_MESSAGE); }
@Override public void showMessage(MessageType type, String caption) { Notification notif = createNotification(type, caption); vaadinApplication.getMainWindow().showNotification(notif); }
@Override public void showMessage(MessageType type, String caption, String description) { Notification notif = createNotification(type, caption); notif.setDescription(description); vaadinApplication.getMainWindow().showNotification(notif); }