use of org.eclipse.egit.ui.internal.WorkbenchStyledLabelProvider in project egit by eclipse.
the class RevertFailureDialog method createCustomArea.
@Override
protected Control createCustomArea(Composite parent) {
if (reasons == null || reasons.isEmpty())
return null;
Composite fileArea = new Composite(parent, SWT.NONE);
GridDataFactory.fillDefaults().grab(true, true).hint(SWT.DEFAULT, 80).applyTo(fileArea);
GridLayoutFactory.fillDefaults().applyTo(fileArea);
TreeViewer viewer = new TreeViewer(fileArea);
viewer.setAutoExpandLevel(AbstractTreeViewer.ALL_LEVELS);
GridDataFactory.fillDefaults().grab(true, true).applyTo(viewer.getControl());
viewer.setContentProvider(new WorkbenchContentProvider() {
@Override
public Object[] getElements(Object element) {
return ((Collection) element).toArray();
}
});
final IStyledLabelProvider styleProvider = new WorkbenchStyledLabelProvider() {
@Override
public StyledString getStyledText(Object element) {
// supported
if (element instanceof RevertFailure)
return ((RevertFailure) element).getStyledText(element);
if (element instanceof Path)
return ((Path) element).getStyledText(element);
return super.getStyledText(element);
}
};
viewer.setLabelProvider(new DelegatingStyledCellLabelProvider(styleProvider));
viewer.setComparator(new ViewerComparator());
Map<MergeFailureReason, RevertFailure> failures = new HashMap<>();
for (Entry<String, MergeFailureReason> reason : reasons.entrySet()) {
RevertFailure failure = failures.get(reason.getValue());
if (failure == null) {
failure = new RevertFailure(reason.getValue());
failures.put(reason.getValue(), failure);
}
failure.add(reason.getKey());
}
viewer.setInput(failures.values());
return fileArea;
}
Aggregations