|
|
Re: Disable adviceBinding [message #516600 is a reply to message #516360] |
Wed, 24 February 2010 14:17 |
Moritz Eysholdt 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 |
Andreas Rytina 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
>>>
>
>
|
|
|
Powered by
FUDForum. Page generated in 0.03522 seconds