Skip to main content
aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorEric Williams2018-05-28 18:22:41 +0000
committerEric Williams2018-05-29 17:39:18 +0000
commit2bd7cc57d6f8db85984adca7abc84236618f0b2d (patch)
treeb0110e1269fd34e972dce6919e4ca94c530edc06 /tests
parent86c15e9a4fc470befff6e93a09521c3e3a6c7a65 (diff)
downloadeclipse.platform.swt-2bd7cc57d6f8db85984adca7abc84236618f0b2d.tar.gz
eclipse.platform.swt-2bd7cc57d6f8db85984adca7abc84236618f0b2d.tar.xz
eclipse.platform.swt-2bd7cc57d6f8db85984adca7abc84236618f0b2d.zip
Bug 258196: [GTK] Virtual Tree does not resize correctly horizontally
Using the patch from bugzilla, add updated flags to Tree and TreeItem which are triggered when changes are made that would affect the layout of the Tree. These changes will trigger the proper scrolling width to be set. Tested on GTK2 and GTK3, no ill effects seen. No AllNonBrowser JUnit tests fail, and the snippet from bug 490203 doesn't show any reduction in performance either. Bumped versions for first 4.9 commit. Change-Id: If8d435248db5bc4ba5448f803bafd4eef1165167 Signed-off-by: Eric Williams <ericwill@redhat.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/org.eclipse.swt.tests.gtk/META-INF/MANIFEST.MF2
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug258196_VirtualTreeResizing.java51
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug490203_VirtualTreePerf.java63
-rw-r--r--tests/org.eclipse.swt.tests.gtk/pom.xml2
4 files changed, 116 insertions, 2 deletions
diff --git a/tests/org.eclipse.swt.tests.gtk/META-INF/MANIFEST.MF b/tests/org.eclipse.swt.tests.gtk/META-INF/MANIFEST.MF
index 36a60085bc..29dc8f69be 100644
--- a/tests/org.eclipse.swt.tests.gtk/META-INF/MANIFEST.MF
+++ b/tests/org.eclipse.swt.tests.gtk/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.swt.tests.gtk
-Bundle-Version: 3.106.0.qualifier
+Bundle-Version: 3.107.100.qualifier
Bundle-Vendor: %providerName
Require-Bundle: org.junit;bundle-version="4.12.0",
org.eclipse.swt
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug258196_VirtualTreeResizing.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug258196_VirtualTreeResizing.java
new file mode 100644
index 0000000000..d7c60a83b3
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug258196_VirtualTreeResizing.java
@@ -0,0 +1,51 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Tree;
+import org.eclipse.swt.widgets.TreeItem;
+
+public class Bug258196_VirtualTreeResizing {
+ public static void main(String[] args) {
+ final Display display = new Display();
+ final Shell shell = new Shell(display);
+ shell.setLayout (new FillLayout());
+ final Tree tree = new Tree(shell, SWT.VIRTUAL | SWT.BORDER);
+ tree.addListener(SWT.SetData, event -> {
+ final TreeItem item = (TreeItem)event.item;
+ TreeItem parentItem = item.getParentItem();
+ String text = null;
+ if (parentItem == null) {
+ text = "node "+tree.indexOf(item);
+ } else {
+ text = parentItem.getText()+" - "+parentItem.indexOf(item);
+ }
+ item.setData(text);
+ item.setItemCount(10);
+ display.asyncExec(() -> {
+ if (!item.isDisposed()) {
+ item.setText(item.getData().toString());
+ }
+ });
+ });
+ tree.setItemCount(20);
+ shell.setSize(400, 300);
+ shell.open();
+ while (!shell.isDisposed ()) {
+ if (!display.readAndDispatch ()) display.sleep ();
+ }
+ display.dispose ();
+ }
+}
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug490203_VirtualTreePerf.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug490203_VirtualTreePerf.java
new file mode 100644
index 0000000000..8c713e2de0
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug490203_VirtualTreePerf.java
@@ -0,0 +1,63 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2018 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.RowData;
+import org.eclipse.swt.layout.RowLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Tree;
+import org.eclipse.swt.widgets.TreeItem;
+
+public class Bug490203_VirtualTreePerf {
+ static final int COUNT = 10_000;
+
+ public static void main(String[] args) {
+ Display display = new Display ();
+ final Shell shell = new Shell (display);
+ shell.setLayout (new RowLayout (SWT.VERTICAL));
+ final Tree tree = new Tree (shell, SWT.VIRTUAL | SWT.BORDER);
+ TreeItem[] top = { null };
+ tree.addListener (SWT.SetData, event -> {
+ TreeItem item = (TreeItem) event.item;
+ if (item.getParentItem() == null) {
+ top[0] = item;
+ item.setText("top");
+ } else {
+ int index = top[0].indexOf (item);
+ item.setText ("Item " + index);
+ }
+ System.out.println (item.getText ());
+ });
+ tree.setLayoutData (new RowData (200, 200));
+ Button button = new Button (shell, SWT.PUSH);
+ button.setText ("&Add Items");
+ final Label label = new Label(shell, SWT.NONE);
+ button.addListener (SWT.Selection, event -> {
+ long t1 = System.currentTimeMillis ();
+ top[0].setItemCount (COUNT);
+ top[0].setExpanded(true);
+ long t2 = System.currentTimeMillis ();
+ label.setText ("Items: " + COUNT + ", Time: " + (t2 - t1) + " (ms)");
+ shell.layout ();
+ });
+ tree.setItemCount (1);
+ shell.pack ();
+ shell.open ();
+ while (!shell.isDisposed ()) {
+ if (!display.readAndDispatch ()) display.sleep ();
+ }
+ display.dispose ();
+ }
+}
diff --git a/tests/org.eclipse.swt.tests.gtk/pom.xml b/tests/org.eclipse.swt.tests.gtk/pom.xml
index eb1a9bbb61..3720418b87 100644
--- a/tests/org.eclipse.swt.tests.gtk/pom.xml
+++ b/tests/org.eclipse.swt.tests.gtk/pom.xml
@@ -19,7 +19,7 @@
</parent>
<groupId>org.eclipse.swt</groupId>
<artifactId>org.eclipse.swt.tests.gtk</artifactId>
- <version>3.106.0-SNAPSHOT</version>
+ <version>3.107.100-SNAPSHOT</version>
<packaging>eclipse-test-plugin</packaging>
<properties>
<code.ignoredWarnings>${tests.ignoredWarnings}</code.ignoredWarnings>

Back to the top