Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrey Loskutov2015-09-11 08:13:03 +0000
committerAndrey Loskutov2015-11-10 08:33:01 +0000
commitb212745ce6ea0079e5876fe77658b174a124c1ae (patch)
tree696e73b789743e7eac8c31b71cbba25715e8e0c2 /org.eclipse.ui.workbench.texteditor
parenta6baa3f82147bb0751b5050bf2eb6c0c23891e78 (diff)
downloadeclipse.platform.text-b212745ce6ea0079e5876fe77658b174a124c1ae.tar.gz
eclipse.platform.text-b212745ce6ea0079e5876fe77658b174a124c1ae.tar.xz
eclipse.platform.text-b212745ce6ea0079e5876fe77658b174a124c1ae.zip
Bug 35779 - [misc] Text Viewer and Editor needs to support word wrap
Added ITextEditorExtension6 API and implementation to control word wrap in AbstractTextEditor. The new word wrap mode is mutually exclusive with the block selection mode of the ITextEditorExtension5. Change-Id: I1102a25b111840f07627c28db1731d6efd16782c Also-by: Holger Voormann <eclipse@voormann.de> Also-by: Florian Weßling <flo@cdhq.de> Signed-off-by: Andrey Loskutov <loskutov@gmx.de>
Diffstat (limited to 'org.eclipse.ui.workbench.texteditor')
-rw-r--r--org.eclipse.ui.workbench.texteditor/META-INF/MANIFEST.MF2
-rw-r--r--org.eclipse.ui.workbench.texteditor/pom.xml2
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/AbstractTextEditor.java72
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/ITextEditorExtension5.java12
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/ITextEditorExtension6.java47
5 files changed, 126 insertions, 9 deletions
diff --git a/org.eclipse.ui.workbench.texteditor/META-INF/MANIFEST.MF b/org.eclipse.ui.workbench.texteditor/META-INF/MANIFEST.MF
index 743b36765c3..d910d805e1f 100644
--- a/org.eclipse.ui.workbench.texteditor/META-INF/MANIFEST.MF
+++ b/org.eclipse.ui.workbench.texteditor/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.ui.workbench.texteditor; singleton:=true
-Bundle-Version: 3.9.200.qualifier
+Bundle-Version: 3.10.0.qualifier
Bundle-Activator: org.eclipse.ui.internal.texteditor.TextEditorPlugin
Bundle-ActivationPolicy: lazy
Bundle-Vendor: %providerName
diff --git a/org.eclipse.ui.workbench.texteditor/pom.xml b/org.eclipse.ui.workbench.texteditor/pom.xml
index 03cc9155592..e9c001075b0 100644
--- a/org.eclipse.ui.workbench.texteditor/pom.xml
+++ b/org.eclipse.ui.workbench.texteditor/pom.xml
@@ -18,6 +18,6 @@
</parent>
<groupId>org.eclipse.ui</groupId>
<artifactId>org.eclipse.ui.workbench.texteditor</artifactId>
- <version>3.9.200-SNAPSHOT</version>
+ <version>3.10.0-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
</project>
diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/AbstractTextEditor.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/AbstractTextEditor.java
index cf334b0be80..c83295f9f8e 100644
--- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/AbstractTextEditor.java
+++ b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/AbstractTextEditor.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2014 IBM Corporation and others.
+ * Copyright (c) 2000, 2015 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -14,6 +14,8 @@
* Stephan Wahlbrink <stephan.wahlbrink@walware.de> - Wrong operations mode/feedback for text drag over/drop in text editors - https://bugs.eclipse.org/bugs/show_bug.cgi?id=206043
* Tom Eicher (Avaloq Evolution AG) - block selection mode
* Nick Sandonato <nsandona@us.ibm.com> - [implementation] AbstractTextEditor does not prompt when out of sync in MultiPageEditorPart - http://bugs.eclipse.org/337719
+ * Holger Voormann - Word Wrap - https://bugs.eclipse.org/bugs/show_bug.cgi?id=35779
+ * Florian Weßling <flo@cdhq.de> - Word Wrap - https://bugs.eclipse.org/bugs/show_bug.cgi?id=35779
*******************************************************************************/
package org.eclipse.ui.texteditor;
@@ -251,7 +253,7 @@ import org.eclipse.ui.texteditor.rulers.RulerColumnRegistry;
* {@link #COMMON_RULER_CONTEXT_MENU_ID}.
* </p>
*/
-public abstract class AbstractTextEditor extends EditorPart implements ITextEditor, IReusableEditor, ITextEditorExtension, ITextEditorExtension2, ITextEditorExtension3, ITextEditorExtension4, ITextEditorExtension5, INavigationLocationProvider, ISaveablesSource, IPersistableEditor {
+public abstract class AbstractTextEditor extends EditorPart implements ITextEditor, IReusableEditor, ITextEditorExtension, ITextEditorExtension2, ITextEditorExtension3, ITextEditorExtension4, ITextEditorExtension5, ITextEditorExtension6, INavigationLocationProvider, ISaveablesSource, IPersistableEditor {
/**
* Tag used in xml configuration files to specify editor action contributions.
@@ -7388,10 +7390,15 @@ public abstract class AbstractTextEditor extends EditorPart implements ITextEdit
disposeFont();
updateCaret();
}
+
+ // we must unset word wrap before we can set block selection
+ if (isWordWrapEnabled()) {
+ setWordWrap(false);
+ }
}
styledText.setBlockSelection(enable);
-
+
if (!enable) {
initializeViewerFont(viewer);
updateCaret();
@@ -7399,4 +7406,63 @@ public abstract class AbstractTextEditor extends EditorPart implements ITextEdit
}
}
}
+
+ /**
+ * Tells whether word wrap is supported.
+ * <p>
+ * By default word wrap is supported. Subclasses may override this method to disable
+ * it.
+ * </p>
+ *
+ * @return <code>true</code> if word wrap is supported, <code>false</code> otherwise
+ * @since 3.10
+ */
+ protected boolean isWordWrapSupported() {
+ return true;
+ }
+
+ /**
+ * <code>true</code> if word wrap is supported and enabled, <code>false</code> otherwise
+ * @return the receiver's word wrap state if word wrap is supported
+ * @since 3.10
+ * @see AbstractTextEditor#isWordWrapSupported()
+ */
+ public final boolean isWordWrapEnabled() {
+ if(!isWordWrapSupported()){
+ return false;
+ }
+ ISourceViewer viewer= getSourceViewer();
+ if (viewer != null) {
+ StyledText styledText= viewer.getTextWidget();
+ if (styledText != null) {
+ return styledText.getWordWrap();
+ }
+ }
+ return false;
+ }
+
+ /**
+ * @see org.eclipse.ui.texteditor.ITextEditorExtension6#setWordWrap(boolean)
+ * @since 3.10
+ */
+ public void setWordWrap(boolean enable) {
+ if (!isWordWrapSupported() || isWordWrapEnabled() == enable) {
+ return;
+ }
+
+ ISourceViewer viewer= getSourceViewer();
+ if (viewer != null) {
+ StyledText styledText= viewer.getTextWidget();
+ if (styledText != null) {
+ if(isBlockSelectionModeEnabled()){
+ setBlockSelectionMode(false);
+ }
+ styledText.setWordWrap(enable);
+ if (fVerticalRuler != null) {
+ fVerticalRuler.update();
+ }
+ }
+ }
+ }
+
}
diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/ITextEditorExtension5.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/ITextEditorExtension5.java
index c747f8094f9..ffe638be747 100644
--- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/ITextEditorExtension5.java
+++ b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/ITextEditorExtension5.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009 Avaloq Evolution AG and others.
+ * Copyright (c) 2009, 2015 Avaloq Evolution AG and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -34,10 +34,14 @@ public interface ITextEditorExtension5 {
boolean isBlockSelectionModeEnabled();
/**
- * Sets the block selection mode state of the receiver to <code>state</code>. Nothing happens
- * if the receiver already is in the requested state.
- *
+ * Sets the block selection mode state of the receiver to <code>state</code>. Nothing happens if
+ * the receiver already is in the requested state.
+ * <p>
+ * Note: enabling block selection mode disables word wrap {@link ITextEditorExtension6}),
+ * enabling word wrap will disable block selection mode.
+ *
* @param state the new block selection state
+ * @see ITextEditorExtension6#setWordWrap(boolean)
*/
void setBlockSelectionMode(boolean state);
}
diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/ITextEditorExtension6.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/ITextEditorExtension6.java
new file mode 100644
index 00000000000..8ad7c0a1de1
--- /dev/null
+++ b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/ITextEditorExtension6.java
@@ -0,0 +1,47 @@
+/*******************************************************************************
+ * Copyright (c) 2015 Holger Voormann and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Holger Voormann - initial API and implementation
+ * Florian Weßling <flo@cdhq.de> - Word Wrap - https://bugs.eclipse.org/bugs/show_bug.cgi?id=35779
+ *******************************************************************************/
+package org.eclipse.ui.texteditor;
+
+/**
+ * Extension interface for {@link org.eclipse.ui.texteditor.ITextEditor}. Adds the following
+ * functions:
+ * <ul>
+ * <li>word wrap</li>
+ * </ul>
+ * <p>
+ * This interface may be implemented by clients.
+ * </p>
+ *
+ * @since 3.10
+ */
+public interface ITextEditorExtension6 {
+
+ /**
+ * Returns <code>true</code> if word wrap is currently enabled, <code>false</code> otherwise.
+ *
+ * @return the receiver's word wrap state
+ */
+ boolean isWordWrapEnabled();
+
+ /**
+ * Sets whether the text editor wraps lines. Nothing happens if the receiver already is in the
+ * requested state.
+ * <p>
+ * Note: enabling word wrap disables block selection mode (see {@link ITextEditorExtension5}),
+ * enabling block selection mode will disable word wrap.
+ *
+ * @param enable <code>true</code> to enable word wrap, <code>false</code> to turn it off.
+ *
+ * @see ITextEditorExtension5#setBlockSelectionMode(boolean)
+ */
+ public void setWordWrap(boolean enable);
+}

Back to the top