Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » How to force a node to refresh it's properties view
How to force a node to refresh it's properties view [message #425600] Wed, 03 December 2008 06:31 Go to next message
Asha Ramegowda is currently offline Asha RamegowdaFriend
Messages: 77
Registered: July 2009
Member
Hi,

I have an editor generated for an emf model.
Based on some run time data I am adding some values to an aggregation
reference variable of the element. It will not reflect until, I save the
editor close it and reopen.
I would like to know, how I can force the node to refresh itself, so that
it generates property descriptors for newly added values in the list?

In fact, I am displaying the properties of the list elements, at the
parent node.
So, my problem is, when I add something to the list using the child
descriptors actions, it appears as a child, but the parent node's property
descriptor for the same list would not get refreshed. So, how can I
refresh the parent node?

Thank you,

Asha R.
Re: How to force a node to refresh it's properties view [message #425604 is a reply to message #425600] Wed, 03 December 2008 11:55 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 31152
Registered: July 2009
Senior Member
Asha,

Comments below.

Asha R wrote:
> Hi,
>
> I have an editor generated for an emf model.
> Based on some run time data I am adding some values to an aggregation
> reference variable of the element. It will not reflect until, I save
> the editor close it and reopen.
Where is it not being reflected? Are you making the change using a command?
> I would like to know, how I can force the node to refresh itself, so
> that it generates property descriptors for newly added values in the
> list?
I'm not quite sure why it wouldn't already do this.
>
> In fact, I am displaying the properties of the list elements, at the
> parent node.
> So, my problem is, when I add something to the list using the child
> descriptors actions, it appears as a child,
I'm not following how this is working...
> but the parent node's property descriptor for the same list would not
> get refreshed. So, how can I refresh the parent node?
If you are using a property descriptor to make the change how is it that
the list of property descriptors is affected by this?

Are you making sure the list of property descriptors is recomputed each
time? By default it's computed once and cached, but in your case, each
instance can have a different list, so you need to ensure it's being
recomputed.
>
> Thank you,
>
> Asha R.
>
Re: How to force a node to refresh it's properties view [message #425631 is a reply to message #425604] Wed, 03 December 2008 14:28 Go to previous messageGo to next message
Asha Ramegowda is currently offline Asha RamegowdaFriend
Messages: 77
Registered: July 2009
Member
Hi Ed,

Thanks for the reply.

I have seen the MappingItemProvider and implemented the properties of a
list to appear as if they are properties of it's parent node.

I mean if I have a Device, which has a list of Property, each of the
property in the list should appear as the property of the parent node.
Everything is same as the MappingItemProvider logic.
Like it displays each property listing with uniquie count like,
+ 1. Property
+ 2. Property
<my attributes for class>
etc.

This works only when I read all the properties initially into the Device
class.
If I add them dynamically it wont reflect until I close and re open the
editor.

I mean to test this, )earlier I blocked the collection of child
descriptors), I collected the child descriptors and tried to add the
Property instances in to the list. When, I add, and go back to the parent
node, it will not reflect the new property added, with a count and
expandable tree.

So, I have to close the editor and re open it.

So far have not tried commands to create this new properties.
But, I guess once I add them through command it should work.
But, when I am using child actions, they also fire commands you know, why
they are not working?

Sorry, if I am unable to put my problem properly, if you are not
understanding... :-).

Thank you,

Asha R.

Please find my comments below.


Ed Merks wrote:

> Asha,

> Comments below.

> Asha R wrote:
>> Hi,
>>
>> I have an editor generated for an emf model.
>> Based on some run time data I am adding some values to an aggregation
>> reference variable of the element. It will not reflect until, I save
>> the editor close it and reopen.
> Where is it not being reflected? Are you making the change using a command?
>> I would like to know, how I can force the node to refresh itself, so
>> that it generates property descriptors for newly added values in the
>> list?
> I'm not quite sure why it wouldn't already do this.
>>
>> In fact, I am displaying the properties of the list elements, at the
>> parent node.
>> So, my problem is, when I add something to the list using the child
>> descriptors actions, it appears as a child,
> I'm not following how this is working...
>> but the parent node's property descriptor for the same list would not
>> get refreshed. So, how can I refresh the parent node?
> If you are using a property descriptor to make the change how is it that
> the list of property descriptors is affected by this?

> Are you making sure the list of property descriptors is recomputed each
> time? By default it's computed once and cached, but in your case, each
> instance can have a different list, so you need to ensure it's being
> recomputed.
>>
>> Thank you,
>>
>> Asha R.
>>
Re: How to force a node to refresh it's properties view [message #425635 is a reply to message #425631] Wed, 03 December 2008 14:49 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 31152
Registered: July 2009
Senior Member
Asha,

Comments below.


