package com.vaadin.ui;
-import java.util.Collections;
-import java.util.Iterator;
import java.util.Map;
import com.vaadin.event.Action;
* @since 3.0
*/
@SuppressWarnings("serial")
-public class Panel extends AbstractComponentContainer implements Scrollable,
- ComponentContainer.ComponentAttachListener,
- ComponentContainer.ComponentDetachListener, Action.Notifier, Focusable,
- LegacyComponent {
-
- /**
- * Content of the panel.
- */
- private ComponentContainer content;
+public class Panel extends AbstractSingleComponentContainer implements
+ Scrollable, Action.Notifier, Focusable, LegacyComponent {
/**
* Keeps track of the Actions added to this component, and manages the
super.setCaption(caption);
}
- /**
- * Returns the content of the Panel.
- *
- * @return
- */
- public ComponentContainer getContent() {
- return content;
- }
-
- /**
- *
- * Set the content of the Panel. If null is given as the new content then a
- * layout is automatically created and set as the content.
- *
- * @param content
- * The new content
- */
- public void setContent(ComponentContainer newContent) {
-
- // If the content is null we create the default content
- if (newContent == null) {
- newContent = createDefaultContent();
- }
-
- // if (newContent == null) {
- // throw new IllegalArgumentException("Content cannot be null");
- // }
-
- if (newContent == content) {
- // don't set the same content twice
- return;
- }
-
- // detach old content if present
- if (content != null) {
- content.setParent(null);
- content.removeListener((ComponentContainer.ComponentAttachListener) this);
- content.removeListener((ComponentContainer.ComponentDetachListener) this);
- }
-
- // Sets the panel to be parent for the content
- newContent.setParent(this);
-
- // Sets the new content
- content = newContent;
-
- // Adds the event listeners for new content
- newContent
- .addListener((ComponentContainer.ComponentAttachListener) this);
- newContent
- .addListener((ComponentContainer.ComponentDetachListener) this);
-
- content = newContent;
- markAsDirty();
- }
-
- /**
- * Create a ComponentContainer which is added by default to the Panel if
- * user does not specify any content.
- *
- * @return
- */
- private ComponentContainer createDefaultContent() {
- VerticalLayout layout = new VerticalLayout();
- // Force margins by default
- layout.setMargin(true);
- return layout;
- }
-
/*
* (non-Javadoc)
*
}
}
- /**
- * Adds the component into this container.
- *
- * @param c
- * the component to be added.
- * @see com.vaadin.ui.AbstractComponentContainer#addComponent(com.vaadin.ui.Component)
- */
- @Override
- public void addComponent(Component c) {
- content.addComponent(c);
- // No repaint request is made as we except the underlying container to
- // request repaints
- }
-
- /**
- * Removes the component from this container.
- *
- * @param c
- * The component to be removed.
- * @see com.vaadin.ui.AbstractComponentContainer#removeComponent(com.vaadin.ui.Component)
- */
- @Override
- public void removeComponent(Component c) {
- content.removeComponent(c);
- // No repaint request is made as we except the underlying container to
- // request repaints
- }
-
- /**
- * Gets the component container iterator for going through all the
- * components in the container.
- *
- * @return the Iterator of the components inside the container.
- * @see com.vaadin.ui.ComponentContainer#getComponentIterator()
- */
- @Override
- public Iterator<Component> iterator() {
- return Collections.singleton((Component) content).iterator();
- }
-
/**
* Called when one or more variables handled by the implementing class are
* changed.
* @see com.vaadin.server.VariableOwner#changeVariables(Object, Map)
*/
@Override
- @SuppressWarnings("unchecked")
public void changeVariables(Object source, Map<String, Object> variables) {
// Get new size
final Integer newWidth = (Integer) variables.get("width");
getState().scrollTop = scrollTop;
}
- /* Documented in superclass */
- @Override
- public void replaceComponent(Component oldComponent, Component newComponent) {
-
- content.replaceComponent(oldComponent, newComponent);
- }
-
- /**
- * A new component is attached to container.
- *
- * @see com.vaadin.ui.ComponentContainer.ComponentAttachListener#componentAttachedToContainer(com.vaadin.ui.ComponentContainer.ComponentAttachEvent)
- */
- @Override
- public void componentAttachedToContainer(ComponentAttachEvent event) {
- if (event.getContainer() == content) {
- fireComponentAttachEvent(event.getAttachedComponent());
- }
- }
-
- /**
- * A component has been detached from container.
- *
- * @see com.vaadin.ui.ComponentContainer.ComponentDetachListener#componentDetachedFromContainer(com.vaadin.ui.ComponentContainer.ComponentDetachEvent)
- */
- @Override
- public void componentDetachedFromContainer(ComponentDetachEvent event) {
- if (event.getContainer() == content) {
- fireComponentDetachEvent(event.getDetachedComponent());
- }
- }
-
- /**
- * Removes all components from this container.
- *
- * @see com.vaadin.ui.ComponentContainer#removeAllComponents()
- */
- @Override
- public void removeAllComponents() {
- content.removeAllComponents();
- }
-
/*
* ACTIONS
*/
super.focus();
}
- /*
- * (non-Javadoc)
- *
- * @see com.vaadin.ui.ComponentContainer#getComponentCount()
- */
- @Override
- public int getComponentCount() {
- // This is so wrong... (#2924)
- return content.getComponentCount();
- }
-
@Override
protected PanelState getState() {
return (PanelState) super.getState();
setSizeUndefined();
}
- /*
- * (non-Javadoc)
+ /**
+ * 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.
*
- * @see com.vaadin.ui.Panel#addComponent(com.vaadin.ui.Component)
+ * @param c
+ * component to add
+ *
+ * @deprecated use Window.setContent(Component) instead
*/
-
- @Override
+ @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.");
}
- super.addComponent(c);
+
+ 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");
+ }
}
/* ********************************************************************* */
import com.vaadin.ui.PasswordField;
import com.vaadin.ui.TextField;
import com.vaadin.ui.Tree;
+import com.vaadin.ui.VerticalLayout;
/**
* This example demonstrates custom layout. All components created here are
* @since 4.0.0
*
*/
-public class CustomLayoutDemo extends com.vaadin.server.LegacyApplication implements
- Listener {
+public class CustomLayoutDemo extends com.vaadin.server.LegacyApplication
+ implements Listener {
private CustomLayout mainLayout = null;
// Create custom layout, themes/example/layout/mainLayout.html
mainLayout = new CustomLayout("mainLayout");
// wrap custom layout inside a panel
+ VerticalLayout customLayoutPanelLayout = new VerticalLayout();
+ customLayoutPanelLayout.setMargin(true);
final Panel customLayoutPanel = new Panel(
- "Panel containing custom layout (mainLayout.html)");
- customLayoutPanel.addComponent(mainLayout);
+ "Panel containing custom layout (mainLayout.html)",
+ customLayoutPanelLayout);
+ customLayoutPanelLayout.addComponent(mainLayout);
// Login components
mainLayout.addComponent(username, "loginUser");
*
*/
public void setBody(String customLayout) {
+ VerticalLayout bodyLayout = new VerticalLayout();
+ bodyLayout.setMargin(true);
+ bodyLayout.addComponent(new CustomLayout(customLayout));
+ bodyPanel.setContent(bodyLayout);
bodyPanel.setCaption(customLayout + ".html");
- bodyPanel.removeAllComponents();
- bodyPanel.addComponent(new CustomLayout(customLayout));
}
/**
}
private Component getExampleComponent(String caption) {
- final Panel panel = new Panel();
+ VerticalLayout layout = new VerticalLayout();
+ layout.setMargin(true);
+ final Panel panel = new Panel(layout);
panel.setCaption("Panel component " + caption);
- panel.addComponent(new Label(
+ layout.addComponent(new Label(
"Panel is a container for other components, by default it draws a frame around it's "
+ "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, "
import com.vaadin.server.VaadinResponse;
import com.vaadin.server.VaadinServiceSession;
import com.vaadin.ui.Label;
-import com.vaadin.ui.Layout.MarginHandler;
import com.vaadin.ui.LegacyWindow;
import com.vaadin.ui.Link;
import com.vaadin.ui.Panel;
}
// URI
- final Panel panel1 = new Panel("URI Handler");
+ final VerticalLayout panel1Layout = new VerticalLayout();
+ panel1Layout.setMargin(true);
+ final Panel panel1 = new Panel("URI Handler", panel1Layout);
context.setCaption("Last URI handler context");
- panel1.addComponent(context);
+ panel1Layout.addComponent(context);
relative.setCaption("Last relative URI");
- panel1.addComponent(relative);
+ panel1Layout.addComponent(relative);
layout.addComponent(panel1);
params.addContainerProperty("Key", String.class, "");
params.addContainerProperty("Value", String.class, "");
- final Panel panel2 = new Panel("Parameter Handler");
+ final VerticalLayout panel2Layout = new VerticalLayout();
+ panel2Layout.setMargin(true);
+ final Panel panel2 = new Panel("Parameter Handler", panel2Layout);
params.setSizeFull();
- panel2.setContent(new VerticalLayout());
- ((MarginHandler) panel2.getContent()).setMargin(true);
params.setColumnHeaderMode(Table.COLUMN_HEADER_MODE_ID);
- panel2.addComponent(params);
+ panel2Layout.addComponent(params);
layout.addComponent(panel2);
// expand parameter panel and its table
setMainWindow(mainWindow);
// Create horizontal ordered layout
+ VerticalLayout panelALayout = new VerticalLayout();
+ panelALayout.setMargin(true);
final Panel panelA = new Panel(
- "Panel containing horizontal ordered layout");
+ "Panel containing horizontal ordered layout", panelALayout);
HorizontalLayout layoutA = new HorizontalLayout();
// Add 4 random components
fillLayout(layoutA, componentCountA);
// Add layout to panel
- panelA.addComponent(layoutA);
+ panelALayout.addComponent(layoutA);
// Create vertical ordered layout
+ VerticalLayout panelBLayout = new VerticalLayout();
+ panelBLayout.setMargin(true);
final Panel panelB = new Panel(
- "Panel containing vertical ordered layout");
+ "Panel containing vertical ordered layout", panelBLayout);
VerticalLayout layoutB = new VerticalLayout();
// Add 4 random components
fillLayout(layoutB, componentCountB);
// Add layout to panel
- panelB.addComponent(layoutB);
+ panelBLayout.addComponent(layoutB);
// Create grid layout
final int gridSize = (int) java.lang.Math.sqrt(componentCountC);
+ VerticalLayout panelGLayout = new VerticalLayout();
+ panelGLayout.setMargin(true);
final Panel panelG = new Panel("Panel containing grid layout ("
- + gridSize + " x " + gridSize + ")");
+ + gridSize + " x " + gridSize + ")", panelGLayout);
GridLayout layoutG = new GridLayout(gridSize, gridSize);
// Add 12 random components
fillLayout(layoutG, componentCountC);
// Add layout to panel
- panelG.addComponent(layoutG);
+ panelGLayout.addComponent(layoutG);
// Create TabSheet
final TabSheet tabsheet = new TabSheet();
tabsheet.addTab(layoutG, "Grid layout (4 x 2)", null);
// Create custom layout
- final Panel panelC = new Panel("Custom layout with style exampleStyle");
+ VerticalLayout panelCLayout = new VerticalLayout();
+ panelCLayout.setMargin(true);
+ final Panel panelC = new Panel("Custom layout with style exampleStyle",
+ panelCLayout);
final CustomLayout layoutC = new CustomLayout("exampleStyle");
// Add 4 random components
fillLayout(layoutC, componentCountD);
// Add layout to panel
- panelC.addComponent(layoutC);
+ panelCLayout.addComponent(layoutC);
// Add demo panels (layouts) to main window
mainWindow.addComponent(panelA);
break;
case 5:
// Link
- result = new Panel();
+ VerticalLayout panelLayout = new VerticalLayout();
+ panelLayout.setMargin(true);
+ result = new Panel(panelLayout);
result.setCaption("Panel component " + caption);
- ((Panel) result)
+ panelLayout
.addComponent(new Label(
"Panel is a container for other components, by default it draws a frame around it's "
+ "extremities and may have a caption to clarify the nature of the contained components' purpose."
Tree menu;
- Panel bodyLayout = new Panel();
+ VerticalLayout bodyLayout = new VerticalLayout();
// TODO this could probably be a simple Set
HashMap<Class<?>, String> itemCaptions = new HashMap<Class<?>, String>();
mainLayout.addComponent(lo);
- bodyLayout.addStyleName("light");
- bodyLayout.setSizeFull();
- bodyLayout.setContent(new VerticalLayout());
+ Panel bodyPanel = new Panel(bodyLayout);
+ bodyPanel.addStyleName("light");
+ bodyPanel.setSizeFull();
- mainLayout.addComponent(bodyLayout);
+ mainLayout.addComponent(bodyPanel);
mainLayout.setSplitPosition(30);
test(main);
populateLayout(main);
- final Panel panel = new Panel("Panel");
+ VerticalLayout panelLayout = new VerticalLayout();
+ panelLayout.setMargin(true);
+ final Panel panel = new Panel("Panel", panelLayout);
test(panel);
- populateLayout((Layout) panel.getContent());
+ populateLayout(panelLayout);
final TabSheet tabsheet = new TabSheet();
test(tabsheet);
final Embedded emb = new Embedded("Embedded " + count++);
test(layout, emb);
- final Panel panel = new Panel("Panel " + count++);
+ VerticalLayout panelLayout = new VerticalLayout();
+ panelLayout.setMargin(true);
+ final Panel panel = new Panel("Panel " + count++, panelLayout);
test(layout, panel);
final Label label = new Label("Label " + count++);
*/
public class TestComponentAddAndRecursion extends CustomComponent {
Panel p;
+ VerticalLayout pl;
Panel p2;
+ VerticalLayout p2l;
Label l;
Label l2;
Panel p3;
+ VerticalLayout p3l;
public TestComponentAddAndRecursion() {
l = new Label("A");
l2 = new Label("B");
- p = new Panel("p");
- p.addComponent(l);
- p.addComponent(l2);
+ pl = new VerticalLayout();
+ pl.setMargin(true);
+ p = new Panel("p", pl);
+ pl.addComponent(l);
+ pl.addComponent(l2);
main.addComponent(p);
- p2 = new Panel("p2");
- p2.addComponent(l);
+ p2l = new VerticalLayout();
+ p2l.setMargin(true);
+ p2 = new Panel("p2", p2l);
+ p2l.addComponent(l);
main.addComponent(p2);
- p3 = new Panel("p3");
- p2.addComponent(p3);
+ p3l = new VerticalLayout();
+ p3l.setMargin(true);
+ p3 = new Panel("p3", p3l);
+ p2l.addComponent(p3);
Button b = new Button("use gridlayout", new Button.ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
- p2.addComponent(l2);
+ p2l.addComponent(l2);
}
});
@Override
public void buttonClick(ClickEvent event) {
- p3.addComponent(p);
+ p3l.addComponent(p);
}
});
@Override
public void buttonClick(ClickEvent event) {
Label l = new Label("both");
- p.addComponent(l);
- p2.addComponent(l);
+ pl.addComponent(l);
+ p2l.addComponent(l);
}
});
@Override
public void buttonClick(ClickEvent event) {
try {
- p3.addComponent(p2);
+ p3l.addComponent(p2);
new Notification("ERROR", "This should have failed",
Notification.TYPE_ERROR_MESSAGE).show(Page
.getCurrent());
@Override
public void buttonClick(ClickEvent event) {
- Panel p = new Panel("dynamic");
- p.addComponent(p2);
+ VerticalLayout layout = new VerticalLayout();
+ Panel p = new Panel("dynamic", layout);
+ layout.addComponent(p2);
try {
- p3.addComponent(p);
+ p3l.addComponent(p);
new Notification("ERROR", "This should have failed",
Notification.TYPE_ERROR_MESSAGE).show(Page
.getCurrent());
});
buttons.addComponent(b);
- Panel p = new Panel("Tree");
+ VerticalLayout pl = createPanelLayout();
+ Panel p = new Panel("Tree", pl);
p.setStyleName(Reindeer.PANEL_LIGHT);
h.addComponent(p);
Tree tree = new Tree("ITEM_CAPTION_MODE_PROPERTY");
tree.setContainerDataSource(ordered);
tree.setItemCaptionPropertyId("Asd");
tree.setItemCaptionMode(Tree.ITEM_CAPTION_MODE_PROPERTY);
- p.addComponent(tree);
+ pl.addComponent(tree);
tree = new Tree("ITEM_CAPTION_MODE_ITEM");
// nonhierarchical container will get wrapped
tree.setContainerDataSource(ordered);
tree.setItemCaptionMode(Tree.ITEM_CAPTION_MODE_ITEM);
- p.addComponent(tree);
+ pl.addComponent(tree);
- p = new Panel("ComboBox");
+ pl = createPanelLayout();
+ p = new Panel("ComboBox", pl);
p.setStyleName(Reindeer.PANEL_LIGHT);
h.addComponent(p);
ComboBox c = new ComboBox("ITEM_CAPTION_MODE_PROPERTY");
c.setContainerDataSource(cont);
c.setItemCaptionPropertyId("Asd");
c.setItemCaptionMode(ComboBox.ITEM_CAPTION_MODE_PROPERTY);
- p.addComponent(c);
+ pl.addComponent(c);
c = new ComboBox("ITEM_CAPTION_MODE_ITEM");
c.setImmediate(true);
c.setContainerDataSource(cont);
c.setItemCaptionMode(ComboBox.ITEM_CAPTION_MODE_ITEM);
- p.addComponent(c);
+ pl.addComponent(c);
- p = new Panel("ListBox");
+ pl = createPanelLayout();
+ p = new Panel("ListBox", pl);
p.setStyleName(Reindeer.PANEL_LIGHT);
h.addComponent(p);
ListSelect l = new ListSelect("ITEM_CAPTION_MODE_PROPERTY");
l.setContainerDataSource(cont);
l.setItemCaptionPropertyId("Asd");
l.setItemCaptionMode(ComboBox.ITEM_CAPTION_MODE_PROPERTY);
- p.addComponent(l);
+ pl.addComponent(l);
l = new ListSelect("ITEM_CAPTION_MODE_ITEM");
l.setContainerDataSource(cont);
l.setItemCaptionMode(ComboBox.ITEM_CAPTION_MODE_ITEM);
- p.addComponent(l);
+ pl.addComponent(l);
+ }
+
+ private VerticalLayout createPanelLayout() {
+ VerticalLayout pl = new VerticalLayout();
+ pl.setMargin(true);
+ return pl;
}
}
final HorizontalSplitPanel sp2 = new HorizontalSplitPanel();
sp2.setSplitPosition(255, Sizeable.UNITS_PIXELS);
- final Panel p = new Panel("Accordion Panel");
+ VerticalLayout pl = new VerticalLayout();
+ pl.setMargin(true);
+ final Panel p = new Panel("Accordion Panel", pl);
p.setSizeFull();
tab = new TabSheet();
tab.setSizeFull();
- final Panel report = new Panel("Monthly Program Runs",
- new VerticalLayout());
- final VerticalLayout controls = new VerticalLayout();
+ VerticalLayout reportLayout = new VerticalLayout();
+ final Panel report = new Panel("Monthly Program Runs", reportLayout);
+ final VerticalLayout controls = reportLayout;
controls.setMargin(true);
controls.addComponent(new Label("Report tab"));
controls.addComponent(click);
controls.addComponent(click2);
- report.addComponent(controls);
+ reportLayout.addComponent(controls);
final DateField cal = new DateField();
cal.setResolution(DateField.RESOLUTION_DAY);
cal.setLocale(new Locale("en", "US"));
- report.addComponent(cal);
- ((VerticalLayout) report.getContent()).setExpandRatio(controls, 1);
+ reportLayout.addComponent(cal);
+ reportLayout.setExpandRatio(controls, 1);
report.addStyleName(Reindeer.PANEL_LIGHT);
report.setHeight(100, Sizeable.UNITS_PERCENTAGE);
}
// Init filtering view
- final Panel filterPanel = new Panel("Filter", new HorizontalLayout());
+ final HorizontalLayout filterLayout = new HorizontalLayout();
+ final Panel filterPanel = new Panel("Filter", filterLayout);
filterPanel.setWidth(100, Panel.UNITS_PERCENTAGE);
lo.addComponent(filterPanel);
- filterPanel.addComponent(fooFilter);
- filterPanel.addComponent(barFilter);
- filterPanel.addComponent(filterButton);
+ filterLayout.addComponent(fooFilter);
+ filterLayout.addComponent(barFilter);
+ filterLayout.addComponent(filterButton);
fooFilter
.setDescription("Filters foo column in case-sensitive contains manner.");
barFilter
.setDescription("Filters bar column in case-insensitive prefix manner.");
- filterPanel.addComponent(count);
+ filterLayout.addComponent(count);
// Table
lo.addComponent(t);
package com.vaadin.tests;
-import com.vaadin.event.Action;
-import com.vaadin.event.Action.Handler;
import com.vaadin.ui.AbstractSelect;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
/**
* @author Vaadin Ltd.
*/
-public class TestForPreconfiguredComponents extends CustomComponent implements
- Handler {
+public class TestForPreconfiguredComponents extends CustomComponent {
private static final String[] firstnames = new String[] { "John", "Mary",
"Joe", "Sarah", "Jeff", "Jane", "Peter", "Marc", "Josie", "Linus" };
private final VerticalLayout main = new VerticalLayout();
- private final Action[] actions = new Action[] { new Action("edit"),
- new Action("delete") };
-
- private Panel al;
-
- private Tree contextTree;
-
public TestForPreconfiguredComponents() {
setCompositionRoot(main);
}
public Panel createTestBench(Component t) {
- final Panel ol = new Panel();
- ol.setContent(new HorizontalLayout());
+ final HorizontalLayout ol = new HorizontalLayout();
ol.addComponent(t);
final HorizontalLayout ol2 = new HorizontalLayout();
- final Panel status = new Panel("Events");
+ final VerticalLayout statusLayout = new VerticalLayout();
+ final Panel status = new Panel("Events", statusLayout);
final Button clear = new Button("clear event log");
- clear.addListener(new ClickListener() {
+ clear.addClickListener(new ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
- status.removeAllComponents();
- status.addComponent(ol2);
+ statusLayout.removeAllComponents();
+ statusLayout.addComponent(ol2);
}
});
ol2.addComponent(clear);
final Button commit = new Button("commit changes");
ol2.addComponent(commit);
- status.addComponent(ol2);
+ statusLayout.addComponent(ol2);
status.setHeight("300px");
status.setWidth("400px");
t.addListener(new Listener() {
@Override
public void componentEvent(Event event) {
- status.addComponent(new Label(event.getClass().getName()));
+ statusLayout
+ .addComponent(new Label(event.getClass().getName()));
// TODO should not use Field.toString()
- status.addComponent(new Label("selected: "
+ statusLayout.addComponent(new Label("selected: "
+ event.getSource().toString()));
}
});
- return ol;
- }
-
- @Override
- public Action[] getActions(Object target, Object sender) {
- return actions;
- }
-
- @Override
- public void handleAction(Action action, Object sender, Object target) {
- if (action == actions[1]) {
- al.addComponent(new Label("Delete selected on " + target));
- contextTree.removeItem(target);
-
- } else {
- al.addComponent(new Label("Edit selected on " + target));
- }
+ return new Panel(ol);
}
}
TmpFileBuffer buffer = new TmpFileBuffer();
- Panel status = new Panel("Uploaded file:");
+ VerticalLayout statusLayout = new VerticalLayout();
+ Panel status = new Panel("Uploaded file:", statusLayout);
private final Upload up;
memoryStatus = new Label();
main.addComponent(memoryStatus);
+ statusLayout.setMargin(true);
status.setVisible(false);
main.addComponent(status);
@Override
public void uploadFinished(FinishedEvent event) {
- status.removeAllComponents();
+ statusLayout.removeAllComponents();
final InputStream stream = buffer.getStream();
if (stream == null) {
- status.addComponent(new Label(
+ statusLayout.addComponent(new Label(
"Upload finished, but output buffer is null!!"));
} else {
- status.addComponent(new Label(
- "<b>Name:</b> " + event.getFilename(), ContentMode.HTML));
- status.addComponent(new Label("<b>Mimetype:</b> "
+ statusLayout.addComponent(new Label("<b>Name:</b> "
+ + event.getFilename(), ContentMode.HTML));
+ statusLayout.addComponent(new Label("<b>Mimetype:</b> "
+ event.getMIMEType(), ContentMode.HTML));
- status.addComponent(new Label("<b>Size:</b> " + event.getLength()
- + " bytes.", ContentMode.HTML));
+ statusLayout.addComponent(new Label("<b>Size:</b> "
+ + event.getLength() + " bytes.", ContentMode.HTML));
- status.addComponent(new Link("Download " + buffer.getFileName(),
- new StreamResource(buffer, buffer.getFileName())));
+ statusLayout.addComponent(new Link("Download "
+ + buffer.getFileName(), new StreamResource(buffer, buffer
+ .getFileName())));
status.setVisible(true);
}
private final Action[] actions = new Action[] { new Action("edit"),
new Action("delete") };
- private Panel al;
+ private VerticalLayout al;
private Tree contextTree;
t.setImmediate(true);
t.addActionHandler(this);
final AbstractOrderedLayout ol = (AbstractOrderedLayout) createTestBench(t);
- al = new Panel("action log");
- ol.addComponent(al);
+ al = new VerticalLayout();
+ al.setMargin(true);
+ ol.addComponent(new Panel("action log", al));
main.addComponent(ol);
contextTree = t;
ol.addComponent(t);
- final Panel status = new Panel("Events");
+ final VerticalLayout statusLayout = new VerticalLayout();
+ statusLayout.setMargin(true);
+ final Panel status = new Panel("Events", statusLayout);
final Button clear = new Button("c");
- clear.addListener(new ClickListener() {
+ clear.addClickListener(new ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
- status.removeAllComponents();
- status.addComponent(clear);
+ statusLayout.removeAllComponents();
+ statusLayout.addComponent(clear);
}
});
- status.addComponent(clear);
+ statusLayout.addComponent(clear);
status.setHeight("300px");
status.setWidth("400px");
t.addListener(new Listener() {
@Override
public void componentEvent(Event event) {
- status.addComponent(new Label(event.getClass().getName()));
+ statusLayout
+ .addComponent(new Label(event.getClass().getName()));
// TODO should not use Field.toString()
- status.addComponent(new Label("selected: "
+ statusLayout.addComponent(new Label("selected: "
+ event.getSource().toString()));
}
});
Buffer buffer = new MemoryBuffer();
- Panel status = new Panel("Uploaded file:");
+ VerticalLayout statusLayout = new VerticalLayout();
+ Panel status = new Panel("Uploaded file:", statusLayout);
private final Upload up;
l.setValue("Finished with unknow event");
}
- status.removeAllComponents();
+ statusLayout.removeAllComponents();
final InputStream stream = buffer.getStream();
if (stream == null) {
- status.addComponent(new Label(
+ statusLayout.addComponent(new Label(
"Upload finished, but output buffer is null"));
} else {
- status.addComponent(new Label("<b>Name:</b> "
+ statusLayout.addComponent(new Label("<b>Name:</b> "
+ event.getFilename(), ContentMode.HTML));
- status.addComponent(new Label("<b>Mimetype:</b> "
+ statusLayout.addComponent(new Label("<b>Mimetype:</b> "
+ event.getMIMEType(), ContentMode.HTML));
- status.addComponent(new Label("<b>Size:</b> "
+ statusLayout.addComponent(new Label("<b>Size:</b> "
+ event.getLength() + " bytes.", ContentMode.HTML));
- status.addComponent(new Link("Download "
+ statusLayout.addComponent(new Link("Download "
+ buffer.getFileName(), new StreamResource(buffer,
buffer.getFileName())));
- status.setVisible(true);
+ statusLayout.setVisible(true);
}
setBuffer();
memoryStatus = new Label();
main.addComponent(memoryStatus);
+ statusLayout.setMargin(true);
status.setVisible(false);
main.addComponent(status);
import com.vaadin.ui.AbstractOrderedLayout;
import com.vaadin.ui.Component;
+import com.vaadin.ui.ComponentContainer;
import com.vaadin.ui.CustomComponent;
import com.vaadin.ui.DateField;
import com.vaadin.ui.Panel;
root.addComponent(getSelect());
root.addComponent(getDateField());
- final Panel p1 = getPanel();
+ final VerticalLayout p1Layout = createPanelLayout();
+ final Panel p1 = getPanel(p1Layout);
+ p1.setContent(p1Layout);
root.addComponent(p1);
- p1.addComponent(getSelect());
- p1.addComponent(getDateField());
- p1.addComponent(getSelect());
- p1.addComponent(getDateField());
+ p1Layout.addComponent(getSelect());
+ p1Layout.addComponent(getDateField());
+ p1Layout.addComponent(getSelect());
+ p1Layout.addComponent(getDateField());
final AbstractOrderedLayout l1 = getOrderedLayout();
- p1.addComponent(l1);
+ p1Layout.addComponent(l1);
l1.addComponent(getSelect());
l1.addComponent(getDateField());
l1.addComponent(getSelect());
l1.addComponent(getDateField());
- final Panel p2 = getPanel();
+ final VerticalLayout p2Layout = createPanelLayout();
+ final Panel p2 = getPanel(p2Layout);
l1.addComponent(p2);
- p2.addComponent(getSelect());
- p2.addComponent(getDateField());
- p2.addComponent(getSelect());
- p2.addComponent(getDateField());
-
+ p2Layout.addComponent(getSelect());
+ p2Layout.addComponent(getDateField());
+ p2Layout.addComponent(getSelect());
+ p2Layout.addComponent(getDateField());
}
VerticalLayout getOrderedLayout() {
return l;
}
- Panel getPanel() {
- final Panel panel = new Panel();
+ private VerticalLayout createPanelLayout() {
+ VerticalLayout layout = new VerticalLayout();
+ layout.setMargin(true);
+ return layout;
+ }
+
+ Panel getPanel(ComponentContainer content) {
+ final Panel panel = new Panel(content);
panel.setCaption(getCaption("panel"));
return panel;
}
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.Button.ClickListener;
+import com.vaadin.ui.Component;
import com.vaadin.ui.Label;
import com.vaadin.ui.LegacyWindow;
import com.vaadin.ui.Panel;
+import com.vaadin.ui.VerticalLayout;
-public class TestSetVisibleAndCaching extends com.vaadin.server.LegacyApplication {
+public class TestSetVisibleAndCaching extends
+ com.vaadin.server.LegacyApplication {
Panel panelA = new Panel("Panel A");
Panel panelB = new Panel("Panel B");
"TestSetVisibleAndCaching");
setMainWindow(mainWindow);
- panelA.addComponent(new Label(
- "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"));
- panelB.addComponent(new Label(
- "BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB"));
- panelC.addComponent(new Label(
- "CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC"));
+ panelA.setContent(wrapInPanelLayout(new Label(
+ "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA")));
+ panelB.setContent(wrapInPanelLayout(new Label(
+ "BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB")));
+ panelC.setContent(wrapInPanelLayout(new Label(
+ "CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC")));
mainWindow
.addComponent(new Label(
}
+ private VerticalLayout wrapInPanelLayout(Component component) {
+ VerticalLayout layout = new VerticalLayout();
+ layout.setMargin(true);
+ layout.addComponent(component);
+ return layout;
+ }
+
private void selectPanel(int selectedPanel) {
System.err.println("Selecting panel " + selectedPanel);
switch (selectedPanel) {
private ComboBox select;
private Button prev;
private Button next;
+ private VerticalLayout testPanelLayout;
private Panel testPanel;
@Override
public void valueChange(ValueChangeEvent event) {
Testable t = (Testable) select.getValue();
if (t != null) {
- testPanel.removeAllComponents();
+ testPanelLayout.removeAllComponents();
try {
Component c = t.getComponent();
if (c != null) {
- testPanel.addComponent(c);
+ testPanelLayout.addComponent(c);
}
} catch (InstantiationException e) {
// TODO Auto-generated catch block
}
});
- testPanel = new Panel();
+ testPanelLayout = new VerticalLayout();
+ testPanel = new Panel(testPanelLayout);
testPanel.setSizeFull();
- testPanel.setContent(new VerticalLayout());
testPanel.setStyleName("testable");
main.addComponent(testPanel);
main.setExpandRatio(testPanel, 1);
Component c = super.getComponent();
+ VerticalLayout pl = new VerticalLayout();
+ pl.setMargin(true);
Panel p = new Panel(
- "Wrapper panel (400px*400px)");
+ "Wrapper panel (400px*400px)", pl);
p.setContent(new VerticalLayout());
p.setWidth("400px");
p.setHeight("400px");
- p.addComponent(c);
+ pl.addComponent(c);
p.addStyleName("testablew");
p.addStyleName("testable");
return p;
import com.vaadin.ui.Panel;
import com.vaadin.ui.Tree;
import com.vaadin.ui.Tree.ExpandEvent;
+import com.vaadin.ui.VerticalLayout;
/**
* Browsable file explorer using Vaadin Tree component. Demonstrates: how to add
* @since 4.0.0
*
*/
-public class TreeFilesystem extends com.vaadin.server.LegacyApplication implements
- Tree.ExpandListener {
+public class TreeFilesystem extends com.vaadin.server.LegacyApplication
+ implements Tree.ExpandListener {
// Filesystem explorer panel and it's components
private final Panel explorerPanel = new Panel("Filesystem explorer");
main.addComponent(new Label("<h2>Tree demo</h2>", ContentMode.HTML));
// configure file structure panel
+ VerticalLayout explorerLayout = new VerticalLayout();
+ explorerLayout.setMargin(true);
+ explorerPanel.setContent(explorerLayout);
main.addComponent(explorerPanel);
- explorerPanel.addComponent(tree);
+ explorerLayout.addComponent(tree);
explorerPanel.setHeight("400px");
// "this" handles tree's expand event
* @since 4.0.0
*
*/
-public class TreeFilesystemContainer extends com.vaadin.server.LegacyApplication
- implements Listener {
+public class TreeFilesystemContainer extends
+ com.vaadin.server.LegacyApplication implements Listener {
// Filesystem explorer panel and it's components
private final Panel explorerPanel = new Panel("Filesystem explorer");
main.setExpandRatio(explorerPanel, 1);
// Explorer panel contains tree
- explorerPanel.addComponent(filesystem);
+ VerticalLayout explorerLayout = new VerticalLayout();
+ explorerLayout.setMargin(true);
+ explorerPanel.setContent(explorerLayout);
+ explorerLayout.addComponent(filesystem);
// Property panel contains label
- propertyPanel.addComponent(fileProperties);
+ VerticalLayout propertyLayout = new VerticalLayout();
+ propertyLayout.setMargin(true);
+ propertyPanel.setContent(propertyLayout);
+ propertyLayout.addComponent(fileProperties);
fileProperties.setCaption("No file selected.");
propertyPanel.setEnabled(false);
import com.vaadin.ui.CustomComponent;
import com.vaadin.ui.Panel;
import com.vaadin.ui.Select;
+import com.vaadin.ui.VerticalLayout;
public class UsingCustomNewItemHandlerInSelect extends CustomComponent {
public UsingCustomNewItemHandlerInSelect() {
- final Panel panel = new Panel("Select demo");
- panel.addComponent(select);
+ VerticalLayout pl = new VerticalLayout();
+ pl.setMargin(true);
+ final Panel panel = new Panel("Select demo", pl);
+ pl.addComponent(select);
select.setCaption("Select component");
select.setImmediate(true);
import com.vaadin.ui.LegacyWindow;
import com.vaadin.ui.Panel;
import com.vaadin.ui.Select;
+import com.vaadin.ui.VerticalLayout;
public class UsingObjectsInSelect extends com.vaadin.server.LegacyApplication
implements ValueChangeListener {
final LegacyWindow main = new LegacyWindow("Select demo");
setMainWindow(main);
- final Panel panel = new Panel("Select demo");
- panel.addComponent(select);
- final Panel panel2 = new Panel("Selection");
- panel2.addComponent(selectedTask);
+ VerticalLayout panelLayout = new VerticalLayout();
+ panelLayout.setMargin(true);
+ final Panel panel = new Panel("Select demo", panelLayout);
+ panelLayout.addComponent(select);
+ VerticalLayout panel2Layout = new VerticalLayout();
+ panel2Layout.setMargin(true);
+ final Panel panel2 = new Panel("Selection", panel2Layout);
+ panel2Layout.addComponent(selectedTask);
select.setCaption("Select component");
select.addListener(this);
public Layout buildLayout() {
VerticalLayout layout = new VerticalLayout();
- final Panel widePanel = new Panel("too big");
+ VerticalLayout panelLayout = new VerticalLayout();
+ panelLayout.setMargin(true);
+ final Panel widePanel = new Panel("too big", panelLayout);
widePanel.setSizeUndefined();
widePanel.setWidth("2000px");
widePanel.setHeight("200px");
}
});
- widePanel.addComponent(button);
+ panelLayout.addComponent(button);
layout.setSizeUndefined();
return layout;
}
Layout cssLayout = new CssLayout();
cssLayout.setCaption("Panel");
- final Panel p = new Panel();
+ final VerticalLayout pl = new VerticalLayout();
+ pl.setMargin(true);
+ final Panel p = new Panel(pl);
p.setHeight("400px");
Label l50 = null;
for (int i = 0; i < 100; i++) {
Label c = new Label("Label" + i);
- p.addComponent(c);
+ pl.addComponent(c);
if (i == 50) {
l50 = c;
}
import com.vaadin.ui.CheckBox;
import com.vaadin.ui.LegacyWindow;
import com.vaadin.ui.Panel;
+import com.vaadin.ui.VerticalLayout;
public class EnableState extends AbstractTestCase {
@Override
public void init() {
LegacyWindow mainWindow = new LegacyWindow("Helloworld Application");
- final Panel panel = new Panel("Test");
+ VerticalLayout panelLayout = new VerticalLayout();
+ panelLayout.setMargin(true);
+ final Panel panel = new Panel("Test", panelLayout);
final Button button = new Button("ablebutton");
- panel.addComponent(button);
+ panelLayout.addComponent(button);
CheckBox enable = new CheckBox("Toggle button enabled", true);
enable.addListener(new Property.ValueChangeListener() {
import com.vaadin.ui.Form;
import com.vaadin.ui.GridLayout;
import com.vaadin.ui.Panel;
+import com.vaadin.ui.VerticalLayout;
public class GridLayoutInForm extends TestBase {
form.setSizeUndefined();
- Panel panel = new Panel();
- panel.addComponent(form);
+ VerticalLayout panelLayout = new VerticalLayout();
+ panelLayout.setMargin(true);
+ Panel panel = new Panel(panelLayout);
+ panelLayout.addComponent(form);
panel.setHeight("500px");
addComponent(panel);
if (styleName != null) {
p.setCaption(styleName);
}
- p.setContent(new GridLayout());
+ GridLayout layout = new GridLayout();
+ p.setContent(layout);
// ((VerticalLayout) p.getContent()).setMargin(false);
p.setSizeUndefined();
- p.getContent().setSizeUndefined();
+ layout.setSizeUndefined();
for (int i = 0; i < labels; i++) {
Label l = new Label("Label " + i);
if (styleName != null) {
l.setStyleName(styleName);
}
- p.addComponent(l);
+ layout.addComponent(l);
}
return p;
}
protected Component buildRootSeparator() {
- Panel panel = new Panel();
+ VerticalLayout layout = new VerticalLayout();
+ layout.setMargin(true);
+ Panel panel = new Panel(layout);
panel.addStyleName("pexp-separator");
panel.setWidth("100%");
panel.setHeight(3.0f, Sizeable.Unit.PIXELS);
import com.vaadin.ui.Label;
import com.vaadin.ui.Panel;
import com.vaadin.ui.TextArea;
+import com.vaadin.ui.VerticalLayout;
import com.vaadin.ui.themes.Reindeer;
public class BasicPanelTest extends TestBase {
actions.addComponent(scrollPosition);
actions.addComponent(new Button("Sync"));
+ VerticalLayout panelLayout = new VerticalLayout();
+ panelLayout.setMargin(true);
+ panel.setContent(panelLayout);
+
final CheckBox heightSelection = new CheckBox("Undefined height");
heightSelection.setImmediate(true);
heightSelection.addListener(new ValueChangeListener() {
panel.setHeight("100%");
panel.setStyleName(Reindeer.PANEL_LIGHT);
- panel.getContent().setCaption("Content caption");
+ panelLayout.setCaption("Content caption");
TextArea textArea = new TextArea("TextArea caption");
textArea.setWidth("300px");
textArea.setHeight("500px");
- panel.addComponent(textArea);
+ panelLayout.addComponent(textArea);
getLayout().addComponent(actions);
getLayout().addComponent(panel);
import com.vaadin.event.MouseEvents.ClickListener;
import com.vaadin.tests.components.TestBase;
import com.vaadin.ui.Panel;
+import com.vaadin.ui.VerticalLayout;
public class PanelClickListenerRelativeCoordinates extends TestBase {
@Override
protected void setup() {
- Panel panel = new Panel("Panel's caption");
+ VerticalLayout panelLayout = new VerticalLayout();
+ panelLayout.setMargin(true);
+ Panel panel = new Panel("Panel's caption", panelLayout);
panel.addListener(new ClickListener() {
@Override
import com.vaadin.tests.components.TestBase;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
-import com.vaadin.ui.ComponentContainer;
import com.vaadin.ui.Label;
import com.vaadin.ui.Notification;
import com.vaadin.ui.Panel;
+import com.vaadin.ui.VerticalLayout;
public class PanelConcurrentModificationException extends TestBase {
- private final ComponentContainer panel = new Panel();
+ private final VerticalLayout panelLayout = new VerticalLayout();
+ private final Panel panel = new Panel(panelLayout);
@Override
protected void setup() {
+ panelLayout.setMargin(true);
+
addComponent(new Button("Click here for exception",
new Button.ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
- panel.addComponent(new Label("Label"));
+ panelLayout.addComponent(new Label("Label"));
}
}));
addComponent(new Button("Or click here first",
@Override
protected void setup() {
- final Panel p = new Panel(new CssLayout());
+ final CssLayout pl = new CssLayout();
+ final Panel p = new Panel(pl);
p.setSizeFull();
p.setHeight("600px");
- p.addComponent(foo());
+ pl.addComponent(foo());
addMore = new Button("Add");
addMore.addListener(new ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
- p.removeComponent(addMore);
- p.addComponent(foo());
- p.addComponent(addMore);
+ pl.removeComponent(addMore);
+ pl.addComponent(foo());
+ pl.addComponent(addMore);
}
});
- p.addComponent(addMore);
+ pl.addComponent(addMore);
addComponent(p);
((VerticalLayout) getMainWindow().getContent()).setSizeFull();
}
private Component foo() {
- Panel panel = new Panel();
- panel.addComponent(new Label(
+ VerticalLayout layout = new VerticalLayout();
+ layout.setMargin(true);
+ Panel panel = new Panel(layout);
+ layout.addComponent(new Label(
"fooooooooo<br/>foo<br/>foo<br/>foo<br/>foo<br/>foo<br/>foo<br/>foo<br/>foo<br/>foo<br/>foo<br/>foo<br/>foo<br/>"
+ "foo<br/>foo<br/>foo<br/>foo<br/>foo<br/>foo<br/>foo<br/>foo<br/>foo<br/>foo<br/>foo<br/>foo<br/>foo<br/>",
ContentMode.HTML));
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.Panel;
import com.vaadin.ui.TextField;
+import com.vaadin.ui.VerticalLayout;
public class PanelShouldRemoveActionHandler extends TestBase {
@Override
protected void setup() {
- panel = new Panel("A panel");
- panel.addComponent(new TextField());
+ VerticalLayout layout = new VerticalLayout();
+ layout.setMargin(true);
+ panel = new Panel("A panel", layout);
+ layout.addComponent(new TextField());
Button add = new Button("Add an action handler",
new Button.ClickListener() {
package com.vaadin.tests.components.panel;
-import com.vaadin.tests.components.AbstractComponentContainerTest;
+import com.vaadin.tests.components.AbstractComponentTest;
import com.vaadin.ui.Panel;
-public class PanelTest<T extends Panel> extends
- AbstractComponentContainerTest<T> {
+public class PanelTest<T extends Panel> extends AbstractComponentTest<T> {
@SuppressWarnings("unchecked")
@Override
+ "'>" + LoremIpsum.get(2000) + "</div>",
ContentMode.HTML);
l.setSizeFull();
- p.addComponent(l);
+ vl.addComponent(l);
PopupView pv = new PopupView("Click here to popup", p);
popupViews.add(pv);
import com.vaadin.ui.Notification;
import com.vaadin.ui.Panel;
import com.vaadin.ui.RichTextArea;
+import com.vaadin.ui.VerticalLayout;
import com.vaadin.ui.Window;
@SuppressWarnings("serial")
getLayout().getUI().addActionHandler(actionHandler);
getLayout().addComponent(createRichTextArea("InMainLayout"));
- Panel panel = new Panel("RTA Panel");
+ VerticalLayout panelLayout = new VerticalLayout();
+ panelLayout.setMargin(true);
+ Panel panel = new Panel("RTA Panel", panelLayout);
panel.addActionHandler(actionHandler);
- panel.getContent().addComponent(createRichTextArea("InPanel"));
+ panelLayout.addComponent(createRichTextArea("InPanel"));
getLayout().addComponent(panel);
Window w = new Window("SubWindow");
import com.vaadin.ui.HorizontalSplitPanel;
import com.vaadin.ui.Notification;
import com.vaadin.ui.Panel;
+import com.vaadin.ui.VerticalLayout;
import com.vaadin.ui.VerticalSplitPanel;
public class SplitPanelSplitterWidth extends TestBase {
split.setWidth("200px");
split.setHeight("200px");
split.setLocked(true);
- Panel p = new Panel("Left");
+ Panel p = buildPanel("Left");
p.setSizeFull();
split.addComponent(p);
- p = new Panel("Right");
+ p = buildPanel("Right");
p.setSizeFull();
split.addComponent(p);
split2.setWidth("200px");
split2.setHeight("200px");
split2.setLocked(true);
- p = new Panel("Top");
+ p = buildPanel("Top");
p.setSizeFull();
split2.addComponent(p);
- p = new Panel("Bottom");
+ p = buildPanel("Bottom");
p.setSizeFull();
split2.addComponent(p);
getLayout().addComponent(split2);
}
+
+ private Panel buildPanel(String caption) {
+ VerticalLayout pl = new VerticalLayout();
+ pl.setMargin(true);
+ return new Panel(caption, pl);
+ }
}
import com.vaadin.ui.HorizontalSplitPanel;
import com.vaadin.ui.Panel;
import com.vaadin.ui.Table;
+import com.vaadin.ui.VerticalLayout;
public class SafariRenderingBugWhiteSpace extends TestBase {
split.setFirstComponent(table);
split.setSplitPosition(100, Sizeable.UNITS_PERCENTAGE);
- Panel editor = new Panel("Editor");
+ VerticalLayout pl = new VerticalLayout();
+ pl.setMargin(true);
+ Panel editor = new Panel("Editor", pl);
editor.setSizeFull();
split.setSecondComponent(editor);
getLayout().setSizeFull();
import com.vaadin.ui.Label;
import com.vaadin.ui.Panel;
import com.vaadin.ui.TabSheet;
+import com.vaadin.ui.VerticalLayout;
public class TabSheetCaptions extends TestBase {
final Date date = new Date();
date.setTime((long) 1000000000000.0);
- panel1 = new Panel("Panel initial caption (should also be tab caption)");
+ VerticalLayout layout1 = new VerticalLayout();
+ layout1.setMargin(true);
+ layout1.setSizeFull();
+ panel1 = new Panel(
+ "Panel initial caption (should also be tab caption)", layout1);
panel1.setSizeFull();
- panel1.getContent().setSizeFull();
- panel1.addComponent(new Label("This is a panel"));
+ layout1.addComponent(new Label("This is a panel"));
tabSheet.addTab(panel1);
Button button = new Button("Update tab caption");
- button.addListener(new Button.ClickListener() {
+ button.addClickListener(new Button.ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
tabSheet.getTab(panel1).setCaption(
});
Button button2 = new Button("Update panel caption");
- button2.addListener(new Button.ClickListener() {
+ button2.addClickListener(new Button.ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
panel1.setCaption("This is a new panel caption "
import com.vaadin.server.LegacyApplication;
import com.vaadin.ui.Component;
import com.vaadin.ui.LegacyWindow;
-import com.vaadin.ui.Panel;
import com.vaadin.ui.Table;
import com.vaadin.ui.TextField;
import com.vaadin.ui.VerticalLayout;
final Table table = new Table();
table.addContainerProperty("column1", Component.class, null);
- final Panel panel = new Panel("Panel");
- ((VerticalLayout) panel.getContent()).setMargin(false);
VerticalLayout vl = new VerticalLayout();
final TextField textField = new TextField();
vl.addComponent(textField);
import com.vaadin.tests.components.TestBase;
import com.vaadin.ui.Panel;
import com.vaadin.ui.Tree;
+import com.vaadin.ui.VerticalLayout;
public class TreeHorizontalResize extends TestBase {
@Override
protected void setup() {
- Panel treePanel = new Panel();
+ VerticalLayout treeLayout = new VerticalLayout();
+ treeLayout.setMargin(true);
+ treeLayout.setSizeUndefined();
+ Panel treePanel = new Panel(treeLayout);
treePanel.setHeight("500px");
treePanel.setWidth(null);
- treePanel.getContent().setSizeUndefined();
addComponent(treePanel);
Tree tree = new Tree();
for (Iterator<?> it = tree.rootItemIds().iterator(); it.hasNext();) {
tree.expandItemsRecursively(it.next());
}
- treePanel.addComponent(tree);
+ treeLayout.addComponent(tree);
}
@Override
import com.vaadin.ui.Label;
import com.vaadin.ui.Panel;
import com.vaadin.ui.Tree;
+import com.vaadin.ui.VerticalLayout;
public class TreeScrollingOnSelection extends TestBase {
private static final long serialVersionUID = 4082075610259697145L;
});
tree.setImmediate(true);
- Panel panel = new Panel();
- panel.addComponent(tree);
+ VerticalLayout panelLayout = new VerticalLayout();
+ panelLayout.setMargin(true);
+ Panel panel = new Panel(panelLayout);
+ panelLayout.addComponent(tree);
panel.setWidth("200px");
panel.setHeight("300px");
* Helper to create panels for different theme variants...
*/
private Panel createPanelWith(String caption, String styleName) {
- Panel panel = new Panel(caption);
- panel.addComponent(new Label("Some content"));
+ VerticalLayout panelLayout = new VerticalLayout();
+ panelLayout.setMargin(true);
+ Panel panel = new Panel(caption, panelLayout);
+ panelLayout.addComponent(new Label("Some content"));
panel.setIcon(new ThemeResource(parent.ICON_URL));
panel.setComponentError(new UserError("A error message..."));
panel.setId("layout" + debugIdCounter++);
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.LegacyWindow;
import com.vaadin.ui.Panel;
+import com.vaadin.ui.VerticalLayout;
public class ExecuteJavaScript extends AbstractTestCase {
for (final String script : new String[] { "alert('foo');",
"window.print()", "document.write('foo')" }) {
- Panel p = new Panel("Example: " + script);
- p.addComponent(createScriptButton(script));
+ VerticalLayout pl = new VerticalLayout();
+ pl.setMargin(true);
+ Panel p = new Panel("Example: " + script, pl);
+ pl.addComponent(createScriptButton(script));
mainWindow.addComponent(p);
}
import com.vaadin.tests.components.TestBase;
import com.vaadin.ui.NativeButton;
+import com.vaadin.ui.VerticalLayout;
import com.vaadin.ui.Window;
public class FullSizedWindow extends TestBase {
@Override
protected void setup() {
- Window w = new Window("full sized window");
+ VerticalLayout layout = new VerticalLayout();
+ layout.setMargin(true);
+ Window w = new Window("full sized window", layout);
w.setSizeFull();
- w.getContent().setSizeFull();
+ layout.setSizeFull();
NativeButton b = new NativeButton("A large button");
b.setSizeFull();
- w.getContent().addComponent(b);
+ layout.addComponent(b);
getMainWindow().addWindow(w);
setTheme("runo");
}
}
}));
- Panel panel = new Panel("scrollable panel");
+ VerticalLayout panelLayout = new VerticalLayout();
+ panelLayout.setMargin(true);
+ Panel panel = new Panel("scrollable panel", panelLayout);
panel.setHeight(400, Panel.UNITS_PIXELS);
panel.setScrollLeft(50);
panel.setScrollTop(50);
- panel.getContent().setSizeUndefined();
+ panelLayout.setSizeUndefined();
window.addComponent(l("Spacer", 500, 500));
l2 = null;
for (int i = 0; i < 10; i++) {
l2 = l("X" + i);
- panel.addComponent(l2);
+ panelLayout.addComponent(l2);
}
final Component x29 = l2;
l = l("Y" + i);
horizontalLayout.addComponent(l);
}
- panel.addComponent(horizontalLayout);
+ panelLayout.addComponent(horizontalLayout);
final Component y29 = l;
((VerticalLayout) getMainWindow().getContent()).addComponent(
package com.vaadin.tests.components.window;
import com.vaadin.tests.components.panel.PanelTest;
+import com.vaadin.ui.VerticalLayout;
import com.vaadin.ui.Window;
public class WindowTest extends PanelTest<Window> {
@Override
protected void addTestComponent(Window c) {
+ VerticalLayout layout = new VerticalLayout();
+ layout.setMargin(true);
+ c.setContent(layout);
getMainWindow().addWindow(c);
getTestComponents().add(c);
}
import com.vaadin.tests.util.Log;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.ComponentContainer;
import com.vaadin.ui.Notification;
import com.vaadin.ui.Panel;
import com.vaadin.ui.Table;
import com.vaadin.ui.TextArea;
import com.vaadin.ui.TextField;
+import com.vaadin.ui.VerticalLayout;
public class BasicPersonForm extends TestBase {
private class ConfigurationPanel extends Panel {
public ConfigurationPanel() {
- super("Configuration");
+ super("Configuration", new VerticalLayout());
+ ((VerticalLayout) getContent()).setMargin(true);
BeanItem<Configuration> bi = new BeanItem<BasicPersonForm.Configuration>(
configuration);
FieldGroup confFieldGroup = new FieldGroup(bi);
confFieldGroup.setBuffered(false);
for (Object propertyId : bi.getItemPropertyIds()) {
- addComponent(confFieldGroup.buildAndBind(propertyId));
+ ((ComponentContainer) getContent()).addComponent(confFieldGroup
+ .buildAndBind(propertyId));
}
}
l.addComponent(new Label("Normal Panel", ContentMode.HTML));
- Panel p = new Panel("Normal Panel");
+ VerticalLayout pl = new VerticalLayout();
+ pl.setMargin(true);
+ Panel p = new Panel("Normal Panel", pl);
p.setHeight("100px");
- p.addComponent(new Label("Panel content"));
+ pl.addComponent(new Label("Panel content"));
l.addComponent(p);
l.addComponent(new Label(
"Light Style (<code>LiferayTheme.PANEL_LIGHT</code>)",
ContentMode.HTML));
- Panel p2 = new Panel("Light Style Panel");
+ VerticalLayout p2l = new VerticalLayout();
+ p2l.setMargin(true);
+ Panel p2 = new Panel("Light Style Panel", p2l);
p2.setStyleName(LiferayTheme.PANEL_LIGHT);
- p2.addComponent(new Label("Panel content"));
+ p2l.addComponent(new Label("Panel content"));
l.addComponent(p2);
return l;
Label l = new Label(
"This is a nice game to guess how many Layouts your FF2 (or any other browser) can deal with. Due to the worldwide attempt to decrease energy consumption, playing this game is only allowed above 60° longitude betwheen August and May (as excess energy consumed by you CPU is used to heat your room). It is considered wise to save all your work before starting the game.");
- root = new Panel("Test box");
+ VerticalLayout rootLayout = new VerticalLayout();
+ rootLayout.setMargin(true);
+ root = new Panel("Test box", rootLayout);
root.setWidth("600px");
root.setHeight("200px");
final Button b = new Button("Go try your luck with " + i + " layouts!");
import com.vaadin.tests.components.TestBase;
import com.vaadin.ui.GridLayout;
import com.vaadin.ui.Label;
-import com.vaadin.ui.Layout.MarginHandler;
import com.vaadin.ui.Panel;
+import com.vaadin.ui.VerticalLayout;
public class GridLayoutInsidePanel extends TestBase {
gl.addComponent(new Label(
"A label which defines the size of the GL"));
- Panel p = new Panel("Panel 1");
- ((MarginHandler) p.getContent()).setMargin(false);
+ VerticalLayout pl = new VerticalLayout();
+ pl.setMargin(true);
+ pl.setSizeUndefined();
+ Panel p = new Panel("Panel 1", pl);
+ pl.setMargin(false);
p.setSizeUndefined();
- p.getContent().setSizeUndefined();
- p.addComponent(gl);
+ pl.addComponent(gl);
addComponent(p);
}
{
"A label which defines the size of the GL"));
Panel p = new Panel("Panel 2", gl);
- ((MarginHandler) p.getContent()).setMargin(false);
+ gl.setMargin(false);
p.setSizeUndefined();
- p.getContent().setSizeUndefined();
+ gl.setSizeUndefined();
addComponent(p);
}
if (wrapped) {
Panel panel = new Panel(container);
panel.setSizeFull();
- container = panel;
+ setTestLayout(panel);
+ } else {
+ setTestLayout(container);
}
- setTestLayout(container);
}
}));
row3.setIcon(icons[1]);
glo.replaceComponent(x3, x3 = new CheckBox("CHECKBOX"));
- glo.replaceComponent(x22, x22 = new Panel("PANEL"));
+ VerticalLayout pl = new VerticalLayout();
+ pl.setMargin(true);
+ glo.replaceComponent(x22, x22 = new Panel("PANEL", pl));
x22.setIcon(new ThemeResource(CALENDAR_32_PNG));
x3.setIcon(icons[0]);
row3.setCaption("long test caption bewucbwuebco or bmort b cbwecubw wbeucwe asdasd asdasda asdasd");
glo.replaceComponent(x3, x3 = new CheckBox("CHECKBOX"));
- glo.replaceComponent(x22, x22 = new Panel("PANEL"));
+ VerticalLayout pl = new VerticalLayout();
+ pl.setMargin(true);
+ glo.replaceComponent(x22, x22 = new Panel("PANEL", pl));
x3.setComponentError(new UserError("component error, user error"));
x22.setComponentError(new UserError("component error, user error"));
import com.vaadin.tests.components.AbstractTestUI;
import com.vaadin.ui.Label;
import com.vaadin.ui.Panel;
+import com.vaadin.ui.VerticalLayout;
import com.vaadin.ui.themes.LiferayTheme;
@Theme("liferay")
@Override
protected void setup(VaadinRequest request) {
- Panel p = new Panel("Panel");
+ VerticalLayout pl = new VerticalLayout();
+ pl.setMargin(true);
+ Panel p = new Panel("Panel", pl);
addComponent(p);
- p.addComponent(new Label("Panel content"));
+ pl.addComponent(new Label("Panel content"));
- p = new Panel("Light Panel");
+ pl = new VerticalLayout();
+ pl.setMargin(true);
+ p = new Panel("Light Panel", pl);
p.addStyleName(LiferayTheme.PANEL_LIGHT);
addComponent(p);
- p.addComponent(new Label("Panel content"));
+ pl.addComponent(new Label("Panel content"));
}
@Override
import com.vaadin.ui.PopupView;
import com.vaadin.ui.Table;
import com.vaadin.ui.TextField;
+import com.vaadin.ui.VerticalLayout;
public class Ticket1397 extends LegacyApplication {
setTheme("runo");
main = new LegacyWindow("PopupView test");
setMainWindow(main);
- Panel panel = new Panel("PopupTest");
+ VerticalLayout panelLayout = new VerticalLayout();
+ panelLayout.setMargin(true);
+ Panel panel = new Panel("PopupTest", panelLayout);
// First test component
final ObjectProperty<String> prop = new ObjectProperty<String>(
PopupView pe = new PopupView(content);
pe.setDescription("Click to edit");
- panel.addComponent(pe);
+ panelLayout.addComponent(pe);
// Second test component
PopupView pe2 = new PopupView("fooLabel", new Label("Foooooooooo..."));
pe2.setDescription("Click to view");
- panel.addComponent(pe2);
+ panelLayout.addComponent(pe2);
// Third test component
final ObjectProperty<StringBuffer> prop2 = new ObjectProperty<StringBuffer>(
}
}
- final Panel panel2 = new Panel("Editor with a button");
- panel2.addComponent(new myButton());
+ VerticalLayout panel2Layout = new VerticalLayout();
+ panel2Layout.setMargin(true);
+ final Panel panel2 = new Panel("Editor with a button", panel2Layout);
+ panel2Layout.addComponent(new myButton());
PopupView.Content content2 = new PopupView.Content() {
@Override
public String getMinimizedValueAsHTML() {
};
PopupView p3 = new PopupView(content2);
- panel.addComponent(p3);
+ panelLayout.addComponent(p3);
// Fourth test component
- final Panel panel3 = new Panel("Editor popup for a property");
+ VerticalLayout panel3Layout = new VerticalLayout();
+ panel3Layout.setMargin(true);
+ final Panel panel3 = new Panel("Editor popup for a property",
+ panel3Layout);
TextField tf2 = new TextField("TextField for editing a property");
final ObjectProperty<String> op = new ObjectProperty<String>(
"This is property text.");
tf2.setPropertyDataSource(op);
- panel3.addComponent(tf2);
+ panel3Layout.addComponent(tf2);
PopupView.Content content3 = new PopupView.Content() {
@Override
};
PopupView p4 = new PopupView(content3);
- panel.addComponent(p4);
+ panelLayout.addComponent(p4);
// Fifth test component
Table table = new Table("Table for testing purposes");
import com.vaadin.ui.HorizontalLayout;
import com.vaadin.ui.Label;
import com.vaadin.ui.Layout;
-import com.vaadin.ui.Layout.MarginHandler;
import com.vaadin.ui.LegacyWindow;
import com.vaadin.ui.Panel;
import com.vaadin.ui.Table;
HorizontalLayout header = new HorizontalLayout();
// This is where the actual data is put.
- Panel container = new Panel();
+ VerticalLayout containerLayout = new VerticalLayout();
+ Panel container = new Panel(containerLayout);
// Last known height before the panel was collapsed
private float lastHeight = -1;
initHeader(labelString);
+ containerLayout.setMargin(true);
+
initContainer();
}
buttonContainer.addComponent(collapse);
collapse.setStyleName("collapse");
- collapse.addListener(new Button.ClickListener() {
+ collapse.addClickListener(new Button.ClickListener() {
@Override
public void buttonClick(Button.ClickEvent event) {
if (useWorkaround) {
});
if (useWorkaround) {
- expand.addListener(new Button.ClickListener() {
+ expand.addClickListener(new Button.ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
private void initContainer() {
container.setStyleName("custompanel");
container.setSizeFull();
- ((MarginHandler) container.getContent()).setMargin(false);
- container.getContent().setSizeFull();
+ containerLayout.setMargin(false);
+ containerLayout.setSizeFull();
root.addComponent(container);
root.setExpandRatio(container, 1);
}
}
public void setPanelComponent(Component component) {
- container.removeAllComponents();
- container.addComponent(component);
+ containerLayout.removeAllComponents();
+ containerLayout.addComponent(component);
}
}
import com.vaadin.ui.Component;
import com.vaadin.ui.Panel;
import com.vaadin.ui.Select;
+import com.vaadin.ui.VerticalLayout;
/**
* @author Efecte R&D
public class Ticket1506_Panel extends Panel {
public Ticket1506_Panel() {
+ VerticalLayout layout = new VerticalLayout();
+ layout.setMargin(true);
+ setContent(layout);
+
ObjectProperty<String> property1 = new ObjectProperty<String>(null,
String.class);
- addComponent(initSelect(new Ticket1506_TestContainer(), "Test select",
- property1));
- addComponent(initButton(property1));
- addComponent(initSelect(new Ticket1506_TestContainer2(),
+ layout.addComponent(initSelect(new Ticket1506_TestContainer(),
+ "Test select", property1));
+ layout.addComponent(initButton(property1));
+ layout.addComponent(initSelect(new Ticket1506_TestContainer2(),
"Test select 2", new ObjectProperty<String>(null, String.class)));
}
private Component initButton(final ObjectProperty<?> property) {
Button button = new Button("Clear select");
- button.addListener(new Button.ClickListener() {
+ button.addClickListener(new Button.ClickListener() {
@Override
public void buttonClick(Button.ClickEvent event) {
property.setValue(null);
.substring(getClass().getName().lastIndexOf(".") + 1));
setMainWindow(main);
- Panel p = new Panel("Test wrapper for gridlayout margin/spacing");
-
- p.setContent(new HorizontalLayout());
+ HorizontalLayout pl = new HorizontalLayout();
+ Panel p = new Panel("Test wrapper for gridlayout margin/spacing", pl);
gl = new GridLayout(3, 3);
gl.setMargin(true);
for (int i = 0; i < 3 * 3; i++) {
gl.addComponent(new Button("test"));
}
- p.addComponent(gl);
- p.addComponent(new Label("| next component"));
+ pl.addComponent(gl);
+ pl.addComponent(new Label("| next component"));
Button b = new Button("next margin state");
- b.addListener(new Button.ClickListener() {
+ b.addClickListener(new Button.ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
nextMarginState();
main.addComponent(b);
Button b2 = new Button("next spacing state");
- b2.addListener(new Button.ClickListener() {
+ b2.addClickListener(new Button.ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
nextSpacingState();
cl.addComponent(new Label("<<< Add customlayout testcase here >>>"));
// Form
- Panel formPanel = new Panel("Form");
+ VerticalLayout formPanelLayout = new VerticalLayout();
+ formPanelLayout.setMargin(true);
+ Panel formPanel = new Panel("Form", formPanelLayout);
cb = new CheckBox("Form", new MethodProperty<Boolean>(formPanel,
"visible"));
cb.setImmediate(true);
hidingControls.addComponent(cb);
formPanel.setVisible(false);
- formPanel.addComponent(getFormPanelExample());
+ formPanelLayout.addComponent(getFormPanelExample());
lo.addComponent(formPanel);
for (Iterator<Component> i = hidingControls.getComponentIterator(); i
setContent(internalLayout);
testedLayout = layout;
testPanelLayout.setWidth("100%");
- Panel controlWrapper = new Panel();
- controlWrapper.addComponent(controls);
+ VerticalLayout controlWrapperLayout = new VerticalLayout();
+ controlWrapperLayout.setMargin(true);
+ Panel controlWrapper = new Panel(controlWrapperLayout);
+ controlWrapperLayout.addComponent(controls);
controlWrapper.setWidth("100%");
controlWrapper.setStyleName("controls");
internalLayout.addComponent(controlWrapper);
VerticalLayout el = new VerticalLayout();
main.setContent(el);
- Panel p = new Panel("Test panel");
+ VerticalLayout pl = new VerticalLayout();
+ pl.setMargin(true);
+ Panel p = new Panel("Test panel", pl);
p.setSizeFull();
- p.addComponent(new Label(
+ pl.addComponent(new Label(
"Second component is embedded with a slow resource "
+ "and thus should break layout if Embedded cannot"
+ " request re-layout after load."));
import com.vaadin.ui.Label;
import com.vaadin.ui.LegacyWindow;
import com.vaadin.ui.Panel;
+import com.vaadin.ui.VerticalLayout;
-public class Ticket1834PanelScrolling extends com.vaadin.server.LegacyApplication {
+public class Ticket1834PanelScrolling extends
+ com.vaadin.server.LegacyApplication {
private static final int ROWS = 50;
private Label state = new Label("State");
private Panel p;
+ private VerticalLayout pl;
@Override
public void init() {
@Override
public void buttonClick(ClickEvent event) {
- p.addComponent(new Label("new Row" + ++i));
+ pl.addComponent(new Label("new Row" + ++i));
}
});
main.addComponent(b);
- p = new Panel("TestPanel");
+ pl = new VerticalLayout();
+ pl.setMargin(true);
+ p = new Panel("TestPanel", pl);
for (int i = 0; i < ROWS; i++) {
- p.addComponent(new Label(
+ pl.addComponent(new Label(
"Label"
+ i
+ "................................................................................................................."));
import com.vaadin.ui.LegacyWindow;
import com.vaadin.ui.Panel;
+import com.vaadin.ui.VerticalLayout;
public class Ticket1868 extends com.vaadin.server.LegacyApplication {
setMainWindow(new LegacyWindow("#1868"));
+ VerticalLayout pl = new VerticalLayout();
+ pl.setMargin(true);
Panel p = new Panel(
- "This is a really long caption for the panel, too long in fact!");
+ "This is a really long caption for the panel, too long in fact!",
+ pl);
p.setWidth("300px");
p.setHeight("300px");
FormLayout formLayout = new FormLayout();
Form form = new Form(formLayout);
- Panel p = new Panel("Form " + w + "x" + h);
+ VerticalLayout vl = new VerticalLayout();
+ vl.setMargin(true);
+ vl.setSizeFull();
+ Panel p = new Panel("Form " + w + "x" + h, vl);
p.setWidth(w);
p.setHeight(h);
- p.getContent().setSizeFull();
-
parentLayout.addComponent(p);
- p.addComponent(form);
+ vl.addComponent(form);
formLayout.setSizeFull();
return form;
createLayout(parentLayout, newLayout, w, h, null, null, align);
}
- private static void createLayout(GridLayout parentLayout, Layout newLayout,
- String w, String h, String componentWidth, String componentHeight,
- boolean align) {
+ private static void createLayout(GridLayout parentLayout,
+ final Layout newLayout, String w, String h, String componentWidth,
+ String componentHeight, boolean align) {
String dirText = "V";
String type;
if (newLayout instanceof VerticalLayout) {
tf.setValue(tf.getValue() + " h:" + componentHeight);
}
- p.addComponent(tf);
+ newLayout.addComponent(tf);
if (align) {
((AlignmentHandler) newLayout).setComponentAlignment(
toggleStyleName();
}
});
- p.addComponent(b);
+ p.setContent(b);
return p;
}
}
.substring(getClass().getName().lastIndexOf(".") + 1));
setMainWindow(main);
- p = new Panel("TestPanel 250x300");
+ VerticalLayout pl = new VerticalLayout();
+ pl.setMargin(true);
+ p = new Panel("TestPanel 250x300", pl);
// p.getLayout().setWidth("100%");
// p.setContent(new GridLayout(1, 100));
for (int i = 0; i < ROWS; i++) {
- p.addComponent(new Label(
+ pl.addComponent(new Label(
"Label"
+ i
+ " 5067w09adsfasdjfahlsdfjhalfjhaldjfhalsjdfhlajdhflajhdfljahdslfjahldsjfhaljdfhaljfdhlajsdhflajshdflkajhsdlfkjahsldfkjahsldfhalskjfdhlksjfdh857idifhaljsdfhlajsdhflajhdflajhdfljahldfjhaljdfhalsjdfhalkjdhflkajhdfljahsdlfjahlsdjfhaldjfhaljfdhlajdhflajshdfljahsdlfjhalsjdfhalskjhfdlhusfglksuhdflgjshflgjhslfghslfjghsljfglsjhfglsjhfgljshfgljshflgjhslfghsljfgsljdfglsdjhfglsjhflgkjshfldjgh"));
main.addComponent(p);
VerticalLayout ol = new VerticalLayout();
- p = new Panel("a");
- p.addComponent(new Label("Longer than caption"));
+ pl = new VerticalLayout();
+ pl.setMargin(true);
+ p = new Panel("a", pl);
+ pl.addComponent(new Label("Longer than caption"));
ol.addComponent(p);
main.addComponent(ol);
ol = new VerticalLayout();
- p = new Panel("captionasdfjahsdjfh this should be clipped god damn it");
+ pl = new VerticalLayout();
+ pl.setMargin(true);
+ p = new Panel("captionasdfjahsdjfh this should be clipped god damn it",
+ pl);
// p.getLayout().setSizeFull();
p.setWidth("50px");
p.setHeight("100px");
- p.addComponent(new Label(
+ pl.addComponent(new Label(
"aasdfaasdfja dslkfj lakfdj lakjdf lkaj dflkaj ldfkj alsdfj laksdj flkajs dflkj sdfsadfasdfasd"));
ol.addComponent(p);
main.addComponent(ol);
ol = new VerticalLayout();
- p = new Panel("300x-1");
+ pl = new VerticalLayout();
+ pl.setMargin(true);
+ p = new Panel("300x-1", pl);
// p.getLayout().setSizeFull();
p.setWidth("300px");
- p.addComponent(new Label("Short"));
- p.addComponent(new Label("Short"));
- p.addComponent(new Label("Short"));
- p.addComponent(new Label("Short"));
- p.addComponent(new Label("Short"));
- p.addComponent(new Label("Short"));
- p.addComponent(new Label("Short"));
- p.addComponent(new Label("Short"));
- p.addComponent(new Label("Short"));
- p.addComponent(new Label("Short"));
- p.addComponent(new Label("Short"));
- p.addComponent(new Label("Short"));
- p.addComponent(new Label("Short"));
+ pl.addComponent(new Label("Short"));
+ pl.addComponent(new Label("Short"));
+ pl.addComponent(new Label("Short"));
+ pl.addComponent(new Label("Short"));
+ pl.addComponent(new Label("Short"));
+ pl.addComponent(new Label("Short"));
+ pl.addComponent(new Label("Short"));
+ pl.addComponent(new Label("Short"));
+ pl.addComponent(new Label("Short"));
+ pl.addComponent(new Label("Short"));
+ pl.addComponent(new Label("Short"));
+ pl.addComponent(new Label("Short"));
+ pl.addComponent(new Label("Short"));
ol.addComponent(p);
main.addComponent(ol);
layout.addComponent(p);
GridLayout gl = new GridLayout(1, 4);
+ gl.setMargin(true);
gl.setCaption("Horizontal");
Button b;
addButtons(gl);
- p.addComponent(gl);
+ p.setContent(gl);
/* VERTICAL */
gl = new GridLayout(4, 1);
+ gl.setMargin(true);
gl.setCaption("Vertical");
addButtons(gl);
b.setHeight("200px");
gl.addComponent(b);
- p.addComponent(gl);
+ p.setContent(gl);
}
layout.addComponent(p);
AbstractOrderedLayout ol = new VerticalLayout();
+ ol.setMargin(true);
ol.setCaption("Horizontal");
// ol.setWidth("100%");
ol.addComponent(b);
addButtons(ol);
- p.addComponent(ol);
+ p.setContent(ol);
/* VERTICAL */
ol = new HorizontalLayout();
+ ol.setMargin(true);
ol.setCaption("Vertical");
addButtons(ol);
b.setHeight("200px");
ol.addComponent(b);
- p.addComponent(ol);
+ p.setContent(ol);
}
}
private void gridLayout(Layout layout) {
- Panel p = new Panel("GridLayout");
+ VerticalLayout pl = new VerticalLayout();
+ pl.setMargin(true);
+ Panel p = new Panel("GridLayout", pl);
p.setWidth("500px");
p.setHeight("500px");
- p.getContent().setSizeFull();
+ pl.setSizeFull();
layout.addComponent(p);
GridLayout gl = new GridLayout(1, 4);
+ gl.setMargin(true);
gl.setCaption("Horizontal");
gl.setWidth("100%");
addButtons(gl);
- p.addComponent(gl);
+ p.setContent(gl);
/* VERTICAL */
gl = new GridLayout(4, 1);
+ gl.setMargin(true);
// gl.setCaption("Vertical");
gl.setHeight("100%");
addButtons(gl);
// b.setHeight(200);
// gl.addComponent(b);
- p.addComponent(gl);
+ p.setContent(gl);
}
private void orderedLayout(Layout layout) {
- Panel p = new Panel("OrderedLayout");
+ VerticalLayout pl = new VerticalLayout();
+ pl.setMargin(true);
+ Panel p = new Panel("OrderedLayout", pl);
p.setWidth("500px");
p.setHeight("500px");
- p.getContent().setWidth("100%");
+ pl.setWidth("100%");
layout.addComponent(p);
AbstractOrderedLayout ol = new VerticalLayout();
+ ol.setMargin(true);
// ol.setCaption("Horizontal");
ol.setWidth("100%");
addButtons(ol);
- p.addComponent(ol);
+ pl.addComponent(ol);
/* VERTICAL */
ol = new HorizontalLayout();
+ ol.setMargin(true);
// ol.setCaption("Vertical");
ol.setHeight("200px");
addButtons(ol);
// Button b = new Button("High button");
// b.setHeight(200);
// ol.addComponent(b);
- p.addComponent(ol);
+ pl.addComponent(ol);
}
private void expandLayout(Layout layout) {
- Panel p = new Panel("ExpandLayout");
+ VerticalLayout panelLayout = new VerticalLayout();
+ panelLayout.setMargin(true);
+ Panel p = new Panel("ExpandLayout", panelLayout);
layout.addComponent(p);
- p.getContent().setWidth("500");
- p.getContent().setHeight("400");
+ panelLayout.setWidth("500");
+ panelLayout.setHeight("400");
AbstractOrderedLayout el = new VerticalLayout();
// el.setCaption("Horizontal");
// el.addComponent(b);
addButtons(el);
- p.addComponent(el);
+ panelLayout.addComponent(el);
/* VERTICAL */
// b.setHeight(100);
// el.addComponent(b);
- p.addComponent(el);
+ panelLayout.addComponent(el);
}
Panel p = new Panel(ol);
p.setWidth("300px");
p.setHeight("300px");
- p.getContent().setSizeFull();
+ ol.setSizeFull();
TextField tf = new TextField("Long caption, longer than 100 pixels");
tf.setWidth("100px");
main.setContent(ol);
ol.setSizeFull();
- Panel p = new Panel("Tree test");
+ VerticalLayout pl = new VerticalLayout();
+ pl.setMargin(true);
+ Panel p = new Panel("Tree test", pl);
p.setSizeFull();
Tree t = new Tree();
});
main.addComponent(p);
- p.addComponent(t);
- p.addComponent(events);
+ pl.addComponent(t);
+ pl.addComponent(events);
- Panel p2 = new Panel("Table test (try dbl click also)");
+ VerticalLayout p2l = new VerticalLayout();
+ p2l.setMargin(true);
+ Panel p2 = new Panel("Table test (try dbl click also)", p2l);
p2.setSizeFull();
final VerticalLayout events2 = new VerticalLayout();
}
});
- p2.addComponent(table);
- p2.addComponent(events2);
+ p2l.addComponent(table);
+ p2l.addComponent(events2);
main.addComponent(p2);
import com.vaadin.ui.HorizontalLayout;
import com.vaadin.ui.LegacyWindow;
import com.vaadin.ui.Panel;
+import com.vaadin.ui.VerticalLayout;
public class Ticket2014 extends LegacyApplication {
}
private void createPanel(GridLayout layout) {
- panel = new Panel("panel caption");
+ VerticalLayout panelLayout = new VerticalLayout();
+ panelLayout.setMargin(true);
+ panel = new Panel("panel caption", panelLayout);
layout.addComponent(panel);
innerLayout1 = new HorizontalLayout();
innerLayout1.setSpacing(true);
- panel.addComponent(innerLayout1);
+ panelLayout.addComponent(innerLayout1);
b1 = new Button("Button inside orderedLayout", new ClickListener() {
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;
-import com.vaadin.ui.Layout.MarginHandler;
import com.vaadin.ui.LegacyWindow;
import com.vaadin.ui.Panel;
import com.vaadin.ui.TextArea;
tf1.setSizeFull();
tf1.setValue(contents);
tf1.setCaption("TextField caption");
- p.getContent().addComponent(tf1);
+ ((ComponentContainer) p.getContent()).addComponent(tf1);
/*
*
tf2.setSizeFull();
tf2.setValue(contents);
tf2.setCaption("TextField caption");
- p2.getContent().addComponent(tf2);
+ ((ComponentContainer) p2.getContent()).addComponent(tf2);
/*
*
* GridLayout
*/
- Panel p3 = new Panel();
+ VerticalLayout p3l = new VerticalLayout();
+ p3l.setMargin(true);
+ Panel p3 = new Panel(p3l);
p3.setCaption("GridLayout");
p3.setWidth("500px");
p3.setHeight("500px");
// p3.setContent(new GridLayout());
- p3.getContent().setSizeFull();
- ((MarginHandler) p3.getContent()).setMargin(false);
+ p3l.setSizeFull();
+ p3l.setMargin(false);
GridLayout gl = new GridLayout();
gl.setSizeFull();
gl.setMargin(false);
- p3.getContent().addComponent(gl);
+ p3l.addComponent(gl);
w.addComponent(p3);
tf3 = new TextArea();
HorizontalLayout layout = new HorizontalLayout();
p.setContent(layout);
- p.getContent().setSizeFull();
+ layout.setSizeFull();
for (int i = 0; i < COMPONENTS; i++) {
TextField tf = new TextField();
}
tf.setWidth("100%");
layout.setComponentAlignment(tf, Alignment.BOTTOM_LEFT);
- p.addComponent(tf);
+ layout.addComponent(tf);
}
GridLayout layout = new GridLayout(COMPONENTS, 1);
p.setContent(layout);
- p.getContent().setSizeFull();
+ layout.setSizeFull();
for (int i = 0; i < COMPONENTS; i++) {
TextField tf = new TextField();
}
tf.setWidth("100%");
layout.setComponentAlignment(tf, Alignment.MIDDLE_LEFT);
- p.addComponent(tf);
+ layout.addComponent(tf);
}
VerticalLayout layout = new VerticalLayout();
p.setContent(layout);
- p.getContent().setSizeFull();
+ layout.setSizeFull();
for (int i = 0; i < COMPONENTS; i++) {
TextArea tf = new TextArea();
tf.setSizeFull();
layout.setComponentAlignment(tf, Alignment.BOTTOM_LEFT);
- p.addComponent(tf);
+ layout.addComponent(tf);
}
p.setSizeFull();
Label l = new Label("Spacer");
l.setHeight("400px");
- p.addComponent(l);
+ ol.addComponent(l);
embedded = new Embedded(null, new ThemeResource(
"icons/64/folder-add.png"));
}
});
- p.addComponent(b);
+ ol.addComponent(b);
b = new Button("Change image source (is fine)", new ClickListener() {
});
- p.addComponent(b);
+ ol.addComponent(b);
layout.addComponent(p);
}
}
sp.setSizeFull();
sp.setSplitPosition(20, Sizeable.UNITS_PIXELS);
- p = new Panel("This is a panel");
+ VerticalLayout pl = new VerticalLayout();
+ pl.setMargin(true);
+ p = new Panel("This is a panel", pl);
p.setSizeFull();
Label label1 = new Label("This is a table!");
label1.setHeight("1500px");
label1.setWidth("1500px");
- p.addComponent(label1);
+ pl.addComponent(label1);
p.setScrollTop(50);
// MyTable table1 = new MyTable(24, "table1");
// table1.loadTable(1000);
// sp.addComponent(new Label("Filler"));
// sp.addComponent(tab);
- p = new Panel("This is a panel");
+ pl = new VerticalLayout();
+ pl.setMargin(true);
+ p = new Panel("This is a panel", pl);
p.setWidth("2000px");
p.setHeight("2000px");
- Panel p2 = new Panel("This is another panel");
+ VerticalLayout p2l = new VerticalLayout();
+ p2l.setMargin(true);
+ Panel p2 = new Panel("This is another panel", p2l);
p2.setWidth("2500px");
p2.setHeight("2500px");
label1 = new Label("This is a table!");
label1.setHeight("1500px");
label1.setWidth("1500px");
- p2.addComponent(label1);
- p.addComponent(p2);
+ p2l.addComponent(label1);
+ pl.addComponent(p2);
tab.addTab(p, "Panel with panel", null);
}
VerticalLayout ol2 = new VerticalLayout();
ol2.setSizeFull();
- p = new Panel("This is a panel");
+ VerticalLayout pl = new VerticalLayout();
+ pl.setMargin(true);
+ p = new Panel("This is a panel", pl);
p.setSizeFull();
Label label1 = new Label("This is a table!");
label1.setWidth("1500px");
p.setScrollTop(50);
- p.addComponent(label1);
+ pl.addComponent(label1);
ol2.addComponent(p);
ol.addComponent(ol2);
import com.vaadin.ui.Label;
import com.vaadin.ui.LegacyWindow;
import com.vaadin.ui.Panel;
+import com.vaadin.ui.VerticalLayout;
public class Ticket2083 extends LegacyApplication {
}
private void createUI(GridLayout layout) {
+ VerticalLayout pl = new VerticalLayout();
+ pl.setMargin(true);
Panel p = new Panel(
- "This is a panel with a longer caption than it should have");
+ "This is a panel with a longer caption than it should have", pl);
p.setWidth("100px");
- p.getContent().addComponent(new Label("Contents"));
+ pl.addComponent(new Label("Contents"));
layout.addComponent(p);
}
}
cb = new ComboBox();
// cb.setCaption("A combobox");
// cb.setWidth("100%");
- p.addComponent(cb);
+ ol.addComponent(cb);
layout.addComponent(p);
ol = new VerticalLayout();
cb = new ComboBox();
cb.setCaption("A combobox");
// cb.setWidth("100px");
- p.addComponent(cb);
+ ol.addComponent(cb);
layout.addComponent(p);
//
cb = new ComboBox();
// cb.setCaption("A combobox");
cb.setWidth("100px");
- p.addComponent(cb);
+ ol.addComponent(cb);
layout.addComponent(p);
ol = new VerticalLayout();
cb = new ComboBox();
cb.setCaption("A combobox");
cb.setWidth("100px");
- p.addComponent(cb);
+ ol.addComponent(cb);
layout.addComponent(p);
ol = new VerticalLayout();
cb = new ComboBox();
// cb.setCaption("A combobox");
cb.setWidth("500px");
- p.addComponent(cb);
+ ol.addComponent(cb);
layout.addComponent(p);
ol = new VerticalLayout();
cb = new ComboBox();
cb.setCaption("A combobox");
cb.setWidth("500px");
- p.addComponent(cb);
+ ol.addComponent(cb);
layout.addComponent(p);
ol = new VerticalLayout();
cb = new ComboBox();
// cb.setCaption("A combobox");
cb.setWidth("100%");
- p.addComponent(cb);
+ ol.addComponent(cb);
layout.addComponent(p);
ol = new VerticalLayout();
cb = new ComboBox();
cb.setCaption("A combobox");
cb.setWidth("100%");
- p.addComponent(cb);
+ ol.addComponent(cb);
layout.addComponent(p);
}
cb = new ComboBox();
// cb.setCaption("A combobox");
// cb.setWidth("100%");
- p.addComponent(cb);
+ ol.addComponent(cb);
layout.addComponent(p);
ol = new VerticalLayout();
cb = new ComboBox();
cb.setCaption("A combobox");
// cb.setWidth("100px");
- p.addComponent(cb);
+ ol.addComponent(cb);
layout.addComponent(p);
ol = new VerticalLayout();
cb = new ComboBox();
// cb.setCaption("A combobox");
cb.setWidth("100px");
- p.addComponent(cb);
+ ol.addComponent(cb);
layout.addComponent(p);
ol = new VerticalLayout();
cb = new ComboBox();
cb.setCaption("A combobox");
cb.setWidth("100px");
- p.addComponent(cb);
+ ol.addComponent(cb);
layout.addComponent(p);
ol = new VerticalLayout();
cb = new ComboBox();
// cb.setCaption("A combobox");
cb.setWidth("500px");
- p.addComponent(cb);
+ ol.addComponent(cb);
layout.addComponent(p);
ol = new VerticalLayout();
cb = new ComboBox();
cb.setCaption("A combobox");
cb.setWidth("500px");
- p.addComponent(cb);
+ ol.addComponent(cb);
layout.addComponent(p);
ol = new VerticalLayout();
// cb.setCaption("A combobox");
cb.setWidth("100%");
// cb.setWidth("500px");
- p.addComponent(cb);
+ ol.addComponent(cb);
layout.addComponent(p);
ol = new VerticalLayout();
cb = new ComboBox();
cb.setCaption("A combobox");
cb.setWidth("100%");
- p.addComponent(cb);
+ ol.addComponent(cb);
layout.addComponent(p);
}
Panel right = new Panel("Panel");
- right.addComponent(new Label("Some basic text might show up here."));
+ right.setContent(new Label("Some basic text might show up here."));
base.addComponent(content);
setMainWindow(new LegacyWindow());
VerticalLayout ol = new VerticalLayout();
- Panel p = new Panel("Test");
- p.addComponent(new Label("Panel1"));
+ VerticalLayout pl = new VerticalLayout();
+ pl.setMargin(true);
+ Panel p = new Panel("Test", pl);
+ pl.addComponent(new Label("Panel1"));
p.setHeight("500px");
p.setWidth("500px");
p.setStyleName(Reindeer.PANEL_LIGHT);
tf.setHeight("1000px");
tf.setWidth("1000px");
- outerPanel = new Panel();
+ VerticalLayout outerLayout = new VerticalLayout();
+ outerLayout.setMargin(true);
+ outerPanel = new Panel(outerLayout);
outerPanel.setCaption("A RichTextArea");
outerPanel.setVisible(false);
outerPanel.setHeight("1000px");
outerPanel.setWidth("1000px");
- outerPanel.getContent().setSizeFull();
- Panel innerPanel = new Panel("Inner panel");
+ outerLayout.setSizeFull();
+ VerticalLayout innerLayout = new VerticalLayout();
+ innerLayout.setMargin(true);
+ Panel innerPanel = new Panel("Inner panel", innerLayout);
innerPanel.setSizeFull();
- outerPanel.addComponent(innerPanel);
+ outerLayout.addComponent(innerPanel);
tf2 = new TextField("A 2000x2000 textfield");
tf2.setWidth("2000px");
tf2.setHeight("2000px");
- innerPanel.addComponent(tf2);
+ innerLayout.addComponent(tf2);
main.addComponent(outerPanel);
main.addComponent(tf);
}
import com.vaadin.ui.Label;
import com.vaadin.ui.LegacyWindow;
import com.vaadin.ui.Panel;
+import com.vaadin.ui.VerticalLayout;
import com.vaadin.ui.themes.Reindeer;
public class Ticket2304 extends LegacyApplication {
.substring(getClass().getName().lastIndexOf(".") + 1));
setMainWindow(main);
- Panel p = new Panel();
+ VerticalLayout pl = new VerticalLayout();
+ pl.setMargin(true);
+ Panel p = new Panel(pl);
p.setStyleName(Reindeer.PANEL_LIGHT);
main.addComponent(p);
p.setHeight("100px");
Label l = new Label(
"a\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\n");
l.setContentMode(ContentMode.PREFORMATTED);
- p.addComponent(l);
+ pl.addComponent(l);
main.addComponent(new Label(
"This text should be right below the panel, w/o spacing"));
}
import com.vaadin.ui.Label;
import com.vaadin.ui.LegacyWindow;
import com.vaadin.ui.Panel;
+import com.vaadin.ui.VerticalLayout;
import com.vaadin.ui.themes.Reindeer;
public class Ticket2310 extends LegacyApplication {
+ "invisible -> invalid change (with disabled "
+ "flag) is sent to client. Label is grey when panel is shown."));
- final Panel p = new Panel();
+ VerticalLayout pl = new VerticalLayout();
+ pl.setMargin(true);
+ final Panel p = new Panel(pl);
p.setStyleName(Reindeer.PANEL_LIGHT);
main.addComponent(p);
p.setHeight("100px");
final Label l = new Label("foobar");
- p.addComponent(l);
+ pl.addComponent(l);
Button b = new Button("change label");
"This test has somewhat invalid layouts in it to detect analyzy layout function in debug dialog"));
HorizontalLayout hl = new HorizontalLayout();
- Panel panel = new Panel("p1");
- Panel panel2 = new Panel("p2");
+ Panel panel = buildPanel("p1");
+ Panel panel2 = buildPanel("p2");
hl.addComponent(panel);
hl.addComponent(panel2);
mainw.addComponent(hl);
hl = new HorizontalLayout();
- panel = new Panel("p1");
+ panel = buildPanel("p1");
panel.setSizeUndefined();
panel.setHeight("100%");
- panel2 = new Panel("p2");
+ panel2 = buildPanel("p2");
panel2.setSizeUndefined();
panel2.setHeight("100%");
mainw.addComponent(new Button("click me to save split panel state"));
}
+ private Panel buildPanel(String caption) {
+ VerticalLayout pl = new VerticalLayout();
+ pl.setMargin(true);
+ return new Panel(caption, pl);
+ }
+
}
private Panel createMultilevelPanel(int i, Panel panel) {
if (panel == null) {
- panel = new Panel("Panel level " + i);
+ VerticalLayout panelLayout = new VerticalLayout();
+ panelLayout.setMargin(true);
+ panel = new Panel("Panel level " + i, panelLayout);
panel.setSizeFull();
- panel.getContent().setSizeFull();
+ panelLayout.setSizeFull();
}
- Panel p = new Panel("Panel level " + i--);
- p.getContent().setSizeFull();
+ VerticalLayout pl = new VerticalLayout();
+ pl.setMargin(true);
+ pl.setSizeFull();
+ Panel p = new Panel("Panel level " + i--, pl);
p.setSizeFull();
- panel.addComponent(p);
+ pl.addComponent(p);
if (i > 0) {
createMultilevelPanel(i, p);
}
import com.vaadin.ui.LegacyWindow;
import com.vaadin.ui.Panel;
import com.vaadin.ui.TabSheet;
+import com.vaadin.ui.VerticalLayout;
public class Ticket2425 extends LegacyApplication {
w.addComponent(new Label("No scrollbars should be visible anywhere"));
TabSheet ts = new TabSheet();
- ts.addTab(new Panel(), "Panel 1", null);
- ts.addTab(new Panel(), "Panel 2", null);
+ ts.addTab(createPanel(), "Panel 1", null);
+ ts.addTab(createPanel(), "Panel 2", null);
w.addComponent(ts);
}
+ private Panel createPanel() {
+ VerticalLayout layout = new VerticalLayout();
+ layout.setMargin(true);
+ return new Panel(layout);
+ }
+
}
private void buildViews(String[] strings) {
for (String string : strings) {
- Panel p = new Panel(string);
+ VerticalLayout pl = new VerticalLayout();
+ pl.setMargin(true);
+ Panel p = new Panel(string, pl);
p.setSizeFull();
- ((VerticalLayout) p.getContent()).setSpacing(true);
- p.addComponent(new Label("This is a simple test case for "
+ pl.setSpacing(true);
+ pl.addComponent(new Label("This is a simple test case for "
+ "UriFragmentReader that can be used for"
+ " adding linking, back/forward button "
+ "and history support for ajax application. "));
}
sb.append("Application will change to them from uri "
+ "fragment or server initiated via textfield below.");
- p.addComponent(new Label(sb.toString()));
+ pl.addComponent(new Label(sb.toString()));
final TextField tf = new TextField(
"Type view name (will change to that "
+ "view and change the uri fragment)");
- p.addComponent(tf);
+ pl.addComponent(tf);
Button b = new Button("Go!");
- p.addComponent(b);
+ pl.addComponent(b);
b.addListener(new Button.ClickListener() {
@Override
import com.vaadin.ui.LegacyWindow;
import com.vaadin.ui.Panel;
import com.vaadin.ui.TextField;
+import com.vaadin.ui.VerticalLayout;
/**
* Key codes were converted to lower case on the server (overlapping special key
"Forumtests Application");
setMainWindow(mainWindow);
- Panel p = new Panel();
+ VerticalLayout pl = new VerticalLayout();
+ pl.setMargin(true);
+ Panel p = new Panel(pl);
mainWindow.addComponent(p);
Label l = new Label("Panel with F8 bound");
- p.addComponent(l);
+ pl.addComponent(l);
TextField f = new TextField();
- p.addComponent(f);
+ pl.addComponent(f);
p.addAction(new ShortcutListener("F8", KeyCode.F8, null) {
import com.vaadin.ui.Panel;
import com.vaadin.ui.Table;
import com.vaadin.ui.TextField;
+import com.vaadin.ui.VerticalLayout;
public class Ticket677 extends LegacyApplication {
}
}));
- root.setContent(new GridLayout(2, 3));
+ GridLayout content = new GridLayout(2, 3);
+ root.setContent(content);
main.addComponent(root);
TextField tf = new TextField("Enabled");
tf.setImmediate(true);
- root.addComponent(tf);
+ content.addComponent(tf);
tf = new TextField("Disabled");
tf.setImmediate(true);
tf.setEnabled(false);
- root.addComponent(tf);
+ content.addComponent(tf);
- root.addComponent(one);
+ VerticalLayout oneLayout = new VerticalLayout();
+ oneLayout.setMargin(true);
+ one.setContent(oneLayout);
+
+ content.addComponent(one);
tf = new TextField("Enabled");
tf.setImmediate(true);
- one.addComponent(tf);
+ oneLayout.addComponent(tf);
tf = new TextField("Disabled");
tf.setImmediate(true);
tf.setEnabled(false);
- one.addComponent(tf);
+ oneLayout.addComponent(tf);
+
+ VerticalLayout twoLayout = new VerticalLayout();
+ twoLayout.setMargin(true);
+ two.setContent(twoLayout);
- root.addComponent(two);
+ content.addComponent(two);
tf = new TextField("Enabled");
tf.setImmediate(true);
- two.addComponent(tf);
+ twoLayout.addComponent(tf);
tf = new TextField("Disabled");
tf.setImmediate(true);
tf.setEnabled(false);
- two.addComponent(tf);
+ twoLayout.addComponent(tf);
form = new Form();
form.setCaption("Enabled");
});
form.setItemDataSource(new BeanItem<MyBean>(new MyBean()));
- root.addComponent(form);
+ content.addComponent(form);
table = new Table("Enabled");
table.setPageLength(7);
});
table.setEditable(true);
- root.addComponent(table);
+ content.addComponent(table);
}
import com.vaadin.ui.HorizontalLayout;
import com.vaadin.ui.LegacyWindow;
import com.vaadin.ui.Panel;
+import com.vaadin.ui.VerticalLayout;
public class Ticket736 extends LegacyApplication {
f.getField("zip").setRequired(true);
// Debug form properties
- final Panel formProperties = new Panel("Form properties");
+ final VerticalLayout formPropertiesLayout = new VerticalLayout();
+ formPropertiesLayout.setMargin(true);
+ final Panel formProperties = new Panel("Form properties",
+ formPropertiesLayout);
formProperties.setWidth("200px");
final String[] visibleProps = { "required", "invalidAllowed",
"readOnly", "readThrough", "writeThrough", "invalidCommitted",
CheckBox b = new CheckBox(visibleProps[i],
new MethodProperty<Boolean>(f, visibleProps[i]));
b.setImmediate(true);
- formProperties.addComponent(b);
+ formPropertiesLayout.addComponent(b);
}
mainWin.addComponent(formProperties);
import com.vaadin.ui.Label;
import com.vaadin.ui.LegacyWindow;
import com.vaadin.ui.Panel;
+import com.vaadin.ui.VerticalLayout;
/**
* Provides sample directory based on application directory. If this fails then
return file;
}
// Add failure notification as an Panel to main window
- final Panel errorPanel = new Panel("Demo application error");
+ VerticalLayout errorLayout = new VerticalLayout();
+ errorLayout.setMargin(true);
+ final Panel errorPanel = new Panel("Demo application error",
+ errorLayout);
errorPanel.setStyleName("strong");
errorPanel.setComponentError(new SystemError(
"Cannot provide sample directory"));
- errorPanel.addComponent(new Label(errorMessage, ContentMode.HTML));
+ errorLayout.addComponent(new Label(errorMessage, ContentMode.HTML));
// Remove all components from applications main window
uI.removeAllComponents();
// Add error panel
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.DateField;
import com.vaadin.ui.Field;
import com.vaadin.ui.Form;
hl.setSizeFull();
hl.setSpacing(true);
- ComponentContainer part1 = createPart(
- "Empty required fields validation", true, false);
+ Panel part1 = createPart("Empty required fields validation", true,
+ false);
part1.setId("emptyFieldPart");
hl.addComponent(part1);
- ComponentContainer part2 = createPart(
+ Panel part2 = createPart(
"Empty required fields with failing validator", true, true);
part1.setId("validatedFieldPart");
hl.addComponent(part2);
- Panel panel = new Panel();
+ VerticalLayout panelLayout = new VerticalLayout();
+ panelLayout.setMargin(true);
+ Panel panel = new Panel(panelLayout);
panel.setSizeFull();
panel.setStyleName(Reindeer.PANEL_LIGHT);
- panel.addComponent(hl);
+ panelLayout.addComponent(hl);
addComponent(panel);
}
- private ComponentContainer createPart(String caption, boolean required,
+ private Panel createPart(String caption, boolean required,
boolean failValidator) {
VerticalLayout part = new VerticalLayout();
part.setMargin(true);