Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » property changed and commandStack
property changed and commandStack [message #238141] Wed, 29 August 2007 09:50 Go to next message
Eclipse UserFriend
Originally posted by: alexjaquet.gmail.com

Hi,

I would like to be able to undo redo once a user change the value of a
property.

Since the command stack is available in a editor and changing a property
is not executed as a command how can deal with that ?

Thanks

Regards,
Alexandre
Re: property changed and commandStack [message #238145 is a reply to message #238141] Wed, 29 August 2007 11:48 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: alexjaquet.gmail.com

I'm been using a TabbedPropertySheet.
Re: property changed and commandStack [message #238152 is a reply to message #238145] Wed, 29 August 2007 13:07 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: alexjaquet.gmail.com

I've tryed to put in my editor getAdapter
if (type == IPropertySheetPage.class) {
System.out.println("toto");
}

but it's never called

any idea welcome

thanks

Regards,
Alexandre
Re: property changed and commandStack [message #238156 is a reply to message #238152] Wed, 29 August 2007 15:17 Go to previous messageGo to next message
René is currently offline RenéFriend
Messages: 45
Registered: July 2009
Member
Hi,

Im not sure if my guess is correct but you can try it.

When you change a property value you change the value in the model too?
In this case you violating the MVC pattern. The correct way should be:
The change of the property invoke a property change event. a editpart
catch these event and execute a command to change the model.
So you can use the redo/undo functionally.

best regards,
René

Alexandre Jaquet schrieb:
> I've tryed to put in my editor getAdapter
> if (type == IPropertySheetPage.class) {
> System.out.println("toto");
> }
>
> but it's never called
>
> any idea welcome
>
> thanks
>
> Regards,
> Alexandre
Re: property changed and commandStack [message #238167 is a reply to message #238156] Thu, 30 August 2007 07:06 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: alexjaquet.gmail.com

Hi Renée, that's right actually that break the mvc pattern.

I need to add a something like a propertyChange listener on my edit part
, but there is no existing PropertyChangeListener except one from
java.beans package

If I want to add a listener my edit part should be able to register
correctly the listener

with an edit part we can only add :

-edit part listener
-node listener

Any other hints ?

Thanks for responding.

Regards,
Alexandre
Re: property changed and commandStack [message #238177 is a reply to message #238167] Thu, 30 August 2007 07:16 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: alexjaquet.gmail.com

... I can create a command on the edit part inside a notifyChanged but
there is no command stack inside an edit part

can I pass it at the creation time of the edit part?
Re: property changed and commandStack [message #238182 is a reply to message #238177] Thu, 30 August 2007 07:34 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: alexjaquet.gmail.com

I've tryed to add a command stack in my edit part, and created a command
and executed it by the command stack like this

public void notifyChanged(Notification notification) {

// notify the figure of any widget's property change
IFigure fig = getFigure();
if (fig != null && fig instanceof AbstractWidgetFigure) {
Object notifier = notification.getNotifier();
if (notifier instanceof Property) {
Property p = (Property) notifier;
FigureContext fc = getFigureFactory().getFigureContext();
String value = p.getValue();
if (! fc.isDesignMode()) {
// Translate the value in Preview mode
value = p.getI18nValue(fc.getLocale());
}
UpdatePropertyCommand command = new UpdatePropertyCommand(p,value);
this.commandStack.execute(command);
}

The problem who occurs is once the command is executed the notifyChanged
is re called (in loop) ...

Any other idea welcomed


Thanks

Regards,
Alexandre
Re: property changed and commandStack [message #238187 is a reply to message #238182] Thu, 30 August 2007 10:47 Go to previous message
René is currently offline RenéFriend
Messages: 45
Registered: July 2009
Member
Hi Alexandre,

You can use the property change support from java.beans. Have a look at
the shapes editor example
( http://www.eclipse.org/articles/Article-GEF-diagram-editor/s hape.html).
There is explained how to implement the property change support. The
full source can you find in the GEF examples.

Im not sure if you can use the notifyChanged support but i think the
porperty-change-support is a lot easier to implement.


Regrads
René


Alexandre Jaquet schrieb:
> I've tryed to add a command stack in my edit part, and created a command
> and executed it by the command stack like this
>
> public void notifyChanged(Notification notification) {
>
> // notify the figure of any widget's property change
> IFigure fig = getFigure();
> if (fig != null && fig instanceof AbstractWidgetFigure) {
> Object notifier = notification.getNotifier();
> if (notifier instanceof Property) {
> Property p = (Property) notifier;
> FigureContext fc = getFigureFactory().getFigureContext();
> String value = p.getValue();
> if (! fc.isDesignMode()) {
> // Translate the value in Preview mode
> value = p.getI18nValue(fc.getLocale());
> }
> UpdatePropertyCommand command = new UpdatePropertyCommand(p,value);
> this.commandStack.execute(command);
> }
>
> The problem who occurs is once the command is executed the notifyChanged
> is re called (in loop) ...
>
> Any other idea welcomed
>
>
> Thanks
>
> Regards,
> Alexandre
Previous Topic:Show a group of elements in a tip window?
Next Topic:FigureCanvas and automatic Scrollbars
Goto Forum:
  


Current Time: Sun Dec 21 21:47:31 GMT 2014

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

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