Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Xtext 2.4.2: What is CancelationIndicator ?(Cancelling a validation ???)
Xtext 2.4.2: What is CancelationIndicator ? [message #1075745] Tue, 30 July 2013 01:29 Go to next message
J A is currently offline J AFriend
Messages: 31
Registered: July 2013
Member
Dear all,

While reading the code of of a validator, I hit the CancelIndicator, and don't understand what is its purpose and how to see its effect.

Can someone provide me with a hint ?

// Initializing code, inside org.eclipse.xtext.validation.NamesAreUniqueValidator{}

Map context = AbstractDeclarativeValidator.getContext();
CancelIndicator cancelIndicator = (CancelIndicator) context.get(CancelableDiagnostician.CANCEL_INDICATOR);
...

// Client code
org.eclipse.xtext.validation.NamesAreUniqueValidationHelper{

	public void checkUniqueNames(Iterable<IEObjectDescription> descriptions, CancelIndicator cancelIndicator, ValidationMessageAcceptor acceptor)
	{
		Iterator iter = descriptions.iterator();
		if (!(iter.hasNext()))
			return;
		Map clusterToNames = Maps.newHashMap();
		while (iter.hasNext())
		{
			IEObjectDescription description = (IEObjectDescription) iter.next();
			checkDescriptionForDuplicatedName(description, clusterToNames, acceptor);
			if ((cancelIndicator != null) && (cancelIndicator.isCanceled()))
				return;
		}
	}

}

[Updated on: Tue, 30 July 2013 01:30]

Report message to a moderator

Re: Xtext 2.4.2: What is CancelationIndicator ? [message #1075763 is a reply to message #1075745] Tue, 30 July 2013 02:30 Go to previous messageGo to next message
Henrik Lindberg is currently offline Henrik LindbergFriend
Messages: 2509
Registered: July 2009
Senior Member
It is used to periodically check if the user (or the system) has
cancelled an operation running in the background.

Look at the source of:

org.eclipse.xtext.util.CancelIndicator

where there is a null implementation (i.e. one that always reports that
operation should not be cancelled).

Hope that helps.

- henrik

On 2013-30-07 3:29, J A wrote:
> Dear all,
>
> While reading the code of of a validator, I hit the CancelIndicator, and
> don't understand what is its purpose and how to see its effect.
>
> Can someone provide me with a hint ?
>
>
> // Initializing code, inside
> org.eclipse.xtext.validation.NamesAreUniqueValidator{}
>
> Map context = AbstractDeclarativeValidator.getContext();
> CancelIndicator cancelIndicator = (CancelIndicator)
> context.get(CancelableDiagnostician.CANCEL_INDICATOR);
> ...
>
> // Client code
> org.eclipse.xtext.validation.NamesAreUniqueValidationHelper{
>
> public void checkUniqueNames(Iterable<IEObjectDescription>
> descriptions, CancelIndicator cancelIndicator, ValidationMessageAcceptor
> acceptor)
> {
> Iterator iter = descriptions.iterator();
> if (!(iter.hasNext()))
> return;
> Map clusterToNames = Maps.newHashMap();
> while (iter.hasNext())
> {
> IEObjectDescription description = (IEObjectDescription)
> iter.next();
> checkDescriptionForDuplicatedName(description,
> clusterToNames, acceptor);
> if ((cancelIndicator != null) &&
> (cancelIndicator.isCanceled()))
> return;
> }
> }
>
> }
>
Re: Xtext 2.4.2: What is CancelationIndicator ? [message #1076311 is a reply to message #1075763] Wed, 31 July 2013 06:35 Go to previous message
J A is currently offline J AFriend
Messages: 31
Registered: July 2013
Member
Thank you Henrik. JA
Previous Topic:Validation speed: only validate what is new ?
Next Topic:Getting value of parser rules during runtime
Goto Forum:
  


Current Time: Wed Sep 25 01:57:27 GMT 2024

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

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

Back to the top