Asha R wrote:
> Hi Ed,
>
> Thanks for the reply.
Goodness knows how I can ever get anything else done...
>
> I have seen the MappingItemProvider and implemented the properties of
> a list to appear as if they are properties of it's parent node.
>
> I mean if I have a Device, which has a list of Property, each of the
> property in the list should appear as the property of the parent node.
> Everything is same as the MappingItemProvider logic.
> Like it displays each property listing with uniquie count like,
> + 1. Property
> + 2. Property
> <my attributes for class>
> etc.
>
> This works only when I read all the properties initially into the
> Device class.
> If I add them dynamically it wont reflect until I close and re open
> the editor.
I gather that. Can you show what your getPropertyDescriptors method
looks like?
>
> I mean to test this, )earlier I blocked the collection of child
> descriptors), I collected the child descriptors and tried to add the
> Property instances in to the list. When, I add, and go back to the
> parent node, it will not reflect the new property added, with a count
> and expandable tree.
I though you needed to add an actual Property to the Device object and
normally doing that will be reflected in the tree view. Then the item
provider just creates property descriptors to wrap those Property instances.
>
> So, I have to close the editor and re open it.
>
> So far have not tried commands to create this new properties.
Without commands, things won't work so well. Specifically, when you
execute a command, the properties view will be refreshed, and that's
exactly what's not happening.
> But, I guess once I add them through command it should work.
yep.
> But, when I am using child actions, they also fire commands you know,
> why they are not working?
Not so clear what's not working. I suspect it's because your caching
the list of property descriptors, as I mentioned, but now I'm asking to
see the code so that I'll be sure the question is answered.
>
> Sorry, if I am unable to put my problem properly, if you are not
> understanding... :-).
>
> Thank you,
>
> Asha R.
>
> Please find my comments below.
>
>
> Ed Merks wrote:
>
>> Asha,
>
>> Comments below.
>
>> Asha R wrote:
>>> Hi,
>>>
>>> I have an editor generated for an emf model.
>>> Based on some run time data I am adding some values to an
>>> aggregation reference variable of the element. It will not reflect
>>> until, I save the editor close it and reopen.
>> Where is it not being reflected? Are you making the change using a
>> command?
>>> I would like to know, how I can force the node to refresh itself, so
>>> that it generates property descriptors for newly added values in the
>>> list?
>> I'm not quite sure why it wouldn't already do this.
>>>
>>> In fact, I am displaying the properties of the list elements, at the
>>> parent node.
>>> So, my problem is, when I add something to the list using the child
>>> descriptors actions, it appears as a child,
>> I'm not following how this is working...
>>> but the parent node's property descriptor for the same list would
>>> not get refreshed. So, how can I refresh the parent node?
>> If you are using a property descriptor to make the change how is it
>> that the list of property descriptors is affected by this?
>
>> Are you making sure the list of property descriptors is recomputed
>> each time? By default it's computed once and cached, but in your
>> case, each instance can have a different list, so you need to ensure
>> it's being recomputed.
>>>
>>> Thank you,
>>>
>>> Asha R.
>>>
>
>
Re: How to force a node to refresh it's properties view [message #425637 is a reply to message #425635] Wed, 03 December 2008 15:21 Go to previous messageGo to next message
Asha Ramegowda is currently offline Asha RamegowdaFriend
Messages: 77
Registered: July 2009
Member
Hi Ed,

Thanks for the reply again. :-).
Please see my comments below.

Ed Merks wrote:

> Asha,

> Comments below.


> Asha R wrote:
>> Hi Ed,
>>
>> Thanks for the reply.
> Goodness knows how I can ever get anything else done...

I am Indian and my mother tongue is not English. So I don't know what you
mean by this and I don't know such good English. :)). So, I am not getting
what you said. I hope you are not sarcastic :)).
I am not even getting whether you complimented me or what :)))!
I am really confused, probably because of this so called dynamic
properties. :)). Sorry, if I am assuming something wrong. But, I really
feel bad for taking help from you all the time.

>>
>> I have seen the MappingItemProvider and implemented the properties of
>> a list to appear as if they are properties of it's parent node.
>>
>> I mean if I have a Device, which has a list of Property, each of the
>> property in the list should appear as the property of the parent node.
>> Everything is same as the MappingItemProvider logic.
>> Like it displays each property listing with uniquie count like,
>> + 1. Property
>> + 2. Property
>> <my attributes for class>
>> etc.
>>
>> This works only when I read all the properties initially into the
>> Device class.
>> If I add them dynamically it wont reflect until I close and re open
>> the editor.
> I gather that. Can you show what your getPropertyDescriptors method
> looks like?

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

addDeviceNamePropertyDescriptor(object);

Device theDevice = (Device)object;
HdfPackage ePackage = HdfPackage.eINSTANCE;
boolean hasProperties = (theDevice.getDeviceProperties().size() > 0);

if (hasProperties)
{
int count = 1;
for (final Property childProperty :
theDevice.getDeviceProperties())
{
IItemPropertyDescriptor childPropertyItemPropertyDescriptor =
new
ItemPropertyDescriptor(((ComposeableAdapterFactory)adapterFa ctory).getRootAdapterFactory(),
getResourceLocator(),
//Can be replaced with a proper string from plugin.properties
//Count is used to generate the unique names
count + " ." + " Device Property",
"Proper combination of plugin.properties will appear here",
HdfPackage.Literals.DEVICE__DEVICE_PROPERTIES, //name of the
list we want to handle
true,
false,
false,
ItemPropertyDescriptor.GENERIC_VALUE_IMAGE,
null,
null);

itemPropertyDescriptors.add
(new ItemPropertyDescriptorDecorator(childProperty,
childPropertyItemPropertyDescriptor)
{
@Override
public Object getPropertyValue(Object o)
{
super.getPropertyValue(o);
return this.object;
}
@Override
public Collection<?> getChoiceOfValues(Object o)
{
return null;
}
});
++count;
}
}
}
return itemPropertyDescriptors;
}

