Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Service Oriented Architecture Tools Platform (STP) » Listen to any modyfication of the diagram
Listen to any modyfication of the diagram [message #616136] Mon, 19 May 2008 13:15 Go to next message
Till Essers is currently offline Till Essers
Messages: 92
Registered: July 2009
Member
Hi

I'm using the stp.bpmn modeler and I want to be notified about any
change in the diagram itself. If something is added, removed, changed, etc.
But where do I have to register my listener and what listener do I have
to implement?

Thanks
Till
Re: Listen to any modyfication of the diagram [message #616141 is a reply to message #616136] Mon, 19 May 2008 13:21 Go to previous messageGo to next message
Eclipse User
Originally posted by: atoulme.intalio.com

Look for the EMF EContentAdapter class. That should give you a gread
head start.

Thanks,

Antoine

Till Essers wrote:
> Hi
>
> I'm using the stp.bpmn modeler and I want to be notified about any
> change in the diagram itself. If something is added, removed, changed, etc.
> But where do I have to register my listener and what listener do I have
> to implement?
>
> Thanks
> Till
Re: Listen to any modyfication of the diagram [message #616145 is a reply to message #616141] Mon, 19 May 2008 15:01 Go to previous messageGo to next message
Till Essers is currently offline Till Essers
Messages: 92
Registered: July 2009
Member
Sorry for bugging you again...

Writing my own EContentAdapter and adding it to the Diagram object would
be the way it should work. My only left problem is... where to get the
Diagram object for the active editor?

Thanks
Till

PS: I wrote a small tutorial on hiding the advanced tab, you might
review it and then link it to your component, Antoine.
http://wiki.eclipse.org/STP/BPMN_Component/Hiding_property_t abs

Antoine Toulme schrieb:
> Look for the EMF EContentAdapter class. That should give you a gread
> head start.
>
> Thanks,
>
> Antoine
>
> Till Essers wrote:
>> Hi
>>
>> I'm using the stp.bpmn modeler and I want to be notified about any
>> change in the diagram itself. If something is added, removed, changed,
>> etc.
>> But where do I have to register my listener and what listener do I
>> have to implement?
>>
>> Thanks
>> Till
Re: Listen to any modyfication of the diagram [message #616149 is a reply to message #616145] Mon, 19 May 2008 15:18 Go to previous messageGo to next message
Till Essers is currently offline Till Essers
Messages: 92
Registered: July 2009
Member
Nevermind, I found it and feel stupid :D
Till Essers schrieb:
> Sorry for bugging you again...
>
> Writing my own EContentAdapter and adding it to the Diagram object would
> be the way it should work. My only left problem is... where to get the
> Diagram object for the active editor?
>
> Thanks
> Till
>
> PS: I wrote a small tutorial on hiding the advanced tab, you might
> review it and then link it to your component, Antoine.
> http://wiki.eclipse.org/STP/BPMN_Component/Hiding_property_t abs
>
> Antoine Toulme schrieb:
>> Look for the EMF EContentAdapter class. That should give you a gread
>> head start.
>>
>> Thanks,
>>
>> Antoine
>>
>> Till Essers wrote:
>>> Hi
>>>
>>> I'm using the stp.bpmn modeler and I want to be notified about any
>>> change in the diagram itself. If something is added, removed,
>>> changed, etc.
>>> But where do I have to register my listener and what listener do I
>>> have to implement?
>>>
>>> Thanks
>>> Till
Re: Listen to any modyfication of the diagram [message #616152 is a reply to message #616149] Mon, 19 May 2008 15:48 Go to previous messageGo to next message
Eclipse User
Originally posted by: atoulme.intalio.com

Hey, just for the next folk reading this to feel smarter, would you mind
giving away the secret ? ;)

Till Essers wrote:
> Nevermind, I found it and feel stupid :D
> Till Essers schrieb:
>> Sorry for bugging you again...
>>
>> Writing my own EContentAdapter and adding it to the Diagram object
>> would be the way it should work. My only left problem is... where to
>> get the Diagram object for the active editor?
>>
>> Thanks
>> Till
>>
>> PS: I wrote a small tutorial on hiding the advanced tab, you might
>> review it and then link it to your component, Antoine.
>> http://wiki.eclipse.org/STP/BPMN_Component/Hiding_property_t abs
>>
>> Antoine Toulme schrieb:
>>> Look for the EMF EContentAdapter class. That should give you a gread
>>> head start.
>>>
>>> Thanks,
>>>
>>> Antoine
>>>
>>> Till Essers wrote:
>>>> Hi
>>>>
>>>> I'm using the stp.bpmn modeler and I want to be notified about any
>>>> change in the diagram itself. If something is added, removed,
>>>> changed, etc.
>>>> But where do I have to register my listener and what listener do I
>>>> have to implement?
>>>>
>>>> Thanks
>>>> Till
Re: Listen to any modyfication of the diagram [message #616154 is a reply to message #616145] Mon, 19 May 2008 15:50 Go to previous messageGo to next message
Eclipse User
Originally posted by: atoulme.intalio.com

> PS: I wrote a small tutorial on hiding the advanced tab, you might
> review it and then link it to your component, Antoine.
> http://wiki.eclipse.org/STP/BPMN_Component/Hiding_property_t abs

That is very nice! I added the categories [[Category:BPMN]] and
[[Category:STP]] to have it referenced properly.

I will add the item to our latest news, and our home page.

Thanks for the contribution !

Antoine
Re: Listen to any modyfication of the diagram [message #616156 is a reply to message #616152] Mon, 19 May 2008 15:53 Go to previous messageGo to next message
Till Essers is currently offline Till Essers
Messages: 92
Registered: July 2009
Member
How to add the ContentAdapter:
After opening the editor call the getDiagram() method and add your
EContentAdapter to the eAdapters list.

An Action for opening the editor will look like this:
IEditorPart editorpart =
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActi vePage().openEditor(new
FileEditorInput(file), MyBpmnDiagramEditor.ID);
Diagram
((EexBpmnDiagramEditor)editorpart).getDiagram().eAdapters(). add(new
MyContentAdapter());

Thats it ;)

Next step is to understand the Notification passed around ;)

Antoine Toulme schrieb:
> Hey, just for the next folk reading this to feel smarter, would you mind
> giving away the secret ? ;)
>
> Till Essers wrote:
>> Nevermind, I found it and feel stupid :D
>> Till Essers schrieb:
>>> Sorry for bugging you again...
>>>
>>> Writing my own EContentAdapter and adding it to the Diagram object
>>> would be the way it should work. My only left problem is... where to
>>> get the Diagram object for the active editor?
>>>
>>> Thanks
>>> Till
>>>
>>> PS: I wrote a small tutorial on hiding the advanced tab, you might
>>> review it and then link it to your component, Antoine.
>>> http://wiki.eclipse.org/STP/BPMN_Component/Hiding_property_t abs
>>>
>>> Antoine Toulme schrieb:
>>>> Look for the EMF EContentAdapter class. That should give you a gread
>>>> head start.
>>>>
>>>> Thanks,
>>>>
>>>> Antoine
>>>>
>>>> Till Essers wrote:
>>>>> Hi
>>>>>
>>>>> I'm using the stp.bpmn modeler and I want to be notified about any
>>>>> change in the diagram itself. If something is added, removed,
>>>>> changed, etc.
>>>>> But where do I have to register my listener and what listener do I
>>>>> have to implement?
>>>>>
>>>>> Thanks
>>>>> Till
Re: Listen to any modyfication of the diagram [message #616159 is a reply to message #616154] Mon, 19 May 2008 16:07 Go to previous message
Till Essers is currently offline Till Essers
Messages: 92
Registered: July 2009
Member
Oh and I wrote the addition to the EclipseCon2007 tutorial I mentioned a
few month' ago ;)
You may add it to your Wiki if you want to:
=== Showing the property tab only when a task is selected ===

Until now we just disabled the input fields in our property tab when no
task is selected, but hiding the whole property tab is a nicer solution.
The first step we have to take is adding a filter to our propertySection:
<source lang="xml">
<extension point="org.eclipse.ui.views.properties.tabbed.propertySections ">
<propertySections
contributorId="org.eclipse.gmf.runtime.diagram.ui.properties ">
<propertySection

class=" org.eclipse.stp.samples.eclipsecon2007.participant.propertie s.ParticipantPropertySection "

filter=" org.eclipse.stp.samples.eclipsecon2007.participant.propertie s.PropertySectionFilter "
id="ParticipantsSection"
tab="Participants">
<input type="org.eclipse.stp.bpmn.Activity"/>
<input type="java.lang.Object"/>
</propertySection>
</propertySections>
</extension>
</source>

The second step is to implement the filter:
<source lang="java">
public class PropertySectionFilter implements IFilter {
public boolean select(Object toTest) {
if(toTest instanceof ActivityEditPart) {
Object obj = ((IGraphicalEditPart) toTest).resolveSemanticElement();
if(obj instanceof Activity){
Activity task = (Activity)obj;
if(task.getActivityType() == ActivityType.get(ActivityType.TASK)) {
return true;
}
}
}
return false;
}
}
</source>

All the filter does is testing if the given Object is a task and return
true to show the tab if this is the case.
We have to do this with a filter, because we can't declare the Activity
as input for the section. (even though the tutorial says you should...
remove the <input type="java.lang.Object" /> and the tab will never show
up) What is passed is always an EditPart, so we have to filter for an
ActivityEditPart first, then get the element this EditPart wraps through
resolveSemanticElement(). Then we have to take a look on the type of the
Activity because we just want our tab to be shown when the selected
Activity is of type TASK.

Now the participant tab will only show up when you click on a task.

Antoine Toulme schrieb:
>
>> PS: I wrote a small tutorial on hiding the advanced tab, you might
>> review it and then link it to your component, Antoine.
>> http://wiki.eclipse.org/STP/BPMN_Component/Hiding_property_t abs
>
> That is very nice! I added the categories [[Category:BPMN]] and
> [[Category:STP]] to have it referenced properly.
>
> I will add the item to our latest news, and our home page.
>
> Thanks for the contribution !
>
> Antoine
Previous Topic:Re: [stp-newsgroup] Insert own complex properties into the modeler
Next Topic:SCA Tools Project newsgroup
Goto Forum:
  


Current Time: Thu Oct 23 05:57:38 GMT 2014

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

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