提交 0f1fd5b6 编写于 作者: J jurgen

Word wrap in text editors

Former-commit-id: d9e7b623
上级 87b89881
......@@ -68,6 +68,7 @@
<menu id="edit" label="%menu.edit">
<command commandId="org.jkiss.dbeaver.ui.editors.sql.comment.single"><visibleWhen checkEnabled="true"/></command>
<command commandId="org.jkiss.dbeaver.ui.editors.sql.comment.multi"><visibleWhen checkEnabled="true"/></command>
<command commandId="org.jkiss.dbeaver.ui.editors.sql.word.wrap"><visibleWhen checkEnabled="true"/></command>
<command commandId="org.eclipse.ui.edit.text.upperCase"><visibleWhen checkEnabled="true"/></command>
<command commandId="org.eclipse.ui.edit.text.lowerCase"><visibleWhen checkEnabled="true"/></command>
</menu>
......
......@@ -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
......
......@@ -206,6 +206,7 @@
<command id="org.jkiss.dbeaver.ui.editors.sql.save.file" name="%command.org.jkiss.dbeaver.ui.editors.sql.save.file.name" description="%command.org.jkiss.dbeaver.ui.editors.sql.save.file.description" categoryId="org.jkiss.dbeaver.core.sql"/>
<command id="org.jkiss.dbeaver.ui.editors.sql.comment.single" name="%command.org.jkiss.dbeaver.ui.editors.sql.comment.single.name" description="%command.org.jkiss.dbeaver.ui.editors.sql.comment.single.description" categoryId="org.jkiss.dbeaver.core.sql"/>
<command id="org.jkiss.dbeaver.ui.editors.sql.comment.multi" name="%command.org.jkiss.dbeaver.ui.editors.sql.comment.multi.name" description="%command.org.jkiss.dbeaver.ui.editors.sql.comment.multi.description" categoryId="org.jkiss.dbeaver.core.sql"/>
<command id="org.jkiss.dbeaver.ui.editors.sql.word.wrap" name="%command.org.jkiss.dbeaver.ui.editors.sql.word.wrap.name" description="%command.org.jkiss.dbeaver.ui.editors.sql.word.wrap.description" categoryId="org.jkiss.dbeaver.core.sql"/>
<command id="org.jkiss.dbeaver.ui.editors.sql.export.data" name="%command.org.jkiss.dbeaver.ui.editors.sql.export.data.name" description="%command.org.jkiss.dbeaver.ui.editors.sql.export.data.description" categoryId="org.jkiss.dbeaver.core.sql"/>
<command id="org.jkiss.dbeaver.core.export.data" name="%command.org.jkiss.dbeaver.core.export.data.name" description="%command.org.jkiss.dbeaver.core.export.data.description" categoryId="org.jkiss.dbeaver.core.util"/>
<command id="org.jkiss.dbeaver.core.import.data" name="%command.org.jkiss.dbeaver.core.import.data.name" description="%command.org.jkiss.dbeaver.core.import.data.description" categoryId="org.jkiss.dbeaver.core.util"/>
......@@ -800,6 +801,13 @@
</with>
</enabledWhen>
</handler>
<handler commandId="org.jkiss.dbeaver.ui.editors.sql.word.wrap" class="org.jkiss.dbeaver.ui.editors.text.handlers.ToggleWordWrapHandler">
<enabledWhen>
<with variable="activeEditor">
<adapt type="org.eclipse.ui.texteditor.ITextEditor"/>
</with>
</enabledWhen>
</handler>
<!-- Entity editor handlers -->
<handler commandId="org.eclipse.ui.file.revert" class="org.jkiss.dbeaver.ui.editors.entity.handlers.RevertChangesHandler">
......@@ -1618,6 +1626,11 @@
contextId="org.jkiss.dbeaver.ui.editors.sql"
schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
sequence="CTRL+SHIFT+/"/>
<key
commandId="org.jkiss.dbeaver.ui.editors.sql.word.wrap"
contextId="org.jkiss.dbeaver.ui.editors.sql"
schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
sequence="CTRL+ALT+E"/>
<key commandId="org.jkiss.dbeaver.ui.editors.text.content.format" contextId="org.eclipse.ui.contexts.window" schemeId="org.eclipse.ui.defaultAcceleratorConfiguration" sequence="CTRL+ALT+F"/>
</extension>
......
......@@ -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
......
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
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册