Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian Ratz2017-07-10 05:29:45 -0400
committerSebastian Ratz2017-11-15 12:08:01 -0500
commit6758b1974631342370488a9a781e6b30b528c5ae (patch)
tree0dbf862d1a9f1acab588ed729d3cc349e280d910 /org.eclipse.ui.workbench.texteditor
parent4e9bd88ff6da2d59ca521a78e1ee397cc1ebcfd8 (diff)
downloadeclipse.platform.text-6758b1974631342370488a9a781e6b30b528c5ae.tar.gz
eclipse.platform.text-6758b1974631342370488a9a781e6b30b528c5ae.tar.xz
eclipse.platform.text-6758b1974631342370488a9a781e6b30b528c5ae.zip
Bug 518939 - Fix text zoom enablement in multi page editorsI20171119-2000I20171118-1500I20171117-2000I20171116-2000I20171115-2000
Change-Id: I2b13a98af986419a38b63043aa680b3e8d628fd2 Signed-off-by: Sebastian Ratz <sebastian.ratz@sap.com>
Diffstat (limited to 'org.eclipse.ui.workbench.texteditor')
-rw-r--r--org.eclipse.ui.workbench.texteditor/plugin.xml14
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/AbstractTextZoomHandler.java20
2 files changed, 16 insertions, 18 deletions
diff --git a/org.eclipse.ui.workbench.texteditor/plugin.xml b/org.eclipse.ui.workbench.texteditor/plugin.xml
index 7316269fb..c5b9c212c 100644
--- a/org.eclipse.ui.workbench.texteditor/plugin.xml
+++ b/org.eclipse.ui.workbench.texteditor/plugin.xml
@@ -1308,24 +1308,10 @@
<handler
class="org.eclipse.ui.texteditor.TextZoomInHandler"
commandId="org.eclipse.ui.edit.text.zoomIn">
- <enabledWhen>
- <with variable="activePart">
- <instanceof
- value="org.eclipse.ui.texteditor.ITextEditor">
- </instanceof>
- </with>
- </enabledWhen>
</handler>
<handler
class="org.eclipse.ui.texteditor.TextZoomOutHandler"
commandId="org.eclipse.ui.edit.text.zoomOut">
- <enabledWhen>
- <with variable="activePart">
- <instanceof
- value="org.eclipse.ui.texteditor.ITextEditor">
- </instanceof>
- </with>
- </enabledWhen>
</handler>
</extension>
<extension
diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/AbstractTextZoomHandler.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/AbstractTextZoomHandler.java
index d65e48989..d08250311 100644
--- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/AbstractTextZoomHandler.java
+++ b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/AbstractTextZoomHandler.java
@@ -22,6 +22,7 @@ import org.eclipse.swt.graphics.FontData;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.expressions.IEvaluationContext;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.Platform;
@@ -31,7 +32,8 @@ import org.eclipse.jface.resource.FontDescriptor;
import org.eclipse.jface.resource.FontRegistry;
import org.eclipse.jface.resource.JFaceResources;
-import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.ISources;
import org.eclipse.ui.handlers.HandlerUtil;
import org.eclipse.ui.part.AbstractMultiEditor;
import org.eclipse.ui.part.MultiPageEditorPart;
@@ -93,7 +95,10 @@ abstract class AbstractTextZoomHandler extends AbstractHandler {
}
private AbstractTextEditor getActiveTextEditor(ExecutionEvent event) {
- IWorkbenchPart part= HandlerUtil.getActiveEditor(event);
+ return getActiveTextEditor(HandlerUtil.getActiveEditor(event));
+ }
+
+ private AbstractTextEditor getActiveTextEditor(IEditorPart part) {
if (part instanceof AbstractTextEditor) {
return (AbstractTextEditor)part;
} else if ((part instanceof AbstractMultiEditor) && ((AbstractMultiEditor)part).getActiveEditor() instanceof AbstractTextEditor) {
@@ -105,8 +110,15 @@ abstract class AbstractTextZoomHandler extends AbstractHandler {
}
@Override
- public boolean isEnabled() {
- return true;
+ public void setEnabled(Object evaluationContext) {
+ boolean enabled = false;
+ if (evaluationContext instanceof IEvaluationContext) {
+ Object activeEditor = ((IEvaluationContext) evaluationContext).getVariable(ISources.ACTIVE_EDITOR_NAME);
+ if (activeEditor instanceof IEditorPart) {
+ enabled = getActiveTextEditor((IEditorPart) activeEditor) != null;
+ }
+ }
+ setBaseEnabled(enabled);
}
/**

Back to the top