Java Code Examples for com.vaadin.ui.Notification.Type

The following examples show how to use com.vaadin.ui.Notification.Type. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may want to check out the right sidebar which shows the related API usage.
Example 1
Source Project: sidemenu-addon   Source File: DemoUI.java    License: Apache License 2.0 6 votes vote down vote up
private void setUser(String name, Resource icon) {
	sideMenu.setUserName(name);
	sideMenu.setUserIcon(icon);

	sideMenu.clearUserMenu();
       sideMenu.addUserMenuItem("Settings", VaadinIcons.WRENCH, () -> Notification.show("Showing settings", Type.TRAY_NOTIFICATION));
       sideMenu.addUserMenuItem("Sign out", () -> Notification.show("Logging out..", Type.TRAY_NOTIFICATION));

	sideMenu.addUserMenuItem("Hide logo", () -> {
		if (!logoVisible) {
			sideMenu.setMenuCaption(menuCaption, logo);
		} else {
			sideMenu.setMenuCaption(menuCaption);
		}
		logoVisible = !logoVisible;
	});
}
 
Example 2
public void save(Button.ClickEvent event) {
    try {
        // Commit the fields from UI to DAO
        formFieldBindings.commit();

        // Save DAO to backend with direct synchronous service API
        getUI().userClient.createUser(contact);

        String msg = String.format("Saved '%s %s'.",
                contact.getFirstName(),
                contact.getLastName());
        Notification.show(msg, Type.TRAY_NOTIFICATION);
        getUI().refreshContacts();
    } catch (FieldGroup.CommitException e) {
        // Validation exceptions could be shown here
    }
}
 
Example 3
Source Project: hawkbit   Source File: ErrorView.java    License: Eclipse Public License 1.0 6 votes vote down vote up
@Override
public void enter(final ViewChangeListener.ViewChangeEvent event) {
    final DashboardMenuItem view = dashboardMenu.getByViewName(event.getViewName());
    if (view == null) {
        message.setValue(i18n.getMessage("message.error.view", event.getViewName()));
        return;
    }
    if (dashboardMenu.isAccessDenied(event.getViewName())) {
        final Notification nt = new Notification("Access denied",
                i18n.getMessage("message.accessdenied.view", event.getViewName()), Type.ERROR_MESSAGE, false);
        nt.setStyleName(SPUIStyleDefinitions.SP_NOTIFICATION_ERROR_MESSAGE_STYLE);
        nt.setPosition(Position.BOTTOM_RIGHT);
        nt.show(UI.getCurrent().getPage());
        message.setValue(i18n.getMessage("message.accessdenied.view", event.getViewName()));
    }
}
 
Example 4
Source Project: hawkbit   Source File: HawkbitUIErrorHandler.java    License: Eclipse Public License 1.0 6 votes vote down vote up
@Override
public void error(final ErrorEvent event) {

    // filter upload exceptions
    if (event.getThrowable() instanceof UploadException) {
        return;
    }

    final HawkbitErrorNotificationMessage message = buildNotification(getRootExceptionFrom(event));
    if (event instanceof ConnectorErrorEvent) {
        final Connector connector = ((ConnectorErrorEvent) event).getConnector();
        if (connector instanceof UI) {
            final UI uiInstance = (UI) connector;
            uiInstance.access(() -> message.show(uiInstance.getPage()));
            return;
        }
    }

    final Optional<Page> originError = getPageOriginError(event);
    if (originError.isPresent()) {
        message.show(originError.get());
        return;
    }

    HawkbitErrorNotificationMessage.show(message.getCaption(), message.getDescription(), Type.HUMANIZED_MESSAGE);
}
 
Example 5
Source Project: vaadin-sliderpanel   Source File: DemoUI.java    License: MIT License 6 votes vote down vote up
private VerticalLayout dummyContent(final String title, final int length) {
    String text = "";
    for (int x = 0; x <= length; x++) {
        text += LOREM_IPSUM + " ";
    }
    Label htmlDummy = new Label(String.format("<h3>%s</h3>%s", title, text.trim()), ContentMode.HTML);
    VerticalLayout component = new VerticalLayout(htmlDummy);
    component.setExpandRatio(htmlDummy, 1);
    component.addComponent(new Button(title, new Button.ClickListener() {
        @Override
        public void buttonClick(final ClickEvent event) {
            Notification.show("clicked: " + title, Type.HUMANIZED_MESSAGE);
        }
    }));
    component.setMargin(true);
    component.setSpacing(true);
    return component;
}
 
