Java Code Examples for org.apache.wicket.markup.html.form.DropDownChoice#setOutputMarkupId()

The following examples show how to use org.apache.wicket.markup.html.form.DropDownChoice#setOutputMarkupId() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ActiveLearningSidebar.java    From inception with Apache License 2.0 6 votes vote down vote up
private Form<Void> createSessionControlForm()
{
    Form<Void> form = new Form<>(CID_SESSION_CONTROL_FORM);

    DropDownChoice<AnnotationLayer> layersDropdown = new BootstrapSelect<>(CID_SELECT_LAYER);
    layersDropdown.setModel(alStateModel.bind("layer"));
    layersDropdown.setChoices(LoadableDetachableModel.of(this::listLayersWithRecommenders));
    layersDropdown.setChoiceRenderer(new LambdaChoiceRenderer<>(AnnotationLayer::getUiName));
    layersDropdown.add(LambdaBehavior.onConfigure(it -> it.setEnabled(!alStateModel
        .getObject().isSessionActive())));
    layersDropdown.setOutputMarkupId(true);
    layersDropdown.setRequired(true);
    form.add(layersDropdown);
    
    form.add(new LambdaAjaxSubmitLink(CID_START_SESSION_BUTTON, this::actionStartSession)
            .add(visibleWhen(() -> !alStateModel.getObject().isSessionActive())));
    form.add(new LambdaAjaxLink(CID_STOP_SESSION_BUTTON, this::actionStopSession)
        .add(visibleWhen(() -> alStateModel.getObject().isSessionActive())));
    form.add(visibleWhen(() -> alStateModel.getObject().isDoExistRecommenders()));

    return form;
}
 
Example 2
Source File: StatementGroupPanel.java    From inception with Apache License 2.0 6 votes vote down vote up
public NewStatementGroupFragment(String aId) {
    super(aId, "newStatementGroup", StatementGroupPanel.this, groupModel);
                
    IModel<KBProperty> property = Model.of();
    
    Form<KBProperty> form = new Form<>("form", property);
    DropDownChoice<KBProperty> type = new BootstrapSelect<>("property");
    type.setModel(property);
    type.setChoiceRenderer(new ChoiceRenderer<>("uiLabel"));            
    type.setChoices(getUnusedProperties());
    type.setRequired(true);
    type.setOutputMarkupId(true);
    form.add(type);
    focusComponent = type;
    
    form.add(new LambdaAjaxButton<>("create", this::actionNewProperty));
    form.add(new LambdaAjaxLink("cancel", this::actionCancelNewProperty));
    add(form);
}
 
Example 3
Source File: QualifierEditor.java    From inception with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a new fragement for editing a qualifier.<br>
 * The editor has two slightly different behaviors, depending on the value of
 * {@code isNewQualifier}:
 * <ul>
 * <li>{@code !isNewQualifier}: Save button commits changes, cancel button discards unsaved
 * changes, delete button removes the qualifier from the statement.</li>
 * <li>{@code isNewQualifier}: Save button commits changes (creates a new qualifier in the
 * statement), cancel button removes the qualifier from the UI, delete button is not visible
 * .</li>
 * </ul>
 *
 * @param aId
 *            markup ID
 * @param aQualifier
 *            qualifier model
 * @param isNewQualifier
 *            whether the qualifier being edited is new, meaning it has no corresponding
 *            qualifier in the KB backend
 */
public EditMode(String aId, IModel<KBQualifier> aQualifier, boolean isNewQualifier)
{
    super(aId, "editMode", QualifierEditor.this, aQualifier);

    IModel<KBQualifier> compoundModel = CompoundPropertyModel.of(aQualifier);

    Form<KBQualifier> form = new Form<>("form", compoundModel);
    DropDownChoice<KBProperty> type = new BootstrapSelect<>("property");
    type.setChoiceRenderer(new ChoiceRenderer<>("uiLabel"));
    type.setChoices(kbService.listProperties(kbModel.getObject(), false));
    type.setRequired(true);
    type.setOutputMarkupId(true);
    form.add(type);
    initialFocusComponent = type;

    form.add(new TextField<>("language"));

    Component valueTextArea = new TextArea<String>("value");
    form.add(valueTextArea);

    form.add(new LambdaAjaxButton<>("create", QualifierEditor.this::actionSave));
    form.add(new LambdaAjaxLink("cancel", t -> {
        if (isNewQualifier) {
            QualifierEditor.this.actionCancelNewQualifier(t);
        } else {
            QualifierEditor.this.actionCancelExistingQualifier(t);
        }
    }));
    form.add(new LambdaAjaxLink("delete", QualifierEditor.this::actionDelete)
        .setVisibilityAllowed(!isNewQualifier));

    add(form);
}
 
