Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » Guarantee uniqueness of labels
Guarantee uniqueness of labels [message #227203] Thu, 30 November 2006 13:09 Go to next message
Eclipse UserFriend
Originally posted by: beconico.gmail.com

Hi!

I am working in an editor where objects are labeled. Each label should be
unique. Therefore, when a label is edited (directly or using the
Properties View), I would like to check its uniqueness. If there already
exists a similar label the change should not be allowed. What is the
simplest way to do this?

Thanks,
Nicolás
Re: Guarantee uniqueness of labels [message #227217 is a reply to message #227203] Thu, 30 November 2006 17:54 Go to previous messageGo to next message
Alex Boyko is currently offline Alex BoykoFriend
Messages: 200
Registered: July 2009
Senior Member
Hi Nicholas,

I'd suggest you to perform the validation for label uniqueness on the
model side, not on the GEF side. When you set the new label text for one
of your elements, there must a command created for that. In your command
canExecute() method you can do this validation, but the validation should
work with the model.
To track which command is being created for direct editing look at the
DirectEditPolicy or you edit policy deriving from it (this is only if you
have label direct editing functionality).
Hope this helps.

Cheers,
Alex
Re: Guarantee uniqueness of labels [message #227263 is a reply to message #227217] Fri, 01 December 2006 08:50 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: beconico.gmail.com

Thanks for your answer Alex!

Now I can efficiently control when the id of my object is changed when its
associated graphical label is directly edited. For that I have created a
dedicated command (before the command that was executed was used by all
EditParts), so only the check is not performed for all objects, but only
for those of the type I want.

However, I still have the problem of edition through the Properties view.
I thought on doing something similar, that is, do my validation on the
canExecute() method of the command that is to be executed. However, I do
not know how to associate a dedicated command with such edition. If I
implement the validation in the "general" command, the check will be
performed evry time a property for whatever object is changed, and I would
not like that. Any idea here?

I have tried to do the validation in the setId() method of my EMF object.
The id is only updated if its different from any existing one. The result
is what I want, but I think the solution is not very elegant, since the
command stack gets filled with commands that were executed without actual
changes. So if I select "undo" from the menu, nothing happens in practice.

Any help is very appreciated. Thanks

Nicolás
Re: Guarantee uniqueness of labels [message #227290 is a reply to message #227263] Fri, 01 December 2006 20:18 Go to previous messageGo to next message
Alex Boyko is currently offline Alex BoykoFriend
Messages: 200
Registered: July 2009
Senior Member
Hi Nicolas,

First of all, I had a feeling this would be the next question... Well, the
solution for this problem won't be very pretty. UndoablePropertySheetEntry
is used for GEF properties view. It is in charge of creating commands for
IPropertySource entries value modifications in the properties view. The
command created by UndoablePropertySheetEntry for a value modification is
SetValueCommand, which calls setPropertyValue on your model object and the
value applied to the model object. I'd suggest you to extend
UndoablePropertySheetEntry to create a different command for that specific
"label" property or append an Unexecutable command to a CompoundCommand
inside which SetValueCommand is wrapped. You can hook your own undoable
property sheet entries by overriding #getAdapter(Class) method in your
editor class (look at how it's done in GEF's
GraphicalEditor#getAdapter(Class) method).
Once, I saw that someone on the news group was trying to create a more
complex command than SetValueCommand from the property sheet entry. The
response from Pratik Shah (one of the GEF developers) was to extend
UndoablePropertySheetEntry and override getAdapter(Class) method, which
is what I'm advising you to do for this problem. So, this is probably a
better solution to go with... unless someone else will propose something
better.

Cheers,
Alex
Re: Guarantee uniqueness of labels [message #227326 is a reply to message #227290] Sun, 03 December 2006 17:53 Go to previous message
Eclipse UserFriend
Originally posted by: beconico.gmail.com

Thanks! I will try that.

Cheers,
Nicolás
Previous Topic:Which version for eclipse 3.0.2?
Next Topic:Best way to refresh GraphicalEditor when resource changes outside GEF
Goto Forum:
  


Current Time: Wed May 15 02:27:02 GMT 2024

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

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

Back to the top