TableViewerSelectionListener removeBtnSelAdapter =
DozerUiUtils.createDeleteSelectionListener(
editor.getModelManager().getModel());
AddRemoveListComposite arl =
new AddRemoveListComposite(
section,
messagePrefix,
toolkit,
addBtnSelAdapter,
removeBtnSelAdapter);
//TABLE
Table table = arl.getTable();
table.setHeaderVisible(true);
TableColumn column = new TableColumn(table, SWT.LEFT);
column.setText("Converter");
TableColumn column2 = new TableColumn(table, SWT.LEFT);
column2.setText("From");
TableColumn column3 = new TableColumn(table, SWT.LEFT);
column3.setText("To");
TableLayout tableLayout = new TableLayout();
ColumnWeightData columnData1 = new ColumnWeightData(1);
columnData1.minimumWidth = 100;
ColumnWeightData columnData2 = new ColumnWeightData(1);
columnData2.minimumWidth = 100;
ColumnWeightData columnData3 = new ColumnWeightData(1);
columnData3.minimumWidth = 100;
tableLayout.addColumnData(columnData1);
tableLayout.addColumnData(columnData2);
tableLayout.addColumnData(columnData3);
table.setLayout(tableLayout);
//Logic
ElementAsClassLabelProvider labelProvider =
new ElementAsClassLabelProvider() {
@Override
protected String getColumnText(Element node, int columnIndex) {
Element child;
NodeList nodeList;
switch (columnIndex) {
case 0:
String attrValue = node.getAttribute("type");
if (attrValue != null)
return DozerUiUtils.nullSafeTrimString(attrValue);
break;
case 1:
nodeList = node.getElementsByTagName("class-a");
child = (Element)nodeList.item(0);
if (child != null)
return DOMUtils.getTextContent(child);
break;
case 2:
nodeList = node.getElementsByTagName("class-b");
child = (Element)nodeList.item(0);
if (child != null)
return DOMUtils.getTextContent(child);
break;
}
return null;
}
};
final TableViewer tableViewer = arl.getTableViewer();
tableViewer.setLabelProvider(labelProvider);
TableWrapData td = new TableWrapData();
arl.setLayoutData(td);
section.setClient(arl);
return arl.getTableViewer();
}