Java Code Examples for org.apache.wicket.markup.repeater.Item#setOutputMarkupId()
The following examples show how to use
org.apache.wicket.markup.repeater.Item#setOutputMarkupId() .
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: StatementEditor.java From inception with Apache License 2.0 | 4 votes |
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 2
Source File: StatementGroupPanel.java From inception with Apache License 2.0 | 4 votes |
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 3
Source File: StatementEditor.java From inception with Apache License 2.0 | 4 votes |
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); }
Example 4
Source File: FeatureEditorListPanel.java From webanno with Apache License 2.0 | 4 votes |
@Override protected void populateItem(final Item<FeatureState> item) { LOG.trace("FeatureEditorPanelContent.populateItem(" + item.getModelObject().feature.getUiName() + ": " + item.getModelObject().value + ")"); // Feature editors that allow multiple values may want to update themselves, // e.g. to add another slot. item.setOutputMarkupId(true); final FeatureState featureState = item.getModelObject(); final FeatureEditor editor; // Look up a suitable editor and instantiate it FeatureSupport featureSupport = featureSupportRegistry .getFeatureSupport(featureState.feature); AnnotationDetailEditorPanel editorPanel = findParent(AnnotationDetailEditorPanel.class); editor = featureSupport.createEditor("editor", FeatureEditorListPanel.this, editorPanel, getModel(), item.getModel()); // We need to enable the markup ID here because we use it during the AJAX behavior // that automatically saves feature editors on change/blur. // Check addAnnotateActionBehavior. editor.setOutputMarkupId(true); editor.setOutputMarkupPlaceholderTag(true); // Ensure that markup IDs of feature editor focus components remain constant across // refreshes of the feature editor panel. This is required to restore the focus. editor.getFocusComponent().setOutputMarkupId(true); editor.getFocusComponent() .setMarkupId(ID_PREFIX + editor.getModelObject().feature.getId()); if (!featureState.feature.getLayer().isReadonly()) { AnnotatorState state = getModelObject(); // Whenever it is updating an annotation, it updates automatically when a // component for the feature lost focus - but updating is for every component // edited LinkFeatureEditors must be excluded because the auto-update will break // the ability to add slots. Adding a slot is NOT an annotation action. if ( state.getSelection().getAnnotation().isSet() && !(editor instanceof LinkFeatureEditor) ) { editor.addFeatureUpdateBehavior(); } else if (!(editor instanceof LinkFeatureEditor)) { editor.getFocusComponent().add(new AjaxFormComponentUpdatingBehavior("change") { private static final long serialVersionUID = 5179816588460867471L; @Override protected void onUpdate(AjaxRequestTarget aTarget) { owner.refresh(aTarget); } }); } // Add tooltip on label StringBuilder tooltipTitle = new StringBuilder(); tooltipTitle.append(featureState.feature.getUiName()); if (featureState.feature.getTagset() != null) { tooltipTitle.append(" ("); tooltipTitle.append(featureState.feature.getTagset().getName()); tooltipTitle.append(')'); } Component labelComponent = editor.getLabelComponent(); // labelComponent.setMarkupId( // ID_PREFIX + editor.getModelObject().feature.getId() + "-w-lbl"); labelComponent.add(new AttributeAppender("style", "cursor: help", ";")); labelComponent.add(new DescriptionTooltipBehavior(tooltipTitle.toString(), featureState.feature.getDescription())); } else { editor.getFocusComponent().setEnabled(false); } item.add(editor); }
Example 5
Source File: RecommendedArtifactPortfolioPanel.java From artifact-listener with Apache License 2.0 | 4 votes |
@Override protected void addItemColumns(final Item<Artifact> item, IModel<? extends Artifact> itemModel) { item.setOutputMarkupId(true); Artifact artifact = item.getModelObject(); final IModel<Artifact> artifactModel = new ArtifactModel(Model.of(item.getModelObject().getArtifactKey())); final ArtifactLastVersionModel artifactLastVersionModel = new ArtifactLastVersionModel(artifactModel); item.add(new ClassAttributeAppender(new LoadableDetachableModel<String>() { private static final long serialVersionUID = 1L; @Override protected String load() { User user = MavenArtifactNotifierSession.get().getUser(); boolean isFollowed = user != null && userService.isFollowedArtifact(user, item.getModelObject()); boolean isDeprecated = artifactModel.getObject() != null && ArtifactDeprecationStatus.DEPRECATED.equals(artifactModel.getObject().getDeprecationStatus()); return isFollowed ? "success" : (isDeprecated ? "warning" : null); } })); // GroupId column item.add(new Label("groupId", BindingModel.of(artifactModel, Binding.artifact().group().groupId()))); item.add(new ExternalLink("groupLink", mavenCentralSearchUrlService.getGroupUrl(artifact.getGroup().getGroupId()))); // ArtifactId column Link<Void> localArtifactLink = ArtifactDescriptionPage.linkDescriptor(artifactModel).link("localArtifactLink"); localArtifactLink.add(new Label("artifactId", BindingModel.of(artifactModel, Binding.artifact().artifactId()))); item.add(localArtifactLink); item.add(new ExternalLink("artifactLink", mavenCentralSearchUrlService.getArtifactUrl(artifact.getGroup().getGroupId(), artifact.getArtifactId()))); // LastVersion, lastUpdateDate columns item.add(new Label("synchronizationPlannedPlaceholder", new ResourceModel("artifact.follow.synchronizationPlanned")) { private static final long serialVersionUID = 1L; @Override protected void onConfigure() { super.onConfigure(); setVisible(artifactModel.getObject() != null && !artifactLastVersionModel.isLastVersionAvailable()); } }); WebMarkupContainer localContainer = new WebMarkupContainer("followedArtifact") { private static final long serialVersionUID = 1L; @Override protected void onConfigure() { super.onConfigure(); setVisible(artifactLastVersionModel.isLastVersionAvailable()); } }; localContainer.add(new ArtifactVersionTagPanel("latestVersion", Model.of(artifactLastVersionModel.getLastVersion()))); String latestVersion = (artifact.getLatestVersion() != null ? artifact.getLatestVersion().getVersion() : ""); localContainer.add(new ExternalLink("versionLink", mavenCentralSearchUrlService.getVersionUrl(artifact.getGroup().getGroupId(), artifact.getArtifactId(), latestVersion))); localContainer.add(new DateLabelWithPlaceholder("lastUpdateDate", Model.of(artifactLastVersionModel.getLastVersionUpdateDate()), DatePattern.SHORT_DATE)); item.add(localContainer); // Followers count column Label followersCount = new CountLabel("followersCount", "artifact.follow.dataView.followers", BindingModel.of(artifactModel, Binding.artifact().followersCount())); followersCount.add(new AttributeModifier("class", new LoadableDetachableModel<String>() { private static final long serialVersionUID = 1L; @Override protected String load() { if (artifactModel.getObject() != null && artifactModel.getObject().getFollowersCount() > 0) { return "badge"; } return null; } })); item.add(followersCount); // Follow actions item.add(new ArtifactFollowActionsPanel("followActions", artifactModel)); }