protected void populateItem(final ListItem<SiteNodePluginEntry> item) {
Link<Void> link;
item.add(link = new Link<Void>("link") {
@Override
public void onClick() {
SiteNodePlugin plugin = item.getModelObject().getPlugin();
final Component currentEditor = getEditor();
// remember the last editor that is not a create node
// panel
if (lastEditor == null ||
currentEditor.getMetaData(EDITOR_NODE_TYPE) == null) {
lastEditor = currentEditor;
}
SimpleCallback goBack = new SimpleCallback() {
public void execute() {
setupEditor(lastEditor);
}
};
Panel panel = plugin.newCreateNodePanel(EDITOR_ID, getNewNodeParent(),
goBack);
panel.setMetaData(EDITOR_NODE_TYPE, plugin.getNodeType());
setupEditor(panel);
}
@Override
protected void onComponentTag(ComponentTag tag) {
super.onComponentTag(tag);
SiteNodePlugin plugin = item.getModelObject().getPlugin();
String editorNodeType = getEditor().getMetaData(EDITOR_NODE_TYPE);
if (plugin.getNodeType().equals(editorNodeType)) {
CharSequence klass = tag.getString("class");
if (klass == null) {
klass = "selected";
} else {
klass = klass + " selected";
}
tag.put("class", klass);
}
}
});
item.add(new WebMarkupContainer("separator") {
@Override
public boolean isVisible() {
return item.getIndex() != createNodesModel.getObject().size() - 1;
}
});
IModel<BrixNode> parent = getNewNodeParent();
SiteNodePlugin plugin = item.getModelObject().getPlugin();
link.add(new Label("label", plugin.newCreateNodeCaptionModel(parent)));
}
}.setReuseItems(false));
}