private Label createNoFeaturesWarningLabel() { Label label = new Label("noFeaturesWarning", "No features available!"); label.add(visibleWhen(() -> getModelObject().getFeatureStates().isEmpty())); return label; }
private Label createNoStatementLabel() { Label statementDoesNotExist = new Label("statementDoesNotExist", "There is no statement " + "in the KB which matches this SPO."); statementDoesNotExist .add(LambdaBehavior.onConfigure(component -> component.setVisible(!existStatements))); return statementDoesNotExist; }
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; }
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; }
layerTypes.setChoices(layerSupportRegistry::getAllTypes); layerTypes.add(LambdaBehavior .enabledWhen(() -> isNull(LayerDetailForm.this.getModelObject().getId()))); layerTypes.setRequired(true); layerTypes.setNullValid(false); anchoringMode.setChoiceRenderer(new EnumChoiceRenderer<>(this)); anchoringMode.setChoices(Arrays.asList(AnchoringMode.values())); anchoringMode.add(LambdaBehavior.onConfigure(_this -> { AnnotationLayer layer = LayerDetailForm.this.getModelObject(); allowStacking.add(LambdaBehavior.onConfigure(_this -> { AnnotationLayer layer = LayerDetailForm.this.getModelObject(); _this.setVisible(!isBlank(layer.getType())); crossSentence.add(LambdaBehavior.onConfigure(_this -> { AnnotationLayer layer = LayerDetailForm.this.getModelObject(); _this.setVisible(!isBlank(layer.getType())); showTextInHover.add(LambdaBehavior.onConfigure(_this -> { AnnotationLayer layer = LayerDetailForm.this.getModelObject(); _this.setVisible(!isBlank(layer.getType()) && linkedListBehavior.add(LambdaBehavior.onConfigure(_this -> { AnnotationLayer layer = LayerDetailForm.this.getModelObject(); _this.setVisible(!isBlank(layer.getType()) && CHAIN_TYPE.equals(layer.getType()));
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 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; }
layerTypes.setChoices(layerSupportRegistry::getAllTypes); layerTypes.add(LambdaBehavior .enabledWhen(() -> isNull(LayerDetailForm.this.getModelObject().getId()))); layerTypes.setRequired(true); layerTypes.setNullValid(false); anchoringMode.setChoiceRenderer(new EnumChoiceRenderer<>(this)); anchoringMode.setChoices(Arrays.asList(AnchoringMode.values())); anchoringMode.add(LambdaBehavior.onConfigure(_this -> { AnnotationLayer layer = LayerDetailForm.this.getModelObject(); allowStacking.add(LambdaBehavior.onConfigure(_this -> { AnnotationLayer layer = LayerDetailForm.this.getModelObject(); _this.setVisible(!isBlank(layer.getType())); crossSentence.add(LambdaBehavior.onConfigure(_this -> { AnnotationLayer layer = LayerDetailForm.this.getModelObject(); _this.setVisible(!isBlank(layer.getType())); showTextInHover.add(LambdaBehavior.onConfigure(_this -> { AnnotationLayer layer = LayerDetailForm.this.getModelObject(); _this.setVisible(!isBlank(layer.getType()) && linkedListBehavior.add(LambdaBehavior.onConfigure(_this -> { AnnotationLayer layer = LayerDetailForm.this.getModelObject(); _this.setVisible(!isBlank(layer.getType()) && CHAIN_TYPE.equals(layer.getType()));
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 Label createSelectedAnnotationLayerLabel() { Label label = new Label("selectedAnnotationLayer", new Model<String>()); label.setOutputMarkupPlaceholderTag(true); label.add(visibleWhen(() -> getModelObject().getPreferences().isRememberLayer())); return label; }
traitsContainer.setOutputMarkupId(true); add(new Label("name").add(visibleWhen(() -> isNotBlank(getModelObject().getName())))); add(new TextField<String>("uiName").setRequired(true)); add(new TextArea<String>("description")); required = new CheckBox("required"); required.setOutputMarkupId(true); required.add(LambdaBehavior.onConfigure(_this -> { boolean relevant = CAS.TYPE_NAME_STRING .equals(FeatureDetailForm.this.getModelObject().getType()); () -> featureSupportRegistry.getFeatureType(getModelObject()), (v) -> getModelObject().setType(v.getName()))); featureType.add(LambdaBehavior.onConfigure(_this -> { if (isNull(getModelObject().getId())) { featureType.setEnabled(true); visibleWhen(() -> !isNull(getModelObject().getId()))));
.setRequired(true) .add(this::validateUsername) .add(enabledWhen(() -> isCreate))); add(new Label("lastLogin")); add(new EmailTextField("email")); .add(visibleWhen(ManageUsersPage.this::isAdmin))); .add(visibleWhen(ManageUsersPage.this::isAdmin)));
private Label createStatementIndicatorLabel() { Label statementExists = new Label("statementExists", "There is at least one statement " + "in the KB which matches for this SPO."); statementExists .add(LambdaBehavior.onConfigure(component -> component.setVisible(existStatements))); return statementExists; }
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 WebMarkupContainer createKbInfoContainer(String aId) { WebMarkupContainer wmc = new WebMarkupContainer(aId); wmc.add(new Label("description", kbInfoModel.bind("description")) .add(LambdaBehavior.visibleWhen(() -> kbInfoModel.getObject() != null))); wmc.add(new Label("hostInstitutionName", kbInfoModel.bind("hostInstitutionName")) .add(LambdaBehavior.visibleWhen(() -> kbInfoModel.getObject() != null))); wmc.add(new Label("authorName", kbInfoModel.bind("authorName")) .add(LambdaBehavior.visibleWhen(() -> kbInfoModel.getObject() != null))); wmc.add(new ExternalLink("websiteURL", kbInfoModel.bind("websiteURL"), kbInfoModel.bind("websiteURL")) .add(LambdaBehavior.visibleWhen(() -> kbInfoModel.getObject() != null))); return wmc; }
traitsContainer.setOutputMarkupId(true); add(new Label("name").add(visibleWhen(() -> isNotBlank(getModelObject().getName())))); add(new TextField<String>("uiName").setRequired(true)); add(new TextArea<String>("description")); required = new CheckBox("required"); required.setOutputMarkupId(true); required.add(LambdaBehavior.onConfigure(_this -> { boolean relevant = CAS.TYPE_NAME_STRING .equals(FeatureDetailForm.this.getModelObject().getType()); () -> featureSupportRegistry.getFeatureType(getModelObject()), (v) -> getModelObject().setType(v.getName()))); featureType.add(LambdaBehavior.onConfigure(_this -> { if (isNull(getModelObject().getId())) { featureType.setEnabled(true); visibleWhen(() -> !isNull(getModelObject().getId()))));
.setRequired(true) .add(this::validateUsername) .add(enabledWhen(() -> isCreate))); add(new Label("lastLogin")); add(new EmailTextField("email")); .add(visibleWhen(ManageUsersPage.this::isAdmin))); .add(visibleWhen(ManageUsersPage.this::isAdmin)));
private Label createStatementIndicatorLabel() { Label statementExists = new Label("statementExists", "There is at least one statement " + "in the KB which matches for this SPO."); statementExists .add(LambdaBehavior.onConfigure(component -> component.setVisible(existStatements))); return statementExists; }
cancelLink.add(LambdaBehavior.enabledWhen(() -> thread != null)); add(cancelLink);
private Label createNoRecommendationLabel() { Label noRecommendation = new Label(CID_NO_RECOMMENDATION_LABEL, "There are no further suggestions."); noRecommendation.add(visibleWhen(() -> { ActiveLearningUserState alState = alStateModel.getObject(); return alState.isSessionActive() && !alState.getSuggestion().isPresent() && !activeLearningService.hasSkippedSuggestions( getModelObject().getUser(), alState.getLayer()); })); noRecommendation.setOutputMarkupPlaceholderTag(true); return noRecommendation; }