Probably you don't need following files, but still, I am posting them here.
-------------------------------------
This is my ecore model
-------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<ecore:EPackage xmi:version="2.0"
xmlns:xmi="http://www.omg.org/XMI"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="hdf"
nsURI="http://www.example.org/hd" nsPrefix="hd">
<eClassifiers xsi:type="ecore:EClass" name="HardwareDefinition">
<eStructuralFeatures xsi:type="ecore:EReference" name="devices"
upperBound="-1"
eType="#//Device" containment="true"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="buses"
upperBound="-1"
eType="#//Bus" containment="true"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="Device">
<eStructuralFeatures xsi:type="ecore:EAttribute" name="deviceName"
eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
<eStructuralFeatures xsi:type="ecore:EReference"
name="deviceProperties" upperBound="-1"
eType="#//Property" containment="true"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="Bus">
<eStructuralFeatures xsi:type="ecore:EAttribute" name="busName"
eType="ecore:EDataType
platform:/plugin/org.eclipse.emf.ecore/model/Ecore.ecore#//E String "/>
<eStructuralFeatures xsi:type="ecore:EReference" name="busProperties"
upperBound="-1"
eType="#//Property" containment="true"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="Property">
<eStructuralFeatures xsi:type="ecore:EAttribute" name="name"
eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="value"
eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="enumProperty"
eType="#//HDENUM"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="floatValue"
eType="ecore:EDataType
platform:/plugin/org.eclipse.emf.ecore/model/Ecore.ecore#//E Float "/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EEnum" name="HDENUM">
<eLiterals name="WinXP"/>
<eLiterals name="LINUX"/>
<eLiterals name="UNIX"/>
<eLiterals name="SOLARIS"/>
</eClassifiers>
</ecore:EPackage>
----------------------------------------------------------
And I have generated the code setting the item providers to be stateful.
------------------------------------------------------------ -
This is my genmodel
-------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<genmodel:GenModel xmi:version="2.0"
xmlns:xmi="http://www.omg.org/XMI"
xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore"
xmlns:genmodel="http://www.eclipse.org/emf/2002/GenModel"
modelDirectory="/sample/src"
modelPluginID="sample" modelName="Sample"
importerID="org.eclipse.emf.importer.ecore"
complianceLevel="5.0" copyrightFields="false"
usedGenPackages=" platform:/plugin/org.eclipse.emf.ecore/model/Ecore.genmodel# //ecore ">
<foreignModel>sample.ecore</foreignModel>
<genPackages prefix="Hdf" disposableProviderFactory="true"
ecorePackage="sample.ecore#/">
<genEnums typeSafeEnumCompatible="false"
ecoreEnum="sample.ecore#//HDENUM">
<genEnumLiterals ecoreEnumLiteral="sample.ecore#//HDENUM/WinXP"/>
<genEnumLiterals ecoreEnumLiteral="sample.ecore#//HDENUM/LINUX"/>
<genEnumLiterals ecoreEnumLiteral="sample.ecore#//HDENUM/UNIX"/>
<genEnumLiterals ecoreEnumLiteral="sample.ecore#//HDENUM/SOLARIS"/>
</genEnums>
<genClasses provider="Stateful"
ecoreClass="sample.ecore#//HardwareDefinition">
<genFeatures property="None" children="true" createChild="true"
ecoreFeature="ecore:EReference sample.ecore#//HardwareDefinition/devices"/>
<genFeatures property="None" children="true" createChild="true"
ecoreFeature="ecore:EReference sample.ecore#//HardwareDefinition/buses"/>
</genClasses>
<genClasses provider="Stateful" ecoreClass="sample.ecore#//Device">
<genFeatures createChild="false" ecoreFeature="ecore:EAttribute
sample.ecore#//Device/deviceName"/>
<genFeatures property="None" children="true" createChild="true"
ecoreFeature="ecore:EReference sample.ecore#//Device/deviceProperties"/>
</genClasses>
<genClasses provider="Stateful" ecoreClass="sample.ecore#//Bus">
<genFeatures createChild="false" ecoreFeature="ecore:EAttribute
sample.ecore#//Bus/busName"/>
<genFeatures property="None" children="true" createChild="true"
ecoreFeature="ecore:EReference sample.ecore#//Bus/busProperties"/>
</genClasses>
<genClasses provider="Stateful" ecoreClass="sample.ecore#//Property">
<genFeatures createChild="false" ecoreFeature="ecore:EAttribute
sample.ecore#//Property/name"/>
<genFeatures createChild="false" ecoreFeature="ecore:EAttribute
sample.ecore#//Property/value"/>
<genFeatures createChild="false" ecoreFeature="ecore:EAttribute
sample.ecore#//Property/enumProperty"/>
<genFeatures createChild="false" ecoreFeature="ecore:EAttribute
sample.ecore#//Property/floatValue"/>
</genClasses>
</genPackages>
</genmodel:GenModel>
------------------------------------------------------------ --------
This is just an example as I can't share the real code with you... :-).
But, here you can try adding the child nodes with descriptors and go back
to the parent node and it will not reflect the properties of child node
until and unless you close the editor and open it. So, that's the problem.

