Community
Participate
Working Groups
I extended one of our actions using the new enablement functionality but I didn't get it to work. Here is what I did: <action id="ExtractMethodAction" menubarPath="org.eclipse.jdt.ui.RefactoringMenu/codingGroup" label="%Refactoring.extractMethodAction.label" class="org.eclipse.jdt.internal.ui.refactoring.actions.ExtractMethodActi on" enablesFor="1"> </action>
Sorry, pressed commit... So lets start again. Here is what I did. I changed one of our existing action <action id="ExtractMethodAction" menubarPath="org.eclipse.jdt.ui.RefactoringMenu/codingGroup" label="%Refactoring.extractMethodAction.label" class="org.eclipse.jdt.internal.ui.refactoring.actions.ExtractMethodAction" enablesFor="1"> <== added this line </action> As a result the action is now disabled as soon as I activate an editor, even if the editor as a selection. Debugging it reveal that the SelectionEnabler assumes that the selection implements IAdaptable. This makes sense for elements of a structured selection but not for the selection itself. No I tried to use the new <selection class=""/> stuff. I changed my declaration as follows: <action id="ExtractMethodAction" menubarPath="org.eclipse.jdt.ui.RefactoringMenu/codingGroup" label="%Refactoring.extractMethodAction.label" class="org.eclipse.jdt.internal.ui.refactoring.actions.ExtractMethodAction"/> <selection class="xxxx"/> <== this class doesn't exist </action> The action was enabled all the time also I specified a totally bogus class name. Debugging this one revealed that the <selection ...> element is only considered when their is an enabledFor element. Have you every tested this stuff ? And another issue: ITextSelection is specified in a way that isEmpty never returns false. This was done (as far as I can recall a discussion with KUM) since a text selection must also mark the cursor (empty selection). So for text selection I want the possibility to only enable it when the length of an selection is > 0. Any idea how to specify this.
Support for ITextSelection was added in SelectionEnabler. Here is a action declaration that works for a ITextSelection or a StructuredSelection where the elements are IFiles: <action label="Menu Option" class="org.eclipse.ui.selectionTest.SetAction1Delegate" menubarPath="org.eclipse.selectionTest.TextSelectionMenu/group1" enablesFor="+" id="org.eclipse.ui.tests.internal.as_122"> <enablement> <or> <objectClass name="org.eclipse.jface.text.ITextSelection"/> <objectClass name="org.eclipse.core.resources.IFile"/> </or> </enablement> </action>
This solution is somehow strange. One test is used to test the selection class whereas the other tests the elements of an selection. But both tests use the property objectClass. In my opinion there should be a new property selectionClass.
Not going to fix this for 2.0.
Reopened for investigation
*** This bug has been marked as a duplicate of 7761 ***