Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
suliangchun
dbeaver
提交
b42becbf
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,发现更多精彩内容 >>
提交
b42becbf
编写于
4月 26, 2021
作者:
S
ShadelessFox
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
#11480 Avoid having direct references to the owning spreadsheet
Former-commit-id:
b1134b28
上级
711a6c55
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
34 addition
and
16 deletion
+34
-16
plugins/org.jkiss.dbeaver.ui.editors.data/src/org/jkiss/dbeaver/ui/controls/resultset/spreadsheet/SpreadsheetFindReplaceTarget.java
...s/resultset/spreadsheet/SpreadsheetFindReplaceTarget.java
+34
-16
未找到文件。
plugins/org.jkiss.dbeaver.ui.editors.data/src/org/jkiss/dbeaver/ui/controls/resultset/spreadsheet/SpreadsheetFindReplaceTarget.java
浏览文件 @
b42becbf
...
...
@@ -29,7 +29,6 @@ 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
;
...
...
@@ -55,7 +54,8 @@ class SpreadsheetFindReplaceTarget implements IFindReplaceTarget, IFindReplaceTa
private
static
final
Log
log
=
Log
.
getLog
(
SpreadsheetFindReplaceTarget
.
class
);
private
static
SpreadsheetFindReplaceTarget
instance
;
private
SpreadsheetPresentation
owner
;
/** Uses {@link Object#hashCode()} to identity the current owner and determine whether he was changed or not. */
private
int
ownerIdentity
;
private
Pattern
searchPattern
;
private
Color
scopeHighlightColor
;
private
boolean
replaceAll
;
...
...
@@ -102,10 +102,7 @@ class SpreadsheetFindReplaceTarget implements IFindReplaceTarget, IFindReplaceTa
@Override
public
Point
getSelection
()
{
final
SpreadsheetPresentation
newOwner
=
getActiveSpreadsheet
();
if
(
newOwner
!=
null
&&
newOwner
!=
this
.
owner
)
{
refreshOwner
(
newOwner
);
}
final
SpreadsheetPresentation
owner
=
getActiveSpreadsheet
();
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
);
...
...
@@ -116,6 +113,7 @@ class SpreadsheetFindReplaceTarget implements IFindReplaceTarget, IFindReplaceTa
@Override
public
String
getSelectionText
()
{
final
SpreadsheetPresentation
owner
=
getActiveSpreadsheet
();
GridPos
selection
=
(
GridPos
)
owner
.
getSelection
().
getFirstElement
();
if
(
selection
==
null
)
{
return
""
;
...
...
@@ -129,6 +127,7 @@ class SpreadsheetFindReplaceTarget implements IFindReplaceTarget, IFindReplaceTa
@Override
public
boolean
isEditable
()
{
final
SpreadsheetPresentation
owner
=
getActiveSpreadsheet
();
return
owner
.
getController
().
getReadOnlyStatus
()
==
null
;
}
...
...
@@ -141,18 +140,20 @@ class SpreadsheetFindReplaceTarget implements IFindReplaceTarget, IFindReplaceTa
@Override
public
void
beginSession
()
{
final
SpreadsheetPresentation
owner
=
getActiveSpreadsheet
(
false
);
this
.
sessionActive
=
true
;
this
.
owner
.
getControl
().
redraw
();
owner
.
getControl
().
redraw
();
this
.
originalSelection
=
new
ArrayList
<>(
owner
.
getSpreadsheet
().
getSelection
());
this
.
owner
.
highlightRows
(-
1
,
-
1
,
null
);
owner
.
highlightRows
(-
1
,
-
1
,
null
);
}
@Override
public
void
endSession
()
{
final
SpreadsheetPresentation
owner
=
getActiveSpreadsheet
(
false
);
this
.
sessionActive
=
false
;
this
.
searchPattern
=
null
;
Control
control
=
this
.
owner
.
getControl
();
Control
control
=
owner
.
getControl
();
if
(
control
!=
null
&&
!
control
.
isDisposed
())
{
owner
.
getSpreadsheet
().
deselectAll
();
owner
.
getSpreadsheet
().
selectCells
(
this
.
originalSelection
);
...
...
@@ -167,6 +168,7 @@ class SpreadsheetFindReplaceTarget implements IFindReplaceTarget, IFindReplaceTa
@Override
public
void
setScope
(
IRegion
scope
)
{
final
SpreadsheetPresentation
owner
=
getActiveSpreadsheet
();
if
(
scope
==
null
||
scope
.
getLength
()
==
0
)
{
owner
.
highlightRows
(-
1
,
-
1
,
null
);
if
(
scope
==
null
)
{
...
...
@@ -187,6 +189,7 @@ class SpreadsheetFindReplaceTarget implements IFindReplaceTarget, IFindReplaceTa
@Override
public
void
setSelection
(
int
offset
,
int
length
)
{
final
SpreadsheetPresentation
owner
=
getActiveSpreadsheet
();
int
columnCount
=
owner
.
getSpreadsheet
().
getColumnCount
();
List
<
GridPos
>
selRows
=
new
ArrayList
<>();
for
(
int
rowNum
=
0
;
rowNum
<
length
;
rowNum
++)
{
...
...
@@ -215,6 +218,7 @@ class SpreadsheetFindReplaceTarget implements IFindReplaceTarget, IFindReplaceTa
{
searchPattern
=
null
;
final
SpreadsheetPresentation
owner
=
getActiveSpreadsheet
();
ResultSetModel
model
=
owner
.
getController
().
getModel
();
if
(
model
.
isEmpty
())
{
return
-
1
;
...
...
@@ -312,6 +316,7 @@ class SpreadsheetFindReplaceTarget implements IFindReplaceTarget, IFindReplaceTa
@Override
public
void
replaceSelection
(
String
text
,
boolean
regExReplace
)
{
final
SpreadsheetPresentation
owner
=
getActiveSpreadsheet
();
GridPos
selection
=
(
GridPos
)
owner
.
getSelection
().
getFirstElement
();
if
(
selection
==
null
)
{
return
;
...
...
@@ -336,12 +341,13 @@ class SpreadsheetFindReplaceTarget implements IFindReplaceTarget, IFindReplaceTa
@Override
public
String
toString
()
{
final
SpreadsheetPresentation
owner
=
getActiveSpreadsheet
();
DBSDataContainer
dataContainer
=
owner
.
getController
().
getDataContainer
();
return
"Target: "
+
(
dataContainer
==
null
?
null
:
dataContainer
.
getName
());
}
private
void
refreshOwner
(
@NotNull
SpreadsheetPresentation
newOwner
)
{
if
(
this
.
owner
==
newOwner
)
{
if
(
this
.
owner
Identity
==
newOwner
.
hashCode
()
)
{
return
;
}
final
boolean
refreshSession
=
this
.
sessionActive
;
...
...
@@ -349,23 +355,35 @@ class SpreadsheetFindReplaceTarget implements IFindReplaceTarget, IFindReplaceTa
if
(
refreshSession
)
{
this
.
endSession
();
}
this
.
owner
=
newOwner
;
this
.
owner
Identity
=
newOwner
.
hashCode
()
;
if
(
refreshSession
)
{
this
.
beginSession
();
this
.
searchPattern
=
searchPattern
;
}
}
@Nullable
private
static
SpreadsheetPresentation
getActiveSpreadsheet
()
{
@NotNull
private
SpreadsheetPresentation
getActiveSpreadsheet
()
{
return
getActiveSpreadsheet
(
true
);
}
@NotNull
private
SpreadsheetPresentation
getActiveSpreadsheet
(
boolean
refreshActiveSpreadsheet
)
{
final
IWorkbenchWindow
workbenchWindow
=
PlatformUI
.
getWorkbench
().
getActiveWorkbenchWindow
();
if
(
workbenchWindow
==
null
)
{
return
null
;
throw
new
IllegalStateException
(
"Can't obtain workbench window"
)
;
}
final
IEditorPart
activeEditor
=
workbenchWindow
.
getActivePage
().
getActiveEditor
();
if
(
activeEditor
==
null
)
{
return
null
;
throw
new
IllegalStateException
(
"Can't obtain active editor"
);
}
final
SpreadsheetPresentation
spreadsheet
=
activeEditor
.
getAdapter
(
SpreadsheetPresentation
.
class
);
if
(
spreadsheet
==
null
)
{
throw
new
IllegalStateException
(
"Can't obtain active spreadsheet"
);
}
if
(
refreshActiveSpreadsheet
)
{
refreshOwner
(
spreadsheet
);
}
return
activeEditor
.
getAdapter
(
SpreadsheetPresentation
.
class
)
;
return
spreadsheet
;
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录