different context menu for different tree item

Hello,

I have tree view for folder/file navigation. When I right click on any tree item I want to open different context menu as per tree item.
e.g. folder a → folder b → file abc.txt
When I right click on folder a, it should display context menu with items (delete, move), and when I right click on file abc.txt it should display context menu with items(rename, open).

Action getActions(Object target, Object sender)
target and sender both has null values, so how do I decide which context menu to return?

here is my code,

private static final Action FILE_RENAME = new Action("Rename");     
private static final Action FILE_OPEN = new Action("Open");  

private static final Action DIR_DELETE = new Action("Delete");      
private static final Action DIR_MOVE = new Action("Move");   

private static final Action[] FILE_ACTIONS = new Action[]

{ FILE_RENAME,
FILE_OPEN};

private static final Action[] DIR_ACTIONS = new Action[]

{ DIR_DELETE,
DIR_MOVE};

tree.addActionHandler(new Action.Handler() {
        public Action[] getActions(Object target, Object sender) {
            return FILE_ACTIONS;
        }

        public void handleAction(Action action, Object sender, Object target) {
            if (FILE_DELETE.equals(action)) {
            }
        }

}

As long as your tree is empty getActions is only called once, with target = null and sender = null.
If the tree contains items the method is called for each item while target refers to the itemId.