PropertySource of the Stereotypes

52 views
Skip to first unread message

Emre Taspolatoglu

unread,
May 8, 2013, 12:42:53 PM5/8/13
to emf-pr...@googlegroups.com
Hello there again!

I have a small question. I was trying to locate the property source of the defined and to a model applied stereotypes in the profile applications, which are being shown in the EMFPRofileApplicationsView. After loading them manually we get their properties shown as a standard list view in the Eclipse properties view.

I tried to locate them by using the Eclipse Spy, but somehow I can't be sure whether I have landed on the correct class, which actually needs to either extend IPropertySource or implement IAdaptable. But since these extension or the implementations don't have to be directly (as far as I know EObject or EClass also provide a property source to be queried), I wasn't sure if I am on the right path.

I believe that what I am looking for is "StereotypeApplicationImpl"? Another reason, why I cannot be sure, whether this is the right class to query for a property source is that EMF-Profiles unfortunately does not support the tabbed properties view, and therefor I cannot endorse if it is the correct input type as a property source for an extension of the properties view.

Your help will be very appreciated. Thanks a lot!

Emre


Philip Langer

unread,
May 12, 2013, 3:46:50 PM5/12/13
to emf-pr...@googlegroups.com
Hi Emre,

sorry for the delay!

The EMFProfileApplicationsView adapts to IPropertySheetPage and provides the basic PropertySheetPage that uses the ReflectiveItemProviderAdapterFactory as a PropertySourceProvider; see
org.modelversioning.emfprofile.application.registry.ui.views.EMFProfileApplicationsView.getPropertySheetPage().

We use the reflective item provider adapter since the stereotype applications are dynamic instances and we have no generated code for the specific stereotypes.

Is that what you were asking? Do you want to customize the property view? If yes, we can think about creating a more customizable subclass of the reflective item provider that is used for the property sheet page. We had something in mind already earlier but never implemented it.

Best wishes,

Philip

Emre Taspolatoglu

unread,
May 12, 2013, 4:29:37 PM5/12/13
to emf-pr...@googlegroups.com
Hello Philip,

no worries about any delay. As long as I get your help. :)

In the mean time, I had some time to look more into the the source code and I got a little bit closer to what I had in mind. For the better understanding I list my thoughts as follows:

1.) Yes, I would like to revise the Properties View for the Stereotypes etc. For that I have built a seperate plug-in, which contributes to the Eclipse Properties View. First of all, since I wanted to use the tabbed properties view, I had to change some parts in the EMFProfileApplicationsView as follows:

    @Override
    public Object getAdapter(@SuppressWarnings("rawtypes") Class adapter) {
        if (adapter.equals(IPropertySheetPage.class)) {
//            return getPropertySheetPage();
            return new TabbedPropertySheetPage(this);
        } else {
            return super.getAdapter(adapter);
        }
    }

and

    @Override
    public String getContributorId() {
        return getSite().getId();
    }

Also EMFProfileApplicationsView now implements ITabbedPropertySheetPageContributor. And based on the selection (StereoApplication or StereoApplicationImpl) I now get the in my plug-in defined tabs and sections in the Eclipse Properties View, even though they are partly empty for the time being.

2.) I have two certain issues I need to resolve. First of all, beside every improvement I would like to have an extra tab, which shows the standard properties of a stereotype as the standard table view. For that I wanted to make use of the quasi-standard AdvancedPropertySection ( http://grepcode.com/file/repository.grepcode.com/java/eclipse.org/3.6.1/org.eclipse.ui.views.properties/tabbed/3.5.100/org/eclipse/ui/views/properties/tabbed/AdvancedPropertySection.java ). This code piece is also being used e.g. by Eclipse Project Explorer in its Resource Tab etc. So what I thought was to use it without any modifications. But it wasn't any success. Funny though that with the correct input type (e.g. StereotypeApplicationImpl) for the section I get the tab created, but it doesn't show any properties of the stereotype. I mean the standard properties (its AppliedTo, Extension and the ones the Stereotype defines) which are actually being show for the actual version of the EMF Profiles. A few examples concerning this I found on the internet was using an extra PropertySheetPage extending the TabbedPropertySheedPage of eclipse.views as the contributing workbench part, be it an editor or a view. Do you have anything like that? If no, I could implement this.

3.) I have managed to query the selected stereotypes (StereotypeApplicationImpl) for the "AppliedTo" and "Extension" properties and got them shown in a tabbed section. But further from the user defined stereotype properties couldn't be queried. I believe that the getStereotype() of the StereotypeApplication isn't being called correctly. I unfortunately haven't got any time to implement a further section class, which might do that and as following calls the getTaggedValue(String) of the Stereotype class. But the question I am having is that the selected type from the EMFProfileApplicationsView is StereotypeApplication and not directly the Stereotype itself. I couldn't manage to build a connection between them.

I am sorry, if my problems and questions are easy or even silly, but I am quite new to the plug-in development and especially to the Properties View. I would be glad for your help!

Thanks a lot,
Emre

This plug-in takes the EMFProfileApplicationsView as the contributer and based on the selections

Philip Langer

unread,
May 13, 2013, 1:20:35 PM5/13/13
to emf-pr...@googlegroups.com
Hi Emre,

first of all, don't worry about your question, they aren't silly at all! Keep asking!

For my answers please see below...

On Sunday, May 12, 2013 10:29:37 PM UTC+2, Emre Taspolatoglu wrote:
Hello Philip,

no worries about any delay. As long as I get your help. :)

In the mean time, I had some time to look more into the the source code and I got a little bit closer to what I had in mind. For the better understanding I list my thoughts as follows:

