Brix brix = getModelObject().getBrix();
Form<Void> form = new Form<Void>("form");
add(form);
final ModelBuffer adapter = new ModelBuffer(nodeModel);
IModel<String> stringModel = adapter.forProperty("title");
form.add(new TextField<String>("title", stringModel));
String workspace = nodeModel.getObject().getSession().getWorkspace().getName();
NodeFilter filter = new NodeTypeFilter(TemplateSiteNodePlugin.TYPE);
IModel<BrixNode> model = adapter.forNodeProperty("template");
form.add(new SiteNodePickerPanel("templatePicker", model, workspace, filter));
IModel<Boolean> booleanModel = adapter.forProperty("requiresSSL");
form.add(new ProtocolSelector("requiresSSL", booleanModel));
IModel<String> mimeTypeModel = adapter.forProperty("mimeType");
form.add(new TextField<String>("mimeType", mimeTypeModel));
// set up markup editor
contentEditorModel = adapter.forProperty("dataAsString");
contentEditorParent = form;
Collection<MarkupEditorFactory> editorFactories = brix.getConfig().getRegistry()
.lookupCollection(MarkupEditorFactory.POINT);
setupEditor(editorFactories.iterator().next().getClass().getName());
// set up buttons to control editor switching
RepeatingView editors = new RepeatingView("editors") {
@Override
public boolean isVisible() {
return size() > 1;
}
};
form.add(editors);
for (MarkupEditorFactory factory : editorFactories) {
final String cn = factory.getClass().getName();
editors.add(new Button(editors.newChildId(), factory.newLabel()) {
public void onSubmit() {
setupEditor(cn);
}
@Override
public boolean isEnabled() {
return !cn.equals(currentEditorFactory);
}
});
}
form.add(new ContainerFeedbackPanel("feedback", this));
form.add(new Button("save") {
@Override
public void onSubmit() {
JcrNode node = nodeModel.getObject();
node.checkout();
adapter.apply();
node.save();
node.checkin();
getSession().info(getString("status.saved"));
goBack();