Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
suliangchun
dbeaver
提交
6386fa40
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,发现更多精彩内容 >>
提交
6386fa40
编写于
4月 26, 2021
作者:
S
ShadelessFox
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
#11480 Add explicit null-check instead of throwing exceptions
Former-commit-id:
33d34bd7
上级
b42becbf
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
35 addition
and
7 deletion
+35
-7
plugins/org.jkiss.dbeaver.ui.editors.data/src/org/jkiss/dbeaver/ui/controls/resultset/spreadsheet/SpreadsheetFindReplaceTarget.java
...s/resultset/spreadsheet/SpreadsheetFindReplaceTarget.java
+35
-7
未找到文件。
plugins/org.jkiss.dbeaver.ui.editors.data/src/org/jkiss/dbeaver/ui/controls/resultset/spreadsheet/SpreadsheetFindReplaceTarget.java
浏览文件 @
6386fa40
...
...
@@ -29,6 +29,7 @@ import org.eclipse.ui.IEditorPart;
import
org.eclipse.ui.IWorkbenchWindow
;
import
org.eclipse.ui.PlatformUI
;
import
org.jkiss.code.NotNull
;
import
org.jkiss.code.Nullable
;
import
org.jkiss.dbeaver.Log
;
import
org.jkiss.dbeaver.model.data.DBDAttributeBinding
;
import
org.jkiss.dbeaver.model.struct.DBSDataContainer
;
...
...
@@ -103,6 +104,9 @@ class SpreadsheetFindReplaceTarget implements IFindReplaceTarget, IFindReplaceTa
public
Point
getSelection
()
{
final
SpreadsheetPresentation
owner
=
getActiveSpreadsheet
();
if
(
owner
==
null
)
{
return
new
Point
(
0
,
0
);
}
Collection
<
Integer
>
rowSelection
=
owner
.
getSpreadsheet
().
getRowSelection
();
int
minRow
=
rowSelection
.
stream
().
mapToInt
(
v
->
v
).
min
().
orElse
(-
1
);
int
maxRow
=
rowSelection
.
stream
().
mapToInt
(
v
->
v
).
max
().
orElse
(-
1
);
...
...
@@ -114,6 +118,9 @@ class SpreadsheetFindReplaceTarget implements IFindReplaceTarget, IFindReplaceTa
public
String
getSelectionText
()
{
final
SpreadsheetPresentation
owner
=
getActiveSpreadsheet
();
if
(
owner
==
null
)
{
return
""
;
}
GridPos
selection
=
(
GridPos
)
owner
.
getSelection
().
getFirstElement
();
if
(
selection
==
null
)
{
return
""
;
...
...
@@ -128,7 +135,7 @@ class SpreadsheetFindReplaceTarget implements IFindReplaceTarget, IFindReplaceTa
public
boolean
isEditable
()
{
final
SpreadsheetPresentation
owner
=
getActiveSpreadsheet
();
return
owner
.
getController
().
getReadOnlyStatus
()
==
null
;
return
owner
!=
null
&&
owner
.
getController
().
getReadOnlyStatus
()
==
null
;
}
@Override
...
...
@@ -141,6 +148,9 @@ class SpreadsheetFindReplaceTarget implements IFindReplaceTarget, IFindReplaceTa
public
void
beginSession
()
{
final
SpreadsheetPresentation
owner
=
getActiveSpreadsheet
(
false
);
if
(
owner
==
null
)
{
return
;
}
this
.
sessionActive
=
true
;
owner
.
getControl
().
redraw
();
this
.
originalSelection
=
new
ArrayList
<>(
owner
.
getSpreadsheet
().
getSelection
());
...
...
@@ -151,6 +161,9 @@ class SpreadsheetFindReplaceTarget implements IFindReplaceTarget, IFindReplaceTa
public
void
endSession
()
{
final
SpreadsheetPresentation
owner
=
getActiveSpreadsheet
(
false
);
if
(
owner
==
null
)
{
return
;
}
this
.
sessionActive
=
false
;
this
.
searchPattern
=
null
;
Control
control
=
owner
.
getControl
();
...
...
@@ -169,6 +182,9 @@ class SpreadsheetFindReplaceTarget implements IFindReplaceTarget, IFindReplaceTa
@Override
public
void
setScope
(
IRegion
scope
)
{
final
SpreadsheetPresentation
owner
=
getActiveSpreadsheet
();
if
(
owner
==
null
)
{
return
;
}
if
(
scope
==
null
||
scope
.
getLength
()
==
0
)
{
owner
.
highlightRows
(-
1
,
-
1
,
null
);
if
(
scope
==
null
)
{
...
...
@@ -190,6 +206,9 @@ class SpreadsheetFindReplaceTarget implements IFindReplaceTarget, IFindReplaceTa
public
void
setSelection
(
int
offset
,
int
length
)
{
final
SpreadsheetPresentation
owner
=
getActiveSpreadsheet
();
if
(
owner
==
null
)
{
return
;
}
int
columnCount
=
owner
.
getSpreadsheet
().
getColumnCount
();
List
<
GridPos
>
selRows
=
new
ArrayList
<>();
for
(
int
rowNum
=
0
;
rowNum
<
length
;
rowNum
++)
{
...
...
@@ -216,9 +235,12 @@ class SpreadsheetFindReplaceTarget implements IFindReplaceTarget, IFindReplaceTa
@Override
public
int
findAndSelect
(
int
offset
,
String
findString
,
boolean
searchForward
,
boolean
caseSensitive
,
boolean
wholeWord
,
boolean
regExSearch
)
{
final
SpreadsheetPresentation
owner
=
getActiveSpreadsheet
();
if
(
owner
==
null
)
{
return
-
1
;
}
searchPattern
=
null
;
final
SpreadsheetPresentation
owner
=
getActiveSpreadsheet
();
ResultSetModel
model
=
owner
.
getController
().
getModel
();
if
(
model
.
isEmpty
())
{
return
-
1
;
...
...
@@ -317,6 +339,9 @@ class SpreadsheetFindReplaceTarget implements IFindReplaceTarget, IFindReplaceTa
public
void
replaceSelection
(
String
text
,
boolean
regExReplace
)
{
final
SpreadsheetPresentation
owner
=
getActiveSpreadsheet
();
if
(
owner
==
null
)
{
return
;
}
GridPos
selection
=
(
GridPos
)
owner
.
getSelection
().
getFirstElement
();
if
(
selection
==
null
)
{
return
;
...
...
@@ -342,6 +367,9 @@ class SpreadsheetFindReplaceTarget implements IFindReplaceTarget, IFindReplaceTa
public
String
toString
()
{
final
SpreadsheetPresentation
owner
=
getActiveSpreadsheet
();
if
(
owner
==
null
)
{
return
super
.
toString
();
}
DBSDataContainer
dataContainer
=
owner
.
getController
().
getDataContainer
();
return
"Target: "
+
(
dataContainer
==
null
?
null
:
dataContainer
.
getName
());
}
...
...
@@ -362,24 +390,24 @@ class SpreadsheetFindReplaceTarget implements IFindReplaceTarget, IFindReplaceTa
}
}
@N
otNull
@N
ullable
private
SpreadsheetPresentation
getActiveSpreadsheet
()
{
return
getActiveSpreadsheet
(
true
);
}
@N
otNull
@N
ullable
private
SpreadsheetPresentation
getActiveSpreadsheet
(
boolean
refreshActiveSpreadsheet
)
{
final
IWorkbenchWindow
workbenchWindow
=
PlatformUI
.
getWorkbench
().
getActiveWorkbenchWindow
();
if
(
workbenchWindow
==
null
)
{
throw
new
IllegalStateException
(
"Can't obtain workbench window"
)
;
return
null
;
}
final
IEditorPart
activeEditor
=
workbenchWindow
.
getActivePage
().
getActiveEditor
();
if
(
activeEditor
==
null
)
{
throw
new
IllegalStateException
(
"Can't obtain active editor"
)
;
return
null
;
}
final
SpreadsheetPresentation
spreadsheet
=
activeEditor
.
getAdapter
(
SpreadsheetPresentation
.
class
);
if
(
spreadsheet
==
null
)
{
throw
new
IllegalStateException
(
"Can't obtain active spreadsheet"
)
;
return
null
;
}
if
(
refreshActiveSpreadsheet
)
{
refreshOwner
(
spreadsheet
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录