public static <T extends Serializable> LambdaModelAdapter<T> of( SerializableSupplier<T> aSupplier, SerializableConsumer<T> aConsumer) { return new LambdaModelAdapter<T>(aSupplier, aConsumer); }
public LambdaModelAdapter<T> build() { return new LambdaModelAdapter<T>(supplier, consumer); } }
private ComboBox<String> languageComboBox(String id, IModel<String> aModel) { // Only set kbModel object if it has not been initialized yet if (aModel.getObject() == null) { aModel.setObject(languages.get(0)); } IModel<String> adapter = new LambdaModelAdapter<String>(aModel::getObject, aModel::setObject); ComboBox<String> comboBox = new ComboBox<String>(id, adapter, languages); comboBox.setOutputMarkupId(true); comboBox.setRequired(true); comboBox.add(new LambdaAjaxFormComponentUpdatingBehavior("change", t -> { // Do nothing just update the kbModel values })); return comboBox; }
private ComboBox<String> languageComboBox(String id, IModel<String> aModel) { // Only set kbModel object if it has not been initialized yet if (aModel.getObject() == null) { aModel.setObject(languages.get(0)); } IModel<String> adapter = new LambdaModelAdapter<String>(aModel::getObject, aModel::setObject); ComboBox<String> comboBox = new ComboBox<String>(id, adapter, languages); comboBox.setOutputMarkupId(true); comboBox.setRequired(true); comboBox.add(new LambdaAjaxFormComponentUpdatingBehavior("change", t -> { // Do nothing just update the kbModel values })); 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; }
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 TextField<String> buildTextField(String id, IModel<IRI> model) { IModel<String> adapter = new LambdaModelAdapter<String>( () -> model.getObject().stringValue(), str -> model.setObject(SimpleValueFactory.getInstance().createIRI(str))); TextField<String> iriTextfield = new TextField<>(id, adapter); iriTextfield.setOutputMarkupId(true); iriTextfield.add(new LambdaAjaxFormComponentUpdatingBehavior("change", t -> { // Do nothing just update the model values })); iriTextfield.setEnabled(false); return iriTextfield; }
private TextField<String> buildTextField(String id, IModel<IRI> model) { IModel<String> adapter = new LambdaModelAdapter<String>( () -> model.getObject().stringValue(), str -> model.setObject(SimpleValueFactory.getInstance().createIRI(str))); TextField<String> iriTextfield = new TextField<>(id, adapter); iriTextfield.setOutputMarkupId(true); iriTextfield.add(new LambdaAjaxFormComponentUpdatingBehavior("change", t -> { // Do nothing just update the model values })); iriTextfield.setEnabled(false); return iriTextfield; }
levels.setLabelPosition(LabelPosition.WRAP_AFTER); levels.setModel(new LambdaModelAdapter<Collection<PermissionLevel>>(() -> { return projectRepository.getProjectPermissionLevels(user.getObject(), project.getObject());
levels.setLabelPosition(LabelPosition.WRAP_AFTER); levels.setModel(new LambdaModelAdapter<Collection<PermissionLevel>>(() -> { return projectRepository.getProjectPermissionLevels(user.getObject(), project.getObject());
.getFeature(FactLinkingConstants.LINKED_LAYER_FEATURE, linkedLayer); qualifierModel = new LambdaModelAdapter<>(() -> this.getSelectedKBItem(aItem), (v) -> { this.setSelectedKBItem((KBHandle) v, aItem, linkedAnnotationFeature); });
.getFeature(FactLinkingConstants.LINKED_LAYER_FEATURE, linkedLayer); qualifierModel = new LambdaModelAdapter<>(() -> this.getSelectedKBItem(aItem), (v) -> { this.setSelectedKBItem((KBHandle) v, aItem, linkedAnnotationFeature); });