Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Create ItemPropertyDescriptor for editing Map
Create ItemPropertyDescriptor for editing Map [message #912959] Fri, 14 September 2012 09:36 Go to next message
John M. is currently offline John M.
Messages: 198
Registered: July 2010
Senior Member
Hello,

is there any possibility to create an ItemPropertyDescriptor for a map, which values are shown up with a table?

[Updated on: Fri, 21 September 2012 06:52]

Report message to a moderator

Re: Create ItemPropertyDescriptor with table [message #912972 is a reply to message #912959] Fri, 14 September 2012 09:57 Go to previous messageGo to next message
Ed Merks is currently offline Ed Merks
Messages: 25999
Registered: July 2009
Senior Member
<html>
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
You mean like this, which someone else just asked about:<br>
<blockquote><a class="moz-txt-link-freetext" href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=220843#c3">https://bugs.eclipse.org/bugs/show_bug.cgi?id=220843#c3</a><br>
</blockquote>
Somehow this "Missing name Mising name" thing is annoying.  Don't
you have a name?<br>
<br>
<div class="moz-cite-prefix">On 14/09/2012 3:36 PM, Missing name
Mising name wrote:<br>
</div>
<blockquote cite="mid:k2vbt6$j9v$1@xxxxxxxxe.org" type="cite">Hello,
<br>
<br>
is there any possibility to create an ItemPropertyDescriptor,
which values are shown up with a table?
<br>
</blockquote>
<br>
</body>
</html>
Re: Create ItemPropertyDescriptor with table [message #912992 is a reply to message #912972] Fri, 14 September 2012 10:53 Go to previous messageGo to next message
John M. is currently offline John M.
Messages: 198
Registered: July 2010
Senior Member
> You mean like this, which someone else just asked about: https://bugs.eclipse.org/bugs/show_bug.cgi?id=220843#c3
I can't find anything, which is related to my question.
I mean I want to select an object in the editor. The object contains for example a list, which shall be shown as a extra table in the property sheet.

Uhm ... I never really noticed it. I will check it soon.
Re: Create ItemPropertyDescriptor with table [message #912998 is a reply to message #912992] Fri, 14 September 2012 11:05 Go to previous messageGo to next message
Ed Merks is currently offline Ed Merks
Messages: 25999
Registered: July 2009
Senior Member
Sorry, but I won't answer questions coming from "Missing name Mising
name" for at least a week.

On 14/09/2012 4:53 PM, Missing name Mising name wrote:
>> You mean like this, which someone else just asked about:
>> https://bugs.eclipse.org/bugs/show_bug.cgi?id=220843#c3
> I can't find anything, which is related to my question.
> I mean I want to select an object in the editor. The object contains
> for example a list, which shall be shown as a extra table in the
> property sheet.
>
> Uhm ... I never really noticed it. I will check it soon.
Re: Create ItemPropertyDescriptor with table [message #918741 is a reply to message #912998] Fri, 21 September 2012 05:46 Go to previous messageGo to next message
John M. is currently offline John M.
Messages: 198
Registered: July 2010
Senior Member
> You mean like this, which someone else just asked about: https://bugs.eclipse.org/bugs/show_bug.cgi?id=220843#c3
I can't find anything, which is related to my question.
I mean I want to select an object in the editor. The object contains for example a list, which shall be shown as a extra table in the property sheet.
Re: Create ItemPropertyDescriptor with table [message #918752 is a reply to message #918741] Fri, 21 September 2012 05:59 Go to previous messageGo to next message
Ed Merks is currently offline Ed Merks
Messages: 25999
Registered: July 2009
Senior Member
I don't know what "an extra table in the property sheet" means.

On 21/09/2012 11:46 AM, John M. wrote:
>> You mean like this, which someone else just asked about:
>> https://bugs.eclipse.org/bugs/show_bug.cgi?id=220843#c3
> I can't find anything, which is related to my question.
> I mean I want to select an object in the editor. The object contains
> for example a list, which shall be shown as a extra table in the
> property sheet.
Re: Create ItemPropertyDescriptor with table [message #918791 is a reply to message #918752] Fri, 21 September 2012 06:50 Go to previous messageGo to next message
John M. is currently offline John M.
Messages: 198
Registered: July 2010
Senior Member
I mean something like a category. You open the category and all keys and values of the map are listed.
I think a specialized ItemPropertyDescriptor could help. If I implement some tree interface, but I am not sure.
Re: Create ItemPropertyDescriptor with table [message #918868 is a reply to message #918791] Fri, 21 September 2012 08:25 Go to previous messageGo to next message
Ed Merks is currently offline Ed Merks
Messages: 25999
Registered: July 2009
Senior Member
John,

You can have a look at
org.eclipse.emf.codegen.ecore.genmodel.provider.GenBaseItemProvider.GenItemPropertyDescriptor.
It's used to create a wrapper object that in turn can act as a property
source of nested properties. If you look in the Generator's properties
view for Ecore properties, e.g., GenPackage's Ecore Package property,
that's what results in there being a "+" that can be expanded to show
the properties of the decorated Ecore model. With this type of
approach, you can have properties that are expandable to show nested
content.


On 21/09/2012 12:50 PM, John M. wrote:
> I mean something like a category. You open the category and all keys
> and values of the map are listed.
> I think a specialized ItemPropertyDescriptor could help. If I
> implement some tree interface, but I am not sure.
Re: Create ItemPropertyDescriptor with table [message #921615 is a reply to message #918868] Mon, 24 September 2012 05:24 Go to previous messageGo to next message
John M. is currently offline John M.
Messages: 198
Registered: July 2010
Senior Member
Thanks so far. Using the right literal and overwriting the method createPropertyValueWrapper in my own ItemPropertyDescriptor works for the first step:

@Override
protected Object createPropertyValueWrapper(Object object, Object propertyValue) {
	if (object instanceof CommandImpl) {
		return new PropertyValueWrapper(adapterFactory, object,
				((CommandImpl) object).getCommandData().getValues(), ((CommandImpl) object).getCommandData()
						.getValues());
	} else {
		return super.createPropertyValueWrapper(object, propertyValue);
	}
}


Now I want to show them in a table form with direct edit instead of a comma seperated field with extra dialog.
Re: Create ItemPropertyDescriptor with table [message #921627 is a reply to message #921615] Mon, 24 September 2012 05:34 Go to previous messageGo to next message
Ed Merks is currently offline Ed Merks
Messages: 25999
Registered: July 2009
Senior Member
John,

Comments below.

On 24/09/2012 11:24 AM, John M. wrote:
> Thanks so far. Using the right literal and overwriting the method
> createPropertyValueWrapper in my own ItemPropertyDescriptor works for
> the first step:
>
> @Override
> protected Object createPropertyValueWrapper(Object object, Object
> propertyValue) {
> if (object instanceof CommandImpl) {
You can't seem to resist using the implementation classes instead of the
API...
> return new PropertyValueWrapper(adapterFactory, object,
> ((CommandImpl) object).getCommandData().getValues(),
> ((CommandImpl) object).getCommandData()
> .getValues());
You'll want to specialize this wrapper so that when it's asked for
property descriptors you produce a list for the property items you want
to have appear as children.
> } else {
> return super.createPropertyValueWrapper(object, propertyValue);
> }
> }
>
> Now I want to show them in a table form with direct edit instead of a
> comma seperated field with extra dialog.
Re: Create ItemPropertyDescriptor with table [message #922806 is a reply to message #921627] Tue, 25 September 2012 07:00 Go to previous messageGo to next message
John M. is currently offline John M.
Messages: 198
Registered: July 2010
Senior Member
> You'll want to specialize this wrapper so that when it's asked for
> property descriptors you produce a list for the property items you want
> to have appear as children.
I want to use my own IItemPropertySource, but the object is an EcoreEMap and I don't know how to combine that.
Or just simply overwrite getPropertyDescriptors?
Re: Create ItemPropertyDescriptor with table [message #922888 is a reply to message #922806] Tue, 25 September 2012 08:31 Go to previous messageGo to next message
Ed Merks is currently offline Ed Merks
Messages: 25999
Registered: July 2009
Senior Member
Try it.

On 25/09/2012 1:00 PM, John M. wrote:
>> You'll want to specialize this wrapper so that when it's asked for
>> property descriptors you produce a list for the property items you want
>> to have appear as children.
> I want to use my own IItemPropertySource, but the object is an
> EcoreEMap and I don't know how to combine that.
> Or just simply overwrite getPropertyDescriptors?
Re: Create ItemPropertyDescriptor with table [message #925271 is a reply to message #922888] Thu, 27 September 2012 10:58 Go to previous messageGo to next message
John M. is currently offline John M.
Messages: 198
Registered: July 2010
Senior Member
Thanks so far. I have understood the system of the descriptor, but there is one question open.
Is there any possibility to create an ItemPropertyDescriptor pointing on a special entry in a map?
The system using the EStructuralFeature, but for a special entry there is no.

I don't hope the only way is to implement IItemPropertyDescriptor on my own.
Re: Create ItemPropertyDescriptor with table [message #925402 is a reply to message #925271] Thu, 27 September 2012 13:28 Go to previous messageGo to next message
Ed Merks is currently offline Ed Merks
Messages: 25999
Registered: July 2009
Senior Member
John,

Comments below.

On 27/09/2012 4:58 PM, John M. wrote:
> Thanks so far. I have understood the system of the descriptor, but
> there is one question open.
> Is there any possibility to create an ItemPropertyDescriptor pointing
> on a special entry in a map?
Not sure what that means.
> The system using the EStructuralFeature, but for a special entry there
> is no.
If it's not modeled then you need to implement the APIs some other way.
>
> I don't hope the only way is to implement IItemPropertyDescriptor on
> my own.
Re: Create ItemPropertyDescriptor with table [message #930519 is a reply to message #925402] Tue, 02 October 2012 07:47 Go to previous messageGo to next message
John M. is currently offline John M.
Messages: 198
Registered: July 2010
Senior Member
I mean I want to see the entrys of a map in a list, which appears when I expand the parent element.
That is the first step. Smile
Re: Create ItemPropertyDescriptor with table [message #945982 is a reply to message #930519] Mon, 15 October 2012 16:52 Go to previous messageGo to next message
John M. is currently offline John M.
Messages: 198
Registered: July 2010
Senior Member
Got it running. Here is my implementation:

public class MapEntryItemPropertyDescriptor extends ItemPropertyDescriptor {
	public MapEntryItemPropertyDescriptor(AdapterFactory adapterFactory, String displayName, String description,
			EStructuralFeature feature) {
		super(adapterFactory, displayName, description, feature);
	}

	public MapEntryItemPropertyDescriptor(AdapterFactory adapterFactory, ResourceLocator resourceLocator,
			String displayName, String description, EStructuralFeature feature, boolean isSettable, boolean multiLine,
			boolean sortChoices, Object staticImage, String category, String[] filterFlags) {
		super(adapterFactory, resourceLocator, displayName, description, feature, isSettable, multiLine, sortChoices,
				staticImage, category, filterFlags);
	}

	@Override
	public Object getPropertyValue(Object object) {
		return ((BasicEMap.Entry<?, ?>) ((EObject) object).eContainer()).getKey();
	}

	@Override
	public void setPropertyValue(Object object, Object value) {
		super.setPropertyValue(((EObject) object).eContainer(), value);
	}
}
Re: Create ItemPropertyDescriptor with table [message #945993 is a reply to message #945982] Mon, 15 October 2012 17:06 Go to previous messageGo to next message
John M. is currently offline John M.
Messages: 198
Registered: July 2010
Senior Member
My only problem is the refreshing of the child element. The child uses the key as label element.
I tried to change the labelUpdate argument of the ViewerNotification in method notifyChanged to true. But it seems it doesn't change anything.

In the editor I have to run manual refresh and the value is shown. What did I forgot?
Re: Create ItemPropertyDescriptor with table [message #946236 is a reply to message #945993] Mon, 15 October 2012 23:25 Go to previous messageGo to next message
Ed Merks is currently offline Ed Merks
Messages: 25999
Registered: July 2009
Senior Member
John,

The properties view normally updates because the command stack listener
tells it to update.

On 15/10/2012 11:06 PM, John M. wrote:
> My only problem is the refreshing of the child element. The child uses
> the key as label element.
> I tried to change the labelUpdate argument of the ViewerNotification
> in method notifyChanged to true. But it seems it doesn't change anything.
>
> In the editor I have to run manual refresh and the value is shown.
> What did I forgot?
Re: Create ItemPropertyDescriptor for editing Map [message #949280 is a reply to message #912959] Thu, 18 October 2012 17:42 Go to previous messageGo to next message
John M. is currently offline John M.
Messages: 198
Registered: July 2010
Senior Member
Adding a CommandStackListener to the CommandStack and firing the event PROP_INPUT solved the problem.
Is there any possibility to find out, who created the change?
In my case for example the property page. So I only fire the event if there is really a change from propery page and not in the editor itself to prevent firing to much events.
Re: Create ItemPropertyDescriptor for editing Map [message #949615 is a reply to message #949280] Fri, 19 October 2012 01:52 Go to previous messageGo to next message
Ed Merks is currently offline Ed Merks
Messages: 25999
Registered: July 2009
Senior Member
John,

Comments below.

On 18/10/2012 11:42 PM, John M. wrote:
> Adding a CommandStackListener to the CommandStack and firing the event
> PROP_INPUT solved the problem.
> Is there any possibility to find out, who created the change?
No.
> In my case for example the property page. So I only fire the event if
> there is really a change from propery page and not in the editor
> itself to prevent firing to much events.
How can you know whether some arbitrary change affects the value of a
property?
Re: Create ItemPropertyDescriptor for editing Map [message #950041 is a reply to message #912959] Fri, 19 October 2012 11:16 Go to previous messageGo to next message
John M. is currently offline John M.
Messages: 198
Registered: July 2010
Senior Member
>> In my case for example the property page. So I only fire the event if
>> there is really a change from propery page and not in the editor
>> itself to prevent firing to much events.
> How can you know whether some arbitrary change affects the value of a
> property?
I can't know that I think.
I want to prevent if I change for example something with the editor, that my listener is activated and firing an event. Because there is already an integrated one and I don't want to fire multiple events for the same change.
Only if I make a change with the property sheet the listener shall be activated.
Re: Create ItemPropertyDescriptor for editing Map [message #950064 is a reply to message #950041] Fri, 19 October 2012 11:50 Go to previous message
Ed Merks is currently offline Ed Merks
Messages: 25999
Registered: July 2009
Senior Member
John,

There's no way to know where the command came from.

On 19/10/2012 5:16 PM, John M. wrote:
>>> In my case for example the property page. So I only fire the event if
>>> there is really a change from propery page and not in the editor
>>> itself to prevent firing to much events.
>> How can you know whether some arbitrary change affects the value of a
>> property?
> I can't know that I think.
> I want to prevent if I change for example something with the editor,
> that my listener is activated and firing an event. Because there is
> already an integrated one and I don't want to fire multiple events for
> the same change.
> Only if I make a change with the property sheet the listener shall be
> activated.
Previous Topic:isModified() returns true on undo though reverting to saved state
Next Topic:Decoration layer over EMF
Goto Forum:
  


Current Time: Wed Aug 20 22:39:47 EDT 2014

Powered by FUDForum. Page generated in 0.03831 seconds