Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Custom property tab
Custom property tab [message #416695] Wed, 13 February 2008 09:32 Go to next message
Florian Hackenberger is currently offline Florian HackenbergerFriend
Messages: 123
Registered: July 2009
Senior Member
Hi!

I would like to add a custom properties tab to the properties view of an EMF
editor. Unlike [1] however, I do not want to completely replace the
property editor of EMF. I just want to have an additional tab for certain
model classes. Is that possible with EMF?

Cheers,
Florian

[1] http://wiki.eclipse.org/EMF/Recipes#Properties_Recipes
Re: Custom property tab [message #416702 is a reply to message #416695] Wed, 13 February 2008 14:18 Go to previous messageGo to next message
Cyril Faucher is currently offline Cyril FaucherFriend
Messages: 63
Registered: July 2009
Member
Hi Florian,

You can use this:
http://topcased-mm.gforge.enseeiht.fr/website/modeling/tutor ials/generatePropertiesView.html

Maybe this generator has been ever added into the Ecore Tools component
(subproject of EMFT).

Best regards,
Cyril.

DI Florian Hackenberger a écrit :
> Hi!
>
> I would like to add a custom properties tab to the properties view of an EMF
> editor. Unlike [1] however, I do not want to completely replace the
> property editor of EMF. I just want to have an additional tab for certain
> model classes. Is that possible with EMF?
>
> Cheers,
> Florian
>
> [1] http://wiki.eclipse.org/EMF/Recipes#Properties_Recipes


--
Cyril Faucher
IRISA-INRIA - Rennes, France
[Breathe life into your metamodels www.kermeta.org]
Re: Custom property tab [message #416705 is a reply to message #416695] Wed, 13 February 2008 14:32 Go to previous messageGo to next message
Marcelo Paternostro is currently offline Marcelo PaternostroFriend
Messages: 602
Registered: July 2009
Senior Member
Hi,

I am not sure if you can/should (like in "respecting the Eclipse UI
conventions") add a tab to the classical properties view (the one with
the "ugly" table look). If you notice what we do, we categorize the
properties using a tree table approach. Anyways, the following posts
may help you.

"about property sheet" from 12/26/2007 10:46 AM
"problem with added property descriptors" from 7/11/2005 3:15 AM
"Extending generated PropertySheet entries" from 10/1/2003 4:12 AM

If you are working with the "new" tabbed properties (the ones you can
use any type of widget), then, unfortunately, you are a bit on your own
because we don't generate then. You can see what GMF does for example,
since their editor is backed by such properties pages. Here's another post:

"How to add a new tab to the Properties view in a GMF editor" from
8/22/2007 9:48 AM

Cheers,
Marcelo


DI Florian Hackenberger wrote:
> Hi!
>
> I would like to add a custom properties tab to the properties view of an EMF
> editor. Unlike [1] however, I do not want to completely replace the
> property editor of EMF. I just want to have an additional tab for certain
> model classes. Is that possible with EMF?
>
> Cheers,
> Florian
>
> [1] http://wiki.eclipse.org/EMF/Recipes#Properties_Recipes
Re: Custom property tab [message #416710 is a reply to message #416705] Wed, 13 February 2008 16:02 Go to previous messageGo to next message
Florian Hackenberger is currently offline Florian HackenbergerFriend
Messages: 123
Registered: July 2009
Senior Member
Marcelo Paternostro wrote:
> I am not sure if you can/should (like in "respecting the Eclipse UI
> conventions") add a tab to the classical properties view (the one with
> the "ugly" table look). If you notice what we do, we categorize the
> properties using a tree table approach. Anyways, the following posts
> may help you.
>
> "about property sheet" from 12/26/2007 10:46 AM
> "problem with added property descriptors" from 7/11/2005 3:15 AM
> "Extending generated PropertySheet entries" from 10/1/2003 4:12 AM
Thanks for the references! I meant the tabbed properties approach and
finally succeded, after some struggeling.

> If you are working with the "new" tabbed properties (the ones you can
> use any type of widget), then, unfortunately, you are a bit on your own
> because we don't generate then.
After reading quite a bit, I found out that the only thing preventing me
from using the tabbed properties view, is the fact that EMF requires an
adapter factory for the model objects (that is the model objects do not
implement the IPropertySource interface, not adapt to it). This factory is
created and set in:

public IPropertySheetPage XXXEditor::getPropertySheetPage():
ExtendedPropertySheetPage page = ...
...
propertySheetPage.setPropertySourceProvider(new
AdapterFactoryContentProvider(adapterFactory));

The AdvancedPropertySection (part of the tabbed properties package), which
is a wrapper for the standard PropertySheetPage, however does not expose
the setPropertySourceProvider method of the property page it creates.
Therefore the AdvancedPropertySection cannot be used to display the
properties of EMF objects. I'm not yet convinced it is the correct
approach, but I simply created a new class EMFPropertySection (mostly
copy/pasted from AdvancedPropertySection), which sets the property ource
provider.

public class EMFPropertySection extends AbstractPropertySection {
protected PropertySheetPage page;

public void createControls(Composite parent,
TabbedPropertySheetPage tabbedPropertySheetPage) {
super.createControls(parent, tabbedPropertySheetPage);
Composite composite = getWidgetFactory().createFlatFormComposite(parent);
page = new PropertySheetPage();
page.setPropertySourceProvider(new AdapterFactoryContentProvider(new
XXXItemProviderAdapterFactory()));

page.createControl(composite);
FormData data = new FormData();
data.left = new FormAttachment(0, 0);
data.right = new FormAttachment(100, 0);
data.top = new FormAttachment(0, 0);
data.bottom = new FormAttachment(100, 0);
page.getControl().setLayoutData(data);
}

public void setInput(IWorkbenchPart part, ISelection selection) {
super.setInput(part, selection);
page.selectionChanged(part, selection);
}

public void dispose() {
super.dispose();

if (page != null) {
page.dispose();
page = null;
}

}

public void refresh() {
page.refresh();
}

public boolean shouldUseExtraSpace() {
return true;
}
}

Then I added the following extensions to my plugin.xml:

<extension
point="org.eclipse.ui.views.properties.tabbed.propertyContributor ">
<propertyContributor

contributorId="org.acoveo.callcenter.masterdata.presentation.XXXEditorID ">
<propertyCategory
category="sample"></propertyCategory>
</propertyContributor>
</extension>
<extension
point="org.eclipse.ui.views.properties.tabbed.propertyTabs" >
<propertyTabs

contributorId="org.acoveo.callcenter.masterdata.presentation.XXXEditorID ">
<propertyTab
category="sample"
id="org.acoveo.callcenter.masterData.editor.propertyTab1"
label="propertyTab">
</propertyTab>
<propertyTab
category="sample"

id="org.acoveo.callcenter.masterData.editor.advancedPropertyTab "
label="Advanced">
</propertyTab>
</propertyTabs>
</extension>
<extension
point="org.eclipse.ui.views.properties.tabbed.propertySections ">
<propertySections

contributorId="org.acoveo.callcenter.masterdata.presentation.XXXEditorID ">
<propertySection

class=" org.acoveo.callcenter.masterdata.presentation.PropertySectio n1 "
id="org.acoveo.callcenter.masterData.editor.propertySection1 "
tab="org.acoveo.callcenter.masterData.editor.propertyTab1">
<input
type="org.eclipse.emf.ecore.EObject">
</input>
</propertySection>
<propertySection

class=" org.acoveo.callcenter.masterdata.presentation.EMFPropertySec tion "

id=" org.acoveo.callcenter.masterData.editor.advancedPropertySect ion1 "

tab="org.acoveo.callcenter.masterData.editor.advancedPropertyTab ">
<input
type="org.eclipse.emf.ecore.EObject">
</input>
</propertySection>
</propertySections>
</extension>

And tatata, it worked. Apart from the EMFPropertySection, I also added
another "custom" section, following [1]. On a first glance, the approach
seems to work, although I'm not yet sure what I should do with the methods
public void setSelectionToViewer(List<?> selection)
public void setActionBars(IActionBars actionBars)
and the remaining functionality of the ExtendedPropertySheetPage. I cannot
use the ExtendedPropertySheetPage in EMFPropertySection, as I do not have
access to the editing domain, do I? Any suggestions/tips for improvement on
that approach?

Cheers,
Florian

[1]
http://www.eclipse.org/articles/Article-Tabbed-Properties/ta bbed_properties_view.html

--
Florian Hackenberger
Re: Custom property tab [message #416712 is a reply to message #416710] Wed, 13 February 2008 18:17 Go to previous messageGo to next message
lucas bigeardel is currently offline lucas bigeardelFriend
Messages: 155
Registered: July 2009
Senior Member
Topcased tabbed properties has been largely reused in ecoretools :

see CVS repository :pserver:anonymous@dev.eclipse.org:/cvsroot/modeling

/plugins/

org.eclipse.emf.ecoretools.properties
org.eclipse.emf.tabbedproperties

regards,

DI Florian Hackenberger a écrit :
> Marcelo Paternostro wrote:
>> I am not sure if you can/should (like in "respecting the Eclipse UI
>> conventions") add a tab to the classical properties view (the one with
>> the "ugly" table look). If you notice what we do, we categorize the
>> properties using a tree table approach. Anyways, the following posts
>> may help you.
>>
>> "about property sheet" from 12/26/2007 10:46 AM
>> "problem with added property descriptors" from 7/11/2005 3:15 AM
>> "Extending generated PropertySheet entries" from 10/1/2003 4:12 AM
> Thanks for the references! I meant the tabbed properties approach and
> finally succeded, after some struggeling.
>
>> If you are working with the "new" tabbed properties (the ones you can
>> use any type of widget), then, unfortunately, you are a bit on your own
>> because we don't generate then.
> After reading quite a bit, I found out that the only thing preventing me
> from using the tabbed properties view, is the fact that EMF requires an
> adapter factory for the model objects (that is the model objects do not
> implement the IPropertySource interface, not adapt to it). This factory is
> created and set in:
>
> public IPropertySheetPage XXXEditor::getPropertySheetPage():
> ExtendedPropertySheetPage page = ...
> ...
> propertySheetPage.setPropertySourceProvider(new
> AdapterFactoryContentProvider(adapterFactory));
>
> The AdvancedPropertySection (part of the tabbed properties package), which
> is a wrapper for the standard PropertySheetPage, however does not expose
> the setPropertySourceProvider method of the property page it creates.
> Therefore the AdvancedPropertySection cannot be used to display the
> properties of EMF objects. I'm not yet convinced it is the correct
> approach, but I simply created a new class EMFPropertySection (mostly
> copy/pasted from AdvancedPropertySection), which sets the property ource
> provider.
>
> public class EMFPropertySection extends AbstractPropertySection {
> protected PropertySheetPage page;
>
> public void createControls(Composite parent,
> TabbedPropertySheetPage tabbedPropertySheetPage) {
> super.createControls(parent, tabbedPropertySheetPage);
> Composite composite = getWidgetFactory().createFlatFormComposite(parent);
> page = new PropertySheetPage();
> page.setPropertySourceProvider(new AdapterFactoryContentProvider(new
> XXXItemProviderAdapterFactory()));
>
> page.createControl(composite);
> FormData data = new FormData();
> data.left = new FormAttachment(0, 0);
> data.right = new FormAttachment(100, 0);
> data.top = new FormAttachment(0, 0);
> data.bottom = new FormAttachment(100, 0);
> page.getControl().setLayoutData(data);
> }
>
> public void setInput(IWorkbenchPart part, ISelection selection) {
> super.setInput(part, selection);
> page.selectionChanged(part, selection);
> }
>
> public void dispose() {
> super.dispose();
>
> if (page != null) {
> page.dispose();
> page = null;
> }
>
> }
>
> public void refresh() {
> page.refresh();
> }
>
> public boolean shouldUseExtraSpace() {
> return true;
> }
> }
>
> Then I added the following extensions to my plugin.xml:
>
> <extension
> point="org.eclipse.ui.views.properties.tabbed.propertyContributor ">
> <propertyContributor
>
> contributorId="org.acoveo.callcenter.masterdata.presentation.XXXEditorID ">
> <propertyCategory
> category="sample"></propertyCategory>
> </propertyContributor>
> </extension>
> <extension
> point="org.eclipse.ui.views.properties.tabbed.propertyTabs" >
> <propertyTabs
>
> contributorId="org.acoveo.callcenter.masterdata.presentation.XXXEditorID ">
> <propertyTab
> category="sample"
> id="org.acoveo.callcenter.masterData.editor.propertyTab1"
> label="propertyTab">
> </propertyTab>
> <propertyTab
> category="sample"
>
> id="org.acoveo.callcenter.masterData.editor.advancedPropertyTab "
> label="Advanced">
> </propertyTab>
> </propertyTabs>
> </extension>
> <extension
> point="org.eclipse.ui.views.properties.tabbed.propertySections ">
> <propertySections
>
> contributorId="org.acoveo.callcenter.masterdata.presentation.XXXEditorID ">
> <propertySection
>
> class=" org.acoveo.callcenter.masterdata.presentation.PropertySectio n1 "
> id="org.acoveo.callcenter.masterData.editor.propertySection1 "
> tab="org.acoveo.callcenter.masterData.editor.propertyTab1">
> <input
> type="org.eclipse.emf.ecore.EObject">
> </input>
> </propertySection>
> <propertySection
>
> class=" org.acoveo.callcenter.masterdata.presentation.EMFPropertySec tion "
>
> id=" org.acoveo.callcenter.masterData.editor.advancedPropertySect ion1 "
>
> tab="org.acoveo.callcenter.masterData.editor.advancedPropertyTab ">
> <input
> type="org.eclipse.emf.ecore.EObject">
> </input>
> </propertySection>
> </propertySections>
> </extension>
>
> And tatata, it worked. Apart from the EMFPropertySection, I also added
> another "custom" section, following [1]. On a first glance, the approach
> seems to work, although I'm not yet sure what I should do with the methods
> public void setSelectionToViewer(List<?> selection)
> public void setActionBars(IActionBars actionBars)
> and the remaining functionality of the ExtendedPropertySheetPage. I cannot
> use the ExtendedPropertySheetPage in EMFPropertySection, as I do not have
> access to the editing domain, do I? Any suggestions/tips for improvement on
> that approach?
>
> Cheers,
> Florian
>
> [1]
> http://www.eclipse.org/articles/Article-Tabbed-Properties/ta bbed_properties_view.html
>
Re: Custom property tab [message #416713 is a reply to message #416710] Wed, 13 February 2008 19:03 Go to previous messageGo to next message
Marcelo Paternostro is currently offline Marcelo PaternostroFriend
Messages: 602
Registered: July 2009
Senior Member
Hi Florian,

You are way ahead of me on this subject. I played with tabbed properties
a long time ago just to see how it worked.

Perhaps you can post your questions on the GMF newsgroup (apologizing
for the "off topic" ;-) ) and see if someone with more experience on
this can give you some good advice. Also, you may look at the Tocased
tabbed properties indicated by lucas.

Sorry for not being more helpful.

Cheers,
Marcelo

DI Florian Hackenberger wrote:
> Marcelo Paternostro wrote:
>> I am not sure if you can/should (like in "respecting the Eclipse UI
>> conventions") add a tab to the classical properties view (the one with
>> the "ugly" table look). If you notice what we do, we categorize the
>> properties using a tree table approach. Anyways, the following posts
>> may help you.
>>
>> "about property sheet" from 12/26/2007 10:46 AM
>> "problem with added property descriptors" from 7/11/2005 3:15 AM
>> "Extending generated PropertySheet entries" from 10/1/2003 4:12 AM
> Thanks for the references! I meant the tabbed properties approach and
> finally succeded, after some struggeling.
>
>> If you are working with the "new" tabbed properties (the ones you can
>> use any type of widget), then, unfortunately, you are a bit on your own
>> because we don't generate then.
> After reading quite a bit, I found out that the only thing preventing me
> from using the tabbed properties view, is the fact that EMF requires an
> adapter factory for the model objects (that is the model objects do not
> implement the IPropertySource interface, not adapt to it). This factory is
> created and set in:
>
> public IPropertySheetPage XXXEditor::getPropertySheetPage():
> ExtendedPropertySheetPage page = ...
> ...
> propertySheetPage.setPropertySourceProvider(new
> AdapterFactoryContentProvider(adapterFactory));
>
> The AdvancedPropertySection (part of the tabbed properties package), which
> is a wrapper for the standard PropertySheetPage, however does not expose
> the setPropertySourceProvider method of the property page it creates.
> Therefore the AdvancedPropertySection cannot be used to display the
> properties of EMF objects. I'm not yet convinced it is the correct
> approach, but I simply created a new class EMFPropertySection (mostly
> copy/pasted from AdvancedPropertySection), which sets the property ource
> provider.
>
> public class EMFPropertySection extends AbstractPropertySection {
> protected PropertySheetPage page;
>
> public void createControls(Composite parent,
> TabbedPropertySheetPage tabbedPropertySheetPage) {
> super.createControls(parent, tabbedPropertySheetPage);
> Composite composite = getWidgetFactory().createFlatFormComposite(parent);
> page = new PropertySheetPage();
> page.setPropertySourceProvider(new AdapterFactoryContentProvider(new
> XXXItemProviderAdapterFactory()));
>
> page.createControl(composite);
> FormData data = new FormData();
> data.left = new FormAttachment(0, 0);
> data.right = new FormAttachment(100, 0);
> data.top = new FormAttachment(0, 0);
> data.bottom = new FormAttachment(100, 0);
> page.getControl().setLayoutData(data);
> }
>
> public void setInput(IWorkbenchPart part, ISelection selection) {
> super.setInput(part, selection);
> page.selectionChanged(part, selection);
> }
>
> public void dispose() {
> super.dispose();
>
> if (page != null) {
> page.dispose();
> page = null;
> }
>
> }
>
> public void refresh() {
> page.refresh();
> }
>
> public boolean shouldUseExtraSpace() {
> return true;
> }
> }
>
> Then I added the following extensions to my plugin.xml:
>
> <extension
> point="org.eclipse.ui.views.properties.tabbed.propertyContributor ">
> <propertyContributor
>
> contributorId="org.acoveo.callcenter.masterdata.presentation.XXXEditorID ">
> <propertyCategory
> category="sample"></propertyCategory>
> </propertyContributor>
> </extension>
> <extension
> point="org.eclipse.ui.views.properties.tabbed.propertyTabs" >
> <propertyTabs
>
> contributorId="org.acoveo.callcenter.masterdata.presentation.XXXEditorID ">
> <propertyTab
> category="sample"
> id="org.acoveo.callcenter.masterData.editor.propertyTab1"
> label="propertyTab">
> </propertyTab>
> <propertyTab
> category="sample"
>
> id="org.acoveo.callcenter.masterData.editor.advancedPropertyTab "
> label="Advanced">
> </propertyTab>
> </propertyTabs>
> </extension>
> <extension
> point="org.eclipse.ui.views.properties.tabbed.propertySections ">
> <propertySections
>
> contributorId="org.acoveo.callcenter.masterdata.presentation.XXXEditorID ">
> <propertySection
>
> class=" org.acoveo.callcenter.masterdata.presentation.PropertySectio n1 "
> id="org.acoveo.callcenter.masterData.editor.propertySection1 "
> tab="org.acoveo.callcenter.masterData.editor.propertyTab1">
> <input
> type="org.eclipse.emf.ecore.EObject">
> </input>
> </propertySection>
> <propertySection
>
> class=" org.acoveo.callcenter.masterdata.presentation.EMFPropertySec tion "
>
> id=" org.acoveo.callcenter.masterData.editor.advancedPropertySect ion1 "
>
> tab="org.acoveo.callcenter.masterData.editor.advancedPropertyTab ">
> <input
> type="org.eclipse.emf.ecore.EObject">
> </input>
> </propertySection>
> </propertySections>
> </extension>
>
> And tatata, it worked. Apart from the EMFPropertySection, I also added
> another "custom" section, following [1]. On a first glance, the approach
> seems to work, although I'm not yet sure what I should do with the methods
> public void setSelectionToViewer(List<?> selection)
> public void setActionBars(IActionBars actionBars)
> and the remaining functionality of the ExtendedPropertySheetPage. I cannot
> use the ExtendedPropertySheetPage in EMFPropertySection, as I do not have
> access to the editing domain, do I? Any suggestions/tips for improvement on
> that approach?
>
> Cheers,
> Florian
>
> [1]
> http://www.eclipse.org/articles/Article-Tabbed-Properties/ta bbed_properties_view.html
>
Re: Custom property tab [message #416714 is a reply to message #416712] Wed, 13 February 2008 19:06 Go to previous message
Florian Hackenberger is currently offline Florian HackenbergerFriend
Messages: 123
Registered: July 2009
Senior Member
lucas bigeardel wrote:
> Topcased tabbed properties has been largely reused in ecoretools :
Thank you all very much indeed! I'll have a look at your suggestions
tomorrow!

Cheers,
Florian
--
Florian Hackenberger
Previous Topic:EMF - Default Valued Feature
Next Topic:Validation Generation & JRE Compliance
Goto Forum:
  


Current Time: Thu Apr 25 12:25:58 GMT 2024

Powered by FUDForum. Page generated in 0.02854 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top