From 0f1fd5b676b1810bf8df38fc5ed56a2cb7a8eb81 Mon Sep 17 00:00:00 2001 From: jurgen Date: Tue, 25 Jun 2013 20:41:12 +0000 Subject: [PATCH] Word wrap in text editors Former-commit-id: d9e7b62303e4eaa3d6b3d13f36e33c27f6121b10 --- .../plugin.xml | 1 + .../org.jkiss.dbeaver.core/plugin.properties | 2 ++ plugins/org.jkiss.dbeaver.core/plugin.xml | 13 ++++++++ .../plugin_ru.properties | 2 ++ .../text/handlers/ToggleWordWrapHandler.java | 32 +++++++++++++++++++ 5 files changed, 50 insertions(+) create mode 100644 plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/editors/text/handlers/ToggleWordWrapHandler.java diff --git a/plugins/org.jkiss.dbeaver.core.application/plugin.xml b/plugins/org.jkiss.dbeaver.core.application/plugin.xml index e5535242ce..e5aad0992e 100644 --- a/plugins/org.jkiss.dbeaver.core.application/plugin.xml +++ b/plugins/org.jkiss.dbeaver.core.application/plugin.xml @@ -68,6 +68,7 @@ + diff --git a/plugins/org.jkiss.dbeaver.core/plugin.properties b/plugins/org.jkiss.dbeaver.core/plugin.properties index 2c06305ce9..efa5f5fe7b 100644 --- a/plugins/org.jkiss.dbeaver.core/plugin.properties +++ b/plugins/org.jkiss.dbeaver.core/plugin.properties @@ -113,6 +113,8 @@ command.org.jkiss.dbeaver.ui.editors.sql.comment.single.name=Toggle Line Comment command.org.jkiss.dbeaver.ui.editors.sql.comment.single.description=Add or remove single line comment command.org.jkiss.dbeaver.ui.editors.sql.comment.multi.name=Toggle Block Comment command.org.jkiss.dbeaver.ui.editors.sql.comment.multi.description=Add or remove multi line comment +command.org.jkiss.dbeaver.ui.editors.sql.word.wrap.name=Toggle Word Wrap +command.org.jkiss.dbeaver.ui.editors.sql.word.wrap.description=Toggles text editor soft word wrap command.org.jkiss.dbeaver.core.export.data.name=Export Data command.org.jkiss.dbeaver.core.export.data.description=Export data to file(s) or database table(s) command.org.jkiss.dbeaver.core.import.data.name=Import Data diff --git a/plugins/org.jkiss.dbeaver.core/plugin.xml b/plugins/org.jkiss.dbeaver.core/plugin.xml index c429f68eed..ec9a15f2b4 100644 --- a/plugins/org.jkiss.dbeaver.core/plugin.xml +++ b/plugins/org.jkiss.dbeaver.core/plugin.xml @@ -206,6 +206,7 @@ + @@ -800,6 +801,13 @@ + + + + + + + @@ -1618,6 +1626,11 @@ contextId="org.jkiss.dbeaver.ui.editors.sql" schemeId="org.eclipse.ui.defaultAcceleratorConfiguration" sequence="CTRL+SHIFT+/"/> + diff --git a/plugins/org.jkiss.dbeaver.core/plugin_ru.properties b/plugins/org.jkiss.dbeaver.core/plugin_ru.properties index 704f758a35..39b7d1fe8f 100644 --- a/plugins/org.jkiss.dbeaver.core/plugin_ru.properties +++ b/plugins/org.jkiss.dbeaver.core/plugin_ru.properties @@ -269,6 +269,8 @@ command.org.jkiss.dbeaver.ui.editors.sql.comment.single.name=\u041E\u0434\u043D\ command.org.jkiss.dbeaver.ui.editors.sql.comment.single.description=\u0412\u0441\u0442\u0430\u0432\u0438\u0442\u044C/\u0443\u0434\u0430\u043B\u0438\u0442\u044C \u043E\u0434\u043D\u043E\u0441\u0442\u0440\u043E\u0447\u043D\u044B\u0439 \u043A\u043E\u043C\u0435\u043D\u0442\u0430\u0440\u0438\u0439 command.org.jkiss.dbeaver.ui.editors.sql.comment.multi.name=\u0411\u043B\u043E\u0447\u043D\u044B\u0439 \u043A\u043E\u043C\u0435\u043D\u0442\u0430\u0440\u0438\u0439 command.org.jkiss.dbeaver.ui.editors.sql.comment.multi.description=\u0412\u0441\u0442\u0430\u0432\u0438\u0442\u044C/\u0443\u0434\u0430\u043B\u0438\u0442\u044C \u043C\u043D\u043E\u0433\u043E\u0441\u0442\u0440\u043E\u0447\u043D\u044B\u0439 \u043A\u043E\u043C\u0435\u043D\u0442\u0430\u0440\u0438\u0439 +command.org.jkiss.dbeaver.ui.editors.sql.word.wrap.name=\u0412\u043A\u043B/\u0432\u044B\u043A\u043B \u043F\u0435\u0440\u0435\u043D\u043E\u0441 \u0441\u0442\u0440\u043E\u043A +command.org.jkiss.dbeaver.ui.editors.sql.word.wrap.description=\u0412\u043A\u043B\u044E\u0447\u0438\u0442\u044C/\u0432\u044B\u043A\u043B\u044E\u0447\u0438\u0442\u044C \u043F\u0435\u0440\u0435\u043D\u043E\u0441 \u0441\u0442\u0440\u043E\u043A \u0432 \u0442\u0435\u043A\u0441\u0442\u043E\u0432\u043E\u043C \u0440\u0435\u0434\u0430\u043A\u0442\u043E\u0440\u0435 dataTransfer.producer.database.name=\u0422\u0430\u0431\u043B\u0438\u0446\u0430 dataTransfer.producer.database.description=\u0422\u0430\u0431\u043B\u0438\u0446\u0430 \u0431\u0430\u0437\u044B \u0434\u0430\u043D\u043D\u044B\u0445 diff --git a/plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/editors/text/handlers/ToggleWordWrapHandler.java b/plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/editors/text/handlers/ToggleWordWrapHandler.java new file mode 100644 index 0000000000..b14f35b5cd --- /dev/null +++ b/plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/editors/text/handlers/ToggleWordWrapHandler.java @@ -0,0 +1,32 @@ +package org.jkiss.dbeaver.ui.editors.text.handlers; + +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.swt.custom.StyledText; +import org.eclipse.swt.widgets.Control; +import org.eclipse.ui.IWorkbenchPart; +import org.eclipse.ui.handlers.HandlerUtil; +import org.eclipse.ui.texteditor.ITextEditor; + +public class ToggleWordWrapHandler extends AbstractTextHandler { + + public Object execute(ExecutionEvent event) { + // get active editor where word wrap will be toggled + IWorkbenchPart activePart = HandlerUtil.getActivePart(event); + + if (activePart instanceof ITextEditor) { + ITextEditor editor = (ITextEditor) activePart; + + // editor (ITextEditor) adapter returns StyledText + Object text = editor.getAdapter(Control.class); + if (text instanceof StyledText) { + StyledText styledText = (StyledText) text; + + // toggle wrapping + styledText.setWordWrap(!styledText.getWordWrap()); + } + } + + return null; + } + +} \ No newline at end of file -- GitLab