return box;
}
private Widget listEditor(final ValueChanged changed) {
Panel panel = new VerticalPanel();
//nheron
int i = 0;
for (final FieldData f : this.field.collectionFieldList) {
DirtyableHorizontalPane hpanel = new DirtyableHorizontalPane();
FieldDataConstraintEditor fieldElement = new FieldDataConstraintEditor(f.collectionType, new ValueChanged() {
public void valueChanged(String newValue) {
f.value = newValue ;
calculateValueFromList();
makeDirty();
}
}, f, givenFact, sce, scenario, executionTrace);
hpanel.add(fieldElement);
final int index = i;
Image del = new ImageButton("images/delete_item_small.gif", Format.format(constants.AElementToDelInCollectionList(), "tt"), new ClickListener() {
public void onClick(Widget w) {
field.collectionFieldList.remove(index);
calculateValueFromList();
refreshEditor();
}
});
hpanel.add(del);
Image addPattern = new ImageButton("images/new_item_below.png");
addPattern.setTitle(constants.AddElementBelow());
addPattern.addClickListener(new ClickListener(){
public void onClick(Widget sender) {
FieldData newFieldData = new FieldData();
newFieldData.name = field.name;
newFieldData.collectionType = field.collectionType;
field.collectionFieldList.add(index+1,newFieldData);
calculateValueFromList();
refreshEditor();
}
});
hpanel.add(addPattern);
Image moveDown = new ImageButton("images/shuffle_down.gif");
moveDown.setTitle(constants.MoveDownListMove());
moveDown.addClickListener(new ClickListener(){
public void onClick(Widget sender) {
if (index <field.collectionFieldList.size()-1){
FieldData onMyLine =field.collectionFieldList.get(index);
FieldData onDown =field.collectionFieldList.get(index+1);
field.collectionFieldList.set(index+1,onMyLine);
field.collectionFieldList.set(index,onDown);
calculateValueFromList();
refreshEditor();
}
}
});
hpanel.add(moveDown);
Image moveUp = new ImageButton("images/shuffle_up.gif");
moveUp.setTitle(constants.MoveUpList());
moveUp.addClickListener(new ClickListener(){
public void onClick(Widget sender) {
if (index >0){
FieldData oneUp =field.collectionFieldList.get(index-1);
FieldData onMyLine =field.collectionFieldList.get(index);
field.collectionFieldList.set(index,oneUp);
field.collectionFieldList.set(index-1,onMyLine);
calculateValueFromList();
refreshEditor();
}
}
});
hpanel.add(moveUp);
panel.add(hpanel);
i++;
}
if (this.field.collectionFieldList.size()==0){
Image add = new ImageButton("images/new_item.gif", Format.format(constants.AElementToAddInCollectionList(), "tt"), new ClickListener() {
public void onClick(Widget w) {
FieldData newFieldData = new FieldData();
newFieldData.name = field.name;
newFieldData.collectionType = field.collectionType;
field.collectionFieldList.add(newFieldData);
calculateValueFromList();
refreshEditor();
}
});
panel.add(add);
}
return panel;
}