Skip to main content
aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorLeo Ufimtsev2018-01-19 17:41:48 +0000
committerLeo Ufimtsev2018-01-22 17:50:07 +0000
commitddedf897614a02d30597f85d9cf8131b465864fc (patch)
treeb02dd29caa3a2f4e721e025fe8dfd9a67eacf639 /tests
parentd30928e83d65746aa877315fed67bbae58a6e788 (diff)
downloadeclipse.platform.swt-ddedf897614a02d30597f85d9cf8131b465864fc.tar.gz
eclipse.platform.swt-ddedf897614a02d30597f85d9cf8131b465864fc.tar.xz
eclipse.platform.swt-ddedf897614a02d30597f85d9cf8131b465864fc.zip
Bug 525305 – [API]Provide SWT.OpenUrl event (Linux implementation)
(For review/merge) Linux implementation for OpenUrl event, with use of GDBus. (As per original patch *1). URL vs file detection done via "new URI(file).getScheme()". I tested, this distinguishes URI's from files quite well. I.e: /myfile/ ./file file .. -> (OpenFile) http://www.eclipse.org mailto:my@mail.com .. -> (OpenUrl) I've tested with latest launcher: 1) Via launcher: eclipse http://www.eclipse.org /tmp/myFile 2) Via gdbus calls: gdbus call --session --dest org.eclipse.swt --object-path /org/eclipse/swt --method org.eclipse.swt.FileOpen "['http://www.google.com', '/tmp/myFile']" Patchset 2: - Updated URL detection logic so that files/urls are properly distinguished. Links: [1] Original patch: https://git.eclipse.org/r/#/c/30107/14/bundles/org.eclipse.swt/Eclipse+SWT/gtk/org/eclipse/swt/widgets/Display.java Bug: https://bugs.eclipse.org/bugs/show_bug.cgi?id=525305 Change-Id: I6531989e3eb766fdf0715a0a9cb86c9ed2b973f3 Signed-off-by: Leo Ufimtsev <lufimtse@redhat.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/org.eclipse.swt.tests.gtk/Bug Snippets/org/eclipse/swt/tests/gtk/snippets/Bug525305_Browser_OpenUrl.java47
1 files changed, 47 insertions, 0 deletions
diff --git a/tests/org.eclipse.swt.tests.gtk/Bug Snippets/org/eclipse/swt/tests/gtk/snippets/Bug525305_Browser_OpenUrl.java b/tests/org.eclipse.swt.tests.gtk/Bug Snippets/org/eclipse/swt/tests/gtk/snippets/Bug525305_Browser_OpenUrl.java
new file mode 100644
index 0000000000..261582c0f7
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/Bug Snippets/org/eclipse/swt/tests/gtk/snippets/Bug525305_Browser_OpenUrl.java
@@ -0,0 +1,47 @@
+package org.eclipse.swt.tests.gtk.snippets;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.browser.Browser;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+
+/*
+ * Title: Handle files or URLs from eclipse launcher or gdbus.
+ * How to run:
+ - Open snippet with Launch Configuration VM Argument: -Dswt.dbus.init
+ - Run launcher with file or url
+ eclipse /myFile htpp://www.google.com
+ * Bug description:
+ * Expected results: Browser opens URLs, filenames printed.
+ * GTK Version(s): 3.22/2.24
+ */
+public class Bug525305_Browser_OpenUrl {
+
+ public static void main(String[] args) {
+ Display display = new Display();
+ Shell shell = new Shell(display);
+ shell.setSize(500, 600);
+ shell.setLayout(new FillLayout());
+
+ final Browser browser = new Browser(shell, SWT.NONE);
+ browser.setText("hello <b>world!</b>");
+
+ display.addListener(SWT.OpenUrl, e -> {
+ System.out.println("OpenUrl with:" + e.text);
+ browser.setUrl(e.text);
+ });
+
+ display.addListener(SWT.OpenDocument, e -> {
+ System.out.println("OpenDocument with: " + e.text);
+ browser.setText("OpenDocument was called with arg: " + e.text);
+ });
+
+ shell.open();
+ while (!shell.isDisposed()) {
+ if (!display.readAndDispatch())
+ display.sleep();
+ }
+ display.dispose();
+ }
+}

Back to the top