Example 6
Source Project: cia   Source File: SendEmailClickListenerTest.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Show notification failure test.
 */
@Test
public void showNotificationFailureTest() {
	final SendEmailRequest request = new SendEmailRequest();		
	final SendEmailClickListener listener = Mockito.spy(new SendEmailClickListener(request));
	final ApplicationManager applicationManager = Mockito.mock(ApplicationManager.class);
	Mockito.doReturn(applicationManager).when(listener).getApplicationManager();
	
	final SendEmailResponse sendEmailResponse = new SendEmailResponse(ServiceResult.FAILURE);
	sendEmailResponse.setErrorMessage("errorMessage");
	Mockito.when(applicationManager.service(request)).thenReturn(sendEmailResponse);
	
	Mockito.doNothing().when(listener).showNotification(ArgumentMatchers.anyString(), ArgumentMatchers.anyString(), ArgumentMatchers.any(Type.class));
	listener.buttonClick(new ClickEvent(new Panel()));
	Mockito.verify(listener).showNotification(ArgumentMatchers.anyString(), ArgumentMatchers.anyString(), ArgumentMatchers.any(Type.class));
}
 
Example 7
Source Project: cia   Source File: LogoutClickListenerTest.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Show notification failure test.
 */
@Test
public void showNotificationFailureTest() {
	final LogoutRequest request = new LogoutRequest();		
	final LogoutClickListener listener = Mockito.spy(new LogoutClickListener(request));
	final ApplicationManager applicationManager = Mockito.mock(ApplicationManager.class);
	Mockito.doReturn(applicationManager).when(listener).getApplicationManager();
	
	final LogoutResponse response = new LogoutResponse(ServiceResult.FAILURE);
	response.setErrorMessage("errorMessage");
	Mockito.when(applicationManager.service(request)).thenReturn(response);
	
	Mockito.doNothing().when(listener).showNotification(ArgumentMatchers.anyString(), ArgumentMatchers.anyString(), ArgumentMatchers.any(Type.class));
	listener.buttonClick(new ClickEvent(new Panel()));
	Mockito.verify(listener).showNotification(ArgumentMatchers.anyString(), ArgumentMatchers.anyString(), ArgumentMatchers.any(Type.class));
}
 
Example 8
Source Project: cia   Source File: ManageUserAccountClickListenerTest.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Show notification failure test.
 */
@Test
public void showNotificationFailureTest() {
	final ManageUserAccountRequest request = new ManageUserAccountRequest();		
	final ManageUserAccountClickListener listener = Mockito.spy(new ManageUserAccountClickListener(request));
	final ApplicationManager applicationManager = Mockito.mock(ApplicationManager.class);
	Mockito.doReturn(applicationManager).when(listener).getApplicationManager();
	
	final ManageUserAccountResponse response = new ManageUserAccountResponse(ServiceResult.FAILURE);
	response.setErrorMessage("errorMessage");
	Mockito.when(applicationManager.service(request)).thenReturn(response);
	
	Mockito.doNothing().when(listener).showNotification(ArgumentMatchers.anyString(), ArgumentMatchers.anyString(), ArgumentMatchers.any(Type.class));
	listener.buttonClick(new ClickEvent(new Panel()));
	Mockito.verify(listener).showNotification(ArgumentMatchers.anyString(), ArgumentMatchers.anyString(), ArgumentMatchers.any(Type.class));
}
 
Example 9
Source Project: cia   Source File: SearchDocumentClickListenerTest.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Show notification failure test.
 */
