String attr = (String) SIMPLE_CASES[i][0];
int size = ((Integer) SIMPLE_CASES[i][1]).intValue();
ModelModifier modifier = new ComponentAttributeModifier(attr);
TextEditor editor = new TextEditor();
editor.setSize(size);
FieldInfo fieldInfo = new FieldInfo(attr, attr, modifier, editor);
context.addFieldInfo(fieldInfo);
}
// ---------------------------------
// A couple more complicated ones...
// ---------------------------------
{
// ----------
// Date created after
// ----------
String id = "dateCreatedAfter";
ModelModifier modifier = new DefaultModelModifier() {
public Object getModelValue(Object model) throws Exception {
Date date = ((CustomerSource) model).getDateCreatedAfter();
if(date != null)
return CustomerSource.dateFormat.format(date);
else
return "";
}
public void setModelValue(Object model, Object value) throws Exception {
String valueStr = (String) value;
Date date = null;
if(valueStr != null && valueStr.length() != 0) {
try {
date = CustomerSource.dateFormat.parse(valueStr);
} catch(ParseException pe) {
/* Ignore invalid dates */
}
}
((CustomerSource) model).setDateCreatedAfter(date);
}
};
TextEditor editor = new TextEditor();
editor.setSize(50);
//and finally create the configurationObject
FieldInfo fieldInfo = new FieldInfo(id, id, modifier, editor);
//add the configuration to the context for usage in the http-requests.
context.addFieldInfo(fieldInfo);
}
{
// -----------
// Date created before
// -----------
String id = "dateCreatedBefore";
ModelModifier modifier = new DefaultModelModifier() {
public Object getModelValue(Object model) throws Exception {
Date date = ((CustomerSource) model).getDateCreatedBefore();
if(date != null)
return CustomerSource.dateFormat.format(date);
else
return "";
}
public void setModelValue(Object model, Object value) throws Exception {
String valueStr = (String) value;
Date date = null;
if(valueStr != null && valueStr.length() != 0) {
try {
date = CustomerSource.dateFormat.parse(valueStr);
} catch(ParseException pe) {
/* Ignore invalid dates */
}
}
((CustomerSource) model).setDateCreatedBefore(date);
}
};
TextEditor editor = new TextEditor();
editor.setSize(50);
//and finally create the configurationObject
FieldInfo fieldInfo = new FieldInfo(id, id, modifier, editor);
//add the configuration to the context for usage in the http-requests.
context.addFieldInfo(fieldInfo);
}
{
// ----------
// Date last visit after
// ----------
String id = "dateLastVisitAfter";
ModelModifier modifier = new DefaultModelModifier() {
public Object getModelValue(Object model) throws Exception {
Date date = ((CustomerSource) model).getDateLastVisitAfter();
if(date != null)
return CustomerSource.dateFormat.format(date);
else
return "";
}
public void setModelValue(Object model, Object value) throws Exception {
String valueStr = (String) value;
Date date = null;
if(valueStr != null && valueStr.length() != 0) {
try {
date = CustomerSource.dateFormat.parse(valueStr);
} catch(ParseException pe) {
/* Ignore invalid dates */
}
}
((CustomerSource) model).setDateLastVisitAfter(date);
}
};
TextEditor editor = new TextEditor();
editor.setSize(50);
//and finally create the configurationObject
FieldInfo fieldInfo = new FieldInfo(id, id, modifier, editor);
//add the configuration to the context for usage in the http-requests.
context.addFieldInfo(fieldInfo);
}
{
// -----------
// Date last visit before
// -----------
String id = "dateLastVisitBefore";
ModelModifier modifier = new DefaultModelModifier() {
public Object getModelValue(Object model) throws Exception {
Date date = ((CustomerSource) model).getDateLastVisitBefore();
if(date != null)
return CustomerSource.dateFormat.format(date);
else
return "";
}
public void setModelValue(Object model, Object value) throws Exception {
String valueStr = (String) value;
Date date = null;
if(valueStr != null && valueStr.length() != 0) {
try {
date = CustomerSource.dateFormat.parse(valueStr);
} catch(ParseException pe) {
/* Ignore invalid dates */
}
}
((CustomerSource) model).setDateLastVisitBefore(date);
}
};
TextEditor editor = new TextEditor();
editor.setSize(50);
//and finally create the configurationObject
FieldInfo fieldInfo = new FieldInfo(id, id, modifier, editor);
//add the configuration to the context for usage in the http-requests.
context.addFieldInfo(fieldInfo);
}
{
// -----------
// Datebox, customer modified before
// -----------
String id = "customerModifiedBefore";
ModelModifier modifier = new DefaultModelModifier() {
public Object getModelValue(Object model) throws Exception {
Date date = ((CustomerSource) model).getDateCustModifiedBefore();
if(date != null)
return CustomerSource.dateFormat.format(date);
else
return "";
}
public void setModelValue(Object model, Object value) throws Exception {
String valueStr = (String) value;
Date date = null;
if(valueStr != null && valueStr.length() != 0) {
try {
date = CustomerSource.dateFormat.parse(valueStr);
} catch(ParseException pe) {
/* Ignore invalid dates */
}
}
((CustomerSource) model).setDateCustModifiedBefore(date);
}
};
TextEditor editor = new TextEditor();
editor.setSize(40);
FieldInfo fieldInfo = new FieldInfo(id,id,modifier,editor);
context.addFieldInfo(fieldInfo);
}
{
// -----------
// Datebox customer modified after
// -----------
String id = "customerModifiedAfter";
ModelModifier modifier = new DefaultModelModifier() {
public Object getModelValue(Object model) throws Exception {
Date date = ((CustomerSource) model).getDateCustModifiedAfter();
if(date != null)
return CustomerSource.dateFormat.format(date);
else
return "";
}
public void setModelValue(Object model, Object value) throws Exception {
String valueStr = (String) value;
Date date = null;
if(valueStr != null && valueStr.length() != 0) {
try {
date = CustomerSource.dateFormat.parse(valueStr);
} catch(ParseException pe) {
/* Ignore invalid dates */
}
}
((CustomerSource) model).setDateCustModifiedAfter(date);
}
};
TextEditor editor = new TextEditor();
editor.setSize(40);
FieldInfo fieldInfo = new FieldInfo(id,id,modifier,editor);
context.addFieldInfo(fieldInfo);
}
{
// // -----------
// Datebox admin modified before
// -----------
String id = "adminModifiedBefore";
ModelModifier modifier = new DefaultModelModifier() {
public Object getModelValue(Object model) throws Exception {
Date date = ((CustomerSource) model).getDateAdminModifiedBefore();
if(date != null)
return CustomerSource.dateFormat.format(date);
else
return "";
}
public void setModelValue(Object model, Object value) throws Exception {
String valueStr = (String) value;
Date date = null;
if(valueStr != null && valueStr.length() != 0) {
try {
date = CustomerSource.dateFormat.parse(valueStr);
} catch(ParseException pe) {
/* Ignore invalid dates */
}
}
((CustomerSource) model).setDateAdminModifiedBefore(date);
}
};
TextEditor editor = new TextEditor();
editor.setSize(40);
FieldInfo fieldInfo = new FieldInfo(id,id,modifier,editor);
context.addFieldInfo(fieldInfo);
}
{
// // -----------
// Datebox admin modified after
// -----------
String id = "adminModifiedAfter";
ModelModifier modifier = new DefaultModelModifier() {
public Object getModelValue(Object model) throws Exception {
Date date = ((CustomerSource) model).getDateAdminModifiedAfter();
if(date != null)
return CustomerSource.dateFormat.format(date);
else
return "";
}
public void setModelValue(Object model, Object value) throws Exception {
String valueStr = (String) value;
Date date = null;
if(valueStr != null && valueStr.length() != 0) {
try {
date = CustomerSource.dateFormat.parse(valueStr);
} catch(ParseException pe) {
/* Ignore invalid dates */
}
}
((CustomerSource) model).setDateAdminModifiedAfter(date);
}
};
TextEditor editor = new TextEditor();
editor.setSize(40);
FieldInfo fieldInfo = new FieldInfo(id,id,modifier,editor);
context.addFieldInfo(fieldInfo);
}
{
// -----------
// what rule to apply (customer / admin / both)
// -----------
//set unique id and description labelkey
String id = "modifyOperation";
ModelModifier modifier = new DefaultModelModifier() {
public Object getModelValue(Object model) throws FailTransferException,
AbortTransferException {
String value = ((CustomerSource)model).getModifyOperation();
if(value != null){
return value;
}
else{
value = "OR";
return value;
}
}
public void setModelValue(Object model, Object value)
throws FailTransferException, AbortTransferException {
((CustomerSource)model).setModifyOperation((String)value);
}
};
SelectEditor editor = new SelectEditor();
editor.addOption(new DefaultSelectOption("OR","OR"));
editor.addOption(new DefaultSelectOption("AND","AND"));
FieldInfo fieldInfo = new FieldInfo(id,id,modifier,editor);
context.addFieldInfo(fieldInfo);
}