return box;
}
private Widget listEditor(final ValueChanged changed) {
Panel panel = new VerticalPanel();
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.setValue( newValue );
calculateValueFromList();
makeDirty();
}
},
f,
givenFact,
sce,
scenario,
executionTrace );
hpanel.add( fieldElement );
final int index = i;
Image del = new ImageButton( images.deleteItemSmall(),
constants.AElementToDelInCollectionList(),
new ClickHandler() {
public void onClick(ClickEvent w) {
field.collectionFieldList.remove( index );
calculateValueFromList();
refreshEditor();
}
} );
hpanel.add( del );
Image addPattern = new ImageButton( images.newItemBelow() );
addPattern.setTitle( constants.AddElementBelow() );
addPattern.addClickHandler( new ClickHandler() {
public void onClick(ClickEvent sender) {
FieldData newFieldData = new FieldData();
newFieldData.setName( field.getName() );
newFieldData.collectionType = field.collectionType;
field.collectionFieldList.add( index + 1,
newFieldData );
calculateValueFromList();
refreshEditor();
}
} );
hpanel.add( addPattern );
Image moveDown = new ImageButton( images.shuffleDown() );
moveDown.setTitle( constants.MoveDownListMove() );
moveDown.addClickHandler( new ClickHandler() {
public void onClick(ClickEvent 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.shuffleUp() );
moveUp.setTitle( constants.MoveUpList() );
moveUp.addClickHandler( new ClickHandler() {
public void onClick(ClickEvent 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.newItem(),
constants.AElementToAddInCollectionList(),
new ClickHandler() {
public void onClick(ClickEvent w) {
FieldData newFieldData = new FieldData();
newFieldData.setName( field.getName() );
newFieldData.collectionType = field.collectionType;
field.collectionFieldList.add( newFieldData );
calculateValueFromList();
refreshEditor();
}
} );
panel.add( add );
}
return panel;
}