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: 23
Registered: April 2012
Junior Member
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: 2570
Registered: July 2012
Senior Member
Why not simply calling
Previous Topic:How to improve RCP applications startup time?
Next Topic:How to show E4 sample view generated from wizard?
Goto Forum:

Current Time: Wed Mar 21 20:34:28 GMT 2018

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

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