@Test
public void showNotificationFailureTest() {
	final SearchDocumentRequest request = new SearchDocumentRequest();		
	final SearchDocumentClickListener listener = Mockito.spy(new SearchDocumentClickListener(request,null));
	final ApplicationManager applicationManager = Mockito.mock(ApplicationManager.class);
	Mockito.doReturn(applicationManager).when(listener).getApplicationManager();
	
	final SearchDocumentResponse response = new SearchDocumentResponse(ServiceResult.FAILURE);
	response.setErrorMessage("errorMessage");
	Mockito.when(applicationManager.service(request)).thenReturn(response);
	
	Mockito.doNothing().when(listener).showNotification(ArgumentMatchers.anyString(), ArgumentMatchers.anyString(), ArgumentMatchers.any(Type.class));
	listener.buttonClick(new ClickEvent(new Panel()));
	Mockito.verify(listener).showNotification(ArgumentMatchers.anyString(), ArgumentMatchers.anyString(), ArgumentMatchers.any(Type.class));
}
 
Example 10
/**
 * Show notification failure test.
 */
@Test
public void showNotificationFailureTest() {
	final DisableGoogleAuthenticatorCredentialRequest request = new DisableGoogleAuthenticatorCredentialRequest();		
	final DisableGoogleAuthenticatorCredentialClickListener listener = Mockito.spy(new DisableGoogleAuthenticatorCredentialClickListener(request));
	final ApplicationManager applicationManager = Mockito.mock(ApplicationManager.class);
	Mockito.doReturn(applicationManager).when(listener).getApplicationManager();
	
	final DisableGoogleAuthenticatorCredentialResponse response = new DisableGoogleAuthenticatorCredentialResponse(ServiceResult.FAILURE);
	response.setErrorMessage("errorMessage");
	Mockito.when(applicationManager.service(request)).thenReturn(response);
	
	Mockito.doNothing().when(listener).showNotification(ArgumentMatchers.anyString(), ArgumentMatchers.anyString(), ArgumentMatchers.any(Type.class));
	listener.buttonClick(new ClickEvent(new Panel()));
	Mockito.verify(listener).showNotification(ArgumentMatchers.anyString(), ArgumentMatchers.anyString(), ArgumentMatchers.any(Type.class));
}
 
Example 11
protected void onLogin(@Observes
LoginEvent loginEvent) {
    if (isUserSignedIn()) {
        logger.info("User {} already authenticated", getPrincipalName());
        navigator.navigateTo(QuestionnaireView.NAME);
        return;
    }
    try {
        JaasAccessControl.login(loginEvent.getUsername(), loginEvent.getPassword());
        logger.info("User {} authenticated", getPrincipalName());
        navigator.navigateTo(QuestionnaireView.NAME);
    } catch (Exception e) {
        Notification.show("Error logging in", Type.ERROR_MESSAGE);
        logger.error(e.getMessage(), e);
    }
}
 
Example 12
Source Project: chipster   Source File: CSCTextToToolClickListener.java    License: MIT License 6 votes vote down vote up
@Override
public void buttonClick(ClickEvent event) {
	
	ChipsterSADLParser parser = new ChipsterSADLParser();
	try {
		SADLDescription description = parser.parse(root.getTextEditor().getHeader());
		root.getToolEditor().removeItems();
		root.getTreeToolEditor().removeAllChildren();
		root.getToolEditor().addTool(description);
		List<Input> inputs = description.getInputs();
		for(int i = 0 ; i < inputs.size(); i++) {
			root.getToolEditor().addInput(inputs.get(i));
		}
		List<Output> outputs = description.getOutputs();
		for(int i = 0 ; i < outputs.size(); i++) {
			root.getToolEditor().addOutput(outputs.get(i));
		}
		List<Parameter> parameters = description.getParameters();
		for(int i = 0 ; i < parameters.size(); i++) {
			root.getToolEditor().addParameter(parameters.get(i));
		}
		
	} catch (Exception e) {
		new Notification("Something wrong with the header\n\n" + e.getMessage(), Type.WARNING_MESSAGE).show(Page.getCurrent());
	}
}
 
