From 9da9cc5748523950c086330a8e7f75d53b8d9ea7 Mon Sep 17 00:00:00 2001
From: Simon Barner <barner@fortiss.org>
Date: Thu, 12 Apr 2018 15:37:14 +0000
Subject: [PATCH] Workaround rare lockup (on Windows). refs 3381

---
 .../base/ui/annotation/view/generic/.ratings  |   6 +-
 .../view/generic/GenericAnnotationView.java   | 123 +++++++++---------
 .../annotation/view/generic/filter/.ratings   |   7 +-
 3 files changed, 67 insertions(+), 69 deletions(-)

diff --git a/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/annotation/view/generic/.ratings b/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/annotation/view/generic/.ratings
index 9fd0a9e30..431405d7f 100644
--- a/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/annotation/view/generic/.ratings
+++ b/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/annotation/view/generic/.ratings
@@ -1,3 +1,3 @@
-ColumnHandle.java 133a43480037921ac4501b9f43feab56aed46941 GREEN
-GenericAnnotationView.java 3780e3791589ed81abcbd5b5c809007560b3bce1 GREEN
-HierarchicalNameViewerComparator.java edf1d012a3d18860d2ef7f9e07baf46cdfeec381 GREEN
+ColumnHandle.java 133a43480037921ac4501b9f43feab56aed46941 YELLOW
+GenericAnnotationView.java 782362f13579378700bd41f9d5532c60217f1414 YELLOW
+HierarchicalNameViewerComparator.java edf1d012a3d18860d2ef7f9e07baf46cdfeec381 YELLOW
diff --git a/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/annotation/view/generic/GenericAnnotationView.java b/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/annotation/view/generic/GenericAnnotationView.java
index 2e3bacfb0..53d2c1715 100644
--- a/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/annotation/view/generic/GenericAnnotationView.java
+++ b/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/annotation/view/generic/GenericAnnotationView.java
@@ -15,7 +15,6 @@
 +--------------------------------------------------------------------------*/
 package org.fortiss.tooling.base.ui.annotation.view.generic;
 
-import static java.lang.Math.max;
 import static org.fortiss.tooling.base.ui.annotation.editingsupport.EditingSupportFactory.createEditingSupport;
 import static org.fortiss.tooling.base.ui.annotation.labelprovider.LabelProviderFactory.createLabelProvider;
 
@@ -49,9 +48,7 @@ import org.eclipse.swt.events.ControlEvent;
 import org.eclipse.swt.events.ControlListener;
 import org.eclipse.swt.events.SelectionAdapter;
 import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.graphics.Image;
 import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.Rectangle;
 import org.eclipse.swt.layout.FillLayout;
 import org.eclipse.swt.layout.GridData;
 import org.eclipse.swt.layout.GridLayout;
