Bug 125437 [Commands] handlers: TextActionHandler does not properly maintain enablement of its delegate actions
In order to synchronize enablement behavior of global clipboard actions managed by TextActionHandler with Text control's native context menu, the following rules should be observed: 1. Cut, Paste and Delete should only be enabled for editable Text fields 2. In addition, Paste should only be enabled if there is textual content on the clipboard 3. Select All should only be enabled when there is at least one character in the Text control Furthermore, TextActionHandler does not properly update enablement in its addText(Text) method. For one, it assumes that the Text control being added is currently active, OR that this method will be called before set<Action>(IAction) methods are (which properly update enablement). This may not be the case, particularly in scenarios where the global actions are shared (e.g., editor's action bar contributor) and controls are added only after the actions have been set. This is in follow-up to bugs.eclipse.org/bugs/show_bug.cgi?id=124673. Apparently, I didn't catch all of the problems with TextActionHandler. A proposed patch is attached.
bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/actions/TextActionHandler.java
protected CutActionHandler() {
            super(IDEWorkbenchMessages.Cut);
            setId("TextCutActionHandler");
            setEnabled(false);
            PlatformUI.getWorkbench().getHelpSystem().setHelp(this,
					IIDEHelpContextIds.TEXT_CUT_ACTION);
        }
        public void runWithEvent(Event event) {
            if (activeTextControl != null && !activeTextControl.isDisposed()) {
                activeTextControl.cut();
                updateActionsEnableState();
                return;
            }
            if (cutAction != null) {
                cutAction.runWithEvent(event);
                return;
            }
        }
        /**
         * Update state.
         */
        public void updateEnabledState() {
            if (activeTextControl != null && !activeTextControl.isDisposed()) {
                setEnabled(activeTextControl.getSelectionCount() > 0);