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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
|
/*
@ITMillApache2LicenseForJavaFiles@
*/
package com.vaadin.tests.featurebrowser;
import com.vaadin.ui.Button;
import com.vaadin.ui.Component;
import com.vaadin.ui.Form;
import com.vaadin.ui.Label;
import com.vaadin.ui.OrderedLayout;
import com.vaadin.ui.Window;
import com.vaadin.ui.Window.CloseEvent;
public class FeatureWindow extends Feature implements Window.CloseListener {
private final Button addButton = new Button("Add window", this, "addWin");
private final Button removeButton = new Button("Remove window", this,
"delWin");
private Window demoWindow;
private Form windowProperties;
public FeatureWindow() {
super();
}
@Override
protected Component getDemoComponent() {
final OrderedLayout layoutRoot = new OrderedLayout();
final OrderedLayout layoutUpper = new OrderedLayout();
final OrderedLayout layoutLower = new OrderedLayout();
demoWindow = new Window("Feature Test Window");
demoWindow.addListener(this);
demoWindow.setWidth("400px");
demoWindow.setHeight("200px");
demoWindow.setTheme("itmill5");
layoutUpper.addComponent(addButton);
layoutUpper.addComponent(removeButton);
updateWinStatus();
// Properties
propertyPanel = new PropertyPanel(demoWindow);
windowProperties = propertyPanel.createBeanPropertySet(new String[] {
"width", "height", "name", "theme", "border", "scrollable", });
windowProperties.replaceWithSelect("border", new Object[] {
new Integer(Window.BORDER_DEFAULT),
new Integer(Window.BORDER_NONE),
new Integer(Window.BORDER_MINIMAL) }, new Object[] { "Default",
"None", "Minimal" });
// Disabled, not applicable for default theme
windowProperties.getField("border").setEnabled(false);
windowProperties.getField("scrollable").setEnabled(false);
propertyPanel.addProperties("Window Properties", windowProperties);
windowProperties.getField("width").setDescription(
"Minimum width is 100");
windowProperties.getField("height").setDescription(
"Minimum height is 100");
setJavadocURL("ui/Window.html");
layoutRoot.addComponent(layoutUpper);
layoutRoot.addComponent(layoutLower);
return layoutRoot;
}
@Override
protected String getExampleSrc() {
return "Window win = new Window();\n"
+ "getApplication().addWindow(win);\n";
}
@Override
protected String getDescriptionXHTML() {
return "The window support in IT Mill Toolkit allows for opening and closing windows, "
+ "refreshing one window from another (for asynchronous terminals), "
+ "resizing windows and scrolling window content. "
+ "There are also a number of preset window border styles defined by "
+ "this feature.";
}
@Override
protected String getImage() {
return "icon_demo.png";
}
@Override
protected String getTitle() {
return "Window";
}
public void addWin() {
propertyPanel.commit();
getApplication().getMainWindow().addWindow(demoWindow);
demoWindow.removeAllComponents();
demoWindow
.addComponent(new Label(
"<br /><br />This is a new window created by "
+ "<em>Add window</em>"
+ " button's event.<br /><br />You may simply"
+ " close this window or select "
+ "<em>Remove window</em> from the Feature Browser window.",
Label.CONTENT_XHTML));
// prevent user to change window name tag (after window is
// created)
windowProperties.getField("name").setEnabled(false);
windowProperties.getField("name").setReadOnly(true);
demoWindow.setVisible(true);
updateWinStatus();
}
public void delWin() {
getApplication().getMainWindow().removeWindow(demoWindow);
// allow user to change window name tag (before window is
// created)
windowProperties.getField("name").setEnabled(true);
windowProperties.getField("name").setReadOnly(false);
updateWinStatus();
}
private void updateWinStatus() {
if (demoWindow.getApplication() == null) {
addButton.setEnabled(true);
removeButton.setEnabled(false);
} else {
addButton.setEnabled(false);
removeButton.setEnabled(true);
}
}
public void windowClose(CloseEvent e) {
delWin();
}
}
|