コード例 #1
0
ファイル: MainView.java プロジェクト: johndevs/tokka-poc
  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."));
    }
  }
コード例 #2
0
  @SuppressWarnings("serial")
  private void buildview() {
    // TODO Auto-generated method stub
    CssLayout cs = new CssLayout();

    VerticalComponentGroup verticalComponentGroup = new VerticalComponentGroup();
    VerticalComponentGroup vcg = new VerticalComponentGroup();
    // HorizontalControlGroup to HorizontalButtonGroup by ranji
    NavigationButton filltray = new NavigationButton();
    HorizontalButtonGroup hg = new HorizontalButtonGroup();
    HorizontalButtonGroup hg1 = new HorizontalButtonGroup();
    HorizontalButtonGroup hg2 = new HorizontalButtonGroup();

    filltray.setHeight("3cm");
    filltray.setWidth("100%");

    filltray.setCaption("Fill Tray");
    filltray.setStyleName("filltray");

    // optiongroup.setStyleName("optiongrp");
    // optiongroup.addItem("Fill Tray by Patient");
    // optiongroup.addItem("Fill Tray by Medicine");
    // optiongroup.setHeight("2cm");
    // optiongroup.setVisible(true);
    verticalComponentGroup.addComponent(filltray);
    verticalComponentGroup.addComponent(new Label(""));
    NavigationButton Dispense = new NavigationButton();
    Dispense.setHeight("3cm");
    Dispense.setWidth("100%");
    Dispense.setCaption("Dispense");
    Dispense.setStyleName("dispense");

    vcg.addComponent(Dispense);

    filltray.addClickListener(
        new NavigationButtonClickListener() {

          @Override
          public void buttonClick(NavigationButtonClickEvent event) {
            // TODO Auto-generated method stub
            getNavigationManager().navigateTo(new FillTray());
            // optiongroup.setVisible(true);
          }
        });

    Dispense.addClickListener(
        new NavigationButtonClickListener() {

          @Override
          public void buttonClick(NavigationButtonClickEvent event) {
            // TODO Auto-generated method stub
            dbhelper db = new dbhelper();
            Container dispensing = db.getDispenser();
            Table table = new Table();
            table.setContainerDataSource(dispensing);
            if (table.firstItemId() == null) {
              UI.getCurrent().setDescription("Tray is Empty !");
            } else {
              getNavigationManager().navigateTo(new Dispense());
            }
            popmessage();
          }

          private void popmessage() {
            // TODO Auto-generated method stub
            Popover message = new Popover();
            message.setCaption("Please Fill the Tray First");
          }
        });
    // Embedded b = new Embedded("",new com.vaadin.server.ThemeResource("fill1.JPG"));
    // b.setHeight("100%");
    // b.setWidth("100%");
    // Embedded c = new Embedded("",new com.vaadin.server.ThemeResource("fill2.JPG"));
    // c.setHeight("100%");
    // c.setWidth("100%");
    // Embedded d = new Embedded("",new com.vaadin.server.ThemeResource("fill3.JPG"));
    // d.setHeight("100%");
    // d.setWidth("100%");
    // hg.addComponent(b);
    hg.setHeight("100%");
    hg.setWidth("33%");
    // hg1.addComponent(c);
    hg1.setHeight("100%");
    hg1.setWidth("33%");

    // hg2.addComponent(d);
    hg2.setHeight("100%");
    hg2.setWidth("33%");
    //	vcg.addComponent(optiongroup);
    //  cs.addComponent(optiongroup);
    cs.addComponent(verticalComponentGroup);
    cs.addComponent(vcg);
    cs.addComponent(hg);
    cs.addComponent(hg1);
    cs.addComponent(hg2);
    setContent(cs);
  }