Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
suliangchun
dbeaver
提交
8b492705
D
dbeaver
项目概览
suliangchun
/
dbeaver
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
dbeaver
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
8b492705
编写于
10月 22, 2021
作者:
S
Serge Rider
浏览文件
操作
浏览文件
下载
差异文件
Merge remote-tracking branch 'origin/devel' into devel
上级
7c50826f
b6caea12
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
134 addition
and
11 deletion
+134
-11
plugins/org.jkiss.dbeaver.ui.editors.data/src/org/jkiss/dbeaver/ui/controls/resultset/internal/ResultSetMessages.java
...ver/ui/controls/resultset/internal/ResultSetMessages.java
+6
-0
plugins/org.jkiss.dbeaver.ui.editors.data/src/org/jkiss/dbeaver/ui/controls/resultset/internal/ResultSetMessages.properties
.../controls/resultset/internal/ResultSetMessages.properties
+6
-0
plugins/org.jkiss.dbeaver.ui.editors.data/src/org/jkiss/dbeaver/ui/controls/resultset/internal/ResultSetMessages_ru.properties
...ntrols/resultset/internal/ResultSetMessages_ru.properties
+6
-0
plugins/org.jkiss.dbeaver.ui.editors.data/src/org/jkiss/dbeaver/ui/data/managers/AbstractTextPanelEditor.java
...iss/dbeaver/ui/data/managers/AbstractTextPanelEditor.java
+97
-7
plugins/org.jkiss.dbeaver.ui.editors.data/src/org/jkiss/dbeaver/ui/editors/content/ContentEditorInput.java
.../jkiss/dbeaver/ui/editors/content/ContentEditorInput.java
+19
-4
未找到文件。
plugins/org.jkiss.dbeaver.ui.editors.data/src/org/jkiss/dbeaver/ui/controls/resultset/internal/ResultSetMessages.java
浏览文件 @
8b492705
...
...
@@ -349,6 +349,12 @@ public class ResultSetMessages extends NLS {
public
static
String
validate_unique_key_usage_dialog_use_all_columns_no_valid_columns_found
;
public
static
String
validate_unique_key_usage_dialog_use_all_columns_cannot_reload_unique_columns
;
public
static
String
panel_editor_text_loading_placeholder_label
;
public
static
String
panel_editor_text_word_wrap_name
;
public
static
String
panel_editor_text_auto_format_name
;
public
static
String
panel_editor_text_encoding_name
;
public
static
String
panel_editor_text_encoding_title
;
static
{
// initialize resource bundle
NLS
.
initializeMessages
(
BUNDLE_NAME
,
ResultSetMessages
.
class
);
...
...
plugins/org.jkiss.dbeaver.ui.editors.data/src/org/jkiss/dbeaver/ui/controls/resultset/internal/ResultSetMessages.properties
浏览文件 @
8b492705
...
...
@@ -327,3 +327,9 @@ validate_unique_key_usage_dialog_use_all_columns = Use All Columns
validate_unique_key_usage_dialog_custom_unique_key
=
Custom Unique Key
validate_unique_key_usage_dialog_use_all_columns_no_valid_columns_found
=
No valid columns found for unique key
validate_unique_key_usage_dialog_use_all_columns_cannot_reload_unique_columns
=
Can't reload unique columns
panel_editor_text_loading_placeholder_label
=
Loading content ... ({0})
panel_editor_text_word_wrap_name
=
Word Wrap
panel_editor_text_auto_format_name
=
Auto Format
panel_editor_text_encoding_name
=
Encoding...
panel_editor_text_encoding_title
=
Change encoding
\ No newline at end of file
plugins/org.jkiss.dbeaver.ui.editors.data/src/org/jkiss/dbeaver/ui/controls/resultset/internal/ResultSetMessages_ru.properties
浏览文件 @
8b492705
...
...
@@ -274,3 +274,9 @@ virtual_edit_columns_page_dialog_button_edit = \u0418\u0437\u043C\u0435\u043D\u0
virtual_edit_columns_page_dialog_button_remove
=
\u0423\u0434\u0430\u
043B
\u0438\u0442\u
044C
virtual_edit_columns_page_confirm_action_delete
=
\u0423\u0434\u0430\u
043B
\u0438\u0442\u
044C
\u0432\u0438\u0440\u0442\u0443\u0430\u
043B
\u
044C
\u
043D
\u
044B
\u0439
\u0441\u0442\u
043E
\u
043B
\u0431\u0435\u0446
virtual_edit_columns_page_confirm_action_question_delete_column
=
\u0412\u
044B
\u0443\u0432\u0435\u0440\u0435\u
043D
\u
044B,
\u0447\u0442\u
043E
\u0445\u
043E
\u0442\u0438\u0442\u0435
\u0443\u0434\u0430\u
043B
\u0438\u0442\u
044C
\u0432\u0438\u0440\u0442\u0443\u0430\u
043B
\u
044C
\u
043D
\u
044B
\u0439
\u0441\u0442\u
043E
\u
043B
\u0431\u0435\u0446
"{0}"?
panel_editor_text_loading_placeholder_label
=
\u0417\u0430\u0433\u0440\u0443\u0437\u
043A
\u0430
\u0434\u0430\u
043D
\u
043D
\u
044B
\u0445
... ({0})
panel_editor_text_word_wrap_name
=
\u
041F
\u0435\u0440\u0435\u
043D
\u
043E
\u0441
\u0441\u
043B
\u
043E
\u0432
panel_editor_text_auto_format_name
=
\u0410\u0432\u0442\u
043E
\u0444\u
043E
\u0440\u
043C
\u0430\u0442\u0438\u0440\u
043E
\u0432\u0430\u
043D
\u0438\u0435
panel_editor_text_encoding_name
=
\u
041A
\u
043E
\u0434\u0438\u0440\u
043E
\u0432\u
043A
\u0430
...
panel_editor_text_encoding_title
=
\u0421\u
043C
\u0435\u
043D
\u0438\u0442\u
044C
\u
043A
\u
043E
\u0434\u0438\u0440\u
043E
\u0432\u
043A
\u0443
plugins/org.jkiss.dbeaver.ui.editors.data/src/org/jkiss/dbeaver/ui/data/managers/AbstractTextPanelEditor.java
浏览文件 @
8b492705
...
...
@@ -21,15 +21,21 @@ import org.eclipse.jface.action.Action;
import
org.eclipse.jface.action.IAction
;
import
org.eclipse.jface.action.IContributionManager
;
import
org.eclipse.jface.action.Separator
;
import
org.eclipse.jface.dialogs.IDialogConstants
;
import
org.eclipse.jface.dialogs.IDialogSettings
;
import
org.eclipse.jface.text.IUndoManager
;
import
org.eclipse.jface.text.TextViewer
;
import
org.eclipse.jface.text.source.ISourceViewer
;
import
org.eclipse.osgi.util.NLS
;
import
org.eclipse.swt.SWT
;
import
org.eclipse.swt.custom.ST
;
import
org.eclipse.swt.custom.StyledText
;
import
org.eclipse.swt.graphics.GC
;
import
org.eclipse.swt.graphics.Point
;
import
org.eclipse.swt.layout.GridData
;
import
org.eclipse.swt.widgets.Button
;
import
org.eclipse.swt.widgets.Combo
;
import
org.eclipse.swt.widgets.Composite
;
import
org.eclipse.ui.IEditorInput
;
import
org.eclipse.ui.IEditorSite
;
import
org.eclipse.ui.IWorkbenchCommandConstants
;
...
...
@@ -37,16 +43,20 @@ import org.eclipse.ui.PartInitException;
import
org.eclipse.ui.texteditor.ITextEditorActionConstants
;
import
org.eclipse.ui.texteditor.ITextEditorActionDefinitionIds
;
import
org.jkiss.code.NotNull
;
import
org.jkiss.code.Nullable
;
import
org.jkiss.dbeaver.DBException
;
import
org.jkiss.dbeaver.Log
;
import
org.jkiss.dbeaver.model.DBPMessageType
;
import
org.jkiss.dbeaver.model.data.DBDContent
;
import
org.jkiss.dbeaver.model.data.storage.StringContentStorage
;
import
org.jkiss.dbeaver.model.runtime.DBRProgressMonitor
;
import
org.jkiss.dbeaver.model.runtime.VoidProgressMonitor
;
import
org.jkiss.dbeaver.ui.UIUtils
;
import
org.jkiss.dbeaver.ui.controls.StyledTextUtils
;
import
org.jkiss.dbeaver.ui.controls.resultset.internal.ResultSetMessages
;
import
org.jkiss.dbeaver.ui.data.IStreamValueEditor
;
import
org.jkiss.dbeaver.ui.data.IValueController
;
import
org.jkiss.dbeaver.ui.dialogs.BaseDialog
;
import
org.jkiss.dbeaver.ui.editors.StringEditorInput
;
import
org.jkiss.dbeaver.ui.editors.SubEditorSite
;
import
org.jkiss.dbeaver.ui.editors.TextEditorUtils
;
...
...
@@ -55,6 +65,7 @@ import org.jkiss.dbeaver.ui.editors.data.internal.DataEditorsActivator;
import
org.jkiss.dbeaver.ui.editors.text.BaseTextEditor
;
import
org.jkiss.dbeaver.utils.RuntimeUtils
;
import
java.nio.charset.Charset
;
import
java.nio.charset.StandardCharsets
;
/**
...
...
@@ -64,6 +75,7 @@ public abstract class AbstractTextPanelEditor<EDITOR extends BaseTextEditor> imp
private
static
final
String
PREF_TEXT_EDITOR_WORD_WRAP
=
"content.text.editor.word-wrap"
;
private
static
final
String
PREF_TEXT_EDITOR_AUTO_FORMAT
=
"content.text.editor.auto-format"
;
private
static
final
String
PREF_TEXT_EDITOR_ENCODING
=
"content.text.editor.encoding"
;
private
static
final
Log
log
=
Log
.
getLog
(
AbstractTextPanelEditor
.
class
);
public
static
final
int
LONG_CONTENT_LENGTH
=
10000
;
...
...
@@ -128,7 +140,7 @@ public abstract class AbstractTextPanelEditor<EDITOR extends BaseTextEditor> imp
public
void
contributeSettings
(
@NotNull
IContributionManager
manager
,
@NotNull
final
StyledText
editorControl
)
{
manager
.
add
(
new
Separator
());
{
Action
wwAction
=
new
Action
(
"Word Wrap"
,
Action
.
AS_CHECK_BOX
)
{
Action
wwAction
=
new
Action
(
ResultSetMessages
.
panel_editor_text_word_wrap_name
,
Action
.
AS_CHECK_BOX
)
{
@Override
public
void
run
()
{
boolean
newWW
=
!
editorControl
.
getWordWrap
();
...
...
@@ -147,6 +159,33 @@ public abstract class AbstractTextPanelEditor<EDITOR extends BaseTextEditor> imp
afAction
.
setChecked
(
getPanelSettings
().
getBoolean
(
PREF_TEXT_EDITOR_AUTO_FORMAT
));
manager
.
add
(
afAction
);
}
if
(
textEditor
!=
null
)
{
manager
.
add
(
new
Action
(
ResultSetMessages
.
panel_editor_text_encoding_name
)
{
@Override
public
void
run
()
{
final
ChangeEncodingDialog
dialog
=
new
ChangeEncodingDialog
(
getPanelSettings
().
get
(
PREF_TEXT_EDITOR_ENCODING
));
if
(
dialog
.
open
()
!=
IDialogConstants
.
OK_ID
)
{
return
;
}
getPanelSettings
().
put
(
PREF_TEXT_EDITOR_ENCODING
,
dialog
.
getEncoding
());
final
EDITOR
editor
=
getTextEditor
();
if
(
editor
!=
null
)
{
final
TextViewer
viewer
=
editor
.
getTextViewer
();
if
(
viewer
!=
null
)
{
final
StyledText
control
=
viewer
.
getTextWidget
();
if
(
control
!=
null
&&
!
control
.
isDisposed
())
{
try
{
primeEditorValue
(
new
VoidProgressMonitor
(),
control
,
null
);
}
catch
(
DBException
e
)
{
log
.
error
(
"Can't refresh editor"
,
e
);
}
}
}
}
}
});
}
}
protected
EDITOR
getTextEditor
()
{
...
...
@@ -210,12 +249,13 @@ public abstract class AbstractTextPanelEditor<EDITOR extends BaseTextEditor> imp
}
@Override
public
void
primeEditorValue
(
@NotNull
DBRProgressMonitor
monitor
,
@NotNull
StyledText
control
,
@N
otNull
DBDContent
value
)
throws
DBException
public
void
primeEditorValue
(
@NotNull
DBRProgressMonitor
monitor
,
@NotNull
StyledText
control
,
@N
ullable
DBDContent
value
)
throws
DBException
{
try
{
// Load contents in two steps (empty + real in async mode). Workaround for some strange bug in StyledText in E4.13 (#6701)
TextViewer
textViewer
=
editor
.
getTextViewer
();
final
ContentEditorInput
textInput
=
new
ContentEditorInput
(
valueController
,
null
,
null
,
monitor
);
final
TextViewer
textViewer
=
editor
.
getTextViewer
();
final
String
encoding
=
getPanelSettings
().
get
(
PREF_TEXT_EDITOR_ENCODING
);
final
ContentEditorInput
textInput
=
new
ContentEditorInput
(
valueController
,
null
,
null
,
encoding
,
monitor
);
boolean
longContent
=
textInput
.
getContentLength
()
>
LONG_CONTENT_LENGTH
;
if
(
longContent
)
{
UIUtils
.
asyncExec
(()
->
{
...
...
@@ -229,7 +269,7 @@ public abstract class AbstractTextPanelEditor<EDITOR extends BaseTextEditor> imp
if
(
textWidget
!=
null
&&
longContent
)
{
GC
gc
=
new
GC
(
textWidget
);
try
{
UIUtils
.
drawMessageOverControl
(
textWidget
,
gc
,
"Loading content ... ("
+
textInput
.
getContentLength
()
+
")"
,
0
);
UIUtils
.
drawMessageOverControl
(
textWidget
,
gc
,
NLS
.
bind
(
ResultSetMessages
.
panel_editor_text_loading_placeholder_label
,
textInput
.
getContentLength
())
,
0
);
editor
.
setInput
(
textInput
);
}
finally
{
gc
.
dispose
();
...
...
@@ -283,7 +323,7 @@ public abstract class AbstractTextPanelEditor<EDITOR extends BaseTextEditor> imp
return
viewerSettings
;
}
private
class
WordWrapAction
extends
StyledTextUtils
.
StyledTextActionEx
{
private
static
class
WordWrapAction
extends
StyledTextUtils
.
StyledTextActionEx
{
private
final
StyledText
text
;
WordWrapAction
(
StyledText
text
)
{
...
...
@@ -304,7 +344,7 @@ public abstract class AbstractTextPanelEditor<EDITOR extends BaseTextEditor> imp
private
class
AutoFormatAction
extends
Action
{
AutoFormatAction
()
{
super
(
"Auto Format"
,
Action
.
AS_CHECK_BOX
);
super
(
ResultSetMessages
.
panel_editor_text_auto_format_name
,
Action
.
AS_CHECK_BOX
);
}
@Override
...
...
@@ -320,4 +360,54 @@ public abstract class AbstractTextPanelEditor<EDITOR extends BaseTextEditor> imp
applyEditorStyle
();
}
}
private
static
class
ChangeEncodingDialog
extends
BaseDialog
{
private
String
encoding
;
public
ChangeEncodingDialog
(
@NotNull
String
defaultEncoding
)
{
super
(
UIUtils
.
getActiveShell
(),
ResultSetMessages
.
panel_editor_text_encoding_title
,
null
);
this
.
encoding
=
defaultEncoding
;
this
.
setShellStyle
(
SWT
.
DIALOG_TRIM
);
}
@Override
protected
Composite
createDialogArea
(
Composite
parent
)
{
final
Composite
composite
=
super
.
createDialogArea
(
parent
);
{
final
Composite
innerComposite
=
UIUtils
.
createComposite
(
composite
,
1
);
innerComposite
.
setLayoutData
(
new
GridData
(
GridData
.
FILL_HORIZONTAL
));
final
Combo
encodingCombo
=
UIUtils
.
createEncodingCombo
(
innerComposite
,
encoding
);
encodingCombo
.
setLayoutData
(
new
GridData
(
GridData
.
FILL_HORIZONTAL
));
encodingCombo
.
addModifyListener
(
event
->
{
encoding
=
encodingCombo
.
getText
();
updateCompletion
();
});
}
return
composite
;
}
@Override
protected
void
createButtonsForButtonBar
(
Composite
parent
)
{
super
.
createButtonsForButtonBar
(
parent
);
updateCompletion
();
}
private
void
updateCompletion
()
{
final
Button
button
=
getButton
(
IDialogConstants
.
OK_ID
);
try
{
Charset
.
forName
(
encoding
);
button
.
setEnabled
(
true
);
}
catch
(
Exception
ignored
)
{
button
.
setEnabled
(
false
);
}
}
@NotNull
public
String
getEncoding
()
{
return
encoding
;
}
}
}
plugins/org.jkiss.dbeaver.ui.editors.data/src/org/jkiss/dbeaver/ui/editors/content/ContentEditorInput.java
浏览文件 @
8b492705
...
...
@@ -24,6 +24,7 @@ import org.eclipse.core.runtime.Path;
import
org.eclipse.jface.resource.ImageDescriptor
;
import
org.eclipse.ui.*
;
import
org.eclipse.ui.editors.text.IEncodingSupport
;
import
org.jkiss.code.NotNull
;
import
org.jkiss.code.Nullable
;
import
org.jkiss.dbeaver.DBException
;
import
org.jkiss.dbeaver.Log
;
...
...
@@ -75,10 +76,10 @@ public class ContentEditorInput implements IPathEditorInput, IStatefulEditorInpu
private
StringEditorInput
.
StringStorage
stringStorage
;
public
ContentEditorInput
(
IValueController
valueController
,
IEditorPart
[]
editorParts
,
IEditorPart
defaultPart
,
DBRProgressMonitor
monitor
)
@NotNull
IValueController
valueController
,
@Nullable
IEditorPart
[]
editorParts
,
@Nullable
IEditorPart
defaultPart
,
@NotNull
DBRProgressMonitor
monitor
)
throws
DBException
{
this
.
valueController
=
valueController
;
...
...
@@ -87,6 +88,20 @@ public class ContentEditorInput implements IPathEditorInput, IStatefulEditorInpu
this
.
fileCharset
=
getDefaultEncoding
();
this
.
prepareContent
(
monitor
);
}
public
ContentEditorInput
(
@NotNull
IValueController
valueController
,
@Nullable
IEditorPart
[]
editorParts
,
@Nullable
IEditorPart
defaultPart
,
@Nullable
String
charset
,
@NotNull
DBRProgressMonitor
monitor
)
throws
DBException
{
this
.
valueController
=
valueController
;
this
.
editorParts
=
editorParts
;
this
.
defaultPart
=
defaultPart
;
this
.
fileCharset
=
CommonUtils
.
isEmpty
(
charset
)
?
getDefaultEncoding
()
:
charset
;
this
.
prepareContent
(
monitor
);
}
public
IValueController
getValueController
()
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录