Example 4
Source File: LayerSelectionPanel.java    From webanno with Apache License 2.0 5 votes vote down vote up
private DropDownChoice<AnnotationLayer> createDefaultAnnotationLayerSelector()
{
    DropDownChoice<AnnotationLayer> selector = new BootstrapSelect<>("defaultAnnotationLayer");
    selector.setChoices(LoadableDetachableModel.of(this::getSelectableLayers));
    selector.setChoiceRenderer(new ChoiceRenderer<>("uiName"));
    selector.setOutputMarkupId(true);
    selector.add(LambdaAjaxFormComponentUpdatingBehavior.onUpdate("change",
            this::actionChangeDefaultLayer));
    return selector;
}
 
Example 5
Source File: ODateTimeField.java    From Orienteer with Apache License 2.0 5 votes vote down vote up
private DropDownChoice<String> createChoice(String id, int mode) {
    DropDownChoice<String> choice = new DropDownChoice<>(id, new Model<>(), Arrays.asList(AM, PM));
    boolean support = isSupportAmPm();
    choice.setOutputMarkupId(true);
    choice.setNullValid(false);
    if (mode != -1) choice.setModelObject(mode == Calendar.AM ? choice.getChoices().get(0) : choice.getChoices().get(1));
    else choice.setModelObject(choice.getChoices().get(0));
    choice.setVisible(support);
    choice.setEnabled(support);
    return choice;
}
 
Example 6
Source File: KnowledgeBaseIriPanel.java    From inception with Apache License 2.0 4 votes vote down vote up
public KnowledgeBaseIriPanel(String id, CompoundPropertyModel<KnowledgeBaseWrapper> aModel)
{
    super(id);
    setOutputMarkupId(true);
    selectedSchemaProfile = Model.of(SchemaProfile.RDFSCHEMA);

    kbModel = aModel;

    DropDownChoice<Reification> reificationChoice = selectReificationStrategy("reification",
            "kb.reification");
    add(reificationChoice);

    // The Kendo comboboxes do not redraw properly when added directly to an
    // AjaxRequestTarget (for each combobox, a text field and a dropdown will be shown).
    // Instead, wrap all of them in a WMC and redraw that.
    WebMarkupContainer comboBoxWrapper = new WebMarkupContainer("comboBoxWrapper");
    comboBoxWrapper.setOutputMarkupId(true);
    add(comboBoxWrapper);
    
    // Add comboboxes for classIri, subclassIri, typeIri and descriptionIri
    ComboBox<String> classField = buildComboBox("classIri", kbModel.bind("kb.classIri"),
            IriConstants.CLASS_IRIS);
    ComboBox<String> subclassField = buildComboBox("subclassIri",
            kbModel.bind("kb.subclassIri"), IriConstants.SUBCLASS_IRIS);
    ComboBox<String> typeField = buildComboBox("typeIri", kbModel.bind("kb.typeIri"),
            IriConstants.TYPE_IRIS);
    ComboBox<String> subPropertyField = buildComboBox("subPropertyIri",
        kbModel.bind("kb.subPropertyIri"), IriConstants.SUBPROPERTY_IRIS);
    ComboBox<String> descriptionField = buildComboBox("descriptionIri",
            kbModel.bind("kb.descriptionIri"), IriConstants.DESCRIPTION_IRIS);
    ComboBox<String> labelField = buildComboBox("labelIri",
            kbModel.bind("kb.labelIri"), IriConstants.LABEL_IRIS);
    ComboBox<String> propertyTypeField = buildComboBox("propertyTypeIri",
            kbModel.bind("kb.propertyTypeIri"), IriConstants.PROPERTY_TYPE_IRIS);
    ComboBox<String> propertyLabelField = buildComboBox("propertyLabelIri",
            kbModel.bind("kb.propertyLabelIri"), IriConstants.PROPERTY_LABEL_IRIS);
    ComboBox<String> propertyDescriptionField = buildComboBox("propertyDescriptionIri",
            kbModel.bind("kb.propertyDescriptionIri"), IriConstants.PROPERTY_DESCRIPTION_IRIS);
    comboBoxWrapper
        .add(classField, subclassField, typeField, subPropertyField, descriptionField,
            labelField, propertyTypeField, propertyLabelField, propertyDescriptionField);
    
    // RadioGroup to select the IriSchemaType
    DropDownChoice<SchemaProfile> iriSchemaChoice = new BootstrapSelect<SchemaProfile>(
            "iriSchema", selectedSchemaProfile, Arrays.asList(SchemaProfile.values()),
            new EnumChoiceRenderer<>(this))
    {
        private static final long serialVersionUID = 3863260896285332033L;

        @Override
        protected void onInitialize()
        {
            super.onInitialize();
            // Initialize according to current model values
            SchemaProfile modelProfile = SchemaProfile
                .checkSchemaProfile(kbModel.getObject().getKb());

            setModelObject(modelProfile);
        }
    };
    iriSchemaChoice.setOutputMarkupId(true);
    // OnChange update the model with corresponding iris
    iriSchemaChoice.add(new LambdaAjaxFormComponentUpdatingBehavior("change", _target -> {
        SchemaProfile profile = iriSchemaChoice.getModelObject();
        // If the user switches to the custom profile, we retain the values from the
        // previously selected profile and just make the IRI mapping ediable. If the user
        // switches to a pre-defined profile, we reset the values.
        if (SchemaProfile.CUSTOMSCHEMA != profile) {
            classField.setModelObject(profile.getClassIri().stringValue());
            subclassField.setModelObject(profile.getSubclassIri().stringValue());
            typeField.setModelObject(profile.getTypeIri().stringValue());
            descriptionField.setModelObject(profile.getDescriptionIri().stringValue());
            labelField.setModelObject(profile.getLabelIri().stringValue());
            propertyTypeField.setModelObject(profile.getPropertyTypeIri().stringValue());
            propertyLabelField.setModelObject(profile.getPropertyLabelIri().stringValue());
            propertyDescriptionField
                .setModelObject(profile.getPropertyDescriptionIri().stringValue());
        }
        _target.add(comboBoxWrapper, iriSchemaChoice, reificationChoice);
    }));
    comboBoxWrapper.add(iriSchemaChoice);
}
 
