@Override
  public void afterViewChange(ViewChangeEvent event) {
    for (int i = 0; i < navbar.getComponentCount(); i++) {

      if (navbar.getComponent(i) instanceof Button) {
        final Button btn = (Button) navbar.getComponent(i);
        btn.removeStyleName(ValoTheme.BUTTON_BORDERLESS_COLORED);

        String view = (String) btn.getData();

        if (event.getViewName().equals(view)) {
          btn.addStyleName(ValoTheme.BUTTON_BORDERLESS_COLORED);
        }
      }
    }
  }
Exemple #2
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);
  }
  @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);
  }
Exemple #4
0
  private void updateList() {

    group.removeAllComponents();

    if (lists.size() > 0) {
      // Re-Populate view
      // List<TokkaList> lists = ((TokkaUI)getUI()).getLists();
      for (final TokkaList list : lists) {
        HorizontalLayout hl = new HorizontalLayout();
        hl.setWidth("100%");

        Label lbl = new Label(list.getName());
        lbl.setSizeUndefined();
        hl.addComponent(lbl);

        lbl = new Label(list.getUndoneItems() + "/" + list.getTotalItems());
        lbl.setSizeUndefined();
        hl.addComponent(lbl);

        hl.setExpandRatio(hl.getComponent(0), 1);

        hl.addLayoutClickListener(
            new LayoutClickListener() {

              @Override
              public void layoutClick(LayoutClickEvent event) {
                getNavigationManager().navigateTo(new ItemView(list, MainView.this));
              }
            });

        group.addComponent(hl);
      }
    } else {
      group.addComponent(new Label("No items added yet."));
    }
  }
  private void BuildNavigator() {
    navegador = new Navigator(parentUI, content);
    navegador.addView("/dashboard", DashboardView.class);

    for (String route : routes.keySet()) {
      navegador.addView("/" + route, routes.get(route));
    }
    String f = Page.getCurrent().getUriFragment();
    if (f != null && f.startsWith("!")) {
      f = f.substring(1);
    }
    if (f == null || f.equals("") || f.equals("/")) {
      navegador.navigateTo("/dashboard");
      menu.getComponent(0).addStyleName("selected");
      HelpManager.getInstance().showHelpFor(DashboardView.class);
    } else {
      navegador.navigateTo(f);
      HelpManager.getInstance().showHelpFor(routes.get(f));
      viewNameToMenuButton.get(f).addStyleName("selected");
    }

    navegador.addViewChangeListener(
        new ViewChangeListener() {
          @Override
          public boolean beforeViewChange(ViewChangeEvent event) {
            HelpManager.getInstance().closeAll();
            return true;
          }

          @Override
          public void afterViewChange(ViewChangeEvent event) {
            View newView = event.getNewView();
            HelpManager.getInstance().showHelpFor(newView);
          }
        });
  }