Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » Combined parent-child property descriptors
Combined parent-child property descriptors [message #155327] Sun, 24 October 2004 04:03 Go to next message
Eclipse UserFriend
Originally posted by: ranjit.notMyId.com

Hi,

Is there any way that I can combine parent class & child class
properties to be displayed on a property sheet?

Here is what I intend to do

Class A (parent)
prop1
prop2

Class B extends A
prop3

Class C extends A
prop4

Now what should I do such that whenever I click on a edit part
corresponding to model class B I get to see properties (1,2 & 3) in the
property sheet whereas see (1, 2 & 4) when I click C type item.
Right now I have to duplicate properties (1 & 2) in B and C.

I tried initializing the property descriptors in the constructors where
in the extended classes call the super() and then append their
respective properties to the propertyDescriptor array, but that doesn't
seem to work.


Thanks.
Re: Combined parent-child property descriptors [message #155332 is a reply to message #155327] Sun, 24 October 2004 12:45 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: dyx.gmx.net

This should go to the platform group.
You override the PropertyDescriptor related methods in the subclass and =
=

append the new properties to the old ones. Check the LED.java class in t=
he =

logic example for an implementation of this.

Examples:

static{
PropertyDescriptor pValueProp =3D new TextPropertyDescriptor(P_VALUE,
LogicMessages.PropertyDescriptor_LED_Value);
pValueProp.setValidator(LogicNumberCellEditorValidator.insta nce());
if(descriptors!=3Dnull){
newDescriptors =3D new =

IPropertyDescriptor[descriptors.length+1];//<<<<<<<<<
for(int i=3D0;i<descriptors.length;i++)
newDescriptors[i] =3D descriptors[i];// keep superclass properties
newDescriptors[descriptors.length] =3D pValueProp; // append new one
} else
newDescriptors =3D new IPropertyDescriptor[]{pValueProp};
}

public Object getPropertyValue(Object propName) {
if (P_VALUE.equals(propName))
return new Integer(getValue()).toString();
if( ID_SIZE.equals(propName)){
return new String("("+getSize().width+","+getSize().height+")");
}
return super.getPropertyValue(propName);// <<<<<<<<<<<<<<<<<<<<<<<
}




On Sun, 24 Oct 2004 00:03:37 -0400, Ranjit <ranjit@notMyId.com> wrote:

> Hi,
>
> Is there any way that I can combine parent class & child class =

> properties to be displayed on a property sheet?
>
> Here is what I intend to do
>
> Class A (parent)
> prop1
> prop2
>
> Class B extends A
> prop3
>
> Class C extends A
> prop4
>
> Now what should I do such that whenever I click on a edit part =

> corresponding to model class B I get to see properties (1,2 & 3) in th=
e =

> property sheet whereas see (1, 2 & 4) when I click C type item.
> Right now I have to duplicate properties (1 & 2) in B and C.
>
> I tried initializing the property descriptors in the constructors wher=
e =

> in the extended classes call the super() and then append their =

> respective properties to the propertyDescriptor array, but that doesn'=
t =

> seem to work.
>
>
> Thanks.



-- =

Using Opera's revolutionary e-mail client: http://www.opera.com/m2/
Re: Combined parent-child property descriptors [message #155340 is a reply to message #155332] Sun, 24 October 2004 14:52 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: ranjit.notMyId.com

Oops, sorry for posting it here and thanks for the solution :).
I think the mistake I was making was I directly tried to add the
properties of the child classes into the descriptors instead of making a
copy as in the snippet you posted.

Thanks.


Frank Dyck wrote:
> This should go to the platform group.
> You override the PropertyDescriptor related methods in the subclass and
> append the new properties to the old ones. Check the LED.java class in
> the logic example for an implementation of this.
>
> Examples:
>
> static{
> PropertyDescriptor pValueProp = new TextPropertyDescriptor(P_VALUE,
> LogicMessages.PropertyDescriptor_LED_Value);
> pValueProp.setValidator(LogicNumberCellEditorValidator.insta nce());
> if(descriptors!=null){
> newDescriptors = new
> IPropertyDescriptor[descriptors.length+1];//<<<<<<<<<
> for(int i=0;i<descriptors.length;i++)
> newDescriptors[i] = descriptors[i];// keep superclass
> properties
> newDescriptors[descriptors.length] = pValueProp; // append new one
> } else
> newDescriptors = new IPropertyDescriptor[]{pValueProp};
> }
>
> public Object getPropertyValue(Object propName) {
> if (P_VALUE.equals(propName))
> return new Integer(getValue()).toString();
> if( ID_SIZE.equals(propName)){
> return new String("("+getSize().width+","+getSize().height+")");
> }
> return super.getPropertyValue(propName);// <<<<<<<<<<<<<<<<<<<<<<<
> }
>
>
>
>
> On Sun, 24 Oct 2004 00:03:37 -0400, Ranjit <ranjit@notMyId.com> wrote:
>
>> Hi,
>>
>> Is there any way that I can combine parent class & child class
>> properties to be displayed on a property sheet?
>>
>> Here is what I intend to do
>>
>> Class A (parent)
>> prop1
>> prop2
>>
>> Class B extends A
>> prop3
>>
>> Class C extends A
>> prop4
>>
>> Now what should I do such that whenever I click on a edit part
>> corresponding to model class B I get to see properties (1,2 & 3) in
>> the property sheet whereas see (1, 2 & 4) when I click C type item.
>> Right now I have to duplicate properties (1 & 2) in B and C.
>>
>> I tried initializing the property descriptors in the constructors
>> where in the extended classes call the super() and then append their
>> respective properties to the propertyDescriptor array, but that
>> doesn't seem to work.
>>
>>
>> Thanks.
>
>
>
>
Re: Combined parent-child property descriptors [message #155348 is a reply to message #155340] Sun, 24 October 2004 15:04 Go to previous message
Eclipse UserFriend
Originally posted by: dyx.gmx.net

Don`t forget to do it also in the other Property related methods.
Check the LED class for the code.


> Oops, sorry for posting it here and thanks for the solution :).
> I think the mistake I was making was I directly tried to add the =

> properties of the child classes into the descriptors instead of making=
a =

> copy as in the snippet you posted.
>
> Thanks.
>
>
> Frank Dyck wrote:
>> This should go to the platform group.
>> You override the PropertyDescriptor related methods in the subclass =

>> and append the new properties to the old ones. Check the LED.java =

>> class in the logic example for an implementation of this.
>> Examples:
>> static{
>> PropertyDescriptor pValueProp =3D new TextPropertyDescriptor(P_VA=
LUE,
>> LogicMessages.PropertyDescriptor_LED_Value);
>> pValueProp.setValidator(LogicNumberCellEditorValidator.insta nce()=
);
>> if(descriptors!=3Dnull){
>> newDescriptors =3D new =

>> IPropertyDescriptor[descriptors.length+1];//<<<<<<<<<
>> for(int i=3D0;i<descriptors.length;i++)
>> newDescriptors[i] =3D descriptors[i];// keep superclass =
=

>> properties
>> newDescriptors[descriptors.length] =3D pValueProp; // append =
new =

>> one
>> } else
>> newDescriptors =3D new IPropertyDescriptor[]{pValueProp};
>> }
>> public Object getPropertyValue(Object propName) {
>> if (P_VALUE.equals(propName))
>> return new Integer(getValue()).toString();
>> if( ID_SIZE.equals(propName)){
>> return new String("("+getSize().width+","+getSize().height+")=
");
>> }
>> return super.getPropertyValue(propName);// <<<<<<<<<<<<<<<<<<<<<<=
<
>> }
>> On Sun, 24 Oct 2004 00:03:37 -0400, Ranjit <ranjit@notMyId.com> =

>> wrote:
>>
>>> Hi,
>>>
>>> Is there any way that I can combine parent class & child class =

>>> properties to be displayed on a property sheet?
>>>
>>> Here is what I intend to do
>>>
>>> Class A (parent)
>>> prop1
>>> prop2
>>>
>>> Class B extends A
>>> prop3
>>>
>>> Class C extends A
>>> prop4
>>>
>>> Now what should I do such that whenever I click on a edit part =

>>> corresponding to model class B I get to see properties (1,2 & 3) in =
=

>>> the property sheet whereas see (1, 2 & 4) when I click C type item.=

>>> Right now I have to duplicate properties (1 & 2) in B and C.
>>>
>>> I tried initializing the property descriptors in the constructors =

>>> where in the extended classes call the super() and then append thei=
r =

>>> respective properties to the propertyDescriptor array, but that =

>>> doesn't seem to work.
>>>
>>>
>>> Thanks.
>>



-- =

Using Opera's revolutionary e-mail client: http://www.opera.com/m2/
Previous Topic:delete an editPart
Next Topic:Importing new classes at runtime
Goto Forum:
  


Current Time: Fri Jan 17 09:26:34 GMT 2025

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

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

Back to the top