Friday, January 8, 2010

Add-In Extension: Create default methods for classes

May be you know the Add-In for automated creation of find(..) & exists(..) method for tables provided by Axaptapedia?

Well, I have created a similar Add-In for classes. The goal of that Add-In is the same as the find(..) & exists(..) Add-In, to speed up code implementation.

What's the functionality?
  • It creates required abstract and interface methods
  • If the class is not abstract, a protected new(..) and a static construct(..) constructor will be created
  • If the class is in the RunBase tree, a static main(..) method is created
  • Already created methods will not be touched

How to install:
  • Import this XPO containing a private project with a class and a menu item.
  • Add the menu Item to the menu SysContextMenu (you can decide on what position)
  • Add a the code below to the class method SysContextMenu/verifyItem before line 217 (switch menuItem)
    case menuItemActionStr(DEV_CreateDefClsMeths):
        return ! docNode && _firstType == UtilElementType::Class;
  • In AOT, select a class and open context menu/Add-Ins. You will see now the new entry named Create default class methods. Klick it to process.
Tip: place the modification on a private layer (a layer which is used internally only): it's not really customer related, so you don't have to deliver it to them.

It works in AX 2009. Not tested for AX 4.0

(this article is available in English only)

5 comments:

  1. He,

    I have to follow this procedure but it doesn't work in AX2009 SP1 ?

    I cannot to see the menu item in the Add-Ins menu.

    It is very strange :s

    ReplyDelete
  2. Hi 'Developer'

    Check the follow conditions:
    - is the menu item really present in SysContextMenu?
    - is the first item selected in AOT a class node?

    You can try to remove the modification in class method SysContextMenu.verifyItem(). After that, the context menu entry should be shown for every AOT node.

    If this helps not, please let me know!

    ReplyDelete
  3. The muenu item code is added in the SysContextMenu class but it is not visible in the menu.

    The first item selected in AOT is offcourse a class node. I have to place the modification in the first case of the menuitem-action switch but it doesn't help :(

    ReplyDelete
  4. The SysContextMenu.verifyItem() modification is optional. But I guess, you have not added the MENUITEM to the AOT\MENUS\SysContextMenu and therefore you cannot see the menu.

    Please check the
    AOT\Menus\SysContextMenu menu.

    By the way: if it does not work again - I can send you a step by step document. Send me a message at patrick[AT]luegisdorf.ch

    Till later

    ReplyDelete
  5. Hi Patrick,

    It works now :) I have a mistake, I forget to add the menu item in the SysContextMenu. It's very shamefull for my.

    I thanks you for your help. Very great ;)

    Greetings

    ReplyDelete