Skip to main content
aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorLeo Ufimtsev2018-02-14 15:49:01 +0000
committerAlexander Kurtakov2018-02-15 16:20:39 +0000
commit1a3294ba5966b01cc2953d4ad12ed02eb971b97f (patch)
tree1129f5c27ad077c38883f1fbdd5920ff535fa840 /tests
parenta377e8395b4414fe37916d64d08d92f6cac6dfa2 (diff)
downloadeclipse.platform.swt-1a3294ba5966b01cc2953d4ad12ed02eb971b97f.tar.gz
eclipse.platform.swt-1a3294ba5966b01cc2953d4ad12ed02eb971b97f.tar.xz
eclipse.platform.swt-1a3294ba5966b01cc2953d4ad12ed02eb971b97f.zip
Bug 510803 [GTK3] Regression in table editing capabilities in tabfolder.I20180215-2000
Breakage occurred because tabItem reparented an item that had a non-standard gDk parent window. Solution: fix gdk window parent for such special controls. (I.e ControlEditors in tables). Verification: - Open child eclipse, change method signature. Now table cells can be edited via click. - Open attached snippet, with patch cells can be edited properly. - AllTests Gtk3.22 - X11/Wayland. Patchset 3: - Minor rename of methods to clarify that it's a *gdk* window, Bug: https://bugs.eclipse.org/bugs/show_bug.cgi?id=5108033 Change-Id: I8dcaac950eb0847dd97016b2140c607012550d2f Signed-off-by: Leo Ufimtsev <lufimtse@redhat.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug510803_TabFolder_Table_inPlaceEditing.java108
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug510803_TabFolder_TreeEditor_Regression.java124
2 files changed, 124 insertions, 108 deletions
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug510803_TabFolder_Table_inPlaceEditing.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug510803_TabFolder_Table_inPlaceEditing.java
deleted file mode 100644
index aa8a2e6b02..0000000000
--- a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug510803_TabFolder_Table_inPlaceEditing.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2018 Red Hat and others. All rights reserved.
- * The contents of this file are made available under the terms
- * of the GNU Lesser General Public License (LGPL) Version 2.1 that
- * accompanies this distribution (lgpl-v21.txt). The LGPL is also
- * available at http://www.gnu.org/licenses/lgpl.html. If the version
- * of the LGPL at http://www.gnu.org is different to the version of
- * the LGPL accompanying this distribution and there is any conflict
- * between the two license versions, the terms of the LGPL accompanying
- * this distribution shall govern.
- *
- * Contributors:
- * Red Hat - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.tests.gtk.snippets;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.KeyAdapter;
-import org.eclipse.swt.events.KeyEvent;
-import org.eclipse.swt.events.MouseAdapter;
-import org.eclipse.swt.events.MouseEvent;
-import org.eclipse.swt.layout.FillLayout;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.TabFolder;
-import org.eclipse.swt.widgets.TabItem;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.TableItem;
-import org.eclipse.swt.widgets.Text;
-
-/*
- * Title:
- * How to run:
- * Bug description:
- * Expected results:
- * GTK Version(s):
- */
-//clicking on a row item and typing appends characters.
-//Gtk2: Works as expected.
-//Gtk3: Spam of errors, black second window.
-//(SWT:7324): Gdk-WARNING **: gdk_window_new(): parent is destroyed
-//(SWT:7324): Gdk-CRITICAL **: gdk_window_set_user_data: assertion 'GDK_IS_WINDOW (window)' failed
-//(SWT:7324): Gdk-CRITICAL **: gdk_window_get_scale_factor: assertion 'GDK_IS_WINDOW (window)' failed
-//(SWT:7324): GLib-GObject-CRITICAL **: g_object_ref: assertion 'G_IS_OBJECT (object)' failed
-public class Bug510803_TabFolder_Table_inPlaceEditing {
-
- public static void main(String[] args) {
- Shell shell = shellSetup();
-
- final TabFolder tabFolder = new TabFolder(shell, SWT.NONE);
- TabItem tabItem = new TabItem(tabFolder, SWT.NONE);
- tabItem.setText("Hello tab");
-
- Table table = new Table(tabFolder, SWT.NONE);
- TableItem tableItem = new TableItem(table, SWT.None);
- tableItem.setText("Item 1");
- TableItem tableItem2 = new TableItem(table, SWT.None);
- tableItem2.setText("Item 2");
-
- // Notes:
- // - Seems to occur with any control, not just Text. (Tested with Button also)
- final Text cellEditorText = new Text(table, SWT.SINGLE); // Note,
- cellEditorText.setText("Hello world");
-
- // Listeners that make typing into Table edit controls. Useful to test
- // functionality, but errors occur without the listeners also.
- table.addMouseListener(new MouseAdapter() {
- @Override
- public void mouseUp(MouseEvent e) {
- cellEditorText.setFocus();
- };
- });
-
- cellEditorText.addKeyListener(new KeyAdapter() {
- @Override
- public void keyPressed(KeyEvent e) {
- TableItem selectedItem = table.getSelection()[0];
- selectedItem.setText(selectedItem.getText() + e.character);
- };
- });
-
- // Location of setControl() method call has an impact.
- // If it's before 'Text' creation, no errors are thrown into the
- // console.
- tabItem.setControl(table);
-
- mainEventLoop(shell);
- }
-
- private static Shell shellSetup() {
- final Display display = new Display();
- Shell shell = new Shell(display);
- shell.setLayout(new FillLayout());
- return shell;
- }
-
- private static void mainEventLoop(Shell shell) {
- Display display = shell.getDisplay();
- shell.open();
- shell.setSize(200, 300);
- 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/Bug510803_TabFolder_TreeEditor_Regression.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug510803_TabFolder_TreeEditor_Regression.java
new file mode 100644
index 0000000000..4edc512151
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug510803_TabFolder_TreeEditor_Regression.java
@@ -0,0 +1,124 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat and others. All rights reserved.
+ * The contents of this file are made available under the terms
+ * of the GNU Lesser General Public License (LGPL) Version 2.1 that
+ * accompanies this distribution (lgpl-v21.txt). The LGPL is also
+ * available at http://www.gnu.org/licenses/lgpl.html. If the version
+ * of the LGPL at http://www.gnu.org is different to the version of
+ * the LGPL accompanying this distribution and there is any conflict
+ * between the two license versions, the terms of the LGPL accompanying
+ * this distribution shall govern.
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+import static org.eclipse.swt.events.SelectionListener.widgetSelectedAdapter;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.TableEditor;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.TabFolder;
+import org.eclipse.swt.widgets.TabItem;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
+import org.eclipse.swt.widgets.TableItem;
+import org.eclipse.swt.widgets.Text;
+
+/*
+ * Title: Modified Snippet88, table cell editor.
+ * Snippet88 creates Cell Editor on every new click.
+ * This snippet has a passive table editor that is created once, is initially invisible and is set to be visible when needed.
+ *
+ * This snippet emulates refactoring dialogues like "change method signature", where you have a Table with TableEditor inside a tab folder.
+ *
+ * How to run: Run snippet. Try to edit cells.
+ * Bug description: Passive table/tree editors were not working.
+ * Expected results: Cells can be edited.
+ * GTK Version(s): Gtk3.22, Gtk2.24. x11/Wayland.
+ */
+public class Bug510803_TabFolder_TreeEditor_Regression {
+
+ public static void main(String[] args) {
+ Display display = new Display();
+ Shell shell = new Shell(display);
+ shell.setLayout(new FillLayout());
+
+ { // Part one : Tab folder who's direct item is a Table.
+ final TabFolder tabFolder = new TabFolder(shell, SWT.NONE);
+ TabItem tabItem = new TabItem(tabFolder, SWT.NONE);
+ tabItem.setText("One Control");
+ Table table = makeTableWithPassiveControlEditor(tabFolder);
+ tabItem.setControl(table);
+ }
+
+ { // Part two : TabItem who has a composite, who then has a table with editor.
+ // To verify that if a tabItem has a composite, it's children are traversed properly.
+ final TabFolder tabFolder = new TabFolder(shell, SWT.NONE);
+ TabItem tabItem = new TabItem(tabFolder, SWT.NONE);
+ tabItem.setText("Composite with Children");
+
+ Composite composite = new Composite(tabFolder, SWT.NONE);
+ composite.setLayout(new FillLayout(SWT.VERTICAL));
+ new Button(composite, SWT.PUSH).setText("Dummy button");
+
+ makeTableWithPassiveControlEditor(composite);
+ tabItem.setControl(composite);
+ }
+
+ shell.setSize(300, 300);
+ shell.open();
+
+ while (!shell.isDisposed()) {
+ if (!display.readAndDispatch())
+ display.sleep();
+ }
+ display.dispose();
+ }
+ private static Table makeTableWithPassiveControlEditor(final Composite parent) {
+ final Table table = new Table(parent, SWT.FULL_SELECTION | SWT.HIDE_SELECTION);
+ TableColumn column1 = new TableColumn(table, SWT.NONE);
+ for (int i = 0; i < 10; i++) {
+ TableItem item = new TableItem(table, SWT.NONE);
+ item.setText("Item " + i);
+ }
+ column1.pack();
+
+ final TableEditor tableEditor = new TableEditor(table);
+ tableEditor.horizontalAlignment = SWT.LEFT;
+ tableEditor.grabHorizontal = true;
+ tableEditor.minimumWidth = 50;
+
+ final Text tableEditorControl = new Text(table, SWT.NONE);
+ // Location of setControl() method call has an impact.
+ // If it's before 'Text tableEditorControl = new Text(table, SWT.NONE);', then things work.
+
+ tableEditorControl.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_YELLOW));
+ tableEditorControl.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_RED));
+ tableEditorControl.setText("Click some row");
+ tableEditorControl.addModifyListener(me -> {
+ if (tableEditor.getItem() != null) {
+ table.getSelection()[0].setText(tableEditorControl.getText());
+ }
+ });
+ tableEditor.setEditor(tableEditorControl);
+ tableEditorControl.setVisible(false);
+ tableEditor.setColumn(0);
+
+ table.addSelectionListener(widgetSelectedAdapter(e -> {
+ TableItem item = (TableItem) e.item;
+ if (item == null) return;
+ tableEditorControl.setVisible(true);
+ tableEditorControl.setText(item.getText());
+ tableEditorControl.selectAll();
+ tableEditorControl.setFocus();
+ tableEditor.setItem(item);
+ }));
+ return table;
+ }
+}

Back to the top