IModel<String> cssClass = cssClassFor(componentFactory, viewButtonIcon);
viewButtonIcon.add(AttributeModifier.replace("class", "ViewLinkItem " + cssClass.getObject()));
link.setVisible(false);
} else {
IModel<String> cssClass = cssClassFor(componentFactory, viewItemIcon);
viewItemIcon.add(new CssClassAppender(cssClass));
}
item.add(link);
}
private IModel<String> cssClassFor(final ComponentFactory componentFactory, Label viewIcon) {
IModel<String> cssClass = null;
if (componentFactory instanceof CollectionContentsAsFactory) {
CollectionContentsAsFactory collectionContentsAsFactory = (CollectionContentsAsFactory) componentFactory;
cssClass = collectionContentsAsFactory.getCssClass();
viewIcon.setDefaultModelObject("");
viewIcon.setEscapeModelStrings(true);
}
if (cssClass == null) {
String name = componentFactory.getName();
cssClass = Model.of(StringExtensions.asLowerDashed(name));
// Small hack: if there is no specific CSS class then we assume that background-image is used
// the span.ViewItemLink should have some content to show it
// FIX: find a way to do this with CSS (width and height don't seems to help)
viewIcon.setDefaultModelObject("     ");
viewIcon.setEscapeModelStrings(false);
}
return cssClass;
}
private IModel<String> nameFor(final ComponentFactory componentFactory) {
IModel<String> name = null;
if (componentFactory instanceof CollectionContentsAsFactory) {
CollectionContentsAsFactory collectionContentsAsFactory = (CollectionContentsAsFactory) componentFactory;
name = collectionContentsAsFactory.getTitleLabel();
}
if (name == null) {
name = Model.of(componentFactory.getName());
}
return name;
}
};
container.add(listView);
addOrReplace(views);
}
for(i=0; i<MAX_NUM_UNDERLYING_VIEWS; i++) {
Component component = underlyingViews[i];
if(component != null) {
if(i != selected) {
component.add(new CssClassAppender(INVISIBLE_CLASS));
} else {
selectedComponent = component;
}
}
}