Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Graphiti » Add connection without palette(Bind 2 elements not using the palette.)
Add connection without palette [message #1139320] Tue, 15 October 2013 17:47 Go to next message
Victor Lopez is currently offline Victor LopezFriend
Messages: 21
Registered: August 2013
Junior Member
Hello everybody,

I have a custom feature that rightclicking on an object, another one is created at its right (both objects of the same type, called PositivePattern). There are like 20 units of space between them and I want them to be connected.

The thing is that the conection must be created when the object is created so I cannot use the palette and bind them. I do it a the CustomFeature class.

This is what I have (All the PositivePattern have an anchor created in the add method):

// get Classes which should be connected
Pattern source = (Pattern) bo;
Pattern target = pp;

AddConnectionContext addContext = new AddConnectionContext(cs.getAnchors().get(0), cs2.getAnchors().get(0)); //Being cs and cs2 the containers of the 2 objects

Connection newConnection = (Connection) getFeatureProvider().addIfPossible(addContext);



addIfPossible returns null so I guess that the created context (addContext) is not a valid one. Someone knows how to proceed?

Thanks in advance.

Víctor.
Re: Add connection without palette [message #1142206 is a reply to message #1139320] Thu, 17 October 2013 13:14 Go to previous message
Hallvard Traetteberg is currently offline Hallvard TraettebergFriend
Messages: 673
Registered: July 2009
Location: Trondheim, Norway
Senior Member
Victor,

I think you need to implement an IAddFeature that recognized the case
where you provide two anchors and returns true from the
canAdd(IAddContext) method. This will let the feature provider find and
use it in its addIfPossible method.

Hallvard

On 15.10.13 19.47, Victor Lopez wrote:
> Hello everybody,
>
> I have a custom feature that rightclicking on an object, another one is
> created at its right (both objects of the same type, called
> PositivePattern). There are like 20 units of space between them and I
> want them to be connected.
>
> The thing is that the conection must be created when the object is
> created so I cannot use the palette and bind them. I do it a the
> CustomFeature class.
>
> This is what I have (All the PositivePattern have an anchor created in
> the add method):
>
>
> // get Classes which should be connected
> Pattern source = (Pattern) bo;
> Pattern target = pp;
>
> AddConnectionContext addContext = new
> AddConnectionContext(cs.getAnchors().get(0), cs2.getAnchors().get(0));
> //Being cs and cs2 the containers of the 2 objects
>
> Connection newConnection = (Connection)
> getFeatureProvider().addIfPossible(addContext);
>
>
>
> addIfPossible returns null so I guess that the created context
> (addContext) is not a valid one. Someone knows how to proceed?
Previous Topic:Reusing EMF.Edit property sheet
Next Topic:How to associate keyboard shortcuts with custom features?
Goto Forum:
  


Current Time: Thu Apr 25 20:06:15 GMT 2024

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

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

Back to the top