Ejemplo n.º 1
0
 public void onClick(ClickEvent e) {
   Element target = e.getNativeEvent().getEventTarget().cast();
   boolean isEditing = assignmentsTable.isVisible();
   if (target == btApply.getElement()) {
     if (isEditing) {
       hide();
       app.getActiveEuclidianView().requestFocusInWindow();
       app.storeUndoInfo();
       app.getKernel().notifyRepaint();
     } else {
       assignmentsTable.setVisible(true);
       checkAssignmentsTable.setVisible(false);
       btTest.setText(app.getPlain("Test"));
       btApply.setText(app.getPlain("OK"));
       hide();
       setGlassEnabled(true);
       center();
     }
   } else if (target == btTest.getElement()) {
     if (isEditing) {
       assignmentsTable.setVisible(false);
       checkAssignmentsTable.setVisible(true);
       check();
       btTest.setText(app.getPlain("Check"));
       btApply.setText(app.getPlain("Back"));
       hide();
       setGlassEnabled(false);
       center();
     } else {
       check();
     }
   }
 }
Ejemplo n.º 2
0
  private void createGUI() {

    getCaption().setText(app.getMenu("Exercise.CreateNew"));

    setWidget(mainWidget = new VerticalPanel());
    addDomHandlers(mainWidget);
    assignmentsTable = new FlexTable();
    FlexCellFormatter cellFormatter = assignmentsTable.getFlexCellFormatter();
    cellFormatter.setColSpan(0, 1, 2);

    assignmentsTable.setWidget(0, 1, new Label(app.getPlain("Tool")));
    assignmentsTable.setWidget(0, 2, new Label(app.getPlain("HintForCorrect")));
    assignmentsTable.setWidget(0, 3, new Label(app.getPlain("Fraction")));

    createAssignmentsTable();
    checkAssignmentsTable = new FlexTable();
    checkAssignmentsTable.setVisible(false);

    mainWidget.add(assignmentsTable);
    mainWidget.add(checkAssignmentsTable);

    addList = new UnorderedList();
    addDomHandlers(addList);
    // addIcon = new ListItem();
    Image addIcon = new Image(GuiResources.INSTANCE.menu_icon_file_new());
    ListItem addListItem = new ListItem();
    addListItem.addStyleName("toolbar_item");
    addListItem.add(addIcon);
    addList.add(addListItem);

    userAddModes = new ToolbarSubemuW(app, 1);
    userAddModes.addStyleName("toolbar_item");
    userAddModes.setVisible(false);
    for (int i = 0; i < app.getKernel().getMacroNumber(); i++) {
      if (!exercise.usesMacro(i)) {
        ListItem item = userAddModes.addItem(i + EuclidianConstants.MACRO_MODE_ID_OFFSET);
        addDomHandlers(item);
      }
    }
    addList.add(userAddModes);
    mainWidget.add(addList);

    mainWidget.add(bottomWidget = new FlowPanel());
    bottomWidget.setStyleName("DialogButtonPanel");

    btApply = new Button(app.getPlain("OK"));
    btApply.addClickHandler(this);
    btApply.getElement().getStyle().setMargin(3, Style.Unit.PX);

    addCancelButton();

    btTest = new Button(app.getPlain("Test"));
    btTest.addClickHandler(this);
    btTest.getElement().getStyle().setMargin(3, Style.Unit.PX);

    bottomWidget.add(btTest);
    bottomWidget.add(btApply);
    // bottomWidget.add(btCancel);

  }
Ejemplo n.º 3
0
  private void updateDescription() {
    // ignoreActions = true;
    String[] modes =
        new String[] {app.getPlain("Value"), app.getPlain("Definition"), app.getPlain("Command")};
    description.clear();

    for (int i = 0; i < modes.length; i++) {
      description.addItem(app.getPlain(modes[i]));
    }

    int descMode = app.getKernel().getAlgebraStyle();
    description.setSelectedIndex(descMode);
    // ignoreActions = false;
  }
Ejemplo n.º 4
0
  private void createExportMenu() {
    MenuBar menu = new MenuBar(true);
    MenuItem miToGraphich =
        new MenuItem(
            app.getMenu("CopyToGraphics"),
            new Command() {

              public void execute() {
                exportToEV();
              }
            });

    menu.addItem(miToGraphich);

    if (app.getLAF().copyToClipboardSupported()) {
      MenuItem miAsPicture =
          new MenuItem(
              app.getPlain("ExportAsPicture"),
              new Command() {

                public void execute() {
                  exportAsPicture();
                }
              });
      menu.addItem(miAsPicture);
    }

    String image = "<img src=\"" + AppResources.INSTANCE.export().getSafeUri().asString() + "\" >";
    btnExport.addItem(image, true, menu);
  }
Ejemplo n.º 5
0
  private void updateSortMode() {
    sortMode.clear();
    for (SortMode mode : supportedModes) {
      sortMode.addItem(app.getPlain(mode.toString()));
    }

    SortMode selectedMode = app.getAlgebraView().getTreeMode();
    sortMode.setSelectedIndex(supportedModes.indexOf(selectedMode));
  }
