Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » Visual Editor (VE) » Custom cell editor
Custom cell editor [message #129484] Thu, 03 August 2006 21:55 Go to next message
hung is currently offline hungFriend
Messages: 117
Registered: July 2009
Senior Member
Hello,
I have 2 questions :

1. Does the example code work with Eclipse 3.2?
2. When implement custom cell editor (following the tutorial), I see my
value gets updated in the Properties View, but the source doesn't get
updated. Am I missing something? Which method I need to override to
update the actual model?

Thanks.
Re: Custom cell editor [message #129511 is a reply to message #129484] Fri, 04 August 2006 13:26 Go to previous messageGo to next message
hung is currently offline hungFriend
Messages: 117
Registered: July 2009
Senior Member
Hung Lam wrote:
> Hello,
> I have 2 questions :
>
> 1. Does the example code work with Eclipse 3.2?
> 2. When implement custom cell editor (following the tutorial), I see my
> value gets updated in the Properties View, but the source doesn't get
> updated. Am I missing something? Which method I need to override to
> update the actual model?
>
> Thanks.

I was able to do that by implement a PropertyDescriptor. It seems to be
straight forward.

One question though:
Can we update 2 properties at the same time?

for example:

MyComposite composite = new MyComposite(this,SWT.NONE);
composite.setA("a");
composite.setB("b");

If user selects to change property "A" in Properties view, we displays a
dialog that let the user changes both A and B.

Thanks.
Re: Custom cell editor [message #129637 is a reply to message #129511] Mon, 07 August 2006 14:40 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: richkulp.us.NO_SPAM.ibm.com

That would be difficult to do. That is because standard property
descriptors only change one property. If it changed two, then it could
not be undone. That is because the property sheet uses a standard set
command, and the standard set command would only know about the one
property setting and so could not undo the other.

With the VE you would instead need to use an ICommandPropertyDescriptor.
This allows you to create two commands and one compound command, one for
each property, that can then be returned to the property sheet. This
will allow undo to work correctly.

--
Thanks,
Rich Kulp
Re: Custom cell editor [message #129660 is a reply to message #129637] Mon, 07 August 2006 18:29 Go to previous messageGo to next message
hung is currently offline hungFriend
Messages: 117
Registered: July 2009
Senior Member
Again, Thank you Rich for your reply.
For a single property, this is how I currently do it:

1. Add an extension "org.eclipse.jem.beaninfo.registrations" to point
to my override file.
2. In my override file, I have the following :

<objectsToAttach
cellEditorClassname=" org.eclipse.ve.swt/org.eclipse.ve.internal.swt.JVEDialogCell Editor:com.ibm.hats/com.ibm.hats.studio.jve.BlockScreenRegio nPropertyEditor "
labelProviderClassname=" com.ibm.hats/com.ibm.hats.studio.jve.BlockScreenRegionLabelP rovider "
xmi:id="_eAnnotations"
xsi:type=" org.eclipse.ve.internal.cde.decorators:BasePropertyDecorator ">
</objectsToAttach>

3. My BlockScreenRegionLabelProvider would implement the followings:

public class BlockScreenRegionPropertyEditor implements
PropertyEditor,INeedData

The rest are handled by JVE beautifully.

Would you be nice enough to show me briefly step by step what need to be
done to accomplish what I want to do. Should I have the same entry in
plugin.xml and override file, and instead of implement
PropertyDescriptor, I have to implement ICommandPropertyDescriptor
instead? Sorry, I am still pretty new to JVE. Thanks in advance.



Rich Kulp wrote:
> That would be difficult to do. That is because standard property
> descriptors only change one property. If it changed two, then it could
> not be undone. That is because the property sheet uses a standard set
> command, and the standard set command would only know about the one
> property setting and so could not undo the other.
>
> With the VE you would instead need to use an ICommandPropertyDescriptor.
> This allows you to create two commands and one compound command, one for
> each property, that can then be returned to the property sheet. This
> will allow undo to work correctly.
>
Re: Custom cell editor [message #129665 is a reply to message #129660] Mon, 07 August 2006 21:37 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: richkulp.us.NO_SPAM.ibm.com

Take a look at the jfc.BoundsPropertyDescriptor.

When you set bounds, you need to unset size/location (if they were set).
Otherwise there would be conflicts. So in this case we are changing more
than one value.

See jfc/Component.override to see how we specify the
BoundsPropertyDescriptor as the property descriptor for the "bounds"
property.
--
Thanks,
Rich Kulp
Re: Custom cell editor [message #129671 is a reply to message #129665] Tue, 08 August 2006 18:50 Go to previous messageGo to next message
hung is currently offline hungFriend
Messages: 117
Registered: July 2009
Senior Member
Thanks for the info, I am able to implement "Almost" what I want to do.
This is what I currently have:

1. Update multiple properties when user modifies (by typing in the
"TextCellEditor" in the Properties).
2. I am also able to change the Default cell editor of a property to
use a Dialog.

What I want to do is to combine 1 & 2. ie: When user selects a
property, a button displayed next to the property value to allow user to
bring up a dialog. After user finishes with the dialog, it will then
update multiple properties (if necessary).

I attempted to do this by adding 2 <objectsToAttach> to the override
file, but getting "cellEditorClassname" feature not found Exception.

I am not sure if I am doing it correctly. Thanks.

Rich Kulp wrote:
> Take a look at the jfc.BoundsPropertyDescriptor.
>
> When you set bounds, you need to unset size/location (if they were set).
> Otherwise there would be conflicts. So in this case we are changing more
> than one value.
>
> See jfc/Component.override to see how we specify the
> BoundsPropertyDescriptor as the property descriptor for the "bounds"
> property.
Re: Custom cell editor [message #129676 is a reply to message #129671] Tue, 08 August 2006 23:45 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: richkulp.us.NO_SPAM.ibm.com

Your cell editor can only update one property. That is all the property
sheet understands. What happens is that the ICommandPropertyDescriptor
will then set the other property depending on the value sent into that
came from the cell editor.

If the value of the other property cannot be determined from the setting
of the one property then you will need to do something special. Instead
of returning a single property value from the cell editor, return an
instance of a class that you will write that contains both properties.
Then in your property descriptor adapter it should check to see if the
value is an instance of your special class, and if it is, it should go
and create a compound command that sets both of the properties.

--
Thanks,
Rich Kulp
Re: Custom cell editor [message #129681 is a reply to message #129676] Wed, 09 August 2006 03:04 Go to previous messageGo to next message
hung is currently offline hungFriend
Messages: 117
Registered: July 2009
Senior Member
Rich,
Thanks for the suggestions. I was able to do what I want to do
following some of your suggestions. However,I had to create my own
DialogCellEditor, since it always failed when trying createValue after
return from the dialog in openDialogBox() method.

Rich Kulp wrote:
> Your cell editor can only update one property. That is all the property
> sheet understands. What happens is that the ICommandPropertyDescriptor
> will then set the other property depending on the value sent into that
> came from the cell editor.
>
> If the value of the other property cannot be determined from the setting
> of the one property then you will need to do something special. Instead
> of returning a single property value from the cell editor, return an
> instance of a class that you will write that contains both properties.
> Then in your property descriptor adapter it should check to see if the
> value is an instance of your special class, and if it is, it should go
> and create a compound command that sets both of the properties.
>
Re: Custom cell editor [message #129687 is a reply to message #129681] Wed, 09 August 2006 14:49 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: richkulp.us.NO_SPAM.ibm.com

Yeah, I think the default JVEDialogCellEditor expects to get back only
IJavaInstances and not generic objects.

--
Thanks,
Rich Kulp
Re: Custom cell editor [message #129696 is a reply to message #129687] Wed, 09 August 2006 15:42 Go to previous messageGo to next message
hung is currently offline hungFriend
Messages: 117
Registered: July 2009
Senior Member
Hello,
Is there a way to get the value of another property, not the current
editing property before openDialogBox? I need to display these 2
properties in the dialog, and then if necessary update both. Thanks.


Is Rich Kulp wrote:
> Yeah, I think the default JVEDialogCellEditor expects to get back only
> IJavaInstances and not generic objects.
>
Re: Custom cell editor [message #129704 is a reply to message #129696] Wed, 09 August 2006 16:04 Go to previous messageGo to next message
hung is currently offline hungFriend
Messages: 117
Registered: July 2009
Senior Member
I think I might be able to achieve what I want to do by implement
ISourced. Is this the purpose of ISourced? Thanks.

Hung Lam wrote:
> Hello,
> Is there a way to get the value of another property, not the current
> editing property before openDialogBox? I need to display these 2
> properties in the dialog, and then if necessary update both. Thanks.
>
>
> Is Rich Kulp wrote:
>> Yeah, I think the default JVEDialogCellEditor expects to get back only
>> IJavaInstances and not generic objects.
>>
Re: Custom cell editor [message #129710 is a reply to message #129704] Wed, 09 August 2006 16:06 Go to previous message
Eclipse UserFriend
Originally posted by: richkulp.us.NO_SPAM.ibm.com

Yes, that is its purpose. It allows the cell editor to get the source of
the property so that you can ask for other properties or other info
about the source.

Note that unless you made the property incompatible with others, you can
actually get more than one source object if more than one child is
selected on the graph/tree viewer. The purpose of this is to allow
setting more than one child to have the same value for the property.

--
Thanks,
Rich Kulp
Re: Custom cell editor [message #613686 is a reply to message #129484] Fri, 04 August 2006 13:26 Go to previous message
hung is currently offline hungFriend
Messages: 117
Registered: July 2009
Senior Member
Hung Lam wrote:
> Hello,
> I have 2 questions :
>
> 1. Does the example code work with Eclipse 3.2?
> 2. When implement custom cell editor (following the tutorial), I see my
> value gets updated in the Properties View, but the source doesn't get
> updated. Am I missing something? Which method I need to override to
> update the actual model?
>
> Thanks.

I was able to do that by implement a PropertyDescriptor. It seems to be
straight forward.

One question though:
Can we update 2 properties at the same time?

for example:

MyComposite composite = new MyComposite(this,SWT.NONE);
composite.setA("a");
composite.setB("b");

If user selects to change property "A" in Properties view, we displays a
dialog that let the user changes both A and B.

Thanks.
Re: Custom cell editor [message #613726 is a reply to message #129511] Mon, 07 August 2006 14:40 Go to previous message
Eclipse UserFriend
Originally posted by: richkulp.us.NO_SPAM.ibm.com

That would be difficult to do. That is because standard property
descriptors only change one property. If it changed two, then it could
not be undone. That is because the property sheet uses a standard set
command, and the standard set command would only know about the one
property setting and so could not undo the other.

With the VE you would instead need to use an ICommandPropertyDescriptor.
This allows you to create two commands and one compound command, one for
each property, that can then be returned to the property sheet. This
will allow undo to work correctly.

--
Thanks,
Rich Kulp
Re: Custom cell editor [message #613732 is a reply to message #129637] Mon, 07 August 2006 18:29 Go to previous message
hung is currently offline hungFriend
Messages: 117
Registered: July 2009
Senior Member
Again, Thank you Rich for your reply.
For a single property, this is how I currently do it:

1. Add an extension "org.eclipse.jem.beaninfo.registrations" to point
to my override file.
2. In my override file, I have the following :

<objectsToAttach
cellEditorClassname=" org.eclipse.ve.swt/org.eclipse.ve.internal.swt.JVEDialogCell Editor:com.ibm.hats/com.ibm.hats.studio.jve.BlockScreenRegio nPropertyEditor "
labelProviderClassname=" com.ibm.hats/com.ibm.hats.studio.jve.BlockScreenRegionLabelP rovider "
xmi:id="_eAnnotations"
xsi:type=" org.eclipse.ve.internal.cde.decorators:BasePropertyDecorator ">
</objectsToAttach>

3. My BlockScreenRegionLabelProvider would implement the followings:

public class BlockScreenRegionPropertyEditor implements
PropertyEditor,INeedData

The rest are handled by JVE beautifully.

Would you be nice enough to show me briefly step by step what need to be
done to accomplish what I want to do. Should I have the same entry in
plugin.xml and override file, and instead of implement
PropertyDescriptor, I have to implement ICommandPropertyDescriptor
instead? Sorry, I am still pretty new to JVE. Thanks in advance.



Rich Kulp wrote:
> That would be difficult to do. That is because standard property
> descriptors only change one property. If it changed two, then it could
> not be undone. That is because the property sheet uses a standard set
> command, and the standard set command would only know about the one
> property setting and so could not undo the other.
>
> With the VE you would instead need to use an ICommandPropertyDescriptor.
> This allows you to create two commands and one compound command, one for
> each property, that can then be returned to the property sheet. This
> will allow undo to work correctly.
>
Re: Custom cell editor [message #613733 is a reply to message #129660] Mon, 07 August 2006 21:37 Go to previous message
Eclipse UserFriend
Originally posted by: richkulp.us.NO_SPAM.ibm.com

Take a look at the jfc.BoundsPropertyDescriptor.

When you set bounds, you need to unset size/location (if they were set).
Otherwise there would be conflicts. So in this case we are changing more
than one value.

See jfc/Component.override to see how we specify the
BoundsPropertyDescriptor as the property descriptor for the "bounds"
property.
--
Thanks,
Rich Kulp
Re: Custom cell editor [message #613734 is a reply to message #129665] Tue, 08 August 2006 18:50 Go to previous message
hung is currently offline hungFriend
Messages: 117
Registered: July 2009
Senior Member
Thanks for the info, I am able to implement "Almost" what I want to do.
This is what I currently have:

1. Update multiple properties when user modifies (by typing in the
"TextCellEditor" in the Properties).
2. I am also able to change the Default cell editor of a property to
use a Dialog.

What I want to do is to combine 1 & 2. ie: When user selects a
property, a button displayed next to the property value to allow user to
bring up a dialog. After user finishes with the dialog, it will then
update multiple properties (if necessary).

I attempted to do this by adding 2 <objectsToAttach> to the override
file, but getting "cellEditorClassname" feature not found Exception.

I am not sure if I am doing it correctly. Thanks.

Rich Kulp wrote:
> Take a look at the jfc.BoundsPropertyDescriptor.
>
> When you set bounds, you need to unset size/location (if they were set).
> Otherwise there would be conflicts. So in this case we are changing more
> than one value.
>
> See jfc/Component.override to see how we specify the
> BoundsPropertyDescriptor as the property descriptor for the "bounds"
> property.
Re: Custom cell editor [message #613735 is a reply to message #129671] Tue, 08 August 2006 23:45 Go to previous message
Eclipse UserFriend
Originally posted by: richkulp.us.NO_SPAM.ibm.com

Your cell editor can only update one property. That is all the property
sheet understands. What happens is that the ICommandPropertyDescriptor
will then set the other property depending on the value sent into that
came from the cell editor.

If the value of the other property cannot be determined from the setting
of the one property then you will need to do something special. Instead
of returning a single property value from the cell editor, return an
instance of a class that you will write that contains both properties.
Then in your property descriptor adapter it should check to see if the
value is an instance of your special class, and if it is, it should go
and create a compound command that sets both of the properties.

--
Thanks,
Rich Kulp
Re: Custom cell editor [message #613737 is a reply to message #129676] Wed, 09 August 2006 03:04 Go to previous message
hung is currently offline hungFriend
Messages: 117
Registered: July 2009
Senior Member
Rich,
Thanks for the suggestions. I was able to do what I want to do
following some of your suggestions. However,I had to create my own
DialogCellEditor, since it always failed when trying createValue after
return from the dialog in openDialogBox() method.

Rich Kulp wrote:
> Your cell editor can only update one property. That is all the property
> sheet understands. What happens is that the ICommandPropertyDescriptor
> will then set the other property depending on the value sent into that
> came from the cell editor.
>
> If the value of the other property cannot be determined from the setting
> of the one property then you will need to do something special. Instead
> of returning a single property value from the cell editor, return an
> instance of a class that you will write that contains both properties.
> Then in your property descriptor adapter it should check to see if the
> value is an instance of your special class, and if it is, it should go
> and create a compound command that sets both of the properties.
>
Re: Custom cell editor [message #613739 is a reply to message #129681] Wed, 09 August 2006 14:49 Go to previous message
Eclipse UserFriend
Originally posted by: richkulp.us.NO_SPAM.ibm.com

Yeah, I think the default JVEDialogCellEditor expects to get back only
IJavaInstances and not generic objects.

--
Thanks,
Rich Kulp
Re: Custom cell editor [message #613740 is a reply to message #129687] Wed, 09 August 2006 15:42 Go to previous message
hung is currently offline hungFriend
Messages: 117
Registered: July 2009
Senior Member
Hello,
Is there a way to get the value of another property, not the current
editing property before openDialogBox? I need to display these 2
properties in the dialog, and then if necessary update both. Thanks.


Is Rich Kulp wrote:
> Yeah, I think the default JVEDialogCellEditor expects to get back only
> IJavaInstances and not generic objects.
>
Re: Custom cell editor [message #613741 is a reply to message #129696] Wed, 09 August 2006 16:04 Go to previous message
hung is currently offline hungFriend
Messages: 117
Registered: July 2009
Senior Member
I think I might be able to achieve what I want to do by implement
ISourced. Is this the purpose of ISourced? Thanks.

Hung Lam wrote:
> Hello,
> Is there a way to get the value of another property, not the current
> editing property before openDialogBox? I need to display these 2
> properties in the dialog, and then if necessary update both. Thanks.
>
>
> Is Rich Kulp wrote:
>> Yeah, I think the default JVEDialogCellEditor expects to get back only
>> IJavaInstances and not generic objects.
>>
Re: Custom cell editor [message #613743 is a reply to message #129704] Wed, 09 August 2006 16:06 Go to previous message
Eclipse UserFriend
Originally posted by: richkulp.us.NO_SPAM.ibm.com

Yes, that is its purpose. It allows the cell editor to get the source of
the property so that you can ask for other properties or other info
about the source.

Note that unless you made the property incompatible with others, you can
actually get more than one source object if more than one child is
selected on the graph/tree viewer. The purpose of this is to allow
setting more than one child to have the same value for the property.

--
Thanks,
Rich Kulp
Previous Topic:Manipulating Sweet bits programmatically
Next Topic:Custom GEF edit part questions
Goto Forum:
  


Current Time: Thu Apr 18 03:56:36 GMT 2024

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

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

Back to the top