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