weightedImpactViewerColumn.getColumn().setMoveable(true);
weightedImpactViewerColumn.getColumn().setResizable(true);
new ColumnViewerSorter(tableViewer, weightedImpactViewerColumn) {
protected int doCompare(Viewer viewer, Object e1, Object e2) {
Element element = elementColumnMap.get(tableViewer
.getTable().getSortColumn());
Float v1 = calcWeightedImpact(builder, element,
(Element) e1);
Float v2 = calcWeightedImpact(builder, element,
(Element) e2);
return v1.compareTo(v2);
}
};
weightedImpactViewerColumn
.setLabelProvider(new CellLabelProvider() {
public void update(ViewerCell cell) {
String weightString = calcWeightedImpactString(
builder,(Element) leafElement,
(Element) cell.getElement());
float impact = calcWeightedImpact(builder,
(Element)leafElement,
(Element) cell.getElement());
Color backgroundColor = null;
Color foregroundColor = null;
if (symbolsCheckbox.getSelection()) {
setSymbol(cell, impact);
} else if (grlSymbolsCheckbox.getSelection()) {
setGRLSymbol(cell, impact);
} else {
cell.setFont(Display.getDefault()
.getSystemFont());
cell.setText(weightString);
}
if (attributeExplorerCheckbox.getSelection()) {
if (impact >= thresholdSpinner
.getSelection()) {
backgroundColor = new Color(null, 255,
255, 0);
foregroundColor = new Color(null, 0, 0,
0);
} else {
backgroundColor = new Color(null, 255,
255, 255);
foregroundColor = new Color(null, 0, 0,
0);
}
} else if (heatmapCheckbox.getSelection()) {
backgroundColor = DefaultColors
.getBackgroundColor(impact);
foregroundColor = DefaultColors
.getForegroundColor(impact);
} else {
backgroundColor = new Color(null, 255, 255,
255);
foregroundColor = new Color(null, 0, 0, 0);
}
cell.setBackground(backgroundColor);
cell.setForeground(foregroundColor);
}
});
}
final TableViewerColumn unweightedImpactViewerColumn = new TableViewerColumn(
tableViewer, SWT.NONE);
elementColumnMap.put(unweightedImpactViewerColumn.getColumn(),
(Element) leafElement);
unweightedImpactViewerColumn.getColumn().setText(
String.format("%s", ((Element) leafElement).getName()));
unweightedImpactViewerColumn.getColumn().setToolTipText("the rating to "+((Element) leafElement).getName());
unweightedImpactViewerColumn.getColumn().setWidth(100);
unweightedImpactViewerColumn.getColumn().setMoveable(true);
unweightedImpactViewerColumn.getColumn().setResizable(true);
new ColumnViewerSorter(tableViewer, unweightedImpactViewerColumn) {
protected int doCompare(Viewer viewer, Object e1, Object e2) {
Element element = elementColumnMap.get(tableViewer
.getTable().getSortColumn());
Float v1 = getRating(builder, element, (Element) e1);
Float v2 = getRating(builder, element, (Element) e2);
return v1.compareTo(v2);
}