@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);