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();
}