Java Code Examples for org.apache.wicket.markup.repeater.Item#getModel()

The following examples show how to use org.apache.wicket.markup.repeater.Item#getModel() . 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 File: ProductCatalogPage.java    From the-app with Apache License 2.0 5 votes vote down vote up
private Component productView(IModel<List<ProductInfo>> model) {
    return new DataView<ProductInfo>("products", productDataProvider(model)) {

        @Override
        protected void populateItem(final Item<ProductInfo> item) {
            ProductItemPanel productItem = new ProductItemPanel("productItem", feedback, item.getModel());
            productItem.setOutputMarkupId(true);
            item.add(productItem);
        }
    };
}
 
Example 2
Source File: ProductCatalogPage.java    From AppStash with Apache License 2.0 5 votes vote down vote up
private Component productView(IModel<List<ProductInfo>> model) {
    return new DataView<ProductInfo>("products", productDataProvider(model)) {

        @Override
        protected void populateItem(final Item<ProductInfo> item) {
            ProductItemPanel productItem = new ProductItemPanel("productItem", feedback, item.getModel());
            productItem.setOutputMarkupId(true);
            item.add(productItem);
        }
    };
}
 
Example 3
Source File: StatementEditor.java    From inception with Apache License 2.0 4 votes vote down vote up
public ViewMode(String aId, IModel<KBStatement> aStatement) {
    super(aId, "viewMode", StatementEditor.this, aStatement);

    CompoundPropertyModel<KBStatement> compoundModel = new CompoundPropertyModel<>(
            aStatement);

    add(new Label("value", compoundModel.bind("value")));
    add(new Label("language", compoundModel.bind("language")) {
        private static final long serialVersionUID = 3436068825093393740L;

        @Override
        protected void onConfigure()
        {
            super.onConfigure();
            
            setVisible(isNotEmpty(aStatement.getObject().getLanguage()));
        }
    });
    
    LambdaAjaxLink editLink = new LambdaAjaxLink("edit", StatementEditor.this::actionEdit)
            .onConfigure((_this) -> _this.setVisible(!statement.getObject().isInferred()));
    editLink.add(new WriteProtectionBehavior(kbModel));
    add(editLink);

    LambdaAjaxLink addQualifierLink = new LambdaAjaxLink("addQualifier",
        t -> actionAddQualifier(t, aStatement.getObject()))
        .onConfigure((_this) -> _this.setVisible(!statement.getObject().isInferred() &&
            kbModel.getObject().getReification().supportsQualifier()));
    addQualifierLink.add(new Label("label", new ResourceModel("qualifier.add")));
    addQualifierLink.add(new WriteProtectionBehavior(kbModel));
    add(addQualifierLink);
    
    LambdaAjaxLink makeExplicitLink = new LambdaAjaxLink("makeExplicit",
            StatementEditor.this::actionMakeExplicit).onConfigure(
                (_this) -> _this.setVisible(statement.getObject().isInferred()));
    makeExplicitLink.add(new WriteProtectionBehavior(kbModel));
    add(makeExplicitLink);

    RefreshingView<KBQualifier> qualifierList = new RefreshingView<KBQualifier>("qualifierList")
    {
        private static final long serialVersionUID = -8342276415072873329L;

        @Override
        protected Iterator<IModel<KBQualifier>> getItemModels()
        {
            return new ModelIteratorAdapter<KBQualifier>(
                statement.getObject().getQualifiers())
            {
                @Override protected IModel<KBQualifier> model(KBQualifier object)
                {
                    return LambdaModel.of(() -> object);
                }
            };
        }

        @Override
        protected void populateItem(Item<KBQualifier> aItem)
        {
            QualifierEditor editor = new QualifierEditor("qualifier", kbModel,
                aItem.getModel());
            aItem.add(editor);
            aItem.setOutputMarkupId(true);
        }
    };
    qualifierList.setItemReuseStrategy(new ReuseIfModelsEqualStrategy());

    qualifierListWrapper = new WebMarkupContainer("qualifierListWrapper");
    qualifierListWrapper.setOutputMarkupId(true);
    qualifierListWrapper.add(qualifierList);
    add(qualifierListWrapper);
}
 
