Component component, List<InvalidLayout> errors,
InvalidLayout parent) {
- boolean invalidHeight = !checkHeights(component);
- boolean invalidWidth = !checkWidths(component);
-
- if (invalidHeight || invalidWidth) {
- InvalidLayout error = new InvalidLayout(component, invalidHeight,
- invalidWidth);
- if (parent != null) {
- parent.addError(error);
- } else {
- if (errors == null) {
- errors = new LinkedList<InvalidLayout>();
+ if (component != null) {
+ boolean invalidHeight = !checkHeights(component);
+ boolean invalidWidth = !checkWidths(component);
+
+ if (invalidHeight || invalidWidth) {
+ InvalidLayout error = new InvalidLayout(component,
+ invalidHeight, invalidWidth);
+ if (parent != null) {
+ parent.addError(error);
+ } else {
+ if (errors == null) {
+ errors = new LinkedList<InvalidLayout>();
+ }
+ errors.add(error);
}
- errors.add(error);
+ parent = error;
}
- parent = error;
}
if (component instanceof Panel) {
setSizeUndefined();
}
- /**
- * Add a component to the content ({@link ComponentContainer}) of a window.
- *
- * This version creates an empty {@link VerticalLayout} if no container is
- * defined, but this automatic creation will be removed in future versions.
- *
- * @param c
- * component to add
- *
- * @deprecated use Window.setContent(Component) instead
- */
- @Deprecated
- public void addComponent(Component c) {
- if (c instanceof Window) {
- throw new IllegalArgumentException(
- "Window cannot be added to another via addComponent. "
- + "Use addWindow(Window) instead.");
- }
-
- if (getContent() == null) {
- // TODO this automatic creation should be removed in the future
- VerticalLayout content = new VerticalLayout();
- content.setMargin(true);
- setContent(content);
- }
-
- if (getContent() instanceof ComponentContainer) {
- ((ComponentContainer) getContent()).addComponent(c);
- } else {
- throw new IllegalArgumentException(
- "Cannot add component to a window whose content is not a ComponentContainer");
- }
- }
-
/* ********************************************************************* */
/*
"SELECT * FROM people", Arrays.asList("ID"), connectionPool));
Table table = new Table();
Window w = new Window();
- w.addComponent(table);
+ w.setContent(table);
table.setContainerDataSource(container);
}
import com.vaadin.ui.Label;
import com.vaadin.ui.LegacyWindow;
import com.vaadin.ui.TextField;
+import com.vaadin.ui.VerticalLayout;
import com.vaadin.ui.Window;
/**
private void openSubWindow() {
// Modal window
- test = new Window("Modal window");
+ VerticalLayout layout = new VerticalLayout();
+ layout.setMargin(true);
+ test = new Window("Modal window", layout);
test.setModal(true);
getMainWindow().addWindow(test);
- test.addComponent(new Label(
+ layout.addComponent(new Label(
"You have to close this window before accessing others."));
// Textfield for modal window
final TextField f = new TextField();
f.setTabIndex(4);
- test.addComponent(f);
+ layout.addComponent(f);
f.focus();
// Modal window button
final Button b = new Button("Test Button in modal window");
b.setTabIndex(5);
b.addListener(this);
- test.addComponent(b);
+ layout.addComponent(b);
}
}
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.Label;
import com.vaadin.ui.LegacyWindow;
+import com.vaadin.ui.VerticalLayout;
import com.vaadin.ui.Window;
public class NativeWindowing extends LegacyApplication {
new Button.ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
+ VerticalLayout layout = new VerticalLayout();
+ layout.setMargin(true);
final Window w = new Window("sw "
- + System.currentTimeMillis());
+ + System.currentTimeMillis(), layout);
main.addWindow(w);
w.setPositionX(100);
w.setPositionY(100);
}
});
- w.addComponent(closebutton);
+ layout.addComponent(closebutton);
- w.addComponent(new Label(
+ layout.addComponent(new Label(
"<p>Lorem ipsum dolor sit amet.</p>"
+ "<p>Lorem ipsum dolor sit amet.</p>"
+ "<p>Lorem ipsum dolor sit amet.</p>"
test(gridLayout);
populateLayout(gridLayout);
- final Window window = new Window("TEST: Window");
+ VerticalLayout layout = new VerticalLayout();
+ layout.setMargin(true);
+ final Window window = new Window("TEST: Window", layout);
test(window);
- populateLayout((Layout) window.getContent());
+ populateLayout(layout);
}
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.Label;
import com.vaadin.ui.LegacyWindow;
+import com.vaadin.ui.VerticalLayout;
import com.vaadin.ui.Window;
public class TestForNativeWindowing extends LegacyApplication {
new Button.ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
+ VerticalLayout layout = new VerticalLayout();
+ layout.setMargin(true);
final Window w = new Window("sw "
- + System.currentTimeMillis());
+ + System.currentTimeMillis(), layout);
main.addWindow(w);
w.setPositionX(100);
w.setPositionY(100);
}
});
- w.addComponent(closebutton);
+ layout.addComponent(closebutton);
- w.addComponent(new Label(
+ layout.addComponent(new Label(
"<p>Lorem ipsum dolor sit amet.</p>"
+ "<p>Lorem ipsum dolor sit amet.</p>"
+ "<p>Lorem ipsum dolor sit amet.</p>"
@Override
public void buttonClick(ClickEvent event) {
- Window w = new Window("Testing Window");
+ VerticalLayout layout = new VerticalLayout();
+ layout.setMargin(true);
+ Window w = new Window("Testing Window", layout);
if (asModal.getValue().booleanValue()) {
w.setModal(true);
});
- w.addComponent(s1);
- w.addComponent(s2);
+ layout.addComponent(s1);
+ layout.addComponent(s2);
Slider s = new Slider();
s.setCaption("Volume");
// s.setOrientation(Slider.ORIENTATION_VERTICAL);
// s.setArrows(false);
- w.addComponent(s);
+ layout.addComponent(s);
UI.getCurrent().addWindow(w);
Button b = new Button("Open subwindow", new Button.ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
- Window w = new Window("Subwindow");
+ VerticalLayout layout = new VerticalLayout();
+ layout.setMargin(true);
+ Window w = new Window("Subwindow", layout);
w.center();
w.setHeight("200px");
- w.addComponent(getBigComponent());
+ layout.addComponent(getBigComponent());
getMainWindow().addWindow(w);
}
});
import com.vaadin.ui.Button.ClickListener;
import com.vaadin.ui.Component;
import com.vaadin.ui.Notification;
+import com.vaadin.ui.VerticalLayout;
import com.vaadin.ui.Window;
@SuppressWarnings("serial")
for (int j = 0; j < 20; j++) {
+ VerticalLayout layout = new VerticalLayout();
+ layout.setMargin(true);
Window window = new Window();
+ window.setContent(layout);
getMainWindow().addWindow(window);
Button button1 = new Button("b1 (CTRL-C)");
button1.setClickShortcut(KeyCode.C, ModifierKey.CTRL);
button2.setClickShortcut(KeyCode.V, ModifierKey.CTRL);
- window.addComponent(button1);
- window.addComponent(button2);
+ layout.addComponent(button1);
+ layout.addComponent(button2);
button1.focus();
button1.setData(prev);
prev = button1;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.ComboBox;
import com.vaadin.ui.Component;
+import com.vaadin.ui.VerticalLayout;
import com.vaadin.ui.Window;
public class ComboBoxInPopup extends TestBase {
@Override
protected void setup() {
+ VerticalLayout layout = new VerticalLayout();
+ layout.setMargin(true);
+ layout.setSizeUndefined();
final Window w = new Window();
- w.getContent().setSizeUndefined();
- w.addComponent(createComboBox());
+ w.setContent(layout);
+ layout.addComponent(createComboBox());
Button close = new Button("Close window", new Button.ClickListener() {
@Override
}
});
close.setClickShortcut(KeyCode.ESCAPE, null);
- w.addComponent(close);
+ layout.addComponent(close);
getLayout().getUI().addWindow(w);
import com.vaadin.event.FieldEvents.FocusEvent;
import com.vaadin.tests.components.TestBase;
import com.vaadin.ui.ComboBox;
+import com.vaadin.ui.VerticalLayout;
import com.vaadin.ui.Window;
public class ComboBoxSuggestionOnDetach extends TestBase {
@Override
protected void setup() {
final Window popup = new Window();
+
+ VerticalLayout layout = new VerticalLayout();
+ layout.setMargin(true);
+ layout.setSizeUndefined();
+ popup.setContent(layout);
+
ComboBox comboBox = new ComboBox("Combo box", Arrays.asList("Option 1",
"Option 2", "Option 3"));
comboBox.addListener(new FieldEvents.FocusListener() {
popup.close();
}
});
- popup.addComponent(comboBox);
+ layout.addComponent(comboBox);
popup.setSizeUndefined();
- popup.getContent().setSizeUndefined();
popup.center();
getMainWindow().addWindow(popup);
}
protected void initWindow() {
- VerticalLayout layout = (VerticalLayout) getContent();
+ VerticalLayout layout = new VerticalLayout();
layout.setMargin(true);
layout.setSpacing(true);
+ setContent(layout);
/**
* This causes the window to add the .v-readonly style!
generalForm.setVisibleItemProperties(new String[] { "myDate",
"myString" });
generalForm.setValidationVisible(true);
- addComponent(generalForm);
+ layout.addComponent(generalForm);
}
HorizontalLayout buttons = new HorizontalLayout();
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.Embedded;
import com.vaadin.ui.Label;
+import com.vaadin.ui.VerticalLayout;
import com.vaadin.ui.Window;
public class EmbeddedApplet extends TestBase {
}
}));
- Window window = new Window("Testwindow");
- window.addComponent(new Label("I am inside the window"));
+ VerticalLayout layout = new VerticalLayout();
+ layout.setMargin(true);
+ Window window = new Window("Testwindow", layout);
+ layout.addComponent(new Label("I am inside the window"));
applet.getUI().addWindow(window);
}
}
vlTF2.addComponent(tf2);
hl.addComponent(vlTF2);
- Window wnd = new Window("Test");
- wnd.getContent().setSizeUndefined();
- wnd.addComponent(hl);
+ VerticalLayout layout = new VerticalLayout();
+ layout.setMargin(true);
+ layout.setSizeUndefined();
+ Window wnd = new Window("Test", layout);
+ layout.addComponent(hl);
Button btn = new Button("Show/hide");
- btn.addListener(new Button.ClickListener() {
+ btn.addClickListener(new Button.ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
tf2.setVisible(!tf2.isVisible());
}
});
- wnd.addComponent(btn);
+ layout.addComponent(btn);
return wnd;
}
addComponent(new PopupView("Show popup table", makeTable("Popup",
KeyCode.P)));
addComponent(makeTable("Main window", KeyCode.M));
- sub.addComponent(new PopupView("Show popup table", makeTable(
- "Subwindow popup", KeyCode.U)));
+ ((ComponentContainer) sub.getContent()).addComponent(new PopupView(
+ "Show popup table", makeTable("Subwindow popup", KeyCode.U)));
}
private ComponentContainer makeTable(final String caption, int keyCode) {
panelLayout.addComponent(createRichTextArea("InPanel"));
getLayout().addComponent(panel);
- Window w = new Window("SubWindow");
+ VerticalLayout layout = new VerticalLayout();
+ layout.setMargin(true);
+ Window w = new Window("SubWindow", layout);
w.addActionHandler(actionHandler);
- w.addComponent(createRichTextArea("InSubWindow"));
- w.getContent().setSizeUndefined();
+ layout.addComponent(createRichTextArea("InSubWindow"));
+ layout.setSizeUndefined();
getLayout().getUI().addWindow(w);
String styleName) {
Window window = new Window();
- window.addComponent(new Label("Some content"));
+ VerticalLayout layout = new VerticalLayout();
+ layout.setMargin(true);
+ window.setContent(layout);
+ layout.addComponent(new Label("Some content"));
if (caption != null) {
window.setCaption(caption);
import com.vaadin.ui.Component;
import com.vaadin.ui.Label;
import com.vaadin.ui.LegacyWindow;
+import com.vaadin.ui.VerticalLayout;
import com.vaadin.ui.Window;
public class AttachShouldBeCalledForSubWindows extends AbstractTestCase {
}
private Window createSubWindow() {
- Window w = new Window("Sub window") {
+ VerticalLayout layout = new VerticalLayout();
+ layout.setMargin(true);
+ Window w = new Window("Sub window", layout) {
@Override
public void attach() {
log(this);
}
});
okButton.setClickShortcut(KeyCode.ENTER);
- w.addComponent(okButton);
+ layout.addComponent(okButton);
w.center();
return w;
}
import com.vaadin.tests.components.TestBase;
import com.vaadin.ui.Label;
+import com.vaadin.ui.VerticalLayout;
import com.vaadin.ui.Window;
public class CenteredWindowWithUndefinedSize extends TestBase {
@Override
protected void setup() {
- Window centered = new Window("A window");
+ VerticalLayout layout = new VerticalLayout();
+ layout.setMargin(true);
+ Window centered = new Window("A window", layout);
centered.setSizeUndefined();
- centered.getContent().setSizeFull();
+ layout.setSizeFull();
centered.center();
Label l = new Label("This window should be centered");
l.setSizeUndefined();
- centered.addComponent(l);
+ layout.addComponent(l);
getMainWindow().addWindow(centered);
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.Button.ClickListener;
+import com.vaadin.ui.VerticalLayout;
import com.vaadin.ui.Window;
import com.vaadin.ui.Window.CloseEvent;
import com.vaadin.ui.Window.CloseListener;
}
private Window createClosableSubWindow(final String title) {
- final Window window = new Window(title);
+ VerticalLayout layout = new VerticalLayout();
+ layout.setMargin(true);
+ layout.setSizeFull();
+ final Window window = new Window(title, layout);
window.setSizeUndefined();
- window.getContent().setSizeFull();
window.setClosable(true);
Button closeButton = new Button("Close");
event.getButton().findAncestor(Window.class).close();
}
});
- window.addComponent(closeButton);
+ layout.addComponent(closeButton);
Button removeButton = new Button("Remove from parent");
removeButton.addListener(new ClickListener() {
window.close();
}
});
- window.addComponent(closeButton);
+ layout.addComponent(closeButton);
window.addListener(new CloseListener() {
@Override
import com.vaadin.server.ThemeResource;
import com.vaadin.tests.components.TestBase;
import com.vaadin.ui.Embedded;
+import com.vaadin.ui.VerticalLayout;
import com.vaadin.ui.Window;
public class EmbeddedInSubWindow extends TestBase {
@Override
protected void setup() {
setTheme("tests-tickets");
- Window zoom = new Window("Image Preview");
+ VerticalLayout layout = new VerticalLayout();
+ layout.setMargin(true);
+ layout.setSizeUndefined();
+ Window zoom = new Window("Image Preview", layout);
zoom.setSizeUndefined();
- zoom.getContent().setSizeUndefined();
String res = "icons/EmbeddedInSubWindow-image.png";
Embedded imagePreview = new Embedded(null, new ThemeResource(res));
imagePreview.setSizeUndefined();
- zoom.addComponent(imagePreview);
+ layout.addComponent(imagePreview);
zoom.setModal(true);
zoom.setResizable(false);
import com.vaadin.tests.components.TestBase;
import com.vaadin.ui.NativeButton;
+import com.vaadin.ui.VerticalLayout;
import com.vaadin.ui.Window;
public class ExtraLargeSubWindow extends TestBase {
@Override
protected void setup() {
- Window w = new Window("full sized window");
+ VerticalLayout layout = new VerticalLayout();
+ layout.setMargin(true);
+ layout.setSizeFull();
+ Window w = new Window("full sized window", layout);
w.setWidth("2000px");
w.setHeight("2000px");
- w.getContent().setSizeFull();
NativeButton b = new NativeButton("A large button");
b.setSizeFull();
- w.addComponent(b);
+ layout.addComponent(b);
getMainWindow().addWindow(w);
}
import com.vaadin.ui.Alignment;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.VerticalLayout;
import com.vaadin.ui.Window;
public class ExtraWindowShown extends TestBase {
@Override
public void buttonClick(ClickEvent event) {
- final Window w = new Window("Sub window");
+ VerticalLayout layout = new VerticalLayout();
+ layout.setMargin(true);
+ final Window w = new Window("Sub window", layout);
w.center();
- w.addComponent(new Button("Close", new Button.ClickListener() {
-
- @Override
- public void buttonClick(ClickEvent event) {
- w.close();
- }
- }));
+ layout.addComponent(new Button("Close",
+ new Button.ClickListener() {
+
+ @Override
+ public void buttonClick(ClickEvent event) {
+ w.close();
+ }
+ }));
Button iconButton = new Button("A button with icon");
iconButton
.setIcon(new ThemeResource("../runo/icons/16/ok.png"));
- w.addComponent(iconButton);
+ layout.addComponent(iconButton);
event.getButton().getUI().addWindow(w);
}
import com.vaadin.ui.CheckBox;
import com.vaadin.ui.Label;
import com.vaadin.ui.LegacyWindow;
+import com.vaadin.ui.VerticalLayout;
import com.vaadin.ui.Window;
import com.vaadin.ui.Window.ResizeEvent;
import com.vaadin.ui.Window.ResizeListener;
public void init() {
mainWindow = new LegacyWindow("Resize test");
setMainWindow(mainWindow);
- subWindow = new Window("Sub window");
+ VerticalLayout layout = new VerticalLayout();
+ layout.setMargin(true);
+ subWindow = new Window("Sub window", layout);
subWindow.setHeight("50%");
subWindow.setWidth("50%");
subWindow.center();
- subWindow.addComponent(new Label(LoremIpsum.get(1000)));
+ layout.addComponent(new Label(LoremIpsum.get(1000)));
getMainWindow().addWindow(subWindow);
lazyMode = new CheckBox("Lazy resize");
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.Label;
import com.vaadin.ui.TextField;
+import com.vaadin.ui.VerticalLayout;
import com.vaadin.ui.Window;
public class SubWindowFocus extends TestBase {
Button b = new Button("new", new Button.ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
- final Window win = new Window("Subwin");
- win.getContent().setWidth(null);
+ VerticalLayout layout = new VerticalLayout();
+ layout.setMargin(true);
+ final Window win = new Window("Subwin", layout);
+ layout.setWidth(null);
win.center();
win.setClosable(false);
getMainWindow().addWindow(win);
- win.addComponent(new Label("SPACE notifies, ESC closes."));
+ layout.addComponent(new Label("SPACE notifies, ESC closes."));
win.addActionHandler(new Action.Handler() {
});
- win.addComponent(new TextField());
+ layout.addComponent(new TextField());
}
});
import com.vaadin.ui.Notification;
import com.vaadin.ui.TextField;
import com.vaadin.ui.UI;
+import com.vaadin.ui.VerticalLayout;
import com.vaadin.ui.Window;
public class SubWindowFocusAndBlurListeners extends TestBase {
@Override
protected void setup() {
- final Window window = new Window("Focus test window");
- window.getContent().setSizeUndefined();
+ VerticalLayout layout = new VerticalLayout();
+ layout.setMargin(true);
+ final Window window = new Window("Focus test window", layout);
+ layout.setSizeUndefined();
- window.addComponent(new TextField());
+ layout.addComponent(new TextField());
window.addListener(new FocusListener() {
@Override
public void focus(FocusEvent event) {
import com.vaadin.ui.HorizontalLayout;
import com.vaadin.ui.Label;
import com.vaadin.ui.UI;
+import com.vaadin.ui.VerticalLayout;
import com.vaadin.ui.Window;
public class SubWindowOrder extends TestBase {
UI mainWindow = getMainWindow();
HorizontalLayout controlpanels = new HorizontalLayout();
for (int i = 1; i <= 5; i++) {
- Window dialog = new Window("Dialog " + i);
- dialog.getContent().setSizeUndefined();
+ VerticalLayout layout = new VerticalLayout();
+ layout.setMargin(true);
+ Window dialog = new Window("Dialog " + i, layout);
+ layout.setSizeUndefined();
windowlist.addBean(dialog);
- dialog.addComponent(new Label("this is dialog number " + i));
- dialog.addComponent(new ControlPanel());
+ layout.addComponent(new Label("this is dialog number " + i));
+ layout.addComponent(new ControlPanel());
mainWindow.addWindow(dialog);
}
controlpanels.addComponent(new ControlPanel());
import com.vaadin.ui.Button;
import com.vaadin.ui.TabSheet;
import com.vaadin.ui.Table;
+import com.vaadin.ui.VerticalLayout;
import com.vaadin.ui.Window;
public class SubWindowWithUndefinedHeight extends TestBase {
@Override
protected void setup() {
- final Window subwindow = new Window("subwindow");
+ final VerticalLayout layout = new VerticalLayout();
+ layout.setMargin(true);
+ final Window subwindow = new Window("subwindow", layout);
subwindow.center();
subwindow.setSizeUndefined();
- subwindow.getContent().setSizeUndefined();
+ layout.setSizeUndefined();
final Button tabButton = new Button("A button");
tabButton.setCaption("Tab 1");
public void selectedTabChange(TabSheet.SelectedTabChangeEvent event) {
if (tabsheet.getSelectedTab() == tabButton) {
tabsheet.setSizeUndefined();
- subwindow.getContent().setSizeUndefined();
+ layout.setSizeUndefined();
subwindow.setSizeUndefined();
} else if (tabsheet.getSelectedTab() == table) {
subwindow.setWidth("500px");
subwindow.setHeight("500px");
- subwindow.getContent().setSizeFull();
+ layout.setSizeFull();
tabsheet.setSizeFull();
}
}
});
- subwindow.addComponent(tabsheet);
+ layout.addComponent(tabsheet);
Button button = new Button("click me", new Button.ClickListener() {
@Override
import com.vaadin.ui.HorizontalLayout;
import com.vaadin.ui.TextArea;
import com.vaadin.ui.TextField;
+import com.vaadin.ui.VerticalLayout;
import com.vaadin.ui.Window;
public class SubWindows extends TestBase {
@Override
protected void setup() {
- autoWideWindow = new Window("Dialog - width by contents",
- new HorizontalLayout());
- autoWideWindow.getContent().setSizeUndefined();
- autoWideWindow.addComponent(new TextField("Field 1"));
- autoWideWindow.addComponent(new TextField("Field 2"));
- autoWideWindow.addComponent(new Button("Add", new ClickListener() {
+ final HorizontalLayout hl = new HorizontalLayout();
+ autoWideWindow = new Window("Dialog - width by contents", hl);
+ hl.setSizeUndefined();
+ hl.addComponent(new TextField("Field 1"));
+ hl.addComponent(new TextField("Field 2"));
+ hl.addComponent(new Button("Add", new ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
- autoWideWindow.addComponent(createRemoveButton());
+ hl.addComponent(createRemoveButton());
}
getMainWindow().addWindow(autoWideWindow);
{
- Window dialog = new Window("Dialog - undefined width");
- dialog.addComponent(new TextField("Field 1"));
+ VerticalLayout vl = new VerticalLayout();
+ hl.setMargin(true);
+ Window dialog = new Window("Dialog - undefined width", vl);
+ vl.addComponent(new TextField("Field 1"));
TextField tf2 = new TextField("Field 2");
tf2.setWidth("500px");
- dialog.addComponent(tf2);
- dialog.addComponent(new Button("Ok"));
+ vl.addComponent(tf2);
+ vl.addComponent(new Button("Ok"));
dialog.center();
getMainWindow().addWindow(dialog);
}
{
- Window dialog = new Window("Dialog - width defined by content");
- dialog.getContent().setHeight(null);
- dialog.getContent().setWidth("100%");
+ VerticalLayout layout = new VerticalLayout();
+ layout.setMargin(true);
+ Window dialog = new Window("Dialog - width defined by content",
+ layout);
+ layout.setHeight(null);
+ layout.setWidth("100%");
TextArea ta = new TextArea();
ta.setValue("The textfield should fill the window (except margins)."
+ "\n - Try to resize the window\n");
ta.setRows(5);
ta.setWidth("100%");
- dialog.addComponent(ta);
+ layout.addComponent(ta);
dialog.setPositionX(20);
dialog.setPositionY(100);
}
{
- Window dialog = new Window("Dialog - size defined by content");
- dialog.getContent().setHeight("100%");
- dialog.getContent().setWidth("100%");
+ VerticalLayout layout = new VerticalLayout();
+ layout.setMargin(true);
+ Window dialog = new Window("Dialog - size defined by content",
+ layout);
+ layout.setHeight("100%");
+ layout.setWidth("100%");
TextArea ta = new TextArea();
ta.setValue("The textfield should fill the window (except margins)."
ta.setWidth("100%");
ta.setHeight("100%");
ta.setRows(5);
- dialog.addComponent(ta);
+ layout.addComponent(ta);
dialog.setPositionX(20);
dialog.setPositionY(300);
@Override
protected void setup() {
- Window window = new Window("Sub window");
+ VerticalLayout layout = new VerticalLayout();
+ layout.setMargin(true);
+ Window window = new Window("Sub window", layout);
window.center();
VerticalLayout vl = new VerticalLayout();
Button b = new Button("A 100% wide button, invalid");
b.setWidth("100%");
vl.addComponent(b);
- window.addComponent(vl);
+ layout.addComponent(vl);
getMainWindow().addWindow(window);
}
import com.vaadin.tests.components.TestBase;
import com.vaadin.ui.Label;
+import com.vaadin.ui.VerticalLayout;
import com.vaadin.ui.Window;
public class TestTooSmallSubwindowSize extends TestBase {
@Override
protected void setup() {
- Window w = new Window("Scroll");
+ VerticalLayout layout = new VerticalLayout();
+ layout.setMargin(true);
+ Window w = new Window("Scroll", layout);
Label desc = new Label(
"This is a new child window with a preset"
+ " width, height and position. Resizing has been"
+ " disabled for this window. Additionally, this text label"
+ " is intentionally too large to fit the window. You can"
+ " use the scrollbars to view different parts of the window content.");
- w.addComponent(desc);
+ layout.addComponent(desc);
// Set window position
w.setPositionX(100);
import com.vaadin.server.VaadinRequest;
import com.vaadin.tests.components.AbstractTestUI;
import com.vaadin.ui.TextField;
+import com.vaadin.ui.VerticalLayout;
import com.vaadin.ui.Window;
public class TooltipInWindow extends AbstractTestUI {
@Override
protected void setup(VaadinRequest request) {
- Window window = new Window("Window");
- window.getContent().setSizeUndefined();
+ VerticalLayout layout = new VerticalLayout();
+ layout.setMargin(true);
+ Window window = new Window("Window", layout);
+ layout.setSizeUndefined();
window.center();
- window.addComponent(createTextField());
+ layout.addComponent(createTextField());
addWindow(window);
addComponent(createTextField());
});
centered.setSizeUndefined();
- centered.getContent().setSizeUndefined();
+ layout.setSizeUndefined();
centered.center();
Label l = new Label("This window is centered");
}
});
- centered.addComponent(l);
- centered.addComponent(b);
+ layout.addComponent(l);
+ layout.addComponent(b);
getMainWindow().addWindow(centered);
log = new Log(5);
import com.vaadin.ui.Button;
import com.vaadin.ui.CheckBox;
import com.vaadin.ui.Label;
-import com.vaadin.ui.Layout;
+import com.vaadin.ui.VerticalLayout;
import com.vaadin.ui.Window;
public class WindowResizeListener extends TestBase {
Label sizeLabel = new Label();
public ResizeListenerWindow() {
- super("Subwindow");
+ super("Subwindow", new VerticalLayout());
setWidth("400px");
- Layout hl = (Layout) getContent();
+ VerticalLayout hl = (VerticalLayout) getContent();
+ hl.setMargin(true);
hl.addComponent(new Label("Current size: "));
hl.addComponent(sizeLabel);
getMainWindow().addComponent(horizontalLayout);
final Component y9 = l;
+ VerticalLayout layout = new VerticalLayout();
+ layout.setMargin(true);
final Window window = new Window();
window.setHeight("500px");
window.setWidth("500px");
window.setPositionX(200);
window.setPositionY(200);
- window.addComponent(new Button("Scroll mainwin to X9",
+ layout.addComponent(new Button("Scroll mainwin to X9",
new ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
}
}));
- window.addComponent(new Button("Scroll mainwin to Y9",
+ layout.addComponent(new Button("Scroll mainwin to Y9",
new ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
panel.setScrollLeft(50);
panel.setScrollTop(50);
panelLayout.setSizeUndefined();
- window.addComponent(l("Spacer", 500, 500));
+ layout.addComponent(l("Spacer", 500, 500));
l2 = null;
for (int i = 0; i < 10; i++) {
}
}), 0);
- window.addComponent(panel);
+ layout.addComponent(panel);
getMainWindow().addWindow(window);
}
import com.vaadin.ui.Tree;
import com.vaadin.ui.Tree.TreeDragMode;
import com.vaadin.ui.Tree.TreeTargetDetails;
+import com.vaadin.ui.VerticalLayout;
import com.vaadin.ui.Window;
public class DDTest6 extends TestBase {
// ATM supports only images.
if (file.getType().equals("image/png")) {
Embedded embedded = new Embedded(file.getName(), file.getResource());
- Window w = new Window(file.getName());
- w.addComponent(embedded);
- w.getContent().setSizeUndefined();
+ VerticalLayout layout = new VerticalLayout();
+ layout.setMargin(true);
+ Window w = new Window(file.getName(), layout);
+ layout.addComponent(embedded);
+ layout.setSizeUndefined();
getMainWindow().addWindow(w);
} else if (file.getType().equals("text/csv")) {
showSpreadsheet(file);
String[] split = rows[i].split(",");
table.addItem(split, "" + i);
}
- Window w = new Window(file.getName());
- w.getContent().setSizeUndefined();
+ VerticalLayout layout = new VerticalLayout();
+ layout.setMargin(true);
+ Window w = new Window(file.getName(), layout);
+ layout.setSizeUndefined();
table.setEditable(true);
- w.addComponent(table);
+ layout.addComponent(table);
getMainWindow().addWindow(w);
}
final CssLayout l = new CssLayout();
l.setCaption("Windows");
- final Window w = new Window("Normal window");
+ VerticalLayout layout = new VerticalLayout();
+ layout.setMargin(true);
+ final Window w = new Window("Normal window", layout);
w.setWidth("280px");
w.setHeight("180px");
w.setPositionX(40);
w.setPositionY(160);
- final Window w2 = new Window("Window, no resize");
+ VerticalLayout layout2 = new VerticalLayout();
+ layout2.setMargin(true);
+ final Window w2 = new Window("Window, no resize", layout2);
w2.setResizable(false);
w2.setWidth("280px");
w2.setHeight("180px");
w2.setPositionX(350);
w2.setPositionY(160);
- w2.addComponent(new Label("<code>Window.setResizable(false)</code>",
- ContentMode.HTML));
+ layout2.addComponent(new Label(
+ "<code>Window.setResizable(false)</code>", ContentMode.HTML));
tabs.addListener(new TabSheet.SelectedTabChangeListener() {
@Override
import com.vaadin.ui.Layout;
import com.vaadin.ui.NativeSelect;
import com.vaadin.ui.TextArea;
+import com.vaadin.ui.VerticalLayout;
import com.vaadin.ui.Window;
public class TestAbsoluteLayout extends TestBase {
componentChooser.addListener(new Button.ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
- final Window chooser = new Window("Choose component");
- chooser.getContent().setSizeUndefined();
+ VerticalLayout layout = new VerticalLayout();
+ layout.setMargin(true);
+ final Window chooser = new Window("Choose component",
+ layout);
+ layout.setSizeUndefined();
chooser.setModal(true);
NativeSelect select = new NativeSelect(
});
- chooser.addComponent(select);
+ layout.addComponent(select);
getMainWindow().addWindow(chooser);
addComp.addListener(new Button.ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
+ VerticalLayout layout = new VerticalLayout();
+ layout.setMargin(true);
final Window chooser = new Window(
- "Choose component type to add");
- chooser.getContent().setSizeUndefined();
+ "Choose component type to add", layout);
+ layout.setSizeUndefined();
chooser.setModal(true);
NativeSelect select = new NativeSelect(
});
- chooser.addComponent(select);
+ layout.addComponent(select);
getMainWindow().addWindow(chooser);
import com.vaadin.ui.Label;
import com.vaadin.ui.LegacyWindow;
import com.vaadin.ui.Notification;
+import com.vaadin.ui.VerticalLayout;
import com.vaadin.ui.Window;
public class Ticket1465ModalNotification extends LegacyApplication {
"ButtonPanel containing a table test");
setMainWindow(mainWin);
- final Window modal = new Window("Modal window");
+ VerticalLayout layout = new VerticalLayout();
+ layout.setMargin(true);
+ final Window modal = new Window("Modal window", layout);
modal.setModal(true);
Button b = new Button("click to show notification",
}
});
- modal.addComponent(b);
+ layout.addComponent(b);
b = new Button("click to warning notification",
new Button.ClickListener() {
Notification.TYPE_WARNING_MESSAGE);
}
});
- modal.addComponent(b);
+ layout.addComponent(b);
b = new Button("click to Humanized notification",
new Button.ClickListener() {
Notification.TYPE_HUMANIZED_MESSAGE);
}
});
- modal.addComponent(b);
+ layout.addComponent(b);
b = new Button("click to test modality!", new Button.ClickListener() {
}
});
- modal.addComponent(b);
+ layout.addComponent(b);
mainWin.addWindow(modal);
Window w = new Window("Status of the fields");
w.setModal(true);
w.setHeight("80%");
- w.addComponent(new Label(msg.toString(), ContentMode.HTML));
+ w.setContent(new Label(msg.toString(), ContentMode.HTML));
main.addWindow(w);
}
});
}
Window w = new Window("Status of the fields");
w.setModal(true);
- w.addComponent(new Label(msg.toString(), ContentMode.HTML));
+ w.setContent(new Label(msg.toString(), ContentMode.HTML));
main.addWindow(w);
}
});
}
Window w = new Window("Status of the fields");
w.setModal(true);
- w.addComponent(new Label(msg.toString(), ContentMode.HTML));
+ w.setContent(new Label(msg.toString(), ContentMode.HTML));
main.addWindow(w);
}
});
Button done = new Button("Done");
PropertyEditor(ItemClickEvent event) {
+ VerticalLayout layout = new VerticalLayout();
+ layout.setMargin(true);
+ setContent(layout);
c = (Container) event.getSource();
propertyid = event.getPropertyId();
editor.setPropertyDataSource(c.getContainerProperty(itemid,
propertyid));
- addComponent(editor);
- addComponent(done);
+ layout.addComponent(editor);
+ layout.addComponent(done);
setWidth(W + "px");
setHeight(H + "px");
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.Button.ClickListener;
-import com.vaadin.ui.ComponentContainer;
import com.vaadin.ui.GridLayout;
import com.vaadin.ui.Label;
import com.vaadin.ui.Layout;
w.setContent(new GridLayout(2, 2));
setMainWindow(w);
- Panel p = new Panel();
+ VerticalLayout layout = new VerticalLayout();
+ Panel p = new Panel(layout);
p.setCaption("ExpandLayout");
p.setWidth("500px");
p.setHeight("500px");
- p.setContent(new VerticalLayout());
- p.getContent().setSizeFull();
+ layout.setSizeFull();
w.addComponent(p);
tf1.setSizeFull();
tf1.setValue(contents);
tf1.setCaption("TextField caption");
- ((ComponentContainer) p.getContent()).addComponent(tf1);
+ layout.addComponent(tf1);
/*
*
* OrderedLayout
*/
- Panel p2 = new Panel();
+ VerticalLayout layout2 = new VerticalLayout();
+ Panel p2 = new Panel(layout2);
p2.setCaption("OrderedLayout");
p2.setWidth("500px");
p2.setHeight("500px");
- p2.setContent(new VerticalLayout());
- p2.getContent().setSizeFull();
+ layout2.setSizeFull();
w.addComponent(p2);
tf2.setSizeFull();
tf2.setValue(contents);
tf2.setCaption("TextField caption");
- ((ComponentContainer) p2.getContent()).addComponent(tf2);
+ layout2.addComponent(tf2);
/*
*
// l1.setVisible(false);
// ts.setSelectedTab(l3);
- w.addComponent(ts);
+ w.setContent(ts);
return w;
}
import com.vaadin.ui.HorizontalLayout;
import com.vaadin.ui.HorizontalSplitPanel;
import com.vaadin.ui.Label;
-import com.vaadin.ui.Layout;
import com.vaadin.ui.LegacyWindow;
import com.vaadin.ui.Panel;
import com.vaadin.ui.RichTextArea;
textArea.setSizeFull();
}
if (c == Panel.class) {
- Layout layout = (Layout) ((Panel) cc).getContent();
+ VerticalLayout layout = new VerticalLayout();
+ layout.setMargin(true);
+ ((Panel) cc).setContent(layout);
containerToComponent.put(cc, layout);
layout.setVisible(false);
textArea.setVisible(true);
import com.vaadin.server.LegacyApplication;
import com.vaadin.ui.LegacyWindow;
import com.vaadin.ui.RichTextArea;
+import com.vaadin.ui.VerticalLayout;
import com.vaadin.ui.Window;
public class Ticket2323 extends LegacyApplication {
LegacyWindow w = new LegacyWindow(getClass().getSimpleName());
setMainWindow(w);
- Window subWindow = new Window("");
+ VerticalLayout layout = new VerticalLayout();
+ layout.setMargin(true);
+ Window subWindow = new Window("", layout);
subWindow.setSizeUndefined();
subWindow.getContent().setSizeUndefined();
subWindow.center();
- subWindow.addComponent(new RichTextArea());
+ subWindow.setContent(new RichTextArea());
w.addWindow(subWindow);
}