Skip to main content



      Home
Home » Modeling » Graphiti » Different classloader in ToolBehaviorProvider?
Different classloader in ToolBehaviorProvider? [message #1216413] Thu, 28 November 2013 08:16 Go to next message
Eclipse UserFriend
Hi,

Ive tried to implement the DoubleClickFeature and got a Classcast Exception.
Edit: Maybe its necessary how I create the object:
Object o = getFeatureProvider().getBusinessObjectForPictogramElement(context.getInnerPictogramElement());

java.lang.ClassCastException: moby.impl.SuperStateImpl cannot be cast to moby.impl.SuperStateImpl


Actually I am avoiding it via:
o.getClass().getName().equals(SuperStateImpl.class.getName())

But yeah, thats ugly...

Do you use different class loader?

[Updated on: Thu, 28 November 2013 08:30] by Moderator

Re: Different classloader in ToolBehaviorProvider? [message #1219202 is a reply to message #1216413] Mon, 02 December 2013 10:35 Go to previous messageGo to next message
Eclipse UserFriend
Soeren,

Graphiti itself does not use different classloaders, but the Equinox
framework underneath does. Each bundle (Eclipse plugin) will be loaded using
its own class loader.

Michael
Re: Different classloader in ToolBehaviorProvider? [message #1219315 is a reply to message #1216413] Tue, 03 December 2013 05:02 Go to previous messageGo to next message
Eclipse UserFriend
Hey Michael,

thanks for your reply Smile

Well, I dont know if I understand you, but is it correct if I say that will happen always, or am I doing something wrong there?
I would like to avoid my approach and just check the instance of my objects, is that possible?
Re: Different classloader in ToolBehaviorProvider? [message #1219729 is a reply to message #1219315] Thu, 05 December 2013 10:11 Go to previous messageGo to next message
Eclipse UserFriend
Soeren,

it should not happen always. Can you give more details on what you are
trying?

Michael
Re: Different classloader in ToolBehaviorProvider? [message #1219834 is a reply to message #1216413] Fri, 06 December 2013 03:28 Go to previous message
Eclipse UserFriend
Sure,

I tried to set up the DoubleClickFeature. I created my own Ecore-Model and the ToolBehaviourProvider.

public class MobyEditorToolBehaviorProvider extends DefaultToolBehaviorProvider {

	...
	
	@Override
	public ICustomFeature getDoubleClickFeature(IDoubleClickContext context) {
		Object o = getFeatureProvider().getBusinessObjectForPictogramElement(context.getInnerPictogramElement());
		if(o.getClass().getName().equals(SuperStateImpl.class.getName())) { //XXX: FIX ME
			return new SuperStateCollapseFeature(getFeatureProvider());
		}
	 
	    return super.getDoubleClickFeature(context);
	}

        ...
}


Maybe its my fault. I didnt use the canExecute method from the CustomFeature. I rewrote it and it works fine. Thank you Smile

Anyways I am wondering that I cant check it in the ToolBehaviorProvider like I did.

Thats the correct code, just in case anyone is running into it like me:
Toggle Spoiler
Previous Topic:Control Points for CurvedConnection
Next Topic:graphiti property view during refresh,want to write model by emf recording commad
Goto Forum:
  


Current Time: Wed Jul 23 22:10:22 EDT 2025

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

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

Back to the top