Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Graphiti » How to connect 2 elements created out of same Eobject to different pictogramelements(How to connect 2 elements created out of same Eobject to different pictogramelements)
How to connect 2 elements created out of same Eobject to different pictogramelements [message #1101242] Wed, 04 September 2013 07:35 Go to next message
PALANI SANKAR is currently offline PALANI SANKARFriend
Messages: 35
Registered: April 2013
Member
Hi All

I am facing a problem.i am creating 2 pictogram elements for an eobject
(ex: Student A) and i want to connect it to pictogram elements (ex: university and college). i can be able to create 2 diagrams using student A Eobject.


But during connection ,

connection between studentA and university.

sourceAnchor=getFeatureProvider().getPictogramElementForBusinessObject(StudentA);---->(1)
targetAnchor=getFeatureProvider().getPictogramElementForBusinessObject(University);

connection between studentA and college.

sourceAnchor=getFeatureProvider().getPictogramElementForBusinessObject(StudentA);--->(2)
targetAnchor=getFeatureProvider().getPictogramElementForBusinessObject(college);


But when i do as above , then the pictogram element is coming as same for (1) && (2)
so both university and college is connecting to same pictogram element(studentA).but i want it to be different.

Is there any way to resolve this issue?if i am doing something wrong means please let me know.

PFA my sample explanation.

i have drawn the expected and current behaviour

Thanks
Palani


Thanks
Palani
Re: How to connect 2 elements created out of same Eobject to different pictogramelements [message #1101301 is a reply to message #1101242] Wed, 04 September 2013 09:16 Go to previous messageGo to next message
Sylvain EVEILLARD is currently offline Sylvain EVEILLARDFriend
Messages: 556
Registered: July 2009
Senior Member
getAllPictogramElementsForBusinessObject ?
Re: How to connect 2 elements created out of same Eobject to different pictogramelements [message #1101351 is a reply to message #1101242] Wed, 04 September 2013 10:48 Go to previous messageGo to next message
PALANI SANKAR is currently offline PALANI SANKARFriend
Messages: 35
Registered: April 2013
Member
Hi Sylvain

Thanks for you reply.

But getAllPictogramElementsForBusinessObject gives you all the pictogramelements with respect to that object.

For ex: for studentA EObject,if you are creating a container shape and that container shape contains shapes for graphics algorithm. Then getAllPictogramElementsForBusinessObject(StudentA) will give you 1)ContainerShape
2)Shape
3)Shape and so on.

So i cant use that method.

Thanks
Palani


Thanks
Palani
Re: How to connect 2 elements created out of same Eobject to different pictogramelements [message #1101420 is a reply to message #1101351] Wed, 04 September 2013 12:44 Go to previous messageGo to next message
Michael Wenz is currently offline Michael WenzFriend
Messages: 1931
Registered: July 2009
Location: Walldorf, Germany
Senior Member
Palani,

that should be the way to go, but you will need some more means to identify
the right pictogram element. Maybe a property on the pictogram element
created while adding it to the diagram could help.

If I understood correctly you have two pictogram elements on one diagram
both representing the same student instance and therefor being linked to
that same instance. So the other way around you have 2 links from student to
different pictogram elements, only the first is retrieved by
getPictogramElementForBusinessObject. Only
getAllPictogramElementsForBusinessObject wil give you both.

Michael
Re: How to connect 2 elements created out of same Eobject to different pictogramelements [message #1102912 is a reply to message #1101351] Fri, 06 September 2013 07:31 Go to previous messageGo to next message
Albert Hofkamp is currently offline Albert HofkampFriend
Messages: 41
Registered: August 2009
Member
To give you an example:

In the add method, I do
    private final IPeCreateService pec = Graphiti.getPeCreateService();
    private final IPeService pes = Graphiti.getPeService();



    ContainerShape outer = pec.createContainerShape(parent, true);
    pes.setPropertyValue(outer, AUT_ELEMENT, OUTER);
    ...
    Shape hline = pec.createShape(outer, false);
    pes.setPropertyValue(hline, AUT_ELEMENT, HLINE);
I label each shape with a unique string during creation and adding of the shapes.

When I need a shape I do something like
        ContainerShape outer = (ContainerShape)elm;
        Shape hline = null;
        Shape vline = null;
        Shape kind = null;
        Shape name = null;
        for (Shape child: outer.getChildren()) {
            val = pes.getPropertyValue(child, AUT_ELEMENT);
            if (val == null) continue; // Ignore other graphical elements.

            if (val.equals(HLINE)) {
                hline = child;
            } else if (val.equals(VLINE)) {
                vline = child;
            } else if (val.equals(KIND)) {
                kind = child;
            } else if (val.equals(NAME)) {
                name = child;
            }
        }
        Assert.notNull(hline);
        Assert.notNull(vline);
        Assert.notNull(kind);
        Assert.notNull(name);
This is perhaps a bit too generic for you, but basically, I walk through all shapes, and pick out the ones with the right label. That way I know what I get.

This works much better for me than the 'isinstance' approach of the tutorial.
Re: How to connect 2 elements created out of same Eobject to different pictogramelements [message #1105616 is a reply to message #1102912] Tue, 10 September 2013 04:40 Go to previous messageGo to next message
PALANI SANKAR is currently offline PALANI SANKARFriend
Messages: 35
Registered: April 2013
Member
Hi Albert

Thanks for your reply.

But my scenario is different

For Ex: consider from project explorer i am dragging and dropping a node to graphiti and creating a shape out of that object and then again am dragging and dropping the same object and connecting the same. Now i close and reopen my editor , at that time am trying to get the shape using the node object , that is giving me only one shape. so how to address this issue and draw connection between the shapes.

Thanks
Palani


Thanks
Palani
Re: How to connect 2 elements created out of same Eobject to different pictogramelements [message #1105691 is a reply to message #1105616] Tue, 10 September 2013 07:01 Go to previous messageGo to next message
Albert Hofkamp is currently offline Albert HofkampFriend
Messages: 41
Registered: August 2009
Member
Did you look in the file itself?
For very small models, an xml file is still understandable, so you can check whether the expected number of shapes and connections are actually stored.

Another problem I found once is not setting the size of a shape, or a weird location. If you don't see two objects, that does not mean there are not two objects, some may be invisible (eg 0 width or a weird colour) or be drawn below some other object. Positions and sizes are also in the xml file, so you can check there too.
Re: How to connect 2 elements created out of same Eobject to different pictogramelements [message #1105710 is a reply to message #1105616] Tue, 10 September 2013 07:34 Go to previous message
PALANI SANKAR is currently offline PALANI SANKARFriend
Messages: 35
Registered: April 2013
Member
Hi All

Finally i got the solution. its my mistake of understanding about getAllPictogramElementsForBusinessObject() Thanks Michael and Sylvain.

Thanks
Palani


Thanks
Palani
Previous Topic:Property View - not refreshed after undo
Next Topic:Coordinates of Connection Decorators
Goto Forum:
  


Current Time: Fri Apr 19 05:47:50 GMT 2024

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

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

Back to the top