cancel.setDefaultFormProcessing(false);
form.add(cancel);
}
private void setupProfile() {
final WebMarkupContainer profile = new WebMarkupContainer("profile");
profile.setOutputMarkupId(true);
form.add(profile);
final ModalWindow reportletConfWin = new ModalWindow("reportletConfWin");
reportletConfWin.setCssClassName(ModalWindow.CSS_CLASS_GRAY);
reportletConfWin.setCookieName("reportlet-conf-win-modal");
reportletConfWin.setInitialHeight(REPORTLET_CONF_WIN_HEIGHT);
reportletConfWin.setInitialWidth(REPORTLET_CONF_WIN_WIDTH);
reportletConfWin.setWindowClosedCallback(new ModalWindow.WindowClosedCallback() {
private static final long serialVersionUID = 8804221891699487139L;
@Override
public void onClose(final AjaxRequestTarget target) {
int foundIdx = -1;
if (modalReportletConfOldName != null) {
for (int i = 0; i < reportTO.getReportletConfs().size() && foundIdx == -1; i++) {
if (reportTO.getReportletConfs().get(i).getName().equals(modalReportletConfOldName)) {
foundIdx = i;
}
}
}
if (modalReportletConf != null) {
if (foundIdx == -1) {
reportTO.addReportletConf(modalReportletConf);
} else {
reportTO.getReportletConfs().set(foundIdx, modalReportletConf);
}
}
target.add(reportlets);
}
});
add(reportletConfWin);
final Label idLabel = new Label("idLabel", new ResourceModel("id"));
profile.add(idLabel);
final AjaxTextFieldPanel id = new AjaxTextFieldPanel("id", getString("id"), new PropertyModel<String>(reportTO,
"id"));
id.setEnabled(false);
profile.add(id);
final Label nameLabel = new Label("nameLabel", new ResourceModel("name"));
profile.add(nameLabel);
final AjaxTextFieldPanel name = new AjaxTextFieldPanel("name", getString("name"), new PropertyModel<String>(
reportTO, "name"));
profile.add(name);
final AjaxTextFieldPanel lastExec = new AjaxTextFieldPanel("lastExec", getString("lastExec"),
new DateFormatROModel(new PropertyModel<String>(reportTO, "lastExec")));
lastExec.setEnabled(false);
profile.add(lastExec);
final AjaxTextFieldPanel nextExec = new AjaxTextFieldPanel("nextExec", getString("nextExec"),
new DateFormatROModel(new PropertyModel<String>(reportTO, "nextExec")));
nextExec.setEnabled(false);
profile.add(nextExec);
reportlets = new ListChoice<AbstractReportletConf>("reportletConfs", new Model(), reportTO.getReportletConfs(),
new IChoiceRenderer<ReportletConf>() {
private static final long serialVersionUID = 1048000918946220007L;
@Override
public Object getDisplayValue(final ReportletConf object) {
return object.getName();
}
@Override
public String getIdValue(final ReportletConf object, int index) {
return object.getName();
}
}) {
private static final long serialVersionUID = 4022366881854379834L;
@Override
protected CharSequence getDefaultChoice(String selectedValue) {
return null;
}
};
reportlets.setNullValid(true);
profile.add(reportlets);
reportlets.add(new AjaxFormComponentUpdatingBehavior("onchange") {
private static final long serialVersionUID = -1107858522700306810L;
@Override
protected void onUpdate(AjaxRequestTarget target) {
target.add(reportlets);
}
});
profile.add(new AjaxLink(ADD_BUTTON_ID) {
private static final long serialVersionUID = -7978723352517770644L;
@Override
public void onClick(final AjaxRequestTarget target) {
reportletConfWin.setPageCreator(new ModalWindow.PageCreator() {
private static final long serialVersionUID = -7834632442532690940L;
@Override
public Page createPage() {
modalReportletConfOldName = null;
modalReportletConf = null;
return new ReportletConfModalPage(null, reportletConfWin,
ReportModalPage.this.getPageReference());
}
});
reportletConfWin.show(target);
}
});
profile.add(new AjaxLink(EDIT_BUTTON_ID) {
private static final long serialVersionUID = -7978723352517770644L;
@Override
public void onClick(final AjaxRequestTarget target) {
if (reportlets.getModelObject() != null) {
reportletConfWin.setPageCreator(new ModalWindow.PageCreator() {
private static final long serialVersionUID = -7834632442532690940L;
@Override
public Page createPage() {
modalReportletConfOldName = reportlets.getModelObject().getName();
modalReportletConf = null;
return new ReportletConfModalPage(reportlets.getModelObject(), reportletConfWin,
ReportModalPage.this.getPageReference());
}
});
reportletConfWin.show(target);
} else {
target.appendJavaScript("alert('" + getString("selectItem") + "')");
}
}
});
profile.add(new AjaxLink(REMOVE_BUTTON_ID) {
private static final long serialVersionUID = -7978723352517770644L;
@Override
public void onClick(final AjaxRequestTarget target) {
reportTO.removeReportletConf(reportlets.getModelObject());
reportlets.setModelObject(null);
target.add(reportlets);
}
@Override
protected void updateAjaxAttributes(final AjaxRequestAttributes attributes) {
if (reportlets.getModelObject() != null) {
super.updateAjaxAttributes(attributes);
final AjaxCallListener ajaxCallListener = new AjaxCallListener() {
private static final long serialVersionUID = 7160235486520935153L;
@Override
public CharSequence getPrecondition(final Component component) {
return "if (!confirm('" + getString("confirmDelete") + "')) {return false;}";
}
};
attributes.getAjaxCallListeners().add(ajaxCallListener);
}
}
});
profile.add(new AjaxLink(UP_BUTTON_ID) {
private static final long serialVersionUID = -7978723352517770644L;
@Override
public void onClick(final AjaxRequestTarget target) {
if (reportlets.getModelObject() != null) {
moveUp(reportlets.getModelObject());
target.add(reportlets);
}
}
});
profile.add(new AjaxLink(DOWN_BUTTON_ID) {
private static final long serialVersionUID = -7978723352517770644L;
@Override
public void onClick(final AjaxRequestTarget target) {