Skip to main content



      Home
Home » Modeling » GMF (Graphical Modeling Framework) » Strange code generated by GMF in XXXVisualIDRegistry#canCreateNode(...)
Strange code generated by GMF in XXXVisualIDRegistry#canCreateNode(...) [message #161635] Tue, 20 November 2007 03:58 Go to next message
Eclipse UserFriend
Hi,

Below, a code snippet generated by GMF (SDK version 2.0.1). The second
if statement is not required and the else statement will never be called.
Does someone have an explanation ?
Thanks.

Regards,

Mariot

public static boolean canCreateNode (View view, intnodeVisualID) {

String modelID = XXXVisualIDRegistry.getModelID(view);

if (!XXXEditPart.MODEL_ID.equals(modelID)) {
return false;
}
int visualID;
if (XXXEditPart.MODEL_ID.equals(modelID)) {
visualID = XXXVisualIDRegistry.getVisualID(view);
} else {
...
}
...

}
Re: Strange code generated by GMF in XXXVisualIDRegistry#canCreateNode(...) [message #161645 is a reply to message #161635] Tue, 20 November 2007 04:43 Go to previous message
Eclipse UserFriend
Hi Mariot,

The inner if (and especially its else part) is needed in case your model
provides shortcuts to other models (in this case, the outer if is also a
bit different). You are right that a simpler code can be generated if
the model does not provide shortcuts, but this is not a error, just a
stylistic problem.

Best regards,
Boris


Mariot Chauvin wrote:
> Hi,
>
> Below, a code snippet generated by GMF (SDK version 2.0.1). The second
> if statement is not required and the else statement will never be called.
> Does someone have an explanation ?
> Thanks.
>
> Regards,
>
> Mariot
>
> public static boolean canCreateNode (View view, intnodeVisualID) {
>
> String modelID = XXXVisualIDRegistry.getModelID(view);
>
> if (!XXXEditPart.MODEL_ID.equals(modelID)) {
> return false;
> }
> int visualID;
> if (XXXEditPart.MODEL_ID.equals(modelID)) {
> visualID = XXXVisualIDRegistry.getVisualID(view);
> } else {
> ...
> }
> ...
>
> }
Previous Topic:BorderItemRectilinearRouter.
Next Topic:Implementing a Progress Monitor Dialog
Goto Forum:
  


Current Time: Mon Jul 07 11:25:05 EDT 2025

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

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

Back to the top