Author: mareshkau
Date: 2011-01-18 11:21:35 -0500 (Tue, 18 Jan 2011)
New Revision: 28356
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/i18n/handlers/I18nHandler.java
Log:
https://issues.jboss.org/browse/JBIDE-8138
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/i18n/handlers/I18nHandler.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/i18n/handlers/I18nHandler.java 2011-01-18
16:17:44 UTC (rev 28355)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/i18n/handlers/I18nHandler.java 2011-01-18
16:21:35 UTC (rev 28356)
@@ -17,10 +17,12 @@
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.commands.HandlerEvent;
+import org.eclipse.core.expressions.IEvaluationContext;
import org.eclipse.jface.text.TextSelection;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.ISources;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.commands.IElementUpdater;
import org.eclipse.ui.handlers.HandlerUtil;
@@ -40,17 +42,16 @@
@Override
public void setEnabled(Object evaluationContext) {
- IEditorPart activeEditor= PlatformUI
- .getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
- boolean enabled;
- if(activeEditor instanceof ITextEditor){
- ITextEditor txtEditor = (ITextEditor) activeEditor;
- ISelection selection = txtEditor.getSelectionProvider().getSelection();
- enabled = getExternalizeStringsCommandEnabled(selection);
- } else {
- enabled = false;
+ boolean enabled=false;
+ if (evaluationContext instanceof IEvaluationContext) {
+ IEvaluationContext context = (IEvaluationContext) evaluationContext;
+ Object activeEditor = context.getVariable(ISources.ACTIVE_EDITOR_NAME);
+ if(activeEditor instanceof ITextEditor){
+ ITextEditor txtEditor = (ITextEditor) activeEditor;
+ ISelection selection = txtEditor.getSelectionProvider().getSelection();
+ enabled = getExternalizeStringsCommandEnabled(selection);
+ }
}
-
if (isEnabled() != enabled) {
setBaseEnabled(enabled);
}