本文整理匯總了Java中org.eclipse.emf.ecore.EValidator類的典型用法代碼示例。如果您正苦於以下問題:Java EValidator類的具體用法?Java EValidator怎麽用?Java EValidator使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
EValidator類屬於org.eclipse.emf.ecore包,在下文中一共展示了EValidator類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: setMarkerAttibutes
import org.eclipse.emf.ecore.EValidator; //導入依賴的package包/類
/**
* Sets attributes for the given {@link IMarker}.
*
* @param marker
* the {@link IMarker}
* @param resource
* the {@link IFile} containing the mode
* @param instruction
* the {@link EObject} representing the instruction
* @param persistent
* should be persisted
* @throws CoreException
* if attributes can't be set
*/
protected void setMarkerAttibutes(final IMarker marker, IFile resource, EObject instruction,
boolean persistent) throws CoreException {
final IItemLabelProvider provider = (IItemLabelProvider)ADAPTER_FACTORY.adapt(instruction,
IItemLabelProvider.class);
marker.setAttribute(IBreakpoint.ENABLED, true);
marker.setAttribute(IBreakpoint.PERSISTED, persistent);
marker.setAttribute(IBreakpoint.ID, getModelIdentifier());
marker.setAttribute(EValidator.URI_ATTRIBUTE, EcoreUtil.getURI(instruction).toString());
final String instructionText = provider.getText(instruction);
marker.setAttribute(IMarker.MESSAGE, "DSL Breakpoint: " + resource.getFullPath() + " ["
+ instructionText + "]");
try {
marker.setAttribute(IMAGE_ATTRIBUTE, toAttribute(provider.getImage(instruction)));
} catch (IOException e) {
Activator.getDefault().error(e);
}
marker.setAttribute(TEXT_ATTRIBUTE, instructionText);
}
示例2: showInstruction
import org.eclipse.emf.ecore.EValidator; //導入依賴的package包/類
/**
* Show the given {@link EObject instruction}.
*
* @param editorPart
* the opened {@link DialectEditor}
* @param instruction
* the {@link EObject instruction} to show
*/
public static void showInstruction(DialectEditor editorPart, EObject instruction) {
final URI resourceURI = instruction.eResource().getURI();
if (resourceURI.isPlatformResource()) {
final String resourcePath = resourceURI.toPlatformString(true);
final IResource resource = ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(
resourcePath));
try {
final IMarker marker = resource.createMarker(EValidator.MARKER);
marker.setAttribute(EValidator.URI_ATTRIBUTE, EcoreUtil.getURI(instruction).toString());
final TraceabilityMarkerNavigationProvider navigationProvider = new TraceabilityMarkerNavigationProvider(
(DialectEditor)editorPart);
navigationProvider.gotoMarker(marker);
marker.delete();
} catch (CoreException e) {
DebugSiriusIdeUiPlugin.INSTANCE.log(e);
}
}
}
示例3: validate
import org.eclipse.emf.ecore.EValidator; //導入依賴的package包/類
@Override
public boolean validate ( final EObject eObject, final DiagnosticChain diagnostics, final Map<Object, Object> context )
{
boolean result = true;
for ( final EValidator v : this.otherValidators )
{
if ( !v.validate ( eObject, diagnostics, context ) )
{
result = false;
}
}
ValidationPlugin.runValidation ( eObject, diagnostics, context );
return result;
}
示例4: setup
import org.eclipse.emf.ecore.EValidator; //導入依賴的package包/類
/**
* Registers validators.
*/
static void setup() {
final EValidator.Registry registry = EValidator.Registry.INSTANCE;
registry.put(TypesPackage.eINSTANCE, new TypesValidator());
registry.put(ModulesPackage.eINSTANCE, new ModulesValidator());
registry.put(ResourcesPackage.eINSTANCE, new ResourcesValidator());
registry.put(ResponsesPackage.eINSTANCE, new ResponsesValidator());
final RamlObjectValidator ramlObjectValidator = new RamlObjectValidator();
for (final EPackage ePackage : PACKAGES) {
final CompositeValidator compositeValidator = new CompositeValidator();
compositeValidator.add(ramlObjectValidator);
final EValidator validator = registry.getEValidator(ePackage);
if (validator != null) {
compositeValidator.add(validator);
}
registry.put(ePackage, compositeValidator);
}
}
示例5: equals
import org.eclipse.emf.ecore.EValidator; //導入依賴的package包/類
@Override
public boolean equals(Object obj) {
if (!(obj instanceof EValidatorEqualitySupport))
return false;
EValidator otherDelegate = ((EValidatorEqualitySupport) obj).getDelegate();
if (otherDelegate.getClass().equals(getDelegate().getClass())) {
if (delegate instanceof AbstractInjectableValidator) {
AbstractInjectableValidator casted = (AbstractInjectableValidator) getDelegate();
AbstractInjectableValidator otherCasted = (AbstractInjectableValidator) otherDelegate;
if (casted.isLanguageSpecific() == otherCasted.isLanguageSpecific()) {
if (casted.isLanguageSpecific()) {
return Objects.equal(casted.getLanguageName(), otherCasted.getLanguageName());
}
return true;
}
return false;
}
return true;
}
return false;
}
示例6: makeCopyOfGlobalState
import org.eclipse.emf.ecore.EValidator; //導入依賴的package包/類
public static GlobalStateMemento makeCopyOfGlobalState() {
GlobalStateMemento memento = new GlobalStateMemento();
memento.validatorReg = new HashMap<EPackage, Object>(EValidator.Registry.INSTANCE);
for(Map.Entry<EPackage, Object> validatorEntry: memento.validatorReg.entrySet()) {
Object existingValue = validatorEntry.getValue();
if (existingValue instanceof CompositeEValidator) {
validatorEntry.setValue(((CompositeEValidator) existingValue).getCopyAndClearContents());
}
}
memento.epackageReg = new HashMap<String, Object>(EPackage.Registry.INSTANCE);
memento.protocolToFactoryMap = new HashMap<String, Object>(Resource.Factory.Registry.INSTANCE.getProtocolToFactoryMap());
memento.extensionToFactoryMap = new HashMap<String, Object>(Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap());
memento.contentTypeIdentifierToFactoryMap = new HashMap<String, Object>(Resource.Factory.Registry.INSTANCE.getContentTypeToFactoryMap());
memento.protocolToServiceProviderMap = new HashMap<String, Object>(IResourceServiceProvider.Registry.INSTANCE.getProtocolToFactoryMap());
memento.extensionToServiceProviderMap = new HashMap<String, Object>(IResourceServiceProvider.Registry.INSTANCE.getExtensionToFactoryMap());
memento.contentTypeIdentifierToServiceProviderMap = new HashMap<String, Object>(IResourceServiceProvider.Registry.INSTANCE.getContentTypeToFactoryMap());
return memento;
}
示例7: ValidatorTester
import org.eclipse.emf.ecore.EValidator; //導入依賴的package包/類
@Inject
public ValidatorTester(T validator, EValidatorRegistrar registrar, @Named(Constants.LANGUAGE_NAME) final String languageName) {
this.validator = validator;
EValidator.Registry originalRegistry = registrar.getRegistry();
EValidatorRegistryImpl newRegistry = new EValidatorRegistryImpl();
registrar.setRegistry(newRegistry);
this.validator.register(registrar);
diagnostician = new Diagnostician(newRegistry) {
@Override
public java.util.Map<Object,Object> createDefaultContext() {
java.util.Map<Object,Object> map = super.createDefaultContext();
map.put(AbstractInjectableValidator.CURRENT_LANGUAGE_NAME, languageName);
return map;
}
};
registrar.setRegistry(originalRegistry);
validatorCalled = false;
}
示例8: testBug_279962
import org.eclipse.emf.ecore.EValidator; //導入依賴的package包/類
@Test public void testBug_279962() {
EValidator validator = registry.getEValidator(pack);
assertTrue(validator instanceof CompositeEValidator);
CompositeEValidator composite = (CompositeEValidator) validator;
int prevSize = composite.getContents().size();
get(Val_279962_01.class);
get(Val_279962_04.class);
assertEquals(prevSize + 2, composite.getContents().size());
assertNotNull(validator);
Resource resource = get(XtextResource.class);
Model model = EnumRulesTestLanguageFactory.eINSTANCE.createModel();
resource.getContents().add(model);
// do not expect an exception
validator.validate(model, new BasicDiagnostic(), null);
assertEquals(prevSize + 4, composite.getContents().size());
}
示例9: setUp
import org.eclipse.emf.ecore.EValidator; //導入依賴的package包/類
@Override
public void setUp() throws Exception {
super.setUp();
with(XtextStandaloneSetup.class);
EValidator.Registry.INSTANCE.put(EcorePackage.eINSTANCE, EcoreValidator.INSTANCE);
File tempFile = File.createTempFile("XtextValidationTest", ".ecore");
tempFile.deleteOnExit();
Files.write("<?xml version='1.0' encoding='UTF-8'?>" +
"<ecore:EPackage xmi:version='2.0' xmlns:xmi='http://www.omg.org/XMI'"+
" xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'"+
" xmlns:ecore='http://www.eclipse.org/emf/2002/Ecore'"+
" name='XtextValidationBugs'"+
" nsURI='http://XtextValidationBugs'"+
" nsPrefix='XtextValidationBugs'>"+
" <eClassifiers xsi:type='ecore:EClass' name='Bug322875'>"+
" <eStructuralFeatures xsi:type='ecore:EReference' name='referencesETypeFromClasspathPackage' eType='ecore:EClass classpath:/org/eclipse/xtext/Xtext.ecore#//Grammar'/>"+
" </eClassifiers>"+
"</ecore:EPackage>"
, tempFile, StandardCharsets.UTF_8);
xtextValidationTest_ecore = tempFile.toURI().toURL();
}
示例10: gotoMarker
import org.eclipse.emf.ecore.EValidator; //導入依賴的package包/類
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void gotoMarker(IMarker marker) {
try {
if (marker.getType().equals(EValidator.MARKER)) {
String uriAttribute = marker.getAttribute(EValidator.URI_ATTRIBUTE, null);
if (uriAttribute != null) {
URI uri = URI.createURI(uriAttribute);
EObject eObject = editingDomain.getResourceSet().getEObject(uri, true);
if (eObject != null) {
setSelectionToViewer(Collections.singleton(editingDomain.getWrapper(eObject)));
}
}
}
}
catch (CoreException exception) {
ModelEditorPlugin.INSTANCE.log(exception);
}
}
示例11: getAdapter
import org.eclipse.emf.ecore.EValidator; //導入依賴的package包/類
/**
* {@inheritDoc}
*
* @see org.eclipse.mylyn.docs.intent.mapping.ide.adapter.IMarkerToLocationDescriptor#getAdapter(org.eclipse.core.resources.IMarker)
*/
public ILocationDescriptor getAdapter(IMarker marker) {
ILocationDescriptor res = null;
try {
if (marker.isSubtypeOf(EValidator.MARKER)) {
final String uri = (String)marker.getAttribute(IEObjectLocationMaker.URI_ATTRIBUTE);
// TODO we should change this to use a global ResourceSet...
final ResourceSet rs = new ResourceSetImpl();
final EObject eObject = rs.getEObject(URI.createURI(uri), true);
res = IdeMappingUtils.adapt(eObject, ILocationDescriptor.class);
}
} catch (CoreException e) {
Activator.getDefault().getLog().log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(),
e));
}
return res;
}
示例12: execute
import org.eclipse.emf.ecore.EValidator; //導入依賴的package包/類
public static List<Diagnostic> execute(Model model){
OCLstdlibStandaloneSetup.doSetup();
EssentialOCLStandaloneSetup.doSetup();
CompleteOCLStandaloneSetup.doSetup();
OCLstdlib.install();
OCL ocl = OCL.newInstance();
List<String> oclFilePaths = new ArrayList<String>();
oclFilePaths.add("model/ontouml.ocl");
if(checkTypes) oclFilePaths.add("model/types.ocl");
if(checkRelationships) oclFilePaths.add("model/relationships.ocl");
if(checkMetaAttributes) oclFilePaths.add("model/metaattributes.ocl");
if(checkBinaryProperties) oclFilePaths.add("model/binproperties.ocl");
if(checkDependencies) oclFilePaths.add("model/dependency.ocl");
if(checkCardinalities) oclFilePaths.add("model/cardinalities.ocl");
ComposedEValidator composed = ComposedEValidator.install(OntoumlPackage.eINSTANCE);
for(String oclPath: oclFilePaths){
File file = new File(oclPath);
URI oclURI = URI.createFileURI(file.getAbsolutePath());
CompleteOCLEObjectValidator myValidator = new CompleteOCLEObjectValidator(OntoumlPackage.eINSTANCE, oclURI, ocl.getEnvironmentFactory());
EValidator.Registry.INSTANCE.put(OntoumlPackage.eINSTANCE, myValidator);
composed.addChild(myValidator);
}
Diagnostic diagnostics = Diagnostician.INSTANCE.validate(model);
return diagnostics.getChildren();
}
示例13: gotoMarker
import org.eclipse.emf.ecore.EValidator; //導入依賴的package包/類
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void gotoMarker(IMarker marker) {
try {
if (marker.getType().equals(EValidator.MARKER)) {
String uriAttribute = marker.getAttribute(
EValidator.URI_ATTRIBUTE, null);
if (uriAttribute != null) {
URI uri = URI.createURI(uriAttribute);
EObject eObject = editingDomain.getResourceSet()
.getEObject(uri, true);
if (eObject != null) {
setSelectionToViewer(Collections
.singleton(editingDomain.getWrapper(eObject)));
}
}
}
} catch (CoreException exception) {
bpmn2EditorPlugin.INSTANCE.log(exception);
}
}
示例14: gotoMarker
import org.eclipse.emf.ecore.EValidator; //導入依賴的package包/類
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void gotoMarker(IMarker marker) {
try {
if (marker.getType().equals(EValidator.MARKER)) {
String uriAttribute = marker.getAttribute(EValidator.URI_ATTRIBUTE, null);
if (uriAttribute != null) {
URI uri = URI.createURI(uriAttribute);
EObject eObject = editingDomain.getResourceSet().getEObject(uri, true);
if (eObject != null) {
setSelectionToViewer(Collections.singleton(editingDomain.getWrapper(eObject)));
}
}
}
}
catch (CoreException exception) {
NotationEditorPlugin.INSTANCE.log(exception);
}
}
示例15: gotoMarker
import org.eclipse.emf.ecore.EValidator; //導入依賴的package包/類
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void gotoMarker(IMarker marker) {
try {
if (marker.getType().equals(EValidator.MARKER)) {
String uriAttribute = marker.getAttribute(EValidator.URI_ATTRIBUTE, null);
if (uriAttribute != null) {
URI uri = URI.createURI(uriAttribute);
EObject eObject = editingDomain.getResourceSet().getEObject(uri, true);
if (eObject != null) {
setSelectionToViewer(Collections.singleton(editingDomain.getWrapper(eObject)));
}
}
}
}
catch (CoreException exception) {
HistoryEditorPlugin.INSTANCE.log(exception);
}
}