private void initGUI() {
    mainContainer = new BorderLayoutContainer();
    refresButton = new TextButton("", ELearningController.ICONS.refresh());
    removeFromLectureButton =
        new TextButton("Remove form lecture", ELearningController.ICONS.delete());
    ListStore<Lecture> lectureListStore = new ListStore<Lecture>(lectureDataProperties.key());
    lectureComboBox =
        new ComboBox<Lecture>(
            lectureListStore,
            new LabelProvider<Lecture>() {
              public String getLabel(Lecture item) {
                return item.getLectureName();
              }
            });
    ListStore<Professor> professorListStore = new ListStore<Professor>(professorProperties.key());
    professorComboBox =
        new ComboBox<Professor>(
            professorListStore,
            new LabelProvider<Professor>() {
              public String getLabel(Professor item) {
                return item.getUsername();
              }
            });
    userGrid = createGrid();
    ToolBar toolBar = new ToolBar();

    lectureComboBox.setTriggerAction(ComboBoxCell.TriggerAction.ALL);
    lectureComboBox.setEditable(false);
    lectureComboBox.setAllowBlank(false);
    professorComboBox.setTriggerAction(ComboBoxCell.TriggerAction.ALL);
    professorComboBox.setEditable(false);
    professorComboBox.setAllowBlank(false);

    toolBar.setHorizontalSpacing(5);
    toolBar.add(refresButton);
    toolBar.add(new SeparatorToolItem());
    toolBar.add(new Label("Professor: "));
    toolBar.add(professorComboBox);
    toolBar.add(new Label("Lecture: "));
    toolBar.add(lectureComboBox);
    toolBar.add(new SeparatorToolItem());
    toolBar.add(removeFromLectureButton);

    mainContainer.setNorthWidget(toolBar, new BorderLayoutContainer.BorderLayoutData(30));
    mainContainer.setCenterWidget(userGrid);
    setState(ManageEnrolledStudentsController.IManageEnrolledStudentsState.NONE);
  }
Пример #2
0
  /** @param supportedValidatorTypes use these to construct content of the combo box */
  AddValidatorDialog(
      Set<ArgumentValidatorType> supportedValidatorTypes, ArgumentValidatorMessages avMessages) {
    this.avMessages = avMessages;

    setHeadingText(avMessages.validatorDialogHeading());
    setAutoHide(false);
    setSize("400", "250");
    // Initialize the ComboBox list store with the given Set<..>
    ListStore<ArgumentValidatorType> validatorTypes = new ListStore<>(new AVTLabelKeyProvider());
    validatorTypes.addAll(supportedValidatorTypes);

    // Initialize the ComboBox
    validatorTypeCB = new ComboBox<>(validatorTypes, new AVTLabelKeyProvider());
    validatorTypeCB.setForceSelection(true);
    validatorTypeCB.setAllowBlank(false);
    validatorTypeCB.setTriggerAction(TriggerAction.ALL);

    // Construct all "provided" fields.
    constructDoubleSpinnerFields();
    constructIntegerSpinnerFields();
    charLimitField = new NumberField<>(new NumberPropertyEditor.IntegerPropertyEditor());
    charLimitField.setAllowBlank(false);
    charLimitField.addValidHandler(this);
    charLimitField.addInvalidHandler(this);

    add(BINDER.createAndBindUi(this));

    // Initialize validatorTypeToCardMap
    validatorTypeToCardMap = Maps.newHashMap();
    validatorTypeToCardMap.put(ArgumentValidatorType.DoubleAbove, dblAboveValidatorCon);
    validatorTypeToCardMap.put(ArgumentValidatorType.DoubleBelow, dblBelowValidatorCon);
    validatorTypeToCardMap.put(ArgumentValidatorType.DoubleRange, dblRangeValidatorCon);

    validatorTypeToCardMap.put(ArgumentValidatorType.IntAbove, intAboveValidatorCon);
    validatorTypeToCardMap.put(ArgumentValidatorType.IntBelow, intBelowValidatorCon);
    validatorTypeToCardMap.put(ArgumentValidatorType.IntRange, intRangeValidatorCon);

    validatorTypeToCardMap.put(ArgumentValidatorType.Regex, regexValidatorCon);
    validatorTypeToCardMap.put(ArgumentValidatorType.CharacterLimit, characterLimitValidatorCon);

    // Set default values.
    ArgumentValidatorType next = supportedValidatorTypes.iterator().next();
    validatorTypeCB.setValue(next, true);
    cardLC.setActiveWidget(validatorTypeToCardMap.get(next));
  }