Example 4
Source File: StatementGroupPanel.java    From inception with Apache License 2.0 4 votes vote down vote up
public ExistingStatementGroupFragment(String aId)
{
    super(aId, "existingStatementGroup", StatementGroupPanel.this, groupModel);

    StatementGroupBean statementGroupBean = groupModel.getObject();
    Form<StatementGroupBean> form = new Form<StatementGroupBean>("form");
    LambdaAjaxLink propertyLink = new LambdaAjaxLink("propertyLink",
            this::actionPropertyLinkClicked);
    propertyLink.add(new Label("property", groupModel.bind("property.uiLabel")));
    form.add(propertyLink);

    // TODO what about handling type intersection when multiple range statements are
    // present?
    // obtain IRI of property range, if existent
    IModel<KBProperty> propertyModel = Model.of(statementGroupBean.getProperty());

    form.add(new IriInfoBadge("statementIdtext", groupModel.bind("property.identifier")));
                
    RefreshingView<KBStatement> statementList = new RefreshingView<KBStatement>(
            "statementList") {
        private static final long serialVersionUID = 5811425707843441458L;

        @Override
        protected Iterator<IModel<KBStatement>> getItemModels() {
            return new ModelIteratorAdapter<KBStatement>(
                statementGroupBean.getStatements()) {
                @Override
                protected IModel<KBStatement> model(KBStatement object) {
                    return LambdaModel.of(() -> object);
                }
            };
        }

        @Override
        protected void populateItem(Item<KBStatement> aItem) {
            StatementEditor editor = new StatementEditor("statement",
                    groupModel.bind("kb"), aItem.getModel(), propertyModel);
            aItem.add(editor);
            aItem.setOutputMarkupId(true);
        }

    };
    statementList.setItemReuseStrategy(new ReuseIfModelsEqualStrategy());

    // wrap the RefreshingView in a WMC, otherwise we can't redraw it with AJAX (see
    // https://cwiki.apache.org/confluence/display/WICKET/How+to+repaint+a+ListView+via+Ajax)
    statementListWrapper = new WebMarkupContainer("statementListWrapper");
    statementListWrapper.setOutputMarkupId(true);
    statementListWrapper.add(statementList);
    form.add(statementListWrapper);

    WebMarkupContainer statementGroupFooter = new WebMarkupContainer("statementGroupFooter");
    LambdaAjaxLink addLink = new LambdaAjaxLink("add", this::actionAddValue);
    addLink.add(new Label("label", new ResourceModel("statement.value.add")));
    addLink.add(new WriteProtectionBehavior(groupModel.bind("kb")));
    statementGroupFooter.add(addLink);

    AttributeAppender framehighlightAppender = new AttributeAppender("style",
            LoadableDetachableModel.of(() -> 
                "background-color:#" + getColoringStrategy().getFrameColor()
            ));
    statementGroupFooter.add(framehighlightAppender);
    form.add(framehighlightAppender);

    AttributeAppender highlightAppender = new AttributeAppender("style",
            LoadableDetachableModel.of(() -> {
                StatementColoringStrategy coloringStrategy = getColoringStrategy();
                return "background-color:#" + coloringStrategy.getBackgroundColor()
                        + ";color:#" + coloringStrategy.getTextColor();
            }));
    statementListWrapper.add(highlightAppender);

    form.add(statementGroupFooter);
    add(form);

}
 
Example 5
Source File: StatementEditor.java    From inception with Apache License 2.0 4 votes vote down vote up
public ViewMode(String aId, IModel<KBStatement> aStatement) {
    super(aId, "viewMode", StatementEditor.this, aStatement);

    CompoundPropertyModel<KBStatement> model = new CompoundPropertyModel<>(
            aStatement);
    
    WebMarkupContainer presenter;
    try {
        presenter = valueTypeRegistry
            .getValueSupport(aStatement.getObject(), property.getObject())
            .createPresenter("value", model, property, kbModel);
    }
    catch (IllegalArgumentException e) {
        LOG.warn("Unable to find an editor that supports the value type. "
                + "String Editor is used as default: {}", e.getLocalizedMessage());
        presenter = new StringLiteralValuePresenter("value", model);
    }
    add(presenter);
    LambdaAjaxLink editLink = new LambdaAjaxLink("edit", StatementEditor.this::actionEdit)
            .onConfigure((_this) -> _this.setVisible(!statement.getObject().isInferred()));
    editLink.add(new WriteProtectionBehavior(kbModel));
    add(editLink);

    LambdaAjaxLink addQualifierLink = new LambdaAjaxLink("addQualifier",
        t -> actionAddQualifier(t, aStatement.getObject()))
        .onConfigure((_this) -> _this.setVisible(!statement.getObject().isInferred() &&
            kbModel.getObject().getReification().supportsQualifier()));
    addQualifierLink.add(new Label("label", new ResourceModel("qualifier.add")));
    addQualifierLink.add(new WriteProtectionBehavior(kbModel));
    add(addQualifierLink);
    
    LambdaAjaxLink makeExplicitLink = new LambdaAjaxLink("makeExplicit",
            StatementEditor.this::actionMakeExplicit).onConfigure(
                (_this) -> _this.setVisible(statement.getObject().isInferred()));
    makeExplicitLink.add(new WriteProtectionBehavior(kbModel));
    add(makeExplicitLink);

    RefreshingView<KBQualifier> qualifierList = new RefreshingView<KBQualifier>("qualifierList")
    {
        private static final long serialVersionUID = -8342276415072873329L;

        @Override
        protected Iterator<IModel<KBQualifier>> getItemModels()
        {
            return new ModelIteratorAdapter<KBQualifier>(
                statement.getObject().getQualifiers())
            {
                @Override protected IModel<KBQualifier> model(KBQualifier object)
                {
                    return LambdaModel.of(() -> object);
                }
            };
        }

        @Override
        protected void populateItem(Item<KBQualifier> aItem)
        {
            QualifierEditor editor = new QualifierEditor("qualifier", kbModel,
                aItem.getModel());
            aItem.add(editor);
            aItem.setOutputMarkupId(true);
        }
    };
    qualifierList.setItemReuseStrategy(new ReuseIfModelsEqualStrategy());

    qualifierListWrapper = new WebMarkupContainer("qualifierListWrapper");
    qualifierListWrapper.setOutputMarkupId(true);
    qualifierListWrapper.add(qualifierList);
    add(qualifierListWrapper);
}