Example 7
Source File: SimulationLearningCurvePanel.java    From inception with Apache License 2.0 4 votes vote down vote up
public SimulationLearningCurvePanel(String aId, Project aProject,
        IModel<Recommender> aSelectedRecommenderPanel)
{
    super(aId);
    project = aProject;
    selectedRecommenderPanel = aSelectedRecommenderPanel;
    evaluate = true;

    Form<Recommender> form = new Form<>(MID_FORM);
    add(form);
    
    final DropDownChoice<RecommenderEvaluationScoreMetricEnum> dropdown = 
            new BootstrapSelect<RecommenderEvaluationScoreMetricEnum>(
            "select", new Model<RecommenderEvaluationScoreMetricEnum>(DROPDOWN_VALUES.get(0)),
            new ListModel<RecommenderEvaluationScoreMetricEnum>(DROPDOWN_VALUES));
    dropdown.setOutputMarkupId(true);
    selectedValue = RecommenderEvaluationScoreMetricEnum.Accuracy;

    dropdown.add(new AjaxFormComponentUpdatingBehavior("change")
    {
        private static final long serialVersionUID = -6744838136235652577L;

        @Override
        protected void onUpdate(AjaxRequestTarget _target)
        {
            selectedValue = dropdown.getModelObject();

            if (chartPanel == null) {
                return;
            }
            
            startEvaluation(_target, form);
        }
    });

    form.add(dropdown);
    
    emptyPanel  = new EmptyPanel(MID_CHART_CONTAINER);
    emptyPanel.setOutputMarkupPlaceholderTag(true);
    emptyPanel.setMarkupId(OUTPUT_MID_CHART_CONTAINER);
    emptyPanel.setOutputMarkupId(true);
    form.add(emptyPanel);
    
    // clicking the start button the annotated documents are evaluated and the learning curve
    // for the selected recommender is plotted in the hCart Panel
    @SuppressWarnings({ "unchecked", "rawtypes" })
    LambdaAjaxButton startButton = new LambdaAjaxButton(MID_SIMULATION_START_BUTTON,
        (_target, _form) -> 
            startEvaluation(_target, _form )
        );
    
    form.add(startButton);
}
 
