Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
suliangchun
dbeaver
提交
a3efe7ca
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,发现更多精彩内容 >>
提交
a3efe7ca
编写于
4月 23, 2017
作者:
S
Serge Rider
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Remove unformatted text action. Fix SQL editor "Edit" menu.
上级
255b04c7
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
2 addition
and
133 deletion
+2
-133
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/editors/sql/SQLEditorContributor.java
...rg/jkiss/dbeaver/ui/editors/sql/SQLEditorContributor.java
+1
-11
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/editors/sql/handlers/CopySourceCodeHandler.java
...beaver/ui/editors/sql/handlers/CopySourceCodeHandler.java
+1
-1
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/editors/sql/handlers/CopyUnformattedTextAction.java
...er/ui/editors/sql/handlers/CopyUnformattedTextAction.java
+0
-121
未找到文件。
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/editors/sql/SQLEditorContributor.java
浏览文件 @
a3efe7ca
...
...
@@ -22,15 +22,12 @@ import org.eclipse.ui.IEditorPart;
import
org.eclipse.ui.IWorkbenchActionConstants
;
import
org.eclipse.ui.IWorkbenchWindow
;
import
org.eclipse.ui.editors.text.TextEditorActionContributor
;
import
org.eclipse.ui.texteditor.BasicTextEditorActionContributor
;
import
org.eclipse.ui.texteditor.ITextEditorActionDefinitionIds
;
import
org.eclipse.ui.texteditor.RetargetTextEditorAction
;
import
org.jkiss.dbeaver.core.CoreCommands
;
import
org.jkiss.dbeaver.core.CoreMessages
;
import
org.jkiss.dbeaver.core.DBeaverActivator
;
import
org.jkiss.dbeaver.core.DBeaverUI
;
import
org.jkiss.dbeaver.ui.ActionUtils
;
import
org.jkiss.dbeaver.ui.editors.sql.handlers.CopyUnformattedTextAction
;
import
java.util.ResourceBundle
;
...
...
@@ -50,7 +47,6 @@ public class SQLEditorContributor extends TextEditorActionContributor
private
RetargetTextEditorAction
contentAssistTip
;
private
RetargetTextEditorAction
contentAssistInformation
;
private
RetargetTextEditorAction
contentFormatProposal
;
private
CopyUnformattedTextAction
copyUnformattedTextAction
;
public
SQLEditorContributor
()
{
...
...
@@ -83,8 +79,6 @@ public class SQLEditorContributor extends TextEditorActionContributor
contentAssistInformation
=
new
RetargetTextEditorAction
(
bundle
,
getActionResourcePrefix
(
ACTION_CONTENT_ASSIST_INFORMATION
));
contentAssistInformation
.
setActionDefinitionId
(
ITextEditorActionDefinitionIds
.
SHOW_INFORMATION
);
copyUnformattedTextAction
=
new
CopyUnformattedTextAction
();
}
@Override
...
...
@@ -115,7 +109,6 @@ public class SQLEditorContributor extends TextEditorActionContributor
contentAssistTip
.
setAction
(
getAction
(
activeEditorPart
,
ACTION_CONTENT_ASSIST_TIP
));
//$NON-NLS-1$
contentAssistInformation
.
setAction
(
getAction
(
activeEditorPart
,
ACTION_CONTENT_ASSIST_INFORMATION
));
//$NON-NLS-1$
contentFormatProposal
.
setAction
(
getAction
(
activeEditorPart
,
ACTION_CONTENT_FORMAT_PROPOSAL
));
//$NON-NLS-1$
copyUnformattedTextAction
.
setEditor
(
activeEditorPart
);
}
}
...
...
@@ -140,10 +133,7 @@ public class SQLEditorContributor extends TextEditorActionContributor
editMenu
.
add
(
contentAssistProposal
);
editMenu
.
add
(
contentAssistTip
);
editMenu
.
add
(
contentAssistInformation
);
MenuManager
formatMenu
=
new
MenuManager
(
CoreMessages
.
actions_menu_edit_ContentFormat
);
editMenu
.
add
(
formatMenu
);
formatMenu
.
add
(
contentFormatProposal
);
formatMenu
.
add
(
copyUnformattedTextAction
);
editMenu
.
add
(
contentFormatProposal
);
}
IMenuManager
navMenu
=
manager
.
findMenuUsingPath
(
IWorkbenchActionConstants
.
M_NAVIGATE
);
if
(
navMenu
!=
null
)
{
...
...
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/editors/sql/handlers/CopySourceCodeHandler.java
浏览文件 @
a3efe7ca
...
...
@@ -151,7 +151,7 @@ public class CopySourceCodeHandler extends AbstractHandler {
SashForm
sash
=
new
SashForm
(
previewPanel
,
SWT
.
VERTICAL
);
sash
.
setLayoutData
(
new
GridData
(
GridData
.
FILL_BOTH
));
createSQLPanel
(
sash
);
Composite
targetGroup
=
UIUtils
.
createPlaceholder
(
sash
,
1
);
Composite
targetGroup
=
UIUtils
.
createPlaceholder
(
sash
,
1
,
5
);
targetGroup
.
setLayoutData
(
new
GridData
(
GridData
.
FILL_BOTH
));
UIUtils
.
createControlLabel
(
targetGroup
,
"Result"
);
targetText
=
new
StyledText
(
targetGroup
,
SWT
.
BORDER
|
SWT
.
READ_ONLY
|
SWT
.
V_SCROLL
|
SWT
.
WRAP
);
...
...
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/editors/sql/handlers/CopyUnformattedTextAction.java
已删除
100644 → 0
浏览文件 @
255b04c7
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2017 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.sql.handlers
;
import
org.eclipse.jface.action.Action
;
import
org.eclipse.jface.text.BadLocationException
;
import
org.eclipse.jface.text.IDocument
;
import
org.eclipse.jface.text.ITextSelection
;
import
org.eclipse.jface.text.rules.IToken
;
import
org.eclipse.swt.dnd.TextTransfer
;
import
org.eclipse.swt.widgets.Display
;
import
org.jkiss.dbeaver.model.sql.SQLDialect
;
import
org.jkiss.dbeaver.ui.TextUtils
;
import
org.jkiss.dbeaver.ui.UIUtils
;
import
org.jkiss.dbeaver.ui.editors.sql.SQLEditorBase
;
import
org.jkiss.dbeaver.ui.editors.sql.syntax.SQLRuleManager
;
import
org.jkiss.dbeaver.ui.editors.sql.syntax.tokens.SQLCommentToken
;
import
org.jkiss.utils.Pair
;
/**
* CopyUnformattedTextAction
*/
public
class
CopyUnformattedTextAction
extends
Action
{
private
SQLEditorBase
sqlEditor
;
public
CopyUnformattedTextAction
()
{
super
(
"Copy Unformatted Text"
);
setToolTipText
(
"Copies unformatted text to clipboard"
);
}
@Override
public
void
run
()
{
if
(
sqlEditor
==
null
)
{
return
;
}
ITextSelection
selection
=
(
ITextSelection
)
sqlEditor
.
getSelectionProvider
().
getSelection
();
IDocument
document
=
sqlEditor
.
getDocumentProvider
().
getDocument
(
sqlEditor
.
getEditorInput
());
if
(
document
==
null
)
{
return
;
}
int
startPos
,
endPos
;
if
(
selection
.
getLength
()
>
1
)
{
startPos
=
selection
.
getOffset
();
endPos
=
startPos
+
selection
.
getLength
();
}
else
{
startPos
=
0
;
endPos
=
document
.
getLength
();
}
StringBuilder
result
=
new
StringBuilder
();
SQLRuleManager
ruleManager
=
sqlEditor
.
getRuleManager
();
SQLDialect
dialect
=
sqlEditor
.
getSyntaxManager
().
getDialect
();
ruleManager
.
setRange
(
document
,
startPos
,
endPos
-
startPos
);
String
[]
singleLineComments
=
dialect
.
getSingleLineComments
();
Pair
<
String
,
String
>
multiLineComments
=
dialect
.
getMultiLineComments
();
boolean
lastWhitespace
=
false
;
try
{
for
(;;)
{
IToken
token
=
ruleManager
.
nextToken
();
if
(
token
.
isEOF
())
{
break
;
}
int
tokenOffset
=
ruleManager
.
getTokenOffset
();
final
int
tokenLength
=
ruleManager
.
getTokenLength
();
if
(
token
.
isWhitespace
())
{
if
(!
lastWhitespace
)
{
result
.
append
(
' '
);
}
lastWhitespace
=
true
;
}
else
if
(
token
instanceof
SQLCommentToken
)
{
String
comment
=
document
.
get
(
tokenOffset
,
tokenLength
);
for
(
String
slc
:
singleLineComments
)
{
if
(
comment
.
startsWith
(
slc
))
{
if
(
multiLineComments
!=
null
)
{
comment
=
multiLineComments
.
getFirst
()
+
comment
.
substring
(
slc
.
length
())
+
multiLineComments
.
getSecond
();
}
break
;
}
}
comment
=
TextUtils
.
compactWhiteSpaces
(
comment
);
result
.
append
(
comment
);
}
else
{
lastWhitespace
=
false
;
result
.
append
(
document
.
get
(
tokenOffset
,
tokenLength
));
}
}
}
catch
(
BadLocationException
e
)
{
// dump
e
.
printStackTrace
();
}
UIUtils
.
setClipboardContents
(
Display
.
getCurrent
(),
TextTransfer
.
getInstance
(),
result
.
toString
().
trim
());
}
public
void
setEditor
(
SQLEditorBase
textEditor
)
{
setEnabled
(
textEditor
!=
null
);
this
.
sqlEditor
=
textEditor
;
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录