Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » UndoablePropertySheet with EMF ItemProviders
UndoablePropertySheet with EMF ItemProviders [message #142837] Thu, 15 July 2004 16:36 Go to next message
Eclipse UserFriend
Originally posted by: greskamp.research.ge.com

I'm having the same problem described in David Michonneau's 2/11/04
post; I'm trying to use auto-generated EMF ItemProviders with GEF's
UndoablePropertySheetEntry.

I'm using Eclipse 2.1.3, GEF 2.1.3, and EMF 1.1.1.

Was the value wrapping/unwrapping issue ever resolved?

SPECIFICS:
When a property is changed in the undoable property sheet, a
SetPropertyValueCommand executes. The SetPropertyValueCommand first
tries to get the current value of the property being modified so that
the operation can be undone later. In my case, the PropertySource is an
auto-generated EMF ItemProvider. The PropertySource.getPropertyValue()
method delegates to ItemPropertyDescriptor.getPropertyValue(). The
problem is that the EMF
org.eclipse.emf.edit.provider.ItemPropertyDescriptor.getProp ertyValue()
method returns the property value wrapped in a PropertyValueWrapper,
whereas the SetPropertyValueCommand expects an unwrapped value.
Consequently, an exception occurs when the user tries to undo the command.

The EMF newsgroup referred me here :-)

