blob: 8abd99df342f4f6fc727d20f7b74180ca0cdce11 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
|
package ch.asynk.helloworld;
import java.util.Date;
import com.vaadin.Application;
import com.vaadin.terminal.UserError;
import com.vaadin.data.Property;
import com.vaadin.data.Property.ValueChangeEvent;
import com.vaadin.ui.FormLayout;
import com.vaadin.ui.VerticalLayout;
import com.vaadin.ui.Window;
import com.vaadin.ui.Label;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.TextField;
class DataMappingLayout extends FormLayout {
public DataMappingLayout() {
//
final TextField tf1 = new TextField("Property.ValueChangeListener");
tf1.setImmediate(true);
addComponent(tf1);
final Label lb1 = new Label();
lb1.setCaption("The Value");
addComponent(lb1);
tf1.addListener( new Property.ValueChangeListener() {
@Override
public void valueChange(ValueChangeEvent event) {
String value = (String) tf1.getValue();
lb1.setValue(value);
}
});
//
Button closeButton = new Button("close the application");
closeButton.setDescription("This will close the application");
addComponent(closeButton );
closeButton.addListener( new Button.ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
getApplication().getMainWindow().getApplication().close();
}
});
}
}
class MainLayout extends VerticalLayout {
public MainLayout() {
Label label = new Label("Hello world");
addComponent(label);
//
addComponent( new Button("What is the time?", new Button.ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
getApplication().getMainWindow().showNotification("The time is " + new Date(), "<i>italic</i> <b>bold</b> description",Window.Notification.TYPE_WARNING_MESSAGE);
event.getButton().setComponentError( new UserError("Stop pressing this button !!") );
}
}));
//
Button nextButton = new Button("next layout");
nextButton.setDescription("Go to next layout");
addComponent(nextButton );
nextButton.addListener( new Button.ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
getApplication().getMainWindow().setContent( new DataMappingLayout() );
}
});
}
}
public class HelloWorldApp extends Application {
private static final long serialVersionUID = 1L;
@Override
public void init() {
final Window mainWindow = new Window("Hello World Application");
mainWindow.setContent( new MainLayout() );
setMainWindow(mainWindow);
setLogoutURL("http://asynk.ch");
}
}
|