Example 13
Source Project: chipster   Source File: Parameter.java    License: MIT License 6 votes vote down vote up
private Name[] getEnumList() {
	if (typeTable == null || typeTable.getItemIds().isEmpty())
		return null;
	Name[] names = typeTable.getItemIds().toArray(new Name[0]);
	ArrayList<Name> list = new ArrayList<Name>();
	for (Name name : names) {
		if (!name.getID().isEmpty()) {
			if ("".equals(name.getDisplayName())) {
				name.setDisplayName(null);
			}

			list.add(name);
		} else {
			new Notification(
					"Not all ENUM types were generated to text, because id was empty",
					Type.WARNING_MESSAGE).show(Page.getCurrent());
		}
	}
	return list.toArray(new Name[0]);
}
 
Example 14
Source Project: chipster   Source File: StorageEntryContainer.java    License: MIT License 6 votes vote down vote up
public void update(final StorageView view, final String username) {		
		
	List<StorageEntry> entries;
	try {
		if (username != null) {
			entries = adminEndpoint.listStorageUsageOfSessions(username);
		} else {
			//clear table
			entries = new LinkedList<>();
		}
		
		if (entries != null) {

			updateUI(view, entries);
			
		} else {
			Notification.show("Timeout", "Chipster filebroker server doesn't respond", Type.ERROR_MESSAGE);
			logger.error("timeout while waiting storage usage of sessions");
		}
	} catch (JMSException | InterruptedException | AuthCancelledException e) {
		logger.error(e);
	}
}
 
Example 15
Source Project: chipster   Source File: ReportDataSource.java    License: MIT License 6 votes vote down vote up
public void updateFilebrokerReport(final ReportView view) {
			
	String report;
	try {						
		
		report = getStorageAdminAPI().getStatusReport();		

		if (report != null) {
			updateFilebrokerUI(view, report);
		} else {
			Notification.show("Timeout", "Chipster filebroker server doesn't respond", Type.ERROR_MESSAGE);
			logger.error("timeout while waiting status report");
		}
		
	} catch (JMSException | InterruptedException | IOException | IllegalConfigurationException | MicroarrayException | AuthCancelledException e) {
		logger.error("failed to update storage status report", e);
	}			
}
 
Example 16
Source Project: chipster   Source File: ReportDataSource.java    License: MIT License 6 votes vote down vote up
public void updateJobmanagerReport(final ReportView view) {
	
	String report;
	try {						
		
		report = getJobmanagerAdminAPI().getStatusReport();		

		if (report != null) {
			
			updateJobmanagerUI(view, report);
			
		} else {
			Notification.show("Timeout", "Chipster jobmanager server doesn't respond", Type.ERROR_MESSAGE);
			logger.error("timeout while waiting status report");
		}
		
	} catch (JMSException | IOException | IllegalConfigurationException | MicroarrayException | InterruptedException | AuthCancelledException e) {
		logger.error("failed to update storage status report", e);
	}		
}
 
Example 17
Source Project: chipster   Source File: StorageAggregateContainer.java    License: MIT License 6 votes vote down vote up
public void update(StorageView view) {
	
	List<StorageAggregate> entries;
	try {
		entries = adminEndpoint.listStorageUsageOfUsers();

		if (entries != null) {				
			updateUI(view, entries);
		} else {
			Notification.show("Timeout", "Chipster filebroker server doesn't respond", Type.ERROR_MESSAGE);
			logger.error("timeout while waiting storage usage of users");
		}
		
	} catch (JMSException | InterruptedException | AuthCancelledException e) {
		logger.error("unable to list users' storage usage", e);
	}			
}
 
Example 18
Source Project: chipster   Source File: StorageView.java    License: MIT License 6 votes vote down vote up
private void updateStorageTotals() {
	
	super.submitUpdate(new Runnable() {

		@Override
		public void run() {								
			try {
				Long[] totals = adminEndpoint.getStorageUsage();
									
				if (totals != null) {
					StorageView.this.setDiskUsage(totals[0], totals[1]);
				} else {
					Notification.show("Timeout", "Chipster filebroker server doesn't respond", Type.ERROR_MESSAGE);
					logger.error("timeout while waiting storage usage totals");
				}

			} catch (JMSException | InterruptedException | AuthCancelledException e) {
				logger.error(e);
			}			
		}			
	}, this);
}
 
Example 19
/**
 * Show notification failure test.
 */
