Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--org.eclipse.ui.editors/plugin.xml48
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/TextOperationActionHandler.java85
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/folding/CollapseAllHandler.java22
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/folding/CollapseHandler.java22
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/folding/ExpandAllHandler.java22
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/folding/ExpandHandler.java22
-rw-r--r--org.eclipse.ui.genericeditor.tests/src/org/eclipse/ui/genericeditor/tests/FoldingTest.java15
-rw-r--r--org.eclipse.ui.genericeditor/.classpath2
-rw-r--r--org.eclipse.ui.genericeditor/.settings/org.eclipse.jdt.core.prefs9
-rw-r--r--org.eclipse.ui.genericeditor/META-INF/MANIFEST.MF6
10 files changed, 246 insertions, 7 deletions
diff --git a/org.eclipse.ui.editors/plugin.xml b/org.eclipse.ui.editors/plugin.xml
index 3976749e1b8..3ba076fc1fc 100644
--- a/org.eclipse.ui.editors/plugin.xml
+++ b/org.eclipse.ui.editors/plugin.xml
@@ -167,6 +167,54 @@
commandId="org.eclipse.ui.edit.text.removeTrailingWhitespace"
class="org.eclipse.ui.internal.editors.text.RemoveTrailingWhitespaceHandler">
</handler>
+ <handler
+ commandId="org.eclipse.ui.edit.text.folding.collapse_all"
+ class="org.eclipse.ui.internal.editors.text.folding.CollapseAllHandler">
+ <enabledWhen>
+ <with
+ variable="activePart">
+ <adapt
+ type="org.eclipse.jface.text.ITextOperationTarget">
+ </adapt>
+ </with>
+ </enabledWhen>
+ </handler>
+ <handler
+ class="org.eclipse.ui.internal.editors.text.folding.CollapseAllHandler"
+ commandId="org.eclipse.ui.edit.text.folding.collapse_all">
+ <enabledWhen>
+ <with
+ variable="activePart">
+ <adapt
+ type="org.eclipse.jface.text.ITextOperationTarget">
+ </adapt>
+ </with>
+ </enabledWhen>
+ </handler>
+ <handler
+ class="org.eclipse.ui.internal.editors.text.folding.ExpandAllHandler"
+ commandId="org.eclipse.ui.edit.text.folding.expand_all">
+ <enabledWhen>
+ <with
+ variable="activePart">
+ <adapt
+ type="org.eclipse.jface.text.ITextOperationTarget">
+ </adapt>
+ </with>
+ </enabledWhen>
+ </handler>
+ <handler
+ class="org.eclipse.ui.internal.editors.text.folding.ExpandHandler"
+ commandId="org.eclipse.ui.edit.text.folding.expand">
+ <enabledWhen>
+ <with
+ variable="activePart">
+ <adapt
+ type="org.eclipse.jface.text.ITextOperationTarget">
+ </adapt>
+ </with>
+ </enabledWhen>
+ </handler>
</extension>
<extension
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/TextOperationActionHandler.java b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/TextOperationActionHandler.java
new file mode 100644
index 00000000000..b78b11a3325
--- /dev/null
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/TextOperationActionHandler.java
@@ -0,0 +1,85 @@
+/*******************************************************************************
+ * Copyright (c) 2020 Red Hat Inc. and others.
+ *
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *******************************************************************************/
+package org.eclipse.ui.internal.editors.text;
+
+import org.eclipse.swt.custom.BusyIndicator;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+
+import org.eclipse.core.runtime.Status;
+
+import org.eclipse.jface.text.ITextOperationTarget;
+
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.IWorkbenchPartSite;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.handlers.HandlerUtil;
+
+/**
+ * Abstract Handler to delegate to an operation of {@link ITextOperationTarget}.
+ */
+public abstract class TextOperationActionHandler extends AbstractHandler {
+
+ protected final int operationCode;
+
+ public TextOperationActionHandler(int operationCode) {
+ this.operationCode= operationCode;
+ }
+
+ @Override
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+ if (operationCode < 0) {
+ return null;
+ }
+ IWorkbenchPart part= HandlerUtil.getActivePart(event);
+ ITextOperationTarget target= part.getAdapter(ITextOperationTarget.class);
+ if (target == null) {
+ return null;
+ }
+
+ IWorkbenchPartSite site= part.getSite();
+ Shell shell= site.getShell();
+ if (shell != null && !shell.isDisposed()) {
+ Display display= shell.getDisplay();
+ BusyIndicator.showWhile(display, () -> target.doOperation(operationCode));
+ return Status.OK_STATUS;
+ }
+ return null;
+ }
+
+ @Override
+ public void setEnabled(Object evaluationContext) {
+ IWorkbench workbench= PlatformUI.getWorkbench();
+ if (workbench == null) {
+ setBaseEnabled(false);
+ return;
+ }
+ IWorkbenchWindow window= workbench.getActiveWorkbenchWindow();
+ if (window == null) {
+ setBaseEnabled(false);
+ return;
+ }
+ IWorkbenchPage page= window.getActivePage();
+ if (page == null) {
+ setBaseEnabled(false);
+ return;
+ }
+ IWorkbenchPart part= page.getActivePart();
+ setBaseEnabled(part != null && part.getAdapter(ITextOperationTarget.class) != null);
+ }
+}
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/folding/CollapseAllHandler.java b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/folding/CollapseAllHandler.java
new file mode 100644
index 00000000000..7646a395640
--- /dev/null
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/folding/CollapseAllHandler.java
@@ -0,0 +1,22 @@
+/*******************************************************************************
+ * Copyright (c) 2020 Red Hat Inc. and others.
+ *
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *******************************************************************************/
+package org.eclipse.ui.internal.editors.text.folding;
+
+import org.eclipse.jface.text.source.projection.ProjectionViewer;
+
+import org.eclipse.ui.internal.editors.text.TextOperationActionHandler;
+
+public class CollapseAllHandler extends TextOperationActionHandler {
+
+ public CollapseAllHandler() {
+ super(ProjectionViewer.COLLAPSE_ALL);
+ }
+}
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/folding/CollapseHandler.java b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/folding/CollapseHandler.java
new file mode 100644
index 00000000000..a2fe6abcd26
--- /dev/null
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/folding/CollapseHandler.java
@@ -0,0 +1,22 @@
+/*******************************************************************************
+ * Copyright (c) 2020 Red Hat Inc. and others.
+ *
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *******************************************************************************/
+package org.eclipse.ui.internal.editors.text.folding;
+
+import org.eclipse.jface.text.source.projection.ProjectionViewer;
+
+import org.eclipse.ui.internal.editors.text.TextOperationActionHandler;
+
+public class CollapseHandler extends TextOperationActionHandler {
+
+ public CollapseHandler() {
+ super(ProjectionViewer.COLLAPSE);
+ }
+}
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/folding/ExpandAllHandler.java b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/folding/ExpandAllHandler.java
new file mode 100644
index 00000000000..f2c88dd9cff
--- /dev/null
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/folding/ExpandAllHandler.java
@@ -0,0 +1,22 @@
+/*******************************************************************************
+ * Copyright (c) 2020 Red Hat Inc. and others.
+ *
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *******************************************************************************/
+package org.eclipse.ui.internal.editors.text.folding;
+
+import org.eclipse.jface.text.source.projection.ProjectionViewer;
+
+import org.eclipse.ui.internal.editors.text.TextOperationActionHandler;
+
+public class ExpandAllHandler extends TextOperationActionHandler {
+
+ public ExpandAllHandler() {
+ super(ProjectionViewer.EXPAND_ALL);
+ }
+}
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/folding/ExpandHandler.java b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/folding/ExpandHandler.java
new file mode 100644
index 00000000000..b2596c0b13b
--- /dev/null
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/folding/ExpandHandler.java
@@ -0,0 +1,22 @@
+/*******************************************************************************
+ * Copyright (c) 2020 Red Hat Inc. and others.
+ *
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *******************************************************************************/
+package org.eclipse.ui.internal.editors.text.folding;
+
+import org.eclipse.jface.text.source.projection.ProjectionViewer;
+
+import org.eclipse.ui.internal.editors.text.TextOperationActionHandler;
+
+public class ExpandHandler extends TextOperationActionHandler {
+
+ public ExpandHandler() {
+ super(ProjectionViewer.EXPAND);
+ }
+}
diff --git a/org.eclipse.ui.genericeditor.tests/src/org/eclipse/ui/genericeditor/tests/FoldingTest.java b/org.eclipse.ui.genericeditor.tests/src/org/eclipse/ui/genericeditor/tests/FoldingTest.java
index bd05bc0f5f2..d3905186689 100644
--- a/org.eclipse.ui.genericeditor.tests/src/org/eclipse/ui/genericeditor/tests/FoldingTest.java
+++ b/org.eclipse.ui.genericeditor.tests/src/org/eclipse/ui/genericeditor/tests/FoldingTest.java
@@ -13,6 +13,8 @@
*/
package org.eclipse.ui.genericeditor.tests;
+import static org.junit.Assert.assertTrue;
+
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
@@ -23,6 +25,8 @@ import org.junit.Test;
import org.eclipse.swt.widgets.Display;
+import org.eclipse.core.commands.Command;
+
import org.eclipse.jface.text.ITextViewer;
import org.eclipse.jface.text.Position;
import org.eclipse.jface.text.source.Annotation;
@@ -31,8 +35,11 @@ import org.eclipse.jface.text.source.projection.ProjectionAnnotation;
import org.eclipse.jface.text.source.projection.ProjectionViewer;
import org.eclipse.jface.text.tests.util.DisplayHelper;
+import org.eclipse.ui.commands.ICommandService;
import org.eclipse.ui.genericeditor.tests.contributions.EnabledPropertyTester;
+import org.eclipse.ui.editors.text.IFoldingCommandIds;
+
public class FoldingTest extends AbstratGenericEditorTest {
@Override
@@ -118,4 +125,12 @@ public class FoldingTest extends AbstratGenericEditorTest {
}
return annotationList;
}
+
+ @Test
+ public void testFoldingCommandsEnabled() throws Exception {
+ createAndOpenFile("bar.xml", "<a>\n b</a>");
+ ICommandService commandService = editor.getEditorSite().getService(ICommandService.class);
+ Command collapseAllCommand = commandService.getCommand(IFoldingCommandIds.FOLDING_COLLAPSE_ALL);
+ assertTrue(collapseAllCommand.isEnabled() && collapseAllCommand.isHandled());
+ }
}
diff --git a/org.eclipse.ui.genericeditor/.classpath b/org.eclipse.ui.genericeditor/.classpath
index eca7bdba8f0..e801ebfb468 100644
--- a/org.eclipse.ui.genericeditor/.classpath
+++ b/org.eclipse.ui.genericeditor/.classpath
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>
diff --git a/org.eclipse.ui.genericeditor/.settings/org.eclipse.jdt.core.prefs b/org.eclipse.ui.genericeditor/.settings/org.eclipse.jdt.core.prefs
index 25c93f491d9..fbe2ec86786 100644
--- a/org.eclipse.ui.genericeditor/.settings/org.eclipse.jdt.core.prefs
+++ b/org.eclipse.ui.genericeditor/.settings/org.eclipse.jdt.core.prefs
@@ -10,9 +10,9 @@ org.eclipse.jdt.core.compiler.annotation.nullable.secondary=
org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=11
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
-org.eclipse.jdt.core.compiler.compliance=1.8
+org.eclipse.jdt.core.compiler.compliance=11
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
@@ -26,6 +26,7 @@ org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled
org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled
org.eclipse.jdt.core.compiler.problem.discouragedReference=warning
org.eclipse.jdt.core.compiler.problem.emptyStatement=info
+org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=warning
org.eclipse.jdt.core.compiler.problem.fallthroughCase=warning
@@ -71,6 +72,7 @@ org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=igno
org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore
org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=info
org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=info
+org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning
org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled
@@ -103,4 +105,5 @@ org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=error
org.eclipse.jdt.core.compiler.problem.unusedTypeParameter=ignore
org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning
org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
-org.eclipse.jdt.core.compiler.source=1.8
+org.eclipse.jdt.core.compiler.release=enabled
+org.eclipse.jdt.core.compiler.source=11
diff --git a/org.eclipse.ui.genericeditor/META-INF/MANIFEST.MF b/org.eclipse.ui.genericeditor/META-INF/MANIFEST.MF
index 05b438dba0b..2619e897122 100644
--- a/org.eclipse.ui.genericeditor/META-INF/MANIFEST.MF
+++ b/org.eclipse.ui.genericeditor/META-INF/MANIFEST.MF
@@ -2,11 +2,11 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %Bundle-Name
Bundle-SymbolicName: org.eclipse.ui.genericeditor;singleton:=true
-Bundle-Version: 1.1.900.qualifier
+Bundle-Version: 1.2.0.qualifier
Bundle-Vendor: %Bundle-Vendor
-Bundle-RequiredExecutionEnvironment: JavaSE-1.8
+Bundle-RequiredExecutionEnvironment: JavaSE-11
Require-Bundle: org.eclipse.ui.workbench.texteditor;bundle-version="3.10.0",
- org.eclipse.ui.editors;bundle-version="3.10.0",
+ org.eclipse.ui.editors;bundle-version="3.14.0",
org.eclipse.text;bundle-version="3.6.0",
org.eclipse.jface.text;bundle-version="3.13.0",
org.eclipse.core.runtime;bundle-version="3.12.0",

Back to the top