Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 88527

Summary: [CellEditors] Expose CellEditorActionHandler#updateActionsEnableState()
Product: [Eclipse Project] Platform Reporter: Pratik Shah <ppshah>
Component: UIAssignee: Platform UI Triaged <platform-ui-triaged>
Status: CLOSED WONTFIX QA Contact:
Severity: normal    
Priority: P3 CC: susan, Tod_Creasey
Version: 3.1   
Target Milestone: ---   
Hardware: PC   
OS: All   
Whiteboard: stalebug
Bug Depends on:    
Bug Blocks: 75096    

Description Pratik Shah CLA 2005-03-18 16:45:45 EST
For the TextCellEditor, the actions aren't being updated enough to be in the 
right state all the time.  I can override add/removeCellEditor to add 
additional listeners, but I need to be able to invoke updateActionsEnableState
().  Can you make that method protected?  Otherwise, the 
CellEditorActionHandler should itself be responsible for keeping the default 
action handlers in the right state all the time (which might vary slightly 
depending on the type of CellEditor).

Is it possible to get this done for 3.1M6?
Comment 1 Pratik Shah CLA 2005-04-13 17:59:03 EDT
too late for 3.1?
Comment 2 Tod Creasey CLA 2005-04-14 09:28:29 EDT
I'm afraid so.
Comment 3 Susan McCourt CLA 2005-07-06 14:50:35 EDT
Pratik - can you please expand upon your first comment?  In what cases should 
the actions be updated that we are not currently handling?  It sounds like 
there are particular listeners that need to be added for different kinds of 
cell editors.  Attaching your workaround code would help in explaining the 
problem.

If it seems like a general problem and that extending the action handler is 
the right solution, we can make the method protected, but I want to explore 
whether this can/should be fixed inside.
Comment 4 Pratik Shah CLA 2005-07-14 16:05:23 EDT
Currently, if you bring up a TextCellEditor with two words (say "some text") 
and all the text selected, you can follow these steps to see that the actions 
are not enabled properly:

Hit "End" key.  At this point copy, cut and delete should be disabled, but are 
not.

Hit Ctrl+Shift+Left Arrow to select the last word.  At this point copy, cut 
and delete should be enabled, but they are not.

Again hit Ctrl+Shift+Left Arrow to select everything and then hit the 
backspace key to delete everything.  At this point, cut, copy and delete are 
still enabled.

This is reproducible in GEF's logic example.  We do not have a workaround for 
this right now.

The problem here is that the action's state at all times is what it should've 
been before the last keystroke, and is really caused by TextCellEditor.  This 
bug was introduced by the fix for bug 14201.  TextCellEditor updates the 
actions' enablement on keyPressed() instead of keyReleased(), and hence before 
the change resulting from that keystroke is applied.  As a result, the 
actions' enablement state is always one keystroke behind.

There is a comment in TextCellEditor#createControl() that says that mouse and 
key listeners are used to determine selection changes because selection 
listeners are not supported.  However, I see an addSelectionListener() in Text 
now (that probably wasn't there originally).  Maybe the TextCellEditor can 
switch to using that mechanism?  That will simplify the code, fix this 
problem, and hopefully won't break the API (since TextCellEditor is marked as 
not to be subclassed).  

Otherwise the simpler solution would be to update the actions' state not just 
when the key is pressed, but also when it is released.
Comment 5 Randy Hudson CLA 2005-07-14 17:29:52 EDT
Sounds like a great opportunity to use asyncExec ;-)
Comment 6 Eric Moffatt CLA 2005-08-15 10:46:18 EDT
*** Bug 83474 has been marked as a duplicate of this bug. ***
Comment 7 Eric Moffatt CLA 2005-08-15 10:47:04 EDT
*** Bug 97732 has been marked as a duplicate of this bug. ***
Comment 8 Eric Moffatt CLA 2007-07-11 11:08:30 EDT
just tried this using the propertysheet example and the menu seems to be correct all the time...
Comment 9 Pratik Shah CLA 2007-07-11 11:40:00 EDT
Eric, can you clarify how you verified this?  I am still seeing this problem in the property sheet with the EMF Ecore editor in 3.3RC4.
Comment 10 Randy Hudson CLA 2007-07-11 20:50:19 EDT
> just tried this using the propertysheet example and the menu seems to be
> correct all the time...

I imagine Pratik is referring to the actions that are associated with keybindings. There is also a native context menu for a text control, but its contents are not related to the problem.
Comment 11 Eric Moffatt CLA 2007-07-16 11:43:43 EDT
Randy, I tried the scenario as described in comment #4...these are all 'standard' commands used by the Text control itself. It's conceivable that there may be some 'bound' Copy/Paste command in the ECore code itself I suppose...

Pratik, What I did was to start a fresh workspace, connect to CVS and check out 'org.eclipse.ui.examples.propertysheet'. This is our reference implementation. Then run an 'inner' (i.e. through the 'Run/Debug' menu).

In the inner, create a project (any type), add a file "foo.usr" to it. It should open the file and the Outline view should be showing some names (of golfers). If you open the Properties view at this point and select a name in the Outline you should see that person's 'properties'. At this point I activated a text editing control and ran your scenarios...
Comment 12 Pratik Shah CLA 2007-07-16 12:38:49 EDT
As Randy mentioned in comment 10, I am talking about the copy/cut/paste actions under the Edit menu of the menubar, not on the cell editor's context menu.  Is that what you were checking, Eric?
Comment 13 Eric Moffatt CLA 2007-07-19 10:07:19 EDT
Aha, yes indeed that was what I was looking at...I'll re-test and get back.
Comment 14 Eclipse Webmaster CLA 2019-09-06 15:32:37 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.
Comment 15 Eclipse Genie CLA 2021-11-28 11:48:01 EST
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. As such, we're closing this bug.

If you have further information on the current state of the bug, please add it and reopen this bug. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.