Example #1
0
 private int getMaxButtons() {
   int extraButtons = 0;
   if (app.getLAF().undoRedoSupported()) {
     extraButtons = 90;
   }
   if (app.showMenuBar()) {
     extraButtons += 90;
   }
   if (app.isExam()) {
     extraButtons += 30;
     if (!app.getExam().is3DAllowed()) {
       extraButtons += 55;
     }
     if (!app.getExam().isCASAllowed()) {
       extraButtons += 55;
     }
   }
   return ((int) app.getWidth() - extraButtons - 15) / 45;
 }
Example #2
0
  public void updateActionPanel() {
    rightButtonPanel.clear();
    boolean exam = app.isExam();
    setStyleName("examToolbar", exam);
    if (exam) {
      // We directly read the parameters to show the intention.
      // It may be possible that 3D is not supported from technical
      // reasons (e.g. the graphics card is problematic), but in such
      // cases we don't want to show that here.

      if (!app.getExam().isCASAllowed()) {
        Label nocas = new Label("CAS");
        nocas.getElement().getStyle().setTextDecoration(TextDecoration.LINE_THROUGH);
        nocas.getElement().setClassName("timer");
        rightButtonPanel.add(nocas);
      }
      if (!app.getExam().is3DAllowed()) {
        Label no3d = new Label("3D");
        no3d.getElement().getStyle().setTextDecoration(TextDecoration.LINE_THROUGH);
        no3d.getElement().setClassName("timer");
        rightButtonPanel.add(no3d);
      }
      rightButtonPanel.add(getTimer());
    }

    if (app.getLAF().undoRedoSupported()) {
      addUndoPanel();
    }
    if (app.getArticleElement().getDataParamShowMenuBar(false)
        || app.getArticleElement().getDataParamApp()) {
      PerspectiveResources pr =
          ((ImageFactory) GWT.create(ImageFactory.class)).getPerspectiveResources();
      this.menuBarShowing = true;
      // openMenuButton = new StandardButton(pr.button_open_menu(), null,
      // 32);
      //
      // openMenuButton.addFastClickHandler(new FastClickHandler() {
      // @Override
      // public void onClick(Widget source) {
      // app.hideKeyboard();
      // app.closePopups();
      // GGWToolBar.this.app.toggleMenu();
      // }

      openMenuButton = new StandardButton(pr.menu_header_open_menu(), null, 32);

      openMenuButton.getUpHoveringFace().setImage(getImage(pr.menu_header_open_menu_hover(), 32));

      openMenuButton.addFastClickHandler(
          new FastClickHandler() {
            @Override
            public void onClick(Widget source) {
              app.hideKeyboard();
              app.closePopups();
              GGWToolBar.this.app.toggleMenu();
            }
          });

      openMenuButton.addDomHandler(
          new KeyUpHandler() {
            public void onKeyUp(KeyUpEvent event) {
              if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER) {
                GGWToolBar.this.app.toggleMenu();
              }
              if (event.getNativeKeyCode() == KeyCodes.KEY_LEFT) {
                GGWToolBar.this.selectMenuButton(0);
              }
              if (event.getNativeKeyCode() == KeyCodes.KEY_RIGHT) {
                GGWToolBar.this.toolBar.selectMenu(0);
              }
            }
          },
          KeyUpEvent.getType());

      if (!exam && app.enableFileFeatures()) {
        // openSearchButton = new
        // StandardButton(pr.button_open_search(),
        // null, 32);
        // openSearchButton.addFastClickHandler(new FastClickHandler() {
        // @Override
        // public void onClick(Widget source) {
        // app.openSearch(null);
        // }
        // });

        openSearchButton = new StandardButton(pr.menu_header_open_search(), null, 32);
        openSearchButton.getUpFace().setImage(getImage(pr.menu_header_open_search(), 32));
        openSearchButton
            .getUpHoveringFace()
            .setImage(getImage(pr.menu_header_open_search_hover(), 32));

        openSearchButton.addFastClickHandler(
            new FastClickHandler() {
              @Override
              public void onClick(Widget source) {
                app.openSearch(null);
              }
            });

        openSearchButton.addDomHandler(
            new KeyUpHandler() {
              public void onKeyUp(KeyUpEvent event) {
                if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER) {
                  app.openSearch(null);
                }
                if (event.getNativeKeyCode() == KeyCodes.KEY_RIGHT) {
                  GGWToolBar.this.selectMenuButton(1);
                }
                if (event.getNativeKeyCode() == KeyCodes.KEY_LEFT) {
                  GGWToolBar.this.toolBar.selectMenu(-1);
                }
              }
            },
            KeyUpEvent.getType());

        this.rightButtonPanel.add(openSearchButton);
      }
      this.rightButtonPanel.add(openMenuButton);
    }
  }
Example #3
0
 private void stopCheating() {
   if (app.getExam() != null) {
     app.getExam().stopCheating();
   }
 }