コード例 #1
0
  @Override
  protected void formOK(UserRequest ureq) {
    commitFields();
    commitStepLabels();

    String selectedType = typeEl.getSelectedKey();
    SliderType type = SliderType.valueOf(selectedType);
    rubric.setSliderType(type);
    if (type == SliderType.continuous) {
      rubric.setStart(1);
      rubric.setEnd(100);
      rubric.setSteps(100);
    } else {
      int steps = Integer.parseInt(stepsEl.getSelectedKey());
      rubric.setStart(1);
      rubric.setEnd(steps);
      rubric.setSteps(steps);
    }

    for (Iterator<Slider> sliderIt = rubric.getSliders().iterator(); sliderIt.hasNext(); ) {
      Slider slider = sliderIt.next();
      if (!StringHelper.containsNonWhitespace(slider.getStartLabel())
          && !StringHelper.containsNonWhitespace(slider.getEndLabel())) {
        sliderIt.remove();
      }
    }

    rubricCtrl.updateForm();

    fireEvent(ureq, new ChangePartEvent(rubric));
    fireEvent(ureq, new ClosePartEvent(rubric));
  }
コード例 #2
0
  private void commitStepLabels() {
    if (!typeEl.isOneSelected()) return;

    SliderType selectedType = SliderType.valueOf(typeEl.getSelectedKey());
    if (selectedType == SliderType.discrete || selectedType == SliderType.discrete_slider) {
      if (rubric.getStepLabels() == null) {
        rubric.setStepLabels(new ArrayList<>());
      }

      int steps = Integer.parseInt(stepsEl.getSelectedKey());
      for (int i = 0; i < stepLabels.size() && i < steps; i++) {
        StepLabelColumn stepLabel = stepLabels.get(i);
        if (i < rubric.getStepLabels().size()) {
          rubric.getStepLabels().get(i).setLabel(stepLabel.getStepLabelEl().getValue());
        } else {
          StepLabel label = new StepLabel();
          label.setId(UUID.randomUUID().toString());
          label.setLabel(stepLabel.getStepLabelEl().getValue());
          rubric.getStepLabels().add(label);
        }
      }

      if (rubric.getStepLabels().size() > steps) {
        List<StepLabel> labels = new ArrayList<>(rubric.getStepLabels().subList(0, steps));
        rubric.setStepLabels(labels);
      }
    } else {
      rubric.getStepLabels().clear();
    }
  }
コード例 #3
0
  private void updateTypeSettings() {
    if (!typeEl.isOneSelected()) return;

    SliderType selectedType = SliderType.valueOf(typeEl.getSelectedKey());
    if (selectedType == SliderType.discrete || selectedType == SliderType.discrete_slider) {
      stepsEl.setVisible(true);
    } else if (selectedType == SliderType.continuous) {
      stepsEl.setVisible(false);
    }
  }