Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
suliangchun
dbeaver
提交
e6296004
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,发现更多精彩内容 >>
提交
e6296004
编写于
3月 10, 2018
作者:
A
Alexander Fedorov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
#3118 add "Specify Script" dialog
上级
882d2101
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
201 addition
and
1 deletion
+201
-1
plugins/org.jkiss.dbeaver.debug.ui/META-INF/MANIFEST.MF
plugins/org.jkiss.dbeaver.debug.ui/META-INF/MANIFEST.MF
+2
-0
plugins/org.jkiss.dbeaver.debug.ui/src/org/jkiss/dbeaver/debug/ui/DatabaseLaunchShortcut.java
...rc/org/jkiss/dbeaver/debug/ui/DatabaseLaunchShortcut.java
+23
-1
plugins/org.jkiss.dbeaver.debug.ui/src/org/jkiss/dbeaver/debug/ui/DatabaseScriptDialog.java
.../src/org/jkiss/dbeaver/debug/ui/DatabaseScriptDialog.java
+79
-0
plugins/org.jkiss.dbeaver.debug.ui/src/org/jkiss/dbeaver/debug/ui/DatabaseScriptEditor.java
.../src/org/jkiss/dbeaver/debug/ui/DatabaseScriptEditor.java
+80
-0
plugins/org.jkiss.dbeaver.ext.postgresql.debug.ui/src/org/jkiss/dbeaver/ext/postgresql/debug/ui/internal/PgSqlLocalLaunchShortcut.java
...ostgresql/debug/ui/internal/PgSqlLocalLaunchShortcut.java
+17
-0
未找到文件。
plugins/org.jkiss.dbeaver.debug.ui/META-INF/MANIFEST.MF
浏览文件 @
e6296004
...
...
@@ -10,7 +10,9 @@ Require-Bundle: org.eclipse.core.runtime,
org.eclipse.core.expressions,
org.eclipse.jface.text,
org.eclipse.ui;visibility:=reexport,
org.eclipse.ui.editors,
org.eclipse.ui.workbench.texteditor,
org.eclipse.ui.ide,
org.eclipse.debug.ui;visibility:=reexport,
org.jkiss.dbeaver.runtime.ide.core,
org.jkiss.dbeaver.runtime.ide.ui,
...
...
plugins/org.jkiss.dbeaver.debug.ui/src/org/jkiss/dbeaver/debug/ui/DatabaseLaunchShortcut.java
浏览文件 @
e6296004
...
...
@@ -44,6 +44,10 @@ import org.eclipse.jface.window.Window;
import
org.eclipse.osgi.util.NLS
;
import
org.eclipse.swt.widgets.Shell
;
import
org.eclipse.ui.IEditorPart
;
import
org.eclipse.ui.IEditorSite
;
import
org.eclipse.ui.IWorkbenchPage
;
import
org.eclipse.ui.IWorkbenchPart
;
import
org.eclipse.ui.IWorkbenchPartSite
;
import
org.eclipse.ui.IWorkbenchWindow
;
import
org.eclipse.ui.PlatformUI
;
import
org.eclipse.ui.dialogs.ElementListSelectionDialog
;
...
...
@@ -58,6 +62,8 @@ public abstract class DatabaseLaunchShortcut implements ILaunchShortcut2 {
private
final
String
configurationTypeId
;
private
final
String
launchObjectName
;
private
IWorkbenchPartSite
workbenchPartSite
;
public
DatabaseLaunchShortcut
(
String
typeId
,
String
objectName
)
{
this
.
configurationTypeId
=
typeId
;
this
.
launchObjectName
=
objectName
;
...
...
@@ -66,6 +72,16 @@ public abstract class DatabaseLaunchShortcut implements ILaunchShortcut2 {
@Override
public
void
launch
(
ISelection
selection
,
String
mode
)
{
if
(
selection
instanceof
IStructuredSelection
)
{
IWorkbenchWindow
activeWindow
=
PlatformUI
.
getWorkbench
().
getActiveWorkbenchWindow
();
if
(
activeWindow
!=
null
)
{
IWorkbenchPage
activePage
=
activeWindow
.
getActivePage
();
if
(
activePage
!=
null
)
{
IWorkbenchPart
activePart
=
activePage
.
getActivePart
();
if
(
activePart
!=
null
)
{
workbenchPartSite
=
activePart
.
getSite
();
}
}
}
Object
[]
array
=
((
IStructuredSelection
)
selection
).
toArray
();
searchAndLaunch
(
array
,
mode
,
getSelectionEmptyMessage
());
}
...
...
@@ -73,7 +89,9 @@ public abstract class DatabaseLaunchShortcut implements ILaunchShortcut2 {
@Override
public
void
launch
(
IEditorPart
editor
,
String
mode
)
{
ISelection
selection
=
editor
.
getEditorSite
().
getSelectionProvider
().
getSelection
();
IEditorSite
editorSite
=
editor
.
getEditorSite
();
workbenchPartSite
=
editorSite
;
ISelection
selection
=
editorSite
.
getSelectionProvider
().
getSelection
();
if
(
selection
instanceof
IStructuredSelection
)
{
Object
[]
array
=
((
IStructuredSelection
)
selection
).
toArray
();
searchAndLaunch
(
array
,
mode
,
getEditorEmptyMessage
());
...
...
@@ -86,6 +104,10 @@ public abstract class DatabaseLaunchShortcut implements ILaunchShortcut2 {
}
}
protected
IWorkbenchPartSite
getWorkbenchPartSite
()
{
return
workbenchPartSite
;
}
protected
String
getSelectionEmptyMessage
()
{
String
message
=
DebugUIMessages
.
DatabaseLaunchShortcut_e_selection_empty
;
...
...
plugins/org.jkiss.dbeaver.debug.ui/src/org/jkiss/dbeaver/debug/ui/DatabaseScriptDialog.java
0 → 100644
浏览文件 @
e6296004
package
org.jkiss.dbeaver.debug.ui
;
import
org.eclipse.jface.dialogs.TitleAreaDialog
;
import
org.eclipse.swt.SWT
;
import
org.eclipse.swt.custom.StyledText
;
import
org.eclipse.swt.layout.FillLayout
;
import
org.eclipse.swt.layout.GridData
;
import
org.eclipse.swt.widgets.Composite
;
import
org.eclipse.swt.widgets.Control
;
import
org.eclipse.swt.widgets.Shell
;
import
org.eclipse.ui.IEditorSite
;
import
org.eclipse.ui.IWorkbenchPartSite
;
import
org.eclipse.ui.PartInitException
;
import
org.jkiss.dbeaver.model.struct.DBSObject
;
import
org.jkiss.dbeaver.runtime.ui.DBUserInterface
;
import
org.jkiss.dbeaver.ui.UIUtils
;
import
org.jkiss.dbeaver.ui.editors.StringEditorInput
;
import
org.jkiss.dbeaver.ui.editors.SubEditorSite
;
import
org.jkiss.dbeaver.ui.editors.sql.SQLEditorBase
;
import
org.jkiss.dbeaver.utils.GeneralUtils
;
public
class
DatabaseScriptDialog
extends
TitleAreaDialog
{
private
final
DBSObject
dbsObject
;
private
String
scriptValue
;
private
IEditorSite
subSite
;
private
SQLEditorBase
sqlViewer
;
private
StringEditorInput
sqlInput
;
public
DatabaseScriptDialog
(
Shell
shell
,
IWorkbenchPartSite
parentSite
,
String
name
,
String
value
,
DBSObject
dbsObject
)
{
super
(
shell
);
this
.
dbsObject
=
dbsObject
;
this
.
subSite
=
new
SubEditorSite
(
parentSite
);
this
.
sqlInput
=
new
StringEditorInput
(
name
,
value
,
true
,
GeneralUtils
.
getDefaultFileEncoding
());
this
.
scriptValue
=
value
;
}
public
String
getScriptTextValue
()
{
return
scriptValue
;
}
@Override
protected
Control
createDialogArea
(
Composite
parent
)
{
String
title
=
"Specify Script"
;
getShell
().
setText
(
title
);
Control
createdArea
=
super
.
createDialogArea
(
parent
);
sqlViewer
=
new
DatabaseScriptEditor
(
dbsObject
,
title
);
try
{
sqlViewer
.
init
(
subSite
,
sqlInput
);
sqlViewer
.
reloadSyntaxRules
();
Object
text
=
sqlViewer
.
getAdapter
(
Control
.
class
);
if
(
text
instanceof
StyledText
)
{
((
StyledText
)
text
).
setEditable
(
true
);;
}
}
catch
(
PartInitException
e
)
{
DBUserInterface
.
getInstance
().
showError
(
getShell
().
getText
(),
null
,
e
);
}
Composite
panel
=
UIUtils
.
createPlaceholder
(
parent
,
1
);
panel
.
setLayoutData
(
new
GridData
(
GridData
.
FILL_BOTH
));
Composite
editorPH
=
new
Composite
(
panel
,
SWT
.
BORDER
);
GridData
gd
=
new
GridData
(
GridData
.
FILL_BOTH
);
gd
.
verticalIndent
=
3
;
gd
.
horizontalSpan
=
1
;
gd
.
minimumHeight
=
100
;
gd
.
minimumWidth
=
100
;
editorPH
.
setLayoutData
(
gd
);
editorPH
.
setLayout
(
new
FillLayout
());
sqlViewer
.
createPartControl
(
editorPH
);
return
createdArea
;
}
@Override
protected
void
okPressed
()
{
scriptValue
=
sqlViewer
.
getDocument
().
get
();
super
.
okPressed
();
}
}
plugins/org.jkiss.dbeaver.debug.ui/src/org/jkiss/dbeaver/debug/ui/DatabaseScriptEditor.java
0 → 100644
浏览文件 @
e6296004
package
org.jkiss.dbeaver.debug.ui
;
import
org.eclipse.core.runtime.CoreException
;
import
org.eclipse.core.runtime.IProgressMonitor
;
import
org.eclipse.jface.text.Document
;
import
org.eclipse.jface.text.IDocument
;
import
org.eclipse.osgi.util.NLS
;
import
org.jkiss.dbeaver.DBException
;
import
org.jkiss.dbeaver.Log
;
import
org.jkiss.dbeaver.model.DBPDataSource
;
import
org.jkiss.dbeaver.model.exec.DBCExecutionContext
;
import
org.jkiss.dbeaver.model.runtime.VoidProgressMonitor
;
import
org.jkiss.dbeaver.model.struct.DBSObject
;
import
org.jkiss.dbeaver.ui.editors.StringEditorInput
;
import
org.jkiss.dbeaver.ui.editors.sql.SQLEditorBase
;
import
org.jkiss.dbeaver.ui.editors.text.BaseTextDocumentProvider
;
public
class
DatabaseScriptEditor
extends
SQLEditorBase
{
static
protected
final
Log
log
=
Log
.
getLog
(
DatabaseScriptEditor
.
class
);
private
final
DBCExecutionContext
executionContext
;
public
DatabaseScriptEditor
(
DBSObject
dbsObject
,
String
title
)
{
DBPDataSource
dataSource
=
dbsObject
.
getDataSource
();
DBCExecutionContext
isolatedContext
=
null
;
try
{
isolatedContext
=
dataSource
.
openIsolatedContext
(
new
VoidProgressMonitor
(),
title
);
}
catch
(
DBException
e
)
{
String
message
=
NLS
.
bind
(
"Unable to open execution context for {0}"
,
dbsObject
);
log
.
error
(
message
,
e
);
}
this
.
executionContext
=
isolatedContext
;
setDocumentProvider
(
new
BaseTextDocumentProvider
()
{
@Override
protected
void
doSaveDocument
(
IProgressMonitor
monitor
,
Object
element
,
IDocument
document
,
boolean
overwrite
)
throws
CoreException
{
//we are not going to save it
}
@Override
protected
IDocument
createDocument
(
Object
element
)
throws
CoreException
{
Document
document
=
new
Document
();
if
(
element
instanceof
StringEditorInput
)
{
StringEditorInput
stringInput
=
(
StringEditorInput
)
element
;
StringBuilder
buffer
=
stringInput
.
getBuffer
();
document
.
set
(
buffer
.
toString
());
}
else
{
document
.
set
(
title
);
}
return
document
;
}
@Override
public
boolean
isReadOnly
(
Object
element
)
{
return
false
;
}
@Override
public
boolean
isModifiable
(
Object
element
)
{
return
true
;
}
});
}
@Override
public
DBCExecutionContext
getExecutionContext
()
{
return
executionContext
;
}
@Override
public
void
dispose
()
{
if
(
executionContext
!=
null
)
{
executionContext
.
close
();
}
super
.
dispose
();
}
}
plugins/org.jkiss.dbeaver.ext.postgresql.debug.ui/src/org/jkiss/dbeaver/ext/postgresql/debug/ui/internal/PgSqlLocalLaunchShortcut.java
浏览文件 @
e6296004
...
...
@@ -22,9 +22,12 @@ import java.util.Map;
import
org.eclipse.core.runtime.CoreException
;
import
org.eclipse.debug.core.ILaunchConfiguration
;
import
org.eclipse.debug.core.ILaunchConfigurationWorkingCopy
;
import
org.eclipse.jface.dialogs.IDialogConstants
;
import
org.eclipse.ui.IWorkbenchPartSite
;
import
org.jkiss.dbeaver.debug.DBGController
;
import
org.jkiss.dbeaver.debug.core.DebugCore
;
import
org.jkiss.dbeaver.debug.ui.DatabaseLaunchShortcut
;
import
org.jkiss.dbeaver.debug.ui.DatabaseScriptDialog
;
import
org.jkiss.dbeaver.ext.postgresql.debug.core.PostgreSqlDebugCore
;
import
org.jkiss.dbeaver.model.struct.DBSObject
;
...
...
@@ -38,6 +41,20 @@ public class PgSqlLocalLaunchShortcut extends DatabaseLaunchShortcut {
protected
ILaunchConfiguration
createConfiguration
(
DBSObject
launchable
)
throws
CoreException
{
ILaunchConfigurationWorkingCopy
workingCopy
=
PostgreSqlDebugCore
.
createConfiguration
(
launchable
);
workingCopy
.
setAttribute
(
DebugCore
.
ATTR_ATTACH_KIND
,
DBGController
.
ATTACH_KIND_LOCAL
);
IWorkbenchPartSite
site
=
getWorkbenchPartSite
();
String
script
=
workingCopy
.
getAttribute
(
DebugCore
.
ATTR_SCRIPT_TEXT
,
DebugCore
.
ATTR_SCRIPT_TEXT_DEFAULT
);
String
inputName
=
"Script"
;
DatabaseScriptDialog
dialog
=
new
DatabaseScriptDialog
(
getShell
(),
site
,
inputName
,
script
,
launchable
);
dialog
.
create
();
dialog
.
setTitle
(
"Specify script to be executed"
);
dialog
.
setMessage
(
"Specify script to be executed to start debug."
);
int
open
=
dialog
.
open
();
if
(
IDialogConstants
.
CANCEL_ID
==
open
)
{
return
null
;
}
String
modified
=
dialog
.
getScriptTextValue
();
workingCopy
.
setAttribute
(
DebugCore
.
ATTR_SCRIPT_TEXT
,
modified
);
return
workingCopy
.
doSave
();
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录