Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » Weird bug with Eclipse BPMN modeler in SetCommand.create
Weird bug with Eclipse BPMN modeler in SetCommand.create [message #726360] Sat, 17 September 2011 15:59 Go to next message
Paul Keryon is currently offline Paul KeryonFriend
Messages: 5
Registered: April 2011
Junior Member
Hi, I'm using the BPMN modeler code to create drag'n'drop annotations, and it's working fine excepted that when the annotation icon is added, the entire editor seems like "resetting" and two simple views (extending ViewPart and no observers, no interacting with editing domain) are weirdly closed


The code which is provoking the closure is the following

protected Command createEAnnotationDropCommand(final EAnnotation ea, final EModelElement element) 
	{
		AbstractTransactionalCommand command = new EasyCommand(element) 
		{

			@Override
			protected CommandResult doExecuteWithResult
			(
					IProgressMonitor monitor, IAdaptable info) 
			throws ExecutionException 
			{
				if (element.getEAnnotation(ea.getSource()) != null) 
				{
					RemoveCommand.create(getEditingDomain(), element,
							EcorePackage.eINSTANCE.getEModelElement_EAnnotations(),
							element.getEAnnotation(ea.getSource())).execute();
				}

				SetCommand.create(getEditingDomain(), ea, 
						EcorePackage.eINSTANCE.getEAnnotation_EModelElement(),
						element).execute();
				
				
				return CommandResult.newOKCommandResult();
			}
		};
		return new ICommandProxy(command);
	}



Every time the command is dispatched (so the function returns CommandResult.newOKCommandResult() ), the views are shut down.. after that I get the error

org.eclipse.swt.SWTException: Widget is disposed

but I think it's logic because the views have been closed by "something"

I've searched a lot but found nothing, might this be a gmf bug?
Re: Weird bug with Eclipse BPMN modeler in SetCommand.create [message #726364 is a reply to message #726360] Sat, 17 September 2011 16:29 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33137
Registered: July 2009
Senior Member
<html>
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
Paul,<br>
<br>
Comments below.<br>
<br>
On 17/09/2011 8:59 AM, Paul Keryon wrote:
<blockquote cite="mid:j52fg0$n4e$1@news.eclipse.org" type="cite">Hi,
I'm using the BPMN modeler code to create drag'n'drop annotations,
and it's working fine excepted that when the annotation icon is
added, the entire editor seems like "resetting" and two simple
views (extending ViewPart and no observers, no interacting with
editing domain) are weirdly closed
<br>
<br>
<br>
The code which is provoking the closure is the following
<br>
<br>
protected Command createEAnnotationDropCommand(final EAnnotation
ea, final EModelElement element)     {
<br>
        AbstractTransactionalCommand command = new
EasyCommand(element)         {
<br>
<br>
            @Override
<br>
            protected CommandResult doExecuteWithResult
<br>
            (
<br>
                    IProgressMonitor monitor, IAdaptable info)
            throws ExecutionException             {
<br>
                if (element.getEAnnotation(ea.getSource()) !=
null)                 {
<br>
                    RemoveCommand.create(getEditingDomain(),
element,
<br>
                           
EcorePackage.eINSTANCE.getEModelElement_EAnnotations(),
<br>
</blockquote>
Note that EcorePackage.Literals.EMODEL_ELEMENT__EANNOTATIONS is a
little more efficient...<br>
<blockquote cite="mid:j52fg0$n4e$1@news.eclipse.org" type="cite">                           
element.getEAnnotation(ea.getSource())).execute();
<br>
</blockquote>
So if there's an annotation with the same source URI you remove
it.   I'm not sure why these are being done as nested commands.  Why
not just operate directly via the APIs.  After all, there's nothing
being done with these commands here that's going to help support
undo.<br>
<blockquote cite="mid:j52fg0$n4e$1@news.eclipse.org" type="cite">               
}
<br>
<br>
                SetCommand.create(getEditingDomain(), ea,
                       
EcorePackage.eINSTANCE.getEAnnotation_EModelElement(),
<br>
                        element).execute();
<br>
</blockquote>
I could see this resulting in a command that's not executable.  It
would be better to operate on the multi-valued side using an
AddCommand. Is the ea contained somewhere else at this point?<br>
<br>
Also note this important statement in the Javadoc for
Command.execute.<br>
<br>
  /**<br>
   * Performs the command activity required for the effect.<br>
<b>   * The effect of calling &lt;code&gt;execute&lt;/code&gt; when
&lt;code&gt;canExecute&lt;/code&gt; returns
&lt;code&gt;false&lt;/code&gt;, <br>
   * or when &lt;code&gt;canExecute&lt;/code&gt; hasn't been
called, is undefined.</b><br>
   */<br>
<br>
Commands should be executed on the command stack, and that always
checks to see if they are in fact executable.   Also, as I mentioned
already, here your use of commands doesn't really seem to make sense
to me.<br>
<blockquote cite="mid:j52fg0$n4e$1@news.eclipse.org" type="cite">               
<br>
                <br>
                return CommandResult.newOKCommandResult();
<br>
            }
<br>
        };
<br>
        return new ICommandProxy(command);
<br>
    }
<br>
<br>
<br>
Every time the command is dispatched (so the function returns
CommandResult.newOKCommandResult() ), the views are shut down..
after that I get the error
<br>
<br>
org.eclipse.swt.SWTException: Widget is disposed
<br>
<br>
but I think it's logic because the views have been closed by
"something"
<br>
<br>
I've searched a lot but found nothing, might this be a gmf bug?
<br>
</blockquote>
</body>
</html>


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:Same type of diagram in the compartments
Next Topic:[solved] Connection Label from Reference Attribute
Goto Forum:
  


Current Time: Fri Apr 19 21:52:23 GMT 2024

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

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

Back to the top