private ComboBox<String> basePrefixField(String aId, String aProperty) { // Add textfield and label for basePrefix ComboBox<String> basePrefix = new ComboBox<String>(aId, kbModel.bind(aProperty), Arrays.asList(IriConstants.INCEPTION_NAMESPACE)); basePrefix.add(new LambdaAjaxFormComponentUpdatingBehavior("change")); basePrefix.setConvertEmptyInputStringToNull(false); basePrefix.setOutputMarkupId(true); return basePrefix; }
@Override public void onUpdate(AjaxRequestTarget aTarget) { try { if (action != null) { action.accept(aTarget); } } catch (Exception e) { if (exceptionHandler != null) { exceptionHandler.accept(aTarget, e); } else { Component component = getComponent(); LoggerFactory.getLogger(component.getPage().getClass()) .error("Error: " + e.getMessage(), e); component.error("Error: " + e.getMessage()); aTarget.addChildren(component.getPage(), IFeedback.class); } } } }
private DropDownChoice<AnnotationLayer> createDefaultAnnotationLayerSelector() { DropDownChoice<AnnotationLayer> selector = new BootstrapSelect<>("defaultAnnotationLayer"); selector.setChoices(new PropertyModel<>(this, "annotationLayers")); selector.setChoiceRenderer(new ChoiceRenderer<>("uiName")); selector.setOutputMarkupId(true); selector.add(LambdaAjaxFormComponentUpdatingBehavior.onUpdate("change", this::actionChangeDefaultLayer)); return selector; }
private ComboBox<String> basePrefixField(String aId, String aProperty) { // Add textfield and label for basePrefix ComboBox<String> basePrefix = new ComboBox<String>(aId, kbModel.bind(aProperty), Arrays.asList(IriConstants.INCEPTION_NAMESPACE)); basePrefix.add(new LambdaAjaxFormComponentUpdatingBehavior("change")); basePrefix.setConvertEmptyInputStringToNull(false); basePrefix.setOutputMarkupId(true); return basePrefix; }
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; }
public NumericLiteralValueEditor(String aId, IModel<KBStatement> aModel) { super(aId, CompoundPropertyModel.of(aModel)); // Clear the value if it is not an instance of number if (! (aModel.getObject().getValue() instanceof Number)) { aModel.getObject().setValue(0); } value = new NumberTextField<>("value", Double.class); value.setOutputMarkupId(true); value.add(new LambdaAjaxFormComponentUpdatingBehavior("change", t -> t.add(getParent()))); add(value); }
public NumericLiteralValueEditor(String aId, IModel<KBStatement> aModel) { super(aId, CompoundPropertyModel.of(aModel)); // Clear the value if it is not an instance of number if (! (aModel.getObject().getValue() instanceof Number)) { aModel.getObject().setValue(0); } value = new NumberTextField<>("value", Double.class); value.setOutputMarkupId(true); value.add(new LambdaAjaxFormComponentUpdatingBehavior("change", t -> t.add(getParent()))); add(value); }
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; }
public BooleanLiteralValueEditor(String aId, IModel<KBStatement> aModel) { super(aId, CompoundPropertyModel.of(aModel)); value = new CheckBox("value"); value.setOutputMarkupId(true); value.add(new LambdaAjaxFormComponentUpdatingBehavior("change", t -> t.add(getParent()))); add(value); }
public BooleanLiteralValueEditor(String aId, IModel<KBStatement> aModel) { super(aId, CompoundPropertyModel.of(aModel)); value = new CheckBox("value"); value.setOutputMarkupId(true); value.add(new LambdaAjaxFormComponentUpdatingBehavior("change", t -> t.add(getParent()))); add(value); }
Model.of(!hiddenLayerIds.contains(layer.getId()))); layerVisible.add(new LambdaAjaxFormComponentUpdatingBehavior("change", _target -> { if (!layerVisible.getModelObject()) { hiddenLayerIds.add(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);
public DocumentRepositorySelectionForm(String aId) { super(aId); DropDownChoice<DocumentRepository> repositoryCombo = new BootstrapSelect<DocumentRepository>("repositoryCombo", new PropertyModel<DocumentRepository>(ExternalSearchAnnotationSidebar.this, "currentRepository"), repositoriesModel); repositoryCombo.setChoiceRenderer(new ChoiceRenderer<DocumentRepository>("name")); repositoryCombo.setNullValid(false); // Just update the selection repositoryCombo.add(new LambdaAjaxFormComponentUpdatingBehavior("change")); add(repositoryCombo); } }
public ProjectSelectionPanel(String id, IModel<Project> aModel) { super(id); overviewList = new OverviewListChoice<>("project"); overviewList.setChoiceRenderer(new ChoiceRenderer<>("name")); overviewList.setModel(aModel); overviewList.setChoices(LambdaModel.of(this::listProjects)); overviewList.add(new LambdaAjaxFormComponentUpdatingBehavior("change", this::onChange)); add(overviewList); add(createLink = new LambdaAjaxLink("create", this::actionCreate)); MetaDataRoleAuthorizationStrategy.authorize(createLink, Component.RENDER, StringUtils.join( new String[] { Role.ROLE_ADMIN.name(), Role.ROLE_PROJECT_CREATOR.name() }, ",")); }
public DocumentRepositorySelectionForm(String aId) { super(aId); DropDownChoice<DocumentRepository> repositoryCombo = new BootstrapSelect<DocumentRepository>( "repositoryCombo", new PropertyModel<DocumentRepository>(SearchPage.this, "currentRepository"), repositoriesModel) { private static final long serialVersionUID = 1L; { setChoiceRenderer(new ChoiceRenderer<DocumentRepository>("name")); setNullValid(false); } @Override protected CharSequence getDefaultChoice(String aSelectedValue) { return ""; } }; // Just update the selection repositoryCombo.add(new LambdaAjaxFormComponentUpdatingBehavior("change")); add(repositoryCombo); }
public ProjectSelectionPanel(String id, IModel<Project> aModel) { super(id); overviewList = new OverviewListChoice<>("project"); overviewList.setChoiceRenderer(new ChoiceRenderer<>("name")); overviewList.setModel(aModel); overviewList.setChoices(LambdaModel.of(this::listProjects)); overviewList.add(new LambdaAjaxFormComponentUpdatingBehavior("change", this::onChange)); add(overviewList); add(createLink = new LambdaAjaxLink("create", this::actionCreate)); MetaDataRoleAuthorizationStrategy.authorize(createLink, Component.RENDER, StringUtils.join( new String[] { Role.ROLE_ADMIN.name(), Role.ROLE_PROJECT_CREATOR.name() }, ",")); }
public DocumentRepositorySelectionForm(String aId) { super(aId); DropDownChoice<DocumentRepository> repositoryCombo = new BootstrapSelect<DocumentRepository>( "repositoryCombo", new PropertyModel<DocumentRepository>(SearchPage.this, "currentRepository"), repositoriesModel) { private static final long serialVersionUID = 1L; { setChoiceRenderer(new ChoiceRenderer<DocumentRepository>("name")); setNullValid(false); } @Override protected CharSequence getDefaultChoice(String aSelectedValue) { return ""; } }; // Just update the selection repositoryCombo.add(new LambdaAjaxFormComponentUpdatingBehavior("change")); add(repositoryCombo); }