Java 类org.eclipse.emf.ecore.util.EcoreAdapterFactory 实例源码

项目:xtext-core    文件:CompositeNodeTest.java   
@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);
}
项目:Environment    文件:OICEditor.java   
@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();
    }

}
项目:Environment    文件:EditDiagramEditor.java   
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());
}