Search in sources :

Example 1 with ChoiceDescriptor

use of edu.stanford.bmir.protege.web.shared.form.field.ChoiceDescriptor in project webprotege by protegeproject.

the class ChoiceFieldComboBoxEditor method setValue.

@Override
public void setValue(FormDataValue value) {
    FormDataValue first = value.asList().get(0);
    int index = 1;
    for (ChoiceDescriptor descriptor : choiceDescriptors) {
        if (descriptor.getValue().equals(first)) {
            comboBox.setSelectedIndex(index);
            break;
        }
        index++;
    }
}
Also used : FormDataValue(edu.stanford.bmir.protege.web.shared.form.data.FormDataValue) ChoiceDescriptor(edu.stanford.bmir.protege.web.shared.form.field.ChoiceDescriptor)

Example 2 with ChoiceDescriptor

use of edu.stanford.bmir.protege.web.shared.form.field.ChoiceDescriptor in project webprotege by protegeproject.

the class ChoiceFieldComboBoxEditor method setChoices.

@Override
public void setChoices(List<ChoiceDescriptor> choices) {
    comboBox.clear();
    choiceDescriptors.clear();
    comboBox.addItem("");
    for (ChoiceDescriptor descriptor : choices) {
        choiceDescriptors.add(descriptor);
        comboBox.addItem(descriptor.getLabel());
    }
    selectDefaultChoice();
}
Also used : ChoiceDescriptor(edu.stanford.bmir.protege.web.shared.form.field.ChoiceDescriptor)

Example 3 with ChoiceDescriptor

use of edu.stanford.bmir.protege.web.shared.form.field.ChoiceDescriptor in project webprotege by protegeproject.

the class ChoiceFieldRadioButtonEditor method setChoices.

@Override
public void setChoices(List<ChoiceDescriptor> choices) {
    container.clear();
    choiceButtons.clear();
    nameCounter++;
    for (ChoiceDescriptor descriptor : choices) {
        RadioButton radioButton = new RadioButton("Choice" + nameCounter, new SafeHtmlBuilder().appendHtmlConstant(descriptor.getLabel()).toSafeHtml());
        radioButton.addStyleName(WebProtegeClientBundle.BUNDLE.style().noFocusBorder());
        radioButton.addValueChangeHandler(radioButtonValueChangedHandler);
        radioButton.addFocusHandler(event -> {
            radioButton.addStyleName(WebProtegeClientBundle.BUNDLE.style().focusBorder());
            radioButton.removeStyleName(WebProtegeClientBundle.BUNDLE.style().noFocusBorder());
        });
        radioButton.addBlurHandler(event -> {
            radioButton.addStyleName(WebProtegeClientBundle.BUNDLE.style().noFocusBorder());
            radioButton.removeStyleName(WebProtegeClientBundle.BUNDLE.style().focusBorder());
        });
        container.add(radioButton);
        choiceButtons.put(radioButton, descriptor);
    }
    selectDefaultChoice();
}
Also used : RadioButton(com.google.gwt.user.client.ui.RadioButton) ChoiceDescriptor(edu.stanford.bmir.protege.web.shared.form.field.ChoiceDescriptor) SafeHtmlBuilder(com.google.gwt.safehtml.shared.SafeHtmlBuilder)

Example 4 with ChoiceDescriptor

use of edu.stanford.bmir.protege.web.shared.form.field.ChoiceDescriptor in project webprotege by protegeproject.

the class ChoiceFieldCheckBoxEditor method setChoices.

@Override
public void setChoices(List<ChoiceDescriptor> choices) {
    container.clear();
    checkBoxes.clear();
    for (ChoiceDescriptor choiceDescriptor : choices) {
        CheckBox checkBox = new CheckBox(new SafeHtmlBuilder().appendHtmlConstant(choiceDescriptor.getLabel()).toSafeHtml());
        checkBoxes.put(checkBox, choiceDescriptor);
        container.add(checkBox);
        checkBox.getElement().getStyle().setDisplay(Style.Display.BLOCK);
        checkBox.addValueChangeHandler(checkBoxValueChangedHandler);
        checkBox.addStyleName(WebProtegeClientBundle.BUNDLE.style().noFocusBorder());
        checkBox.addFocusHandler(event -> {
            checkBox.addStyleName(WebProtegeClientBundle.BUNDLE.style().focusBorder());
            checkBox.removeStyleName(WebProtegeClientBundle.BUNDLE.style().noFocusBorder());
        });
        checkBox.addBlurHandler(event -> {
            checkBox.addStyleName(WebProtegeClientBundle.BUNDLE.style().noFocusBorder());
            checkBox.removeStyleName(WebProtegeClientBundle.BUNDLE.style().focusBorder());
        });
    }
}
Also used : CheckBox(com.google.gwt.user.client.ui.CheckBox) ChoiceDescriptor(edu.stanford.bmir.protege.web.shared.form.field.ChoiceDescriptor) SafeHtmlBuilder(com.google.gwt.safehtml.shared.SafeHtmlBuilder)

Example 5 with ChoiceDescriptor

use of edu.stanford.bmir.protege.web.shared.form.field.ChoiceDescriptor in project webprotege by protegeproject.

the class ChoiceFieldSegmentedEditor method setChoices.

@Override
public void setChoices(List<ChoiceDescriptor> choices) {
    dirty = false;
    segmentContainer.clear();
    choiceWidgets.clear();
    this.choices.clear();
    this.selectedIndex = -1;
    for (ChoiceDescriptor choice : choices) {
        InlineLabel label = new InlineLabel(choice.getLabel());
        segmentContainer.add(label);
        this.choices.add(choice.getValue());
        this.choiceWidgets.add(label);
        label.addClickHandler(event -> {
            setSelection(choice.getValue(), true);
        });
    }
    segmentContainer.getElement().getStyle().setProperty("maxWidth", SEGMENT_SIZE * choices.size(), Style.Unit.PX);
    setDefaultChoiceSelected();
}
Also used : ChoiceDescriptor(edu.stanford.bmir.protege.web.shared.form.field.ChoiceDescriptor)

Aggregations

ChoiceDescriptor (edu.stanford.bmir.protege.web.shared.form.field.ChoiceDescriptor)5 SafeHtmlBuilder (com.google.gwt.safehtml.shared.SafeHtmlBuilder)2 CheckBox (com.google.gwt.user.client.ui.CheckBox)1 RadioButton (com.google.gwt.user.client.ui.RadioButton)1 FormDataValue (edu.stanford.bmir.protege.web.shared.form.data.FormDataValue)1