Skip to content

Commit

Permalink
Apply code optimizations in TextMergeViewer
Browse files Browse the repository at this point in the history
Follow-up work of
eclipse-platform#1319
  • Loading branch information
fedejeanne committed Apr 17, 2024
1 parent 8d37020 commit 991196f
Showing 1 changed file with 8 additions and 44 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2059,14 +2059,7 @@ protected void createControls(Composite composite) {
// 1st row
if (fMarginWidth > 0) {
fAncestorCanvas = new Canvas(composite, SWT.DOUBLE_BUFFERED);
fAncestorCanvas.addPaintListener(new PaintListener() {

@Override
public void paintControl(PaintEvent e) {
paintSides(e.gc, fAncestor, fAncestorCanvas, false);

}
});
fAncestorCanvas.addPaintListener(e -> paintSides(e.gc, fAncestor, fAncestorCanvas, false));
fAncestorCanvas.addMouseListener(
new MouseAdapter() {
@Override
Expand Down Expand Up @@ -2095,14 +2088,7 @@ public void getName(AccessibleEvent e) {
// 2nd row
if (fMarginWidth > 0) {
fLeftCanvas = new Canvas(composite, SWT.DOUBLE_BUFFERED);
fLeftCanvas.addPaintListener(new PaintListener() {

@Override
public void paintControl(PaintEvent e) {
paintSides(e.gc, fLeft, fLeftCanvas, false);

}
});
fLeftCanvas.addPaintListener(e -> paintSides(e.gc, fLeft, fLeftCanvas, false));
fLeftCanvas.addMouseListener(
new MouseAdapter() {
@Override
Expand Down Expand Up @@ -2158,14 +2144,7 @@ public void getName(AccessibleEvent e) {

if (fMarginWidth > 0) {
fRightCanvas = new Canvas(composite, SWT.DOUBLE_BUFFERED);
fRightCanvas.addPaintListener(new PaintListener() {

@Override
public void paintControl(PaintEvent e) {
paintSides(e.gc, fRight, fRightCanvas, fSynchronizedScrolling);

}
});
fRightCanvas.addPaintListener(e -> paintSides(e.gc, fRight, fRightCanvas, fSynchronizedScrolling));
fRightCanvas.addMouseListener(
new MouseAdapter() {
@Override
Expand All @@ -2191,14 +2170,10 @@ public void mouseDown(MouseEvent e) {
);

fBirdsEyeCanvas = new Canvas(composite, SWT.DOUBLE_BUFFERED);
fBirdsEyeCanvas.addPaintListener(new PaintListener() {
fBirdsEyeCanvas.addPaintListener(e -> {
updateVScrollBar(); // Update scroll bar here as initially viewport height is wrong
paintBirdsEyeView((Canvas) e.widget, e.gc);

@Override
public void paintControl(PaintEvent e) {
updateVScrollBar(); // Update scroll bar here as initially viewport height is wrong
paintBirdsEyeView((Canvas) e.widget, e.gc);

}
});

fBirdsEyeCanvas.addMouseListener(
Expand Down Expand Up @@ -2480,14 +2455,7 @@ protected final Control createCenterControl(Composite parent) {

final Canvas canvas = new Canvas(parent, SWT.DOUBLE_BUFFERED);

canvas.addPaintListener(new PaintListener() {

@Override
public void paintControl(PaintEvent e) {
paintCenter((Canvas) e.widget, e.gc);

}
});
canvas.addPaintListener(e -> paintCenter((Canvas) e.widget, e.gc));
new HoverResizer(canvas, HORIZONTAL);

Cursor normalCursor= canvas.getDisplay().getSystemCursor(SWT.CURSOR_ARROW);
Expand Down Expand Up @@ -4002,11 +3970,7 @@ private void configureCompareFilterActions(Object input, Object ancestor,
}

private void disposeCompareFilterActions(boolean updateActionBars) {
Iterator<ChangeCompareFilterPropertyAction> compareFilterActionsIterator = fCompareFilterActions
.iterator();
while (compareFilterActionsIterator.hasNext()) {
ChangeCompareFilterPropertyAction compareFilterAction = compareFilterActionsIterator
.next();
for (ChangeCompareFilterPropertyAction compareFilterAction : fCompareFilterActions) {
fLeft.removeTextAction(compareFilterAction);
fRight.removeTextAction(compareFilterAction);
fAncestor.removeTextAction(compareFilterAction);
Expand Down

0 comments on commit 991196f

Please sign in to comment.