Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
suliangchun
dbeaver
提交
2463495b
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,发现更多精彩内容 >>
提交
2463495b
编写于
6月 05, 2015
作者:
J
jurgen
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Properties model refactoring
Former-commit-id:
56379d5d
上级
747f97aa
变更
15
隐藏空白更改
内联
并排
Showing
15 changed file
with
156 addition
and
126 deletion
+156
-126
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/model/meta/Property.java
...eaver.core/src/org/jkiss/dbeaver/model/meta/Property.java
+0
-2
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/UIUtils.java
....jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/UIUtils.java
+64
-0
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/controls/ConnectionPropertiesControl.java
...kiss/dbeaver/ui/controls/ConnectionPropertiesControl.java
+1
-2
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/controls/itemlist/ItemListControl.java
...g/jkiss/dbeaver/ui/controls/itemlist/ItemListControl.java
+1
-1
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/editors/DatabaseEditorInput.java
...src/org/jkiss/dbeaver/ui/editors/DatabaseEditorInput.java
+2
-2
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/editors/IDatabaseEditorInput.java
...rc/org/jkiss/dbeaver/ui/editors/IDatabaseEditorInput.java
+2
-1
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/editors/entity/properties/FolderPageProperties.java
...er/ui/editors/entity/properties/FolderPageProperties.java
+2
-6
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/editors/entity/properties/PropertiesContributor.java
...r/ui/editors/entity/properties/PropertiesContributor.java
+0
-1
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/editors/sql/syntax/SQLCompletionProcessor.java
...dbeaver/ui/editors/sql/syntax/SQLCompletionProcessor.java
+1
-2
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/properties/ObjectAttributeDescriptor.java
...kiss/dbeaver/ui/properties/ObjectAttributeDescriptor.java
+7
-7
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/properties/ObjectPropertyDescriptor.java
...jkiss/dbeaver/ui/properties/ObjectPropertyDescriptor.java
+5
-77
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/properties/ObjectPropertyGroupDescriptor.java
.../dbeaver/ui/properties/ObjectPropertyGroupDescriptor.java
+2
-2
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/properties/PropertyDescriptorEx.java
...org/jkiss/dbeaver/ui/properties/PropertyDescriptorEx.java
+2
-1
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/properties/PropertySourceCollection.java
...jkiss/dbeaver/ui/properties/PropertySourceCollection.java
+49
-2
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/properties/PropertyTreeViewer.java
...c/org/jkiss/dbeaver/ui/properties/PropertyTreeViewer.java
+18
-20
未找到文件。
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/model/meta/Property.java
浏览文件 @
2463495b
...
...
@@ -99,8 +99,6 @@ public @interface Property
Class
<?
extends
IPropertyValueTransformer
>
valueTransformer
()
default
IPropertyValueTransformer
.
class
;
Class
<?
extends
IPropertyValueEditorProvider
>
valueEditor
()
default
IPropertyValueEditorProvider
.
class
;
Class
<?
extends
IPropertyValueListProvider
>
listProvider
()
default
IPropertyValueListProvider
.
class
;
}
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/UIUtils.java
浏览文件 @
2463495b
...
...
@@ -24,6 +24,7 @@ import org.eclipse.jface.commands.ActionHandler;
import
org.eclipse.jface.dialogs.IDialogConstants
;
import
org.eclipse.jface.dialogs.IDialogSettings
;
import
org.eclipse.jface.preference.PreferenceDialog
;
import
org.eclipse.jface.viewers.CellEditor
;
import
org.eclipse.jface.viewers.ISelectionProvider
;
import
org.eclipse.jface.window.IShellProvider
;
import
org.eclipse.swt.SWT
;
...
...
@@ -53,15 +54,24 @@ import org.jkiss.dbeaver.DBException;
import
org.jkiss.dbeaver.DBeaverConstants
;
import
org.jkiss.dbeaver.DBeaverPreferences
;
import
org.jkiss.dbeaver.core.*
;
import
org.jkiss.dbeaver.model.DBPNamedObject
;
import
org.jkiss.dbeaver.model.DBPPropertyDescriptor
;
import
org.jkiss.dbeaver.model.DBPPropertySource
;
import
org.jkiss.dbeaver.model.DBUtils
;
import
org.jkiss.dbeaver.model.runtime.DBRProgressMonitor
;
import
org.jkiss.dbeaver.runtime.RunnableWithResult
;
import
org.jkiss.dbeaver.runtime.RuntimeUtils
;
import
org.jkiss.dbeaver.ui.controls.CustomCheckboxCellEditor
;
import
org.jkiss.dbeaver.ui.controls.CustomComboBoxCellEditor
;
import
org.jkiss.dbeaver.ui.controls.CustomNumberCellEditor
;
import
org.jkiss.dbeaver.ui.controls.CustomTextCellEditor
;
import
org.jkiss.dbeaver.ui.dialogs.ConfirmationDialog
;
import
org.jkiss.dbeaver.ui.dialogs.StandardErrorDialog
;
import
org.jkiss.dbeaver.ui.editors.text.BaseTextEditor
;
import
org.jkiss.dbeaver.ui.properties.IPropertyValueListProvider
;
import
org.jkiss.dbeaver.utils.GeneralUtils
;
import
org.jkiss.utils.ArrayUtils
;
import
org.jkiss.utils.BeanUtils
;
import
org.jkiss.utils.CommonUtils
;
import
java.lang.reflect.InvocationTargetException
;
...
...
@@ -1221,6 +1231,60 @@ public class UIUtils {
return
saveRunner
.
getResult
();
}
public
static
CellEditor
createPropertyEditor
(
Composite
parent
,
DBPPropertySource
source
,
DBPPropertyDescriptor
property
)
{
if
(
source
==
null
)
{
return
null
;
}
final
Object
object
=
source
.
getEditableValue
();
if
(!
property
.
isEditable
(
object
))
{
return
null
;
}
return
UIUtils
.
createCellEditor
(
parent
,
object
,
property
);
}
public
static
CellEditor
createCellEditor
(
Composite
parent
,
Object
object
,
DBPPropertyDescriptor
property
)
{
// List
if
(
property
instanceof
IPropertyValueListProvider
)
{
final
IPropertyValueListProvider
listProvider
=
(
IPropertyValueListProvider
)
property
;
final
Object
[]
items
=
listProvider
.
getPossibleValues
(
object
);
if
(!
ArrayUtils
.
isEmpty
(
items
))
{
final
String
[]
strings
=
new
String
[
items
.
length
];
for
(
int
i
=
0
,
itemsLength
=
items
.
length
;
i
<
itemsLength
;
i
++)
{
strings
[
i
]
=
items
[
i
]
instanceof
DBPNamedObject
?
((
DBPNamedObject
)
items
[
i
]).
getName
()
:
CommonUtils
.
toString
(
items
[
i
]);
}
final
CustomComboBoxCellEditor
editor
=
new
CustomComboBoxCellEditor
(
parent
,
strings
,
SWT
.
DROP_DOWN
|
(
listProvider
.
allowCustomValue
()
?
SWT
.
NONE
:
SWT
.
READ_ONLY
));
return
editor
;
}
}
Class
<?>
propertyType
=
property
.
getDataType
();
if
(
propertyType
==
null
||
CharSequence
.
class
.
isAssignableFrom
(
propertyType
))
{
return
new
CustomTextCellEditor
(
parent
);
}
else
if
(
BeanUtils
.
isNumericType
(
propertyType
))
{
return
new
CustomNumberCellEditor
(
parent
,
propertyType
);
}
else
if
(
BeanUtils
.
isBooleanType
(
propertyType
))
{
return
new
CustomCheckboxCellEditor
(
parent
);
//return new CheckboxCellEditor(parent);
}
else
if
(
propertyType
.
isEnum
())
{
final
Object
[]
enumConstants
=
propertyType
.
getEnumConstants
();
final
String
[]
strings
=
new
String
[
enumConstants
.
length
];
for
(
int
i
=
0
,
itemsLength
=
enumConstants
.
length
;
i
<
itemsLength
;
i
++)
{
strings
[
i
]
=
((
Enum
)
enumConstants
[
i
]).
name
();
}
return
new
CustomComboBoxCellEditor
(
parent
,
strings
,
SWT
.
DROP_DOWN
|
SWT
.
READ_ONLY
);
}
else
{
log
.
warn
(
"Unsupported property type: "
+
propertyType
.
getName
());
return
null
;
}
}
private
static
class
SaveRunner
implements
Runnable
{
private
final
DBRProgressMonitor
monitor
;
private
final
ISaveablePart
saveable
;
...
...
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/controls/ConnectionPropertiesControl.java
浏览文件 @
2463495b
...
...
@@ -23,7 +23,6 @@ import org.eclipse.jface.action.Action;
import
org.eclipse.jface.action.IMenuManager
;
import
org.eclipse.jface.operation.IRunnableContext
;
import
org.eclipse.swt.widgets.Composite
;
import
org.eclipse.ui.views.properties.IPropertyDescriptor
;
import
org.jkiss.dbeaver.DBException
;
import
org.jkiss.dbeaver.core.CoreMessages
;
import
org.jkiss.dbeaver.model.DBConstants
;
...
...
@@ -91,7 +90,7 @@ public class ConnectionPropertiesControl extends PropertyTreeViewer {
}
@Override
protected
void
contributeContextMenu
(
IMenuManager
manager
,
final
Object
node
,
final
String
category
,
final
I
PropertyDescriptor
property
)
protected
void
contributeContextMenu
(
IMenuManager
manager
,
final
Object
node
,
final
String
category
,
final
DBP
PropertyDescriptor
property
)
{
boolean
isCustom
=
USER_PROPERTIES_CATEGORY
.
equals
(
category
);
if
(
isCustom
)
{
...
...
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/controls/itemlist/ItemListControl.java
浏览文件 @
2463495b
...
...
@@ -197,7 +197,7 @@ public class ItemListControl extends NodeListControl
setCurListObject
(
object
);
final
ObjectPropertyDescriptor
property
=
getObjectProperty
(
object
,
columnIndex
);
if
(
property
!=
null
&&
property
.
isEditable
(
getObjectValue
(
object
)))
{
return
property
.
createPropertyEditor
(
getControl
()
);
return
UIUtils
.
createPropertyEditor
(
getControl
(),
property
.
getSource
(),
property
);
}
return
null
;
}
...
...
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/editors/DatabaseEditorInput.java
浏览文件 @
2463495b
...
...
@@ -22,9 +22,9 @@ import org.eclipse.ui.IMemento;
import
org.eclipse.ui.IPersistableElement
;
import
org.eclipse.ui.model.IWorkbenchAdapter
;
import
org.eclipse.ui.model.WorkbenchAdapter
;
import
org.eclipse.ui.views.properties.IPropertySource2
;
import
org.jkiss.dbeaver.DBeaverPreferences
;
import
org.jkiss.dbeaver.core.DBeaverCore
;
import
org.jkiss.dbeaver.model.DBPPropertySource
;
import
org.jkiss.dbeaver.model.IDataSourceContainerProvider
;
import
org.jkiss.dbeaver.model.edit.DBECommandContext
;
import
org.jkiss.dbeaver.model.exec.DBCExecutionContext
;
...
...
@@ -193,7 +193,7 @@ public abstract class DatabaseEditorInput<NODE extends DBNDatabaseNode> implemen
}
@Override
public
IPropertySource2
getPropertySource
()
public
DBPPropertySource
getPropertySource
()
{
if
(
propertySource
==
null
)
{
propertySource
=
new
PropertySourceEditable
(
...
...
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/editors/IDatabaseEditorInput.java
浏览文件 @
2463495b
...
...
@@ -21,6 +21,7 @@ package org.jkiss.dbeaver.ui.editors;
import
org.eclipse.ui.IEditorInput
;
import
org.eclipse.ui.views.properties.IPropertySource2
;
import
org.jkiss.dbeaver.model.DBPContextProvider
;
import
org.jkiss.dbeaver.model.DBPPropertySource
;
import
org.jkiss.dbeaver.model.edit.DBECommandContext
;
import
org.jkiss.dbeaver.model.navigator.DBNDatabaseNode
;
import
org.jkiss.dbeaver.model.struct.DBSObject
;
...
...
@@ -58,7 +59,7 @@ public interface IDatabaseEditorInput extends IEditorInput, DBPContextProvider {
* Underlying object's property source
* @return property source
*/
IPropertySource2
getPropertySource
();
DBPPropertySource
getPropertySource
();
Collection
<
String
>
getAttributeNames
();
...
...
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/editors/entity/properties/FolderPageProperties.java
浏览文件 @
2463495b
...
...
@@ -26,11 +26,7 @@ import org.eclipse.swt.SWT;
import
org.eclipse.swt.graphics.Font
;
import
org.eclipse.swt.widgets.Composite
;
import
org.eclipse.ui.progress.UIJob
;
import
org.eclipse.ui.views.properties.IPropertySource
;
import
org.jkiss.dbeaver.model.DBPEvent
;
import
org.jkiss.dbeaver.model.DBPEventListener
;
import
org.jkiss.dbeaver.model.DBPPropertyDescriptor
;
import
org.jkiss.dbeaver.model.DBUtils
;
import
org.jkiss.dbeaver.model.*
;
import
org.jkiss.dbeaver.model.struct.DBSObject
;
import
org.jkiss.dbeaver.ui.UIUtils
;
import
org.jkiss.dbeaver.ui.controls.folders.FolderPage
;
...
...
@@ -47,7 +43,7 @@ public class FolderPageProperties extends FolderPage implements ILazyPropertyLoa
protected
PropertyTreeViewer
propertyTree
;
private
Font
boldFont
;
private
UIJob
refreshJob
=
null
;
private
I
PropertySource
curPropertySource
;
private
DBP
PropertySource
curPropertySource
;
public
FolderPageProperties
(
IDatabaseEditorInput
input
)
{
this
.
input
=
input
;
...
...
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/editors/entity/properties/PropertiesContributor.java
浏览文件 @
2463495b
...
...
@@ -18,7 +18,6 @@
package
org.jkiss.dbeaver.ui.editors.entity.properties
;
import
org.eclipse.ui.views.properties.IPropertyDescriptor
;
import
org.jkiss.dbeaver.core.CoreMessages
;
import
org.jkiss.dbeaver.model.DBPPropertyDescriptor
;
import
org.jkiss.dbeaver.ui.properties.ILazyPropertyLoadListener
;
...
...
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/editors/sql/syntax/SQLCompletionProcessor.java
浏览文件 @
2463495b
...
...
@@ -23,7 +23,6 @@ import org.eclipse.jface.text.ITextViewer;
import
org.eclipse.jface.text.TextPresentation
;
import
org.eclipse.jface.text.contentassist.*
;
import
org.eclipse.swt.graphics.Image
;
import
org.eclipse.ui.views.properties.IPropertyDescriptor
;
import
org.jkiss.code.Nullable
;
import
org.jkiss.dbeaver.DBException
;
import
org.jkiss.dbeaver.core.DBeaverCore
;
...
...
@@ -534,7 +533,7 @@ public class SQLCompletionProcessor implements IContentAssistProcessor
StringBuilder
info
=
new
StringBuilder
();
PropertyCollector
collector
=
new
PropertyCollector
(
object
,
false
);
collector
.
collectProperties
();
for
(
IPropertyDescriptor
descriptor
:
collector
.
getPropertyDescriptors
())
{
for
(
DBPPropertyDescriptor
descriptor
:
collector
.
getPropertyDescriptors2
())
{
Object
propValue
=
collector
.
getPropertyValue
(
descriptor
.
getId
());
if
(
propValue
==
null
)
{
continue
;
...
...
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/properties/ObjectAttributeDescriptor.java
浏览文件 @
2463495b
...
...
@@ -17,9 +17,9 @@
*/
package
org.jkiss.dbeaver.ui.properties
;
import
org.jkiss.dbeaver.core.Log
;
import
org.eclipse.jface.viewers.IFilter
;
import
org.eclipse.ui.views.properties.IPropertySource
;
import
org.jkiss.dbeaver.core.Log
;
import
org.jkiss.dbeaver.model.DBPPropertySource
;
import
org.jkiss.dbeaver.model.meta.IPropertyCacheValidator
;
import
org.jkiss.dbeaver.model.meta.LazyProperty
;
import
org.jkiss.dbeaver.model.meta.Property
;
...
...
@@ -41,7 +41,7 @@ public abstract class ObjectAttributeDescriptor {
static
final
Log
log
=
Log
.
getLog
(
ObjectAttributeDescriptor
.
class
);
private
final
I
PropertySource
source
;
private
final
DBP
PropertySource
source
;
private
ObjectPropertyGroupDescriptor
parent
;
private
int
orderNumber
;
private
String
id
;
...
...
@@ -51,7 +51,7 @@ public abstract class ObjectAttributeDescriptor {
private
Class
<?>
declaringClass
;
public
ObjectAttributeDescriptor
(
I
PropertySource
source
,
DBP
PropertySource
source
,
ObjectPropertyGroupDescriptor
parent
,
Method
getter
,
String
id
,
...
...
@@ -88,7 +88,7 @@ public abstract class ObjectAttributeDescriptor {
return
declaringClass
;
}
public
I
PropertySource
getSource
()
public
DBP
PropertySource
getSource
()
{
return
source
;
}
...
...
@@ -148,7 +148,7 @@ public abstract class ObjectAttributeDescriptor {
public
abstract
String
getDescription
();
public
static
List
<
ObjectPropertyDescriptor
>
extractAnnotations
(
I
PropertySource
source
,
DBP
PropertySource
source
,
Class
<?>
theClass
,
IFilter
filter
)
{
...
...
@@ -157,7 +157,7 @@ public abstract class ObjectAttributeDescriptor {
return
annoProps
;
}
static
void
extractAnnotations
(
I
PropertySource
source
,
ObjectPropertyGroupDescriptor
parent
,
Class
<?>
theClass
,
List
<
ObjectPropertyDescriptor
>
annoProps
,
IFilter
filter
)
static
void
extractAnnotations
(
DBP
PropertySource
source
,
ObjectPropertyGroupDescriptor
parent
,
Class
<?>
theClass
,
List
<
ObjectPropertyDescriptor
>
annoProps
,
IFilter
filter
)
{
Method
[]
methods
=
theClass
.
getMethods
();
for
(
Method
method
:
methods
)
{
...
...
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/properties/ObjectPropertyDescriptor.java
浏览文件 @
2463495b
...
...
@@ -22,26 +22,19 @@ import org.eclipse.jface.viewers.CellEditor;
import
org.eclipse.jface.viewers.IFontProvider
;
import
org.eclipse.jface.viewers.ILabelProvider
;
import
org.eclipse.jface.viewers.LabelProvider
;
import
org.eclipse.swt.SWT
;
import
org.eclipse.swt.graphics.Font
;
import
org.eclipse.swt.graphics.Image
;
import
org.eclipse.swt.widgets.Composite
;
import
org.eclipse.ui.views.properties.IPropertyDescriptor
;
import
org.eclipse.ui.views.properties.IPropertySource
;
import
org.jkiss.dbeaver.model.DBPNamedObject
;
import
org.jkiss.dbeaver.model.DBPPersistedObject
;
import
org.jkiss.dbeaver.model.DBPPropertyDescriptor
;
import
org.jkiss.dbeaver.model.
meta.IPropertyValueEditorProvider
;
import
org.jkiss.dbeaver.model.
DBPPropertySource
;
import
org.jkiss.dbeaver.model.meta.IPropertyValueTransformer
;
import
org.jkiss.dbeaver.model.meta.Property
;
import
org.jkiss.dbeaver.model.runtime.DBRProgressMonitor
;
import
org.jkiss.dbeaver.model.struct.DBSObject
;
import
org.jkiss.dbeaver.runtime.VoidProgressMonitor
;
import
org.jkiss.dbeaver.ui.controls.CustomCheckboxCellEditor
;
import
org.jkiss.dbeaver.ui.controls.CustomComboBoxCellEditor
;
import
org.jkiss.dbeaver.ui.controls.CustomNumberCellEditor
;
import
org.jkiss.dbeaver.ui.controls.CustomTextCellEditor
;
import
org.jkiss.utils.ArrayUtils
;
import
org.jkiss.dbeaver.ui.UIUtils
;
import
org.jkiss.utils.BeanUtils
;
import
org.jkiss.utils.CommonUtils
;
import
org.osgi.framework.Bundle
;
...
...
@@ -61,12 +54,11 @@ public class ObjectPropertyDescriptor extends ObjectAttributeDescriptor implemen
private
final
String
propDescription
;
private
Method
setter
;
private
ILabelProvider
labelProvider
;
private
IPropertyValueEditorProvider
valueEditor
;
private
IPropertyValueTransformer
valueTransformer
;
private
final
Class
<?>
declaringClass
;
public
ObjectPropertyDescriptor
(
I
PropertySource
source
,
DBP
PropertySource
source
,
ObjectPropertyGroupDescriptor
parent
,
Property
propInfo
,
Method
getter
)
...
...
@@ -99,16 +91,6 @@ public class ObjectPropertyDescriptor extends ObjectAttributeDescriptor implemen
this
.
labelProvider
=
new
DefaultLabelProvider
();
}
// Obtain value editor
Class
<?
extends
IPropertyValueEditorProvider
>
valueEditorClass
=
propInfo
.
valueEditor
();
if
(
valueEditorClass
!=
null
&&
valueEditorClass
!=
IPropertyValueEditorProvider
.
class
)
{
try
{
valueEditor
=
valueEditorClass
.
newInstance
();
}
catch
(
Throwable
e
)
{
log
.
warn
(
"Can't create value editor"
,
e
);
}
}
// Obtain value transformer
Class
<?
extends
IPropertyValueTransformer
>
valueTransformerClass
=
propInfo
.
valueTransformer
();
if
(
valueTransformerClass
!=
null
&&
valueTransformerClass
!=
IPropertyValueTransformer
.
class
)
{
...
...
@@ -159,25 +141,13 @@ public class ObjectPropertyDescriptor extends ObjectAttributeDescriptor implemen
@Override
public
CellEditor
createPropertyEditor
(
Composite
parent
)
{
IPropertySource
source
=
getSource
();
if
(
source
==
null
)
{
return
null
;
}
final
Object
object
=
source
.
getEditableValue
();
if
(!
isEditable
(
object
))
{
return
null
;
}
if
(
valueEditor
!=
null
)
{
return
valueEditor
.
createCellEditor
(
parent
,
object
,
propInfo
);
}
else
{
return
createCellEditor
(
parent
,
object
,
this
);
}
return
UIUtils
.
createPropertyEditor
(
parent
,
getSource
(),
this
);
}
@Override
public
boolean
isEditable
(
Object
object
)
{
final
I
PropertySource
propertySource
=
getSource
();
final
DBP
PropertySource
propertySource
=
getSource
();
if
(!(
propertySource
instanceof
IPropertySourceEditable
)
||
!((
IPropertySourceEditable
)
propertySource
).
isEditable
(
object
))
{
return
false
;
}
...
...
@@ -331,48 +301,6 @@ public class ObjectPropertyDescriptor extends ObjectAttributeDescriptor implemen
return
null
;
}
public
static
CellEditor
createCellEditor
(
Composite
parent
,
Object
object
,
DBPPropertyDescriptor
property
)
{
// List
if
(
property
instanceof
IPropertyValueListProvider
)
{
final
IPropertyValueListProvider
listProvider
=
(
IPropertyValueListProvider
)
property
;
final
Object
[]
items
=
listProvider
.
getPossibleValues
(
object
);
if
(!
ArrayUtils
.
isEmpty
(
items
))
{
final
String
[]
strings
=
new
String
[
items
.
length
];
for
(
int
i
=
0
,
itemsLength
=
items
.
length
;
i
<
itemsLength
;
i
++)
{
strings
[
i
]
=
items
[
i
]
instanceof
DBPNamedObject
?
((
DBPNamedObject
)
items
[
i
]).
getName
()
:
CommonUtils
.
toString
(
items
[
i
]);
}
final
CustomComboBoxCellEditor
editor
=
new
CustomComboBoxCellEditor
(
parent
,
strings
,
SWT
.
DROP_DOWN
|
(
listProvider
.
allowCustomValue
()
?
SWT
.
NONE
:
SWT
.
READ_ONLY
));
return
editor
;
}
}
Class
<?>
propertyType
=
property
.
getDataType
();
if
(
propertyType
==
null
||
CharSequence
.
class
.
isAssignableFrom
(
propertyType
))
{
return
new
CustomTextCellEditor
(
parent
);
}
else
if
(
BeanUtils
.
isNumericType
(
propertyType
))
{
return
new
CustomNumberCellEditor
(
parent
,
propertyType
);
}
else
if
(
BeanUtils
.
isBooleanType
(
propertyType
))
{
return
new
CustomCheckboxCellEditor
(
parent
);
//return new CheckboxCellEditor(parent);
}
else
if
(
propertyType
.
isEnum
())
{
final
Object
[]
enumConstants
=
propertyType
.
getEnumConstants
();
final
String
[]
strings
=
new
String
[
enumConstants
.
length
];
for
(
int
i
=
0
,
itemsLength
=
enumConstants
.
length
;
i
<
itemsLength
;
i
++)
{
strings
[
i
]
=
((
Enum
)
enumConstants
[
i
]).
name
();
}
return
new
CustomComboBoxCellEditor
(
parent
,
strings
,
SWT
.
DROP_DOWN
|
SWT
.
READ_ONLY
);
}
else
{
log
.
warn
(
"Unsupported property type: "
+
propertyType
.
getName
());
return
null
;
}
}
@Override
public
int
hashCode
()
{
...
...
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/properties/ObjectPropertyGroupDescriptor.java
浏览文件 @
2463495b
...
...
@@ -18,7 +18,7 @@
package
org.jkiss.dbeaver.ui.properties
;
import
org.eclipse.jface.viewers.IFilter
;
import
org.
eclipse.ui.views.properties.I
PropertySource
;
import
org.
jkiss.dbeaver.model.DBP
PropertySource
;
import
org.jkiss.dbeaver.model.meta.PropertyGroup
;
import
org.jkiss.dbeaver.model.runtime.DBRProgressMonitor
;
...
...
@@ -37,7 +37,7 @@ public class ObjectPropertyGroupDescriptor extends ObjectAttributeDescriptor
private
List
<
ObjectPropertyDescriptor
>
children
=
new
ArrayList
<
ObjectPropertyDescriptor
>();
public
ObjectPropertyGroupDescriptor
(
I
PropertySource
source
,
DBP
PropertySource
source
,
ObjectPropertyGroupDescriptor
parent
,
Method
getter
,
PropertyGroup
groupInfo
,
...
...
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/properties/PropertyDescriptorEx.java
浏览文件 @
2463495b
...
...
@@ -27,6 +27,7 @@ import org.eclipse.swt.widgets.Composite;
import
org.eclipse.ui.views.properties.IPropertyDescriptor
;
import
org.jkiss.dbeaver.model.DBPPropertyDescriptor
;
import
org.jkiss.dbeaver.runtime.RuntimeUtils
;
import
org.jkiss.dbeaver.ui.UIUtils
;
import
org.jkiss.utils.ArrayUtils
;
import
org.jkiss.utils.CommonUtils
;
...
...
@@ -126,7 +127,7 @@ public class PropertyDescriptorEx implements DBPPropertyDescriptor, IPropertyDes
if
(!
editable
)
{
return
null
;
}
return
ObjectPropertyDescriptor
.
createCellEditor
(
parent
,
null
,
this
);
return
UIUtils
.
createCellEditor
(
parent
,
null
,
this
);
}
@Nullable
...
...
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/properties/PropertySourceCollection.java
浏览文件 @
2463495b
...
...
@@ -22,6 +22,8 @@ import org.eclipse.jface.viewers.ILabelProvider;
import
org.eclipse.swt.widgets.Composite
;
import
org.eclipse.ui.views.properties.IPropertyDescriptor
;
import
org.eclipse.ui.views.properties.IPropertySource
;
import
org.jkiss.dbeaver.model.DBPPropertyDescriptor
;
import
org.jkiss.dbeaver.model.DBPPropertySource
;
import
org.jkiss.dbeaver.model.DBUtils
;
import
java.util.ArrayList
;
...
...
@@ -31,7 +33,7 @@ import java.util.List;
/**
* Simple property source which store properties in map
*/
public
class
PropertySourceCollection
implements
IPropertySource
{
public
class
PropertySourceCollection
implements
DBPPropertySource
,
IPropertySource
{
private
List
<
IPropertyDescriptor
>
props
=
new
ArrayList
<
IPropertyDescriptor
>();
...
...
@@ -52,6 +54,11 @@ public class PropertySourceCollection implements IPropertySource {
return
this
;
}
@Override
public
DBPPropertyDescriptor
[]
getPropertyDescriptors2
()
{
return
props
.
toArray
(
new
DBPPropertyDescriptor
[
props
.
size
()]);
}
@Override
public
IPropertyDescriptor
[]
getPropertyDescriptors
()
{
...
...
@@ -70,18 +77,38 @@ public class PropertySourceCollection implements IPropertySource {
return
false
;
}
@Override
public
boolean
isPropertyResettable
(
Object
id
)
{
return
false
;
}
@Override
public
void
resetPropertyValue
(
Object
id
)
{
}
@Override
public
void
resetPropertyValueToDefault
(
Object
id
)
{
}
@Override
public
void
setPropertyValue
(
Object
id
,
Object
value
)
{
}
private
class
ItemPropertyDescriptor
implements
IPropertyDescriptor
{
@Override
public
boolean
isDirty
(
Object
id
)
{
return
false
;
}
@Override
public
boolean
hasDefaultValue
(
Object
id
)
{
return
false
;
}
private
class
ItemPropertyDescriptor
implements
DBPPropertyDescriptor
,
IPropertyDescriptor
{
private
Integer
id
;
private
Object
item
;
...
...
@@ -105,6 +132,26 @@ public class PropertySourceCollection implements IPropertySource {
return
null
;
}
@Override
public
Class
<?>
getDataType
()
{
return
Object
.
class
;
}
@Override
public
boolean
isRequired
()
{
return
false
;
}
@Override
public
Object
getDefaultValue
()
{
return
null
;
}
@Override
public
boolean
isEditable
(
Object
object
)
{
return
false
;
}
@Override
public
String
getDisplayName
()
{
return
DBUtils
.
getObjectShortName
(
item
);
...
...
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/properties/PropertyTreeViewer.java
浏览文件 @
2463495b
...
...
@@ -29,8 +29,6 @@ import org.eclipse.swt.graphics.Point;
import
org.eclipse.swt.layout.GridData
;
import
org.eclipse.swt.layout.GridLayout
;
import
org.eclipse.swt.widgets.*
;
import
org.eclipse.ui.views.properties.IPropertyDescriptor
;
import
org.eclipse.ui.views.properties.IPropertySource
;
import
org.eclipse.ui.views.properties.IPropertySource2
;
import
org.jkiss.dbeaver.core.CoreMessages
;
import
org.jkiss.dbeaver.core.DBeaverUI
;
...
...
@@ -64,7 +62,7 @@ public class PropertyTreeViewer extends TreeViewer {
//private Color colorBlue;
private
int
selectedColumn
=
-
1
;
private
CellEditor
curCellEditor
;
private
I
PropertyDescriptor
selectedProperty
;
private
DBP
PropertyDescriptor
selectedProperty
;
private
String
[]
customCategories
;
private
IBaseLabelProvider
extraLabelProvider
;
...
...
@@ -174,12 +172,12 @@ public class PropertyTreeViewer extends TreeViewer {
};
}
public
void
loadProperties
(
I
PropertySource
propertySource
)
public
void
loadProperties
(
DBP
PropertySource
propertySource
)
{
loadProperties
(
null
,
propertySource
);
}
protected
void
loadProperties
(
TreeNode
parent
,
I
PropertySource
propertySource
)
protected
void
loadProperties
(
TreeNode
parent
,
DBP
PropertySource
propertySource
)
{
// Make tree model
customCategories
=
getCustomCategories
();
...
...
@@ -209,11 +207,11 @@ public class PropertyTreeViewer extends TreeViewer {
UIUtils
.
packColumns
(
getTree
(),
true
,
new
float
[]{
0.5f
,
0.5f
});
}
private
Map
<
String
,
TreeNode
>
loadTreeNodes
(
TreeNode
parent
,
I
PropertySource
propertySource
)
private
Map
<
String
,
TreeNode
>
loadTreeNodes
(
TreeNode
parent
,
DBP
PropertySource
propertySource
)
{
Map
<
String
,
TreeNode
>
categories
=
new
LinkedHashMap
<
String
,
TreeNode
>();
final
IPropertyDescriptor
[]
props
=
propertySource
.
getPropertyDescriptors
();
for
(
I
PropertyDescriptor
prop
:
props
)
{
final
DBPPropertyDescriptor
[]
props
=
propertySource
.
getPropertyDescriptors2
();
for
(
DBP
PropertyDescriptor
prop
:
props
)
{
String
categoryName
=
prop
.
getCategory
();
if
(
CommonUtils
.
isEmpty
(
categoryName
))
{
categoryName
=
CATEGORY_GENERAL
;
...
...
@@ -225,7 +223,7 @@ public class PropertyTreeViewer extends TreeViewer {
}
TreeNode
propNode
=
new
TreeNode
(
category
,
propertySource
,
prop
);
// Load nested object's properties
if
(!(
propertySource
instanceof
IPropertySourceEditable
)
&&
prop
instanceof
DBPPropertyDescriptor
)
{
if
(!(
propertySource
instanceof
IPropertySourceEditable
))
{
Class
<?>
propType
=
((
DBPPropertyDescriptor
)
prop
).
getDataType
();
if
(
propType
!=
null
)
{
if
(
DBPObject
.
class
.
isAssignableFrom
(
propType
))
{
...
...
@@ -246,7 +244,7 @@ public class PropertyTreeViewer extends TreeViewer {
collection
=
(
Collection
<?>)
propertyValue
;
}
PropertySourceCollection
psc
=
new
PropertySourceCollection
(
collection
);
for
(
IPropertyDescriptor
pd
:
psc
.
getPropertyDescriptors
())
{
for
(
DBPPropertyDescriptor
pd
:
psc
.
getPropertyDescriptors2
())
{
TreeNode
itemNode
=
new
TreeNode
(
propNode
,
psc
,
pd
);
}
}
...
...
@@ -262,7 +260,7 @@ public class PropertyTreeViewer extends TreeViewer {
super
.
setInput
(
null
);
}
protected
void
addProperty
(
Object
node
,
I
PropertyDescriptor
property
)
protected
void
addProperty
(
Object
node
,
DBP
PropertyDescriptor
property
)
{
if
(
node
instanceof
TreeNode
)
{
TreeNode
treeNode
=
(
TreeNode
)
node
;
...
...
@@ -295,7 +293,7 @@ public class PropertyTreeViewer extends TreeViewer {
super
.
refresh
();
}
public
I
PropertyDescriptor
getSelectedProperty
()
public
DBP
PropertyDescriptor
getSelectedProperty
()
{
return
selectedProperty
;
}
...
...
@@ -385,7 +383,7 @@ public class PropertyTreeViewer extends TreeViewer {
if
(
prop
.
property
==
null
||
!
prop
.
isEditable
())
{
return
;
}
final
CellEditor
cellEditor
=
prop
.
property
.
createPropertyEditor
(
treeControl
);
final
CellEditor
cellEditor
=
UIUtils
.
createPropertyEditor
(
treeControl
,
prop
.
propertySource
,
prop
.
property
);
if
(
cellEditor
==
null
)
{
return
;
}
...
...
@@ -510,7 +508,7 @@ public class PropertyTreeViewer extends TreeViewer {
}
}
private
boolean
isCustomProperty
(
I
PropertyDescriptor
property
)
private
boolean
isCustomProperty
(
DBP
PropertyDescriptor
property
)
{
if
(
customCategories
!=
null
)
{
for
(
String
category
:
customCategories
)
{
...
...
@@ -527,7 +525,7 @@ public class PropertyTreeViewer extends TreeViewer {
return
null
;
}
protected
void
contributeContextMenu
(
IMenuManager
manager
,
Object
node
,
String
category
,
I
PropertyDescriptor
property
)
protected
void
contributeContextMenu
(
IMenuManager
manager
,
Object
node
,
String
category
,
DBP
PropertyDescriptor
property
)
{
}
...
...
@@ -584,12 +582,12 @@ public class PropertyTreeViewer extends TreeViewer {
private
static
class
TreeNode
{
final
TreeNode
parent
;
final
I
PropertySource
propertySource
;
final
I
PropertyDescriptor
property
;
final
DBP
PropertySource
propertySource
;
final
DBP
PropertyDescriptor
property
;
final
String
category
;
final
List
<
TreeNode
>
children
=
new
ArrayList
<
TreeNode
>();
private
TreeNode
(
TreeNode
parent
,
IPropertySource
propertySource
,
I
PropertyDescriptor
property
,
String
category
)
private
TreeNode
(
TreeNode
parent
,
DBPPropertySource
propertySource
,
DBP
PropertyDescriptor
property
,
String
category
)
{
this
.
parent
=
parent
;
this
.
propertySource
=
propertySource
;
...
...
@@ -600,12 +598,12 @@ public class PropertyTreeViewer extends TreeViewer {
}
}
private
TreeNode
(
TreeNode
parent
,
IPropertySource
propertySource
,
I
PropertyDescriptor
property
)
private
TreeNode
(
TreeNode
parent
,
DBPPropertySource
propertySource
,
DBP
PropertyDescriptor
property
)
{
this
(
parent
,
propertySource
,
property
,
null
);
}
private
TreeNode
(
TreeNode
parent
,
I
PropertySource
propertySource
,
String
category
)
private
TreeNode
(
TreeNode
parent
,
DBP
PropertySource
propertySource
,
String
category
)
{
this
(
parent
,
propertySource
,
null
,
category
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录