|
|
Re: [EMFForms] Adding model instances to the "running" instance [message #1741898 is a reply to message #1741709] |
Tue, 30 August 2016 13:56 |
Peter Hermsdorf Messages: 44 Registered: August 2011 |
Member |
|
|
Hi Jonas,
thanks for the pointer - that helped get going.
I now use a custom ReferenceService which extends from DefaultReferenceService. Because I wanted to provide a pre-defined List of Objects for my reference I did the following:
@Override
public void addExistingModelElements(final EObject eObject, final EReference eReference) {
if (eReference.getEReferenceType().getInstanceClass().equals(MyRole.class)) {
final Set<EObject> elements = createRoleObjects();//loads them from DB and creates instances
ECPControlHelper.removeExistingReferences(eObject, eReference, elements);
final Set<EObject> addedElements = SelectModelElementWizardFactory.openModelElementSelectionDialog(elements,
eReference.isMany());
ECPControlHelper.addModelElementsInReference(eObject, addedElements, eReference, editingDomain);
} else {
super.addExistingModelElements(eObject, eReference);
}
}
Since I'm very new to EMF and EMFForms I guess it's not the A+ solution, but it works for now (any hints on improving are welcome!)
Additionally I wanted to remove the "Add Button" and customize the icons. The UI seems to come from the class MultiReferenceSWTRenderer. What would be the best way to customize the ui (remove button, change images)?
Since the class is in an internal package, a lot of code would have to be copied to create a customized version of the renderer, just for changing the name of an image and to implement showAddNewButton() to return false....
Thanks for any hints!
regards, peter
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.02839 seconds