Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
suliangchun
dbeaver
提交
840f8a0f
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,发现更多精彩内容 >>
提交
840f8a0f
编写于
1月 26, 2013
作者:
J
jurgen
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Advanced copy options
上级
c51ea320
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
212 addition
and
55 deletion
+212
-55
docs/todo.txt
docs/todo.txt
+2
-0
plugins/org.jkiss.dbeaver.core/plugin.xml
plugins/org.jkiss.dbeaver.core/plugin.xml
+1
-1
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/controls/resultset/ResultSetCommandHandler.java
...beaver/ui/controls/resultset/ResultSetCommandHandler.java
+16
-12
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/controls/resultset/ResultSetCopySpecialHandler.java
...er/ui/controls/resultset/ResultSetCopySpecialHandler.java
+170
-0
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/controls/resultset/ResultSetViewer.java
.../jkiss/dbeaver/ui/controls/resultset/ResultSetViewer.java
+23
-4
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/controls/spreadsheet/SpreadsheetCopySpecialHandler.java
...i/controls/spreadsheet/SpreadsheetCopySpecialHandler.java
+0
-38
未找到文件。
docs/todo.txt
浏览文件 @
840f8a0f
...
...
@@ -21,4 +21,6 @@ Variable number of columns in RS (cassandra)
ADVANCED COPY DIALOG
generate sql
exclipse secure store
USE JDBC DRIVER API IN PLUGIN (HACK OSGI?)
\ No newline at end of file
plugins/org.jkiss.dbeaver.core/plugin.xml
浏览文件 @
840f8a0f
...
...
@@ -832,7 +832,7 @@
</with>
</enabledWhen>
</handler>
<handler
commandId=
"org.jkiss.dbeaver.core.edit.copy.special"
class=
"org.jkiss.dbeaver.ui.controls.resultset.ResultSetCo
mmand
Handler"
>
<handler
commandId=
"org.jkiss.dbeaver.core.edit.copy.special"
class=
"org.jkiss.dbeaver.ui.controls.resultset.ResultSetCo
pySpecial
Handler"
>
<activeWhen><reference
definitionId=
"org.jkiss.dbeaver.core.ui.spreadsheet.control"
/></activeWhen>
<enabledWhen>
<with
variable=
"activeFocusControl"
>
...
...
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/controls/resultset/ResultSetCommandHandler.java
浏览文件 @
840f8a0f
...
...
@@ -23,7 +23,6 @@ import org.eclipse.core.commands.ExecutionException;
import
org.eclipse.ui.IWorkbenchCommandConstants
;
import
org.eclipse.ui.texteditor.ITextEditorActionDefinitionIds
;
import
org.jkiss.dbeaver.model.data.DBDDisplayFormat
;
import
org.jkiss.dbeaver.ui.ICommandIds
;
import
org.jkiss.dbeaver.ui.controls.spreadsheet.Spreadsheet
;
import
org.jkiss.dbeaver.ui.controls.spreadsheet.SpreadsheetCommandHandler
;
...
...
@@ -48,15 +47,10 @@ public class ResultSetCommandHandler extends SpreadsheetCommandHandler {
@Override
public
Object
execute
(
ExecutionEvent
event
)
throws
ExecutionException
{
Spreadsheet
spreadsheet
=
getActiveSpreadsheet
(
event
);
if
(
spreadsheet
==
null
)
{
return
null
;
}
if
(!(
spreadsheet
.
getController
()
instanceof
ResultSetViewer
))
{
ResultSetViewer
resultSet
=
getResultSet
(
event
);
if
(
resultSet
==
null
)
{
return
null
;
}
ResultSetViewer
resultSet
=
(
ResultSetViewer
)
spreadsheet
.
getController
();
//ResultSetViewer.ResultSetMode resultSetMode = resultSet.getMode();
String
actionId
=
event
.
getCommand
().
getId
();
if
(
actionId
.
equals
(
IWorkbenchCommandConstants
.
FILE_REFRESH
))
{
resultSet
.
refresh
();
...
...
@@ -87,17 +81,27 @@ public class ResultSetCommandHandler extends SpreadsheetCommandHandler {
}
else
if
(
actionId
.
equals
(
CMD_REJECT_CHANGES
))
{
resultSet
.
rejectChanges
();
}
else
if
(
actionId
.
equals
(
IWorkbenchCommandConstants
.
EDIT_COPY
))
{
resultSet
.
copySelectionToClipboard
(
false
,
false
,
DBDDisplayFormat
.
EDIT
);
}
else
if
(
actionId
.
equals
(
ICommandIds
.
CMD_COPY_SPECIAL
))
{
resultSet
.
copySelectionToClipboard
(
true
,
false
,
DBDDisplayFormat
.
UI
);
resultSet
.
copySelectionToClipboard
(
false
,
false
,
false
,
null
,
DBDDisplayFormat
.
EDIT
);
}
else
if
(
actionId
.
equals
(
IWorkbenchCommandConstants
.
EDIT_PASTE
))
{
resultSet
.
pasteCellValue
();
}
else
if
(
actionId
.
equals
(
IWorkbenchCommandConstants
.
EDIT_CUT
))
{
resultSet
.
copySelectionToClipboard
(
false
,
true
,
DBDDisplayFormat
.
EDIT
);
resultSet
.
copySelectionToClipboard
(
false
,
false
,
true
,
null
,
DBDDisplayFormat
.
EDIT
);
}
return
null
;
}
protected
ResultSetViewer
getResultSet
(
ExecutionEvent
event
)
{
Spreadsheet
spreadsheet
=
getActiveSpreadsheet
(
event
);
if
(
spreadsheet
==
null
)
{
return
null
;
}
if
(!(
spreadsheet
.
getController
()
instanceof
ResultSetViewer
))
{
return
null
;
}
return
(
ResultSetViewer
)
spreadsheet
.
getController
();
}
}
\ No newline at end of file
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/controls/resultset/ResultSetCopySpecialHandler.java
0 → 100644
浏览文件 @
840f8a0f
/*
* Copyright (C) 2010-2012 Serge Rieder
* serge@jkiss.org
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package
org.jkiss.dbeaver.ui.controls.resultset
;
import
org.eclipse.core.commands.ExecutionEvent
;
import
org.eclipse.core.commands.ExecutionException
;
import
org.eclipse.jface.dialogs.Dialog
;
import
org.eclipse.jface.dialogs.IDialogConstants
;
import
org.eclipse.jface.dialogs.IDialogSettings
;
import
org.eclipse.swt.SWT
;
import
org.eclipse.swt.layout.GridData
;
import
org.eclipse.swt.layout.GridLayout
;
import
org.eclipse.swt.widgets.*
;
import
org.eclipse.ui.commands.IElementUpdater
;
import
org.eclipse.ui.handlers.HandlerUtil
;
import
org.eclipse.ui.menus.UIElement
;
import
org.jkiss.dbeaver.core.CoreMessages
;
import
org.jkiss.dbeaver.model.data.DBDDisplayFormat
;
import
org.jkiss.dbeaver.ui.ICommandIds
;
import
org.jkiss.dbeaver.ui.UIUtils
;
import
java.util.Map
;
/**
* Copy special handler
*/
public
class
ResultSetCopySpecialHandler
extends
ResultSetCommandHandler
implements
IElementUpdater
{
@Override
public
Object
execute
(
ExecutionEvent
event
)
throws
ExecutionException
{
ResultSetViewer
resultSet
=
getResultSet
(
event
);
if
(
resultSet
==
null
)
{
return
null
;
}
if
(
event
.
getCommand
().
getId
().
equals
(
ICommandIds
.
CMD_COPY_SPECIAL
))
{
ConfigDialog
configDialog
=
new
ConfigDialog
(
HandlerUtil
.
getActiveShell
(
event
));
if
(
configDialog
.
open
()
==
IDialogConstants
.
OK_ID
)
{
resultSet
.
copySelectionToClipboard
(
configDialog
.
copyHeader
,
configDialog
.
copyRows
,
false
,
configDialog
.
delimiter
,
configDialog
.
format
);
}
}
return
null
;
}
@Override
public
void
updateElement
(
UIElement
element
,
Map
parameters
)
{
element
.
setText
(
CoreMessages
.
actions_spreadsheet_copy_special
);
}
private
class
ConfigDialog
extends
Dialog
{
public
static
final
String
PARAM_COPY_HEADER
=
"copyHeader"
;
public
static
final
String
PARAM_COPY_ROWS
=
"copyRows"
;
public
static
final
String
PARAM_FORMAT
=
"format"
;
public
static
final
String
PARAM_DELIMITER
=
"delimiter"
;
private
final
IDialogSettings
settings
;
private
Button
copyHeaderCheck
;
private
Button
copyRowsCheck
;
private
Combo
formatCombo
;
private
Combo
delimCombo
;
private
boolean
copyHeader
=
true
;
private
boolean
copyRows
=
false
;
private
DBDDisplayFormat
format
=
DBDDisplayFormat
.
UI
;
private
String
delimiter
=
"\t"
;
protected
ConfigDialog
(
Shell
shell
)
{
super
(
shell
);
settings
=
UIUtils
.
getDialogSettings
(
"AdvanceCopySettings"
);
if
(
settings
.
get
(
PARAM_COPY_HEADER
)
!=
null
)
{
copyHeader
=
settings
.
getBoolean
(
PARAM_COPY_HEADER
);
}
if
(
settings
.
get
(
PARAM_COPY_ROWS
)
!=
null
)
{
copyRows
=
settings
.
getBoolean
(
"copyRows"
);
}
if
(
settings
.
get
(
PARAM_FORMAT
)
!=
null
)
{
format
=
DBDDisplayFormat
.
valueOf
(
settings
.
get
(
"format"
));
}
if
(
settings
.
get
(
PARAM_DELIMITER
)
!=
null
)
{
delimiter
=
settings
.
get
(
"delimiter"
);
}
}
@Override
protected
void
configureShell
(
Shell
newShell
)
{
super
.
configureShell
(
newShell
);
newShell
.
setText
(
"Options"
);
}
@Override
protected
Control
createDialogArea
(
Composite
parent
)
{
Composite
group
=
(
Composite
)
super
.
createDialogArea
(
parent
);
((
GridLayout
)
group
.
getLayout
()).
numColumns
=
2
;
copyHeaderCheck
=
UIUtils
.
createLabelCheckbox
(
group
,
"Copy header"
,
copyHeader
);
copyRowsCheck
=
UIUtils
.
createLabelCheckbox
(
group
,
"Copy row numbers"
,
copyRows
);
UIUtils
.
createControlLabel
(
group
,
"Format"
);
formatCombo
=
new
Combo
(
group
,
SWT
.
BORDER
|
SWT
.
DROP_DOWN
|
SWT
.
READ_ONLY
);
formatCombo
.
add
(
"Display (default)"
);
formatCombo
.
add
(
"Editable"
);
formatCombo
.
add
(
"Database native"
);
formatCombo
.
select
(
format
==
DBDDisplayFormat
.
UI
?
0
:
format
==
DBDDisplayFormat
.
EDIT
?
1
:
2
);
UIUtils
.
createControlLabel
(
group
,
"Delimiter"
);
delimCombo
=
new
Combo
(
group
,
SWT
.
BORDER
|
SWT
.
DROP_DOWN
);
delimCombo
.
setLayoutData
(
new
GridData
(
GridData
.
FILL_HORIZONTAL
));
delimCombo
.
add
(
"\t"
);
delimCombo
.
add
(
";"
);
delimCombo
.
add
(
","
);
if
(!
delimiter
.
equals
(
"\t"
)
&&
!
delimiter
.
equals
(
";"
)
&&
!
delimiter
.
equals
(
","
))
{
delimCombo
.
add
(
delimiter
);
}
String
[]
items
=
delimCombo
.
getItems
();
for
(
int
i
=
0
,
itemsLength
=
items
.
length
;
i
<
itemsLength
;
i
++)
{
String
delim
=
items
[
i
];
if
(
delim
.
equals
(
delimiter
))
{
delimCombo
.
select
(
i
);
break
;
}
}
return
group
;
}
@Override
protected
void
okPressed
()
{
copyHeader
=
copyHeaderCheck
.
getSelection
();
copyRows
=
copyRowsCheck
.
getSelection
();
switch
(
formatCombo
.
getSelectionIndex
())
{
case
0
:
format
=
DBDDisplayFormat
.
UI
;
break
;
case
1
:
format
=
DBDDisplayFormat
.
EDIT
;
break
;
case
2
:
format
=
DBDDisplayFormat
.
NATIVE
;
break
;
}
delimiter
=
delimCombo
.
getText
();
settings
.
put
(
PARAM_COPY_HEADER
,
copyHeader
);
settings
.
put
(
PARAM_COPY_ROWS
,
copyRows
);
settings
.
put
(
PARAM_FORMAT
,
format
.
name
());
settings
.
put
(
PARAM_DELIMITER
,
delimiter
);
super
.
okPressed
();
}
}
}
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/controls/resultset/ResultSetViewer.java
浏览文件 @
840f8a0f
...
...
@@ -1682,8 +1682,16 @@ public class ResultSetViewer extends Viewer implements IDataSourceProvider, ISpr
new
DataUpdater
().
rejectChanges
();
}
public
void
copySelectionToClipboard
(
boolean
copyHeader
,
boolean
cut
,
DBDDisplayFormat
format
)
public
void
copySelectionToClipboard
(
boolean
copyHeader
,
boolean
copyRowNumbers
,
boolean
cut
,
String
delimiter
,
DBDDisplayFormat
format
)
{
if
(
delimiter
==
null
)
{
delimiter
=
"\t"
;
}
String
lineSeparator
=
ContentUtils
.
getDefaultLineSeparator
();
List
<
Integer
>
colsSelected
=
new
ArrayList
<
Integer
>();
int
firstCol
=
Integer
.
MAX_VALUE
,
lastCol
=
Integer
.
MIN_VALUE
;
...
...
@@ -1703,17 +1711,25 @@ public class ResultSetViewer extends Viewer implements IDataSourceProvider, ISpr
colsSelected
.
add
(
pos
.
col
);
}
}
int
rowNumber
=
1
;
StringBuilder
tdt
=
new
StringBuilder
();
if
(
copyHeader
)
{
if
(
copyRowNumbers
)
{
tdt
.
append
(
"-"
);
}
for
(
int
colIndex
:
colsSelected
)
{
GridColumn
column
=
spreadsheet
.
getColumn
(
colIndex
);
if
(
tdt
.
length
()
>
0
)
{
tdt
.
append
(
'\t'
);
tdt
.
append
(
delimiter
);
}
tdt
.
append
(
column
.
getText
());
}
tdt
.
append
(
lineSeparator
);
}
if
(
copyRowNumbers
)
{
tdt
.
append
(
rowNumber
++).
append
(
delimiter
);
}
int
prevRow
=
firstRow
;
int
prevCol
=
firstCol
;
for
(
GridPos
pos
:
selection
)
{
...
...
@@ -1721,18 +1737,21 @@ public class ResultSetViewer extends Viewer implements IDataSourceProvider, ISpr
if
(
prevCol
<
lastCol
)
{
for
(
int
i
=
prevCol
;
i
<
lastCol
;
i
++)
{
if
(
colsSelected
.
contains
(
i
))
{
tdt
.
append
(
'\t'
);
tdt
.
append
(
delimiter
);
}
}
}
tdt
.
append
(
lineSeparator
);
if
(
copyRowNumbers
)
{
tdt
.
append
(
rowNumber
++).
append
(
delimiter
);
}
prevRow
=
pos
.
row
;
prevCol
=
firstCol
;
}
if
(
pos
.
col
>
prevCol
)
{
for
(
int
i
=
prevCol
;
i
<
pos
.
col
;
i
++)
{
if
(
colsSelected
.
contains
(
i
))
{
tdt
.
append
(
'\t'
);
tdt
.
append
(
delimiter
);
}
}
prevCol
=
pos
.
col
;
...
...
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/controls/spreadsheet/SpreadsheetCopySpecialHandler.java
已删除
100644 → 0
浏览文件 @
c51ea320
/*
* Copyright (C) 2010-2012 Serge Rieder
* serge@jkiss.org
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package
org.jkiss.dbeaver.ui.controls.spreadsheet
;
import
org.eclipse.ui.commands.IElementUpdater
;
import
org.eclipse.ui.menus.UIElement
;
import
org.jkiss.dbeaver.core.CoreMessages
;
import
java.util.Map
;
/**
* Standard command handler
*/
public
class
SpreadsheetCopySpecialHandler
extends
SpreadsheetCommandHandler
implements
IElementUpdater
{
@Override
public
void
updateElement
(
UIElement
element
,
Map
parameters
)
{
element
.
setText
(
CoreMessages
.
actions_spreadsheet_copy_special
);
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录