@@ -311,64 +308,65 @@ public class GenericAnnotationView extends AnnotationViewPartBase {
 	 * Installs a listener to the given {@link Table} that adjust the row height to to the current
 	 * contents.
 	 */
-	private void addRowHeightListener(Table table) {
-
-		/*
-		 * NB: MeasureItem, PaintItem and EraseItem are called repeatedly and are hence
-		 * performance critical.
-		 */
-		Listener rowHeightListener = new Listener() {
-			@Override
-			public void handleEvent(Event event) {
-				switch(event.type) {
-					case SWT.MeasureItem: {
-						TableItem item = (TableItem)event.item;
-						String text = item.getText(event.index);
-						Point textSize = event.gc.textExtent(text);
-						event.width = textSize.x;
-						event.height = Math.max(event.height, textSize.y);
-
-						Image image = item.getImage(event.index);
-						if(image != null) {
-							Rectangle imageSize = image.getBounds();
-							event.width = max(event.width, imageSize.x);
-							event.height = max(event.height, imageSize.y);
-						}
-						break;
-					}
-					case SWT.PaintItem: {
-						TableItem item = (TableItem)event.item;
-
-						// Determine maximum content height (considering text and image contents),
-						// and derive resulting vertical offset
-						String text = item.getText(event.index);
-						int contentHeight = event.gc.textExtent(text).y;
-
-						Image image = item.getImage(event.index);
-						if(image != null) {
-							contentHeight = max(contentHeight, image.getBounds().y);
-						}
-						int offset = max(0, (event.height - contentHeight) / 2);
-
-						// Render content
-						event.gc.drawText(text, event.x, event.y + offset, true);
-						if(image != null) {
-							event.gc.drawImage(image, event.x, event.y + offset);
-						}
-
-						break;
-					}
-					case SWT.EraseItem: {
-						event.detail &= ~SWT.FOREGROUND;
-						break;
-					}
-				}
-			}
-		};
-		table.addListener(SWT.MeasureItem, rowHeightListener);
-		table.addListener(SWT.PaintItem, rowHeightListener);
-		table.addListener(SWT.EraseItem, rowHeightListener);
-	}
+	// TODO: Disable for now (see #3381).
+	// private void addRowHeightListener(Table table) {
+	//
+	// /*
+	// * NB: MeasureItem, PaintItem and EraseItem are called repeatedly and are hence
+	// * performance critical.
+	// */
+	// Listener rowHeightListener = new Listener() {
+	// @Override
+	// public void handleEvent(Event event) {
+	// switch(event.type) {
+	// case SWT.MeasureItem: {
+	// TableItem item = (TableItem)event.item;
+	// String text = item.getText(event.index);
+	// Point textSize = event.gc.textExtent(text);
+	// event.width = textSize.x;
+	// event.height = Math.max(event.height, textSize.y);
+	//
+	// Image image = item.getImage(event.index);
+	// if(image != null) {
+	// Rectangle imageSize = image.getBounds();
+	// event.width = max(event.width, imageSize.x);
+	// event.height = max(event.height, imageSize.y);
+	// }
+	// break;
+	// }
+	// case SWT.PaintItem: {
+	// TableItem item = (TableItem)event.item;
+	//
+	// // Determine maximum content height (considering text and image contents),
+	// // and derive resulting vertical offset
+	// String text = item.getText(event.index);
+	// int contentHeight = event.gc.textExtent(text).y;
+	//
+	// Image image = item.getImage(event.index);
+	// if(image != null) {
+	// contentHeight = max(contentHeight, image.getBounds().y);
+	// }
+	// int offset = max(0, (event.height - contentHeight) / 2);
+	//
+	// // Render content
+	// event.gc.drawText(text, event.x, event.y + offset, true);
+	// if(image != null) {
+	// event.gc.drawImage(image, event.x, event.y + offset);
+	// }
+	//
+	// break;
+	// }
+	// case SWT.EraseItem: {
+	// event.detail &= ~SWT.FOREGROUND;
+	// break;
+	// }
+	// }
+	// }
+	// };
+	// table.addListener(SWT.MeasureItem, rowHeightListener);
+	// table.addListener(SWT.PaintItem, rowHeightListener);
+	// table.addListener(SWT.EraseItem, rowHeightListener);
+	// }
 
 	/**
 	 * Constructs a {@link Listener} such that a context menu is created upon a right-click on
@@ -562,7 +560,8 @@ public class GenericAnnotationView extends AnnotationViewPartBase {
 		table.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
 
 		// Listener to adjust row height to contents
-		addRowHeightListener(table);
+		// TODO: Disable for now (see #3381)
+		// addRowHeightListener(table);
 
 		// Preserve default row-height (used to restore it during contents updates in
 		// update(Collection<AnnotationEntry>)).
diff --git a/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/annotation/view/generic/filter/.ratings b/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/annotation/view/generic/filter/.ratings
index fdf7f5f2c..ab02aab3a 100644
--- a/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/annotation/view/generic/filter/.ratings
+++ b/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/annotation/view/generic/filter/.ratings
@@ -1,4 +1,3 @@
-
-AnnotationFilter.java ab3e2d0b60696cc6a1abb00295c6e066b7cf6151 GREEN
-AnnotationFilterWidget.java 9e2d724a13b523982c27ffa41666e3708a100389 GREEN
-TextFocusListener.java 6a657b1c6d1f539982ea5a5d76414a6e36e960c5 GREEN
+AnnotationFilter.java ab3e2d0b60696cc6a1abb00295c6e066b7cf6151 YELLOW
+AnnotationFilterWidget.java 9e2d724a13b523982c27ffa41666e3708a100389 YELLOW
+TextFocusListener.java 6a657b1c6d1f539982ea5a5d76414a6e36e960c5 YELLOW
-- 
GitLab