1.
Emf.edit
a)
Note: Emf.edit is located between EMF.Editor and Emf.ecore, and he has a role of a intermediaries. He is responsible for converting requests related to the UI of Emf.Editor into a call that is unrelated to the UI of EMF.ECORE. He needs to provide the following four features: implement ContentProvider and LabelProvider for supporting Viewer display; implement iPropertySource for supporting attributes; implementing Command framework for supporting models; implementing Framework for supporting modification notifications.
b)
ContentProvider and LabelProvider
i.
Photo:
II.
Note: When TreeViewer needs to display content, call her iContentProvider's getChildren (Object Obj) method. This method will be forwarded to the internal of AdapterFactoryContentProvider. She is acquired by ItemProviderAdapterFactory her referenced a ITreeItemContentProvider type Adapter of obj, and the Adapter generated by the EMF corresponding ECore model a ItemProviderAdapter (here TeacherItemProvider), the final desired displayed by the TeacherItemProvider responsible for generating child nodes List.
III.
Code:
Public Class AdapterFactoryContentProvider Implements ItreeContentProvider {
Public Object [] getChildren (Object Object) {
ItreeItemContentProvider TreeItemContentProvider =
(ItreeItemContentProvider) AdapterFactory.Adapt (Object,
ItreeItemContentProvider.class;
Return TreeItemContentProvider.getChildren (Object);
}
}
Note: Red is a UI-related request, blue is a UI-independent adapter class, pink is a request that is unrelated to the UI.
c)
IPropertySource
i.
Photo:
II.
Note: When PropertySheetPage needs to display the properties, he accesses his iPropertySourceProvider's getPropertySource (Object Obj) method. This method will be forwarded to the internal of AdapterFactoryContentProvider. She is acquired by ItemProviderAdapterFactory she cited a IItemPropertySource type of Adapter for obj. This Adapter is generated by the EMF a ItemProviderAdapter corresponds to ECore model (here TeacherItemProvider), and finally the need to show the this TeacherItemProvider responsible for generating the list of properties .
III.
Code:
Public class adapterfactoryContentProvider imports iPropertySourceProvider {
Public iPropertySource GetPropertySource (Object Object) {
ItemPropertySource ItemPropertySource = (IIITEMPROPERTYSOURCE)
AdapterFactory.Adapt (Object, IIITEMPROPERTYSOURCE.CLASS); ...
}
}
d)
Command Framework
i.
Photo:
II.
Explanation: Since EMF.Editor does not understand the underlying model details, he cannot operate directly, he needs to generate some Command objects for operating the model. When Editor needs to modify the model, he created a Command object for model operation by calling his CreateCommand (EDITINGDOMAIN) method. This method will last forward to Domain's createcommand (), then Domain will be referenced according to he ItemProvideradapterFactory is getting an IEDITINGDOMAINITEMPROVIDER adapter, which is finally generated for a Command object for operating the model.
III.
Code:
Public class deleteAction extends commandActionHandler {
Public Command CreateCommand (Collection Selection) {
Return RemoveCommand.create (Domain, Selection);
}
}
Public class removecommand extends abstractOverrideableCommand {
Public Static Command Create (...) {
Return domain.createCommand (...);
}
}
Public class adapterfactoryeddomain imports editingdomain {
Public Command CreateCommand (...) {
IEditingDomainItemProvider EditingDomainItemProvider =
AdapterFactory.Adapt (Owner,
IEditingDomainItemProvider.class);
Return EditingDomainItemProvider.createCommand (...);
}
}
Note: When the command is required, Editor will call the CommandStack on EditingDomain and call the Execute (Command C) method above.
e)
Notify Framework
i.
Photo:
II.
Description: When we modify the value of the model, the model will issue an update notification to the ItemProvider, which is then forwarded to ItemProvideradapterFactory, and then eventually send it to the AdapterFactoryContentProvider, and he is responsible for updating the corresponding viewer.