Java Code Examples for org.apache.wicket.markup.html.list.ListView#setModel()

The following examples show how to use org.apache.wicket.markup.html.list.ListView#setModel() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: webanno   File: TelemetryDetailsPanel.java    License: Apache License 2.0 6 votes vote down vote up
public TelemetryDetailsPanel(String aId, IModel<List<TelemetryDetail>> aModel)
{
    super(aId, aModel);
    
    ListView<TelemetryDetail> details = new ListView<TelemetryDetail>("details") {
        private static final long serialVersionUID = 5156853968330655499L;

        @Override
        protected void populateItem(ListItem<TelemetryDetail> aItem)
        {
            aItem.add(new Label("key", aItem.getModelObject().getKey()));
            aItem.add(new Label("value", aItem.getModelObject().getValue()));
            aItem.add(new Label("description", aItem.getModelObject().getDescription()));
        }
    };
    
    details.setModel(aModel);

    add(details);
}
 
Example 2
Source Project: inception   File: ActiveLearningSidebar.java    License: Apache License 2.0 5 votes vote down vote up
private ListView<LearningRecord> createLearningHistoryListView()
{
    ListView<LearningRecord> learningHistory = new ListView<LearningRecord>(
            CID_HISTORY_LISTVIEW)
    {
        private static final long serialVersionUID = 5594228545985423567L;

        @Override
        protected void populateItem(ListItem<LearningRecord> item)
        {
            LearningRecord rec = item.getModelObject();
            AnnotationFeature recAnnotationFeature = rec.getAnnotationFeature();
            String recFeatureValue;
            if (recAnnotationFeature != null) {
                FeatureSupport featureSupport = featureSupportRegistry
                    .getFeatureSupport(recAnnotationFeature);
                recFeatureValue = featureSupport
                    .renderFeatureValue(recAnnotationFeature, rec.getAnnotation());
            }
            else {
                recFeatureValue = rec.getAnnotation();
            }
            LambdaAjaxLink textLink = new LambdaAjaxLink(CID_JUMP_TO_ANNOTATION, _target -> 
                    actionSelectHistoryItem(_target, item.getModelObject()));
            textLink.setBody(rec::getTokenText);
            item.add(textLink);

            item.add(new Label(CID_RECOMMENDED_ANNOTATION, recFeatureValue));
            item.add(new Label(CID_USER_ACTION, rec.getUserAction()));
            item.add(
                new LambdaAjaxLink(CID_REMOVE_RECORD, t -> actionRemoveHistoryItem(t, rec)));
        }
    };
    learningRecords = LambdaModel.of(this::listLearningRecords);
    learningHistory.setModel(learningRecords);
    return learningHistory;
}
 
Example 3
Source Project: inception   File: ImageSidebar.java    License: Apache License 2.0 5 votes vote down vote up
public ImageSidebar(String aId, IModel<AnnotatorState> aModel,
        AnnotationActionHandler aActionHandler, CasProvider aCasProvider,
        AnnotationPage aAnnotationPage)
{
    super(aId, aModel, aActionHandler, aCasProvider, aAnnotationPage);

    mainContainer = new WebMarkupContainer("mainContainer");
    mainContainer.setOutputMarkupId(true);
    add(mainContainer);

    ListView<ImageHandle> images = new ListView<ImageHandle>("images")
    {
        private static final long serialVersionUID = -1203277069357712752L;

        @Override
        protected void populateItem(ListItem<ImageHandle> item)
        {
            item.add(new ExternalLink("open", item.getModelObject().getUrl()));
            LambdaAjaxLink jumpToLink = new LambdaAjaxLink("jumpTo",
                _target -> actionJumpTo(_target, item.getModelObject()));
            item.add(jumpToLink);
            jumpToLink.add(new ExternalImage("image", item.getModelObject().getUrl()));
        }
    };
    images.setModel(LoadableDetachableModel.of(this::listImageUrls));
    
    mainContainer.add(images);
}
 
Example 4
Source Project: inception   File: RecommenderInfoPanel.java    License: Apache License 2.0 4 votes vote down vote up
public RecommenderInfoPanel(String aId, IModel<AnnotatorState> aModel)
{
    super(aId, aModel);
    
    setOutputMarkupId(true);
    
    WebMarkupContainer recommenderContainer = new WebMarkupContainer("recommenderContainer");
    add(recommenderContainer);
    
    ListView<Recommender> searchResultGroups = new ListView<Recommender>("recommender")
    {
        private static final long serialVersionUID = -631500052426449048L;

        @Override
        protected void populateItem(ListItem<Recommender> item)
        {
            User user = userService.getCurrentUser();
            Recommender recommender = item.getModelObject();
            List<EvaluatedRecommender> activeRecommenders = recommendationService
                    .getActiveRecommenders(user, recommender.getLayer());
            Optional<EvaluationResult> evalResult = activeRecommenders.stream()
                    .filter(r -> r.getRecommender().equals(recommender))
                    .map(EvaluatedRecommender::getEvaluationResult)
                    .findAny();
            item.add(new Label("name", recommender.getName()));
            item.add(new Label("state", evalResult.isPresent() ? "active" : "off"));

            item.add(new LambdaAjaxLink("acceptAll", _target -> 
                    actionAcceptAll(_target, recommender)));
            
            WebMarkupContainer resultsContainer = new WebMarkupContainer("resultsContainer");
            // Show results only if the evaluation was not skipped (and of course only if the
            // result is actually present).
            resultsContainer.setVisible(evalResult.map(r -> !r.isEvaluationSkipped())
                    .orElse(evalResult.isPresent()));
            resultsContainer.add(new Label("f1Score",
                    evalResult.map(EvaluationResult::computeF1Score).orElse(0.0d)));
            resultsContainer.add(new Label("accuracy",
                    evalResult.map(EvaluationResult::computeAccuracyScore).orElse(0.0d)));
            resultsContainer.add(new Label("precision",
                    evalResult.map(EvaluationResult::computePrecisionScore).orElse(0.0d)));
            resultsContainer.add(new Label("recall",
                    evalResult.map(EvaluationResult::computeRecallScore).orElse(0.0d)));
            item.add(resultsContainer);
        }
    };
    IModel<List<Recommender>> recommenders = LoadableDetachableModel.of(() -> 
            recommendationService.listEnabledRecommenders(aModel.getObject().getProject()));
    searchResultGroups.setModel(recommenders);
    
    recommenderContainer.add(visibleWhen(() -> !recommenders.getObject().isEmpty()));
    recommenderContainer.add(searchResultGroups);

    WebMarkupContainer noRecommendersWarning = new WebMarkupContainer("noRecommendersWarning");
    noRecommendersWarning.setOutputMarkupPlaceholderTag(true);
    noRecommendersWarning.add(visibleWhen(() -> recommenders.getObject().isEmpty()));
    add(noRecommendersWarning);
}
 
