Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » Re: How to add a new tab to the Properties view in a GMF editor
Re: How to add a new tab to the Properties view in a GMF editor [message #147468] Wed, 22 August 2007 13:54 Go to next message
Eclipse UserFriend
Originally posted by: merks.ca.ibm.com

Satyajit,

This is best asked on the GMF newsgroup, which I've added to the "to"
list of the reply, so you can continue to use this thread.


Satyajit Chakraborty wrote:
> Hi all,
> I have created a GMF editor which is based on a ecore model. The editor is working quite well, but now I want to add a new tab to the Properties view. I have some custom properties which are not a part of my original domain model and I would like to show them in different property tabs. If I select a shape on the diagram, these extra tabs should show up. I am using GMF 1.0.3.
> Please help.
>
> Regards,
> Satyajit.
>
Re: How to add a new tab to the Properties view in a GMF editor [message #147546 is a reply to message #147468] Thu, 23 August 2007 02:39 Go to previous messageGo to next message
Koji Hashimoto is currently offline Koji HashimotoFriend
Messages: 28
Registered: July 2009
Junior Member
Satyajit,

For GMF 1.0.3, I have successfully added a custom tab to the Properties
view in the following way. I don't know this is a smart way, though.

1. Add a PropertyTabs extension

<extension point="org.eclipse.ui.views.properties.tabbed.propertyTabs" >
<propertyTabs
contributorId="org.eclipse.gmf.runtime.diagram.ui.properties ">
<propertyTab
category="Advanced"
id="property.tab.YourAdvancedPropertySection"
label="YourCustomLabel"/>
</propertyTabs>
</extension>

2. Add a PropertySection

<extension point="org.eclipse.ui.views.properties.tabbed.propertySections ">
<propertySections
contributorId="org.eclipse.gmf.runtime.diagram.ui.properties ">
<propertySection
class="org.example.YourPropertySection"
filter="org.example.YourEditPartPropertySectionFilter"
id="property.section.YourAdvancedPropertySection"
tab="property.tab.YourAdvancedPropertySection"/>
</propertySections>
</extension>

3. Create YourPropertySection class by extending AbstractPropertySection

4. Create YourEditPartPropertySectionFilter class implementing IFilter

public class YourEditPartPropertySectionFilter implements IFilter {
public boolean select(Object toTest) {
if (toTest instanceof YourEditPart) {
return true;
}
return false;
}
}

I hope this helps you.

Koji


Ed Merks wrote:

> Satyajit,

> This is best asked on the GMF newsgroup, which I've added to the "to"
> list of the reply, so you can continue to use this thread.


> Satyajit Chakraborty wrote:
>> Hi all,
>> I have created a GMF editor which is based on a ecore model. The editor
is working quite well, but now I want to add a new tab to the Properties view.
I have some custom properties which are not a part of my original domain model
and I would like to show them in different property tabs. If I select a shape
on the diagram, these extra tabs should show up. I am using GMF 1.0.3.
>> Please help.
>>
>> Regards,
>> Satyajit.
>>
Re: How to add a new tab to the Properties view in a GMF editor [message #148841 is a reply to message #147546] Tue, 04 September 2007 08:44 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: bmoros.um.es

Hi Koji,

is it also necessary to implement a IPropertySource if you want that both
the diagram and the model change when the new PropertySection is modifyed?
or is it enought to implement the changes of the model by executing a
Command?. I have tried the second approach but I am able to change the model
but the diagram is not refreshed.

Do you have any idea?

Thanks in advance!!


"Koji Hashimoto" <kojihashi@gmail.com> escribi
Re: How to add a new tab to the Properties view in a GMF editor [message #148857 is a reply to message #148841] Tue, 04 September 2007 12:15 Go to previous messageGo to next message
Koji Hashimoto is currently offline Koji HashimotoFriend
Messages: 28
Registered: July 2009
Junior Member
Hi Begoña,

No, your PropertySection doesn't need to implement IPropertySource.
Executing a command is the regular way to edit both your semantic model and notation model.

Are you using the editingDomain you can get from your AttributeInstanceEditPart when executing the SetCommand?
If not, you should.

When a node corresponding to your AttributeInstanceEditPart is selected, your PropertySection.setInput() is called with ISelection from which you can get the AttributeInstanceEditPart instance. Then you can get the editingDomain by AttributeInstanceEditPart.getEditingDomain().

Koji


From: "Begoña Moros" <bmoros@um.es>
Subject: Re: How to add a new tab to the Properties view in a GMF editor
Date: Tue, 4 Sep 2007 10:44:46 +0200

> Hi Koji,
>
> is it also necessary to implement a IPropertySource if you want that both
> the diagram and the model change when the new PropertySection is modifyed?
> or is it enought to implement the changes of the model by executing a
> Command?. I have tried the second approach but I am able to change the model
> but the diagram is not refreshed.
>
> Do you have any idea?
>
> Thanks in advance!!
>
>
> "Koji Hashimoto" <kojihashi@gmail.com> escribió en el mensaje
> news:1ca0bced7b9d5b14c629907a5b3d4c6c$1@www.eclipse.org...
> > Satyajit,
> >
> > For GMF 1.0.3, I have successfully added a custom tab to the Properties
> > view in the following way. I don't know this is a smart way, though..
> >
> > 1. Add a PropertyTabs extension
> >
> > <extension point="org.eclipse.ui.views.properties.tabbed.propertyTabs" >
> > <propertyTabs
> > contributorId="org.eclipse.gmf.runtime.diagram.ui.properties ">
> > <propertyTab
> > category="Advanced"
> > id="property.tab.YourAdvancedPropertySection"
> > label="YourCustomLabel"/>
> > </propertyTabs>
> > </extension>
> >
> > 2. Add a PropertySection
> >
> > <extension
> > point="org.eclipse.ui.views.properties.tabbed.propertySections ">
> > <propertySections
> > contributorId="org.eclipse.gmf.runtime.diagram.ui.properties ">
> > <propertySection
> > class="org.example.YourPropertySection"
> > filter="org.example.YourEditPartPropertySectionFilter"
> > id="property.section.YourAdvancedPropertySection"
> > tab="property.tab.YourAdvancedPropertySection"/>
> > </propertySections>
> > </extension>
> >
> > 3. Create YourPropertySection class by extending AbstractPropertySection
> >
> > 4. Create YourEditPartPropertySectionFilter class implementing IFilter
> >
> > public class YourEditPartPropertySectionFilter implements IFilter {
> > public boolean select(Object toTest) {
> > if (toTest instanceof YourEditPart) {
> > return true;
> > }
> > return false;
> > }
> > }
> >
> > I hope this helps you.
> >
> > Koji
> >
> >
> > Ed Merks wrote:
> >
> >> Satyajit,
> >
> >> This is best asked on the GMF newsgroup, which I've added to the "to"
> >> list of the reply, so you can continue to use this thread.
> >
> >
> >> Satyajit Chakraborty wrote:
> >>> Hi all,
> >>> I have created a GMF editor which is based on a ecore model. The
> >>> editor
> > is working quite well, but now I want to add a new tab to the Properties
> > view. I have some custom properties which are not a part of my original
> > domain model and I would like to show them in different property tabs. If
> > I select a shape on the diagram, these extra tabs should show up. I am
> > using GMF 1.0.3.
> >>> Please help.
> >>>
> >>> Regards,
> >>> Satyajit.
> >>>
> >
> >
>
>
Re: How to add a new tab to the Properties view in a GMF editor [message #148880 is a reply to message #148857] Tue, 04 September 2007 14:46 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: bmoros.um.es

Hi Koji,

Thank you for your answer. I do exactly what you have explained!!, the
problem is that the SetCommand modify the 'value' object that is referenced
from the AttributeInstance (that is,
attributeInstance.getValue().setValue(aValue)) So, when the value is changed
in the PropertySection the notification never arrives to
AttributeInstanceEditPart to refresh. I guess the notification is sent to
the ValueEditPart that it does not exist.

I hope I explain myself clear enough. Any idea about where the problem is?

Best regards,
Bego
Re: How to add a new tab to the Properties view in a GMF editor [message #148896 is a reply to message #148880] Tue, 04 September 2007 16:44 Go to previous messageGo to next message
Marc Gil is currently offline Marc GilFriend
Messages: 81
Registered: July 2009
Member
Hi Begoña, I send you a simple code you can add to your XPropertySection
file that implements your property section.

This is a handler that is executed when a text field is modified. Replace
projectName and projectPackage to your own ones:
protected void handleNameModified()
{
Element e = (Element) getGMFElement();
String newName = textName.getText();

EAttribute atr =
projectName.projectPackage.eINSTANCE.getElement_NameElement( );

doSetCommand(e, atr, newName);
}

The method getGMFElement brings to you the EMF element that represents the
selected node from your diagram. Replace 'Element' to your own one:
protected Element getGMFElement()
{
StructuredSelection ss = (StructuredSelection) getSelection();
if(ss != null)
{
Element e = (Element) ss.getFirstElement();
return e;
}
else
return null;
}

And the method doSetCommand executes the transaction that changes the
value of the attribute Name, in this case:
public void doSetCommand(Object owner, Object feature, Object value)
{
EditingDomain editingDomain = ((projectDiagramEditor)
getPart()).getEditingDomain();
SetCommand sCommand = (SetCommand) SetCommand.create(editingDomain,
owner, feature , value);
editingDomain.getCommandStack().execute(sCommand);
}

Try to adapt this code to your project and see if it works.

Salut!
Marc.
Re: How to add a new tab to the Properties view in a GMF editor [message #148937 is a reply to message #148880] Wed, 05 September 2007 04:21 Go to previous messageGo to next message
Koji Hashimoto is currently offline Koji HashimotoFriend
Messages: 28
Registered: July 2009
Junior Member
Begoña,

I think I understand your real problem.
The notification is issued by not AttributeInstance but Value, right?
Then, you might have to override handleNotificationEvent() in
AttributeInstance EditPart as follows:

@Override
protected void handleNotificationEvent(Notification notification) {
if (notification.getNotifier() instanceof Value) {
// refresh your node
}
super.handleNotificationEvent(notification);
}

I'm not sure this solution is correct. I'm inspired by the following
article:
http://wiki.eclipse.org/GMF_Tips#Making_figures_sensitive_to _attributes_of_semantic_elements

Give it a try!

Koji


Begoña Moros wrote:

> Hi Koji,

> Thank you for your answer. I do exactly what you have explained!!, the
> problem is that the SetCommand modify the 'value' object that is referenced
> from the AttributeInstance (that is,
> attributeInstance.getValue().setValue(aValue)) So, when the value is changed
> in the PropertySection the notification never arrives to
> AttributeInstanceEditPart to refresh. I guess the notification is sent to
> the ValueEditPart that it does not exist.

> I hope I explain myself clear enough. Any idea about where the problem is?

> Best regards,
> Begoña


> "Koji Hashimoto" <kojihashi@gmail.com> escribió en el mensaje
> news:20070904.211549.193696205.kojihashi@gmail.com...
> Hi Begoña,

> No, your PropertySection doesn't need to implement IPropertySource.
> Executing a command is the regular way to edit both your semantic model and
> notation model.

> Are you using the editingDomain you can get from your
> AttributeInstanceEditPart when executing the SetCommand?
> If not, you should.

> When a node corresponding to your AttributeInstanceEditPart is selected,
> your PropertySection.setInput() is called with ISelection from which you can
> get the AttributeInstanceEditPart instance. Then you can get the
> editingDomain by AttributeInstanceEditPart.getEditingDomain().

> Koji


> From: "Begoña Moros" <bmoros@um.es>
> Subject: Re: How to add a new tab to the Properties view in a GMF editor
> Date: Tue, 4 Sep 2007 10:44:46 +0200

>> Hi Koji,
>>
>> is it also necessary to implement a IPropertySource if you want that both
>> the diagram and the model change when the new PropertySection is modifyed?
>> or is it enought to implement the changes of the model by executing a
>> Command?. I have tried the second approach but I am able to change the
>> model
>> but the diagram is not refreshed.
>>
>> Do you have any idea?
>>
>> Thanks in advance!!
>>
>>
>> "Koji Hashimoto" <kojihashi@gmail.com> escribió en el mensaje
>> news:1ca0bced7b9d5b14c629907a5b3d4c6c$1@www.eclipse.org...
>> > Satyajit,
>> >
>> > For GMF 1.0.3, I have successfully added a custom tab to the Properties
>> > view in the following way. I don't know this is a smart way, though.
>> >
>> > 1. Add a PropertyTabs extension
>> >
>> > <extension point="org.eclipse.ui.views.properties.tabbed.propertyTabs" >
>> > <propertyTabs
>> > contributorId="org.eclipse.gmf.runtime.diagram.ui.properties ">
>> > <propertyTab
>> > category="Advanced"
>> > id="property.tab.YourAdvancedPropertySection"
>> > label="YourCustomLabel"/>
>> > </propertyTabs>
>> > </extension>
>> >
>> > 2. Add a PropertySection
>> >
>> > <extension
>> > point="org.eclipse.ui.views.properties.tabbed.propertySections ">
>> > <propertySections
>> > contributorId="org.eclipse.gmf.runtime.diagram.ui.properties ">
>> > <propertySection
>> > class="org.example.YourPropertySection"
>> > filter="org.example.YourEditPartPropertySectionFilter"
>> > id="property.section.YourAdvancedPropertySection"
>> > tab="property.tab.YourAdvancedPropertySection"/>
>> > </propertySections>
>> > </extension>
>> >
>> > 3. Create YourPropertySection class by extending AbstractPropertySection
>> >
>> > 4. Create YourEditPartPropertySectionFilter class implementing IFilter
>> >
>> > public class YourEditPartPropertySectionFilter implements IFilter {
>> > public boolean select(Object toTest) {
>> > if (toTest instanceof YourEditPart) {
>> > return true;
>> > }
>> > return false;
>> > }
>> > }
>> >
>> > I hope this helps you.
>> >
>> > Koji
>> >
>> >
>> > Ed Merks wrote:
>> >
>> >> Satyajit,
>> >
>> >> This is best asked on the GMF newsgroup, which I've added to the "to"
>> >> list of the reply, so you can continue to use this thread.
>> >
>> >
>> >> Satyajit Chakraborty wrote:
>> >>> Hi all,
>> >>> I have created a GMF editor which is based on a ecore model. The
>> >>> editor
>> > is working quite well, but now I want to add a new tab to the Properties
>> > view. I have some custom properties which are not a part of my original
>> > domain model and I would like to show them in different property tabs.
>> > If
>> > I select a shape on the diagram, these extra tabs should show up. I am
>> > using GMF 1.0.3.
>> >>> Please help.
>> >>>
>> >>> Regards,
>> >>> Satyajit.
>> >>>
>> >
>> >
>>
>>
Adding Property Tabs for all GMF Editors [message #481866 is a reply to message #147546] Mon, 24 August 2009 15:24 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: msp.informatik.uni-kiel.de

Hello,

I would like to add a property tab and a section for all GMF generated
editors. However, I'm not sure whether this is possible.

I was able to add a tab and a section for a specific GMF editor by using
the propertyTabs and propertySections extension points and setting the
same property sheet page contributor ID as it is defined for the
generated property tabs in the editor's diagram plugin. This identifier
simply equals the diagram plugin ID.

To extend this approach to all GMF editors, I tried using
org.eclipse.gmf.runtime.diagram.ui.properties as contributor ID as is is
suggested in the post below. However, the tab does not show up in this way.

The article "The Eclipse Tabbed Properties View" at Eclipse Corner
states the following:

"A workbench part cannot make use of two or more property contributors.
It can identify a single property contributor by implementing the
ITabbedPropertySheetPageContributor interface."

Does this mean the only way to add tabs to the properties for an editor
is by referencing that editor's specific property contributor ID?

Yours
Miro


Koji Hashimoto wrote:
> Satyajit,
>
> For GMF 1.0.3, I have successfully added a custom tab to the Properties
> view in the following way. I don't know this is a smart way, though.
>
> 1. Add a PropertyTabs extension
>
> <extension point="org.eclipse.ui.views.properties.tabbed.propertyTabs" >
> <propertyTabs
> contributorId="org.eclipse.gmf.runtime.diagram.ui.properties ">
> <propertyTab
> category="Advanced"
> id="property.tab.YourAdvancedPropertySection"
> label="YourCustomLabel"/>
> </propertyTabs>
> </extension>
>
> 2. Add a PropertySection
>
> <extension point="org.eclipse.ui.views.properties.tabbed.propertySections ">
> <propertySections
> contributorId="org.eclipse.gmf.runtime.diagram.ui.properties ">
> <propertySection
> class="org.example.YourPropertySection"
> filter="org.example.YourEditPartPropertySectionFilter"
> id="property.section.YourAdvancedPropertySection"
> tab="property.tab.YourAdvancedPropertySection"/>
> </propertySections>
> </extension>
>
> 3. Create YourPropertySection class by extending AbstractPropertySection
>
> 4. Create YourEditPartPropertySectionFilter class implementing IFilter
>
> public class YourEditPartPropertySectionFilter implements IFilter {
> public boolean select(Object toTest) {
> if (toTest instanceof YourEditPart) {
> return true;
> }
> return false;
> }
> }
>
> I hope this helps you.
>
> Koji

Original thread: How to add a new tab to the Properties view in a GMF editor
Re: Adding Property Tabs for all GMF Editors [message #482015 is a reply to message #481866] Tue, 25 August 2009 07:11 Go to previous message
Eclipse UserFriend
Originally posted by: msp.informatik.uni-kiel.de

I just realized, if I change the getContributorId() method of the
editor's diagram editor part to return
org.eclipse.gmf.runtime.diagram.ui.properties, then my new tab does show
up when using this string as contributor. However, this does not solve
my problem, as I don't want to change the editors.

Miro


Miro Spšoenemann wrote:
> Hello,
>
> I would like to add a property tab and a section for all GMF generated
> editors. However, I'm not sure whether this is possible.
>
> I was able to add a tab and a section for a specific GMF editor by using
> the propertyTabs and propertySections extension points and setting the
> same property sheet page contributor ID as it is defined for the
> generated property tabs in the editor's diagram plugin. This identifier
> simply equals the diagram plugin ID.
>
> To extend this approach to all GMF editors, I tried using
> org.eclipse.gmf.runtime.diagram.ui.properties as contributor ID as is is
> suggested in the post below. However, the tab does not show up in this way.
>
> The article "The Eclipse Tabbed Properties View" at Eclipse Corner
> states the following:
>
> "A workbench part cannot make use of two or more property contributors.
> It can identify a single property contributor by implementing the
> ITabbedPropertySheetPageContributor interface."
>
> Does this mean the only way to add tabs to the properties for an editor
> is by referencing that editor's specific property contributor ID?
>
> Yours
> Miro
>
>
> Koji Hashimoto wrote:
>> Satyajit,
>>
>> For GMF 1.0.3, I have successfully added a custom tab to the
>> Properties view in the following way. I don't know this is a smart
>> way, though.
>>
>> 1. Add a PropertyTabs extension
>>
>> <extension point="org.eclipse.ui.views.properties.tabbed.propertyTabs" >
>> <propertyTabs
>> contributorId="org.eclipse.gmf.runtime.diagram.ui.properties ">
>> <propertyTab
>> category="Advanced"
>> id="property.tab.YourAdvancedPropertySection"
>> label="YourCustomLabel"/>
>> </propertyTabs>
>> </extension>
>>
>> 2. Add a PropertySection
>>
>> <extension
>> point="org.eclipse.ui.views.properties.tabbed.propertySections ">
>> <propertySections
>> contributorId="org.eclipse.gmf.runtime.diagram.ui.properties ">
>> <propertySection
>> class="org.example.YourPropertySection"
>> filter="org.example.YourEditPartPropertySectionFilter"
>> id="property.section.YourAdvancedPropertySection"
>> tab="property.tab.YourAdvancedPropertySection"/>
>> </propertySections>
>> </extension>
>>
>> 3. Create YourPropertySection class by extending AbstractPropertySection
>>
>> 4. Create YourEditPartPropertySectionFilter class implementing IFilter
>>
>> public class YourEditPartPropertySectionFilter implements IFilter {
>> public boolean select(Object toTest) {
>> if (toTest instanceof YourEditPart) {
>> return true;
>> }
>> return false;
>> }
>> }
>>
>> I hope this helps you.
>>
>> Koji
>
> Original thread: How to add a new tab to the Properties view in a GMF
> editor
Previous Topic:Triggering Xpand and QVTO not from ANT script but from GMF runtime
Next Topic:DiagramUpdater & CanonicalEditPolicy
Goto Forum:
  


Current Time: Sat Jul 27 05:26:04 GMT 2024

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

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

Back to the top