Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Graphiti » Editor is dirty when create method returns EMPTY
Editor is dirty when create method returns EMPTY [message #902971] Tue, 21 August 2012 13:17 Go to next message
Joao S is currently offline Joao SFriend
Messages: 51
Registered: January 2011
Hello everyone,

Following graphiti tutorial:

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;
        // create EClass
        EClass newClass = EcoreFactory.eINSTANCE.createEClass();
        // 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.
        // do the add
        addGraphicalRepresentation(context, newClass);
        // return newly created business object(s)
        return new Object[] { newClass };

When this method returns EMPTY, the editor still gets dirty despite no object was added to the resource.

Is this the expected behaviour?

Is there anyway that I can avoid this?

Re: Editor is dirty when create method returns EMPTY [message #902978 is a reply to message #902971] Tue, 21 August 2012 13:51 Go to previous message
Rob Cernich is currently offline Rob CernichFriend
Messages: 40
Registered: September 2011
You need to override hasDoneChanges() to return true or false depending on whether or not you changed the model. Returning false will keep the dirty flag from appearing.

Hope that helps.
Previous Topic:Populating Diagram with all domain objects
Next Topic:Resize shape (only horizontal)
Goto Forum:

Current Time: Sun May 27 17:27:12 GMT 2018

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

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

Back to the top