com.vaadin.data.HasValue.ValueChangeEvent Java Examples

The following examples show how to use com.vaadin.data.HasValue.ValueChangeEvent. 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 check out the related API usage on the sidebar.
Example #1
Source File: DecisionFlowValueChangeListenerTest.java    From cia with Apache License 2.0 6 votes vote down vote up
/**
 * Selection value change test.
 */
@Test
public void selectionValueChangeTest() {
	final String pageName = "pageName";
	final String pageId = "pageId";
	final DecisionFlowValueChangeListener listener = new DecisionFlowValueChangeListener(pageName, pageId);
	final UI uiMock = Mockito.mock(UI.class);
	UI.setCurrent(uiMock);
	
	final Navigator navigatorMock = Mockito.mock(Navigator.class);
	Mockito.when(uiMock.getNavigator()).thenReturn(navigatorMock);		
			
	final ValueChangeEvent event = Mockito.mock(ValueChangeEvent.class);
	
	final HasValue hasValue = Mockito.mock(HasValue.class);
	Mockito.when(hasValue.isEmpty()).thenReturn(false);
	
	Mockito.when(event.getSource()).thenReturn(hasValue);
	
	final String value = "value";
	Mockito.when(event.getValue()).thenReturn("value");
		
	listener.valueChange(event);
	
	Mockito.verify(navigatorMock, times(1)).navigateTo(pageName + "/CHARTS/DECISION_FLOW_CHART/" + pageId + "[" +value + "]");
}
 
Example #2
Source File: Util.java    From gantt with Apache License 2.0 6 votes vote down vote up
public static TextField createNumberEditor(String caption, float value, final Component component,
        final NumberValueChange valueChange) {
    TextField field = new TextField(caption);
    field.setMaxLength(5);
    field.setValue("" + value);
    field.addValueChangeListener(new ValueChangeListener<String>() {

        @Override
        public void valueChange(ValueChangeEvent<String> event) {
            Object v = event.getValue();
            try {
                float f = Float.parseFloat("" + v);
                valueChange.onValueChange(f);
            } catch (NumberFormatException e) {
                Notification.show("Invalid floating number! Format is 123.345");
            }
        }
    });
    return field;
}
 
Example #3
Source File: Util.java    From gantt with Apache License 2.0 6 votes vote down vote up
public static NativeSelect createNativeSelectEditor(String caption, Object value, Collection<Object> items,
        final SelectValueChange valueChange) {
    NativeSelect<Object> s = new NativeSelect<>(caption);
    s.setItemCaptionGenerator(item -> String.valueOf(item));
    s.setItems(items);
    s.setEmptySelectionAllowed(false);
    s.setValue(value);
    s.addValueChangeListener(new ValueChangeListener<Object>() {

        @Override
        public void valueChange(ValueChangeEvent<Object> event) {
            valueChange.onValueChange(event.getValue());
        }
    });
    return s;
}
 
Example #4
Source File: DecisionFlowValueChangeListener.java    From cia with Apache License 2.0 5 votes vote down vote up
@Override
public void valueChange(final ValueChangeEvent<String> event) {
	if (!event.getSource().isEmpty()) {
		UI.getCurrent().getNavigator().navigateTo(pageName + "/" + PageMode.CHARTS + "/"
				+ ChartIndicators.DECISION_FLOW_CHART + "/" + pageId + "[" + event.getValue() + "]");
	}
}
 
Example #5
Source File: DemoUI.java    From gantt with Apache License 2.0 5 votes vote down vote up
@Override
public void valueChange(ValueChangeEvent<String> event) {
    String tzId = event.getValue();
    if ("Default".equals(tzId)) {
        gantt.setTimeZone(getDefaultTimeZone());
    } else {
        gantt.setTimeZone(TimeZone.getTimeZone(tzId));
    }
    syncLocale();
}
 
Example #6
Source File: Util.java    From gantt with Apache License 2.0 5 votes vote down vote up
public static TextField createTextEditor(String caption, String value, final Component component,
        final TextValueChange valueChange) {
    TextField field = new TextField(caption);
    field.setValue("" + value);
    field.addValueChangeListener(new ValueChangeListener<String>() {

        @Override
        public void valueChange(ValueChangeEvent<String> event) {
            Object v = event.getValue();
            valueChange.onValueChange(String.valueOf(v));
        }
    });
    return field;
}
 
