|
Re: Lost in a maze. [message #499918 is a reply to message #499762] |
Tue, 24 November 2009 14:21 |
|
Mauro Condarelli wrote on Mon, 23 November 2009 20:23 |
Up to this point the things are relatively clear and clean.
Scene uses what I believe is a correct way to hook to the selection: getSite().getPage().addSelectionListener(Book.ID, this);
Is this acceptable?\
|
It would be better to use:
ISelectionService s = getSite().getService(ISelectionService.class);
s.addSelectionListener(Book.ID, this);
This has the advantage that when your part is disposed, you don't have to worry about removing the selection listener (it gets cleaned up automatically).
Quote: |
IWorkbenchWindow ww = HandlerUtil.getActiveWorkbenchWindow(event);
IWorkbench w = ww.getWorkbench();
IWorkbenchPart wp = w.get
if (wp instanceof Book) {
Book b = (Book) wp;
b.setFile(file);
}
|
from the workbench window, I would go:
IWorkbenchPage page = ww.getActivePage();
Book part = (Book)page.findView(Book.ID);
You can put safeguards around that code, but basically look for your part by ID (or part reference, although in an RCP app that might not be as important).
PW
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Menu_Contributions
|
|
|
Powered by
FUDForum. Page generated in 0.03551 seconds