Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    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 08:58 Go to next message
Mariot Chauvin is currently offline Mariot ChauvinFriend
Messages: 174
Registered: July 2009
Senior Member
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 09:43 Go to previous message
Boris Blajer is currently offline Boris BlajerFriend
Messages: 217
Registered: July 2009
Senior Member
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: Thu Sep 19 12:24:12 GMT 2024

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

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

Back to the top