@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); }
@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(); } }
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()); }