Java Code Examples for org.eclipse.emf.ecore.util.EcoreAdapterFactory

The following are top voted examples for showing how to use org.eclipse.emf.ecore.util.EcoreAdapterFactory. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: xtext-core   File: CompositeNodeTest.java   Source Code and License 5 votes vote down vote up
@Test public void testIsAdapterForType() {
	EObject object = EcoreFactory.eINSTANCE.createEObject();
	CompositeNodeWithSemanticElement node = createCompositeNode();
	object.eAdapters().add(node);
	AdapterFactory adapterFactory = new EcoreAdapterFactory();
	Adapter adapter = adapterFactory.adapt(object, INode.class);
	assertSame(node, adapter);
	// the following line may not throw a ClassCastException
	Adapter secondAdapter = adapterFactory.adapt(object, new Object());
	assertNull(secondAdapter);
}
 
Example 2
Project: Environment   File: OICEditor.java   Source Code and License 5 votes vote down vote up
@Override
protected void createPages() {
	
	OICEditorInput editorInput = (OICEditorInput)getEditorInput();
	OperationInterfaceContainer oic = editorInput.getOperationInterfaceContainer();
	
	EditingDomain ed = TransactionUtil.getEditingDomain(oic);
	
	adapterFactory = new ComposedAdapterFactory(ComposedAdapterFactory.Descriptor.Registry.INSTANCE);
	adapterFactory.addAdapterFactory(new ResourceItemProviderAdapterFactory());
	adapterFactory.addAdapterFactory(new ApplicationAdapterFactory());
	adapterFactory.addAdapterFactory(new ArchitectureAdapterFactory());
	adapterFactory.addAdapterFactory(new ParametertypeAdapterFactory());
	adapterFactory.addAdapterFactory(new OverviewAdapterFactory());
	adapterFactory.addAdapterFactory(new ReflectiveItemProviderAdapterFactory());
	adapterFactory.addAdapterFactory(new EcoreAdapterFactory());
	
	editingDomain = new AdapterFactoryEditingDomain(adapterFactory, ed.getCommandStack());
	
	try {
		this.importEditor = new ImportEditor();
		//this.importEditor.init(getEditorSite(), getEditorInput());
		
		int pageIndex = addPage(importEditor, getEditorInput());
		setPageText(pageIndex, "Import");
		
		this.interfacesEditor = new InterfacesEditor(this);
		//this.interfacesEditor.init(getEditorSite(), getEditorInput());
		
		pageIndex = addPage(interfacesEditor, getEditorInput());
		System.out.println(pageIndex);
		setPageText(pageIndex, "Provided interfaces");
		
		setActiveEditor(interfacesEditor);
	} catch (PartInitException e) {
		e.printStackTrace();
	}
	
}
 
Example 3
Project: Environment   File: EditDiagramEditor.java   Source Code and License 5 votes vote down vote up
public EditDiagramEditor() {
	adapterFactory = new ComposedAdapterFactory(ComposedAdapterFactory.Descriptor.Registry.INSTANCE);
	adapterFactory.addAdapterFactory(new ResourceItemProviderAdapterFactory());
	adapterFactory.addAdapterFactory(new MethodItemProviderAdapterFactory());
	adapterFactory.addAdapterFactory(new ReflectiveItemProviderAdapterFactory());
	adapterFactory.addAdapterFactory(new EcoreAdapterFactory());
}