/** * Creates a new Label object. * * @param panel the panel * @param content the content */ public static void createHeader2Label(final AbstractOrderedLayout panel, final String content) { final Label label = new Label(content); label.setStyleName("Level2Header"); panel.addComponent(label); panel.setExpandRatio(label, ContentRatio.SMALL); }
public PerformanceTestLabelsAndOrderedLayouts() { main = new VerticalLayout(); setCompositionRoot(main); addInfo(); result = new Label(); main.addComponent(result); main.addComponent( new Button( "click when rendered", new ClickListener() { @Override public void buttonClick(ClickEvent event) { endTest(); } })); main.addComponent( new Button( "Click for layout repaint (cached components)", new ClickListener() { @Override public void buttonClick(ClickEvent event) { testContainer.markAsDirty(); } })); testContainer = new VerticalLayout(); for (int i = 0; i < INITIAL_COMPONENTS; i++) { Label l = new Label("foo" + i); testContainer.addComponent(l); } main.addComponent(testContainer); startTest(); }
@Test public void testAlignment() { AbstractOrderedLayout layout = new AbstractOrderedLayout() {}; AbstractComponent first = new AbstractComponent() {}; AbstractComponent second = new AbstractComponent() {}; layout.addComponent(first); layout.addComponent(second); Alignment alignment = Alignment.BOTTOM_RIGHT; layout.setComponentAlignment(first, alignment); layout.setComponentAlignment(second, Alignment.MIDDLE_CENTER); AbstractComponent replace = new AbstractComponent() {}; layout.replaceComponent(first, replace); Assert.assertEquals( "Alignment for replaced component is not " + "the same as for previous one", alignment, layout.getComponentAlignment(replace)); }
private void createUI(AbstractOrderedLayout layout) { Button b = new Button("This is a button"); CheckBox cb = new CheckBox("This is a checkbox"); cb.setImmediate(true); setTheme("tests-tickets"); layout.setStyleName("mylayout"); status = new Label("Result:"); layout.addComponent(status); layout.setSpacing(true); layout.setMargin(true); layout.addComponent(b); layout.addComponent(cb); layout.addComponent(new Label("a")); layout.addComponent(new Label("b")); layout.addComponent(new Label("c")); checkButton(Button.class); checkCheckBox(CheckBox.class); checkDataBinding(CheckBox.class); }
@Test public void testExpandRatio() { AbstractOrderedLayout layout = new AbstractOrderedLayout() {}; AbstractComponent first = new AbstractComponent() {}; AbstractComponent second = new AbstractComponent() {}; layout.addComponent(first); layout.addComponent(second); int ratio = 2; layout.setExpandRatio(first, ratio); layout.setExpandRatio(second, 1); AbstractComponent replace = new AbstractComponent() {}; layout.replaceComponent(first, replace); Assert.assertEquals( "Expand ratio for replaced component is not " + "the same as for previous one", ratio, layout.getExpandRatio(replace), 0.0001); }
private void addInfo() { main.addComponent(new Label(DESCRIPTION, ContentMode.HTML)); }
@Override public void add(Component component, int index) { layout.addComponent(component, index); }