Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Graphiti » Saving Editor in a AbstractCustomFeature = UI Deadlock
Saving Editor in a AbstractCustomFeature = UI Deadlock [message #909722] Fri, 07 September 2012 12:39 Go to next message
Sir Wayne is currently offline Sir Wayne
Messages: 206
Registered: July 2009
Senior Member
Hello community,

if i save a editor in a custom feature i will get a ui deadlock. A ProgressMonitor is still running and never end. The feature is execute by a ContextButtonEntry. The Deadlock occurs in the in org.eclipse.emf.transaction.util.Lock.class row 357.

Is it my fault or a bug?

public class MyCustomFeature extends AbstractCustomFeature
    {

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

    @Override
    public void execute(ICustomContext context)
        {
        //My Editor (GrapthitEditor) Deadlock in org.eclipse.emf.transaction.util.Lock.class 357
        PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor().doSave(new NullProgressMonitor());
        
        }

    }



EDIT:
The UI Deadlock occurs in OrderedLock row 175
		try {
			success = semaphore.acquire(delay);
		} catch (InterruptedException e) {
			if (DEBUG)
				System.out.println("[" + currentThread + "] Operation interrupted while waiting... :-|"); //$NON-NLS-1$ //$NON-NLS-2$
			//remember the interrupt to throw it later
			currentThread.interrupt();
		}


Thanks

[Updated on: Fri, 07 September 2012 12:47]

Report message to a moderator

Re: Saving Editor in a AbstractCustomFeature = UI Deadlock [message #910685 is a reply to message #909722] Mon, 10 September 2012 04:04 Go to previous messageGo to next message
Michael Wenz is currently offline Michael Wenz
Messages: 1571
Registered: July 2009
Location: Walldorf, Germany
Senior Member
As far as I know EMF transaction should block that. You have started a
change on a resource (you're in the middle of a transaction inside the
feature) and want to save that resource, which would require the resource to
be consistent...

While I thing enforcing save from inside an operation is a litel strange,
the only way I see is to trigger that is to do that asynchronously.

Michael
Re: Saving Editor in a AbstractCustomFeature = UI Deadlock [message #910708 is a reply to message #910685] Mon, 10 September 2012 04:57 Go to previous messageGo to next message
Sir Wayne is currently offline Sir Wayne
Messages: 206
Registered: July 2009
Senior Member
Yes i can explain the problem, what i need is a subtransaction.

We have a Feature which can only execute if the editor is not dirty.
If the editor is dirty, the user get a save dialog (yes/no/cancel dialog) and should save the editor.

Do you have a idea, how could i handle this in a feature? Asynchron doesn't work, because we have to wait until the editor is saved.


EDIT: But the Add and Create Feature do the same. You can call in AbstractCreateFeature the addGraphicalRepresentation method. The addGraphicalRepresentation create a new Command (AbstractAddShapeFeature) and execute
it. So it's a command (create) in a command (add)

Example AbstractCreateFeature.
    @Override
    public Object[] create(ICreateContext context)
        {
//create stuff
       ....

        // do the add and execute a new add command
        addGraphicalRepresentation(context, eObject);

        return ...

[Updated on: Mon, 10 September 2012 05:14]

Report message to a moderator

Re: Saving Editor in a AbstractCustomFeature = UI Deadlock [message #910750 is a reply to message #910708] Mon, 10 September 2012 06:29 Go to previous messageGo to next message
Michael Wenz is currently offline Michael Wenz
Messages: 1571
Registered: July 2009
Location: Walldorf, Germany
Senior Member
I see. Inside your feature you could check if the editor is saved, if yes
simply execute the operataion. If no, asynchronously trigger the saving of
the editor and end the feature. In the runnable where you save the editor,
you can simply retrigger your feature again (probably again asynchronously)
via DiagramEditor.executeFeature().

I haven't tried that but it should work.

Michael
Re: Saving Editor in a AbstractCustomFeature = UI Deadlock [message #910770 is a reply to message #910750] Mon, 10 September 2012 07:21 Go to previous message
Sir Wayne is currently offline Sir Wayne
Messages: 206
Registered: July 2009
Senior Member
Michael Wenz wrote on Mon, 10 September 2012 06:29
I see. Inside your feature you could check if the editor is saved, if yes
simply execute the operataion. If no, asynchronously trigger the saving of
the editor and end the feature. In the runnable where you save the editor,
you can simply retrigger your feature again (probably again asynchronously)
via DiagramEditor.executeFeature().

I haven't tried that but it should work.


Thanks works =)
Previous Topic:Absolute coordinates to container relative coordinates
Next Topic:Editor dirty handling
Goto Forum:
  


Current Time: Thu Jul 24 04:27:45 EDT 2014

Powered by FUDForum. Page generated in 0.05983 seconds