예제 #1
0
 private static void assertUniqueIds(Set<Object> ids, MenuItem item) {
   int id = item.getId();
   System.out.println("Item " + item.getText() + ", id: " + id);
   Assert.assertFalse(ids.contains(id));
   ids.add(id);
   if (item.getChildren() != null) {
     for (MenuItem subItem : item.getChildren()) {
       assertUniqueIds(ids, subItem);
     }
   }
 }
예제 #2
0
        public void menuSelected(MenuItem selectedItem) {
          if (selectedItem.getText().equals("Cadastrar")) {
            SsamUsuario U = new SsamUsuario();
            Window mainWindow3 = new Window("Cadastrar");
            // System.out.println("PARENT " + getWindow().getParent());
            mainWindow3.setWidth(1500, Window.UNITS_PIXELS);
            mainWindow3.setHeight(1500, Window.UNITS_PIXELS);
            mainWindow3.addComponent(U);
            getWindow().getParent().addWindow(mainWindow3);

          } else if (selectedItem.getText().equals("Consultar")) {
            SsamConsulta U;
            try {
              U = new SsamConsulta(verificaTpUsuario(Logou));
              Window mainWindow3 = new Window("Consultar");
              // System.out.println("PARENT " + getWindow().getParent());
              mainWindow3.setWidth(1200, Window.UNITS_PIXELS);
              mainWindow3.setHeight(1000, Window.UNITS_PIXELS);
              mainWindow3.addComponent(U);
              getWindow().getParent().addWindow(mainWindow3);
            } catch (SQLException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
            }
          } else if (selectedItem.getText().equals("Seleção")) {
            SsamSelecao S;
            SelecaoDao aprovados = new SelecaoDao();
            try {
              S = new SsamSelecao(aprovados.calcula(), aprovados.getNome());
              Window mainWindow3 = new Window("Seleção");
              mainWindow3.setWidth(1200, Window.UNITS_PIXELS);
              mainWindow3.setHeight(1000, Window.UNITS_PIXELS);
              mainWindow3.addComponent(S);
              getWindow().getParent().addWindow(mainWindow3);

            } catch (SQLException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
            }

            ///// //Colocar na tela SSamSelecao

          } else if (selectedItem.getText().equals("Alterar Senha")) {
            SsamAlterarSenha U = new SsamAlterarSenha();
            Window mainWindow3 = new Window("Alterar Senha");
            // System.out.println("PARENT " + getWindow().getParent());
            mainWindow3.setWidth(400, Window.UNITS_PIXELS);
            mainWindow3.setHeight(300, Window.UNITS_PIXELS);
            mainWindow3.addComponent(U);
            getWindow().getParent().addWindow(mainWindow3);
          }
        }
예제 #3
0
  protected void initSortMenu() {
    MenuBar menuBar = new MenuBar();
    menuBar.addStyleName(ExplorerLayout.STYLE_SEARCHBOX_SORTMENU);

    // TODO: Adding types of sorting manually and listener/events
    MenuItem rootItem = menuBar.addItem("Sort by", null);
    rootItem.addItem("Id", null);
    rootItem.addItem("Name", null);
    rootItem.addItem("Due date", null);
    rootItem.addItem("Creation date", null);

    layout.addComponent(menuBar);
    layout.setComponentAlignment(menuBar, Alignment.MIDDLE_RIGHT);
  }
예제 #4
0
  @Before
  public void setUp() {
    menuBar = new MenuBar();
    menuFile = menuBar.addItem("File", this);
    menuEdit = menuBar.addItem("Edit", this);
    menuEditCopy = menuEdit.addItem("Copy", this);
    menuEditCut = menuEdit.addItem("Cut", this);
    menuEditPaste = menuEdit.addItem("Paste", this);
    menuEdit.addSeparator();
    menuEditFind = menuEdit.addItem("Find...", this);
    menuFileOpen = menuFile.addItem("Open", this);
    menuFileSave = menuFile.addItem("Save", this);
    menuFile.addSeparator();
    menuFileExit = menuFile.addItem("Exit", this);

    menuItems.add(menuFile);
    menuItems.add(menuEdit);
    menuItems.add(menuEditCopy);
    menuItems.add(menuEditCut);
    menuItems.add(menuEditPaste);
    menuItems.add(menuEditFind);
    menuItems.add(menuFileOpen);
    menuItems.add(menuFileSave);
    menuItems.add(menuFileExit);
  }
예제 #5
0
  @Test
  public void testMenubarIdUniqueness() {
    // Ids within a menubar must be unique
    assertUniqueIds(menuBar);

    menuBar.removeItem(menuFile);
    MenuItem file2 = menuBar.addItem("File2", this);
    MenuItem file3 = menuBar.addItem("File3", this);
    MenuItem file2sub = file2.addItem("File2 sub menu", this);
    menuItems.add(file2);
    menuItems.add(file2sub);
    menuItems.add(file3);

    assertUniqueIds(menuBar);
  }
  @Override
  protected void setup() {
    Command c =
        new Command() {
          public void menuSelected(MenuItem selectedItem) {
            getMainWindow().showNotification(selectedItem.getText());
          }
        };

    MenuBar root = new MenuBar();

    MenuItem submenu = root.addItem("Hello", null);
    submenu.addItem("World", c);

    root.addItem("World", c);
    addComponent(root);
  }
