Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
suliangchun
dbeaver
提交
0726393b
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,发现更多精彩内容 >>
提交
0726393b
编写于
2月 18, 2017
作者:
S
Serge Rider
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Index create dialog: support ASC/DESC index column modifiers
上级
36338e8d
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
122 addition
and
15 deletion
+122
-15
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/editors/object/struct/AttributesSelectorPage.java
...aver/ui/editors/object/struct/AttributesSelectorPage.java
+70
-11
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/editors/object/struct/EditIndexPage.java
...jkiss/dbeaver/ui/editors/object/struct/EditIndexPage.java
+49
-3
plugins/org.jkiss.dbeaver.ext.mysql/src/org/jkiss/dbeaver/ext/mysql/edit/MySQLIndexManager.java
...c/org/jkiss/dbeaver/ext/mysql/edit/MySQLIndexManager.java
+3
-1
未找到文件。
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/editors/object/struct/AttributesSelectorPage.java
浏览文件 @
0726393b
...
...
@@ -36,6 +36,7 @@ import org.jkiss.dbeaver.model.struct.DBSEntity;
import
org.jkiss.dbeaver.model.struct.DBSEntityAttribute
;
import
org.jkiss.dbeaver.ui.DBeaverIcons
;
import
org.jkiss.dbeaver.ui.UIUtils
;
import
org.jkiss.dbeaver.ui.controls.CustomTableEditor
;
import
org.jkiss.utils.CommonUtils
;
import
java.lang.reflect.InvocationTargetException
;
...
...
@@ -52,19 +53,34 @@ public abstract class AttributesSelectorPage extends BaseObjectEditPage {
protected
DBSEntity
entity
;
protected
Table
columnsTable
;
protected
List
<
AttributeInfo
>
attributes
=
new
ArrayList
<>();
protected
Button
toggleButton
;
protected
Group
columnsGroup
;
pr
ivate
static
class
AttributeInfo
{
pr
otected
static
class
AttributeInfo
{
DBSEntityAttribute
attribute
;
int
position
;
Map
<
String
,
Object
>
properties
=
new
HashMap
<>();
public
AttributeInfo
(
DBSEntityAttribute
attribute
)
{
this
.
attribute
=
attribute
;
this
.
position
=
-
1
;
}
public
Object
getProperty
(
String
name
)
{
return
properties
.
get
(
name
);
}
public
void
setProperty
(
String
name
,
Object
value
)
{
properties
.
put
(
name
,
value
);
}
@Override
public
String
toString
()
{
return
attribute
.
getName
();
}
}
public
AttributesSelectorPage
(
...
...
@@ -75,6 +91,16 @@ public abstract class AttributesSelectorPage extends BaseObjectEditPage {
this
.
entity
=
entity
;
}
public
Map
<
String
,
Object
>
getAttributeProperties
(
DBSEntityAttribute
attr
)
{
for
(
AttributeInfo
attrInfo
:
attributes
)
{
if
(
attrInfo
.
attribute
==
attr
)
{
return
attrInfo
.
properties
;
}
}
return
Collections
.
emptyMap
();
}
@Override
protected
Composite
createPageContents
(
Composite
parent
)
{
final
Composite
panel
=
UIUtils
.
createPlaceholder
(
parent
,
1
);
...
...
@@ -111,14 +137,18 @@ public abstract class AttributesSelectorPage extends BaseObjectEditPage {
}
});
TableColumn
colName
=
UIUtils
.
createTableColumn
(
columnsTable
,
SWT
.
NONE
,
CoreMessages
.
dialog_struct_columns_select_column
);
colName
.
addListener
(
SWT
.
Selection
,
new
SortListener
(
0
));
TableColumn
colPosition
=
UIUtils
.
createTableColumn
(
columnsTable
,
SWT
.
CENTER
,
"#"
);
//$NON-NLS-1$
colPosition
.
addListener
(
SWT
.
Selection
,
new
SortListener
(
1
));
createAttributeColumns
(
columnsTable
);
TableColumn
colType
=
UIUtils
.
createTableColumn
(
columnsTable
,
SWT
.
RIGHT
,
"Type"
);
//$NON-NLS-1$
colType
.
addListener
(
SWT
.
Selection
,
new
SortListener
(
2
));
final
CustomTableEditor
tableEditor
=
new
CustomTableEditor
(
columnsTable
)
{
@Override
protected
Control
createEditor
(
Table
table
,
final
int
index
,
final
TableItem
item
)
{
return
createCellEditor
(
table
,
index
,
item
,
(
AttributeInfo
)
item
.
getData
());
}
@Override
protected
void
saveEditorValue
(
Control
control
,
int
index
,
TableItem
item
)
{
saveCellValue
(
control
,
index
,
item
,
(
AttributeInfo
)
item
.
getData
());
}
};
toggleButton
=
new
Button
(
columnsGroup
,
SWT
.
PUSH
);
toggleButton
.
setText
(
"Select All"
);
...
...
@@ -151,6 +181,37 @@ public abstract class AttributesSelectorPage extends BaseObjectEditPage {
});
}
protected
void
createAttributeColumns
(
Table
columnsTable
)
{
TableColumn
colName
=
UIUtils
.
createTableColumn
(
columnsTable
,
SWT
.
NONE
,
CoreMessages
.
dialog_struct_columns_select_column
);
colName
.
addListener
(
SWT
.
Selection
,
new
SortListener
(
0
));
TableColumn
colPosition
=
UIUtils
.
createTableColumn
(
columnsTable
,
SWT
.
CENTER
,
"#"
);
//$NON-NLS-1$
colPosition
.
addListener
(
SWT
.
Selection
,
new
SortListener
(
1
));
TableColumn
colType
=
UIUtils
.
createTableColumn
(
columnsTable
,
SWT
.
RIGHT
,
"Type"
);
//$NON-NLS-1$
colType
.
addListener
(
SWT
.
Selection
,
new
SortListener
(
2
));
}
protected
void
fillAttributeColumns
(
DBSEntityAttribute
attribute
,
AttributeInfo
attributeInfo
,
TableItem
columnItem
)
{
columnItem
.
setText
(
0
,
attribute
.
getName
());
columnItem
.
setText
(
1
,
String
.
valueOf
(
attribute
.
getOrdinalPosition
()));
columnItem
.
setText
(
2
,
attribute
.
getFullTypeName
());
}
protected
Control
createCellEditor
(
Table
table
,
int
index
,
TableItem
item
,
AttributeInfo
data
)
{
/*
final Text text = new Text(table, SWT.BORDER);
text.setText(item.getText(index));
text.selectAll();
return text;
*/
return
null
;
}
protected
void
saveCellValue
(
Control
control
,
int
index
,
TableItem
item
,
AttributeInfo
data
)
{
//item.setText(index, control.getText());
}
protected
void
fillAttributes
(
final
DBSEntity
entity
)
{
// Collect attributes
...
...
@@ -191,9 +252,7 @@ public abstract class AttributesSelectorPage extends BaseObjectEditPage {
if
(
attributeNode
!=
null
)
{
columnItem
.
setImage
(
0
,
DBeaverIcons
.
getImage
(
attributeNode
.
getNodeIcon
()));
}
columnItem
.
setText
(
0
,
attribute
.
getName
());
columnItem
.
setText
(
1
,
String
.
valueOf
(
attribute
.
getOrdinalPosition
()));
columnItem
.
setText
(
2
,
attribute
.
getFullTypeName
());
fillAttributeColumns
(
attribute
,
col
,
columnItem
);
columnItem
.
setData
(
col
);
if
(
isColumnSelected
(
attribute
))
{
columnItem
.
setChecked
(
true
);
...
...
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/editors/object/struct/EditIndexPage.java
浏览文件 @
0726393b
...
...
@@ -19,13 +19,13 @@ package org.jkiss.dbeaver.ui.editors.object.struct;
import
org.eclipse.core.runtime.Assert
;
import
org.eclipse.swt.SWT
;
import
org.eclipse.swt.custom.CCombo
;
import
org.eclipse.swt.events.SelectionAdapter
;
import
org.eclipse.swt.events.SelectionEvent
;
import
org.eclipse.swt.layout.GridData
;
import
org.eclipse.swt.widgets.Button
;
import
org.eclipse.swt.widgets.Combo
;
import
org.eclipse.swt.widgets.Composite
;
import
org.eclipse.swt.widgets.*
;
import
org.jkiss.dbeaver.core.CoreMessages
;
import
org.jkiss.dbeaver.model.struct.DBSEntityAttribute
;
import
org.jkiss.dbeaver.model.struct.rdb.DBSIndexType
;
import
org.jkiss.dbeaver.model.struct.rdb.DBSTable
;
import
org.jkiss.dbeaver.ui.UIUtils
;
...
...
@@ -42,6 +42,8 @@ import java.util.List;
*/
public
class
EditIndexPage
extends
AttributesSelectorPage
{
public
static
final
String
PROP_DESC
=
"desc"
;
private
List
<
DBSIndexType
>
indexTypes
;
private
DBSIndexType
selectedIndexType
;
private
boolean
unique
;
...
...
@@ -96,4 +98,48 @@ public class EditIndexPage extends AttributesSelectorPage {
public
boolean
isUnique
()
{
return
unique
;
}
@Override
protected
void
createAttributeColumns
(
Table
columnsTable
)
{
super
.
createAttributeColumns
(
columnsTable
);
TableColumn
colDesc
=
UIUtils
.
createTableColumn
(
columnsTable
,
SWT
.
NONE
,
"Order"
);
colDesc
.
setToolTipText
(
"Ascending/descending"
);
}
@Override
protected
void
fillAttributeColumns
(
DBSEntityAttribute
attribute
,
AttributeInfo
attributeInfo
,
TableItem
columnItem
)
{
super
.
fillAttributeColumns
(
attribute
,
attributeInfo
,
columnItem
);
boolean
isDesc
=
Boolean
.
TRUE
.
equals
(
attributeInfo
.
getProperty
(
PROP_DESC
));
columnItem
.
setText
(
3
,
isDesc
?
"DESC"
:
"ASC"
);
}
protected
Control
createCellEditor
(
Table
table
,
int
index
,
TableItem
item
,
AttributeInfo
attributeInfo
)
{
if
(
index
==
3
)
{
boolean
isDesc
=
Boolean
.
TRUE
.
equals
(
attributeInfo
.
getProperty
(
PROP_DESC
));
CCombo
combo
=
new
CCombo
(
table
,
SWT
.
DROP_DOWN
|
SWT
.
READ_ONLY
);
combo
.
add
(
"ASC"
);
combo
.
add
(
"DESC"
);
combo
.
select
(
isDesc
?
1
:
0
);
return
combo
;
}
/*
final Text text = new Text(table, SWT.BORDER);
text.setText(item.getText(index));
text.selectAll();
return text;
*/
return
null
;
}
protected
void
saveCellValue
(
Control
control
,
int
index
,
TableItem
item
,
AttributeInfo
attributeInfo
)
{
if
(
index
==
3
)
{
CCombo
combo
=
(
CCombo
)
control
;
boolean
isDesc
=
combo
.
getSelectionIndex
()
==
1
;
item
.
setText
(
index
,
isDesc
?
"DESC"
:
"ASC"
);
attributeInfo
.
setProperty
(
PROP_DESC
,
isDesc
);
}
}
}
plugins/org.jkiss.dbeaver.ext.mysql/src/org/jkiss/dbeaver/ext/mysql/edit/MySQLIndexManager.java
浏览文件 @
0726393b
...
...
@@ -32,6 +32,7 @@ import org.jkiss.dbeaver.ui.editors.object.struct.EditIndexPage;
import
org.jkiss.utils.CommonUtils
;
import
java.util.Collections
;
import
java.util.Map
;
/**
* MySQL index manager
...
...
@@ -72,6 +73,7 @@ public class MySQLIndexManager extends SQLIndexManager<MySQLTableIndex, MySQLTab
idxName
.
append
(
CommonUtils
.
escapeIdentifier
(
parent
.
getName
()));
int
colIndex
=
1
;
for
(
DBSEntityAttribute
tableColumn
:
editPage
.
getSelectedAttributes
())
{
final
Map
<
String
,
Object
>
attrProps
=
editPage
.
getAttributeProperties
(
tableColumn
);
if
(
colIndex
==
1
)
{
idxName
.
append
(
"_"
).
append
(
CommonUtils
.
escapeIdentifier
(
tableColumn
.
getName
()));
//$NON-NLS-1$
}
...
...
@@ -80,7 +82,7 @@ public class MySQLIndexManager extends SQLIndexManager<MySQLTableIndex, MySQLTab
index
,
(
MySQLTableColumn
)
tableColumn
,
colIndex
++,
true
,
!
Boolean
.
TRUE
.
equals
(
attrProps
.
get
(
EditIndexPage
.
PROP_DESC
))
,
false
,
null
));
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录