summaryrefslogtreecommitdiffstatsabout
diff options
context:
space:
mode:
authorMarkus Keller2011-03-30 14:23:46 (EDT)
committer Dani Megert2011-10-06 04:22:41 (EDT)
commit6d60bca262d8fbc2593d38e7d959b463f864d0ee (patch)
tree7799039db74dda8189d189b0031c758a09d7aac8
parentcd64094b5e4cb4fd5aa6df93cf45bcb3df949e9c (diff)
downloadeclipse.platform.ui-6d60bca262d8fbc2593d38e7d959b463f864d0ee.zip
eclipse.platform.ui-6d60bca262d8fbc2593d38e7d959b463f864d0ee.tar.gz
eclipse.platform.ui-6d60bca262d8fbc2593d38e7d959b463f864d0ee.tar.bz2
Bug 341259: [JFace] Add debug flag to find bad content providers that return multiple equal children
-rw-r--r--bundles/org.eclipse.jface/.options2
-rw-r--r--bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/AbstractTreeViewer.java35
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/JFaceUtil.java5
3 files changed, 39 insertions, 3 deletions
diff --git a/bundles/org.eclipse.jface/.options b/bundles/org.eclipse.jface/.options
index a96d276..c4674c5 100644
--- a/bundles/org.eclipse.jface/.options
+++ b/bundles/org.eclipse.jface/.options
@@ -20,4 +20,4 @@ org.eclipse.jface/newlook/preferences/showNewLook=false
org.eclipse.jface/trace/toolbarDisposal=false
# Reports the time to run an action
-org.eclipse.jface/trace/actions=false \ No newline at end of file
+org.eclipse.jface/trace/actions=false
diff --git a/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/AbstractTreeViewer.java b/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/AbstractTreeViewer.java
index 96d0594..b579358 100644
--- a/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/AbstractTreeViewer.java
+++ b/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/AbstractTreeViewer.java
@@ -1412,6 +1412,41 @@ public abstract class AbstractTreeViewer extends ColumnViewer {
}
/**
+ * Asserts that the given array of elements is itself non- <code>null</code>
+ * and contains no <code>null</code> elements.
+ *
+ * @param parent
+ * the parent element
+ * @param elements
+ * the array to check
+ *
+ * @see #assertElementsNotNull(Object[])
+ */
+ private void assertElementsNotNull(Object parent, Object[] elements) {
+ Assert.isNotNull(elements);
+ for (int i = 0, n = elements.length; i < n; ++i) {
+ Assert.isNotNull(elements[i]);
+ }
+
+ if (InternalPolicy.DEBUG_LOG_EQUAL_VIEWER_ELEMENTS
+ && elements.length > 1) {
+ CustomHashtable elementSet = newHashtable(elements.length * 2);
+ for (int i = 0; i < elements.length; i++) {
+ Object element = elements[i];
+ Object old = elementSet.put(element, element);
+ if (old != null) {
+ String message = "Sibling elements in viewer must not be equal:\n " //$NON-NLS-1$
+ + old + ",\n " + element + ",\n parent: " + parent; //$NON-NLS-1$ //$NON-NLS-2$
+ Policy.getLog().log(
+ new Status(IStatus.WARNING, Policy.JFACE, message,
+ new RuntimeException()));
+ return;
+ }
+ }
+ }
+ }
+
+ /**
* Returns all selected items for the given SWT control.
*
* @param control
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/JFaceUtil.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/JFaceUtil.java
index 2848c79..c6ce502 100644
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/JFaceUtil.java
+++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/JFaceUtil.java
@@ -16,8 +16,8 @@ import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.SafeRunner;
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
-import org.eclipse.core.runtime.preferences.InstanceScope;
import org.eclipse.core.runtime.preferences.IEclipsePreferences.NodeChangeEvent;
+import org.eclipse.core.runtime.preferences.InstanceScope;
import org.eclipse.jface.internal.InternalPolicy;
import org.eclipse.jface.preference.JFacePreferences;
import org.eclipse.jface.util.ILogger;
@@ -72,11 +72,12 @@ final class JFaceUtil {
});
// Get all debug options from Platform
- if ("true".equalsIgnoreCase(Platform.getDebugOption("/debug"))) { //$NON-NLS-1$ //$NON-NLS-2$
+ if ("true".equalsIgnoreCase(Platform.getDebugOption(Policy.JFACE + "/debug"))) { //$NON-NLS-1$ //$NON-NLS-2$
Policy.DEBUG_DIALOG_NO_PARENT = "true".equalsIgnoreCase(Platform.getDebugOption(Policy.JFACE + "/debug/dialog/noparent")); //$NON-NLS-1$ //$NON-NLS-2$
Policy.TRACE_ACTIONS = "true".equalsIgnoreCase(Platform.getDebugOption(Policy.JFACE + "/trace/actions")); //$NON-NLS-1$ //$NON-NLS-2$
Policy.TRACE_TOOLBAR = "true".equalsIgnoreCase(Platform.getDebugOption(Policy.JFACE + "/trace/toolbarDisposal")); //$NON-NLS-1$ //$NON-NLS-2$
InternalPolicy.DEBUG_LOG_REENTRANT_VIEWER_CALLS = "true".equalsIgnoreCase(Platform.getDebugOption(Policy.JFACE + "/debug/viewers/reentrantViewerCalls")); //$NON-NLS-1$ //$NON-NLS-2$
+ InternalPolicy.DEBUG_LOG_EQUAL_VIEWER_ELEMENTS = "true".equalsIgnoreCase(Platform.getDebugOption(Policy.JFACE + "/debug/viewers/equalElements")); //$NON-NLS-1$ //$NON-NLS-2$
}
}