Community
Participate
Working Groups
The method PasteAction.canOperateOn is invoked on every selection change. This is not required and is extremely slow on many platforms. The PasteAction is checking that there is something on the clipboard that can be pasted on every single selection change event. This is an expensive operation and is entirely unneccessary. The check should be done when the user invokes Ctrl+V or when the user opens the context menu. In addition to being slow, it is not correct. Another application could change the contents of the clipboard invalidating the check performed on selection change. I am not quite sure why the selection has anything to do with pasting other than the fact that on paste, the selection will be replaced. At one time when there was a Paste toolitem in the toolbar, back then it was neccessary to poll the clipboard to toggle the enabling of the toolitem but I do not understand why that was tied to selection. I can change the contents of the clipboard to not contain any valid data using another application and the Paste menu item is still enabled in the context menu of the java editor.
Doug and I did a test where we copied a lot of text in another application (acroread), and then rapidly switched between two editor tabs in Eclipse (Linux-GTK+). We then selected some text in the Eclipse editor and rapidly switched between two tabs. We did not profile this case, but there seemed to be a visible performance difference. If the clipboard contents could be only checked before the context menu is filled, I think it would help out performance on this platform. See bug 78458 for a similar problem in the UI code.
Only checking when the context menu opens isn't an options since equivalent support is missing for global menus, toobars and short cuts (e.g we have to know when the global Edit menu pops up or when the user pressed Ctrl+V to adjust the availability of the action). I agree that we shouldn't do the check on selection change. We should perform it on run.
Tobias, a reorg move bug ;-). Please step by if you have questions.
Fixed > 20041117