Java Code Examples for org.apache.wicket.markup.html.form.DropDownChoice#setChoices()
The following examples show how to use
org.apache.wicket.markup.html.form.DropDownChoice#setChoices() .
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 |
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 |
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: SearchPage.java From inception with Apache License 2.0 | 6 votes |
public SearchForm(String id) { super(id); setModel(CompoundPropertyModel.of(new SearchFormModel())); DropDownChoice<DocumentRepository> repositoryCombo = new BootstrapSelect<DocumentRepository>("repository"); repositoryCombo.setChoices(LoadableDetachableModel .of(() -> externalSearchService.listDocumentRepositories(project))); repositoryCombo.setChoiceRenderer(new ChoiceRenderer<DocumentRepository>("name")); repositoryCombo.setNullValid(false); add(repositoryCombo); if (!repositoryCombo.getChoices().isEmpty()) { repositoryCombo.setModelObject(repositoryCombo.getChoices().get(0)); } add(new TextField<>("query", String.class)); LambdaAjaxSubmitLink searchLink = new LambdaAjaxSubmitLink("submitSearch", this::actionSearch); add(searchLink); setDefaultButton(searchLink); }
Example 4
Source File: QualifierEditor.java From inception with Apache License 2.0 | 5 votes |
/** * 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 5
Source File: DocumentMetadataAnnotationSelectionPanel.java From inception with Apache License 2.0 | 5 votes |
public DocumentMetadataAnnotationSelectionPanel(String aId, IModel<Project> aProject, IModel<SourceDocument> aDocument, IModel<String> aUsername, CasProvider aCasProvider, AnnotationPage aAnnotationPage, AnnotationActionHandler aActionHandler, AnnotatorState aState) { super(aId, aProject); setOutputMarkupPlaceholderTag(true); annotationPage = aAnnotationPage; sourceDocument = aDocument; username = aUsername; jcasProvider = aCasProvider; project = aProject; selectedLayer = Model.of(); actionHandler = aActionHandler; state = aState; annotationsContainer = new WebMarkupContainer(CID_ANNOTATIONS_CONTAINER); annotationsContainer.setOutputMarkupId(true); annotationsContainer.add(createAnnotationList()); add(annotationsContainer); DropDownChoice<AnnotationLayer> layer = new BootstrapSelect<>(CID_LAYER); layer.setModel(selectedLayer); layer.setChoices(this::listMetadataLayers); layer.setChoiceRenderer(new ChoiceRenderer<>("uiName")); layer.add(new LambdaAjaxFormComponentUpdatingBehavior("change")); add(layer); add(new LambdaAjaxLink(CID_CREATE, this::actionCreate)); }
Example 6
Source File: ImportDocumentsPanel.java From webanno with Apache License 2.0 | 5 votes |
public ImportDocumentsPanel(String aId, IModel<Project> aProject) { super(aId); projectModel = aProject; Form<Void> form = new Form<>("form"); add(form); format = Model.of(); List<String> readableFormats = listReadableFormats(); if (!readableFormats.isEmpty()) { if (readableFormats.contains("Plain text")) { format.setObject("Plain text"); } else { format.setObject(readableFormats.get(0)); } } form.add(fileUpload = new BootstrapFileInputField("documents")); fileUpload.getConfig().showPreview(false); fileUpload.getConfig().showUpload(false); fileUpload.getConfig().showRemove(false); fileUpload.setRequired(true); DropDownChoice<String> formats = new BootstrapSelect<>("format"); formats.setModel(format); formats.setChoices(LambdaModel.of(this::listReadableFormats)); form.add(formats); form.add(new LambdaAjaxButton<>("import", this::actionImport)); }
Example 7
Source File: ProjectDetailPanel.java From webanno with Apache License 2.0 | 5 votes |
public ProjectDetailPanel(String id, IModel<Project> aModel) { super(id, aModel); projectModel = aModel; Form<Project> form = new Form<>("form", CompoundPropertyModel.of(aModel)); add(form); TextField<String> projectNameTextField = new TextField<>("name"); projectNameTextField.setRequired(true); projectNameTextField.add(new ProjectExistsValidator()); projectNameTextField.add(new ProjectNameValidator()); form.add(projectNameTextField); // If we run in development mode, then also show the ID of the project form.add(idLabel = new Label("id")); idLabel.setVisible(RuntimeConfigurationType.DEVELOPMENT .equals(getApplication().getConfigurationType())); form.add(new TextArea<String>("description").setOutputMarkupId(true)); DropDownChoice<ScriptDirection> scriptDirection = new BootstrapSelect<>("scriptDirection"); scriptDirection.setChoiceRenderer(new EnumChoiceRenderer<>(this)); scriptDirection.setChoices(Arrays.asList(ScriptDirection.values())); form.add(scriptDirection); form.add(new CheckBox("disableExport").setOutputMarkupPlaceholderTag(true)); form.add(new CheckBox("anonymousCuration").setOutputMarkupPlaceholderTag(true)); form.add(projectTypes = makeProjectTypeChoice()); form.add(new LambdaAjaxButton<>("save", this::actionSave)); }
Example 8
Source File: LayerSelectionPanel.java From webanno with Apache License 2.0 | 5 votes |
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 9
Source File: LinkFeatureTraitsEditor.java From webanno with Apache License 2.0 | 4 votes |
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: StringFeatureTraitsEditor.java From webanno with Apache License 2.0 | 4 votes |
public StringFeatureTraitsEditor(String aId, UimaPrimitiveFeatureSupport_ImplBase<StringFeatureTraits> aFS, IModel<AnnotationFeature> aFeature) { super(aId, aFeature); // 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 = aFeature; traits = CompoundPropertyModel.of(getFeatureSupport().readTraits(feature.getObject())); keyBindings = newKeyBindingsConfigurationPanel(aFeature); add(keyBindings); Form<StringFeatureTraits> form = new Form<StringFeatureTraits>(MID_FORM, traits) { private static final long serialVersionUID = -3109239605783291123L; @Override protected void onSubmit() { super.onSubmit(); // Tagsets only are allowed for single-row input fields, not for textareas if (traits.getObject().isMultipleRows()) { feature.getObject().setTagset(null); } else { traits.getObject().setDynamicSize(false); } getFeatureSupport().writeTraits(feature.getObject(), traits.getObject()); } }; form.setOutputMarkupPlaceholderTag(true); add(form); NumberTextField<Integer> collapsedRows = new NumberTextField<>("collapsedRows", Integer.class); collapsedRows.setModel(PropertyModel.of(traits, "collapsedRows")); collapsedRows.setMinimum(1); collapsedRows.add(visibleWhen(() -> traits.getObject().isMultipleRows() && !traits.getObject().isDynamicSize())); form.add(collapsedRows); NumberTextField<Integer> expandedRows = new NumberTextField<>("expandedRows", Integer.class); expandedRows.setModel(PropertyModel.of(traits, "expandedRows")); expandedRows.setMinimum(1); expandedRows.add(visibleWhen(() -> traits.getObject().isMultipleRows() && !traits.getObject().isDynamicSize())); form.add(expandedRows); DropDownChoice<TagSet> tagset = new BootstrapSelect<>("tagset"); tagset.setOutputMarkupPlaceholderTag(true); tagset.setChoiceRenderer(new ChoiceRenderer<>("name")); tagset.setNullValid(true); tagset.setModel(PropertyModel.of(aFeature, "tagset")); tagset.setChoices(LoadableDetachableModel .of(() -> annotationService.listTagSets(aFeature.getObject().getProject()))); tagset.add(visibleWhen(() -> !traits.getObject().isMultipleRows())); // If we change the tagset, the input component for the key bindings may change, so we need // to re-generate the key bindings tagset.add(new LambdaAjaxFormComponentUpdatingBehavior("change", _target -> { KeyBindingsConfigurationPanel newKeyBindings = newKeyBindingsConfigurationPanel( aFeature); keyBindings.replaceWith(newKeyBindings); keyBindings = newKeyBindings; _target.add(keyBindings); })); form.add(tagset); CheckBox multipleRows = new CheckBox("multipleRows"); multipleRows.setModel(PropertyModel.of(traits, "multipleRows")); multipleRows.add( new LambdaAjaxFormComponentUpdatingBehavior("change", target -> target.add(form))); form.add(multipleRows); CheckBox dynamicSize = new CheckBox("dynamicSize"); dynamicSize.setModel(PropertyModel.of(traits, "dynamicSize")); dynamicSize.add(new LambdaAjaxFormComponentUpdatingBehavior("change", target -> target.add(form) )); dynamicSize.add(visibleWhen(() -> traits.getObject().isMultipleRows())); form.add(dynamicSize); }
Example 11
Source File: AnnotationPreferencesDialogContent.java From webanno with Apache License 2.0 | 4 votes |
public AnnotationPreferencesDialogContent(String aId, final ModalWindow aModalWindow, IModel<AnnotatorState> aModel) { super(aId); stateModel = aModel; modalWindow = aModalWindow; form = new Form<>("form", new CompoundPropertyModel<>(loadModel(stateModel.getObject()))); NumberTextField<Integer> windowSizeField = new NumberTextField<>("windowSize"); windowSizeField.setType(Integer.class); windowSizeField.setMinimum(1); form.add(windowSizeField); NumberTextField<Integer> sidebarSizeField = new NumberTextField<>("sidebarSize"); sidebarSizeField.setType(Integer.class); sidebarSizeField.setMinimum(AnnotationPreference.SIDEBAR_SIZE_MIN); sidebarSizeField.setMaximum(AnnotationPreference.SIDEBAR_SIZE_MAX); form.add(sidebarSizeField); NumberTextField<Integer> fontZoomField = new NumberTextField<>("fontZoom"); fontZoomField.setType(Integer.class); fontZoomField.setMinimum(AnnotationPreference.FONT_ZOOM_MIN); fontZoomField.setMaximum(AnnotationPreference.FONT_ZOOM_MAX); form.add(fontZoomField); List<Pair<String, String>> editorChoices = annotationEditorRegistry.getEditorFactories() .stream() .map(f -> Pair.of(f.getBeanName(), f.getDisplayName())) .collect(Collectors.toList()); DropDownChoice<Pair<String, String>> editor = new BootstrapSelect<>("editor"); editor.setChoiceRenderer(new ChoiceRenderer<>("value")); editor.setChoices(editorChoices); editor.add(visibleWhen(() -> editor.getChoices().size() > 1 && ANNOTATION.equals(stateModel.getObject().getMode()))); form.add(editor); // Add layer check boxes and combo boxes form.add(createLayerContainer()); // Add a check box to enable/disable automatic page navigations while annotating form.add(new CheckBox("scrollPage")); // Add a check box to enable/disable arc collapsing form.add(new CheckBox("collapseArcs")); form.add(new CheckBox("rememberLayer")); // Add global read-only coloring strategy combo box DropDownChoice<ReadonlyColoringBehaviour> readOnlyColor = new BootstrapSelect<>( "readonlyLayerColoringBehaviour"); readOnlyColor.setChoices(asList(ReadonlyColoringBehaviour.values())); readOnlyColor.setChoiceRenderer(new ChoiceRenderer<>("descriptiveName")); form.add(readOnlyColor); form.add(new LambdaAjaxButton<>("save", this::actionSave)); form.add(new LambdaAjaxLink("cancel", this::actionCancel)); add(form); }
Example 12
Source File: AnnotationPreferencesDialogContent.java From webanno with Apache License 2.0 | 4 votes |
private ListView<AnnotationLayer> createLayerContainer() { return new ListView<AnnotationLayer>("annotationLayers") { private static final long serialVersionUID = -4040731191748923013L; @Override protected void populateItem(ListItem<AnnotationLayer> aItem) { Preferences prefs = form.getModelObject(); AnnotationLayer layer = aItem.getModelObject(); Set<Long> hiddenLayerIds = stateModel.getObject().getPreferences() .getHiddenAnnotationLayerIds(); // add visibility checkbox CheckBox layerVisible = new CheckBox("annotationLayerActive", Model.of(!hiddenLayerIds.contains(layer.getId()))); layerVisible.add(new LambdaAjaxFormComponentUpdatingBehavior("change", _target -> { if (!layerVisible.getModelObject()) { hiddenLayerIds.add(layer.getId()); } else { hiddenLayerIds.remove(layer.getId()); } })); aItem.add(layerVisible); // add coloring strategy choice DropDownChoice<ColoringStrategyType> layerColor = new BootstrapSelect<>( "layercoloring"); layerColor.setModel(Model.of(prefs.colorPerLayer.get(layer.getId()))); layerColor.setChoiceRenderer(new ChoiceRenderer<>("descriptiveName")); layerColor.setChoices(asList(ColoringStrategyType.values())); layerColor.add(new LambdaAjaxFormComponentUpdatingBehavior("change", _target -> prefs.colorPerLayer.put(layer.getId(), layerColor.getModelObject()))); aItem.add(layerColor); // add label aItem.add(new Label("annotationLayerDesc", layer.getUiName())); } }; }