Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
suliangchun
dbeaver
提交
da145d77
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,发现更多精彩内容 >>
提交
da145d77
编写于
8月 10, 2019
作者:
S
Serge Rider
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
#6484 Text editors in value pane: find/replace + common actions.
上级
473022f8
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
84 addition
and
21 deletion
+84
-21
plugins/org.jkiss.dbeaver.ui.editors.base/src/org/jkiss/dbeaver/ui/controls/StyledTextUtils.java
...se/src/org/jkiss/dbeaver/ui/controls/StyledTextUtils.java
+2
-5
plugins/org.jkiss.dbeaver.ui.editors.base/src/org/jkiss/dbeaver/ui/editors/IActionContributor.java
.../src/org/jkiss/dbeaver/ui/editors/IActionContributor.java
+29
-0
plugins/org.jkiss.dbeaver.ui.editors.base/src/org/jkiss/dbeaver/ui/editors/text/BaseTextEditor.java
...src/org/jkiss/dbeaver/ui/editors/text/BaseTextEditor.java
+13
-4
plugins/org.jkiss.dbeaver.ui.editors.data/src/org/jkiss/dbeaver/ui/controls/resultset/IResultSetPanel.java
.../jkiss/dbeaver/ui/controls/resultset/IResultSetPanel.java
+2
-2
plugins/org.jkiss.dbeaver.ui.editors.data/src/org/jkiss/dbeaver/ui/data/managers/AbstractTextPanelEditor.java
...iss/dbeaver/ui/data/managers/AbstractTextPanelEditor.java
+38
-10
未找到文件。
plugins/org.jkiss.dbeaver.ui.editors.base/src/org/jkiss/dbeaver/ui/controls/StyledTextUtils.java
浏览文件 @
da145d77
...
...
@@ -16,10 +16,7 @@
*/
package
org.jkiss.dbeaver.ui.controls
;
import
org.eclipse.jface.action.Action
;
import
org.eclipse.jface.action.GroupMarker
;
import
org.eclipse.jface.action.IMenuManager
;
import
org.eclipse.jface.action.MenuManager
;
import
org.eclipse.jface.action.*
;
import
org.eclipse.jface.text.IFindReplaceTarget
;
import
org.eclipse.swt.custom.ST
;
import
org.eclipse.swt.custom.StyledText
;
...
...
@@ -64,7 +61,7 @@ public class StyledTextUtils {
text
.
addDisposeListener
(
e
->
menuMgr
.
dispose
());
}
public
static
void
fillDefaultStyledTextContextMenu
(
I
Menu
Manager
menu
,
final
StyledText
text
)
{
public
static
void
fillDefaultStyledTextContextMenu
(
I
Contribution
Manager
menu
,
final
StyledText
text
)
{
final
Point
selectionRange
=
text
.
getSelectionRange
();
menu
.
add
(
new
StyledTextAction
(
IWorkbenchCommandConstants
.
EDIT_COPY
,
selectionRange
.
y
>
0
,
text
,
ST
.
COPY
));
menu
.
add
(
new
StyledTextAction
(
IWorkbenchCommandConstants
.
EDIT_PASTE
,
text
.
getEditable
(),
text
,
ST
.
PASTE
));
...
...
plugins/org.jkiss.dbeaver.ui.editors.base/src/org/jkiss/dbeaver/ui/editors/IActionContributor.java
0 → 100644
浏览文件 @
da145d77
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2019 Serge Rider (serge@jkiss.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org.jkiss.dbeaver.ui.editors
;
import
org.eclipse.jface.action.IContributionManager
;
/**
* Action contributor
*/
public
interface
IActionContributor
{
void
contributeActions
(
IContributionManager
manager
);
}
plugins/org.jkiss.dbeaver.ui.editors.base/src/org/jkiss/dbeaver/ui/editors/text/BaseTextEditor.java
浏览文件 @
da145d77
...
...
@@ -43,16 +43,15 @@ import org.jkiss.dbeaver.ui.ICommentsSupport;
import
org.jkiss.dbeaver.ui.ISingleControlEditor
;
import
org.jkiss.dbeaver.ui.UIUtils
;
import
org.jkiss.dbeaver.ui.dialogs.DialogUtils
;
import
org.jkiss.dbeaver.ui.editors.EditorUtils
;
import
org.jkiss.dbeaver.ui.editors.INonPersistentEditorInput
;
import
org.jkiss.dbeaver.ui.editors.IStatefulEditorInput
;
import
org.jkiss.dbeaver.ui.editors.SubEditorSite
;
import
org.jkiss.dbeaver.ui.editors.*
;
import
org.jkiss.dbeaver.utils.ContentUtils
;
import
org.jkiss.dbeaver.utils.GeneralUtils
;
import
org.jkiss.utils.IOUtils
;
import
java.io.*
;
import
java.lang.reflect.InvocationTargetException
;
import
java.util.ArrayList
;
import
java.util.List
;
/**
* Abstract text editor.
...
...
@@ -66,6 +65,12 @@ public abstract class BaseTextEditor extends AbstractDecoratedTextEditor impleme
public
static
final
String
GROUP_SQL_ADDITIONS
=
"sql.additions"
;
public
static
final
String
GROUP_SQL_EXTRAS
=
"sql.extras"
;
private
List
<
IActionContributor
>
actionContributors
=
new
ArrayList
<>();
public
void
addContextMenuContributor
(
IActionContributor
contributor
)
{
actionContributors
.
add
(
contributor
);
}
public
static
BaseTextEditor
getTextEditor
(
IEditorPart
editor
)
{
if
(
editor
==
null
)
{
...
...
@@ -182,6 +187,10 @@ public abstract class BaseTextEditor extends AbstractDecoratedTextEditor impleme
if
(
preferencesAction
!=
null
)
{
menu
.
appendToGroup
(
GROUP_SQL_PREFERENCES
,
preferencesAction
);
}
for
(
IActionContributor
ac
:
actionContributors
)
{
ac
.
contributeActions
(
menu
);
}
}
@Nullable
...
...
plugins/org.jkiss.dbeaver.ui.editors.data/src/org/jkiss/dbeaver/ui/controls/resultset/IResultSetPanel.java
浏览文件 @
da145d77
...
...
@@ -21,12 +21,13 @@ import org.eclipse.jface.action.IContributionManager;
import
org.eclipse.swt.widgets.Composite
;
import
org.eclipse.swt.widgets.Control
;
import
org.jkiss.dbeaver.ui.controls.resultset.IResultSetPresentation
;
import
org.jkiss.dbeaver.ui.editors.IActionContributor
;
/**
* ResultSet panel.
* RSV can embed multiple panels to provide additional visualization functionality
*/
public
interface
IResultSetPanel
{
public
interface
IResultSetPanel
extends
IActionContributor
{
Control
createContents
(
IResultSetPresentation
presentation
,
Composite
parent
);
...
...
@@ -38,5 +39,4 @@ public interface IResultSetPanel {
void
refresh
(
boolean
force
);
void
contributeActions
(
IContributionManager
manager
);
}
plugins/org.jkiss.dbeaver.ui.editors.data/src/org/jkiss/dbeaver/ui/data/managers/AbstractTextPanelEditor.java
浏览文件 @
da145d77
...
...
@@ -18,6 +18,7 @@ package org.jkiss.dbeaver.ui.data.managers;
import
org.eclipse.core.runtime.IAdaptable
;
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.IDialogSettings
;
...
...
@@ -29,6 +30,7 @@ import org.eclipse.swt.custom.StyledText;
import
org.eclipse.ui.IEditorInput
;
import
org.eclipse.ui.IEditorSite
;
import
org.eclipse.ui.PartInitException
;
import
org.eclipse.ui.texteditor.ITextEditorActionConstants
;
import
org.jkiss.code.NotNull
;
import
org.jkiss.dbeaver.DBException
;
import
org.jkiss.dbeaver.Log
;
...
...
@@ -37,6 +39,7 @@ import org.jkiss.dbeaver.model.data.DBDContent;
import
org.jkiss.dbeaver.model.impl.StringContentStorage
;
import
org.jkiss.dbeaver.model.runtime.DBRProgressMonitor
;
import
org.jkiss.dbeaver.ui.UIUtils
;
import
org.jkiss.dbeaver.ui.controls.StyledTextUtils
;
import
org.jkiss.dbeaver.ui.data.IStreamValueEditor
;
import
org.jkiss.dbeaver.ui.data.IValueController
;
import
org.jkiss.dbeaver.ui.editors.StringEditorInput
;
...
...
@@ -76,11 +79,26 @@ public abstract class AbstractTextPanelEditor<EDITOR extends BaseTextEditor> imp
assert
editorControl
!=
null
;
initEditorSettings
(
editorControl
);
editorControl
.
addDisposeListener
(
e
->
editor
.
releaseEditorInput
());
return
editor
.
getEditorControl
();
editor
.
addContextMenuContributor
(
manager
->
contributeTextEditorActions
(
manager
,
editorControl
));
return
editorControl
;
}
protected
abstract
EDITOR
createEditorParty
(
IValueController
valueController
);
protected
void
contributeTextEditorActions
(
@NotNull
IContributionManager
manager
,
@NotNull
final
StyledText
control
)
{
manager
.
removeAll
();
StyledTextUtils
.
fillDefaultStyledTextContextMenu
(
manager
,
control
);
manager
.
add
(
new
AutoFormatAction
());
IAction
preferencesAction
=
editor
.
getAction
(
ITextEditorActionConstants
.
CONTEXT_PREFERENCES
);
if
(
preferencesAction
!=
null
)
{
manager
.
add
(
new
Separator
());
manager
.
add
(
preferencesAction
);
}
}
@Override
public
void
contributeActions
(
@NotNull
IContributionManager
manager
,
@NotNull
final
StyledText
control
)
{
...
...
@@ -105,15 +123,7 @@ public abstract class AbstractTextPanelEditor<EDITOR extends BaseTextEditor> imp
BaseTextEditor
textEditor
=
getTextEditor
();
if
(
textEditor
!=
null
)
{
final
Action
afAction
=
new
Action
(
"Auto Format"
,
Action
.
AS_CHECK_BOX
)
{
@Override
public
void
run
()
{
boolean
newAF
=
!
getPanelSettings
().
getBoolean
(
PREF_TEXT_EDITOR_AUTO_FORMAT
);
setChecked
(
newAF
);
getPanelSettings
().
put
(
PREF_TEXT_EDITOR_AUTO_FORMAT
,
newAF
);
applyEditorStyle
();
}
};
final
Action
afAction
=
new
AutoFormatAction
();
afAction
.
setChecked
(
getPanelSettings
().
getBoolean
(
PREF_TEXT_EDITOR_AUTO_FORMAT
));
manager
.
add
(
afAction
);
}
...
...
@@ -233,4 +243,22 @@ public abstract class AbstractTextPanelEditor<EDITOR extends BaseTextEditor> imp
return
viewerSettings
;
}
private
class
AutoFormatAction
extends
Action
{
AutoFormatAction
()
{
super
(
"Auto Format"
,
Action
.
AS_CHECK_BOX
);
}
@Override
public
boolean
isChecked
()
{
return
getPanelSettings
().
getBoolean
(
PREF_TEXT_EDITOR_AUTO_FORMAT
);
}
@Override
public
void
run
()
{
boolean
newAF
=
!
getPanelSettings
().
getBoolean
(
PREF_TEXT_EDITOR_AUTO_FORMAT
);
//setChecked(newAF);
getPanelSettings
().
put
(
PREF_TEXT_EDITOR_AUTO_FORMAT
,
newAF
);
applyEditorStyle
();
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录