@Test
public void showNotificationFailureTest() {
	final UpdateApplicationConfigurationRequest request = new UpdateApplicationConfigurationRequest();		
	final UpdateApplicationConfigurationClickListener listener = Mockito.spy(new UpdateApplicationConfigurationClickListener(request));
	final ApplicationManager applicationManager = Mockito.mock(ApplicationManager.class);
	Mockito.doReturn(applicationManager).when(listener).getApplicationManager();
	
	Mockito.when(applicationManager.service(request)).thenReturn(new UpdateApplicationConfigurationResponse(ServiceResult.FAILURE));
	
	Mockito.doNothing().when(listener).showNotification(ArgumentMatchers.anyString(), ArgumentMatchers.anyString(), ArgumentMatchers.any(Type.class));
	listener.buttonClick(new ClickEvent(new Panel()));
	Mockito.verify(listener).showNotification(ArgumentMatchers.anyString(), ArgumentMatchers.anyString(), ArgumentMatchers.any(Type.class));
}
 
Example 20
Source Project: cia   Source File: RemoveDataClickListenerTest.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Show notification success test.
 */
@Test
public void showNotificationSuccessTest() {
	final RemoveDataRequest request = new RemoveDataRequest();		
	final RemoveDataClickListener listener = Mockito.spy(new RemoveDataClickListener(request));
	final ApplicationManager applicationManager = Mockito.mock(ApplicationManager.class);
	Mockito.doReturn(applicationManager).when(listener).getApplicationManager();
	
	final RemoveDataResponse response = new RemoveDataResponse(ServiceResult.SUCCESS);
	Mockito.when(applicationManager.asyncService(request)).thenReturn(Mockito.mock(Future.class));
	
	Mockito.doNothing().when(listener).showNotification(ArgumentMatchers.anyString(), ArgumentMatchers.anyString(), ArgumentMatchers.any(Type.class));
	listener.buttonClick(new ClickEvent(new Panel()));
	Mockito.verify(listener).showNotification(ArgumentMatchers.anyString(), ArgumentMatchers.anyString(), ArgumentMatchers.any(Type.class));
}
 
Example 21
Source Project: cia   Source File: UpdateSearchIndexClickListenerTest.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Show notification success test.
 */
@Test
public void showNotificationSuccessTest() {
	final UpdateSearchIndexRequest request = new UpdateSearchIndexRequest();		
	final UpdateSearchIndexClickListener listener = Mockito.spy(new UpdateSearchIndexClickListener(request));
	final ApplicationManager applicationManager = Mockito.mock(ApplicationManager.class);
	Mockito.doReturn(applicationManager).when(listener).getApplicationManager();
	
	final UpdateSearchIndexResponse response = new UpdateSearchIndexResponse(ServiceResult.SUCCESS);
	Mockito.when(applicationManager.asyncService(request)).thenReturn(Mockito.mock(Future.class));
	
	Mockito.doNothing().when(listener).showNotification(ArgumentMatchers.anyString(), ArgumentMatchers.anyString(), ArgumentMatchers.any(Type.class));
	listener.buttonClick(new ClickEvent(new Panel()));
	Mockito.verify(listener).showNotification(ArgumentMatchers.anyString(), ArgumentMatchers.anyString(), ArgumentMatchers.any(Type.class));
}
 
Example 22
Source Project: vaadin-grid-util   Source File: DemoUI.java    License: MIT License 5 votes vote down vote up
private void setColumnRenderes(final Grid grid) {
    grid.getColumn("id")
            .setRenderer(
                    new EditDeleteButtonValueRenderer<Inhabitants>(edit -> {
                        Notification.show(edit.getItem()
                                .toString() + " want's to get edited", Type.HUMANIZED_MESSAGE);
                    }, delete -> {
                        Notification.show(delete.getItem()
                                .toString() + " want's to get deleted", Type.WARNING_MESSAGE);

                    }))
            .setWidth(160);

    grid.getColumn("bodySize")
            .setRenderer(new IndicatorRenderer(1.8, 1.1))
            .setWidth(150);
    grid.getColumn("birthday")
            .setRenderer(new DateRenderer(DateFormat.getDateInstance()))
            .setWidth(210);
    grid.getColumn("onFacebook")
            .setRenderer(new BooleanRenderer())
            .setWidth(130);

    /*
     * the icon of the editButton will get overwritten below by css styling @see DemoUI.initColumnAlignments
     */
    grid.addColumn((ValueProvider<Inhabitants, String>) value -> String.format("%s <i>(%d)</i>",
            value.getCountry()
                    .getName(),
            value.getCountry()
                    .getPopulation()), new EditButtonValueRenderer<Inhabitants>(e -> {
        Notification.show("Goto Link for " + e.getItem()
                .getCountry()
                .getName(), Type.HUMANIZED_MESSAGE);
    }));
}
 
