command enable - 2 questions [message #528006] |
Sun, 18 April 2010 13:11  |
Eclipse User |
|
|
|
Hi, I have 2 questions regarding command enable:
1) I have command, defined with "org.eclipse.ui.commands" extension point. This command contributes to menu, like the following.
<extension point="org.eclipse.ui.menus">
<menuContribution locationURI="menu:navigate?after=navEnd">
<command
commandId="org...gotodriver.command"
icon="icons/drv.gif"
id="org...menu.gotogriver"
The question is how to make the command initial enable state to be disable when plugin A is installed and enable when plugin A is loaded. (like it was for action)
<viewerContribution ..
<action ...
<enablement ...
<PluginState...
2) When the plugin is loaded the command controls enable state with setEnable function according to selection in application editor (inherited from TextEditor). But the enable state is not updated for the command in navigate menu and yes updated for the command in context menu. What is absent?
public void setEnabled(Object evaluationContext) {
super.setEnabled(evaluationContext);
if (evaluationContext instanceof IEvaluationContext) {
IEvaluationContext appContext = (IEvaluationContext) evaluationContext;
ISelection selection = (ISelection) appContext .getVariable(ISources.ACTIVE_CURRENT_SELECTION_NAME);
if (selection instanceof ITextSelection) {
ITextSelection textSelection = (ITextSelection) selection;
String string = textSelection.getText();
boolean enable = isNeededText(string);
setBaseEnabled(enable);
}
}
}
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03925 seconds