Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Graphiti » Loading/Saving Diagrams
Loading/Saving Diagrams [message #990459] Wed, 12 December 2012 15:25 Go to next message
Simon Schimansky is currently offline Simon SchimanskyFriend
Messages: 4
Registered: December 2012
Junior Member
Hi,
i am just learning the ropes. I want to build a simple editor to model Houses and put home automation features in it. therefore i generated a EMF, that covers all the Objects and relations i need.

The following screenshot shows the only 2 Objects, which have create and add features by now:
index.php/fa/12679/0/
I can create objects and i can link them. I can also save the file and close it. If i open it again, the diagram is loaded correctly. However, if i close the program (that i started via Run/debug as in eclipse), and open it again, i cannot open the diagram again. I get a class not found exception for "RoomlessAutomationObject".
ClassNotFoundException: Class 'RoomlessAutomationObject' is not found or is abstract. (platform:/resource/HomeAuto/src/diagrams/newDiagram.diagram, 27, 59)	newDiagram.diagram	/HomeAuto/src/diagrams	line 27, column 59


Too keep it simple, i just used and adopted the tutorial Code to create my add and create features. Here are the create functions of the link and the object:
Object:
 public Object[] create(ICreateContext context) {
        // ask user for EClass name
        String newClassName = ExampleUtil.askString(TITLE, USER_QUESTION, "");
        if (newClassName == null || newClassName.trim().length() == 0) {
            return EMPTY;
        }
 
        
        RoomlessAutomationObject rlao = HomeAutomationFactory.eINSTANCE.createRoomlessAutomationObject();
       
        rlao.setName(newClassName);
 
        // do the add
        addGraphicalRepresentation(context, rlao);
 
        // return newly created business object(s)
        return new Object[] { rlao };
    }


Link:
 public Connection create(ICreateConnectionContext context) {
        Connection newConnection = null;
 
        // get RoomlessAutomationObjects which should be connected
        RoomlessAutomationObject source = getRoomlessAutomationObject(context.getSourceAnchor());
        RoomlessAutomationObject target = getRoomlessAutomationObject(context.getTargetAnchor());
 
        if (source != null && target != null) {
            // create new business object 
            AutomationLink addedLink = createAutomationLink(source, target);
            // add connection for business object
            AddConnectionContext addContext =
                new AddConnectionContext(context.getSourceAnchor(), context
                    .getTargetAnchor());
            addContext.setNewObject(addedLink);
            newConnection =
                (Connection) getFeatureProvider().addIfPossible(addContext);
        }
        
        return newConnection;
    }

 private AutomationLink createAutomationLink(RoomlessAutomationObject source, RoomlessAutomationObject target) {
        AutomationLink addedLink = HomeAutomationFactory.eINSTANCE.createAutomationLink();
        addedLink.setName("new Link");
        addedLink.setTarget(target);
        addedLink.setSource(source);
        source.getOutgoingLinks().add(addedLink);
        target.getIncomingLinks().add(addedLink);
        return addedLink;
   }


I hope you can help me. Thanks in advance and thanks for the awesome tutorial!

Greetings,
Simon
  • Attachment: forum1.png
    (Size: 12.38KB, Downloaded 616 times)
Re: Loading/Saving Diagrams [message #990717 is a reply to message #990459] Thu, 13 December 2012 13:18 Go to previous messageGo to next message
Michael Wenz is currently offline Michael WenzFriend
Messages: 1931
Registered: July 2009
Location: Walldorf, Germany
Senior Member
Simon,

it seems the part that adds the new RoomlessAutomationObject to an EMF
resource is missing in your create feature for that object just after the
creation. Something like:

// Add model element to resource.
// We add the model element to the resource of the diagram for
// simplicity's sake. Normally, a customer would use its own
// model persistence layer for storing the business model separately.
getDiagram().eResource().getContents().add(newClass);

Michael
Re: Loading/Saving Diagrams [message #1058972 is a reply to message #990717] Thu, 16 May 2013 06:00 Go to previous messageGo to next message
anudeep arya is currently offline anudeep aryaFriend
Messages: 49
Registered: March 2013
Member
Hi i am new to graphiti .i am able to create graphiti diagram from my EMF model but i want the diagram file to contain coordinate information of all pictograms in xml format..i am not able to load the graphiti diagram for the next time from this xml file ..

i have created a new xml document object in my addFeature method and added the required features in the file
Re: Loading/Saving Diagrams [message #1059303 is a reply to message #1058972] Fri, 17 May 2013 13:20 Go to previous messageGo to next message
Michael Wenz is currently offline Michael WenzFriend
Messages: 1931
Registered: July 2009
Location: Walldorf, Germany
Senior Member
Hi,

not sure what exactly your point is...

The Graphiti diagram file (or better the pictogram EOBjects stored there)
have the x,y information stored along with them. They are relative to their
parent and set within the add feature that creates them.

Michael
Re: Loading/Saving Diagrams [message #1059338 is a reply to message #1059303] Fri, 17 May 2013 14:47 Go to previous message
Andrej K is currently offline Andrej KFriend
Messages: 26
Registered: March 2013
Location: germany
Junior Member
@Simon Schimansky problem:
i solved this problem by putting my emf "generated" project and graphiti together, so i have one project with Graphiti and EMF
Previous Topic:Synchronize of cetaed elements with property view
Next Topic:CustomFeature's create & get all Elements
Goto Forum:
  


Current Time: Sat Apr 20 00:42:11 GMT 2024

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

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

Back to the top