public void onClick(ClickEvent event) {
ListGridRecord selectedRecord = myList2.getSelectedRecord();
if(selectedRecord != null) {
int idx = myList2.getRecordIndex(selectedRecord);
if(idx > 0) {
RecordList rs = myList2.getRecordList();
rs.removeAt(idx);
rs.addAt(selectedRecord, idx - 1);
}
}
}
});
TransferImgButton upFirst = new TransferImgButton(TransferImgButton.UP_FIRST);
upFirst.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
ListGridRecord selectedRecord = myList2.getSelectedRecord();
if(selectedRecord != null) {
int idx = myList2.getRecordIndex(selectedRecord);
if(idx > 0) {
RecordList rs = myList2.getRecordList();
rs.removeAt(idx);
rs.addAt(selectedRecord, 0);
}
}
}
});
TransferImgButton down = new TransferImgButton(TransferImgButton.DOWN);
down.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
ListGridRecord selectedRecord = myList2.getSelectedRecord();
if(selectedRecord != null) {
RecordList rs = myList2.getRecordList();
int numRecords = rs.getLength();
int idx = myList2.getRecordIndex(selectedRecord);
if(idx < numRecords - 1) {
rs.removeAt(idx);
rs.addAt(selectedRecord, idx + 1);
}
}
}
});
TransferImgButton downLast = new TransferImgButton(TransferImgButton.DOWN_LAST);
downLast.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
ListGridRecord selectedRecord = myList2.getSelectedRecord();
if(selectedRecord != null) {
RecordList rs = myList2.getRecordList();
int numRecords = rs.getLength();
int idx = myList2.getRecordIndex(selectedRecord);
if(idx < numRecords - 1) {
rs.removeAt(idx);
rs.addAt(selectedRecord, rs.getLength() -1);
}
}
}
});