Thanks,
Brian Greskamp
Re: UndoablePropertySheet with EMF ItemProviders [message #142876 is a reply to message #142837] Thu, 15 July 2004 23:54 Go to previous messageGo to next message
Sean Woodhouse is currently offline Sean WoodhouseFriend
Messages: 45
Registered: July 2009
Member
Brian,

I had the same problem too :-(
My workaround was to create my own SetPropertyValueCommand (copied the
source from org.eclipse.gef.internal.ui.properties.SetPropertyValueComma nd)
and replaced the execute() method with:

public void execute() {
resetOnUndo = !getTarget().isPropertySet(propertyName);
if (!resetOnUndo) {
undoValue = getTarget().getPropertyValue(propertyName);

if (undoValue instanceof IPropertySource) {
undoValue = ((IPropertySource) undoValue).getEditableValue();
}
else if(undoValue instanceof IItemPropertySource) {
undoValue = ((IItemPropertySource)
undoValue).getEditableValue(getTarget());
}
} else {
undoValue = null;
}

getTarget().setPropertyValue(propertyName, propertyValue);
}

Notice that is checks the type of object returned from
getTarget().getPropertyValue(propertyName) and sets the undoValue
accordingly. I also had to create my own UndoablePropertySheetEntry class
(again, copied the source from
org.eclipse.gef.internal.ui.properties.UndoablePropertySheet Entry) and
changed the valueChanged() method to instanciate an instance of my
replacement SetPropertyValueCommand.

Works fine for me now, but I would have rather'd a cleaner way to make these
changes than to copy code...

Cheers

Sean



"Brian Greskamp" <greskamp@research.ge.com> wrote in message
news:cd6bmu$ree$1@eclipse.org...
> I'm having the same problem described in David Michonneau's 2/11/04
> post; I'm trying to use auto-generated EMF ItemProviders with GEF's
> UndoablePropertySheetEntry.
>
> I'm using Eclipse 2.1.3, GEF 2.1.3, and EMF 1.1.1.
>
> Was the value wrapping/unwrapping issue ever resolved?
>
> SPECIFICS:
> When a property is changed in the undoable property sheet, a
> SetPropertyValueCommand executes. The SetPropertyValueCommand first
> tries to get the current value of the property being modified so that
> the operation can be undone later. In my case, the PropertySource is an
> auto-generated EMF ItemProvider. The PropertySource.getPropertyValue()
> method delegates to ItemPropertyDescriptor.getPropertyValue(). The
> problem is that the EMF
> org.eclipse.emf.edit.provider.ItemPropertyDescriptor.getProp ertyValue()
> method returns the property value wrapped in a PropertyValueWrapper,
> whereas the SetPropertyValueCommand expects an unwrapped value.
> Consequently, an exception occurs when the user tries to undo the command.
>
> The EMF newsgroup referred me here :-)
>
> Thanks,
> Brian Greskamp
Re: UndoablePropertySheet with EMF ItemProviders [message #142994 is a reply to message #142876] Fri, 16 July 2004 13:45 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: greskamp.research.ge.com

Yeah, I wish it were fixed, but your kludge sounds reasonable. Thanks for
the suggestion.

Thanks,
Brian

"Sean Woodhouse" <swoodhouse@agentissoftware.com> wrote in message
news:cd75cj$4q4$1@eclipse.org...
> Brian,
>
> I had the same problem too :-(
> My workaround was to create my own SetPropertyValueCommand (copied the
> source from
org.eclipse.gef.internal.ui.properties.SetPropertyValueComma nd)
> and replaced the execute() method with:
>
> public void execute() {
> resetOnUndo = !getTarget().isPropertySet(propertyName);
> if (!resetOnUndo) {
> undoValue = getTarget().getPropertyValue(propertyName);
>
> if (undoValue instanceof IPropertySource) {
> undoValue = ((IPropertySource) undoValue).getEditableValue();
> }
> else if(undoValue instanceof IItemPropertySource) {
> undoValue = ((IItemPropertySource)
> undoValue).getEditableValue(getTarget());
> }
> } else {
> undoValue = null;
> }
>
> getTarget().setPropertyValue(propertyName, propertyValue);
> }
>
> Notice that is checks the type of object returned from
> getTarget().getPropertyValue(propertyName) and sets the undoValue
> accordingly. I also had to create my own UndoablePropertySheetEntry class
> (again, copied the source from
> org.eclipse.gef.internal.ui.properties.UndoablePropertySheet Entry) and
> changed the valueChanged() method to instanciate an instance of my
> replacement SetPropertyValueCommand.
>
> Works fine for me now, but I would have rather'd a cleaner way to make
these
> changes than to copy code...
>
> Cheers
>
> Sean
>
>
>
> "Brian Greskamp" <greskamp@research.ge.com> wrote in message
> news:cd6bmu$ree$1@eclipse.org...
> > I'm having the same problem described in David Michonneau's 2/11/04
> > post; I'm trying to use auto-generated EMF ItemProviders with GEF's
> > UndoablePropertySheetEntry.
> >
> > I'm using Eclipse 2.1.3, GEF 2.1.3, and EMF 1.1.1.
> >
> > Was the value wrapping/unwrapping issue ever resolved?
> >
> > SPECIFICS:
> > When a property is changed in the undoable property sheet, a
> > SetPropertyValueCommand executes. The SetPropertyValueCommand first
> > tries to get the current value of the property being modified so that
> > the operation can be undone later. In my case, the PropertySource is an
> > auto-generated EMF ItemProvider. The PropertySource.getPropertyValue()
> > method delegates to ItemPropertyDescriptor.getPropertyValue(). The
> > problem is that the EMF
> > org.eclipse.emf.edit.provider.ItemPropertyDescriptor.getProp ertyValue()
> > method returns the property value wrapped in a PropertyValueWrapper,
> > whereas the SetPropertyValueCommand expects an unwrapped value.
> > Consequently, an exception occurs when the user tries to undo the
command.
> >
> > The EMF newsgroup referred me here :-)
> >
> > Thanks,
> > Brian Greskamp
>
>
Re: UndoablePropertySheet with EMF ItemProviders [message #143002 is a reply to message #142994] Fri, 16 July 2004 16:32 Go to previous message
Eclipse UserFriend
Originally posted by: none.us.ibm.com

It is fixed in 3.0.0:

undoValue = getTarget().getPropertyValue(propertyName);
if (undoValue instanceof IPropertySource)
undoValue = ((IPropertySource)undoValue).getEditableValue();

For older versions, you could always override setPropertyValue() to see if
the value is an instance of the wrapper, and then unwrap it.
Previous Topic:How to listen the saving action of other editor running on the same runtime eclipse?
Next Topic:Text wrap
Goto Forum:
  


Current Time: Fri Mar 29 15:37:34 GMT 2024

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

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

Back to the top