Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrey Loskutov2014-08-05 17:09:27 +0000
committerAndrey Loskutov2015-11-10 08:33:11 +0000
commita50bb821beaaf193dc9bf412316a0c15b32ac0f1 (patch)
treeff0a54cea18b30bb67d13ea64a73dc4d57abd303
parentb212745ce6ea0079e5876fe77658b174a124c1ae (diff)
downloadeclipse.platform.text-a50bb821beaaf193dc9bf412316a0c15b32ac0f1.tar.gz
eclipse.platform.text-a50bb821beaaf193dc9bf412316a0c15b32ac0f1.tar.xz
eclipse.platform.text-a50bb821beaaf193dc9bf412316a0c15b32ac0f1.zip
Bug 35779 - [misc] Text Viewer and Editor needs to support word wrap
Added "Enable word wrap when opening an editor" preference to "Text Editors" preference page, "Toggle Word Wrap" text editor action / toolbar button and ALT+SHIFT+Y shortcut for text editors extending AbstractTextEditor. Change-Id: Ibc4d64d0c76a31aff781726336d41b9ee1cbd659 Also-by: Florian Weßling <flo@cdhq.de> Also-by: Holger Voormann <eclipse@voormann.de> Also-by: Lars Vogel <Lars.Vogel@vogella.com> Signed-off-by: Andrey Loskutov <loskutov@gmx.de>
-rw-r--r--org.eclipse.ui.editors/META-INF/MANIFEST.MF2
-rw-r--r--org.eclipse.ui.editors/plugin.properties4
-rw-r--r--org.eclipse.ui.editors/plugin.xml9
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/TextEditorDefaultsPreferencePage.java7
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/TextEditorMessages.java3
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/TextEditorMessages.properties1
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AbstractDecoratedTextEditorPreferenceConstants.java3
-rw-r--r--org.eclipse.ui.workbench.texteditor/icons/full/dtool16/wordwrap.pngbin0 -> 596 bytes
-rw-r--r--org.eclipse.ui.workbench.texteditor/icons/full/etool16/wordwrap.pngbin0 -> 694 bytes
-rw-r--r--org.eclipse.ui.workbench.texteditor/plugin.properties6
-rw-r--r--org.eclipse.ui.workbench.texteditor/plugin.xml24
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/AbstractTextEditor.java51
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/BasicTextEditorActionContributor.java4
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/ConstructedEditorMessages.properties7
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/IAbstractTextEditorHelpContextIds.java9
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/ITextEditorActionConstants.java9
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/ITextEditorActionDefinitionIds.java10
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/WordWrapToggleAction.java68
18 files changed, 203 insertions, 14 deletions
diff --git a/org.eclipse.ui.editors/META-INF/MANIFEST.MF b/org.eclipse.ui.editors/META-INF/MANIFEST.MF
index 6dc39a9ed77..5e5a2e98bdc 100644
--- a/org.eclipse.ui.editors/META-INF/MANIFEST.MF
+++ b/org.eclipse.ui.editors/META-INF/MANIFEST.MF
@@ -21,7 +21,7 @@ Require-Bundle:
org.eclipse.ui.ide;bundle-version="[3.5.0,4.0.0)",
org.eclipse.ui;bundle-version="[3.5.0,4.0.0)",
org.eclipse.jface.text;bundle-version="[3.8.0,4.0.0)",
- org.eclipse.ui.workbench.texteditor;bundle-version="[3.7.0,4.0.0)",
+ org.eclipse.ui.workbench.texteditor;bundle-version="[3.10.0,4.0.0)",
org.eclipse.core.filebuffers;visibility:=reexport;bundle-version="[3.5.0,4.0.0)",
org.eclipse.core.resources;bundle-version="[3.5.0,4.0.0)",
org.eclipse.core.filesystem;bundle-version="[1.2.0,2.0.0)"
diff --git a/org.eclipse.ui.editors/plugin.properties b/org.eclipse.ui.editors/plugin.properties
index ddb21a870db..ed4969788f6 100644
--- a/org.eclipse.ui.editors/plugin.properties
+++ b/org.eclipse.ui.editors/plugin.properties
@@ -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
@@ -8,6 +8,7 @@
# Contributors:
# IBM Corporation - initial API and implementation
# Alex Weirig <alex.weirig@telewalfer.lu> - Collapse All (https://bugs.eclipse.org/bugs/show_bug.cgi?id=65268)
+# Florian Weßling <flo@cdhq.de> - Adding (soft) word wrap (https://bugs.eclipse.org/bugs/show_bug.cgi?id=35779)
###############################################################################
pluginName= Default Text Editor
providerName= Eclipse.org
@@ -123,6 +124,7 @@ preferenceKeywords.accessibility= accessibility caret cursor quick diff text edi
preferenceKeywords.spelling= spelling spell checking dictionary correction check text editor
preferenceKeywords.linkedmode= editor linked mode template
preferenceKeywords.hyperlinkDetectors= hyperlinking text editor on demand link navigation modifier key
+preferenceKeywords.wordWrap= word wrap wordwrap wrapping wordwrapping soft text line break linebreak
#--- linked mode annotations
linked.focus.label= Current range
diff --git a/org.eclipse.ui.editors/plugin.xml b/org.eclipse.ui.editors/plugin.xml
index 9d824937ff5..bea4d3b31fe 100644
--- a/org.eclipse.ui.editors/plugin.xml
+++ b/org.eclipse.ui.editors/plugin.xml
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.0"?>
-<!-- ====================================================================== -->
+<!-- ================================================================================================================= -->
<!-- Copyright (c) 2002, 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 -->
@@ -9,7 +9,8 @@
<!-- -->
<!-- Contributors: -->
<!-- IBM Corporation - initial API and implementation -->
-<!-- ====================================================================== -->
+<!-- Florian Weßling <flo@cdhq.de> - Adding (soft) word wrap (https://bugs.eclipse.org/bugs/show_bug.cgi?id=35779) -->
+<!-- ================================================================================================================= -->
<plugin>
<extension-point id="documentProviders" name="%ExtPoint.documentProviders" schema="schema/documentProviders.exsd"/>
@@ -224,6 +225,7 @@
<keywordReference id="org.eclipse.ui.editors.tabWidth"/>
<keywordReference id="org.eclipse.ui.editors.lineNumber"/>
<keywordReference id="org.eclipse.ui.editors.printMargin"/>
+ <keywordReference id="org.eclipse.ui.editors.wordWrap"/>
</page>
<page
name="%PreferencePages.Annotations"
@@ -301,6 +303,9 @@
<keyword
label="%preferenceKeywords.hyperlinkDetectors"
id="org.eclipse.ui.editors.hyperlinkDetectors"/>
+ <keyword
+ label="%preferenceKeywords.wordWrap"
+ id="org.eclipse.ui.editors.wordWrap"/>
</extension>
<extension
point="org.eclipse.ui.editors.documentProviders">
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/TextEditorDefaultsPreferencePage.java b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/TextEditorDefaultsPreferencePage.java
index 42e57c619af..85e569c9b79 100644
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/TextEditorDefaultsPreferencePage.java
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/TextEditorDefaultsPreferencePage.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2012 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
@@ -681,6 +681,7 @@ public class TextEditorDefaultsPreferencePage extends PreferencePage implements
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE));
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.INT, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_TAB_WIDTH));
+ overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, AbstractTextEditor.PREFERENCE_WORD_WRAP_ENABLED));
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SPACES_FOR_TABS));
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN_COLOR));
@@ -805,6 +806,10 @@ public class TextEditorDefaultsPreferencePage extends PreferencePage implements
IntegerDomain tabWidthDomain= new IntegerDomain(1, 16);
addTextField(appearanceComposite, tabWidth, tabWidthDomain, 15, 0);
+ label= TextEditorMessages.TextEditorPreferencePage_enableWordWrap;
+ Preference enableWordWrap= new Preference(AbstractTextEditor.PREFERENCE_WORD_WRAP_ENABLED, label, null);
+ addCheckBox(appearanceComposite, enableWordWrap, new BooleanDomain(), 0);
+
label= TextEditorMessages.TextEditorPreferencePage_convertTabsToSpaces;
Preference spacesForTabs= new Preference(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SPACES_FOR_TABS, label, null);
addCheckBox(appearanceComposite, spacesForTabs, new BooleanDomain(), 0);
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/TextEditorMessages.java b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/TextEditorMessages.java
index dcbf8c8cd7e..6d6044d45ef 100644
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/TextEditorMessages.java
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/TextEditorMessages.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2012 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
@@ -31,6 +31,7 @@ final class TextEditorMessages extends NLS {
public static String EditorsPlugin_internal_error;
public static String LinkedModeConfigurationBlock_DASHED_BOX;
public static String TextEditorPreferencePage_displayedTabWidth;
+ public static String TextEditorPreferencePage_enableWordWrap;
public static String TextEditorPreferencePage_convertTabsToSpaces;
public static String TextEditorPreferencePage_undoHistorySize;
public static String TextEditorPreferencePage_printMarginColumn;
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/TextEditorMessages.properties b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/TextEditorMessages.properties
index 0b2129623f2..053cf9fd2ef 100644
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/TextEditorMessages.properties
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/TextEditorMessages.properties
@@ -13,6 +13,7 @@ EditorsPlugin_additionalInfo_affordance=Press 'Tab' from proposal table or click
EditorsPlugin_internal_error=Internal Error
TextEditorPreferencePage_displayedTabWidth=Displayed &tab width:
+TextEditorPreferencePage_enableWordWrap=&Enable word wrap when opening an editor
TextEditorPreferencePage_convertTabsToSpaces=&Insert spaces for tabs
TextEditorPreferencePage_undoHistorySize=&Undo history size:
TextEditorPreferencePage_printMarginColumn=Print margin colu&mn:
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AbstractDecoratedTextEditorPreferenceConstants.java b/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AbstractDecoratedTextEditorPreferenceConstants.java
index 22a9a61e167..7bd29665ec3 100644
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AbstractDecoratedTextEditorPreferenceConstants.java
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AbstractDecoratedTextEditorPreferenceConstants.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2011 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
@@ -745,6 +745,7 @@ public class AbstractDecoratedTextEditorPreferenceConstants {
store.setDefault(EDITOR_TEXT_DRAG_AND_DROP_ENABLED, true);
store.setDefault(EDITOR_SHOW_TEXT_HOVER_AFFORDANCE, true);
store.setDefault(EDITOR_HOVER_ENRICH_MODE, 0);
+ store.setDefault(AbstractTextEditor.PREFERENCE_WORD_WRAP_ENABLED, false);
MarkerAnnotationPreferences.initializeDefaultValues(store);
diff --git a/org.eclipse.ui.workbench.texteditor/icons/full/dtool16/wordwrap.png b/org.eclipse.ui.workbench.texteditor/icons/full/dtool16/wordwrap.png
new file mode 100644
index 00000000000..a446b7d974d
--- /dev/null
+++ b/org.eclipse.ui.workbench.texteditor/icons/full/dtool16/wordwrap.png
Binary files differ
diff --git a/org.eclipse.ui.workbench.texteditor/icons/full/etool16/wordwrap.png b/org.eclipse.ui.workbench.texteditor/icons/full/etool16/wordwrap.png
new file mode 100644
index 00000000000..69e1839376b
--- /dev/null
+++ b/org.eclipse.ui.workbench.texteditor/icons/full/etool16/wordwrap.png
Binary files differ
diff --git a/org.eclipse.ui.workbench.texteditor/plugin.properties b/org.eclipse.ui.workbench.texteditor/plugin.properties
index 2812816bb88..f49ffdb045e 100644
--- a/org.eclipse.ui.workbench.texteditor/plugin.properties
+++ b/org.eclipse.ui.workbench.texteditor/plugin.properties
@@ -1,5 +1,5 @@
###############################################################################
-# Copyright (c) 2000, 2013 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
@@ -38,6 +38,10 @@ toggleBlockSelectionMode.label= Toggle Block Selection
toggleBlockSelectionMode.tooltip= Toggle Block Selection
toggleBlockSelectionMode.description= Toggle block / column selection in the current text editor
+toggleWordWrap.label= Toggle Word Wrap
+toggleWordWrap.tooltip= Toggle Word Wrap
+toggleWordWrap.description= Toggle word wrap in the current text editor
+
smartEnter.label= Insert Line Below Current Line
smartEnter.description= Adds a new line below the current line
smartEnterInverse.label= Insert Line Above Current Line
diff --git a/org.eclipse.ui.workbench.texteditor/plugin.xml b/org.eclipse.ui.workbench.texteditor/plugin.xml
index f3ed45e0334..f3a897f35a9 100644
--- a/org.eclipse.ui.workbench.texteditor/plugin.xml
+++ b/org.eclipse.ui.workbench.texteditor/plugin.xml
@@ -405,6 +405,12 @@
categoryId="org.eclipse.ui.category.edit"
id="org.eclipse.ui.edit.text.toggleBlockSelectionMode">
</command>
+ <command
+ name="%toggleWordWrap.label"
+ description="%toggleWordWrap.description"
+ categoryId="org.eclipse.ui.category.edit"
+ id="org.eclipse.ui.edit.text.toggleWordWrap">
+ </command>
<command
name="%command.toggleInsertMode.name"
description="%command.toggleInsertMode.description"
@@ -794,6 +800,11 @@
commandId="org.eclipse.ui.edit.text.toggleBlockSelectionMode"
schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"/>
<key
+ sequence="M2+M3+Y"
+ contextId="org.eclipse.ui.textEditorScope"
+ commandId="org.eclipse.ui.edit.text.toggleWordWrap"
+ schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"/>
+ <key
platform="carbon"
sequence="M2+M3+A"
contextId="org.eclipse.ui.textEditorScope"
@@ -1184,6 +1195,19 @@
toolbarPath="Normal/Presentation"
tooltip="%toggleBlockSelectionMode.tooltip">
</action>
+ <action
+ allowLabelUpdate="true"
+ definitionId="org.eclipse.ui.edit.text.toggleWordWrap"
+ disabledIcon="$nl$/icons/full/dtool16/wordwrap.png"
+ helpContextId="org.eclipse.ui.word_wrap_toggle_action_context"
+ icon="$nl$/icons/full/etool16/wordwrap.png"
+ id="org.eclipse.ui.edit.text.toggleWordWrap"
+ label="%toggleWordWrap.label"
+ retarget="true"
+ style="toggle"
+ toolbarPath="Normal/Presentation"
+ tooltip="%toggleWordWrap.tooltip">
+ </action>
</actionSet>
</extension>
<extension
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 c83295f9f8e..a2dfb70a1e1 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
@@ -16,6 +16,7 @@
* 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
+ * Andrey Loskutov <loskutov@gmx.de> - Word Wrap - https://bugs.eclipse.org/bugs/show_bug.cgi?id=35779
*******************************************************************************/
package org.eclipse.ui.texteditor;
@@ -2313,6 +2314,16 @@ public abstract class AbstractTextEditor extends EditorPart implements ITextEdit
*/
public static final String PREFERENCE_HOVER_ENRICH_MODE= "hoverReplaceMode"; //$NON-NLS-1$
+ /**
+ * A named preference to control the initial word wrap status.
+ * <p>
+ * Value is of type <code>Boolean</code>.
+ * </p>
+ *
+ * @since 3.10
+ */
+ public static final String PREFERENCE_WORD_WRAP_ENABLED= "wordwrap.enabled"; //$NON-NLS-1$
+
/** Menu id for the editor context menu. */
public static final String DEFAULT_EDITOR_CONTEXT_MENU_ID= "#EditorContext"; //$NON-NLS-1$
/** Menu id for the ruler context menu. */
@@ -3590,6 +3601,9 @@ public abstract class AbstractTextEditor extends EditorPart implements ITextEdit
IVerticalRuler ruler= getVerticalRuler();
if (ruler instanceof CompositeRuler)
updateContributedRulerColumns((CompositeRuler) ruler);
+
+ if(isWordWrapSupported())
+ setWordWrap(getInitialWordWrapStatus());
}
/**
@@ -5950,11 +5964,37 @@ public abstract class AbstractTextEditor extends EditorPart implements ITextEdit
action.setActionDefinitionId(ITextEditorActionDefinitionIds.SHOW_INFORMATION);
setAction(ITextEditorActionConstants.SHOW_INFORMATION, action);
- action= new BlockSelectionModeToggleAction(EditorMessages.getBundleForConstructedKeys(), "Editor.ToggleBlockSelectionMode.", this); //$NON-NLS-1$
+ final BlockSelectionModeToggleAction blockAction= new BlockSelectionModeToggleAction(EditorMessages.getBundleForConstructedKeys(), "Editor.ToggleBlockSelectionMode.", this); //$NON-NLS-1$
+ action = blockAction;
action.setHelpContextId(IAbstractTextEditorHelpContextIds.BLOCK_SELECTION_MODE_ACTION);
action.setActionDefinitionId(ITextEditorActionDefinitionIds.BLOCK_SELECTION_MODE);
setAction(ITextEditorActionConstants.BLOCK_SELECTION_MODE, action);
+ if(isWordWrapSupported()){
+ final WordWrapToggleAction wrapAction= new WordWrapToggleAction(EditorMessages.getBundleForConstructedKeys(), "Editor.ToggleWordWrap.", this, getInitialWordWrapStatus()); //$NON-NLS-1$
+ action = wrapAction;
+ action.setHelpContextId(IAbstractTextEditorHelpContextIds.WORD_WRAP_TOGGLE_ACTION);
+ action.setActionDefinitionId(ITextEditorActionDefinitionIds.WORD_WRAP);
+ setAction(ITextEditorActionConstants.WORD_WRAP, action);
+
+ blockAction.addPropertyChangeListener(new IPropertyChangeListener() {
+ public void propertyChange(PropertyChangeEvent event) {
+ if(IAction.CHECKED == event.getProperty() &&
+ Boolean.TRUE.equals(event.getNewValue())){
+ wrapAction.setChecked(false);
+ }
+ }
+ });
+ wrapAction.addPropertyChangeListener(new IPropertyChangeListener() {
+ public void propertyChange(PropertyChangeEvent event) {
+ if(IAction.CHECKED == event.getProperty() &&
+ Boolean.TRUE.equals(event.getNewValue())){
+ blockAction.setChecked(false);
+ }
+ }
+ });
+ }
+
action= new TextOperationAction(EditorMessages.getBundleForConstructedKeys(), "Editor.OpenHyperlink.", this, HyperlinkManager.OPEN_HYPERLINK, true); //$NON-NLS-1$;
action.setHelpContextId(IAbstractTextEditorHelpContextIds.OPEN_HYPERLINK_ACTION);
action.setActionDefinitionId(ITextEditorActionDefinitionIds.OPEN_HYPERLINK);
@@ -7465,4 +7505,13 @@ public abstract class AbstractTextEditor extends EditorPart implements ITextEdit
}
}
+ /**
+ * Returns the initial word wrap status.
+ *
+ * @return initial word wrap status
+ * @since 3.10
+ */
+ protected boolean getInitialWordWrapStatus() {
+ return getPreferenceStore().getBoolean(PREFERENCE_WORD_WRAP_ENABLED);
+ }
}
diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/BasicTextEditorActionContributor.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/BasicTextEditorActionContributor.java
index 388e05250d3..5627877f930 100644
--- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/BasicTextEditorActionContributor.java
+++ b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/BasicTextEditorActionContributor.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2009 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
@@ -214,6 +214,8 @@ public class BasicTextEditorActionContributor extends EditorActionBarContributor
actionBars.setGlobalActionHandler(ACTIONS[i], getAction(editor, ACTIONS[i]));
actionBars.setGlobalActionHandler(ITextEditorActionDefinitionIds.SHOW_WHITESPACE_CHARACTERS, getAction(editor, ITextEditorActionConstants.SHOW_WHITESPACE_CHARACTERS));
actionBars.setGlobalActionHandler(ITextEditorActionDefinitionIds.BLOCK_SELECTION_MODE, getAction(editor, ITextEditorActionConstants.BLOCK_SELECTION_MODE));
+ if(editor instanceof AbstractTextEditor && ((AbstractTextEditor)editor).isWordWrapSupported())
+ actionBars.setGlobalActionHandler(ITextEditorActionDefinitionIds.WORD_WRAP, getAction(editor, ITextEditorActionConstants.WORD_WRAP));
fFindNext.setAction(getAction(editor, ITextEditorActionConstants.FIND_NEXT));
fFindPrevious.setAction(getAction(editor, ITextEditorActionConstants.FIND_PREVIOUS));
diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/ConstructedEditorMessages.properties b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/ConstructedEditorMessages.properties
index cab744bc9f8..9b4a5b5f998 100644
--- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/ConstructedEditorMessages.properties
+++ b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/ConstructedEditorMessages.properties
@@ -1,5 +1,5 @@
###############################################################################
-# Copyright (c) 2000, 2010 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
@@ -245,6 +245,11 @@ Editor.ToggleBlockSelectionMode.description= Enable block / column selection in
Editor.ToggleBlockSelectionMode.image=
Editor.ToggleBlockSelectionMode.tooltip= Toggle Block Selection Mode
+Editor.ToggleWordWrap.label= Toggle Word Wrap
+Editor.ToggleWordWrap.description= Toggle word wrap in the current text editor
+Editor.ToggleWordWrap.image=
+Editor.ToggleWordWrap.tooltip= Toggle Word Wrap
+
Editor.OpenHyperlink.label= Open Hyperlin&k
Editor.OpenHyperlink.tooltip= Open Hyperlink
Editor.OpenHyperlink.image=
diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/IAbstractTextEditorHelpContextIds.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/IAbstractTextEditorHelpContextIds.java
index 57b59d5cc98..0ff7f3df6ff 100644
--- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/IAbstractTextEditorHelpContextIds.java
+++ b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/IAbstractTextEditorHelpContextIds.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2010 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
@@ -397,6 +397,13 @@ public interface IAbstractTextEditorHelpContextIds {
String BLOCK_SELECTION_MODE_ACTION= PREFIX + "block_selection_mode" + ACTION_POSTFIX; //$NON-NLS-1$
/**
+ * Help context id for the word wrap toggle action. Value:
+ * <code>"org.eclipse.ui.word_wrap_toggle_action_context"</code>
+ * @since 3.10
+ */
+ String WORD_WRAP_TOGGLE_ACTION= PREFIX + "word_wrap_toggle" + ACTION_POSTFIX; //$NON-NLS-1$
+
+ /**
* Help context id for the open hyperlink action.
* Value: <code>"org.eclipse.ui.open_hyperlink_action_context"</code>
* @since 3.7
diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/ITextEditorActionConstants.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/ITextEditorActionConstants.java
index d27d3ea70e8..f8b5a855cfd 100644
--- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/ITextEditorActionConstants.java
+++ b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/ITextEditorActionConstants.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2010 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
@@ -673,6 +673,13 @@ public interface ITextEditorActionConstants extends IWorkbenchActionConstants {
String BLOCK_SELECTION_MODE= "BlockSelectionMode"; //$NON-NLS-1$
/**
+ * Name of the action for toggling word wrap. Value:
+ * <code>"WordWrap"</code>
+ * @since 3.10
+ */
+ String WORD_WRAP= "WordWrap"; //$NON-NLS-1$
+
+ /**
* Name of the action displaying a sticky ruler hover for the current caret location.
* Value: <code>"ShowChangeRulerInformation"</code>
* @since 3.6
diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/ITextEditorActionDefinitionIds.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/ITextEditorActionDefinitionIds.java
index 641eebb6fb6..153ae3298cd 100644
--- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/ITextEditorActionDefinitionIds.java
+++ b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/ITextEditorActionDefinitionIds.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2010 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
@@ -579,6 +579,14 @@ public interface ITextEditorActionDefinitionIds extends IWorkbenchActionDefiniti
String BLOCK_SELECTION_MODE= "org.eclipse.ui.edit.text.toggleBlockSelectionMode"; //$NON-NLS-1$
/**
+ * Command ID of the command to toggle word wrap:
+ * <code>"org.eclipse.ui.edit.text.toggleWordWrap"</code>).
+ *
+ * @since 3.10
+ */
+ String WORD_WRAP= "org.eclipse.ui.edit.text.toggleWordWrap"; //$NON-NLS-1$
+
+ /**
* Command ID of the command to display a sticky ruler hover for the current caret location.
* Value <code>"org.eclipse.ui.edit.text.showChangeRulerInformation"</code>.
*
diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/WordWrapToggleAction.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/WordWrapToggleAction.java
new file mode 100644
index 00000000000..1a5483d4553
--- /dev/null
+++ b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/WordWrapToggleAction.java
@@ -0,0 +1,68 @@
+/*******************************************************************************
+ * Copyright (c) 2015 Andrey Loskutov 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:
+ * Andrey Loskutov <loskutov@gmx.de> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.ui.texteditor;
+
+import java.util.ResourceBundle;
+
+import org.eclipse.jface.action.IAction;
+
+
+/**
+ * This action toggles the word wrap in the editor.
+ *
+ * @since 3.10
+ */
+final class WordWrapToggleAction extends TextEditorAction {
+
+ /**
+ * Construct the action and initialize its state.
+ *
+ * @param resourceBundle the resource bundle to construct label and tooltip from
+ * @param prefix the prefix to use for constructing resource bundle keys
+ * @param editor the editor this action is associated with
+ * @param checked initial toggle state
+ */
+ public WordWrapToggleAction(ResourceBundle resourceBundle, String prefix, ITextEditor editor, boolean checked) {
+ super(resourceBundle, prefix, editor, IAction.AS_CHECK_BOX);
+ update(checked);
+ }
+
+ public void run() {
+ boolean newState = false;
+ if (isWordWrapPossible()) {
+ ITextEditorExtension6 ext6= (ITextEditorExtension6) getTextEditor();
+ newState= !ext6.isWordWrapEnabled();
+ ext6.setWordWrap(newState);
+ }
+ update(newState);
+ }
+
+ private void update(boolean checked) {
+ setEnabled(isWordWrapPossible());
+ setChecked(checked);
+ }
+
+ public void update() {
+ setEnabled(isWordWrapPossible());
+ setChecked(isWordWrapEnabled());
+ }
+
+ private boolean isWordWrapPossible(){
+ return getTextEditor() instanceof ITextEditorExtension6;
+ }
+
+ private boolean isWordWrapEnabled(){
+ if (isWordWrapPossible()) {
+ return ((ITextEditorExtension6)getTextEditor()).isWordWrapEnabled();
+ }
+ return false;
+ }
+}

Back to the top