mainContent.add(popup);
final StyleNameModel styleNameModel = new StyleNameModel(style);
mainContent.add(new Label("style.name", styleNameModel));
final PropertyModel layerNameModel = new PropertyModel(layer, "prefixedName");
mainContent.add(new Label("layer.name", layerNameModel));
mainContent.add(new AjaxLink("change.style", new ParamResourceModel("CssDemoPage.changeStyle", this)) {
public void onClick(AjaxRequestTarget target) {
target.appendJavascript("Wicket.Window.unloadConfirmation = false;");
popup.setInitialHeight(400);
popup.setInitialWidth(600);
popup.setTitle(new Model("Choose style to edit"));
popup.setContent(new StyleChooser(popup.getContentId(), CssDemoPage.this));
popup.show(target);
}
});
mainContent.add(new AjaxLink("change.layer", new ParamResourceModel("CssDemoPage.changeLayer", this)) {
public void onClick(AjaxRequestTarget target) {
target.appendJavascript("Wicket.Window.unloadConfirmation = false;");
popup.setInitialHeight(400);
popup.setInitialWidth(600);
popup.setTitle(new Model("Choose layer to edit"));
popup.setContent(new LayerChooser(popup.getContentId(), CssDemoPage.this));
popup.show(target);
}
});
mainContent.add(new AjaxLink("create.style", new ParamResourceModel("CssDemoPage.createStyle", this)) {
public void onClick(AjaxRequestTarget target) {
target.appendJavascript("Wicket.Window.unloadConfirmation = false;");
popup.setInitialHeight(200);
popup.setInitialWidth(300);
popup.setTitle(new Model("Choose name for new style"));
popup.setContent(new StyleNameInput(popup.getContentId(), CssDemoPage.this));
popup.show(target);
}
});
mainContent.add(new AjaxLink("associate.styles", new ParamResourceModel("CssDemoPage.associateStyles", this)) {
public void onClick(AjaxRequestTarget target) {
target.appendJavascript("Wicket.Window.unloadConfirmation = false;");
popup.setInitialHeight(400);
popup.setInitialWidth(600);
popup.setTitle(new Model("Choose layers to associate"));
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);
}
});
}