Example 23
@EventBusListenerMethod
public void onAccessDenied(org.vaadin.spring.events.Event<AccessDeniedEvent> event) {
	//TODO Redirect to login,
	
	if (event.getPayload().getCause() != null) {
		Notification.show("Access is denied.", "Service can be invoked only by Admin users.", Type.ERROR_MESSAGE);
	} else {
		if (event.getPayload().getViewToken().equals(ViewToken.USER)) {
			Notification.show("Access is denied.", "You must sign in before accessing User home.", Type.ERROR_MESSAGE);
		} else {
			Notification.show("Access is denied.", "You must sign in as Admin user before accessing Admin home.", Type.ERROR_MESSAGE);
		}
	}
}
 
Example 24
Source Project: gantt   Source File: DemoUI.java    License: Apache License 2.0 5 votes vote down vote up
private void showNotificationWithMousedetails(String msg, MouseEventDetails details) {
    String detailsTxt = "";
    if (details.isCtrlKey()) {
        detailsTxt = "(Ctrl down) ";
    }
    Notification.show(detailsTxt + msg, Type.TRAY_NOTIFICATION);
}
 
Example 25
Source Project: jdal   Source File: PageableTable.java    License: Apache License 2.0 5 votes vote down vote up
public void filter() {
	if (this.filterForm != null) {
		filterForm.update();
		
		if (!filterForm.validateView()) {
				Notification.show(filterForm.getErrorMessage(), Notification.Type.ERROR_MESSAGE);
		}
		
		postProcessFilter(this.filterForm.getModel());
	}
	
	firstPage();
}
 
Example 26
Source Project: jdal   Source File: PageableTable.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * @param selected
 */
@Override
public void delete(Collection<?> selected) {
	try {
		List<T> beans = new ArrayList<T>();
		for (Object id : selected) {
			beans.add(getBean(getContainer().getItem(id)));
		}
		
		this.service.delete(beans);
	}
	catch(DataAccessException dae) {
		Notification.show("Error", getMessage("PageableTable.deleteError"), Type.ERROR_MESSAGE);
	}
}
 
Example 27
public void cancel(Button.ClickEvent event) {
    // Place to call business logic.
    Notification.show("Cancelled", Type.TRAY_NOTIFICATION);
    getUI().contactList.select(null);
}
 
Example 28
Source Project: chipster   Source File: Notificationutil.java    License: MIT License 4 votes vote down vote up
public static void showFailNotification(String title, String description) {
	Notification notification = new Notification(title + "\n", description, Type.WARNING_MESSAGE);
	notification.setDelayMsec(-1);
	notification.setHtmlContentAllowed(false);
	notification.show(Page.getCurrent());
}
 
Example 29
Source Project: calendar-component   Source File: MeetingCalendar.java    License: Apache License 2.0 3 votes vote down vote up
private void onCalendarClick(CalendarComponentEvents.ItemClickEvent event) {

        MeetingItem item = (MeetingItem) event.getCalendarItem();

        final Meeting meeting = item.getMeeting();

        Notification.show(meeting.getName(), meeting.getDetails(), Type.HUMANIZED_MESSAGE);
    }
 
Example 30
Source Project: cia   Source File: AbstractClickListener.java    License: Apache License 2.0 2 votes vote down vote up
/**
 * Show notification.
 *
 * @param caption     the caption
 * @param description the description
 * @param type        the type
 */
protected void showNotification(final String caption, final String description, final Type type) {
	Notification.show(caption, description, type);		
}