예제 #1
0
  /**
   * 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);
  }
예제 #2
0
  private final void init() {

    if (content instanceof AbstractOrderedLayout) {
      ((AbstractOrderedLayout) content).setSpacing(true);
      ((AbstractOrderedLayout) content).setMargin(true);
    }
    if (content instanceof GridLayout) {
      addStyleName("marginTop");
    }

    if (null != content) {
      mainLayout.addComponent(content);
      mainLayout.setExpandRatio(content, 1.0F);
    }

    createMandatoryLabel();

    final HorizontalLayout buttonLayout = createActionButtonsLayout();
    mainLayout.addComponent(buttonLayout);
    mainLayout.setComponentAlignment(buttonLayout, Alignment.TOP_CENTER);

    setCaption(caption);
    setCaptionAsHtml(true);
    setContent(mainLayout);
    setResizable(false);
    center();
    setModal(true);
    addStyleName("fontsize");
    setOrginaleValues();
    addComponentListeners();
  }
  @Override
  protected Component getRenderComponent(final AbstractOrderedLayout orderedLayout) {
    if (GroupType.COLLAPSIBLE.equals(getVElement().getGroupType())) {
      final VerticalLayout mainLayout = new VerticalLayout();
      final NativeButton collapseButton =
          new NativeButton(
              StringUtils.EMPTY,
              new Button.ClickListener() {

                @Override
                public void buttonClick(ClickEvent event) {
                  final boolean switchVisible = !orderedLayout.isVisible();
                  setCollapseStyle(event.getButton(), switchVisible);
                  orderedLayout.setVisible(switchVisible);
                }
              });
      collapseButton.setWidth(100, Unit.PERCENTAGE);
      mainLayout.addComponent(collapseButton);
      mainLayout.addComponent(orderedLayout);
      orderedLayout.setMargin(true);
      orderedLayout.setSpacing(true);
      orderedLayout.setVisible(getVElement().isCollapsed());
      setCollapseStyle(collapseButton, getVElement().isCollapsed());
      mainLayout.addStyleName(GROUP_STYLE_NAME);
      return mainLayout;
    }
    return super.getRenderComponent(orderedLayout);
  }
예제 #4
0
  /** @return the Panel containing input text fields */
  public Component createInputPanel() {

    Panel inputPanel = new Panel("Send Message");

    inputPanel.addComponent(createPanelLayout("App URL", urlTextField, "http://127.0.0.1:8080/"));
    inputPanel.addComponent(createPanelLayout("Phone #", phoneNoField, "94721345678"));
    inputPanel.addComponent(createPanelLayout("Message ", messageField, "Message Content"));

    Button sendButton = createSendMsgButton();
    inputPanel.addComponent(sendButton);
    final AbstractOrderedLayout content = (AbstractOrderedLayout) inputPanel.getContent();
    content.setSpacing(true);
    content.setComponentAlignment(sendButton, Alignment.BOTTOM_RIGHT);

    return inputPanel;
  }
  public void validateTextFields(AbstractField component, AbstractOrderedLayout layout) {
    try {
      component.setRequiredError(REQUIRED_MESSAGE);
      component.validate();
    } catch (Validator.EmptyValueException e) {
      layout.getWindow().showNotification(EMPTY_FIELDS.getNotification());
    } catch (Validator.InvalidValueException e) {

    }
  }
  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();
  }
예제 #7
0
  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);
  }
예제 #8
0
  @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));
  }
예제 #9
0
  @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));
 }
예제 #11
0
 @Override
 public void add(Component component, int index) {
   layout.addComponent(component, index);
 }
예제 #12
0
 @Override
 public void remove(int index) {
   layout.removeComponent(layout.getComponent(index));
 }
예제 #13
0
 @Override
 public int size() {
   return layout.getComponentCount();
 }