>>
>> I mean to test this, )earlier I blocked the collection of child
>> descriptors), I collected the child descriptors and tried to add the
>> Property instances in to the list. When, I add, and go back to the
>> parent node, it will not reflect the new property added, with a count
>> and expandable tree.
> I though you needed to add an actual Property to the Device object and
> normally doing that will be reflected in the tree view. Then the item
> provider just creates property descriptors to wrap those Property instances.
>>
>> So, I have to close the editor and re open it.
>>
>> So far have not tried commands to create this new properties.
> Without commands, things won't work so well. Specifically, when you
> execute a command, the properties view will be refreshed, and that's
> exactly what's not happening.
>> But, I guess once I add them through command it should work.
> yep.
>> But, when I am using child actions, they also fire commands you know,
>> why they are not working?
> Not so clear what's not working. I suspect it's because your caching
> the list of property descriptors, as I mentioned, but now I'm asking to
> see the code so that I'll be sure the question is answered.
>>
>> Sorry, if I am unable to put my problem properly, if you are not
>> understanding... :-).
>>
>> Thank you,
>>
>> Asha R.
>>
>> Please find my comments below.
>>
>>
>> Ed Merks wrote:
>>
>>> Asha,
>>
>>> Comments below.
>>
>>> Asha R wrote:
>>>> Hi,
>>>>
>>>> I have an editor generated for an emf model.
>>>> Based on some run time data I am adding some values to an
>>>> aggregation reference variable of the element. It will not reflect
>>>> until, I save the editor close it and reopen.
>>> Where is it not being reflected? Are you making the change using a
>>> command?
>>>> I would like to know, how I can force the node to refresh itself, so
>>>> that it generates property descriptors for newly added values in the
>>>> list?
>>> I'm not quite sure why it wouldn't already do this.
>>>>
>>>> In fact, I am displaying the properties of the list elements, at the
>>>> parent node.
>>>> So, my problem is, when I add something to the list using the child
>>>> descriptors actions, it appears as a child,
>>> I'm not following how this is working...
>>>> but the parent node's property descriptor for the same list would
>>>> not get refreshed. So, how can I refresh the parent node?
>>> If you are using a property descriptor to make the change how is it
>>> that the list of property descriptors is affected by this?
>>
>>> Are you making sure the list of property descriptors is recomputed
>>> each time? By default it's computed once and cached, but in your
>>> case, each instance can have a different list, so you need to ensure
>>> it's being recomputed.
>>>>
>>>> Thank you,
>>>>
>>>> Asha R.
>>>>
>>
>>
Re: How to force a node to refresh it's properties view [message #425638 is a reply to message #425637] Wed, 03 December 2008 15:25 Go to previous messageGo to next message
Asha Ramegowda is currently offline Asha RamegowdaFriend
Messages: 77
Registered: July 2009
Member
Hi Ed,

Some comments in the code are written for my TL who does not know eclipse
:)). Not for you.
Hope you don't mind for them.

Then, I thanked you because I was really waiting for you reply.
But, not because I wanted you to provide me a solution.

Asha R.

Asha R wrote:

> Hi Ed,

> Thanks for the reply again. :-).
> Please see my comments below.

> Ed Merks wrote:

>> Asha,

>> Comments below.


>> Asha R wrote:
>>> Hi Ed,
>>>
>>> Thanks for the reply.
>> Goodness knows how I can ever get anything else done...

> I am Indian and my mother tongue is not English. So I don't know what you
> mean by this and I don't know such good English. :)). So, I am not getting
> what you said. I hope you are not sarcastic :)).
> I am not even getting whether you complimented me or what :)))!
> I am really confused, probably because of this so called dynamic
> properties. :)). Sorry, if I am assuming something wrong. But, I really
> feel bad for taking help from you all the time.

>>>
>>> I have seen the MappingItemProvider and implemented the properties of
>>> a list to appear as if they are properties of it's parent node.
>>>
>>> I mean if I have a Device, which has a list of Property, each of the
>>> property in the list should appear as the property of the parent node.
>>> Everything is same as the MappingItemProvider logic.
>>> Like it displays each property listing with uniquie count like,
>>> + 1. Property
>>> + 2. Property
>>> <my attributes for class>
>>> etc.
>>>
>>> This works only when I read all the properties initially into the
>>> Device class.
>>> If I add them dynamically it wont reflect until I close and re open
>>> the editor.
>> I gather that. Can you show what your getPropertyDescriptors method
>> looks like?

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

> addDeviceNamePropertyDescriptor(object);

> Device theDevice = (Device)object;
> HdfPackage ePackage = HdfPackage.eINSTANCE;
> boolean hasProperties = (theDevice.getDeviceProperties().size() > 0);

> if (hasProperties)
> {
> int count = 1;
> for (final Property childProperty :
> theDevice.getDeviceProperties())
> {
> IItemPropertyDescriptor childPropertyItemPropertyDescriptor =
> new
>
ItemPropertyDescriptor(((ComposeableAdapterFactory)adapterFa ctory).getRootAdapterFactory(),
> getResourceLocator(),
> //Can be replaced with a proper string from plugin.properties
> //Count is used to generate the unique names
> count + " ." + " Device Property",
> "Proper combination of plugin.properties will appear here",
> HdfPackage.Literals.DEVICE__DEVICE_PROPERTIES, //name of the
> list we want to handle
> true,
> false,
> false,
> ItemPropertyDescriptor.GENERIC_VALUE_IMAGE,
> null,
> null);

> itemPropertyDescriptors.add
> (new ItemPropertyDescriptorDecorator(childProperty,
> childPropertyItemPropertyDescriptor)
> {
> @Override
> public Object getPropertyValue(Object o)
> {
> super.getPropertyValue(o);
> return this.object;
> }
> @Override
> public Collection<?> getChoiceOfValues(Object o)
> {
> return null;
> }
> });
> ++count;
> }
> }
> }
> return itemPropertyDescriptors;
> }

