Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Graphiti » Editor doesn't get dirty
Editor doesn't get dirty [message #1375711] Fri, 23 May 2014 05:23 Go to next message
Al B is currently offline Al BFriend
Messages: 130
Registered: July 2009
Senior Member
The editor doesn't get dirty when I execute the custom feature below neither inside a transaction or without it. Undo is not available either.

Any pointer will be greatly appreciated!

-----

public class MyCustomFeature extends AbstractCustomFeature {

public LayoutFeature(IFeatureProvider fp) {
super(fp);
}

@Override
public String getDescription() {
return "Layout diagram with GEF Layouter";
}

@Override
public String getName() {
return "Layout";
}

@Override
public boolean canExecute(ICustomContext context) {
return true;
}

@Override
public void execute(ICustomContext context) {
TransactionalEditingDomain ted = TransactionUtil.getEditingDomain(getDiagram());
ted.getCommandStack().execute(new RecordingCommand(ted) {
@Override
protected void doExecute() {
GraphUtil.layoutDiagram(getDiagram(), 30, getFeatureProvider());
}
});
}

}
Re: Editor doesn't get dirty [message #1376804 is a reply to message #1375711] Fri, 23 May 2014 15:36 Go to previous messageGo to next message
Al B is currently offline Al BFriend
Messages: 130
Registered: July 2009
Senior Member
For testing purpose, I replaced the above code with the exact code from TutorialLayoutDiagramFeature I still get the same results. I failed to mention that this custom feature is executed via a CustomAction. Do I explicitly need to wrap the CustomAction with a RecordingCommand?
Re: Editor doesn't get dirty [message #1376948 is a reply to message #1376804] Fri, 23 May 2014 17:04 Go to previous messageGo to next message
Al B is currently offline Al BFriend
Messages: 130
Registered: July 2009
Senior Member
Never mind. I figured it out. You need to override hasDoneChanges() and return true after the layout changes are successfully complete. That sets the Editor dirty.
Re: Editor doesn't get dirty [message #1383525 is a reply to message #1376948] Mon, 26 May 2014 12:04 Go to previous messageGo to next message
Michael Wenz is currently offline Michael WenzFriend
Messages: 1931
Registered: July 2009
Location: Walldorf, Germany
Senior Member
Just out of curiosity:

why did you get a return value of false? The default implementation in
AbstractFeature returns true...

Michael
Re: Editor doesn't get dirty [message #1384107 is a reply to message #1383525] Wed, 28 May 2014 06:47 Go to previous message
Al B is currently offline Al BFriend
Messages: 130
Registered: July 2009
Senior Member
We're actually extending from our own AbstractCustomFeature; which
extends AbstractFeature, but I didn't realize it was overriding
hasDoneChanges().
Previous Topic:Java 1.5 or 1.6 ?
Next Topic:Align elements horizontally
Goto Forum:
  


Current Time: Fri Mar 29 15:10:21 GMT 2024

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

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

Back to the top