Example 5
public SearchResultGroup(String aId, String aMarkupId, MarkupContainer aMarkupProvider,
    String groupKey, IModel<ResultsGroup> aModel)
{
    super(aId, aMarkupId, aMarkupProvider, aModel);

    ListView<SearchResult> statementList = new ListView<SearchResult>("results")
    {
        private static final long serialVersionUID = 5811425707843441458L;

        @Override
        protected void populateItem(ListItem<SearchResult> aItem)
        {
            Project currentProject = SearchAnnotationSidebar.this.getModel().getObject()
                    .getProject();
            SearchResult result = aItem.getModelObject();

            LambdaAjaxLink lambdaAjaxLink = new LambdaAjaxLink("showSelectedDocument",
                t -> {
                    selectedResult = aItem.getModelObject();
                    actionShowSelectedDocument(t,
                            documentService.getSourceDocument(currentProject,
                                    selectedResult.getDocumentTitle()),
                            selectedResult.getOffsetStart(),
                            selectedResult.getOffsetEnd());
                });
            aItem.add(lambdaAjaxLink);

            AjaxCheckBox selected = new AjaxCheckBox("selected",
                Model.of(result.isSelectedForAnnotation()))
            {
                private static final long serialVersionUID = -6955396602403459129L;

                @Override
                protected void onUpdate(AjaxRequestTarget target)
                {
                    SearchResult modelObject = aItem.getModelObject();
                    modelObject.setSelectedForAnnotation(getModelObject());
                    if (!getModelObject()) {
                        // not all results in the document are selected, so set document
                        // level selection to false
                        target.add(resultsGroupContainer);
                    }
                }
            };
            selected.setVisible(!result.isReadOnly());
            aItem.add(selected);

            String sentence = new String();

            sentence = sentence + aItem.getModel().getObject().getLeftContext() + "<mark>"
                    + aItem.getModel().getObject().getText() + "</mark>"
                    + aItem.getModel().getObject().getRightContext();

            lambdaAjaxLink
                    .add(new Label("sentence", sentence).setEscapeModelStrings(false));
        }
    };
    statementList
            .setModel(LoadableDetachableModel.of(() -> aModel.getObject().getResults()));
    add(statementList);
}
 
Example 6
Source Project: webanno   File: TelemetrySettingsPage.java    License: Apache License 2.0 4 votes vote down vote up
public TelemetrySettingsPage()
{
    Form<Void> form = new Form<>("form");
    
    settingModel = new ListModel<TelemetrySettings>(listSettings());
    
    ListView<TelemetrySettings> settings = new ListView<TelemetrySettings>("settings")
    {
        private static final long serialVersionUID = 7433492093706423431L;

        @Override
        protected void populateItem(ListItem<TelemetrySettings> aItem)
        {
            // We already filtered for settings where the support exists in listSettings, so
            // we can rely on the support being present here.
            TelemetrySupport<?> support = telemetryService
                    .getTelemetrySuppport(aItem.getModelObject().getSupport()).get();
            
            int version = support.getVersion();

            aItem.add(new Label("name", support.getName()));

            aItem.add(support.createTraitsEditor("traitsEditor", aItem.getModel()));
            
            aItem.add(new WebMarkupContainer("reviewRequiredMessage").add(visibleWhen(
                () -> aItem.getModelObject().getVersion() < version)));
            
            TelemetryDetailsPanel details = new TelemetryDetailsPanel("details",
                    new ListModel<TelemetryDetail>(support.getDetails()));
            details.setOutputMarkupPlaceholderTag(true);
            details.setVisible(false);
            aItem.add(details);
            
            aItem.add(new LambdaAjaxLink("toggleDetails", _target -> {
                details.setVisible(!details.isVisible());
                _target.add(details);
            }));
        }
    };
    settings.setModel(settingModel);
    form.add(settings);
    
    form.add(new LambdaAjaxButton<Void>("save", this::actionSave).triggerAfterSubmit());

    add(form);
}