> Probably you don't need following files, but still, I am posting them here.
> -------------------------------------
> This is my ecore model
> -------------------------------------
> <?xml version="1.0" encoding="UTF-8"?>
> <ecore:EPackage xmi:version="2.0"
> xmlns:xmi="http://www.omg.org/XMI"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="hdf"
> nsURI="http://www.example.org/hd" nsPrefix="hd">
> <eClassifiers xsi:type="ecore:EClass" name="HardwareDefinition">
> <eStructuralFeatures xsi:type="ecore:EReference" name="devices"
> upperBound="-1"
> eType="#//Device" containment="true"/>
> <eStructuralFeatures xsi:type="ecore:EReference" name="buses"
> upperBound="-1"
> eType="#//Bus" containment="true"/>
> </eClassifiers>
> <eClassifiers xsi:type="ecore:EClass" name="Device">
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="deviceName"
> eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
> <eStructuralFeatures xsi:type="ecore:EReference"
> name="deviceProperties" upperBound="-1"
> eType="#//Property" containment="true"/>
> </eClassifiers>
> <eClassifiers xsi:type="ecore:EClass" name="Bus">
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="busName"
> eType="ecore:EDataType
> platform:/plugin/org.eclipse.emf.ecore/model/Ecore.ecore#//E String "/>
> <eStructuralFeatures xsi:type="ecore:EReference" name="busProperties"
> upperBound="-1"
> eType="#//Property" containment="true"/>
> </eClassifiers>
> <eClassifiers xsi:type="ecore:EClass" name="Property">
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="name"
> eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="value"
> eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="enumProperty"
> eType="#//HDENUM"/>
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="floatValue"
> eType="ecore:EDataType
> platform:/plugin/org.eclipse.emf.ecore/model/Ecore.ecore#//E Float "/>
> </eClassifiers>
> <eClassifiers xsi:type="ecore:EEnum" name="HDENUM">
> <eLiterals name="WinXP"/>
> <eLiterals name="LINUX"/>
> <eLiterals name="UNIX"/>
> <eLiterals name="SOLARIS"/>
> </eClassifiers>
> </ecore:EPackage>
> ----------------------------------------------------------
> And I have generated the code setting the item providers to be stateful.
> ------------------------------------------------------------ -
> This is my genmodel
> -------------------------------
> <?xml version="1.0" encoding="UTF-8"?>
> <genmodel:GenModel xmi:version="2.0"
> xmlns:xmi="http://www.omg.org/XMI"
> xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore"
> xmlns:genmodel="http://www.eclipse.org/emf/2002/GenModel"
> modelDirectory="/sample/src"
> modelPluginID="sample" modelName="Sample"
> importerID="org.eclipse.emf.importer.ecore"
> complianceLevel="5.0" copyrightFields="false"
>
usedGenPackages=" platform:/plugin/org.eclipse.emf.ecore/model/Ecore.genmodel# //ecore ">
> <foreignModel>sample.ecore</foreignModel>
> <genPackages prefix="Hdf" disposableProviderFactory="true"
> ecorePackage="sample.ecore#/">
> <genEnums typeSafeEnumCompatible="false"
> ecoreEnum="sample.ecore#//HDENUM">
> <genEnumLiterals ecoreEnumLiteral="sample.ecore#//HDENUM/WinXP"/>
> <genEnumLiterals ecoreEnumLiteral="sample.ecore#//HDENUM/LINUX"/>
> <genEnumLiterals ecoreEnumLiteral="sample.ecore#//HDENUM/UNIX"/>
> <genEnumLiterals ecoreEnumLiteral="sample.ecore#//HDENUM/SOLARIS"/>
> </genEnums>
> <genClasses provider="Stateful"
> ecoreClass="sample.ecore#//HardwareDefinition">
> <genFeatures property="None" children="true" createChild="true"
> ecoreFeature="ecore:EReference sample.ecore#//HardwareDefinition/devices"/>
> <genFeatures property="None" children="true" createChild="true"
> ecoreFeature="ecore:EReference sample.ecore#//HardwareDefinition/buses"/>
> </genClasses>
> <genClasses provider="Stateful" ecoreClass="sample.ecore#//Device">
> <genFeatures createChild="false" ecoreFeature="ecore:EAttribute
> sample.ecore#//Device/deviceName"/>
> <genFeatures property="None" children="true" createChild="true"
> ecoreFeature="ecore:EReference sample.ecore#//Device/deviceProperties"/>
> </genClasses>
> <genClasses provider="Stateful" ecoreClass="sample.ecore#//Bus">
> <genFeatures createChild="false" ecoreFeature="ecore:EAttribute
> sample.ecore#//Bus/busName"/>
> <genFeatures property="None" children="true" createChild="true"
> ecoreFeature="ecore:EReference sample.ecore#//Bus/busProperties"/>
> </genClasses>
> <genClasses provider="Stateful" ecoreClass="sample.ecore#//Property">
> <genFeatures createChild="false" ecoreFeature="ecore:EAttribute
> sample.ecore#//Property/name"/>
> <genFeatures createChild="false" ecoreFeature="ecore:EAttribute
> sample.ecore#//Property/value"/>
> <genFeatures createChild="false" ecoreFeature="ecore:EAttribute
> sample.ecore#//Property/enumProperty"/>
> <genFeatures createChild="false" ecoreFeature="ecore:EAttribute
> sample.ecore#//Property/floatValue"/>
> </genClasses>
> </genPackages>
> </genmodel:GenModel>
> ------------------------------------------------------------ --------
> This is just an example as I can't share the real code with you... :-).
> But, here you can try adding the child nodes with descriptors and go back
> to the parent node and it will not reflect the properties of child node
> until and unless you close the editor and open it. So, that's the problem.

