The code to create a table for testing in Eclipse RCP.
IEpTableViewer testTable = controlPane.addTableViewer(false, tableLayoutData, priceListBaseAmountEditorPageContainer);
IEpTableColumn column1 = testTable.addTableColumn("Code", 100); //$NON-NLS-1$
IEpTableColumn column2 = testTable.addTableColumn("email", 100); //$NON-NLS-1$
IEpTableColumn column3 = testTable.addTableColumn("in use", 100); //$NON-NLS-1$
testTable.setContentProvider(new IStructuredContentProvider(){
public Object[] getElements(final Object inputElement) {
return ((List)inputElement).toArray();
}
public void dispose() {
// TODO Auto-generated method stub
}
public void inputChanged(final Viewer viewer, final Object oldInput,
final Object newInput) {
// TODO Auto-generated method stub
}
});
testTable.setLabelProvider(new ITableLabelProvider(){
public Image getColumnImage(final Object element, final int columnIndex) {
// TODO Auto-generated method stub
return null;
}
public String getColumnText(final Object element, final int columnIndex) {
CouponUsageModelDto model = (CouponUsageModelDto) element;
switch (columnIndex) {
case 0:
return model.getCouponCode();
case 1:
return model.getEmailAddress();
case 2:
if (model.isSuspended()) {
return "Suspended"; //$NON-NLS-1$
}
return "In Use"; //$NON-NLS-1$
default:
return ""; //$NON-NLS-1$
}
}
public void addListener(final ILabelProviderListener listener) {
// TODO Auto-generated method stub
}
public void dispose() {
// TODO Auto-generated method stub
}
public boolean isLabelProperty(final Object element, final String property) {
// TODO Auto-generated method stub
return false;
}
public void removeListener(final ILabelProviderListener listener) {
// TODO Auto-generated method stub
}
});
Listcontents = new ArrayList ();
for (int i=0;i<30;i++) {
CouponUsageModelDto dto = new CouponUsageModelDto();
dto.setCouponCode("couponCode"); //$NON-NLS-1$
dto.setEmailAddress("emailAddress"); //$NON-NLS-1$
dto.setSuspended(false);
contents.add(dto);
}
testTable.setInput(contents);
No comments:
Post a Comment