Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » Disable adviceBinding
Disable adviceBinding [message #220833] Mon, 09 March 2009 18:29 Go to next message
Truong Ivan is currently offline Truong IvanFriend
Messages: 10
Registered: July 2009
Junior Member
Hello,
It should be a tricky question but I would like to disable / remove the
RemoveookmarksAdvice binding defined in plugin :
org.eclipse.gmf.runtime.diagram.core

<extension
point="org.eclipse.gmf.runtime.emf.type.core.elementTypes">
<metamodel nsURI="http://www.eclipse.org/emf/2002/Ecore">
<adviceBinding

class=" org.eclipse.gmf.runtime.diagram.core.edithelpers.NotationVie wDependentsAdvice "

id=" org.eclipse.gmf.runtime.diagram.core.advice.notationDepdende nts "
inheritance="none"
typeId="*"/>
<adviceBinding

class=" org.eclipse.gmf.runtime.diagram.core.edithelpers.RemoveBookm arksAdvice "

id="org.eclipse.gmf.runtime.diagram.core.advice.removeBookmarks "
inheritance="none"
typeId="*"/>
</metamodel>
</extension>

<extension
point="org.eclipse.gmf.runtime.emf.type.core.elementTypeBindings ">
<binding
context="org.eclipse.gmf.runtime.emf.type.core.defaultContext ">
<elementType
ref=" org.eclipse.gmf.runtime.diagram.core.advice.notationDepdende nts "/>
<elementType
ref="org.eclipse.gmf.runtime.diagram.core.advice.removeBookmarks "/>
</binding>
</extension>

I read the documentation under
http://publib.boulder.ibm.com/infocenter/rsmhelp/v7r0m0/inde x.jsp?topic=/org.eclipse.gmf.doc/prog-guide/runtime/Develope rs%20Guide%20to%20the%20Extensible%20Type%20Registry/Develop ers%20Guide%20to%20the%20Extensible%20Type%20Registry.html
but couldn't find anyway.

Can someone help me?

Ivan
Re: Disable adviceBinding [message #516360 is a reply to message #220833] Tue, 23 February 2010 12:26 Go to previous messageGo to next message
Andreas Rytina is currently offline Andreas RytinaFriend
Messages: 4
Registered: July 2009
Junior Member
Hi all,
does somebody know a solution for the problem Ivan described below? I
also need to disable the RemoveBookmarksAdvice or use a custom
implementation instead. In my project I use a custom resource
implementation (XtextResource) instead of a XMLResource for the semantic
model. This results in a ClassCastExfeption at
org.ecl...RemoveBookmarksAdvice.gatherSingleBookmark(RemoveB ookmarksAdvice.java:73).
Thank you

Cheers Andy

Truong Ivan schrieb:
> Hello, It should be a tricky question but I would like to disable /
> remove the RemoveookmarksAdvice binding defined in plugin :
> org.eclipse.gmf.runtime.diagram.core
>
> <extension
> point="org.eclipse.gmf.runtime.emf.type.core.elementTypes">
> <metamodel nsURI="http://www.eclipse.org/emf/2002/Ecore">
> <adviceBinding
>
> class=" org.eclipse.gmf.runtime.diagram.core.edithelpers.NotationVie wDependentsAdvice "
>
>
> id=" org.eclipse.gmf.runtime.diagram.core.advice.notationDepdende nts "
> inheritance="none"
> typeId="*"/>
> <adviceBinding
>
> class=" org.eclipse.gmf.runtime.diagram.core.edithelpers.RemoveBookm arksAdvice "
>
>
> id="org.eclipse.gmf.runtime.diagram.core.advice.removeBookmarks "
> inheritance="none"
> typeId="*"/>
> </metamodel>
> </extension>
> <extension
> point="org.eclipse.gmf.runtime.emf.type.core.elementTypeBindings ">
> <binding
> context="org.eclipse.gmf.runtime.emf.type.core.defaultContext ">
> <elementType
> ref=" org.eclipse.gmf.runtime.diagram.core.advice.notationDepdende nts "/>
> <elementType
> ref="org.eclipse.gmf.runtime.diagram.core.advice.removeBookmarks "/>
> </binding>
> </extension>
>
> I read the documentation under
> http://publib.boulder.ibm.com/infocenter/rsmhelp/v7r0m0/inde x.jsp?topic=/org.eclipse.gmf.doc/prog-guide/runtime/Develope rs%20Guide%20to%20the%20Extensible%20Type%20Registry/Develop ers%20Guide%20to%20the%20Extensible%20Type%20Registry.html
> but couldn't find anyway.
>
> Can someone help me?
>
> Ivan
>
Re: Disable adviceBinding [message #516600 is a reply to message #516360] Wed, 24 February 2010 14:17 Go to previous message
Moritz Eysholdt is currently offline Moritz EysholdtFriend
Messages: 161
Registered: July 2009
Location: Kiel, Germany
Senior Member
Hi,

this "fix" exchanges the implementation of the RemoveBookmarkAdvice in
the registry. Admittedly, this is kinda ugly, but it works.

public class BookmarkAdviceFix {

public static class RemoveBookmarkAdviceFix extends
RemoveBookmarksAdvice {
@Override
protected ICommand
getAfterDestroyElementCommand(DestroyElementRequest request) {
try {
return super.getAfterDestroyElementCommand(request);
} catch (ClassCastException e) {
return null;
}
}
}

public static void apply() {
try {
ElementTypeRegistry reg = ElementTypeRegistry.getInstance();
Field specField =
reg.getClass().getDeclaredField("specializationTypeRegistry ");
specField.setAccessible(true);
Object spec = specField.get(reg);
Field mapField = spec.getClass().getDeclaredField("adviceBindings");
mapField.setAccessible(true);
@SuppressWarnings("unchecked")
Map<Object, Collection<Object>> map = (Map<Object,
Collection<Object>>) mapField.get(spec);
for (Map.Entry<Object, Collection<Object>> e : map.entrySet()) {
for (Object o : new ArrayList<Object>(e.getValue())) {
if (o.toString().contains(".advice.removeBookmarks")) {
Field adviceField =
o.getClass().getDeclaredField("editHelperAdvice");
adviceField.setAccessible(true);
adviceField.set(o, new RemoveBookmarkAdviceFix());
}
}
}
} catch (IllegalArgumentException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (SecurityException e) {
e.printStackTrace();
} catch (NoSuchFieldException e) {
e.printStackTrace();
}
}

}


Andreas Rytina wrote:
> Hi all,
> does somebody know a solution for the problem Ivan described below? I
> also need to disable the RemoveBookmarksAdvice or use a custom
> implementation instead. In my project I use a custom resource
> implementation (XtextResource) instead of a XMLResource for the semantic
> model. This results in a ClassCastExfeption at
> org.ecl...RemoveBookmarksAdvice.gatherSingleBookmark(RemoveB ookmarksAdvice.java:73).
> Thank you
>
> Cheers Andy
>
> Truong Ivan schrieb:
>> Hello, It should be a tricky question but I would like to disable /
>> remove the RemoveookmarksAdvice binding defined in plugin :
>> org.eclipse.gmf.runtime.diagram.core
>>
>> <extension
>> point="org.eclipse.gmf.runtime.emf.type.core.elementTypes">
>> <metamodel nsURI="http://www.eclipse.org/emf/2002/Ecore">
>> <adviceBinding
>>
>> class=" org.eclipse.gmf.runtime.diagram.core.edithelpers.NotationVie wDependentsAdvice "
>>
>>
>> id=" org.eclipse.gmf.runtime.diagram.core.advice.notationDepdende nts "
>> inheritance="none"
>> typeId="*"/>
>> <adviceBinding
>>
>> class=" org.eclipse.gmf.runtime.diagram.core.edithelpers.RemoveBookm arksAdvice "
>>
>>
>> id="org.eclipse.gmf.runtime.diagram.core.advice.removeBookmarks "
>> inheritance="none"
>> typeId="*"/>
>> </metamodel>
>> </extension>
>> <extension
>> point="org.eclipse.gmf.runtime.emf.type.core.elementTypeBindings ">
>> <binding
>> context="org.eclipse.gmf.runtime.emf.type.core.defaultContext ">
>> <elementType
>> ref=" org.eclipse.gmf.runtime.diagram.core.advice.notationDepdende nts "/>
>> <elementType
>> ref="org.eclipse.gmf.runtime.diagram.core.advice.removeBookmarks "/>
>> </binding>
>> </extension>
>>
>> I read the documentation under
>> http://publib.boulder.ibm.com/infocenter/rsmhelp/v7r0m0/inde x.jsp?topic=/org.eclipse.gmf.doc/prog-guide/runtime/Develope rs%20Guide%20to%20the%20Extensible%20Type%20Registry/Develop ers%20Guide%20to%20the%20Extensible%20Type%20Registry.html
>> but couldn't find anyway.
>>
>> Can someone help me?
>>
>> Ivan
>>


--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com
Re: Disable adviceBinding [message #516641 is a reply to message #516600] Wed, 24 February 2010 11:24 Go to previous message
Andreas Rytina is currently offline Andreas RytinaFriend
Messages: 4
Registered: July 2009
Junior Member
thanks Moritz, this works.

Moritz Eysholdt schrieb:
> Hi,
>
> this "fix" exchanges the implementation of the RemoveBookmarkAdvice in
> the registry. Admittedly, this is kinda ugly, but it works.
>
> public class BookmarkAdviceFix {
>
> public static class RemoveBookmarkAdviceFix extends
> RemoveBookmarksAdvice {
> @Override
> protected ICommand
> getAfterDestroyElementCommand(DestroyElementRequest request) {
> try {
> return super.getAfterDestroyElementCommand(request);
> } catch (ClassCastException e) {
> return null;
> }
> }
> }
>
> public static void apply() {
> try {
> ElementTypeRegistry reg = ElementTypeRegistry.getInstance();
> Field specField =
> reg.getClass().getDeclaredField("specializationTypeRegistry ");
> specField.setAccessible(true);
> Object spec = specField.get(reg);
> Field mapField = spec.getClass().getDeclaredField("adviceBindings");
> mapField.setAccessible(true);
> @SuppressWarnings("unchecked")
> Map<Object, Collection<Object>> map = (Map<Object,
> Collection<Object>>) mapField.get(spec);
> for (Map.Entry<Object, Collection<Object>> e : map.entrySet()) {
> for (Object o : new ArrayList<Object>(e.getValue())) {
> if (o.toString().contains(".advice.removeBookmarks")) {
> Field adviceField =
> o.getClass().getDeclaredField("editHelperAdvice");
> adviceField.setAccessible(true);
> adviceField.set(o, new RemoveBookmarkAdviceFix());
> }
> }
> }
> } catch (IllegalArgumentException e) {
> e.printStackTrace();
> } catch (IllegalAccessException e) {
> e.printStackTrace();
> } catch (SecurityException e) {
> e.printStackTrace();
> } catch (NoSuchFieldException e) {
> e.printStackTrace();
> }
> }
>
> }
>
>
> Andreas Rytina wrote:
>> Hi all,
>> does somebody know a solution for the problem Ivan described below? I
>> also need to disable the RemoveBookmarksAdvice or use a custom
>> implementation instead. In my project I use a custom resource
>> implementation (XtextResource) instead of a XMLResource for the semantic
>> model. This results in a ClassCastExfeption at
>> org.ecl...RemoveBookmarksAdvice.gatherSingleBookmark(RemoveB ookmarksAdvice.java:73).
>>
>> Thank you
>>
>> Cheers Andy
>>
>> Truong Ivan schrieb:
>>> Hello, It should be a tricky question but I would like to disable /
>>> remove the RemoveookmarksAdvice binding defined in plugin :
>>> org.eclipse.gmf.runtime.diagram.core
>>>
>>> <extension
>>> point="org.eclipse.gmf.runtime.emf.type.core.elementTypes">
>>> <metamodel nsURI="http://www.eclipse.org/emf/2002/Ecore">
>>> <adviceBinding
>>>
>>> class=" org.eclipse.gmf.runtime.diagram.core.edithelpers.NotationVie wDependentsAdvice "
>>>
>>>
>>>
>>> id=" org.eclipse.gmf.runtime.diagram.core.advice.notationDepdende nts "
>>> inheritance="none"
>>> typeId="*"/>
>>> <adviceBinding
>>>
>>> class=" org.eclipse.gmf.runtime.diagram.core.edithelpers.RemoveBookm arksAdvice "
>>>
>>>
>>>
>>> id="org.eclipse.gmf.runtime.diagram.core.advice.removeBookmarks "
>>> inheritance="none"
>>> typeId="*"/>
>>> </metamodel>
>>> </extension>
>>> <extension
>>> point="org.eclipse.gmf.runtime.emf.type.core.elementTypeBindings ">
>>> <binding
>>> context="org.eclipse.gmf.runtime.emf.type.core.defaultContext ">
>>> <elementType
>>> ref=" org.eclipse.gmf.runtime.diagram.core.advice.notationDepdende nts "/>
>>> <elementType
>>> ref="org.eclipse.gmf.runtime.diagram.core.advice.removeBookmarks "/>
>>> </binding>
>>> </extension>
>>>
>>> I read the documentation under
>>> http://publib.boulder.ibm.com/infocenter/rsmhelp/v7r0m0/inde x.jsp?topic=/org.eclipse.gmf.doc/prog-guide/runtime/Develope rs%20Guide%20to%20the%20Extensible%20Type%20Registry/Develop ers%20Guide%20to%20the%20Extensible%20Type%20Registry.html
>>>
>>> but couldn't find anyway.
>>>
>>> Can someone help me?
>>>
>>> Ivan
>>>
>
>
Previous Topic:xpand templates
Next Topic:[Teneo + GMF + EMF Validation] EMF validation set to console, still a dialog appears.
Goto Forum:
  


Current Time: Mon Jul 23 15:37:57 GMT 2018

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

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

Back to the top