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 01:23 Go to next message
Al B is currently offline Al B
Messages: 129
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 11:36 Go to previous messageGo to next message
Al B is currently offline Al B
Messages: 129
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 13:04 Go to previous messageGo to next message
Al B is currently offline Al B
Messages: 129
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 08:04 Go to previous messageGo to next message
Michael Wenz is currently offline Michael Wenz
Messages: 1590
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 02:47 Go to previous message
Al B is currently offline Al B
Messages: 129
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: Mon Sep 01 03:32:34 EDT 2014

Powered by FUDForum. Page generated in 0.01853 seconds