Example 8
Source File: MetricSelectDropDownPanel.java    From inception with Apache License 2.0 4 votes vote down vote up
public MetricSelectDropDownPanel(String aId)
{
    super(aId);

    final DropDownChoice<RecommenderEvaluationScoreMetricEnum> dropdown = new 
            DropDownChoice<RecommenderEvaluationScoreMetricEnum>(
            MID_METRIC_SELECT, new Model<RecommenderEvaluationScoreMetricEnum>(METRICS.get(0)),
            new ListModel<RecommenderEvaluationScoreMetricEnum>(METRICS));
    dropdown.setRequired(true);
    dropdown.setOutputMarkupId(true);

    dropdown.add(new AjaxFormComponentUpdatingBehavior("change")
    {
        private static final long serialVersionUID = -6744838136235652577L;

        protected void onUpdate(AjaxRequestTarget target)
        {
            DropDownEvent dropDownEvent = new DropDownEvent();
            dropDownEvent.setSelectedValue(dropdown.getModelObject());
            dropDownEvent.setTarget(target);

            send(getPage(), Broadcast.BREADTH, dropDownEvent); 
            
            Effects.hide(target, dropdown);
            Effects.show(target, dropdown);
            target.appendJavaScript("document.getElementById('" + link.getMarkupId()
                    + "').classList.remove('fa-chevron-circle-right');");
            target.appendJavaScript("document.getElementById('" + link.getMarkupId()
                    + "').classList.add('fa-chevron-circle-left');");
        }
    });

    add(dropdown);

    link = new AjaxLink<Void>(MID_METRIC_LINK)
    {            
        private static final long serialVersionUID = 1L;

        
        @Override
        public void onClick(AjaxRequestTarget target)
        {
            if (isDropdownVisible) {
                Effects.hide(target, dropdown);
                target.appendJavaScript("document.getElementById('" + link.getMarkupId()
                        + "').classList.remove('fa-chevron-circle-left');");
                target.appendJavaScript("document.getElementById('" + link.getMarkupId()
                        + "').classList.add('fa-chevron-circle-right');");
                isDropdownVisible = false;

            }
            else {

                Effects.show(target, dropdown);
                target.appendJavaScript("document.getElementById('" + link.getMarkupId()
                        + "').classList.remove('fa-chevron-circle-right');");
                target.appendJavaScript("document.getElementById('" + link.getMarkupId()
                        + "').classList.add('fa-chevron-circle-left');");
                isDropdownVisible = true;
            }
        }
    };

    link.setOutputMarkupId(true);
    add(link);
}
 
Example 9
Source File: LinkFeatureTraitsEditor.java    From webanno with Apache License 2.0 4 votes vote down vote up
public LinkFeatureTraitsEditor(String aId, SlotFeatureSupport aFS,
        IModel<AnnotationFeature> aFeatureModel)
{
    super(aId, aFeatureModel);
    
    // We cannot retain a reference to the actual SlotFeatureSupport instance because that
    // is not serializable, but we can retain its ID and look it up again from the registry
    // when required.
    featureSupportId = aFS.getId();
    feature = aFeatureModel;
    
    traits = Model.of(readTraits());
    
    Form<Traits> form = new Form<Traits>(MID_FORM, CompoundPropertyModel.of(traits))
    {
        private static final long serialVersionUID = -3109239605783291123L;

        @Override
        protected void onSubmit()
        {
            super.onSubmit();
            // when saving reset the selected tagset if role labels are not enabled
            if (!traits.getObject().isEnableRoleLabels()) {
                feature.getObject().setTagset(null);
            }
            writeTraits();
        }
    };
    form.setOutputMarkupPlaceholderTag(true);
    add(form);
    
    MultiSelect<Tag> defaultSlots  = new MultiSelect<Tag>("defaultSlots") {
        private static final long serialVersionUID = 8231304829756188352L;
        
        @Override
        public void onConfigure(JQueryBehavior aBehavior)
        {
            super.onConfigure(aBehavior);
            //aBehavior.setOption("placeholder", Options.asString(getString("placeholder")));
            aBehavior.setOption("filter", Options.asString("contains"));
            aBehavior.setOption("autoClose", false);
        }
    };
    defaultSlots.setChoices(LambdaModel.of(this::listTags));
    defaultSlots.setChoiceRenderer(new ChoiceRenderer<>("name"));
    defaultSlots.add(visibleWhen(() -> traits.getObject().isEnableRoleLabels()
            && feature.getObject().getTagset() != null));
    form.add(defaultSlots);

    CheckBox enableRoleLabels = new CheckBox("enableRoleLabels");
    enableRoleLabels.setModel(PropertyModel.of(traits, "enableRoleLabels"));
    enableRoleLabels.add(new LambdaAjaxFormComponentUpdatingBehavior("change", 
        target -> target.add(form)
    ));
    form.add(enableRoleLabels);
    
    DropDownChoice<TagSet> tagset = new BootstrapSelect<>("tagset");
    tagset.setOutputMarkupPlaceholderTag(true);
    tagset.setOutputMarkupId(true);
    tagset.setChoiceRenderer(new ChoiceRenderer<>("name"));
    tagset.setNullValid(true);
    tagset.setModel(PropertyModel.of(aFeatureModel, "tagset"));
    tagset.setChoices(LambdaModel.of(() -> annotationService
            .listTagSets(aFeatureModel.getObject().getProject())));
    tagset.add(new LambdaAjaxFormComponentUpdatingBehavior("change", target -> {
        traits.getObject().setDefaultSlots(new ArrayList<>());
        target.add(form);
    }));
    tagset.add(visibleWhen(() -> traits.getObject().isEnableRoleLabels()));
    form.add(tagset);
}
 
