private ComboBox<String> buildComboBox(String id, IModel<IRI> model, List<IRI> iris) { // Only set model object if it has not been initialized yet if (model.getObject() == null) { model.setObject(iris.get(0)); } List<String> choices = iris.stream().map(IRI::stringValue).collect(Collectors.toList()); IModel<String> adapter = new LambdaModelAdapter<String>( () -> { return model.getObject() != null ? model.getObject().stringValue() : null; }, str -> { model.setObject(str != null ? SimpleValueFactory.getInstance().createIRI(str) : null); }); ComboBox<String> comboBox = new ComboBox<>(id, adapter, choices); comboBox.add(LambdaBehavior.enabledWhen(() -> SchemaProfile.CUSTOMSCHEMA.equals(selectedSchemaProfile.getObject()))); comboBox.setOutputMarkupId(true); comboBox.setRequired(true); comboBox.add(Validators.IRI_VALIDATOR); // Do nothing just update the model values comboBox.add(new LambdaAjaxFormComponentUpdatingBehavior("change")); return comboBox; }
private ComboBox<String> buildComboBox(String id, IModel<IRI> model, List<IRI> iris) { // Only set model object if it has not been initialized yet if (model.getObject() == null) { model.setObject(iris.get(0)); } List<String> choices = iris.stream().map(IRI::stringValue).collect(Collectors.toList()); IModel<String> adapter = new LambdaModelAdapter<String>( () -> { return model.getObject() != null ? model.getObject().stringValue() : null; }, str -> { model.setObject(str != null ? SimpleValueFactory.getInstance().createIRI(str) : null); }); ComboBox<String> comboBox = new ComboBox<>(id, adapter, choices); comboBox.add(LambdaBehavior.enabledWhen(() -> SchemaProfile.CUSTOMSCHEMA.equals(selectedSchemaProfile.getObject()))); comboBox.setOutputMarkupId(true); comboBox.setRequired(true); comboBox.add(Validators.IRI_VALIDATOR); // Do nothing just update the model values comboBox.add(new LambdaAjaxFormComponentUpdatingBehavior("change")); return comboBox; }
public ButtonsForm(String id, final ModalWindow modalWindow) { super(id); add(new LambdaAjaxLink("openButton", OpenDocumentDialogPanel.this::actionOpenDocument) .add(enabledWhen(() -> selectedDocument != null))); add(new LambdaAjaxLink("cancelButton", OpenDocumentDialogPanel.this::actionCancel)); } }
private LambdaAjaxLink createDeleteButton() { LambdaAjaxLink link = new LambdaAjaxLink("delete", this::actionDelete); link.setOutputMarkupPlaceholderTag(true); link.add(visibleWhen(() -> getModelObject().getSelection().getAnnotation().isSet())); // Avoid deleting in read-only layers link.add(enabledWhen(() -> getModelObject().getSelectedAnnotationLayer() != null && !getModelObject().getSelectedAnnotationLayer().isReadonly())); return link; }
cancelLink.add(LambdaBehavior.enabledWhen(() -> thread != null)); add(cancelLink);
cancelLink.add(LambdaBehavior.enabledWhen(() -> thread != null)); add(cancelLink);
layerTypes.setChoices(layerSupportRegistry::getAllTypes); layerTypes.add(LambdaBehavior .enabledWhen(() -> isNull(LayerDetailForm.this.getModelObject().getId()))); layerTypes.setRequired(true); layerTypes.setNullValid(false);
layerTypes.setChoices(layerSupportRegistry::getAllTypes); layerTypes.add(LambdaBehavior .enabledWhen(() -> isNull(LayerDetailForm.this.getModelObject().getId()))); layerTypes.setRequired(true); layerTypes.setNullValid(false);
.setRequired(true) .add(this::validateUsername) .add(enabledWhen(() -> isCreate))); add(new Label("lastLogin")); add(new EmailTextField("email"));
.setRequired(true) .add(this::validateUsername) .add(enabledWhen(() -> isCreate))); add(new Label("lastLogin")); add(new EmailTextField("email"));