Disable menu item at runtime

I have a menu in LibreOffice toolbar and I would like to disable/enable items at runtime.
For example:

  • MyMenu > Login (Enabled)
  • MyMenu > Logout (Disabled)

Click login and when the login is done with success

  • MyMenu > Login (Disabled)
  • MyMenu > Logout (Enabled)

But I’ve no idea to do this !

Windows 7 - Writer - Java