Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [gmf-dev] Referencing the object corresponding to the canvas

Hello,

This news-group is internal, it would be better to ask questions like this in the forum at http://www.eclipse.org/forums/index.php/f/16/.

Anyway, to my understanding, your case is not supported out of the box, so some manual tweaks are required.
I have just reproduces the similar situation with one of the small testing models.
Here I have a Diagram(=your Model) that has not-containment refs to Borders(=your Element's), and separate UltimateContainer which has the actual containments to Borders.
UltimateContainer itself is contained in the Diagram but the same trick will work with whatever logic for choosing actual container, provided you have a navigable path from Diagram to that appropriate container.

So I did the following. In the map model, node reference for Border (= Element),
- set "containment feature" to the actual containment (UltimateContainer#borders)
- set "children feature" the the non-containment reference from canvas to element (Diagram#borders)
- ignored the "Top Level Node Containment Feature must be available in the diagram..." warning for GmfGen model after transformation
- in the generated class LineBorderCreateCommand (something like ElementCreateCommand in your case, you will find it by compilation error ignored warning had warn you about) did the following manual change:

/**
* @generated NOT
*/
protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
    LineBorder newElement = BordersFactory.eINSTANCE.createLineBorder();
   
    //was generated: UltimateContainer owner = (UltimateContainer) getElementToEdit();
    //<begin changes> *** replace with your knowledge about where to put newElement ***
    Diagram diagram = (Diagram)getElementToEdit();
    UltimateContainer owner = diagram.getContainer();
    if (owner == null) {
        owner = BordersFactory.eINSTANCE.createUltimateContainer();
        diagram.setContainer(owner);
    }
    //<end of changes>
           
    owner.getBorders().add(newElement);
    Diagram childHolder = (Diagram) getElementToEdit();
    childHolder.getBorders().add(newElement);

    doConfigure(newElement, monitor, info);

    ((CreateElementRequest) getRequest()).setNewElement(newElement);
    return CommandResult.newOKCommandResult(newElement);
}

If this does not work for you, please post to forum (you may also wish to notify me personally about your post to speed up the things).

Attaching my sample here,
Hope that helps,
Regards,
Michael

--

Michael "Borlander" Golubev
Eclipse Committer (GMF, UML2Tools)
at Montages Think Tank, 
Prague, Czech Republic
1165/1 Dvorecka, 14700, Prague-4 Podoli

tek: +420 602 483 463



On Mon, Oct 21, 2013 at 4:18 PM, Paul C. Brown <pbrown1@xxxxxxxxxxxx> wrote:

I have a Model class that has a list of Elements, but it is not a containment relation (Elements have a containment relation with other elements). Each Element has a reference to the model in which it is presently located. The canvas on the diagram corresponds to the Model.

 

When I add an Element to the canvas, I need to set the value of the Model reference. My understanding is that I need to use an ocl _expression_, but I can’t figure out how to reference either the canvas or its corresponding Model in this _expression_. Can someone tell me how to do this?

 

n  PCB

 

******************************************************************************************

Paul C. Brown                                                                                            

Principal Software Architect

TIBCO Software Inc.

Email: pbrown@xxxxxxxxx               Mobile: 518-424-5360

 

"Total architecture is not a choice - it is a concession to reality."          

Visit  www.total-architecture.com

Architecture Books:

-- Succeeding With SOA: Realizing Business Value Through Total Architecture

-- Implementing SOA: Total Architecture In Practice

-- TIBCO Architecture Fundamentals

-- Architecting Composite Applications and Services with TIBCO

-- Architecting Complex-Event Processing Solutions with TIBCO

 

The SOA Manifesto: soa-manifesto.org

  TCA

Would you fly on a plane without a certified pilot?

Then why aren’t your projects being led by TIBCO-Certified Architects?

******************************************************************************************

 

 

 


_______________________________________________
gmf-dev mailing list
gmf-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/gmf-dev




Attachment: canvas-not-containing-nodes.zip
Description: Zip archive


Back to the top