Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 194160 Details for
Bug 343854
Web Application to Workbench Examples
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Cosmetic patch to link intercept exampe
linkExample.patch (text/plain), 8.42 KB, created by
Dean Roberts
on 2011-04-27 10:31:50 EDT
(
hide
)
Description:
Cosmetic patch to link intercept exampe
Filename:
MIME Type:
Creator:
Dean Roberts
Created:
2011-04-27 10:31:50 EDT
Size:
8.42 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.e4.examples.webintegration >Index: src/org/eclipse/e4/examples/webintegration/links/BrowserView.java >=================================================================== >RCS file: /cvsroot/eclipse/e4/org.eclipse.e4.ui/examples/org.eclipse.e4.examples.webintegration/src/org/eclipse/e4/examples/webintegration/links/BrowserView.java,v >retrieving revision 1.1 >diff -u -r1.1 BrowserView.java >--- src/org/eclipse/e4/examples/webintegration/links/BrowserView.java 26 Apr 2011 19:32:52 -0000 1.1 >+++ src/org/eclipse/e4/examples/webintegration/links/BrowserView.java 27 Apr 2011 14:29:30 -0000 >@@ -1,112 +1,106 @@ >-/******************************************************************************* >- * Copyright (c) 2011 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: >- * Dean Roberts, IBM Corporation - initial API and implementation >- *******************************************************************************/ >- >-package org.eclipse.e4.examples.webintegration.links; >- >- >-import org.eclipse.e4.examples.webintegration.application.Perspective; >-import org.eclipse.swt.SWT; >-import org.eclipse.swt.browser.Browser; >-import org.eclipse.swt.browser.LocationEvent; >-import org.eclipse.swt.browser.LocationListener; >-import org.eclipse.swt.widgets.Composite; >-import org.eclipse.ui.IViewPart; >-import org.eclipse.ui.PartInitException; >-import org.eclipse.ui.PlatformUI; >-import org.eclipse.ui.actions.NewWizardAction; >-import org.eclipse.ui.part.ViewPart; >- >- >-/** >- * Example of a BrowserWidget that can incercept links and perform Eclipse Workbench >- * actions as desired. >- * >- * This example is discussed at http://deanoneclipse.wordpress.com >- */ >-public class BrowserView extends ViewPart { >- >- private Browser browser; >- >- public void createPartControl(Composite parent) { >- browser = new Browser(parent, SWT.NONE); >- browser.setUrl(Perspective.gmailURL); >- >- // Hooks the link intercept code >- browser.addLocationListener(new LinkInterceptListener()); >- } >- >- /** >- * Implement a LocationListener to intercept links and decide what to do. >- */ >- private class LinkInterceptListener implements LocationListener { >- // method called when the user clicks a link but before the link is opened. >- public void changing(LocationEvent event) { >- try { >- // Call user code to process link as desired and return >- // true if the link should be opened in place. >- boolean shouldOpenLinkInPlace = !openView(event.location); >- >- // Setting event.doit to false prevents the link from opening in place >- event.doit = shouldOpenLinkInPlace; >- } catch (PartInitException e) { >- e.printStackTrace(); >- } >- } >- >- // method called after the link has been opened in place. >- public void changed(LocationEvent event) { >- // Not used in this example >- } >- } >- >- /** >- * User code: >- * >- * Examine the link and determine if we wish to intercept it. Perform appropriate actions for intercepted links, do >- * nothing for links we want to be opened in place (default behaviour) >- * >- * Return true if we intercepted the link. Return false if we did not intercept the link and expect the browser to >- * open the link in place. >- */ >- private boolean openView(String location) throws PartInitException { >- >- /** >- * Certainly the if/else-if construct could be replaced with a more elegant lookup mechanism. >- */ >- >- // Open a view >- if (location.equals("http://www.google.com/intl/en_CA/mobile/mail/#utm_source=en_CA-cpp-g4mc-gmhp&utm_medium=cpp&utm_campaign=en_CA")) { >- IViewPart newView = getViewSite().getPage().showView("url.link.1"); >- ((LinkView) newView).setURL(location); >- >- return true; >- // Open a wizard >- } else if (location.contains("/accounts/recovery")) { >- NewWizardAction a = new NewWizardAction(PlatformUI.getWorkbench().getActiveWorkbenchWindow()); >- a.run(); >- // commented out to avoid a dependency on org.eclipse.ui.ide: >- // BasicNewFileResourceWizard wizard = new BasicNewFileResourceWizard(); >- // wizard.init(getSite().getWorkbenchWindow().getWorkbench(), new StructuredSelection()); >- // WizardDialog dialog = new WizardDialog(getSite().getShell(), wizard); >- // dialog.create(); >- // dialog.open(); >- >- return true; >- } >- >- // Do not intercept link. Allow browser widget to open link in place >- return false; >- } >- >- public void setFocus() { >- // Not important for our example. >- } >-} >+/******************************************************************************* >+ * Copyright (c) 2011 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: >+ * Dean Roberts, IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+ >+package org.eclipse.e4.examples.webintegration.links; >+ >+ >+import org.eclipse.e4.examples.webintegration.application.Perspective; >+import org.eclipse.swt.SWT; >+import org.eclipse.swt.browser.Browser; >+import org.eclipse.swt.browser.LocationEvent; >+import org.eclipse.swt.browser.LocationListener; >+import org.eclipse.swt.widgets.Composite; >+import org.eclipse.ui.IViewPart; >+import org.eclipse.ui.PartInitException; >+import org.eclipse.ui.PlatformUI; >+import org.eclipse.ui.actions.NewWizardAction; >+import org.eclipse.ui.part.ViewPart; >+ >+ >+/** >+ * Example of a BrowserWidget that can incercept links and perform Eclipse Workbench >+ * actions as desired. >+ * >+ * This example is discussed at http://deanoneclipse.wordpress.com >+ */ >+public class BrowserView extends ViewPart { >+ >+ private Browser browser; >+ >+ public void createPartControl(Composite parent) { >+ browser = new Browser(parent, SWT.NONE); >+ browser.setUrl(Perspective.gmailURL); >+ >+ // Hooks the link intercept code >+ browser.addLocationListener(new LinkInterceptListener()); >+ } >+ >+ /** >+ * Implement a LocationListener to intercept links and decide what to do. >+ */ >+ private class LinkInterceptListener implements LocationListener { >+ // method called when the user clicks a link but before the link is opened. >+ public void changing(LocationEvent event) { >+ try { >+ // Call user code to process link as desired and return >+ // true if the link should be opened in place. >+ boolean shouldOpenLinkInPlace = !openView(event.location); >+ >+ // Setting event.doit to false prevents the link from opening in place >+ event.doit = shouldOpenLinkInPlace; >+ } catch (PartInitException e) { >+ e.printStackTrace(); >+ } >+ } >+ >+ // method called after the link has been opened in place. >+ public void changed(LocationEvent event) { >+ // Not used in this example >+ } >+ } >+ >+ /** >+ * User code: >+ * >+ * Examine the link and determine if we wish to intercept it. Perform appropriate actions for intercepted links, do >+ * nothing for links we want to be opened in place (default behaviour) >+ * >+ * Return true if we intercepted the link. Return false if we did not intercept the link and expect the browser to >+ * open the link in place. >+ */ >+ private boolean openView(String location) throws PartInitException { >+ >+ /** >+ * Certainly the if/else-if construct could be replaced with a more elegant lookup mechanism. >+ */ >+ >+ // Open a view >+ if (location.equals("http://www.google.com/intl/en_CA/mobile/mail/#utm_source=en_CA-cpp-g4mc-gmhp&utm_medium=cpp&utm_campaign=en_CA")) { >+ IViewPart newView = getViewSite().getPage().showView("url.link.1"); >+ ((LinkView) newView).setURL(location); >+ >+ return true; >+ // Open a wizard >+ } else if (location.contains("/accounts/recovery")) { >+ NewWizardAction action = new NewWizardAction(PlatformUI.getWorkbench().getActiveWorkbenchWindow()); >+ action.run(); >+ >+ return true; >+ } >+ >+ // Do not intercept link. Allow browser widget to open link in place >+ return false; >+ } >+ >+ public void setFocus() { >+ // Not important for our example. >+ } >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 343854
:
194059
| 194160 |
196043