I have tried the solution of a PopUpMenuCustomizer but in that specific case I can not add an ActionPerformedListener.
This kind of listener is not available for JMenuItem element and I only can improve ActionListener.
But it is launched after the action is performed.
Once you get access to the "Copy" JMenuItem you are interested in, you can get its internal swing "AbstractAction", then you can create your own Swing action with the same name and icon which wraps the "AbstractAction" you found in the JMenuItem. In this way your action will be called first, you change the selection and invoke the original action.
Or as an alternative this might also work (but you would need to test it):
Code: Select all
but you would need to take care not to add the same listener twice to the same action because the popup menu customizer is called every time the end user right clicks.
Is it possible to change/modify the ClipboardFragmentInformation directly ?
I know, it is possible to create an AuthorDocumentFragment from the document via the API authorPage.getAuthorAccess().getDocumentController().createDocumentFragment(startCaret, endCaret);
Is it possible to use it to replace the fragment in the clipboard ?
Or maybe update nodes in ClipboardFragmentInformation.getFragment().getContentNodes() ?
That's why I mentioned that we should maybe add new API. Somehow if we had this new API, when the "Copy" operation is invoked, Oxygen could call back to your code and tell you what fragments it will copy in the clipboard, allow you to modify the fragments and also maybe add some custom objects to the clipboard (maybe a set of properties). Then on the "Paste" somehow your code would be invoked again and you would receive those custom properties back, properties which might give you indications about how to change the document fragment. I'll add an issue on our side to look into this.