Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » Changing Perspective(How to close active sockets?)
Changing Perspective [message #556757] Thu, 02 September 2010 10:18 Go to next message
Mathias Zenger is currently offline Mathias Zenger
Messages: 10
Registered: July 2009
Junior Member
Hi,

In my RCP application I run two plug-ins. Both of them provide a perspective. Both plug-ins use the same socket address (IP + port number) for network communication. When changing perspective the inactive perspective/plug-in must free the socket otherwise the active perspective/plug-in can't initialize its socket.

I have a listener in my RCP application's ApplicationWorkbenchWindowAdvisor which could perhaps take care of the needed action:

/**
* Listener for perspective changes.
 */
private IPerspectiveListener listener = new IPerspectiveListener() {
	public void perspectiveActivated(IWorkbenchPage page, IPerspectiveDescriptor perspective) {
		// Close all open editors when changing perspective
			page.closeAllEditors(true);
			
			// TODO:
			// Take action to close all open socket connections when switching perspectives.
		}
		public void perspectiveChanged(IWorkbenchPage page, IPerspectiveDescriptor perspective, String changeId) {
			// No action
		}
	};


Can anybody give me a hint how to access the inactive perspective/plug-in to close the sockets? Any other ideas?
Thank you!
Re: Changing Perspective [message #556758 is a reply to message #556757] Thu, 02 September 2010 10:23 Go to previous message
eshvar60  is currently offline eshvar60
Messages: 51
Registered: March 2010
Member
Hey Mathias,

You are on the right track check out IPerspectiveListener3 and IPerspectiveListener4. The ladder has a preDeactivate method which allows you to perform actions before a perspective is destroyed.

The exact API is here:
http:// help.eclipse.org/help33/index.jsp?topic=/org.eclipse.platfor m.doc.isv/reference/api/org/eclipse/ui/IPerspectiveListener3 .html

and here:
http:// help.eclipse.org/help33/index.jsp?topic=/org.eclipse.platfor m.doc.isv/reference/api/org/eclipse/ui/IPerspectiveListener4 .html
Previous Topic:Switching Presentations on the fly, programmatically?
Next Topic:RCP Training Classes, Sep-Oct
Goto Forum:
  


Current Time: Mon Jul 28 02:16:28 EDT 2014

Powered by FUDForum. Page generated in 0.02314 seconds