Loading/Saving Diagrams [message #990459] |
Wed, 12 December 2012 15:25 |
Simon Schimansky 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:
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)
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03039 seconds