Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse 4 » Inserting an object into the application context
Inserting an object into the application context [message #1750678] Sat, 24 December 2016 23:25 Go to next message
Ken Keefe is currently offline Ken KeefeFriend
Messages: 31
Registered: April 2012
What is the preferred way to get the application or highest-level context in order to insert an object? Right now, I do this:

	public Object execute(MApplication application, @Named(IServiceConstants.ACTIVE_SHELL) Shell shell, EModelService modelService, @Named(IServiceConstants.ACTIVE_SELECTION) ISelection sel, IEclipseContext context) {
		if (sel instanceof TreeSelection) {
			TreeSelection ts = (TreeSelection) sel;
			Object pObj = ts.getFirstElement();
			if(pObj instanceof Project) {
				IEclipseContext c = context.getParent().getParent().getParent().getParent();
				c.set(Project.class, (Project) pObj);

But that is very hackish since I don't know for sure that whenever this code gets called it will take 4 "getParent()" calls to get to the root. It would be nice if there was a getRoot() method.
Re: Inserting an object into the application context [message #1750681 is a reply to message #1750678] Sun, 25 December 2016 07:15 Go to previous message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2786
Registered: July 2012
Senior Member
Why not simply calling
Previous Topic:How to improve RCP applications startup time?
Next Topic:Close button disappears from Editors after migrating workspace from Eclipse 3 to 4
Goto Forum:

Current Time: Thu Sep 24 09:33:28 GMT 2020

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

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

Back to the top