blob: 425e9be6b85a42ef15b4f922f88f3f1f4988c138 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
/*******************************************************************************
* Copyright (c) 2012 TESIS DYNAware GmbH and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Torsten Sommer <torsten.sommer@tesis.de> - initial API and implementation
******************************************************************************/
package org.eclipse.fx.demo.contacts.model;
import org.eclipse.emf.common.command.BasicCommandStack;
import org.eclipse.emf.common.notify.AdapterFactory;
import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain;
import org.eclipse.emf.edit.domain.EditingDomain;
import org.eclipse.emf.edit.provider.ComposedAdapterFactory;
import org.eclipse.emf.edit.provider.ReflectiveItemProviderAdapterFactory;
import org.eclipse.emf.edit.provider.resource.ResourceItemProviderAdapterFactory;
import org.eclipse.fx.demo.contacts.Group;
import org.eclipse.fx.demo.contacts.provider.ContactsItemProviderAdapterFactory;
public class ContactsManagerImpl implements ContactsManager {
protected EditingDomain editingDomain;
protected VCardContactsResource contactsResource;
protected ComposedAdapterFactory adapterFactory;
public ContactsManagerImpl() {
adapterFactory = new ComposedAdapterFactory(ComposedAdapterFactory.Descriptor.Registry.INSTANCE);
adapterFactory.addAdapterFactory(new ResourceItemProviderAdapterFactory());
adapterFactory.addAdapterFactory(new ContactsItemProviderAdapterFactory());
adapterFactory.addAdapterFactory(new ReflectiveItemProviderAdapterFactory());
contactsResource = new VCardContactsResource();
BasicCommandStack commandStack = new BasicCommandStack();
editingDomain = new AdapterFactoryEditingDomain(adapterFactory, commandStack);
editingDomain.getResourceSet().getResources().add(contactsResource);
}
public AdapterFactory getAdapterFactory() {
return adapterFactory;
}
public EditingDomain getEditingDomain() {
return editingDomain;
}
@Override
public Group getRootGroup() {
return (Group) contactsResource.getContents().get(0);
}
}
|