Esempio n. 1
0
  @Override
  protected void init(VaadinRequest request) {
    initViews();
    initNavigator();
    initDefaultUser();

    navigator.navigateTo("login"); // First load is a login screen
  }
Esempio n. 2
0
  @Override
  protected void init(VaadinRequest request) {
    setLocale(Locale.ENGLISH);
    // Let's register a custom error handler to make the 'access denied' messages a bit friendlier.
    setErrorHandler(
        new DefaultErrorHandler() {
          @Override
          public void error(com.vaadin.server.ErrorEvent event) {
            if (SecurityExceptionUtils.isAccessDeniedException(event.getThrowable())) {
              Notification.show("Sorry, you don't have access to do that.");
            } else {
              super.error(event);
            }
          }
        });

    VerticalLayout layout = new VerticalLayout();
    Panel viewContent = new Panel();
    MenuBar menu = new MenuBar();
    menu.addStyleName("navigation-menu");

    layout.addComponents(menu, viewContent);
    layout.setSizeFull();
    viewContent.setSizeFull();
    layout.setExpandRatio(viewContent, 1);

    menu.addItem("Trading Area", e -> onDashboardClicked());
    menu.addItem("Users", e -> onCustomersClicked());

    navigator = new Navigator(this, viewContent);
    springViewProvider.setAccessDeniedViewClass(AccessDeniedView.class);
    navigator.addProvider(springViewProvider);
    navigator.setErrorView(ErrorView.class);
    setContent(layout);
    String state = navigator.getState();
    if (state != null && !state.isEmpty()) {
      navigator.navigateTo(state);
    } else {
      navigator.navigateTo(TradingAreaView.NAME);
    }
  }
Esempio n. 3
0
 @Override
 protected void init(VaadinRequest request) {
   setTheme("valo");
   getPage().setTitle("Aruba Networks");
   MainView mainview = new MainView();
   navigator = new Navigator(this, this);
   navigator.addView("login", new LoginView());
   navigator.addView("main", mainview);
   // navigator.addView("Dataset1", new Dataset1View());
   // navigator.addView("Dataset2",new Dataset2View());
   navigator.navigateTo("main");
 }
Esempio n. 4
0
  private void setupNavigator() {
    navigator = new Navigator(DemoUI.getCurrent(), content);

    registerViews();

    // Add view change listeners so we can do things like select the correct menu item and update
    // the page title
    navigator.addViewChangeListener(navBar);
    navigator.addViewChangeListener(new PageTitleUpdater());

    navigator.navigateTo(navigator.getState());
  }
Esempio n. 5
0
  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);
          }
        });
  }
  public MainView() {
    Navigator navigator = new Navigator(UI.getCurrent(), scroll_panel);
    navigator.addView(DashboardView.VIEW_NAME, DashboardView.class);
    navigator.addView(OrderView.VIEW_NAME, OrderView.class);
    navigator.addView(AboutView.VIEW_NAME, AboutView.class);
    if (navigator.getState().isEmpty()) {
      navigator.navigateTo(DashboardView.VIEW_NAME);
    }

    //		menuButton1.addClickListener(event -> scroll_panel.setContent(new DashboardView()));
    //        menuButton2.addClickListener(event -> scroll_panel.setContent(new OrderView()));
    //        menuButton3.addClickListener(event -> scroll_panel.setContent(new AboutView()));

    menuButton1.addClickListener(event -> doNavigate(DashboardView.VIEW_NAME));
    menuButton2.addClickListener(event -> doNavigate(OrderView.VIEW_NAME));
    menuButton3.addClickListener(event -> doNavigate(AboutView.VIEW_NAME));
  }
Esempio n. 7
0
  /**
   * Internal initialization method, should not be overridden. This method is not declared as final
   * because that would break compatibility with e.g. CDI.
   *
   * @param request the initialization request
   * @param uiId the id of the new ui
   */
  public void doInit(VaadinRequest request, int uiId) {
    if (this.uiId != -1) {
      throw new IllegalStateException("UI id has already been defined");
    }
    this.uiId = uiId;

    // Actual theme - used for finding CustomLayout templates
    theme = request.getParameter("theme");

    getPage().init(request);

    // Call the init overridden by the application developer
    init(request);

    Navigator navigator = getNavigator();
    if (navigator != null) {
      // Kickstart navigation if a navigator was attached in init()
      navigator.navigateTo(navigator.getState());
    }
  }
 @Override
 public void buttonGo() {
   Navigator navigator = UI.getCurrent().getNavigator();
   navigator.navigateTo("/inventorymanagement/" + function.VIEW_INVENTORY_CONSUMPTION);
 }
Esempio n. 9
0
 private void onDashboardClicked() {
   navigator.navigateTo(TradingAreaView.NAME);
 }
Esempio n. 10
0
 private void onCustomersClicked() {
   navigator.navigateTo("users");
 }