Example #7
Source File: WebUserIndicator.java    From cuba with Apache License 2.0 4 votes vote down vote up
protected void substitutedUserChanged(ValueChangeEvent<User> event) {
    UserSessionSource uss = beanLocator.get(UserSessionSource.NAME);

    User newUser = event.getValue();
    UserSession userSession = uss.getUserSession();
    if (userSession == null) {
        throw new RuntimeException("No user session found");
    }

    User oldUser = userSession.getSubstitutedUser() == null ? userSession.getUser() : userSession.getSubstitutedUser();

    if (!oldUser.equals(newUser)) {
        String newUserName = StringUtils.isBlank(newUser.getName()) ? newUser.getLogin() : newUser.getName();

        Messages messages = beanLocator.get(Messages.NAME);

        Dialogs dialogs = getScreenContext(this).getDialogs();

        dialogs.createOptionDialog()
                .withCaption(messages.getMainMessage("substUserSelectDialog.title"))
                .withMessage(messages.formatMainMessage("substUserSelectDialog.msg", newUserName))
                .withType(Dialogs.MessageType.WARNING)
                .withActions(
                        new ChangeSubstUserAction(userComboBox.getValue()) {
                            @Override
                            public void doRevert() {
                                super.doRevert();

                                revertToCurrentUser();
                            }
                        }, new DoNotChangeSubstUserAction() {
                            @Override
                            public void actionPerform(com.haulmont.cuba.gui.components.Component component) {
                                super.actionPerform(component);

                                revertToCurrentUser();
                            }
                        })
                .show();
    }
}
 
Example #8
Source File: DecisionFlowValueChangeListenerTest.java    From cia with Apache License 2.0 4 votes vote down vote up
/**
 * Selection value change event source empty test.
 */
@Test
public void selectionValueChangeEventSourceEmptyTest() {
	final String pageName = "pageName";
	final String pageId = "pageId";
	final DecisionFlowValueChangeListener listener = new DecisionFlowValueChangeListener(pageName, pageId);
	
	final ValueChangeEvent event = Mockito.mock(ValueChangeEvent.class);
	
	final HasValue hasValue = Mockito.mock(HasValue.class);
	Mockito.when(hasValue.isEmpty()).thenReturn(true);
	
	Mockito.when(event.getSource()).thenReturn(hasValue);
	
	listener.valueChange(event);
	
	Mockito.verify(event,times(1)).getSource();

}
 
Example #9
Source File: GroupsView.java    From jpa-addressbook with The Unlicense 4 votes vote down vote up
public void entrySelected(ValueChangeEvent<PhoneBookGroup> event) {
    editEntry(event.getValue());
}
 
Example #10
Source File: MainView.java    From jpa-addressbook with The Unlicense 4 votes vote down vote up
public void entrySelected(ValueChangeEvent<PhoneBookEntry> event) {
    editEntry(event.getValue());
}
 
Example #11
Source File: DemoUI.java    From gantt with Apache License 2.0 4 votes vote down vote up
@Override
public void valueChange(ValueChangeEvent<LocalDateTime> event) {
    gantt.setStartDate(event.getValue());
}
 
Example #12
Source File: DemoUI.java    From gantt with Apache License 2.0 4 votes vote down vote up
@Override
public void valueChange(ValueChangeEvent<LocalDateTime> event) {
    gantt.setEndDate(event.getValue());
}
 
Example #13
Source File: DemoUI.java    From gantt with Apache License 2.0 4 votes vote down vote up
@Override
public void valueChange(ValueChangeEvent<org.tltv.gantt.client.shared.Resolution> event) {
    if (validateResolutionChange(event.getValue())) {
        gantt.setResolution(event.getValue());
    }
}
 
Example #14
Source File: DemoUI.java    From gantt with Apache License 2.0 4 votes vote down vote up
@Override
public void valueChange(ValueChangeEvent<Locale> event) {
    gantt.setLocale(event.getValue());

    syncLocale();
}