>>>
>>> I mean to test this, )earlier I blocked the collection of child
>>> descriptors), I collected the child descriptors and tried to add the
>>> Property instances in to the list. When, I add, and go back to the
>>> parent node, it will not reflect the new property added, with a count
>>> and expandable tree.
>> I though you needed to add an actual Property to the Device object and
>> normally doing that will be reflected in the tree view. Then the item
>> provider just creates property descriptors to wrap those Property instances.
>>>
>>> So, I have to close the editor and re open it.
>>>
>>> So far have not tried commands to create this new properties.
>> Without commands, things won't work so well. Specifically, when you
>> execute a command, the properties view will be refreshed, and that's
>> exactly what's not happening.
>>> But, I guess once I add them through command it should work.
>> yep.
>>> But, when I am using child actions, they also fire commands you know,
>>> why they are not working?
>> Not so clear what's not working. I suspect it's because your caching
>> the list of property descriptors, as I mentioned, but now I'm asking to
>> see the code so that I'll be sure the question is answered.
>>>
>>> Sorry, if I am unable to put my problem properly, if you are not
>>> understanding... :-).
>>>
>>> Thank you,
>>>
>>> Asha R.
>>>
>>> Please find my comments below.
>>>
>>>
>>> Ed Merks wrote:
>>>
>>>> Asha,
>>>
>>>> Comments below.
>>>
>>>> Asha R wrote:
>>>>> Hi,
>>>>>
>>>>> I have an editor generated for an emf model.
>>>>> Based on some run time data I am adding some values to an
>>>>> aggregation reference variable of the element. It will not reflect
>>>>> until, I save the editor close it and reopen.
>>>> Where is it not being reflected? Are you making the change using a
>>>> command?
>>>>> I would like to know, how I can force the node to refresh itself, so
>>>>> that it generates property descriptors for newly added values in the
>>>>> list?
>>>> I'm not quite sure why it wouldn't already do this.
>>>>>
>>>>> In fact, I am displaying the properties of the list elements, at the
>>>>> parent node.
>>>>> So, my problem is, when I add something to the list using the child
>>>>> descriptors actions, it appears as a child,
>>>> I'm not following how this is working...
>>>>> but the parent node's property descriptor for the same list would
>>>>> not get refreshed. So, how can I refresh the parent node?
>>>> If you are using a property descriptor to make the change how is it
>>>> that the list of property descriptors is affected by this?
>>>
>>>> Are you making sure the list of property descriptors is recomputed
>>>> each time? By default it's computed once and cached, but in your
>>>> case, each instance can have a different list, so you need to ensure
>>>> it's being recomputed.
>>>>>
>>>>> Thank you,
>>>>>
>>>>> Asha R.
>>>>>
>>>
>>>
Re: How to force a node to refresh it's properties view [message #425640 is a reply to message #425637] Wed, 03 December 2008 15:35 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 31152
Registered: July 2009
Senior Member
Asha,

Comments below.

