final PartsListGrid myList2 = new PartsListGrid();
myList2.setEmptyMessage("No Records");
myList2.setCanAcceptDroppedRecords(true);
myList2.setCanReorderRecords(true);
TransferImgButton right = new TransferImgButton(TransferImgButton.RIGHT);
right.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
myList2.transferSelectedData(myList1);
}
});
TransferImgButton rightAll = new TransferImgButton(TransferImgButton.RIGHT_ALL);
rightAll.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
Record[] records = myList1.getRecords();
myList1.setData(new Record[]{});
for (Record record : records) {
myList2.addData(record);
}
}
});
TransferImgButton left = new TransferImgButton(TransferImgButton.LEFT);
left.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
myList1.transferSelectedData(myList2);
}
});
TransferImgButton leftAll = new TransferImgButton(TransferImgButton.LEFT_ALL);
leftAll.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
Record[] records = myList2.getRecords();
myList2.setData(new Record[]{});
for (Record record : records) {
myList1.addData(record);
}
}
});
transferStack.addMember(right);
transferStack.addMember(left);
transferStack.addMember(rightAll);
transferStack.addMember(leftAll);
hStack.addMember(transferStack);
hStack.addMember(myList2);
VStack modifyStack = new VStack(3);
modifyStack.setWidth(20);
modifyStack.setAlign(VerticalAlignment.CENTER);
TransferImgButton up = new TransferImgButton(TransferImgButton.UP);
up.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, 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);
}
}
}
});
TransferImgButton delete = new TransferImgButton(TransferImgButton.DELETE);
delete.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
ListGridRecord selectedRecord = myList2.getSelectedRecord();
if(selectedRecord != null) {
myList2.removeData(selectedRecord);
}