Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Graphiti » Validation for DirectEditFeatures
Validation for DirectEditFeatures [message #714339] Wed, 10 August 2011 11:11 Go to next message
Christian B is currently offline Christian BFriend
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 #714357 is a reply to message #714339] Wed, 10 August 2011 12:04 Go to previous messageGo to next message
Matthias Gorning is currently offline Matthias GorningFriend
Messages: 81
Registered: April 2010
Location: Germany
Member
Hi,

How can i ensure the validation at every point?

Currently it is not possible. The validation method will only called if the user types in the text cell editor.

I think the creation of new object is a special case. In the example a default value doesn't make sense and to start the creation of a new object with an error hint is also the wrong way.

Is there a way to include a central validation mechanic which is not bound to single features?

There is no way in Graphiti to centralize the validation mechanism. It's in the responsibility of the Graphiti user to organize the validation stuff in a way, so that it can be used multiple, e.g. in the direct editing feature and also in the rename feature.

BR,
Matthias
Re: Validation for DirectEditFeatures [message #714368 is a reply to message #714357] Wed, 10 August 2011 12:39 Go to previous message
Christian B is currently offline Christian BFriend
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

Previous Topic:Load Diagram from File in RCP
Next Topic:Properties and Listeners
Goto Forum:
  


Current Time: Thu Apr 25 11:05:45 GMT 2024

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

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

Back to the top