Asha R wrote:
> Hi Ed,
>
> Thanks for the reply again. :-).
> Please see my comments below.
>
> Ed Merks wrote:
>
>> Asha,
>
>> Comments below.
>
>
>> Asha R wrote:
>>> Hi Ed,
>>>
>>> Thanks for the reply.
>> Goodness knows how I can ever get anything else done...
>
> I am Indian and my mother tongue is not English. So I don't know what
> you mean by this and I don't know such good English. :)). So, I am not
> getting what you said. I hope you are not sarcastic :)).
A little bit sarcastic. The questions are arriving faster than I can
answer them which makes me cranky.
> I am not even getting whether you complimented me or what :)))!
Not so much. :-P
> I am really confused, probably because of this so called dynamic
> properties. :)). Sorry, if I am assuming something wrong. But, I
> really feel bad for taking help from you all the time.
>
>>>
>>> I have seen the MappingItemProvider and implemented the properties
>>> of a list to appear as if they are properties of it's parent node.
>>>
>>> I mean if I have a Device, which has a list of Property, each of the
>>> property in the list should appear as the property of the parent node.
>>> Everything is same as the MappingItemProvider logic.
>>> Like it displays each property listing with uniquie count like,
>>> + 1. Property
>>> + 2. Property
>>> <my attributes for class>
>>> etc.
>>>
>>> This works only when I read all the properties initially into the
>>> Device class.
>>> If I add them dynamically it wont reflect until I close and re open
>>> the editor.
>> I gather that. Can you show what your getPropertyDescriptors method
>> looks like?
>
> public List<IItemPropertyDescriptor> getPropertyDescriptors(Object
> object) {
> if (itemPropertyDescriptors == null) {
So this is exactly what I'm getting at. Once you compute the list,
you'll never recompute it and because your item providers are stateless
(by default), one adapter is used for all instances. Instead try

itemPropertyDescriptors = null;

I.e., always set it to null, always call super and always do the rest of
your logic.

> super.getPropertyDescriptors(object);
>
> addDeviceNamePropertyDescriptor(object);
>
> Device theDevice = (Device)object;
> HdfPackage ePackage = HdfPackage.eINSTANCE;
> boolean hasProperties =
> (theDevice.getDeviceProperties().size() > 0);
> if (hasProperties)
> {
> int count = 1;
> for (final Property childProperty :
> theDevice.getDeviceProperties())
> {
> IItemPropertyDescriptor
> childPropertyItemPropertyDescriptor =
> new
> ItemPropertyDescriptor(((ComposeableAdapterFactory)adapterFa ctory).getRootAdapterFactory(),
>
> getResourceLocator(),
> //Can be replaced with a proper string
> from plugin.properties
> //Count is used to generate the unique
> names
> count + " ." + " Device Property",
> "Proper combination of plugin.properties
> will appear here",
>
> HdfPackage.Literals.DEVICE__DEVICE_PROPERTIES, //name of the list we
> want to handle
> true,
> false,
> false,
> ItemPropertyDescriptor.GENERIC_VALUE_IMAGE,
> null,
> null);
> itemPropertyDescriptors.add
> (new
> ItemPropertyDescriptorDecorator(childProperty,
> childPropertyItemPropertyDescriptor)
> {
> @Override
> public Object getPropertyValue(Object o)
> {
> super.getPropertyValue(o);
> return this.object;
> }
> @Override
> public Collection<?> getChoiceOfValues(Object o)
> {
> return null;
> }
> });
> ++count;
> }
> }
> }
> return itemPropertyDescriptors;
> }
>
> Probably you don't need following files, but still, I am posting them
> here.
> -------------------------------------
> This is my ecore model
> -------------------------------------
> <?xml version="1.0" encoding="UTF-8"?>
> <ecore:EPackage xmi:version="2.0"
> xmlns:xmi="http://www.omg.org/XMI"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="hdf"
> nsURI="http://www.example.org/hd" nsPrefix="hd">
> <eClassifiers xsi:type="ecore:EClass" name="HardwareDefinition">
> <eStructuralFeatures xsi:type="ecore:EReference" name="devices"
> upperBound="-1"
> eType="#//Device" containment="true"/>
> <eStructuralFeatures xsi:type="ecore:EReference" name="buses"
> upperBound="-1"
> eType="#//Bus" containment="true"/>
> </eClassifiers>
> <eClassifiers xsi:type="ecore:EClass" name="Device">
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="deviceName"
> eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
> <eStructuralFeatures xsi:type="ecore:EReference"
> name="deviceProperties" upperBound="-1"
> eType="#//Property" containment="true"/>
> </eClassifiers>
> <eClassifiers xsi:type="ecore:EClass" name="Bus">
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="busName"
> eType="ecore:EDataType
> platform:/plugin/org.eclipse.emf.ecore/model/Ecore.ecore#//E String "/>
> <eStructuralFeatures xsi:type="ecore:EReference"
> name="busProperties" upperBound="-1"
> eType="#//Property" containment="true"/>
> </eClassifiers>
> <eClassifiers xsi:type="ecore:EClass" name="Property">
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="name"
> eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="value"
> eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
> <eStructuralFeatures xsi:type="ecore:EAttribute"
> name="enumProperty" eType="#//HDENUM"/>
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="floatValue"
> eType="ecore:EDataType
> platform:/plugin/org.eclipse.emf.ecore/model/Ecore.ecore#//E Float "/>
> </eClassifiers>
> <eClassifiers xsi:type="ecore:EEnum" name="HDENUM">
> <eLiterals name="WinXP"/>
> <eLiterals name="LINUX"/>
> <eLiterals name="UNIX"/>
> <eLiterals name="SOLARIS"/>
> </eClassifiers>
> </ecore:EPackage>
> ----------------------------------------------------------
> And I have generated the code setting the item providers to be stateful.
> ------------------------------------------------------------ -
> This is my genmodel
> -------------------------------
> <?xml version="1.0" encoding="UTF-8"?>
> <genmodel:GenModel xmi:version="2.0"
> xmlns:xmi="http://www.omg.org/XMI"
> xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore"
> xmlns:genmodel="http://www.eclipse.org/emf/2002/GenModel"
> modelDirectory="/sample/src"
> modelPluginID="sample" modelName="Sample"
> importerID="org.eclipse.emf.importer.ecore"
> complianceLevel="5.0" copyrightFields="false"
> usedGenPackages=" platform:/plugin/org.eclipse.emf.ecore/model/Ecore.genmodel# //ecore ">
>
> <foreignModel>sample.ecore</foreignModel>
> <genPackages prefix="Hdf" disposableProviderFactory="true"
> ecorePackage="sample.ecore#/">
> <genEnums typeSafeEnumCompatible="false"
> ecoreEnum="sample.ecore#//HDENUM">
> <genEnumLiterals ecoreEnumLiteral="sample.ecore#//HDENUM/WinXP"/>
> <genEnumLiterals ecoreEnumLiteral="sample.ecore#//HDENUM/LINUX"/>
> <genEnumLiterals ecoreEnumLiteral="sample.ecore#//HDENUM/UNIX"/>
> <genEnumLiterals ecoreEnumLiteral="sample.ecore#//HDENUM/SOLARIS"/>
> </genEnums>
> <genClasses provider="Stateful"
> ecoreClass="sample.ecore#//HardwareDefinition">
> <genFeatures property="None" children="true" createChild="true"
> ecoreFeature="ecore:EReference
> sample.ecore#//HardwareDefinition/devices"/>
> <genFeatures property="None" children="true" createChild="true"
> ecoreFeature="ecore:EReference sample.ecore#//HardwareDefinition/buses"/>
> </genClasses>
> <genClasses provider="Stateful" ecoreClass="sample.ecore#//Device">
> <genFeatures createChild="false" ecoreFeature="ecore:EAttribute
> sample.ecore#//Device/deviceName"/>
> <genFeatures property="None" children="true" createChild="true"
> ecoreFeature="ecore:EReference sample.ecore#//Device/deviceProperties"/>
> </genClasses>
> <genClasses provider="Stateful" ecoreClass="sample.ecore#//Bus">
> <genFeatures createChild="false" ecoreFeature="ecore:EAttribute
> sample.ecore#//Bus/busName"/>
> <genFeatures property="None" children="true" createChild="true"
> ecoreFeature="ecore:EReference sample.ecore#//Bus/busProperties"/>
> </genClasses>
> <genClasses provider="Stateful" ecoreClass="sample.ecore#//Property">
> <genFeatures createChild="false" ecoreFeature="ecore:EAttribute
> sample.ecore#//Property/name"/>
> <genFeatures createChild="false" ecoreFeature="ecore:EAttribute
> sample.ecore#//Property/value"/>
> <genFeatures createChild="false" ecoreFeature="ecore:EAttribute
> sample.ecore#//Property/enumProperty"/>
> <genFeatures createChild="false" ecoreFeature="ecore:EAttribute
> sample.ecore#//Property/floatValue"/>
> </genClasses>
> </genPackages>
> </genmodel:GenModel>
> ------------------------------------------------------------ --------
> This is just an example as I can't share the real code with you... :-).
> But, here you can try adding the child nodes with descriptors and go
> back to the parent node and it will not reflect the properties of
> child node until and unless you close the editor and open it. So,
> that's the problem.
>
>>>
>>> I mean to test this, )earlier I blocked the collection of child
>>> descriptors), I collected the child descriptors and tried to add the
>>> Property instances in to the list. When, I add, and go back to the
>>> parent node, it will not reflect the new property added, with a
>>> count and expandable tree.
>> I though you needed to add an actual Property to the Device object
>> and normally doing that will be reflected in the tree view. Then the
>> item provider just creates property descriptors to wrap those
>> Property instances.
>>>
>>> So, I have to close the editor and re open it.
>>>
>>> So far have not tried commands to create this new properties.
>> Without commands, things won't work so well. Specifically, when you
>> execute a command, the properties view will be refreshed, and that's
>> exactly what's not happening.
>>> But, I guess once I add them through command it should work.
>> yep.
>>> But, when I am using child actions, they also fire commands you
>>> know, why they are not working?
>> Not so clear what's not working. I suspect it's because your caching
>> the list of property descriptors, as I mentioned, but now I'm asking
>> to see the code so that I'll be sure the question is answered.
>>>
>>> Sorry, if I am unable to put my problem properly, if you are not
>>> understanding... :-).
>>>
>>> Thank you,
>>>
>>> Asha R.
>>>
>>> Please find my comments below.
>>>
>>>
>>> Ed Merks wrote:
>>>
>>>> Asha,
>>>
>>>> Comments below.
>>>
>>>> Asha R wrote:
>>>>> Hi,
>>>>>
>>>>> I have an editor generated for an emf model.
>>>>> Based on some run time data I am adding some values to an
>>>>> aggregation reference variable of the element. It will not reflect
>>>>> until, I save the editor close it and reopen.
>>>> Where is it not being reflected? Are you making the change using a
>>>> command?
>>>>> I would like to know, how I can force the node to refresh itself,
>>>>> so that it generates property descriptors for newly added values
>>>>> in the list?
>>>> I'm not quite sure why it wouldn't already do this.
>>>>>
>>>>> In fact, I am displaying the properties of the list elements, at
>>>>> the parent node.
>>>>> So, my problem is, when I add something to the list using the
>>>>> child descriptors actions, it appears as a child,
>>>> I'm not following how this is working...
>>>>> but the parent node's property descriptor for the same list would
>>>>> not get refreshed. So, how can I refresh the parent node?
>>>> If you are using a property descriptor to make the change how is it
>>>> that the list of property descriptors is affected by this?
>>>
>>>> Are you making sure the list of property descriptors is recomputed
>>>> each time? By default it's computed once and cached, but in your
>>>> case, each instance can have a different list, so you need to
>>>> ensure it's being recomputed.
>>>>>
>>>>> Thank you,
>>>>>
>>>>> Asha R.
>>>>>
>>>
>>>
>
>
Re: How to force a node to refresh it's properties view [message #425642 is a reply to message #425640] Wed, 03 December 2008 16:02 Go to previous message
Asha Ramegowda is currently offline Asha RamegowdaFriend
Messages: 77
Registered: July 2009
Member
Hi Ed,

Thanks. You are right.
I try my best not to trouble you. Especially on this dynamic properties.
:-).

Thank you,

Asha R.
Previous Topic:ChildCreationExtenderManager and Inherited Extensible models
Next Topic:[Announce] EMF at EclipseCon 2009
Goto Forum:
  


Current Time: Thu May 28 02:23:09 GMT 2020

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

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

Back to the top