| [news.eclipse.tools.emf] Re: [EMF] PropertyType of an EStructuralFeature |
Sebastian,
Comments below.
Cool.Thanks for your answer,
I think at first I try to explain, what im doing here:
I'm developing an automated document export, where each ModelElement of our Application can be rendered to a document (i.e. PDF).
Therefore, I created template, which defines how each Model is rendered.It sounds like you'd want to use the GenModel as input to this generator. The org.eclipse.emf.example.generator shows how to do this type of thing extending the generator. The org.eclipse.emf.example.exporter.html sounds very similar too.
Now there is a DefaultModelElementRenderer, which automatically renders each property of the Model. There shall be options for each property of each Model type, which can be edited in the Template Manager.Maybe you could generate the information you need? Do you need this information only at generation time or at runtime?
Thats why i need a function, which creates the default document renderer with the default model renderers without having access to real existing Model instances.
There are some properties, i never want to be rendered to my document. The Property descriptors do exactly what i want to do:It is possible to find the corresponding GenModel at runtime. E.g., EcorePlugin.getEPackageNsURIToGenModelLocationMap keeps a map of nsURIs to the *.genmodel location of a GenModel that will contain a GenPackage with an EPackage whose nsURI matches the given one. That EPackage is the development time version of your generated EPackage...
Vector<IItemPropertyDescriptor> ret = new Vector<IItemPropertyDescriptor>();
AdapterFactoryItemDelegator adapterFactoryItemDelegator = new AdapterFactoryItemDelegator(new ComposedAdapterFactory(ComposedAdapterFactory.Descriptor.Registry.INSTANCE));
List<IItemPropertyDescriptor> propertyDescriptors = adapterFactoryItemDelegator.getPropertyDescriptors(modelElement);
for (IItemPropertyDescriptor propertyDescriptor : propertyDescriptors) {
EStructuralFeature feature = (EStructuralFeature)propertyDescriptor.getFeature(modelElement);
}
This is how im doing it right now. The Problem is: When i create a Default document template, i dont have access to real existing Instances of each Model type. Currently, im doing a funny workaround: There is a Project Generator for test purposes in our application. I create a new very big project, to ensure, that every model type is in this project, and then i create the defult document renderer by getting a full list of all model types in this project and their descriptors.
If there isn't a possibility to read the PropertyType of the GenModel at runtime, then i should try to generate an instance of each Model typ, and use the PropertyDescriptor, but I yet dont know how to create an instance of each model type automatically.
I think i have to figure this out, when it's impossible to read the GenModel.You could of course always add an EAnnotation to your EStructuralFeatures to mark the ones that you want to export to PDF and thereby have the information easily available at runtime (completely independent of what the properties sheet does).
Ed Merks schrieb:Sebastian,
Comments below.
Sebastian Höcht wrote:We'll let it go this time and then hold you to a higher standard. :-PHi,
this is my first newsgroup entry, and im very new to EMF, so maybe my question is inaccurate.Like doing EPackage.getEClassifiers and for each EClass, calling getEAllStructurals or getEStructuralFeatures depending on whether you want inherited ones or not.
I'm trying to get a full list of all models types of our application with all their properties.But there are different kind of properties. Some can be edited in anGenerally we try to ensure that by default all changeable features are editable either directly in the tree view (containment references) or via the properties view (all other references and all attributes).
Editor, and some are just invisible.This information is available on the GenFeature that decorates each EStructuralFeature. The information is not generally available at runtime...I've heard of a property called "PropertyType" which defines if a property of a model can be edited in an Editor or not.But i neither know where i can find this, nor how iNo, it's only available in the GenModel (the *.genmodel) not in the Ecore model (the *.ecore).
can get the value of the PropertyType. Maybe there is something in the EClassifier?Perhaps you should be doing this using the item providers. E.g., adapterFactoryContentProvider.getPropertySource(someInstance) and from that you can get all the property descriptors.
I already figured out, how to get a full list of all model types (EClass). Then i use myEClass.getEAllStructuralFeatures(); But i only want to get all features, that are editable in an editor.
I wonder what problem you're trying to solve. I might have a better answer based on knowing the purpose...
I appreciate any suggestions.