Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » IPartListener partClosed & partActivated notification(partClosed notification occurred before the partActivated notification)
IPartListener partClosed & partActivated notification [message #874574] Mon, 21 May 2012 07:15 Go to next message
Omer Gillani is currently offline Omer GillaniFriend
Messages: 22
Registered: May 2012
Junior Member

Hi,

During last week working on editor. I observerved partActivated notification occur before the partClosed notification which cause problem for some workflows.

Can anybody guide me to change the order of notification, partClosed notification occur before partActivated which seems logical order?

Thanks in advance.

-Omer Gillani
Re: IPartListener partClosed & partActivated notification [message #874753 is a reply to message #874574] Mon, 21 May 2012 13:40 Go to previous messageGo to next message
Thorsten Schlathölter is currently offline Thorsten SchlathölterFriend
Messages: 211
Registered: February 2012
Location: Düsseldorf
Senior Member
Hi Omer,
are you talking about partActivated and partClosed of different parts? Otherwise it seems to me quite logical that you first activate the part and then close it. At least activation of a closed part doesn't seem to be logical.

Make sure your handler restricts itself to the parts which make sense in your specific context.

e.g.


public void partVisible(IWorkbenchPartReference partRef) {
			
if (MY_PART_ID.equals(partRef.getId())
{
  // do something here if MY_PART became visible
}
else
{
  // do nothing if another part became visible
}


Regards,
Thorsten
Re: IPartListener partClosed & partActivated notification [message #874791 is a reply to message #874753] Mon, 21 May 2012 14:42 Go to previous messageGo to next message
Omer Gillani is currently offline Omer GillaniFriend
Messages: 22
Registered: May 2012
Junior Member

Thorsten,

Yes. I am talking about different parts. When we open multiple editor parts and we close one of the editor part, in this case eclipse WorkbenchPage.firePartActivated first for other editor part which will be visible after closing the selected editor part and then it calls Workbenchpage.firePartClosed for the selected editor part. Actually whatever we have decorated in partActivated method, partClosed method clear all. It doesn't seem logical to me.

when we close editor, it should call partClosed where we may do clean up and then partActivated for the newly visible editor.

Thanks Thorsten.

-Omer Gillani




Re: IPartListener partClosed & partActivated notification [message #874934 is a reply to message #874791] Mon, 21 May 2012 20:28 Go to previous messageGo to next message
Thorsten Schlathölter is currently offline Thorsten SchlathölterFriend
Messages: 211
Registered: February 2012
Location: Düsseldorf
Senior Member
Can you paste some code to get an idea what your listener is actually trying to achieve?
Re: IPartListener partClosed & partActivated notification [message #875202 is a reply to message #874934] Tue, 22 May 2012 10:07 Go to previous messageGo to next message
Omer Gillani is currently offline Omer GillaniFriend
Messages: 22
Registered: May 2012
Junior Member

Have a look over the code

      
public void partClosed(IWorkbenchPart part) {
    if (part == MyEditor.this) {
      SwingUtilities.invokeLater(new Runnable() {
      @Override
      public void run() {
          MyEditorInput vi = (MyEditorInput ) getEditorInput();
	  MyEvent event = createEvent(vi.getViewEvent());
          fireViewRemoved(event);
      });
      close();
    }
}


public void partActivated(IWorkbenchPart part) {
    if (part == MyEditor.this) {
        SwingUtilities.invokeLater(new Runnable() {
	@Override
	public void run() {
            MyEvent event = createEvent(vi.getViewEvent());
            fireViewSelected(event);
        }
	});
     }
}


Re: IPartListener partClosed & partActivated notification [message #875344 is a reply to message #875202] Tue, 22 May 2012 15:00 Go to previous messageGo to next message
Thorsten Schlathölter is currently offline Thorsten SchlathölterFriend
Messages: 211
Registered: February 2012
Location: Düsseldorf
Senior Member
Unfortunately your code does not reveal the problem to me. The real problem must be located somewhere within the listeners to your MyEvents or the fireViewMethods respectively. It does not make sense to guess about this problem. But since you are dealing with different parts I would expect that - when handling ViewRemoved - you should actually be able to distinguish between the current activeSelectedView and the formerly activeSelectedView.

One other thing that strikes my eye is, that you use SwingUtils. Within SWT you should use the Display in order to place async calls to the dispatch thread.

So something like this:

partRef.getPage().getWorkbenchWindow().getShell().getDisplay().asyncExec(runnable)


Instead of SwingUtils.invokeLater().

Regards,
Thorsten
Re: IPartListener partClosed & partActivated notification [message #1008522 is a reply to message #875344] Tue, 12 February 2013 20:02 Go to previous message
Omer Gillani is currently offline Omer GillaniFriend
Messages: 22
Registered: May 2012
Junior Member

Thanks Thorsten.

We are using swt_awt bridge for our classic components and this event actually invokes swing components that's why we are using SwingUtils.invokeLater().

we are planning to re-write our swing components in SWT.

Regards,

Omer Gillani
Previous Topic:Reusing plugins folder for multiple RCP applications
Next Topic:Sorting menus defined through plugin.xml
Goto Forum:
  


Current Time: Wed Nov 26 16:53:28 GMT 2014

Powered by FUDForum. Page generated in 0.02181 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software