in org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/internal/github/ui/pr/CommitAttributePart.java [91:166]
protected Control createContent(FormToolkit toolkit, Composite parent) {
Composite displayArea = toolkit.createComposite(parent);
GridLayoutFactory.fillDefaults().spacing(0, 0).applyTo(displayArea);
GridDataFactory.fillDefaults().grab(true, true).applyTo(displayArea);
if (request != null) {
Composite refArea = toolkit.createComposite(displayArea);
GridLayoutFactory.fillDefaults().spacing(0, 0).numColumns(4)
.applyTo(refArea);
GridDataFactory.swtDefaults().grab(true, false).applyTo(refArea);
Image branchIcon = UIIcons.BRANCH.createImage();
UIUtils.hookDisposal(refArea, branchIcon);
CLabel sourceLabel = new CLabel(refArea, SWT.NONE);
toolkit.adapt(sourceLabel, false, false);
sourceLabel.setText(Messages.CommitAttributePart_LabelSource);
sourceLabel.setImage(branchIcon);
sourceLabel.setForeground(toolkit.getColors().getColor(
IFormColors.TITLE));
toolkit.createText(refArea, request.getRequest().getHead()
.getLabel(), SWT.READ_ONLY);
CLabel destLabel = new CLabel(refArea, SWT.NONE);
toolkit.adapt(destLabel, false, false);
destLabel.setText(Messages.CommitAttributePart_LabelDestination);
destLabel.setImage(branchIcon);
destLabel.setForeground(toolkit.getColors().getColor(
IFormColors.TITLE));
GridDataFactory.swtDefaults().indent(15, 0).applyTo(destLabel);
toolkit.createText(refArea, request.getRequest().getBase()
.getLabel(), SWT.READ_ONLY);
}
Composite treeArea = toolkit.createComposite(displayArea);
toolkit.paintBordersFor(treeArea);
GridLayoutFactory.fillDefaults().spacing(0, 0)
.extendedMargins(2, 2, 2, 7).applyTo(treeArea);
GridDataFactory.fillDefaults().grab(true, true).applyTo(treeArea);
TreeViewer commitViewer = new TreeViewer(toolkit.createTree(treeArea,
SWT.V_SCROLL | SWT.H_SCROLL | toolkit.getBorderStyle()));
commitViewer.setContentProvider(new WorkbenchContentProvider());
commitViewer.setLabelProvider(new DelegatingStyledCellLabelProvider(
new WorkbenchLabelProvider()));
GridDataFactory.fillDefaults().grab(true, true)
.applyTo(commitViewer.getControl());
commitViewer.getControl().setData(FormToolkit.KEY_DRAW_BORDER,
FormToolkit.TREE_BORDER);
commitViewer.addOpenListener(new IOpenListener() {
@Override
public void open(final OpenEvent event) {
PullRequest pr = request.getRequest();
Repository repo = PullRequestUtils.getRepository(pr);
if (repo != null)
openCommits(repo, ((IStructuredSelection) event
.getSelection()).toArray());
else
PullRequestConnectorUi.showNoRepositoryDialog(pr);
}
});
int size = 0;
if (request != null) {
PullRequestAdapter root = new PullRequestAdapter(request);
size = root.getChildren(root).length;
commitViewer.setInput(root);
Point treeSize = commitViewer.getControl().computeSize(SWT.DEFAULT,
SWT.DEFAULT);
((GridData) commitViewer.getControl().getLayoutData()).heightHint = Math
.min(treeSize.y, 200);
}
getSection().setText(
MessageFormat.format(
Messages.CommitAttributePart_SectionCommits,
Integer.valueOf(size)));
return displayArea;
}