1.) Yes, I would like to revise the Properties View for the Stereotypes etc. For that I have built a seperate plug-in, which contributes to the Eclipse Properties View. First of all, since I wanted to use the tabbed properties view, I had to change some parts in the EMFProfileApplicationsView as follows:

    @Override
    public Object getAdapter(@SuppressWarnings("rawtypes") Class adapter) {
        if (adapter.equals(IPropertySheetPage.class)) {
//            return getPropertySheetPage();
            return new TabbedPropertySheetPage(this);
        } else {
            return super.getAdapter(adapter);
        }
    }

and

    @Override
    public String getContributorId() {
        return getSite().getId();
    }

Also EMFProfileApplicationsView now implements ITabbedPropertySheetPageContributor. And based on the selection (StereoApplication or StereoApplicationImpl) I now get the in my plug-in defined tabs and sections in the Eclipse Properties View, even though they are partly empty for the time being.

Cool!! We had some discussions internally about the property view some months ago and back then we already thought that it needs some rework! But we never had the time to do so until now! It would be very nice if you could try to keep your extensions of the property view generic (i.e., not profile specific; working for any profiles) and contribute them to our repository once you're finished implementing it!!
 

2.) I have two certain issues I need to resolve. First of all, beside every improvement I would like to have an extra tab, which shows the standard properties of a stereotype as the standard table view. For that I wanted to make use of the quasi-standard AdvancedPropertySection ( http://grepcode.com/file/repository.grepcode.com/java/eclipse.org/3.6.1/org.eclipse.ui.views.properties/tabbed/3.5.100/org/eclipse/ui/views/properties/tabbed/AdvancedPropertySection.java ). This code piece is also being used e.g. by Eclipse Project Explorer in its Resource Tab etc. So what I thought was to use it without any modifications. But it wasn't any success. Funny though that with the correct input type (e.g. StereotypeApplicationImpl) for the section I get the tab created, but it doesn't show any properties of the stereotype. I mean the standard properties (its AppliedTo, Extension and the ones the Stereotype defines) which are actually being show for the actual version of the EMF Profiles. A few examples concerning this I found on the internet was using an extra PropertySheetPage extending the TabbedPropertySheedPage of eclipse.views as the contributing workbench part, be it an editor or a view. Do you have anything like that? If no, I could implement this.

I haven't had a look at creating tabbed property sheets so far and we don't have implemented any property sheet page for stereotype applications, as we currently only use the default property view and provide it with the selected EObject (StereotypeApplication instance) and the reflective item provider acting as IPropertySourceProvider.

<code>
propertySheetPage.setPropertySourceProvider(new AdapterFactoryContentProvider(new ProfileApplicationDecoratorReflectiveItemProviderAdapterFactory()));
</code>
ProfileApplicationDecoratorReflectiveItemProviderAdapterFactory is just a subclass of ReflectiveItemProviderAdapterFactory with an additional hook to notify about changes.

But your problem that no properties show up at all in the advanced property section seems to indicate that something with obtaining the property source from the selected object is wrong. The property view usually checks if the selected object adapts to IPropertySource or implements it and if not consults the set IPropertySourceProvider. Did you provide the adapter factory content provider to your property sheet as above?

After reading the javadoc of the PropertySheetPage another potential reason for your issue could be that the model for such a page is a hierarchy of IPropertySheetEntry and only if no root entry is set, it tries to adapt the selected object to IPropertySource and consults the IPropertySourceProvider. So could it be that you have set a root entry to that property page already?

* <p>
 * The model for this page is a hierarchy of <code>IPropertySheetEntry</code>.
 * The page may be configured with a custom model by setting the root entry.
 * <p>
 * If no root entry is set then a default model is created which uses the
 * <code>IPropertySource</code> interface to obtain the properties of
 * the current selection. This requires that the selected objects provide an
 * <code>IPropertySource</code> adapter (or implement
 * <code>IPropertySource</code> directly). This restiction can be overcome
 * by providing this page with an <code>IPropertySourceProvider</code>. If
 * supplied, this provider will be used by the default model to obtain a
 * property source for the current selection
 * </p>
 

3.) I have managed to query the selected stereotypes (StereotypeApplicationImpl) for the "AppliedTo" and "Extension" properties and got them shown in a tabbed section. But further from the user defined stereotype properties couldn't be queried. I believe that the getStereotype() of the StereotypeApplication isn't being called correctly. I unfortunately haven't got any time to implement a further section class, which might do that and as following calls the getTaggedValue(String) of the Stereotype class. But the question I am having is that the selected type from the EMFProfileApplicationsView is StereotypeApplication and not directly the Stereotype itself. I couldn't manage to build a connection between them.

You should be able to do the following:

<code>
StereotypeApplication stereotypeApplication = ...;
Stereotype stereotype = (Stereotype) stereotypeApplication.eClass();
stereotype.getEAllStructuralFeatures();
</code>
 
Here is a test case that should succeed when running as junit plug-in test:
org.modelversioning.emfprofile.tests.BasicProfileFacadeTest.testTypeOfAppliedStereotype()

But as you said, stereotypeApplication.getStereotype() should do exactly the same and should work... do you get null? Can you set a breakpoint at 
org.modelversioning.emfprofileapplication.impl.StereotypeApplicationImpl.getStereotype()
and see what is wrong there?

Hope that helps! Good luck in the meantime!

Philip

Emre Taspolatoglu

unread,
May 16, 2013, 3:48:37 PM5/16/13
to emf-pr...@googlegroups.com
Hello Philip,

thanks for the responses. I will look into them as soon as possible and get back to you regarding the outcomes.

Best regards,
Emre

P.S: In the meantime I will have a new question for you, but for that I will be opening a new post. :)


On Wednesday, May 8, 2013 6:42:53 PM UTC+2, Emre Taspolatoglu wrote:
Reply all
Reply to author
Forward
0 new messages