Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Graphiti » Connection without Bussiness Object to display a Reference?
Connection without Bussiness Object to display a Reference? [message #1126234] Sat, 05 October 2013 09:57 Go to next message
Eclipse UserFriend
Hi all,
what is the best way to create a create a connection without a Bussiness
Object, to Display a Reference?

I have the following self referenced EMF object like this (OCL in Ecor
Editor):

abstract class Type
{
attribute name : String[?];
property subtypes : Type[*] { ordered };
}

I want to build/display a type taxonomie in graphiti.

The AbstractCreateConnectionFeature need an Bussiness Object. I tried to
add the target Object, but when I delete the connection, the target
object is also deleted.

Thanks in advance

Jochen Buchholz
Re: Connection without Bussiness Object to display a Reference? [message #1130110 is a reply to message #1126234] Wed, 09 October 2013 08:31 Go to previous messageGo to next message
Michael Wenz is currently offline Michael WenzFriend
Messages: 1640
Registered: July 2009
Location: Walldorf, Germany
Senior Member
Jochen,

not sure what you mean with needs a business object...

The create connection feature is the thing that is hooked into the palette
of an editor to enable the creation of a connection. Inside you would create
a business object if you is needed. It does no harm to simply not create a
BO here and only delegate to an add feature to create the graphical
representation for the link.

If you link the target subtype the connection represents that target object
for the Graphiti framework. This is interpreted as the object shall be
deleted in case delete is called for the framework. This could be changed by
implementing a delete feature for your connection, but I guess in general it
would be better to avoid that link to the target subtype.

Michael
Re: Connection without Bussiness Object to display a Reference? [message #1171920 is a reply to message #1130110] Tue, 05 November 2013 15:28 Go to previous messageGo to next message
Dénes Harmath is currently offline Dénes HarmathFriend
Messages: 157
Registered: July 2009
Senior Member
Hi Jochen,

you just have to implement
- a CreateFeature which does not create a new business object but adds the existing target business object to the given reference of the source business object
- a DeleteFeature which does not delete the business object but removes it from the reference (by overriding DefaultDeleteFeature.deleteBusinessObject)

Hope that helps!

[Updated on: Tue, 05 November 2013 15:34]

Report message to a moderator

Re: Connection without Bussiness Object to display a Reference? [message #1176921 is a reply to message #1130110] Fri, 08 November 2013 16:49 Go to previous messageGo to next message
Jochen Buchholz is currently offline Jochen BuchholzFriend
Messages: 5
Registered: November 2013
Junior Member
Hi Michael,
sorry for the late answer, but I was on vacation.

I locate my mystake in the canAdd method of the AddConnectionFeature.
	@Override
	public boolean canAdd(IAddContext context) {
		// check for right domain object instance below
		return context instanceof IAddConnectionContext
				&& (context.getNewObject() instanceof Type);
	}

I changed it to
	@Override
	public boolean canAdd(IAddContext context) {
		// check for right domain object instance below
		if(context.getNewObject() == null){
			return true;
		}
		return false;
	}

because the canAdd method check the business object and my connection has no business object.

Now my connection is red dotted and I got an error tooltip "No business object linked to graphical representation" when I place my mouse pointer over the connection. How can I disable this message?

I think a dummy business object is a dirty way.

Thanks in advance
Jochen
Re: Connection without Bussiness Object to display a Reference? [message #1181266 is a reply to message #1176921] Mon, 11 November 2013 13:41 Go to previous messageGo to next message
Michael Wenz is currently offline Michael WenzFriend
Messages: 1640
Registered: July 2009
Location: Walldorf, Germany
Senior Member
Hi Jochen,

that message should be send by your update feature, have you checked this?

Have you seen Dénes' answer? That might be of help as well.

Michael
Re: Connection without Bussiness Object to display a Reference? [message #1243777 is a reply to message #1181266] Tue, 11 February 2014 12:29 Go to previous message
Jochen Buchholz is currently offline Jochen BuchholzFriend
Messages: 5
Registered: November 2013
Junior Member
I extended an AbstractUpdateFeature and leave the methods empty.
public class UpdateBolessConnectionFeature extends AbstractUpdateFeature {

	/**
	 * @param fp the feature provider
	 */
	public UpdateBolessConnectionFeature(IFeatureProvider fp) {
		super(fp);
		// TODO Auto-generated constructor stub
	}

	/* (non-Javadoc)
	 * @see org.eclipse.graphiti.func.IUpdate#canUpdate(org.eclipse.graphiti.features.context.IUpdateContext)
	 */
	@Override
	public boolean canUpdate(IUpdateContext context) {
		// TODO Auto-generated method stub
		return false;
	}

	/* (non-Javadoc)
	 * @see org.eclipse.graphiti.func.IUpdate#updateNeeded(org.eclipse.graphiti.features.context.IUpdateContext)
	 */
	@Override
	public IReason updateNeeded(IUpdateContext context) {
		// TODO Auto-generated method stub
		return null;
	}

	/* (non-Javadoc)
	 * @see org.eclipse.graphiti.func.IUpdate#update(org.eclipse.graphiti.features.context.IUpdateContext)
	 */
	@Override
	public boolean update(IUpdateContext context) {
		// TODO Auto-generated method stub
		return false;
	}

}

I add the UpdateBolessConnectionFeature to the feature provider

		if (pictogramElement instanceof ConnectionDecorator
				|| pictogramElement instanceof FreeFormConnection) {
			return new UpdateBolessConnectionFeature(this);
		}

That solve my problem.
Previous Topic:View dependency tree during debugging - Is Graphiti the right tool?
Next Topic:How to automatically unselect 'connection creation' tool entry in palette ?
Goto Forum:
  


Current Time: Fri Dec 19 21:02:26 GMT 2014

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

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