Example 10
Source File: DefineDrillEntityPanel.java    From nextreports-server with Apache License 2.0 4 votes vote down vote up
public DefineDrillEntityPanel(String id, String type, final DrillDownEntity drillEntity, Entity entity) {
	super(id, new CompoundPropertyModel<DrillDownEntity>(drillEntity));
	
	this.type = type;
	
	final Label widgetLabel = new Label("entityLabel", getString(type));		
	add(widgetLabel);
	
	final DropDownChoice<Entity> entityChoice = new DropDownChoice<Entity>("entities", 
			new PropertyModel<Entity>(drillEntity, "entity"), new WidgetDropDownModel(), new EntityChoiceRenderer());
	entityChoice.setOutputMarkupPlaceholderTag(true);
	entityChoice.setOutputMarkupId(true);
	entityChoice.setRequired(true);
	add(entityChoice);
	
	final Label linkLabel = new Label("linkLabel", getString("ActionContributor.Drill.parameter"));
	linkLabel.setOutputMarkupId(true);
	linkLabel.setOutputMarkupPlaceholderTag(true);
	add(linkLabel);
	
	final DropDownChoice<String> paramChoice = new DropDownChoice<String>("parameters",
               new PropertyModel<String>(drillEntity, "linkParameter"), parameters, new ChoiceRenderer<String>());
       paramChoice.setRequired(true);
       paramChoice.setLabel(new Model<String>( getString("ActionContributor.Drill.parameter")));
       paramChoice.setOutputMarkupId(true);
       paramChoice.setOutputMarkupPlaceholderTag(true);
       add(paramChoice);
       
       final Label columnLabel = new Label("columnLabel",  getString("ActionContributor.Drill.column"));            
       columnLabel.setOutputMarkupId(true);
       columnLabel.setOutputMarkupPlaceholderTag(true);
	add(columnLabel);
                   
       final TextField<Integer> columnField = new TextField<Integer>("column");            
       columnField.setOutputMarkupId(true);
       columnField.setOutputMarkupPlaceholderTag(true);
       add(columnField);
       
       if (drillEntity.getIndex() == 0) {
       	if (entity instanceof Chart) {
       		columnLabel.setVisible(false);            	
       		columnField.setVisible(false);            		 
       	}
       } else {
       	if (DrillDownUtil.getLastDrillType(entity) == DrillDownEntity.CHART_TYPE) {
       		columnLabel.setVisible(false);            	
       		columnField.setVisible(false);            		   
       	} 
       }
       
       entityChoice.add(new AjaxFormComponentUpdatingBehavior("onchange") {

           @Override
           protected void onUpdate(AjaxRequestTarget target) {
          	updateParameters(drillEntity);                     
              target.add(paramChoice);
           }

       }); 
       
}