Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
suliangchun
dbeaver
提交
48a0b582
D
dbeaver
项目概览
suliangchun
/
dbeaver
与 Fork 源项目一致
从无法访问的项目Fork
通知
3
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,发现更多精彩内容 >>
提交
48a0b582
编写于
12月 21, 2019
作者:
S
Serge Rider
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
#7444 Task log page: use console
Former-commit-id:
631828d0
上级
3a002d52
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
56 addition
and
45 deletion
+56
-45
plugins/org.jkiss.dbeaver.tasks.native.ui/META-INF/MANIFEST.MF
...ns/org.jkiss.dbeaver.tasks.native.ui/META-INF/MANIFEST.MF
+1
-0
plugins/org.jkiss.dbeaver.tasks.native.ui/src/org/jkiss/dbeaver/tasks/ui/nativetool/ToolWizardPageLog.java
.../jkiss/dbeaver/tasks/ui/nativetool/ToolWizardPageLog.java
+55
-45
未找到文件。
plugins/org.jkiss.dbeaver.tasks.native.ui/META-INF/MANIFEST.MF
浏览文件 @
48a0b582
...
...
@@ -14,6 +14,7 @@ Require-Bundle: org.eclipse.core.runtime,
org.eclipse.jface,
org.eclipse.jface.text,
org.eclipse.ui,
org.eclipse.ui.console,
org.eclipse.ui.editors,
org.eclipse.ui.views,
org.eclipse.ui.workbench,
...
...
plugins/org.jkiss.dbeaver.tasks.native.ui/src/org/jkiss/dbeaver/tasks/ui/nativetool/ToolWizardPageLog.java
浏览文件 @
48a0b582
...
...
@@ -17,26 +17,36 @@
*/
package
org.jkiss.dbeaver.tasks.ui.nativetool
;
import
org.eclipse.jface.text.DocumentEvent
;
import
org.eclipse.jface.text.IDocument
;
import
org.eclipse.jface.text.IDocumentListener
;
import
org.eclipse.jface.wizard.WizardPage
;
import
org.eclipse.osgi.util.NLS
;
import
org.eclipse.swt.SWT
;
import
org.eclipse.swt.custom.StyleRange
;
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.ui.console.MessageConsole
;
import
org.eclipse.ui.console.TextConsoleViewer
;
import
org.jkiss.dbeaver.Log
;
import
org.jkiss.dbeaver.tasks.ui.nativetool.internal.TaskNativeUIMessages
;
import
org.jkiss.dbeaver.ui.UIUtils
;
import
org.jkiss.dbeaver.utils.GeneralUtils
;
import
java.io.*
;
import
java.nio.charset.StandardCharsets
;
import
java.util.Date
;
import
java.util.List
;
public
class
ToolWizardPageLog
extends
WizardPage
{
private
StyledText
dumpLogText
;
private
static
final
Log
log
=
Log
.
getLog
(
ToolWizardPageLog
.
class
);
private
TextConsoleViewer
consoleViewer
;
private
String
task
;
private
OutputStreamWriter
writer
;
private
MessageConsole
console
;
public
ToolWizardPageLog
(
String
task
)
{
...
...
@@ -55,32 +65,21 @@ public class ToolWizardPageLog extends WizardPage {
@Override
public
void
createControl
(
Composite
parent
)
{
Composite
composite
=
UIUtils
.
createPlaceholder
(
parent
,
1
);
Composite
composite
=
new
Composite
(
parent
,
SWT
.
BORDER
);
composite
.
setLayoutData
(
new
GridData
(
GridData
.
FILL_BOTH
));
composite
.
setLayout
(
new
FillLayout
());
console
=
new
MessageConsole
(
"tool-log-console"
,
null
);
consoleViewer
=
new
LogConsoleViewer
(
composite
);
console
.
setWaterMarks
(
1024
*
1024
*
3
,
1024
*
1024
*
4
);
dumpLogText
=
new
StyledText
(
composite
,
SWT
.
MULTI
|
SWT
.
READ_ONLY
|
SWT
.
V_SCROLL
|
SWT
.
H_SCROLL
|
SWT
.
BORDER
);
GridData
gd
=
new
GridData
(
GridData
.
FILL_BOTH
);
dumpLogText
.
setLayoutData
(
gd
);
writer
=
new
OutputStreamWriter
(
console
.
newMessageStream
(),
StandardCharsets
.
UTF_8
);
setControl
(
composite
);
}
public
Writer
getLogWriter
()
{
return
new
Writer
()
{
@Override
public
void
write
(
char
[]
cbuf
,
int
off
,
int
len
)
{
appendLog
(
new
String
(
cbuf
,
off
,
len
));
}
@Override
public
void
flush
()
{
}
@Override
public
void
close
()
{
}
};
return
writer
;
}
public
void
appendLog
(
final
String
line
)
...
...
@@ -93,24 +92,11 @@ public class ToolWizardPageLog extends WizardPage {
if
(
getShell
().
isDisposed
())
{
return
;
}
UIUtils
.
syncExec
(()
->
{
synchronized
(
ToolWizardPageLog
.
this
)
{
if
(!
dumpLogText
.
isDisposed
())
{
int
caretOffset
=
dumpLogText
.
getCaretOffset
();
dumpLogText
.
append
(
line
);
//dumpLogText.append(ContentUtils.getDefaultLineSeparator());
dumpLogText
.
setCaretOffset
(
dumpLogText
.
getCharCount
());
dumpLogText
.
showSelection
();
if
(
error
)
{
StyleRange
style1Range
=
new
StyleRange
();
style1Range
.
start
=
caretOffset
;
style1Range
.
length
=
line
.
length
();
style1Range
.
foreground
=
dumpLogText
.
getDisplay
().
getSystemColor
(
SWT
.
COLOR_RED
);
dumpLogText
.
setStyleRange
(
style1Range
);
}
}
}
});
try
{
writer
.
write
(
line
);
}
catch
(
IOException
e
)
{
log
.
debug
(
e
);
}
}
public
void
clearLog
()
...
...
@@ -120,9 +106,7 @@ public class ToolWizardPageLog extends WizardPage {
}
UIUtils
.
syncExec
(()
->
{
synchronized
(
ToolWizardPageLog
.
this
)
{
if
(!
dumpLogText
.
isDisposed
())
{
dumpLogText
.
setText
(
""
);
//$NON-NLS-1$
}
console
.
clearConsole
();
}
});
}
...
...
@@ -140,7 +124,7 @@ public class ToolWizardPageLog extends WizardPage {
private
class
LogReaderJob
extends
Thread
{
private
ProcessBuilder
processBuilder
;
private
InputStream
input
;
protected
LogReaderJob
(
ProcessBuilder
processBuilder
,
InputStream
stream
)
LogReaderJob
(
ProcessBuilder
processBuilder
,
InputStream
stream
)
{
super
(
NLS
.
bind
(
TaskNativeUIMessages
.
tools_wizard_page_log_task_log_reader
,
task
));
...
...
@@ -222,4 +206,30 @@ public class ToolWizardPageLog extends WizardPage {
}
}
private
class
LogConsoleViewer
extends
TextConsoleViewer
implements
IDocumentListener
{
LogConsoleViewer
(
Composite
composite
)
{
super
(
composite
,
ToolWizardPageLog
.
this
.
console
);
}
@Override
public
void
setDocument
(
IDocument
document
)
{
IDocument
oldDocument
=
getDocument
();
super
.
setDocument
(
document
);
if
(
oldDocument
!=
null
)
{
oldDocument
.
removeDocumentListener
(
this
);
}
if
(
document
!=
null
)
{
document
.
addDocumentListener
(
this
);
}
}
@Override
public
void
documentAboutToBeChanged
(
DocumentEvent
event
)
{
}
@Override
public
void
documentChanged
(
DocumentEvent
event
)
{
revealEndOfDocument
();
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录