* @author IT Mill Ltd.
*
*/
-@SuppressWarnings("unchecked")
public class BasicRandomTest extends com.vaadin.Application implements
Button.ClickListener {
final HorizontalLayout setupLayout = new HorizontalLayout();
final Panel statusPanel = new Panel("Status");
- statusPanel.setWidth(200);
+ statusPanel.setWidth("200px");
setupLayout.addComponent(statusPanel);
statusPanel.addComponent(statusLabel);
setupLayout.addComponent(randomSeedValue);
// loads image from package com.vaadin.demo
final ClassResource cr = new ClassResource("m-bullet-blue.gif", this);
final Embedded em = new Embedded("Embedded " + caption, cr);
- em.setWidth(170);
+ em.setWidth("170px");
return em;
}
+ " Panel contains an layout where the actual contained components are added, "
+ "this layout may be switched on the fly.",
Label.CONTENT_XHTML));
- panel.setWidth(222);
+ panel.setWidth("222px");
return panel;
}
main.addWindow(w);
w.setPositionX(100);
w.setPositionY(100);
- w.setWidth(200);
- w.setHeight(200);
+ w.setWidth("200px");
+ w.setHeight("200px");
- w.setWidth(100);
- w.setHeight(400);
+ w.setWidth("100px");
+ w.setHeight("400px");
final Button closebutton = new Button("Close "
+ w.getCaption(), new Button.ClickListener() {
+ "extremities and may have a caption to clarify the nature of the contained components' purpose."
+ " Panel contains an layout where the actual contained components are added, "
+ "this layout may be switched on the fly."));
- ((Panel) result).setWidth(250);
+ ((Panel) result).setWidth("250px");
break;
case 6:
// Datefield
public void buttonClick(ClickEvent event) {\r
Button b = event.getButton();\r
System.out.println(b.getCaption() + " click: "\r
- + (new Date()).toGMTString());\r
+ + (new Date()).toString());\r
System.out.println(b.getApplication());\r
\r
}\r
\r
t = new Table();\r
\r
- t.setWidth(500);\r
- t.setHeight(300);\r
+ t.setWidth("500px");\r
+ t.setHeight("300px");\r
\r
ta[0] = TestForTablesInitialColumnWidthLogicRendering\r
.getTestTable(3, 0);\r
VerticalLayout v = new VerticalLayout();\r
h.addComponent(v);\r
tbl = new Table();\r
- tbl.setHeight(200);\r
- tbl.setWidth(300);\r
+ tbl.setHeight("200px");\r
+ tbl.setWidth("300px");\r
v.addComponent(tbl);\r
tbl.setSelectable(true);\r
tbl.setMultiSelect(false);\r
tbl.setContainerDataSource(hierarchical);\r
\r
Table tbl2 = new Table();\r
- tbl2.setHeight(200);\r
- tbl2.setWidth(300);\r
+ tbl2.setHeight("200px");\r
+ tbl2.setWidth("300px");\r
v.addComponent(tbl2);\r
tbl2.setSelectable(true);\r
tbl2.setMultiSelect(false);\r
click = new Button("Set height -1", new ClickListener() {\r
\r
public void buttonClick(ClickEvent event) {\r
- tab.setHeight(-1);\r
+ tab.setHeight(null);\r
}\r
\r
});\r
public void valueChange(ValueChangeEvent event) {
- final String currentStyle = l.getStyle();
+ final String currentStyle = l.getStyleName();
final String[] tmp = currentStyle.split(" ");
final ArrayList<String> curStyles = new ArrayList<String>();
for (int i = 0; i < tmp.length; i++) {
main.addWindow(w);
w.setPositionX(100);
w.setPositionY(100);
- w.setWidth(200);
- w.setHeight(200);
+ w.setWidth("200px");
+ w.setHeight("200px");
- w.setWidth(100);
- w.setHeight(400);
+ w.setWidth("100px");
+ w.setHeight("400px");
final Button closebutton = new Button("Close "
+ w.getCaption(), new Button.ClickListener() {
ol2.addComponent(commit);
status.addComponent(ol2);
- status.setHeight(300);
- status.setWidth(400);
+ status.setHeight("300px");
+ status.setWidth("400px");
ol.addComponent(status);
t = getTestTable(3, 40);
t.setCaption("Table with some columns and wide explicit width. (Ought to widen columns to use all space)");
- t.setWidth(1000);
+ t.setWidth("1000px");
main.addComponent(t);
t = getTestTable(12, 4);
t = getTestTable(4, 4);
t.setCaption("Table with some rows and width = 200px");
- t.setWidth(200);
+ t.setWidth("200px");
main.addComponent(t);
final Button b = new Button("refresh view", this, "createNewView");
// configure file structure panel
main.addComponent(explorerPanel);
explorerPanel.addComponent(tree);
- explorerPanel.setHeight(400);
+ explorerPanel.setHeight("400px");
// "this" handles tree's expand event
tree.addListener(this);
return textField;\r
}\r
\r
+ @SuppressWarnings("unused")\r
public void setTextField(ObjectProperty<String> textField) {\r
this.textField = textField;\r
}\r
accordion.removeComponent(accordion.getComponentIterator().next());\r
}\r
\r
- @SuppressWarnings("unchecked")\r
private void closeLastTab() {\r
Iterator<Component> i = accordion.getComponentIterator();\r
Component last = null;\r
accordion.removeComponent(last);\r
}\r
\r
- @SuppressWarnings("unchecked")\r
private void reorder() {\r
AbstractComponentContainer container = accordion;\r
\r
b = new Button("Set date to 4.5.1990");\r
b.addListener(new ClickListener() {\r
\r
+ @SuppressWarnings("deprecation")\r
public void buttonClick(ClickEvent event) {\r
df.setValue(new Date(1990 - 1900, 5 - 1, 4));\r
}\r
b = new Button("Set date to 5.6.2000 using a property data source");\r
b.addListener(new ClickListener() {\r
\r
+ @SuppressWarnings("deprecation")\r
public void buttonClick(ClickEvent event) {\r
ObjectProperty<Date> dfProp = new ObjectProperty<Date>(\r
new Date(2000 - 1900, 6 - 1, 5), Date.class);\r
"Set date to 27.8.2005 by changing a property data source from null");\r
b.addListener(new ClickListener() {\r
\r
+ @SuppressWarnings("deprecation")\r
public void buttonClick(ClickEvent event) {\r
ObjectProperty<Date> dfProp = new ObjectProperty<Date>(null,\r
Date.class);\r
@Override
protected void setup() {
+ @SuppressWarnings("deprecation")
Date d = new Date(2009 - 1900, 12 - 1, 31, 23, 59, 59);
DateField df = new DateField("Lenient ");
@Override
protected void setup() {
+ @SuppressWarnings("deprecation")
DateField df = new DateField("Year", new Date(2009 - 1900, 4 - 1, 1));
df.setLocale(new Locale("en", "US"));
df.setResolution(DateField.RESOLUTION_YEAR);
import com.vaadin.data.util.IndexedContainer;
import com.vaadin.tests.components.TestBase;
import com.vaadin.ui.AbstractSelect.NewItemHandler;
-import com.vaadin.ui.BaseFieldFactory;
import com.vaadin.ui.Button;
import com.vaadin.ui.ComboBox;
import com.vaadin.ui.Component;
+import com.vaadin.ui.DefaultFieldFactory;
import com.vaadin.ui.Field;
-import com.vaadin.ui.FieldFactory;
import com.vaadin.ui.Label;
import com.vaadin.ui.Table;
import com.vaadin.ui.Table.ColumnGenerator;
+import com.vaadin.ui.TableFieldFactory;
public class PropertyValueChange extends TestBase {
}
};
- FieldFactory ff = new MyFieldFactory();
+ TableFieldFactory ff = new MyFieldFactory();
@Override
public void setup() {
t1.setPageLength(0);
t1.setContainerDataSource(container);
t1.addGeneratedColumn("integer x 3", multiplier);
- t1.setFieldFactory(ff);
+ t1.setTableFieldFactory(ff);
t1.setEditable(true);
t1.setDebugId("editortable");
t2.setDescription("This table is in editable mode."
+ " Updates to common datasource should not affect redraw for this "
+ "table. Only the components inside table should get updated.");
- t2.setFieldFactory(ff);
+ t2.setTableFieldFactory(ff);
t2.setEditable(true);
t2.setEnabled(false);
t2.setContainerDataSource(container);
}
}
-class MyFieldFactory extends BaseFieldFactory {
+class MyFieldFactory extends DefaultFieldFactory {
IndexedContainer texts = new IndexedContainer();
tabsheet.removeComponent(tabsheet.getComponentIterator().next());\r
}\r
\r
- @SuppressWarnings("unchecked")\r
private void closeLastTab() {\r
Iterator<Component> i = tabsheet.getComponentIterator();\r
Component last = null;\r
tabsheet.removeComponent(last);\r
}\r
\r
- @SuppressWarnings("unchecked")\r
private void reorder() {\r
AbstractComponentContainer container = tabsheet;\r
\r
Button button = new Button("Update tab caption");\r
button.addListener(new Button.ClickListener() {\r
public void buttonClick(ClickEvent event) {\r
- tabSheet.setTabCaption(panel1, "This is a new tab caption "\r
- + dateFormatter.format(date));\r
+ tabSheet.getTab(panel1).setCaption(\r
+ "This is a new tab caption "\r
+ + dateFormatter.format(date));\r
}\r
});\r
\r
package com.vaadin.tests.components.tree;
-import java.io.IOException;
-import java.io.StringBufferInputStream;
-
import com.vaadin.tests.components.TestBase;
import com.vaadin.ui.Component;
import com.vaadin.ui.CustomLayout;
@Override
protected void setup() {
- try {
- styles = new CustomLayout(new StringBufferInputStream(css));
- } catch (IOException e) {
- e.printStackTrace();
- }
+ styles = new CustomLayout(css);
addComponent(styles);
Tree tree = new Tree();
import com.vaadin.event.dd.DropHandler;
import com.vaadin.event.dd.acceptcriteria.AcceptCriterion;
import com.vaadin.event.dd.acceptcriteria.SourceIs;
-import com.vaadin.terminal.ThemeResource;
import com.vaadin.terminal.gwt.client.ui.dd.VerticalDropLocation;
import com.vaadin.tests.components.TestBase;
import com.vaadin.tests.util.TestUtils;
}
- private final static ThemeResource FOLDER = new ThemeResource(
- "../runo/icons/16/folder.png");
- private final static ThemeResource DOC = new ThemeResource(
- "../runo/icons/16/document.png");
-
@Override
protected String getDescription() {
return "dd";
import com.vaadin.event.dd.DropTarget;
import com.vaadin.event.dd.acceptcriteria.AcceptAll;
import com.vaadin.event.dd.acceptcriteria.AcceptCriterion;
-import com.vaadin.terminal.ThemeResource;
import com.vaadin.tests.components.TestBase;
import com.vaadin.ui.Component;
import com.vaadin.ui.CssLayout;
}
- private final static ThemeResource FOLDER = new ThemeResource(
- "../runo/icons/16/folder.png");
- private final static ThemeResource DOC = new ThemeResource(
- "../runo/icons/16/document.png");
-
@Override
protected String getDescription() {
return "dd: DragAndDropWrapper to build various use cases completely on server side";
import com.vaadin.event.dd.acceptcriteria.AcceptCriterion;
import com.vaadin.event.dd.acceptcriteria.Not;
import com.vaadin.event.dd.acceptcriteria.SourceIsTarget;
-import com.vaadin.terminal.ApplicationResource;
import com.vaadin.terminal.Resource;
import com.vaadin.terminal.StreamResource;
import com.vaadin.terminal.StreamResource.StreamSource;
private BeanItemContainer<File> fs1;
- private static int count;
-
private static DDTest6 instance;
@Override
}
private void showSpreadsheet(File file) {
- ApplicationResource resource = (ApplicationResource) file.getResource();
+ // ApplicationResource resource = (ApplicationResource)
+ // file.getResource();
String string = new String(file.bas.toByteArray());
String[] rows = string.split("\n");
String[] cols = rows[0].split(",");
Table table = new Table();
for (String string2 : cols) {
- String col = string2.replaceAll("\"", ""); // remove surrounding ""
+ // String col =
+ string2.replaceAll("\"", ""); // remove surrounding ""
table.addContainerProperty(string2, String.class, "");
}
for (int i = 1; i < rows.length; i++) {
import java.util.StringTokenizer;
import com.vaadin.data.Property;
-import com.vaadin.ui.AbstractComponent;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.Button.ClickListener;
features.setItemCaptionPropertyId("name");
features.addListener(this);
features.setImmediate(true);
- features.setStyle("menu");
+ features.setStyleName("menu");
// Configure component layout
mainlayout = new CustomLayout("featurebrowser-mainlayout");
// Restart button
final Button close = new Button("restart", getApplication(), "close");
- close.setStyle("link");
+ close.setStyleName("link");
mainlayout.addComponent(close, "restart");
// Test component
// FIXME: navigation statistics
try {
if ((event.getProperty().toString() == null)
- && ((AbstractComponent) event.getProperty()).getTag()
- .equals("tree")) {
+ && (event.getProperty() instanceof Tree)) {
// ignore tree initialization
} else {
FeatureUtil.debug(
getApplication().getUser().toString(),
"valueChange "
- + ((AbstractComponent) event.getProperty())
- .getTag() + ", " + event.getProperty());
+ + event.getProperty().getClass()
+ .getSimpleName() + ", "
+ + event.getProperty());
}
} catch (final Exception e) {
// ignored, should never happen
// FIXME: navigation statistics
try {
FeatureUtil.debug(getApplication().getUser().toString(),
- "buttonClick " + event.getButton().getTag() + ", "
- + event.getButton().getCaption() + ", "
+ "buttonClick "
+ + event.getButton().getClass().getSimpleName()
+ + ", " + event.getButton().getCaption() + ", "
+ event.getButton().getValue());
} catch (final Exception e) {
// ignored, should never happen
final Embedded emb = new Embedded("Embedded Caption", flashResource);
emb.setType(Embedded.TYPE_OBJECT);
emb.setMimeType("application/x-shockwave-flash");
- emb.setWidth(250);
- emb.setHeight(100);
+ emb.setWidth("250px");
+ emb.setHeight("100px");
l.addComponent(emb);
// Properties
final DateField d = new DateField("Time", new Date());
d.setDescription("This is a DateField-component with text-style");
d.setResolution(DateField.RESOLUTION_MIN);
- d.setStyle("text");
+ d.setStyleName("text");
test.addField(new Object(), d);
}
if (value.equals("Calendar")) {
final DateField c = new DateField("Calendar", new Date());
c.setDescription("DateField-component with calendar-style and day-resolution");
- c.setStyle("calendar");
+ c.setStyleName("calendar");
c.setResolution(DateField.RESOLUTION_DAY);
test.addField(new Object(), c);
}
s.addItem("Windows");
s.addItem("Solaris");
s.addItem("Symbian");
- s.setStyle("optiongroup");
+ s.setStyleName("optiongroup");
test.addField(new Object(), s);
}
final GridLayout gl = new GridLayout(3, 3);
final DateField cal = new DateField("Test component 1", new Date());
- cal.setStyle("calendar");
+ cal.setStyleName("calendar");
gl.addComponent(cal, 1, 0, 2, 1);
for (int i = 2; i < 7; i++) {
gl.addComponent(new TextField("Test component " + i));
final VerticalLayout l = new VerticalLayout();
final Label lab = new Label();
- lab.setStyle("featurebrowser-none");
+ lab.setStyleName("featurebrowser-none");
l.addComponent(lab);
// Properties
import com.vaadin.terminal.SystemError;
import com.vaadin.terminal.ThemeResource;
import com.vaadin.terminal.UserError;
-import com.vaadin.ui.AbstractComponent;
import com.vaadin.ui.AbstractComponentContainer;
import com.vaadin.ui.AbstractField;
import com.vaadin.ui.Button;
// FIXME: navigation statistics
try {
- FeatureUtil.debug(
- getApplication().getUser().toString(),
+ FeatureUtil.debug(getApplication().getUser().toString(),
"valueChange "
- + ((AbstractComponent) event.getProperty())
- .getTag() + ", " + event.getProperty());
+ + event.getProperty().getClass().getSimpleName()
+ + ", " + event.getProperty());
} catch (final Exception e) {
// ignored, should never happen
}
// FIXME: navigation statistics
try {
FeatureUtil.debug(getApplication().getUser().toString(),
- "buttonClick " + event.getButton().getTag() + ", "
- + event.getButton().getCaption() + ", "
+ "buttonClick "
+ + event.getButton().getClass().getSimpleName()
+ + ", " + event.getButton().getCaption() + ", "
+ event.getButton().getValue());
} catch (final Exception e) {
// ignored, should never happen
import com.vaadin.ui.AbsoluteLayout;\r
import com.vaadin.ui.AbsoluteLayout.ComponentPosition;\r
import com.vaadin.ui.AbstractComponent;\r
-import com.vaadin.ui.BaseFieldFactory;\r
import com.vaadin.ui.Button;\r
import com.vaadin.ui.Button.ClickEvent;\r
import com.vaadin.ui.Component;\r
+import com.vaadin.ui.DefaultFieldFactory;\r
import com.vaadin.ui.Field;\r
-import com.vaadin.ui.FieldFactory;\r
import com.vaadin.ui.Form;\r
import com.vaadin.ui.Label;\r
import com.vaadin.ui.Layout;\r
\r
public class TestAbsoluteLayout extends TestBase {\r
\r
- private static class MFieldFactory extends BaseFieldFactory {\r
+ private static class MFieldFactory extends DefaultFieldFactory {\r
\r
@Override\r
public Field createField(Item item, Object propertyId,\r
\r
private static MFieldFactory instance;\r
\r
- public static FieldFactory get() {\r
+ public static DefaultFieldFactory get() {\r
if (instance == null) {\r
instance = new MFieldFactory();\r
}\r
componentEditor = new Form();\r
componentEditor.setWriteThrough(false);\r
componentEditor.setCaption("Component properties:");\r
- componentEditor.setFieldFactory(MFieldFactory.get());\r
+ componentEditor.setFormFieldFactory(MFieldFactory.get());\r
addComponent(componentEditor);\r
\r
positionEditor = new Form();\r
positionEditor.setCaption("Component position");\r
positionEditor.setWriteThrough(false);\r
- positionEditor.setFieldFactory(MFieldFactory.get());\r
+ positionEditor.setFormFieldFactory(MFieldFactory.get());\r
addComponent(positionEditor);\r
\r
Button b = new Button("Commit changes", new Button.ClickListener() {\r
\r
// Panel w/ Tree\r
main.setStyleName(Reindeer.PANEL_LIGHT);\r
- main.setWidth(200);\r
+ main.setWidth("200px");\r
// // Description, this is needed. Works in first slot\r
main.addComponent(new Label(desc));\r
\r
Window w = new Window("Status of the fields");\r
w.setModal(true);\r
w.setScrollable(true);\r
- w.setHeight(80);\r
+ w.setHeight("80px");\r
w.setHeightUnits(Sizeable.UNITS_PERCENTAGE);\r
w.addComponent(new Label(msg.toString(), Label.CONTENT_XHTML));\r
main.addWindow(w);\r
\r
Panel p = new Panel(\r
"This is a really long caption for the panel, too long in fact!");\r
- p.setWidth(300);\r
- p.setHeight(300);\r
+ p.setWidth("300px");\r
+ p.setHeight("300px");\r
\r
getMainWindow().addComponent(p);\r
}\r
VerticalLayout el = new VerticalLayout();\r
Panel elp = new Panel(\r
"Vertical ExpandLayout /w first component expanded", el);\r
- el.setHeight(1000);\r
+ el.setHeight("1000px");\r
for (int i = 0; i < 3; i++) {\r
Button b = new Button("x");\r
el.addComponent(b);\r
}\r
}\r
lo.addComponent(elp);\r
- elp.setWidth(300);\r
- elp.setHeight(300);\r
+ elp.setWidth("300px");\r
+ elp.setHeight("300px");\r
elp.setScrollable(true);\r
\r
HorizontalLayout elh = new HorizontalLayout();\r
Panel elph = new Panel(\r
"Horizontal ExpandLayout /w first component expanded", elh);\r
- elh.setWidth(1000);\r
+ elh.setWidth("1000px");\r
for (int i = 0; i < 3; i++) {\r
Button b = new Button("x");\r
elh.addComponent(b);\r
}\r
}\r
lo.addComponent(elph);\r
- elph.setWidth(300);\r
- elph.setHeight(300);\r
+ elph.setWidth("300px");\r
+ elph.setHeight("300px");\r
elph.setScrollable(true);\r
\r
}\r
for (int i = 0; i < 3; i++) {
Button b = new Button("Row " + (i + 1));
if (!horizontal) {
- b.setWidth(500);
+ b.setWidth("500px");
}
ol.addComponent(b);
}
setMainWindow(w);
final VerticalLayout l = new VerticalLayout();
- l.setWidth(400);
- l.setHeight(100);
+ l.setWidth("400px");
+ l.setHeight("100px");
l.addComponent(new TextField("This one works fine"));
TextField t = new TextField();
t.setRequired(true);
w.addComponent(new Button("show me the bug",
new Button.ClickListener() {
public void buttonClick(ClickEvent event) {
- l.setWidth(-1);
+ l.setWidth(null);
}
}));
setMainWindow(w);
final VerticalLayout l = new VerticalLayout();
- l.setWidth(200);
- l.setHeight(-1);
+ l.setWidth("200px");
+ l.setHeight(null);
TextField t = new TextField();
l.addComponent(t);
t.setRequired(true);
addButtons(gl);\r
\r
b = new Button("High button");\r
- b.setHeight(200);\r
+ b.setHeight("200px");\r
gl.addComponent(b);\r
\r
p.addComponent(gl);\r
\r
private void gridLayout(Layout layout) {\r
Panel p = new Panel("GridLayout");\r
- p.setWidth(500);\r
- p.setHeight(500);\r
+ p.setWidth("500px");\r
+ p.setHeight("500px");\r
p.getContent().setSizeFull();\r
layout.addComponent(p);\r
\r
\r
private void orderedLayout(Layout layout) {\r
Panel p = new Panel("OrderedLayout");\r
- p.setWidth(500);\r
- p.setHeight(500);\r
+ p.setWidth("500px");\r
+ p.setHeight("500px");\r
p.getContent().setWidth("100%");\r
layout.addComponent(p);\r
\r
\r
ol = new HorizontalLayout();\r
// ol.setCaption("Vertical");\r
- ol.setHeight(200);\r
+ ol.setHeight("200px");\r
addButtons(ol);\r
// Button b = new Button("High button");\r
// b.setHeight(200);\r
final Button b = new Button("fixed width: 30px", false);
b.addListener(new Property.ValueChangeListener() {
public void valueChange(ValueChangeEvent event) {
- l.setWidth(b.booleanValue() ? 30 : -1);
+ if (b.booleanValue()) {
+ l.setWidth("30px");
+ } else {
+ l.setWidth(null);
+ }
}
});
b.setImmediate(true);
addComponent(editor);\r
addComponent(done);\r
\r
- setWidth(W);\r
- setHeight(H);\r
+ setWidth(W + "px");\r
+ setHeight(H + "px");\r
\r
setPositionX(event.getClientX() - W / 2);\r
setPositionY(event.getClientY() - H / 2);\r
\r
Panel p3 = new Panel();\r
p3.setCaption("GridLayout");\r
- p3.setWidth(500);\r
- p3.setHeight(500);\r
+ p3.setWidth("500px");\r
+ p3.setHeight("500px");\r
// p3.setContent(new GridLayout());\r
p3.getContent().setSizeFull();\r
((Layout) p3.getContent()).setMargin(false);\r
import com.vaadin.ui.Button.ClickEvent;\r
import com.vaadin.ui.Component;\r
import com.vaadin.ui.ComponentContainer;\r
+import com.vaadin.ui.DefaultFieldFactory;\r
import com.vaadin.ui.Field;\r
import com.vaadin.ui.Form;\r
import com.vaadin.ui.GridLayout;\r
p.setValue(i % 5 == 0 ? "enabled" : "disabled");\r
}\r
\r
- table.setFieldFactory(new BaseFieldFactory() {\r
+ table.setTableFieldFactory(new DefaultFieldFactory() {\r
\r
@Override\r
public Field createField(Container container, Object itemId,\r
+ "extremities and may have a caption to clarify the nature of the contained components' purpose."
+ " Panel contains an layout where the actual contained components are added, "
+ "this layout may be switched on the fly."));
- ((Panel) result).setWidth(250);
+ ((Panel) result).setWidth("250px");
break;
case 6:
// Datefield