|
|
Re: Filtering proposals made by ReferenceProposalCreator [message #558702 is a reply to message #558689] |
Tue, 14 September 2010 06:25 |
Nimesh Mising name Messages: 23 Registered: March 2010 |
Junior Member |
|
|
Hi,
I have achieved something similar overriding method in <GrammarName>ProposalPropvider class. I have also added validation checks so that if the model is edited by typing instead of using proposal then it would still throw an error. Not sure whether this is appropriate mechanism but here it is.
@Override
public void completeRecordKey_RecordKeyProperties(EObject model,
Assignment assignment, ContentAssistContext context,
ICompletionProposalAcceptor acceptor) {
final RecordKey recordKey = (RecordKey)model;
final Entity entityOfRecordKey = (Entity)model.eContainer();
lookupCrossReference((CrossReference) assignment.getTerminal(),
context, acceptor, new Predicate<IEObjectDescription>() {
@Override
public boolean apply(IEObjectDescription input) {
SimpleProperty objectProperty = (SimpleProperty)input.getEObjectOrProxy();
return (objectProperty.eContainer() == entityOfRecordKey && !exists(objectProperty, recordKey));
}
private boolean exists(SimpleProperty objectProperty, RecordKey recordKey) {
return recordKey.getRecordKeyProperties().contains(objectProperty);
}
});
}
And in my <Grammar>JavaValidator class I have added a method.
@Check
public void checkNoDuplicatePropertiesInRecordKey(RecordKey recordKey) {
Set<SimpleProperty> uniqueProperties = new HashSet<SimpleProperty>(recordKey.getRecordKeyProperties());
if (uniqueProperties.size() != recordKey.getRecordKeyProperties().size()) {
error("Duplicate properties in record key [" + recordKey.getName() + "] definition", EntityPackage.RECORD_KEY);
}
}
Thanks.
Regards,
- Nimesh
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.02517 seconds