Пример #1
0
  private void assertTextArea(VerticalLayout layout) {
    TextArea ta = (TextArea) layout.getComponent(2);

    assertThat(ta.getCaption(), is("Text area"));
    assertThat(ta.getWidth(), is(300f));
    assertThat(ta.getHeight(), is(200f));
  }
Пример #2
0
  private ButtonTabImpl getButtonById(String viewId) {
    for (int i = 0; i < navigatorContainer.getComponentCount(); i++) {
      ButtonTabImpl button = (ButtonTabImpl) navigatorContainer.getComponent(i);
      if (viewId.equals(button.getTabId())) {
        return button;
      }
    }

    return null;
  }
Пример #3
0
  public void addTab(
      Component component, String id, int level, String caption, String link, Resource resource) {
    if (!hasTab(id)) {
      final ButtonTabImpl button = new ButtonTabImpl(id, level, caption, link);

      button.addClickListener(
          new ClickListener() {
            private static final long serialVersionUID = 1L;

            @Override
            public void buttonClick(ClickEvent event) {
              if (!event.isCtrlKey() && !event.isMetaKey()) {
                if (selectedButton != button) {
                  clearTabSelection(true);
                  selectedButton = button;
                  selectedButton.addStyleName(TAB_SELECTED_STYLENAME);
                  selectedComp = compMap.get(button.getTabId());
                }
                fireTabChangeEvent(new SelectedTabChangeEvent(VerticalTabsheet.this));
              } else {
                Page.getCurrent().open(button.link, "_blank", false);
              }
            }
          });

      if (resource == null) {
        setDefaulButtonIcon(button, false);
      } else {
        button.setIcon(resource);
      }
      button.setStyleName(TAB_STYLENAME);
      button.setWidth("90%");

      if (button.getLevel() > 0) {
        int insertIndex = 0;
        for (int i = 0; i < navigatorContainer.getComponentCount(); i++) {
          ButtonTabImpl buttonTmp = (ButtonTabImpl) navigatorContainer.getComponent(i);
          if (buttonTmp.getLevel() > level) {
            break;
          } else {
            insertIndex++;
          }
        }
        navigatorContainer.addComponent(button, insertIndex);
        navigatorContainer.setComponentAlignment(button, Alignment.MIDDLE_CENTER);
      } else {
        navigatorContainer.addComponent(button);
        navigatorContainer.setComponentAlignment(button, Alignment.MIDDLE_CENTER);
      }

      TabImpl tabImpl = new TabImpl(id, caption, component);
      compMap.put(id, tabImpl);
    }
  }
Пример #4
0
  @Test
  public void rootChildHasCorrectComponents() {
    Component root = ctx.getRootComponent();
    VerticalLayout vlayout = (VerticalLayout) root;
    HorizontalLayout hlayout = (HorizontalLayout) vlayout.getComponent(0);

    assertThat(hlayout.getComponentCount(), is(5));
    assertThat(hlayout.getComponent(0).getCaption(), is("FooBar"));
    assertThat(hlayout.getComponent(1).getCaption(), is("Native click me"));
    assertThat(hlayout.getComponent(2).getCaption(), is("Another button"));
    assertThat(hlayout.getComponent(3).getCaption(), is("Yet another button"));
    assertThat(hlayout.getComponent(4).getCaption(), is("Click me"));
    assertThat(hlayout.getComponent(4).getWidth(), is(150f));

    // Check the remaining two components of the vertical layout
    assertTextField(vlayout);
    assertTextArea(vlayout);
  }
Пример #5
0
  @Override
  protected void setup(VaadinRequest request) {
    TestUtils.injectCSS(this, ".hugemargin { margin: 10px 20px !important; }");

    HorizontalLayout hl = new HorizontalLayout();
    addLayoutTest(hl);
    hl.setExpandRatio(hl.getComponent(0), 1.0f);
    hl.setExpandRatio(hl.getComponent(2), 0.5f);
    VerticalLayout vl = new VerticalLayout();
    addLayoutTest(vl);
    vl.setExpandRatio(vl.getComponent(0), 1.0f);
    vl.setExpandRatio(vl.getComponent(2), 0.5f);

    GridLayout gl = new GridLayout(2, 1);
    addLayoutTest(gl);
    gl.setColumnExpandRatio(0, 1.0f);
    gl.setRowExpandRatio(0, 1.0f);
    gl.setColumnExpandRatio(1, 0.5f);
    gl.setRowExpandRatio(1, 0.5f);
  }
Пример #6
0
  private void assertTextField(VerticalLayout vlayout) {
    TextField tf = (TextField) vlayout.getComponent(1);

    assertThat(tf.getCaption(), is("Text input"));
  }