예제 #7
0
  /**
   * Constructor, passing the Vaadin application page
   *
   * @param ui MainUI application page
   */
  public HeaderComponent(MainUI ui) {
    setHeight("50px");
    setStyleName("header");

    final HorizontalLayout bannerArea = new HorizontalLayout();
    bannerArea.setStyleName("menuArea");
    bannerArea.setSizeFull();

    final ThemeResource resource = new ThemeResource("img/intec-logo.gif.png");
    final Image bannerImg = new Image();
    bannerImg.setAlternateText("Intec");
    bannerImg.setHeight("50px");
    bannerImg.setDescription("Intec Logo");
    bannerImg.setSource(resource);
    bannerImg.setWidth(null);
    bannerImg.setStyleName("bannerImg");

    setMenubar(new MenuBar());
    getMenubar().setStyleName(ValoTheme.MENU_SUBTITLE);
    getMenubar().addStyleName("valo-menu-subtitle-indent");
    getMenubar().setWidth(100, Unit.PERCENTAGE);

    if (!"Anonymous".equals(getUserName())) {
      final MenuItem logout = menubar.addItem("Logout", null);
      logout.setStyleName("menuRight");
    }

    final MenuItem userItem = menubar.addItem(getUserName(), null);
    userItem.setStyleName("menuRight");

    bannerArea.addComponents(bannerImg, menubar);
    bannerArea.setExpandRatio(menubar, 1);
    addComponent(bannerArea);
    setExpandRatio(bannerArea, 1);
    setSizeFull();
  }
예제 #8
0
  private void BuildSettings(String user) {
    Command cmd =
        new Command() {
          @Override
          public void menuSelected(MenuItem selectedItem) {
            Notification.show("Não implementado nesta versão.");
          }
        };

    MenuBar menubar = new MenuBar();
    MenuItem settingsMenu = menubar.addItem(user, new ThemeResource("img/profile-pic.png"), null);
    settingsMenu.addItem("Configurações", cmd);
    settingsMenu.addItem("Preferências", cmd);
    settingsMenu.addSeparator();
    settingsMenu.addItem("Minha conta", cmd);
    settingsMenu.addItem("Sair", cmd);

    settings.addComponent(menubar);
    settings.setMargin(true);
  }
예제 #9
0
  private Component createContentWrapper(final Component content) {
    final CssLayout slot = new CssLayout();
    slot.setWidth("100%");
    slot.addStyleName("dashboard-panel-slot");

    CssLayout card = new CssLayout();
    card.setWidth("100%");
    card.addStyleName(ValoTheme.LAYOUT_CARD);

    HorizontalLayout toolbar = new HorizontalLayout();
    toolbar.addStyleName("dashboard-panel-toolbar");
    toolbar.setWidth("100%");
    toolbar.setSpacing(false);

    Label caption = new Label(content.getCaption());
    caption.addStyleName(ValoTheme.LABEL_H4);
    caption.addStyleName(ValoTheme.LABEL_COLORED);
    caption.addStyleName(ValoTheme.LABEL_NO_MARGIN);
    content.setCaption(null);

    MenuBar tools = new MenuBar();
    tools.addStyleName(ValoTheme.MENUBAR_BORDERLESS);
    MenuItem max =
        tools.addItem(
            "",
            FontAwesome.EXPAND,
            new Command() {

              @Override
              public void menuSelected(final MenuItem selectedItem) {
                if (!slot.getStyleName().contains("max")) {
                  selectedItem.setIcon(FontAwesome.COMPRESS);
                  toggleMaximized(slot, true);
                } else {
                  slot.removeStyleName("max");
                  selectedItem.setIcon(FontAwesome.EXPAND);
                  toggleMaximized(slot, false);
                }
              }
            });
    max.setStyleName("icon-only");
    MenuItem root = tools.addItem("", FontAwesome.COG, null);
    root.addItem(
        "Configure",
        new Command() {
          @Override
          public void menuSelected(final MenuItem selectedItem) {
            Notification.show("Not implemented in this demo");
          }
        });
    root.addSeparator();
    root.addItem(
        "Close",
        new Command() {
          @Override
          public void menuSelected(final MenuItem selectedItem) {
            Notification.show("Not implemented in this demo");
          }
        });

    toolbar.addComponents(caption, tools);
    toolbar.setExpandRatio(caption, 1);
    toolbar.setComponentAlignment(caption, Alignment.MIDDLE_LEFT);

    card.addComponents(toolbar, content);
    slot.addComponent(card);
    return slot;
  }