popup.setContent(new MultipleLayerChooser(popup.getContentId(), CssDemoPage.this));
popup.show(target);
}
});
ParamResourceModel associateToLayer = new ParamResourceModel("CssDemoPage.associateDefaultStyle", this, styleNameModel, layerNameModel);
final SimpleAjaxLink associateDefaultStyle = new SimpleAjaxLink("associate.default.style", new Model(), associateToLayer) {
public void onClick(final AjaxRequestTarget linkTarget) {
final Component theComponent = this;
dialog.setResizable(false);
dialog.setHeightUnit("em");
dialog.setWidthUnit("em");
dialog.setInitialHeight(7);
dialog.setInitialWidth(50);
dialog.showOkCancel(linkTarget, new DialogDelegate() {
boolean success = false;
@Override
protected boolean onSubmit(AjaxRequestTarget target, Component contents) {
layer.setDefaultStyle(style);
getCatalog().save(layer);
theComponent.setEnabled(false);
success = true;
return true;
}
@Override
public void onClose(AjaxRequestTarget target) {
super.onClose(target);
target.addComponent(theComponent);
if(success) {
CssDemoPage.this.info(new ParamResourceModel("CssDemoPage.styleAssociated", CssDemoPage.this, styleNameModel, layerNameModel).getString());
target.addComponent(getFeedbackPanel());
}
}
@Override
protected Component getContents(String id) {
ParamResourceModel confirm = new ParamResourceModel("CssDemoPage.confirmAssocation", CssDemoPage.this, styleNameModel.getObject(),
layerNameModel.getObject(), layer.getDefaultStyle().getName());
return new Label(id, confirm);
}
});
}
};
associateDefaultStyle.setOutputMarkupId(true);
if(layer.getDefaultStyle().equals(style)) {
associateDefaultStyle.setEnabled(false);
}
mainContent.add(associateDefaultStyle);