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();
     }
   }
 }
  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);

  }
  @Test
  public void visible() {
    // Given
    FlexTable t = new FlexTable();
    // Preconditions
    assertThat(t.isVisible()).isEqualTo(true);

    // When
    t.setVisible(false);

    // Then
    assertThat(t.isVisible()).isEqualTo(false);
  }
  protected void onUpdate() {
    if (sortColumnIndex == -1) {
      sortColumnIndex = getInitialSortColumnIndex();
      reverseSort = isInitialSortReverse();
    }

    Collection<O> objects;
    try {
      objects = getObjects();
    } catch (Exception ex) {
      throw new RuntimeException(Str.getSimpleName(getClass()) + ".getObjects() failed.", ex);
    }

    log.info("Objects loaded:", objects.size());

    int rowIndex = -1;

    if (isColumnTitlesEnabled()) {
      rowIndex++;
      for (AColumn column : columns) {
        String columnTitle;
        try {
          columnTitle = column.getTitle();
        } catch (Exception ex) {
          log.error(ex);
          columnTitle = "ERROR: " + Str.formatException(ex);
        }

        boolean customSortingEnabled = isCustomSortingEnabled();

        Widget titleWidget = Widgets.textFieldlabel(columnTitle, false);
        if (titleWidget != null && customSortingEnabled && isShowColumnSortingToggleIcon())
          titleWidget.addStyleName("columnTitleWithSortToggle");

        if (titleWidget != null && (sortColumnIndex == column.index)) {
          // Sortierte Spalte hervorheben
          Style style = titleWidget.getElement().getStyle();
          style.setColor("#444");
          style.setFontWeight(FontWeight.BOLD);
          if (reverseSort) style.setFontStyle(FontStyle.ITALIC);
        }

        table.setWidget(
            rowIndex,
            column.index,
            Widgets.frame(
                titleWidget,
                Widgets.defaultSpacing,
                0,
                Widgets.defaultSpacing,
                Widgets.defaultSpacing / 2));

        if (customSortingEnabled) {
          for (int col = 0; col < columns.size(); col++) {
            table.getCellFormatter().setStyleName(rowIndex, col, "clickable");
          }
        }
      }
    }

    if (isColumnFilteringEnabled()) {
      rowIndex++;
      for (AColumn column : columns) {
        TextBox filterTextbox = column.getFilterWidget();
        SimplePanel frame = Widgets.frame(filterTextbox, Widgets.defaultSpacing);
        table.setWidget(rowIndex, column.index, frame);
      }
    }

    try {
      rows = createRows(objects, rowIndex);
    } catch (Exception ex) {
      throw new RuntimeException(Str.getSimpleName(getClass()) + ".createRows() failed.", ex);
    }
    table.setVisible(!rows.isEmpty());

    for (Row row : rows) {
      appendRow(row);
      rowIndex++;
    }

    for (int i = 0; i < getFootRowCount(); i++) {
      rowIndex++;
      for (AColumn column : columns) {
        table.setWidget(rowIndex, column.index, column.getFootCellWidget(i));
      }
    }
  }