Page 1 of 1
Togglable Custom Toolbar Button
Posted: Wed May 14, 2014 1:50 am
by byoung
Is it possible to create a custom toolbar (with custom actions) and have buttons which toggle?
The scenario I have is this:
My customer, for whom I'm developing extensions, works with legal documents, and in some sections of the documents, change tracking must be turned on and not disabled by the user. I have hidden the toolbar, since all attempts to disable the common actions have failed, and I have created a custom action to toggle change tracking. I want the button on the toolbar to reflect the current state.
Ideally, I would not want to have to create a separate action, but would rather be able to exert some control over the out-of-the-box Author Review toolbar and menu items. If there is a way to do that, instead of the custom toolbars, I would like to know how.
Regards
Bill
Re: Togglable Custom Toolbar Button
Posted: Wed May 14, 2014 11:15 am
by Radu
Hi Bill,
Is it possible to create a custom toolbar (with custom actions) and have buttons which toggle?
Right now you cannot define an author action in a document type association with toggle behavior (only push button). But we'll try to provide this useful functionality in a future version and I will also update this forum thread when this happens.
One workaround for this approach would be for you to create a Workspace Access plugin using our Plugins SDK:
http://www.oxygenxml.com/oxygen_sdk.htm ... er_Plugins
A workspace access plugin can add any type of Swing button to the toolbar so instead of creating the action you would be creating the toolbar button itself.
Ideally, I would not want to have to create a separate action, but would rather be able to exert some control over the out-of-the-box Author Review toolbar and menu items. If there is a way to do that, instead of the custom toolbars, I would like to know how.
You have the API:
AuthorAccess.getEditorAccess().WSAuthorEditorPageBase.getActionsProvider()
which would allow you to get access to the Swing action for tracking changes we mount on the toolbar.
Probably in your ExtensionsBundle customization on the
createAuthorExtensionStateListener() callback when you receive the callback
ro.sync.ecss.extensions.api.AuthorExtensionStateListener.activated(AuthorAccess) you could use the API above to get access to that specific action and then maybe add a caret listener in order to enable/disable it.
Regards,
Radu
Re: Togglable Custom Toolbar Button
Posted: Wed May 14, 2014 3:17 pm
by byoung
Thank you for the quick response, Radu.
I've tried gaining access through getActionProvider (though not via WSAuthorEditorPageBase) - rather through authorAccess.getEditorAccess().getActionsProvider().getAuthorCommonActions().get("Edit/Track_Changes").
What I observed is that I can "try" to toggle, but what happens is something else takes over and re-establishes the default behavior. I can actually see the button change state briefly. I will try WSAuthorEditorPageBase, as you suggest, and see if that behaves any differently.
I realize I failed to mention in the original post - this is standalone Author.
Thanks, again
Bill
Re: Togglable Custom Toolbar Button
Posted: Wed May 14, 2014 4:11 pm
by Radu
Hi Bill,
I think you are on the right track.
So you tried to add some kind of caret listener and disable the actions in certain places?
Our own code also goes through the actions and enables them when the XML is opened and it might also enable/disable them based on certain listeners (caret, mouse) so it probably interferes with what you are trying to do.
You could try to add a property changed listener on the action and if the enabled property has not been changed by you (you can look at a boolean field you create in the class which you can set to "true" before you disable the action and to "false" after the action is disabled) then change the action's enabled flag back to its original value.
Regards,
Radu
Re: Togglable Custom Toolbar Button
Posted: Wed May 14, 2014 4:52 pm
by byoung
That sounds like a reasonable suggestion, Radu. I'll give that a try.
Re: Togglable Custom Toolbar Button
Posted: Wed May 14, 2014 4:59 pm
by byoung
Hi, again, Radu
To answer your question, yes, I have a caret listener which attempts to change the actions:
Code: Select all
AuthorEditorAccess editorAccess = authorAccess.getEditorAccess();
if (<my XPath based condition>) {
for (String key : new String[] { "Edit/Track_Changes", "Edit/Accept_Change" }) {
AbstractAction action =
(AbstractAction) editorAccess.getActionsProvider().getAuthorCommonActions().get(key);
action.setEnabled(false);
}
}
Bill
Re: Togglable Custom Toolbar Button
Posted: Wed May 14, 2014 5:44 pm
by byoung
Hi Radu
It looks like your PropertyChangeListener suggestion is going to work for us.
Thank you!
Bill