Xtext 2.4.2: What is CancelationIndicator ? [message #1075745] |
Tue, 30 July 2013 01:29 |
J A 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 |
Henrik Lindberg 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;
> }
> }
>
> }
>
|
|
|
|
Powered by
FUDForum. Page generated in 0.02765 seconds