private Label createNoFeaturesWarningLabel() { Label label = new Label("noFeaturesWarning", "No features available!"); label.add(visibleWhen(() -> getModelObject().getFeatureStates().isEmpty())); return label; }
private Label createSelectedAnnotationLayerLabel() { Label label = new Label("selectedAnnotationLayer", new Model<String>()); label.setOutputMarkupPlaceholderTag(true); label.add(visibleWhen(() -> getModelObject().getPreferences().isRememberLayer())); return label; }
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; }
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; }
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; }
private LambdaAjaxLink createClearButton() { LambdaAjaxLink link = new LambdaAjaxLink("clear", editorPanel::actionClear); link.setOutputMarkupPlaceholderTag(true); link.add(visibleWhen(() -> getModelObject().getSelection().getAnnotation().isSet())); return link; }
public MenuBar(String aId) { super(aId); add(new LambdaStatelessLink("homeLink", () -> setResponsePage(getApplication().getHomePage()))); add(new LambdaStatelessLink("dashboardLink", () -> setResponsePage(ProjectDashboardPage.class)) .add(visibleWhen(() -> Session.get().getMetaData(SessionMetaData.CURRENT_PROJECT) != null))); add(new LambdaStatelessLink("projectsLink", () -> setResponsePage(ProjectsOverviewPage.class)) .add(visibleWhen(() -> userRepository.getCurrentUser() != null))); add(new LambdaStatelessLink("adminLink", () -> setResponsePage(AdminDashboardPage.class)) .add(visibleWhen(this::adminAreaAccessRequired))); }
public MenuBar(String aId) { super(aId); add(new LambdaStatelessLink("homeLink", () -> setResponsePage(getApplication().getHomePage()))); add(new LambdaStatelessLink("dashboardLink", () -> setResponsePage(ProjectDashboardPage.class)) .add(visibleWhen(() -> Session.get().getMetaData(SessionMetaData.CURRENT_PROJECT) != null))); add(new LambdaStatelessLink("projectsLink", () -> setResponsePage(ProjectsOverviewPage.class)) .add(visibleWhen(() -> userRepository.getCurrentUser() != null))); add(new LambdaStatelessLink("adminLink", () -> setResponsePage(AdminDashboardPage.class)) .add(visibleWhen(this::adminAreaAccessRequired))); }
private Label createSelectedAnnotationTypeLabel() { Label label = new Label("selectedAnnotationType", LoadableDetachableModel.of(() -> { try { return String.valueOf(WebAnnoCasUtil.selectByAddr(editorPanel.getEditorCas(), getModelObject().getSelection().getAnnotation().getId())).trim(); } catch (IOException e) { return ""; } })); label.setOutputMarkupPlaceholderTag(true); // We show the extended info on the selected annotation only when run in development mode label.add(visibleWhen(() -> getModelObject().getSelection().getAnnotation().isSet() && DEVELOPMENT.equals(getApplication().getConfigurationType()))); return label; }
private Form<Void> clearSkippedRecommendationForm() { Form<Void> form = new Form<>(CID_LEARN_FROM_SKIPPED_RECOMMENDATION_FORM); form.add(LambdaBehavior.visibleWhen(() -> { ActiveLearningUserState alState = alStateModel.getObject(); return alState.isSessionActive() && !alState.getSuggestion().isPresent() && activeLearningService.hasSkippedSuggestions( getModelObject().getUser(), alState.getLayer()); })); form.setOutputMarkupPlaceholderTag(true); form.add(new Label(CID_ONLY_SKIPPED_RECOMMENDATION_LABEL, "There are only skipped suggestions. Do you want to learn these again?")); form.add(new LambdaAjaxButton<>(CID_LEARN_SKIPPED_ONES, this::actionClearSkippedRecommendations)); return form; }
private Form<Void> clearSkippedRecommendationForm() { Form<Void> form = new Form<>(CID_LEARN_FROM_SKIPPED_RECOMMENDATION_FORM); form.add(LambdaBehavior.visibleWhen(() -> { ActiveLearningUserState alState = alStateModel.getObject(); return alState.isSessionActive() && !alState.getSuggestion().isPresent() && activeLearningService.hasSkippedSuggestions( getModelObject().getUser(), alState.getLayer()); })); form.setOutputMarkupPlaceholderTag(true); form.add(new Label(CID_ONLY_SKIPPED_RECOMMENDATION_LABEL, "There are only skipped suggestions. Do you want to learn these again?")); form.add(new LambdaAjaxButton<>(CID_LEARN_SKIPPED_ONES, this::actionClearSkippedRecommendations)); return form; }
public DocumentMetadataAnnotationDetailPanel(String aId, IModel<VID> aModel, IModel<SourceDocument> aDocument, IModel<String> aUsername, JCasProvider aJCasProvider, IModel<Project> aProject, AnnotationPage aAnnotationPage) { super(aId, aModel); setOutputMarkupPlaceholderTag(true); sourceDocument = aDocument; username = aUsername; annotationPage = aAnnotationPage; jcasProvider = aJCasProvider; project = aProject; add(featureList = createFeaturesList()); add(new LambdaAjaxLink("delete", this::actionDelete)); add(LambdaBehavior.visibleWhen(() -> getModelObject() != null && getModelObject().isSet())); }
@Override protected void populateItem(ListItem<Project> aItem) { LambdaStatelessLink projectLink = new LambdaStatelessLink(MID_PROJECT_LINK, () -> selectProject(aItem.getModelObject())); projectLink.add(new Label(MID_NAME, aItem.getModelObject().getName())); DateLabel createdLabel = DateLabel.forDatePattern(MID_CREATED, () -> aItem.getModelObject().getCreated(), "yyyy-MM-dd"); createdLabel.add(visibleWhen(() -> createdLabel.getModelObject() != null)); aItem.add(createdLabel); aItem.add(projectLink); aItem.add(createRoleBadges(aItem.getModelObject())); }
public DocumentMetadataAnnotationDetailPanel(String aId, IModel<VID> aModel, IModel<SourceDocument> aDocument, IModel<String> aUsername, JCasProvider aJCasProvider, IModel<Project> aProject, AnnotationPage aAnnotationPage) { super(aId, aModel); setOutputMarkupPlaceholderTag(true); sourceDocument = aDocument; username = aUsername; annotationPage = aAnnotationPage; jcasProvider = aJCasProvider; project = aProject; add(featureList = createFeaturesList()); add(new LambdaAjaxLink("delete", this::actionDelete)); add(LambdaBehavior.visibleWhen(() -> getModelObject() != null && getModelObject().isSet())); }
@Override protected void populateItem(ListItem<Project> aItem) { LambdaStatelessLink projectLink = new LambdaStatelessLink(MID_PROJECT_LINK, () -> selectProject(aItem.getModelObject())); projectLink.add(new Label(MID_NAME, aItem.getModelObject().getName())); DateLabel createdLabel = DateLabel.forDatePattern(MID_CREATED, () -> aItem.getModelObject().getCreated(), "yyyy-MM-dd"); createdLabel.add(visibleWhen(() -> createdLabel.getModelObject() != null)); aItem.add(createdLabel); aItem.add(projectLink); aItem.add(createRoleBadges(aItem.getModelObject())); }
private AnnotationEditorBase createAnnotationEditor() { String editorId = getModelObject().getPreferences().getEditor(); AnnotationEditorFactory factory = editorRegistry.getEditorFactory(editorId); if (factory == null) { factory = editorRegistry.getDefaultEditorFactory(); } AnnotationEditorBase editor = factory.create("editor", getModel(), detailEditor, this::getEditorCas); editor.add(LambdaBehavior.visibleWhen(() -> getModelObject().getDocument() != null)); editor.setOutputMarkupPlaceholderTag(true); return editor; }
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; }
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; }
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 WebMarkupContainer createFeatureEditorPanel() { WebMarkupContainer container = new WebMarkupContainer("featureEditorsContainer"); container.add(visibleWhen(() -> getModelObject().getSelection().getAnnotation().isSet())); // Add placeholder since wmc might start out invisible. Without the placeholder we // cannot make it visible in an AJAX call container.setOutputMarkupPlaceholderTag(true); container.add(createNoFeaturesWarningLabel()); container.add(featureEditorPanelContent = createFeatureEditorPanelContent()); container.add(createSelectedTextLabel()); container.add(selectedAnnotationLayer = createSelectedAnnotationLayerLabel()); return container; }