super.init();
gridBuilder.newGridPanel();
{
// Parameter name
final FieldsetPanel fs = gridBuilder.newFieldset(getString("administration.configuration.parameter")).suppressLabelForWarning();
fs.add(new DivTextPanel(fs.newChildId(), getString(data.getI18nKey())));
}
FormComponent< ? > valueField = null;
{
// Parameter value
final FieldsetPanel fs = gridBuilder.newFieldset(getString("administration.configuration.value"));
if (data.getConfigurationType() == ConfigurationType.INTEGER) {
final TextField<Integer> textField = new TextField<Integer>(InputPanel.WICKET_ID, new PropertyModel<Integer>(data, "intValue"));
fs.add(textField);
valueField = textField;
} else if (data.getConfigurationType() == ConfigurationType.PERCENT) {
final MinMaxNumberField<BigDecimal> numberField = new MinMaxNumberField<BigDecimal>(InputPanel.WICKET_ID,
new PropertyModel<BigDecimal>(data, "floatValue"), BigDecimal.ZERO, NumberHelper.HUNDRED) {
/**
* @see org.projectforge.web.wicket.components.MinMaxNumberField#getConverter(java.lang.Class)
*/
@SuppressWarnings({ "rawtypes", "unchecked"})
@Override
public IConverter getConverter(final Class type)
{
return new BigDecimalPercentConverter(true);
};
};
fs.add(numberField);
valueField = numberField;
} else if (data.getConfigurationType() == ConfigurationType.STRING) {
final MaxLengthTextField textField = new MaxLengthTextField(InputPanel.WICKET_ID, new PropertyModel<String>(data, "stringValue"));
if (ConfigurationParam.CALENDAR_DOMAIN.getI18nKey().equals(data.getI18nKey()) == true) {
textField.setRequired(true);
textField.add(new IValidator<String>() {
@Override
public void validate(final IValidatable<String> validatable)
{
if (Configuration.isDomainValid(validatable.getValue()) == false) {
textField.error(getString("validation.error.generic"));
}
}
});
}
fs.add(textField);
valueField = textField;
} else if (data.getConfigurationType() == ConfigurationType.TEXT) {
final MaxLengthTextArea textArea = new MaxLengthTextArea(TextAreaPanel.WICKET_ID, new PropertyModel<String>(data, "stringValue"));
fs.add(textArea);
valueField = textArea;
} else if (data.getConfigurationType() == ConfigurationType.BOOLEAN) {
fs.addCheckBox(new PropertyModel<Boolean>(data, "booleanValue"), null);
} else if (data.getConfigurationType() == ConfigurationType.TIME_ZONE) {
final TimeZonePanel timeZonePanel = new TimeZonePanel(fs.newChildId(), new PropertyModel<TimeZone>(data, "timeZone"));
fs.add(timeZonePanel);
valueField = timeZonePanel.getTextField();
} else if (data.getConfigurationType() == ConfigurationType.TASK) {
if (data.getTaskId() != null) {
this.task = taskDao.getById(data.getTaskId());
}
final TaskSelectPanel taskSelectPanel = new TaskSelectPanel(fs, new PropertyModel<TaskDO>(this, "task"), parentPage, "taskId");
fs.add(taskSelectPanel);
taskSelectPanel.init();
} else {
throw new UnsupportedOperationException("Parameter of type '" + data.getConfigurationType() + "' not supported.");
}
if (valueField != null) {
WicketUtils.setFocus(valueField);
}
}
{
// Description
final FieldsetPanel fs = gridBuilder.newFieldset(getString("description")).suppressLabelForWarning();
fs.add(new DivTextPanel(fs.newChildId(), getString("administration.configuration.param." + data.getParameter() + ".description")));
}
}