Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » Dynamic properties view?
Dynamic properties view? [message #85080] Wed, 13 December 2006 10:58 Go to next message
Eclipse UserFriend
Originally posted by: tobk.gmx.de

Hello,

is there a way to make the properties view dynamic in that sense, that the
displayed properties depend on some other property? The case is that I have
a property 'type' and depending on that property some other properties
shall be visible, e.g. when the type is 'timer' then there might be a
property 'starttime' and 'duration' and when the type is 'message' there
shall be an 'inMessage' and an 'outMessage'.

My first try was to add some conditions to the ItemProvider's
getPropertyDescriptor method. This worked well when opening the first
property source for a given class. Next I changed the singleton-getter in
the ItemProviderAdapterFactory, so it returns a new ItemProvider each for
each instance. Now each instance has it's own property sheet with
attributes depending on it's type, but the displayed properties still do
not change when the type is changed.

Can you give me an advice how to achive this?
thanks,
tobias
Re: Dynamic properties view? [message #85124 is a reply to message #85080] Wed, 13 December 2006 12:01 Go to previous message
Eclipse UserFriend
Originally posted by: merks.ca.ibm.com

This is a multi-part message in MIME format.
--------------020303000604020903050609
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Tobias,

Comments below.

tobias wrote:
> Hello,
>
> is there a way to make the properties view dynamic in that sense, that the
> displayed properties depend on some other property?
Yes, but that means the item providers need to be stateful and you need
to recompute the properties each time the item provider is asked for the
property descriptors.
> The case is that I have
> a property 'type' and depending on that property some other properties
> shall be visible, e.g. when the type is 'timer' then there might be a
> property 'starttime' and 'duration' and when the type is 'message' there
> shall be an 'inMessage' and an 'outMessage'.
>
It might be best for the property itself to provide properties so that
you would expand the property. For example, in GenBaseItemProvider we
define a specialized property descriptor class that does this:

protected Object createPropertyValueWrapper(Object object, Object
propertyValue)
{
return propertyValue instanceof EModelElement ?
new PropertyValueWrapper(adapterFactory, object, propertyValue,
propertyValue) :
super.createPropertyValueWrapper(object, propertyValue);
}

This ensures that all the property for the EModelElement are available
as nested properties.
> My first try was to add some conditions to the ItemProvider's
> getPropertyDescriptor method. This worked well when opening the first
> property source for a given class. Next I changed the singleton-getter in
> the ItemProviderAdapterFactory, so it returns a new ItemProvider each for
> each instance. Now each instance has it's own property sheet with
> attributes depending on it's type, but the displayed properties still do
> not change when the type is changed.
>
Keep in mind that the properties are cached and computed only once, so
you'd need to change that behavior to compute them each time. Nested
properties seems like a better approach...
> Can you give me an advice how to achive this?
> thanks,
> tobias
>


--------------020303000604020903050609
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Tobias,<br>
<br>
Comments below.<br>
<br>
tobias wrote:
<blockquote cite="midelom5d$a54$1@utils.eclipse.org" type="cite">
<pre wrap="">Hello,

is there a way to make the properties view dynamic in that sense, that the
displayed properties depend on some other property? </pre>
</blockquote>
Yes, but that means the item providers need to be stateful and you need
to recompute the properties each time the item provider is asked for
the property descriptors.<br>
<blockquote cite="midelom5d$a54$1@utils.eclipse.org" type="cite">
<pre wrap="">The case is that I have
a property 'type' and depending on that property some other properties
shall be visible, e.g. when the type is 'timer' then there might be a
property 'starttime' and 'duration' and when the type is 'message' there
shall be an 'inMessage' and an 'outMessage'.
</pre>
</blockquote>
It might be best for the property itself to provide properties so that
you would expand the property.&nbsp; For example, in GenBaseItemProvider we
define a specialized property descriptor class that does this:<br>
<br>
<small>&nbsp;&nbsp;&nbsp; protected Object createPropertyValueWrapper(Object object,
Object propertyValue)<br>
&nbsp;&nbsp;&nbsp; {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return propertyValue instanceof EModelElement ?<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; new PropertyValueWrapper(adapterFactory, object, propertyValue,
propertyValue) :<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; super.createPropertyValueWrapper(object, propertyValue);<br>
&nbsp;&nbsp;&nbsp; }</small><br>
<br>
This ensures that all the property for the EModelElement are available
as nested properties.<br>
<blockquote cite="midelom5d$a54$1@utils.eclipse.org" type="cite">
<pre wrap="">
My first try was to add some conditions to the ItemProvider's
getPropertyDescriptor method. This worked well when opening the first
property source for a given class. Next I changed the singleton-getter in
the ItemProviderAdapterFactory, so it returns a new ItemProvider each for
each instance. Now each instance has it's own property sheet with
attributes depending on it's type, but the displayed properties still do
not change when the type is changed.
</pre>
</blockquote>
Keep in mind that the properties are cached and computed only once, so
you'd need to change that behavior to compute them each time.&nbsp; Nested
properties seems like a better approach...<br>
<blockquote cite="midelom5d$a54$1@utils.eclipse.org" type="cite">
<pre wrap="">
Can you give me an advice how to achive this?
thanks,
tobias
</pre>
</blockquote>
<br>
</body>
</html>

--------------020303000604020903050609--
Previous Topic:Remove items from diagram popup menu
Next Topic:How to implement the project explorer tree code
Goto Forum:
  


Current Time: Fri Jul 19 05:20:09 GMT 2024

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

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

Back to the top