Ejemplo n.º 6
0
  private void check() {
    exercise.checkExercise();

    int k = 1;
    int i = 0; // keep track of the row we're in
    checkAssignmentsTable.setWidget(i, k++, new Label(app.getMenu("Tool")));
    checkAssignmentsTable.setWidget(i, k++, new Label(app.getPlain("Result")));
    checkAssignmentsTable.setWidget(i, k++, new Label(app.getPlain("HintForResult")));
    checkAssignmentsTable.setWidget(i, k++, new Label(app.getPlain("Fraction")));
    i++;

    ArrayList<Assignment> parts = exercise.getParts();
    for (int j = 0; j < parts.size(); j++, i++) {
      final Assignment assignment = parts.get(j);
      Image icon = new Image();
      icon.setUrl(getIconFile(assignment.getIconFileName()));
      k = 0;
      checkAssignmentsTable.setWidget(i, k++, icon);
      checkAssignmentsTable.setWidget(i, k++, new Label(assignment.getToolName()));
      checkAssignmentsTable.setWidget(i, k++, new Label(assignment.getResult().name()));
      checkAssignmentsTable.setWidget(i, k++, new Label(assignment.getHint()));
      checkAssignmentsTable.setWidget(
          i,
          k++,
          new Label(
              app.getKernel()
                  .format(assignment.getFraction() * 100, StringTemplate.defaultTemplate)));
    }

    checkAssignmentsTable.setWidget(i, k = 0, new Label(app.getPlain("FractionTotal")));
    checkAssignmentsTable.setWidget(
        i,
        k++,
        new Label(
            app.getKernel().format(exercise.getFraction() * 100, StringTemplate.defaultTemplate)));
  }
Ejemplo n.º 7
0
  private void initActions() {

    if (app.isExam()) {
      addItem(
          MainMenu.getMenuBarHtml(
              GuiResources.INSTANCE.menu_icon_sign_out().getSafeUri().asString(),
              app.getMenu("Close"),
              true),
          true,
          new MenuCommand(app) {

            @Override
            public void doExecute() {
              // set Firefox dom.allow_scripts_to_close_windows in about:config to true to make this
              // work
              String[] optionNames = {app.getMenu("Cancel"), app.getMenu("Exit")};

              app.getGuiManager()
                  .getOptionPane()
                  .showOptionDialog(
                      app,
                      app.getMenu("ExitExamConfirm"),
                      app.getMenu("ExitExamConfirmTitle"),
                      GOptionPane.CUSTOM_OPTION,
                      GOptionPane.WARNING_MESSAGE,
                      null,
                      optionNames,
                      new AsyncOperation() {
                        @Override
                        public void callback(Object obj) {
                          String[] dialogResult = (String[]) obj;
                          if ("1".equals(dialogResult[0])) {
                            exitExam();
                          }
                        }
                      });
            }
          });
      return;
    }

    // this is enabled always
    addItem(
        MainMenu.getMenuBarHtml(
            GuiResources.INSTANCE.menu_icon_file_new().getSafeUri().asString(),
            app.getMenu("New"),
            true),
        true,
        new MenuCommand(app) {

          @Override
          public void doExecute() {
            ((DialogManagerW) app.getDialogManager()).getSaveDialog().showIfNeeded(newConstruction);
          }
        });

    // open menu is always visible in menu

    addItem(
        MainMenu.getMenuBarHtml(
            GuiResources.INSTANCE.menu_icon_file_open().getSafeUri().asString(),
            app.getPlain("Open"),
            true),
        true,
        new MenuCommand(app) {

          @Override
          public void doExecute() {
            app.openSearch(null);
            if (FileMenuW.this.onFileOpen != null) {
              FileMenuW.this.onFileOpen.run();
            }
          }
        });

    if (app.getLAF().undoRedoSupported()) {
      addItem(
          MainMenu.getMenuBarHtml(
              GuiResources.INSTANCE.menu_icon_file_save().getSafeUri().asString(),
              app.getMenu("Save"),
              true),
          true,
          new MenuCommand(app) {

            @Override
            public void doExecute() {
              app.getGuiManager().save();
            }
          });
    }

    // this is enabled always
    uploadToGGT =
        addItem(
            MainMenu.getMenuBarHtml(
                GuiResources.INSTANCE.menu_icon_file_share().getSafeUri().asString(),
                app.getMenu("Share"),
                true),
            true,
            new MenuCommand(app) {

              @Override
              public void doExecute() {
                if (!nativeShareSupported()) {
                  app.uploadToGeoGebraTube();
                } else {
                  app.getGgbApi()
                      .getBase64(
                          true,
                          new StringHandler() {

                            @Override
                            public void handle(String s) {
                              String title = app.getKernel().getConstruction().getTitle();
                              nativeShare(s, "".equals(title) ? "construction" : title);
                            }
                          });
                }
              }
            });
    App.debug("HAS EXPORT" + app.getLAF().exportSupported());
    if (app.getLAF().exportSupported()) {
      addItem(
          MainMenu.getMenuBarHtml(
              GuiResources.INSTANCE.menu_icons_file_export().getSafeUri().asString(),
              app.getMenu("Export"),
              true),
          true,
          new ExportMenuW(app));
    }

    app.getNetworkOperation().getView().add(this);

    if (!app.getNetworkOperation().isOnline()) {
      render(false);
    }
  }