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); }
/** * Adds a user defined tool to the exercise as well as the view * * @param macro the user defined tool which should be added to the exercise as well as the view */ void addAssignment(Macro macro) { if (!exercise.usesMacro(macro)) { Assignment a = exercise.addAssignment(macro); appendAssignmentRow(a); } userAddModes.setVisible(false); }
/** * If add symbol is clicked, <br> * a ToolCreationDialog will be created, if there are no (more) Macros which can be used for the * Exercise <br> * or a SubMenu like chooser of the tools which can be used for the Exercise will be shown. */ void handleAddClick() { if (app.getKernel().getMacroNumber() == 0 || app.getKernel().getMacroNumber() <= exercise.getParts().size()) { newTool(); } else { userAddModes.setVisible(true); } }
/** * Handles the remove of an Assignment from the Exercise * * @param event the original event to determine which row should be removed from Table * @param assignment the assignment to remove from the Exercise */ void handleAssignmentDeleteClick(ClickEvent event, Assignment assignment) { ListItem item = userAddModes.addItem( app.getKernel().getMacroID(assignment.getTool()) + EuclidianConstants.MACRO_MODE_ID_OFFSET); addDomHandlers(item); exercise.remove(assignment); assignmentsTable.removeRow(assignmentsTable.getCellForEvent(event).getRowIndex()); }
private void onEnd(DomEvent<?> event) { Element relativeElement = event.getRelativeElement(); String modeS = relativeElement.getAttribute("mode"); // Element target = event.getNativeEvent().getEventTarget().cast(); if (addList.getElement().isOrHasChild(relativeElement)) { if (modeS.isEmpty()) { handleAddClick(); } else { int mode = Integer.parseInt(modeS); addAssignment(mode); relativeElement.removeFromParent(); userAddModes.setVisible(false); } event.stopPropagation(); } else { userAddModes.setVisible(false); event.stopPropagation(); } }