Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse 4 » How to make the contacts demo more dynamic?
How to make the contacts demo more dynamic? [message #660576] Sat, 19 March 2011 15:31 Go to next message
Karl Weber is currently offline Karl WeberFriend
Messages: 63
Registered: September 2010
Member
The contact demo is very static in the sense that it has only one details view. Suppose one would like to make it more dynamic such that one click in the list view would

  • open an additional details view for the selected contact if a new contact is selected in the list view
  • set the focus on the appropriate details view if the selection on the list view is changed to a contact, for which a details view has been opened before

Furthermore, it should be possible to delete a details view. To summarize, the part stack for the details should behave like the editor area of the eclipse sdk.

How should one implement this? Should on create one MPart dynamically for every details view?

If yes, how should one delete this MPart? If I delete the details view in the demo (by clicking on the x in the folder of the GUI), an exception is thrown, the MPart is still part of the model, but it does no longer have an associated widget.

How does one have to create a separate context for every MPart, in order to add an "IEditorInput" to this context?

Will this context automatically be destroyed with the MPart?
Re: How to make the contacts demo more dynamic? [message #660605 is a reply to message #660576] Sat, 19 March 2011 21:09 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
Am 19.03.11 08:31, schrieb Karl Weber:
> The contact demo is very static in the sense that it has only one
> details view. Suppose one would like to make it more dynamic such that
> one click in the list view would
>
> open an additional details view for the selected contact if a new
> contact is selected in the list view
> set the focus on the appropriate details view if the selection on the
> list view is changed to a contact, for which a details view has been
> opened before
>
> Furthermore, it should be possible to delete a details view. To
> summarize, the part stack for the details should behave like the editor
> area of the eclipse sdk.
>
> How should one implement this? Should on create one MPart dynamically
> for every details view?

You'd use a MPartDescriptor and then use the EPartService to create
MPart-Instances from it.

>
> If yes, how should one delete this MPart? If I delete the details view
> in the demo (by clicking on the x in the folder of the GUI), an
> exception is thrown, the MPart is still part of the model, but it does
> no longer have an associated widget.

The exception is coming from the custom code which tries to disable a
widget already disposed.

>
> How does one have to create a separate context for every MPart, in order
> to add an "IEditorInput" to this context?

The framework (in this case the rendering engine) creates the
IEclipseContext for all MParts. The current code is getting the current
selection injected and I think that this might be the correct thing for
your example as well the only difference would be that you use
Constructor Injection whereas now Method Injection is used.

>
> Will this context automatically be destroyed with the MPart?

Yes, the rendering engine creates a child-context and when the element
is removed this very context is destroyed.

Tom
Re: How to make the contacts demo more dynamic? [message #661753 is a reply to message #660605] Sun, 27 March 2011 10:43 Go to previous messageGo to next message
Karl Weber is currently offline Karl WeberFriend
Messages: 63
Registered: September 2010
Member
Hi Tom, thanks for your Help!

Tom Schindl wrote on Sat, 19 March 2011 22:09
Am 19.03.11 08:31, schrieb Karl Weber:
> The contact demo is very static in the sense that it has only one
> details view. Suppose one would like to make it more dynamic such that
> one click in the list view would
>
> open an additional details view for the selected contact if a new
> contact is selected in the list view
> set the focus on the appropriate details view if the selection on the
> list view is changed to a contact, for which a details view has been
> opened before
>
> Furthermore, it should be possible to delete a details view. To
> summarize, the part stack for the details should behave like the editor
> area of the eclipse sdk.
>
> How should one implement this? Should on create one MPart dynamically
> for every details view?

You'd use a MPartDescriptor and then use the EPartService to create
MPart-Instances from it.


I managed to define an MPartDescriptor in a fragment and open a corresponding MPart in a Part Stack of the application. So far, so good.

Now I have two further problems:

[1] I cannot open more than one MPart for the given MPartDescriptor. I need to open more than one. In the MPartDescriptor I have set allowMultiple=true. I thought, this would allow me, to open more than one instance of an MPart.

Edit 1: Somehow this problem disappeared. This leaves no [2].

[2] I need to intercept the creation of the MPart in order to add some object(s) (not strings) to its context before it gets created, so that I can use DI to provide this editor with some particular data. How can I do that? The following approach does not work, since part.getContext() return null.
	@Execute
	public void execute(EPartService partService) {
		if (partService != null) {
			MPart part = partService.createPart("de.gps.log.ui.mtkEditor");
			if (part != null) {
				IEclipseContext ctx = part.getContext();
                                // add something to the ctx here
				partService.showPart(part, PartState.ACTIVATE);
			}
		}
	}

Edit 2: Seems I was a little hasty... The second problem seems to have disappeared as well: The solution described here http://www.eclipse.org/forums/index.php?t=msg&&th=16 1887&goto=511703 works.

[Updated on: Sun, 27 March 2011 13:44]

Report message to a moderator

Re: How to make the contacts demo more dynamic? [message #661765 is a reply to message #661753] Sun, 27 March 2011 16:42 Go to previous message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
Am 27.03.11 03:43, schrieb Karl Weber:
> Hi Tom, thanks for your Help!
>
> Tom Schindl wrote on Sat, 19 March 2011 22:09
>> Am 19.03.11 08:31, schrieb Karl Weber:
>> > The contact demo is very static in the sense that it has only one
>> > details view. Suppose one would like to make it more dynamic such that
>> > one click in the list view would
>> > > open an additional details view for the selected contact if a new
>> > contact is selected in the list view
>> > set the focus on the appropriate details view if the selection on the
>> > list view is changed to a contact, for which a details view has been
>> > opened before
>> > > Furthermore, it should be possible to delete a details view. To
>> > summarize, the part stack for the details should behave like the editor
>> > area of the eclipse sdk.
>> > > How should one implement this? Should on create one MPart dynamically
>> > for every details view?
>>
>> You'd use a MPartDescriptor and then use the EPartService to create
>> MPart-Instances from it.
>
>
> I managed to define an MPartDescriptor in a fragment and open a
> corresponding MPart in a Part Stack of the application. So far, so good.
> Now I have two further problems:
>
> [1] I cannot open more than one MPart for the given MPartDescriptor. I
> need to open more than one. In the MPartDescriptor I have set
> allowMultiple=true. I thought, this would allow me, to open more than
> one Instance of an MPart.
>

Not sure about this one and I'm just on holiday after EclipseCon so I'm
not able to take a look but maybe you hit a bug. So if noone else
responds in the next days I'd say you should file a bug.

> [2] I need to intercept the creation of the MPart in order to add some
> Object(s) to its context before it gets created, so that I can use DI to
> provide this editor with some particular data. How can I do that? The
> following approach does not work, since part.getContext() return null.
>
> @Execute
> public void execute(EPartService partService) {
> if (partService != null) {
> MPart part = partService.createPart("de.gps.log.ui.mtkEditor");
> if (part != null) {
> IEclipseContext ctx = part.getContext();
> // add something to the ctx here
> partService.showPart(part, PartState.ACTIVATE);
> }
> }
> }
>
>
>

The part has no context until it gets rendered so that's why you get
null! You can always register an IContextFunctions using DS. You can
take a look at my model-tooling it does such a thing e.g. in
org.eclipse.e4.tools.emf.editor3x/OSGI-INF/xmiresourcecontex tfunction.xml.

Tom
Previous Topic:Splash progress bar
Next Topic:Some questions about savable parts
Goto Forum:
  


Current Time: Fri Apr 19 16:22:50 GMT 2024

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

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

Back to the top