Validation for DirectEditFeatures [message #714339] |
Wed, 10 August 2011 11:11 |
Christian B Messages: 68 Registered: August 2011 |
Member |
|
|
Hi,
I'm working through the tutorial and i got to direct editing.
At this point some validation can be done, for example the following method in my DirectEditEClassFeature:
@Override
public String checkValueValid(String value, IDirectEditingContext context) {
if (value.length() < 1)
return "Please enter any text as class name.";
return null;
}
The problem is the value is not always checked. I can create an EClass, then the cursor is located in direct edit text field. If i click elsewhere in the diagram the focus is lost and i created an EClass with a name of length 0.
How can i ensure the validation at every point?
Previous in the tutorial a RenameEClassFeature is provided. With this feature i can rename an EClass and bypass the validation of the name of the Eclass.
Is there a way to include a central validation mechanic which is not bound to single features?
thanks for your help!
[Updated on: Wed, 10 August 2011 11:12] Report message to a moderator
|
|
|
|
Re: Validation for DirectEditFeatures [message #714368 is a reply to message #714357] |
Wed, 10 August 2011 12:39 |
Christian B Messages: 68 Registered: August 2011 |
Member |
|
|
thx for the fast answer!
If i want to ensure the user only creates valid eClasses are the following approaches good practices or can you think of another one?
- Set valid default value at eClass creation time
- At creation time a popup is displayed for the user which asks for the name of the Eclass. The user has to type in a valid name, otherwise the creation of the eClass gets cancelled
- An EClass can be created unvalidated, but it is marked with a symbol (graphiti offers such markups). The user can only save a valid diagram.
I know the way to go depends on purpose of the editor and its usecases, but i like to think about generell approaches for validation and best practices.
[Updated on: Wed, 10 August 2011 12:41] Report message to a moderator
|
|
|
Powered by
FUDForum. Page generated in 0.03652 seconds