Disable Add Row or Delete Row buttons on form view

User c1ce6b3d19

10-10-2012 23:04:44

I built an application that uses a groovy script to create a new row.  


Is there a way to programmatically disable or remove the Add Row or Delete Row buttons on a form view?


In addition, how can I disable or remove the menu item (Data =>New Row and Data => Delete Row(s))?


 


Thanks,


Jon

ChemAxon 37bb34e128

11-10-2012 07:55:35

Hi Jon,


I am afraid there is now simple and reliable way of disabling/enabling these actions. Both the menu items and toolbar buttons are handled by the same two actions. The actions are implemented in those two classes:


com.im.ijc.core.api.actions.InsertRowAction
com.im.ijc.core.api.actions.DeleteRowsAction

You could possibly try to use something along the lines below. The problem is that the actions themselvs are enabled/disabled by IJC depending on the current selection. Therefore simply calling setEnabled(false) won't work, the actions may be and will be enabled again by IJC.


SystemAction insertAction = SystemAction.get(com.im.ijc.core.api.actions.InsertRowAction.class);
insertAction.setEnabled(false);
    
SystemAction removeAction = SystemAction.get(com.im.ijc.core.api.actions.DeleteRowsAction.class);
removeAction.setEnabled(false);

I am sorry, I don't have a better answer at the moment. But we track this requirement on our backlog as "Customisable insert and delete row actions" item.


Thanks,


-vita

ChemAxon 37bb34e128

11-10-2012 07:57:17

Ah, you might also need to...


import org.openide.util.actions.SystemAction;

-vita

User 167db55417

11-10-2012 07:59:36

Hi,


I'm also interested in the disabling add/delete row buttons or preferably binding them to my groovy scripts.


Ł.