Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Show a list of child elements in property view
Show a list of child elements in property view [message #637027] Wed, 03 November 2010 20:29 Go to next message
Michael is currently offline MichaelFriend
Messages: 3
Registered: November 2010
Junior Member
Hi!

I have a object of type "Parameter" which contains a list of objects of type "Value".

Now, if I click on the parameter object, the properties of this object are shown in the property view. What I want now is to show the whole list with the value objects in the parameter property sheet too.

I tried different things, but doesn't get the wished result.

For a better understanding, it should look like this:

Parameter contains a "name" and the list of "Value"

Value contains a description and a value

What I want now is the following picture:

Property | Value (Header of PropertyView)
Name | xyz
+ Values
| + - Value v1 |
. | - - description | xyz
. | - - value | 1.0
| + - Value v2 |
. | - - description | xyz
. | - - value | 3

The name property of the parameter could also be in the "Misc" category.

I hope it is understandable what I mean.

How I can get this result?

Regards,

Michael

Re: Show a list of child elements in property view [message #637111 is a reply to message #637027] Thu, 04 November 2010 08:57 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 30550
Registered: July 2009
Senior Member
Michael,

Have a look at what TreeNodeItemProvider and MappingItemProvider do.


Michael wrote:
> Hi!
>
> I have a object of type "Parameter" which contains a list of objects
> of type "Value".
>
> Now, if I click on the parameter object, the properties of this object
> are shown in the property view. What I want now is to show the whole
> list with the value objects in the parameter property sheet too.
>
> I tried different things, but doesn't get the wished result.
>
> For a better understanding, it should look like this:
>
> Parameter contains a "name" and the list of "Value"
>
> Value contains a description and a value
>
> What I want now is the following picture:
>
> Property | Value (Header of PropertyView)
> Name | xyz
> + Values
> | + - Value v1 | | - - description | xyz
> | - - value | 1.0
> | + - Value v2 | | - - description | xyz
> | - - value | 3
>
> The name property of the parameter could also be in the "Misc" category.
> I hope it is understandable what I mean.
>
> How I can get this result?
>
> Regards,
>
> Michael
>
>
Re: Show a list of child elements in property view [message #637311 is a reply to message #637111] Fri, 05 November 2010 01:25 Go to previous messageGo to next message
Michael is currently offline MichaelFriend
Messages: 3
Registered: November 2010
Junior Member
Hello Mr. Merks,

first of all thank you for the quick help.

I tried it similar to the two examples you gave me. This is what I have done:

public List<IItemPropertyDescriptor> getPropertyDescriptors(Object object) {
		if (itemPropertyDescriptors == null) {

			super.getPropertyDescriptors(object);

			Parameter para = (Parameter) object;
			EList<Value> values = para.getValues();

			for (Value value : values) {
				for (IItemPropertyDescriptor itemPropertyDescriptor : itemDelegator.getPropertyDescriptors(value)) {

					itemPropertyDescriptors.add(new ItemPropertyDescriptorDecorator(value, itemPropertyDescriptor) {

						@Override
						public String getCategory(Object thisObject) {
							return "Value " + ((Value) object).getName();
						}

					});

				}
			}

		}

		return itemPropertyDescriptors;
	}


Now three problems still remaining.

1. The property values (getPropertyValue) of all values are from the same value object. They are all from the first value in the values list. I don't understand why? Because the decorater gets the correct value during the instantiation.

2. Parameter and Value extend both the class Element and Element has the field "name". So the generated ElementItemProvider adds the ItemPropertyDescriptor for the name property. Now I have the problem that the name of all values is the name of the parameter. Is there a simple way to handle this?

3. If I click on the Parameter, I get almost the structure which I described in my first post. But when I click on a other object type in my navigator tree, so that the properties view changes and click now back on the parameter, the structure is destroyed. Now all Value properties are in one category together with the name of the parameter object.

I have the assumption, that all problems have the same source.

I hope I was precisely enough with my description.

Regards,

Michael

PS: Sorry for my very bad english, I hope you understand what I mean.
Re: Show a list of child elements in property view [message #637334 is a reply to message #637311] Fri, 05 November 2010 06:28 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 30550
Registered: July 2009
Senior Member
Michael,

Comments below.

Michael wrote:
> Hello Mr. Merks,
>
> first of all thank you for the quick help.
> I tried it similar to the two examples you gave me. This is what I
> have done:
>
>
> public List<IItemPropertyDescriptor> getPropertyDescriptors(Object
> object) {
> if (itemPropertyDescriptors == null) {
>
> super.getPropertyDescriptors(object);
You're still caching them. Think about what happens for different
instances of the object though. Each one will need its own set of
descriptors so either you need to stop using singletons or you need to
recompute the set of descriptors each time.
>
> Parameter para = (Parameter) object;
> EList<Value> values = para.getValues();
>
> for (Value value : values) {
> for (IItemPropertyDescriptor itemPropertyDescriptor :
> itemDelegator.getPropertyDescriptors(value)) {
>
> itemPropertyDescriptors.add(new
> ItemPropertyDescriptorDecorator(value, itemPropertyDescriptor) {
>
> @Override
> public String getCategory(Object thisObject) {
> return "Value " + ((Value) object).getName();
> }
>
> });
>
> }
> }
>
> }
>
> return itemPropertyDescriptors;
> }
>
>
> Now three problems still remaining.
>
> 1. The property values (getPropertyValue) of all values are from the
> same value object. They are all from the first value in the values
> list. I don't understand why? Because the decorater gets the correct
> value during the instantiation.
It's not obvious why, but a few breakpoints should help. Is this
another issue with singletons verses stateful adapters?
>
> 2. Parameter and Value extend both the class Element and Element has
> the field "name". So the generated ElementItemProvider adds the
> ItemPropertyDescriptor for the name property. Now I have the problem
> that the name of all values is the name of the parameter. Is there a
> simple way to handle this?
The names of the properties must be unique so you'll have to do
something to make it unique.
>
> 3. If I click on the Parameter, I get almost the structure which I
> described in my first post. But when I click on a other object type in
> my navigator tree, so that the properties view changes and click now
> back on the parameter, the structure is destroyed. Now all Value
> properties are in one category together with the name of the parameter
> object.
There are definitely issues with not caching or changing to be stateful.
>
> I have the assumption, that all problems have the same source.
>
> I hope I was precisely enough with my description.
>
> Regards,
>
> Michael
>
> PS: Sorry for my very bad english, I hope you understand what I mean.
Previous Topic:IMP integration/bridge to EMF
Next Topic:Multiple EMF models in one TreeViewer
Goto Forum:
  


Current Time: Wed Oct 16 21:37:15 GMT 2019

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

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

Back to the top