Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
suliangchun
dbeaver
提交
0b395d82
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,发现更多精彩内容 >>
提交
0b395d82
编写于
4月 14, 2020
作者:
S
serge-rider
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
RSV presentation model refactoring
Former-commit-id:
329dedf5
上级
07564709
变更
14
隐藏空白更改
内联
并排
Showing
14 changed file
with
309 addition
and
121 deletion
+309
-121
plugins/org.jkiss.dbeaver.data.console/src/org/jkiss/dbeaver/data/console/ConsoleTextPresentation.java
...g/jkiss/dbeaver/data/console/ConsoleTextPresentation.java
+3
-6
plugins/org.jkiss.dbeaver.data.gis.view/src/org/jkiss/dbeaver/ui/gis/presentation/GeometryPresentation.java
...iss/dbeaver/ui/gis/presentation/GeometryPresentation.java
+2
-1
plugins/org.jkiss.dbeaver.ui.editors.data/src/org/jkiss/dbeaver/ui/controls/resultset/AbstractPresentation.java
...s/dbeaver/ui/controls/resultset/AbstractPresentation.java
+11
-27
plugins/org.jkiss.dbeaver.ui.editors.data/src/org/jkiss/dbeaver/ui/controls/resultset/IResultSetController.java
...s/dbeaver/ui/controls/resultset/IResultSetController.java
+3
-0
plugins/org.jkiss.dbeaver.ui.editors.data/src/org/jkiss/dbeaver/ui/controls/resultset/IResultSetDecorator.java
...ss/dbeaver/ui/controls/resultset/IResultSetDecorator.java
+10
-2
plugins/org.jkiss.dbeaver.ui.editors.data/src/org/jkiss/dbeaver/ui/controls/resultset/IResultSetLabelProvider.java
...beaver/ui/controls/resultset/IResultSetLabelProvider.java
+36
-0
plugins/org.jkiss.dbeaver.ui.editors.data/src/org/jkiss/dbeaver/ui/controls/resultset/ResultSetDecoratorBase.java
...dbeaver/ui/controls/resultset/ResultSetDecoratorBase.java
+8
-2
plugins/org.jkiss.dbeaver.ui.editors.data/src/org/jkiss/dbeaver/ui/controls/resultset/ResultSetLabelProviderDefault.java
.../ui/controls/resultset/ResultSetLabelProviderDefault.java
+119
-0
plugins/org.jkiss.dbeaver.ui.editors.data/src/org/jkiss/dbeaver/ui/controls/resultset/ResultSetLabelProviderEmpty.java
...er/ui/controls/resultset/ResultSetLabelProviderEmpty.java
+46
-0
plugins/org.jkiss.dbeaver.ui.editors.data/src/org/jkiss/dbeaver/ui/controls/resultset/ResultSetViewer.java
.../jkiss/dbeaver/ui/controls/resultset/ResultSetViewer.java
+48
-4
plugins/org.jkiss.dbeaver.ui.editors.data/src/org/jkiss/dbeaver/ui/controls/resultset/panel/grouping/GroupingResultsDecorator.java
...ls/resultset/panel/grouping/GroupingResultsDecorator.java
+3
-2
plugins/org.jkiss.dbeaver.ui.editors.data/src/org/jkiss/dbeaver/ui/controls/resultset/panel/references/ReferencesResultsDecorator.java
...esultset/panel/references/ReferencesResultsDecorator.java
+2
-1
plugins/org.jkiss.dbeaver.ui.editors.data/src/org/jkiss/dbeaver/ui/controls/resultset/plaintext/PlainTextPresentation.java
...i/controls/resultset/plaintext/PlainTextPresentation.java
+3
-6
plugins/org.jkiss.dbeaver.ui.editors.data/src/org/jkiss/dbeaver/ui/controls/resultset/spreadsheet/SpreadsheetPresentation.java
...ntrols/resultset/spreadsheet/SpreadsheetPresentation.java
+15
-70
未找到文件。
plugins/org.jkiss.dbeaver.data.console/src/org/jkiss/dbeaver/data/console/ConsoleTextPresentation.java
浏览文件 @
0b395d82
...
...
@@ -39,7 +39,6 @@ import org.eclipse.swt.widgets.Control;
import
org.eclipse.swt.widgets.ScrollBar
;
import
org.eclipse.swt.widgets.Shell
;
import
org.eclipse.ui.themes.ITheme
;
import
org.eclipse.ui.themes.IThemeManager
;
import
org.jkiss.code.NotNull
;
import
org.jkiss.code.Nullable
;
import
org.jkiss.dbeaver.model.DBConstants
;
...
...
@@ -123,7 +122,7 @@ public class ConsoleTextPresentation extends AbstractPresentation implements IAd
findReplaceTarget
=
new
StyledTextFindReplaceTarget
(
text
);
TextEditorUtils
.
enableHostEditorKeyBindingsSupport
(
controller
.
getSite
(),
text
);
applyThemeSettings
();
apply
Current
ThemeSettings
();
registerContextMenu
();
activateTextKeyBindings
(
controller
,
text
);
...
...
@@ -140,11 +139,9 @@ public class ConsoleTextPresentation extends AbstractPresentation implements IAd
}
@Override
protected
void
applyThemeSettings
()
{
IThemeManager
themeManager
=
controller
.
getSite
().
getWorkbenchWindow
().
getWorkbench
().
getThemeManager
();
curLineColor
=
themeManager
.
getCurrentTheme
().
getColorRegistry
().
get
(
ThemeConstants
.
COLOR_SQL_RESULT_CELL_ODD_BACK
);
protected
void
applyThemeSettings
(
ITheme
currentTheme
)
{
curLineColor
=
currentTheme
.
getColorRegistry
().
get
(
ThemeConstants
.
COLOR_SQL_RESULT_CELL_ODD_BACK
);
ITheme
currentTheme
=
themeManager
.
getCurrentTheme
();
Font
rsFont
=
currentTheme
.
getFontRegistry
().
get
(
ThemeConstants
.
FONT_SQL_RESULT_SET
);
if
(
rsFont
!=
null
)
{
int
fontHeight
=
rsFont
.
getFontData
()[
0
].
getHeight
();
...
...
plugins/org.jkiss.dbeaver.data.gis.view/src/org/jkiss/dbeaver/ui/gis/presentation/GeometryPresentation.java
浏览文件 @
0b395d82
...
...
@@ -25,6 +25,7 @@ import org.eclipse.swt.graphics.RGB;
import
org.eclipse.swt.layout.GridData
;
import
org.eclipse.swt.widgets.Composite
;
import
org.eclipse.swt.widgets.Display
;
import
org.eclipse.ui.themes.ITheme
;
import
org.jkiss.code.NotNull
;
import
org.jkiss.code.Nullable
;
import
org.jkiss.dbeaver.DBException
;
...
...
@@ -66,7 +67,7 @@ public class GeometryPresentation extends AbstractPresentation {
}
@Override
protected
void
applyThemeSettings
()
{
protected
void
applyThemeSettings
(
ITheme
currentTheme
)
{
}
@Override
...
...
plugins/org.jkiss.dbeaver.ui.editors.data/src/org/jkiss/dbeaver/ui/controls/resultset/AbstractPresentation.java
浏览文件 @
0b395d82
...
...
@@ -19,7 +19,6 @@ package org.jkiss.dbeaver.ui.controls.resultset;
import
org.eclipse.jface.action.IMenuManager
;
import
org.eclipse.jface.action.MenuManager
;
import
org.eclipse.jface.util.IPropertyChangeListener
;
import
org.eclipse.jface.viewers.*
;
import
org.eclipse.swt.SWT
;
import
org.eclipse.swt.events.FocusEvent
;
...
...
@@ -29,9 +28,10 @@ import org.eclipse.swt.widgets.Composite;
import
org.eclipse.swt.widgets.Control
;
import
org.eclipse.swt.widgets.Menu
;
import
org.eclipse.ui.IWorkbenchPartSite
;
import
org.eclipse.ui.PlatformUI
;
import
org.eclipse.ui.contexts.IContextActivation
;
import
org.eclipse.ui.contexts.IContextService
;
import
org.eclipse.ui.themes.ITheme
Manager
;
import
org.eclipse.ui.themes.ITheme
;
import
org.jkiss.code.NotNull
;
import
org.jkiss.dbeaver.model.data.DBDAttributeBinding
;
import
org.jkiss.dbeaver.ui.UIUtils
;
...
...
@@ -45,18 +45,17 @@ import java.util.List;
*/
public
abstract
class
AbstractPresentation
implements
IResultSetPresentation
,
ISelectionProvider
{
private
static
final
String
PRESENTATION_CONTROL_ID
=
"org.jkiss.dbeaver.ui.resultset.presentation"
;
public
static
final
String
RESULTS_CONTROL_CONTEXT_ID
=
"org.jkiss.dbeaver.ui.context.resultset.focused"
;
public
static
final
StructuredSelection
EMPTY_SELECTION
=
new
StructuredSelection
();
public
static
final
String
RESULT_SET_PRESENTATION_CONTEXT_MENU
=
"org.jkiss.dbeaver.ui.controls.resultset.conext.menu"
;
public
static
final
String
DATA_VALUE_CONTROLLER
=
"org.jkiss.dbeaver.resultset.value-controller"
;
private
static
final
String
RESULTS_CONTROL_CONTEXT_ID
=
"org.jkiss.dbeaver.ui.context.resultset.focused"
;
private
static
final
String
PRESENTATION_CONTROL_ID
=
"org.jkiss.dbeaver.ui.resultset.presentation"
;
private
static
final
StructuredSelection
EMPTY_SELECTION
=
new
StructuredSelection
();
@NotNull
protected
IResultSetController
controller
;
private
final
List
<
ISelectionChangedListener
>
selectionChangedListenerList
=
new
ArrayList
<>();
protected
IThemeManager
themeManager
;
private
IPropertyChangeListener
themeChangeListener
;
private
long
lastThemeUpdateTime
;
@Override
@NotNull
...
...
@@ -81,32 +80,17 @@ public abstract class AbstractPresentation implements IResultSetPresentation, IS
@Override
public
void
createPresentation
(
@NotNull
final
IResultSetController
controller
,
@NotNull
Composite
parent
)
{
this
.
controller
=
controller
;
}
this
.
themeManager
=
controller
.
getSite
().
getWorkbenchWindow
().
getWorkbench
().
getThemeManager
();
this
.
themeChangeListener
=
event
->
{
if
(
event
.
getProperty
().
equals
(
IThemeManager
.
CHANGE_CURRENT_THEME
)
||
event
.
getProperty
().
startsWith
(
ThemeConstants
.
RESULTS_PROP_PREFIX
))
{
if
(
lastThemeUpdateTime
>
0
&&
System
.
currentTimeMillis
()
-
lastThemeUpdateTime
<
500
)
{
// Do not update too often (theme change may trigger this hundreds of times)
return
;
}
lastThemeUpdateTime
=
System
.
currentTimeMillis
();
UIUtils
.
asyncExec
(
this
::
applyThemeSettings
);
}
};
this
.
themeManager
.
addPropertyChangeListener
(
themeChangeListener
);
protected
void
applyCurrentThemeSettings
()
{
applyThemeSettings
(
PlatformUI
.
getWorkbench
().
getThemeManager
().
getCurrentTheme
());
}
@Override
public
void
dispose
()
{
if
(
themeChangeListener
!=
null
)
{
themeManager
.
removePropertyChangeListener
(
themeChangeListener
);
themeChangeListener
=
null
;
}
}
protected
void
applyThemeSettings
()
{
protected
void
applyThemeSettings
(
ITheme
currentTheme
)
{
}
...
...
plugins/org.jkiss.dbeaver.ui.editors.data/src/org/jkiss/dbeaver/ui/controls/resultset/IResultSetController.java
浏览文件 @
0b395d82
...
...
@@ -61,6 +61,9 @@ public interface IResultSetController extends IDataController, DBPContextProvide
@NotNull
IResultSetDecorator
getDecorator
();
@NotNull
IResultSetLabelProvider
getLabelProvider
();
@NotNull
ResultSetModel
getModel
();
...
...
plugins/org.jkiss.dbeaver.ui.editors.data/src/org/jkiss/dbeaver/ui/controls/resultset/IResultSetDecorator.java
浏览文件 @
0b395d82
...
...
@@ -18,6 +18,8 @@
package
org.jkiss.dbeaver.ui.controls.resultset
;
import
org.eclipse.jface.action.IContributionManager
;
import
org.jkiss.code.NotNull
;
import
org.jkiss.code.Nullable
;
/**
* ResultSet decorator.
...
...
@@ -37,18 +39,24 @@ public interface IResultSetDecorator {
* Primary presentation ID.
* @return presentation ID or null.
*/
@Nullable
String
getPreferredPresentation
();
@Nullable
String
getEmptyDataMessage
();
@Nullable
String
getEmptyDataDescription
();
IResultSetLabelProvider
getDataLabelProvider
();
/**
* Fill additional menu actions
*/
void
fillContributions
(
IContributionManager
contributionManager
);
void
fillContributions
(
@NotNull
IContributionManager
contributionManager
);
void
registerDragAndDrop
(
IResultSetPresentation
presentation
);
void
registerDragAndDrop
(
@NotNull
IResultSetPresentation
presentation
);
@Nullable
Boolean
getAutoRecordMode
();
}
plugins/org.jkiss.dbeaver.ui.editors.data/src/org/jkiss/dbeaver/ui/controls/resultset/IResultSetLabelProvider.java
0 → 100644
浏览文件 @
0b395d82
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2020 DBeaver Corp and others
*
* 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.controls.resultset
;
import
org.eclipse.swt.graphics.Color
;
import
org.jkiss.code.Nullable
;
import
org.jkiss.dbeaver.model.DBPImage
;
import
org.jkiss.dbeaver.model.data.DBDAttributeBinding
;
public
interface
IResultSetLabelProvider
{
@Nullable
DBPImage
getCellImage
(
DBDAttributeBinding
attribute
,
ResultSetRow
row
);
@Nullable
Color
getCellForeground
(
DBDAttributeBinding
attribute
,
ResultSetRow
row
);
@Nullable
Color
getCellBackground
(
DBDAttributeBinding
attribute
,
ResultSetRow
row
);
}
plugins/org.jkiss.dbeaver.ui.editors.data/src/org/jkiss/dbeaver/ui/controls/resultset/ResultSetDecoratorBase.java
浏览文件 @
0b395d82
...
...
@@ -18,6 +18,7 @@
package
org.jkiss.dbeaver.ui.controls.resultset
;
import
org.eclipse.jface.action.IContributionManager
;
import
org.jkiss.code.NotNull
;
/**
* ResultSet decorator.
...
...
@@ -34,12 +35,17 @@ public abstract class ResultSetDecoratorBase implements IResultSetDecorator {
}
@Override
public
void
fillContributions
(
IContributionManager
contributionManager
)
{
public
IResultSetLabelProvider
getDataLabelProvider
()
{
return
null
;
}
@Override
public
void
fillContributions
(
@NotNull
IContributionManager
contributionManager
)
{
}
@Override
public
void
registerDragAndDrop
(
IResultSetPresentation
presentation
)
{
public
void
registerDragAndDrop
(
@NotNull
IResultSetPresentation
presentation
)
{
}
...
...
plugins/org.jkiss.dbeaver.ui.editors.data/src/org/jkiss/dbeaver/ui/controls/resultset/ResultSetLabelProviderDefault.java
0 → 100644
浏览文件 @
0b395d82
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2020 DBeaver Corp and others
*
* 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.controls.resultset
;
import
org.eclipse.jface.resource.ColorRegistry
;
import
org.eclipse.swt.graphics.Color
;
import
org.eclipse.ui.themes.ITheme
;
import
org.jkiss.code.Nullable
;
import
org.jkiss.dbeaver.model.DBPDataKind
;
import
org.jkiss.dbeaver.model.DBPImage
;
import
org.jkiss.dbeaver.model.DBUtils
;
import
org.jkiss.dbeaver.model.data.DBDAttributeBinding
;
import
org.jkiss.dbeaver.model.impl.data.DBDValueError
;
import
java.util.IdentityHashMap
;
import
java.util.Map
;
public
class
ResultSetLabelProviderDefault
implements
IResultSetLabelProvider
{
private
final
ResultSetViewer
viewer
;
private
Color
foregroundNull
;
private
final
Map
<
DBPDataKind
,
Color
>
dataTypesForegrounds
=
new
IdentityHashMap
<>();
private
boolean
colorizeDataTypes
=
true
;
private
Color
backgroundError
;
public
ResultSetLabelProviderDefault
(
ResultSetViewer
viewer
)
{
this
.
viewer
=
viewer
;
}
@Nullable
@Override
public
DBPImage
getCellImage
(
DBDAttributeBinding
attribute
,
ResultSetRow
row
)
{
return
null
;
}
@Nullable
@Override
public
Color
getCellForeground
(
DBDAttributeBinding
attribute
,
ResultSetRow
row
)
{
if
(
row
.
colorInfo
!=
null
)
{
if
(
row
.
colorInfo
.
cellFgColors
!=
null
)
{
Color
cellFG
=
row
.
colorInfo
.
cellFgColors
[
attribute
.
getOrdinalPosition
()];
if
(
cellFG
!=
null
)
{
return
cellFG
;
}
}
if
(
row
.
colorInfo
.
rowForeground
!=
null
)
{
return
row
.
colorInfo
.
rowForeground
;
}
}
Object
value
=
viewer
.
getModel
().
getCellValue
(
attribute
,
row
);
if
(
DBUtils
.
isNullValue
(
value
))
{
return
foregroundNull
;
}
else
{
if
(
colorizeDataTypes
)
{
Color
color
=
dataTypesForegrounds
.
get
(
attribute
.
getDataKind
());
if
(
color
!=
null
)
{
return
color
;
}
}
return
null
;
}
}
@Nullable
@Override
public
Color
getCellBackground
(
DBDAttributeBinding
attribute
,
ResultSetRow
row
)
{
if
(
row
.
colorInfo
!=
null
)
{
if
(
row
.
colorInfo
.
cellBgColors
!=
null
)
{
Color
cellBG
=
row
.
colorInfo
.
cellBgColors
[
attribute
.
getOrdinalPosition
()];
if
(
cellBG
!=
null
)
{
return
cellBG
;
}
}
if
(
row
.
colorInfo
.
rowBackground
!=
null
)
{
return
row
.
colorInfo
.
rowBackground
;
}
}
Object
value
=
viewer
.
getModel
().
getCellValue
(
attribute
,
row
);
if
(
value
!=
null
&&
value
.
getClass
()
==
DBDValueError
.
class
)
{
return
backgroundError
;
}
return
null
;
}
protected
void
applyThemeSettings
(
ITheme
currentTheme
)
{
this
.
colorizeDataTypes
=
viewer
.
getPreferenceStore
().
getBoolean
(
ResultSetPreferences
.
RESULT_SET_COLORIZE_DATA_TYPES
);
final
ColorRegistry
colorRegistry
=
currentTheme
.
getColorRegistry
();
this
.
foregroundNull
=
colorRegistry
.
get
(
ThemeConstants
.
COLOR_SQL_RESULT_NULL_FOREGROUND
);
this
.
backgroundError
=
colorRegistry
.
get
(
ThemeConstants
.
COLOR_SQL_RESULT_CELL_ERROR_BACK
);
this
.
dataTypesForegrounds
.
put
(
DBPDataKind
.
BINARY
,
colorRegistry
.
get
(
ThemeConstants
.
COLOR_SQL_RESULT_BINARY_FOREGROUND
));
this
.
dataTypesForegrounds
.
put
(
DBPDataKind
.
BOOLEAN
,
colorRegistry
.
get
(
ThemeConstants
.
COLOR_SQL_RESULT_BOOLEAN_FOREGROUND
));
this
.
dataTypesForegrounds
.
put
(
DBPDataKind
.
DATETIME
,
colorRegistry
.
get
(
ThemeConstants
.
COLOR_SQL_RESULT_DATETIME_FOREGROUND
));
this
.
dataTypesForegrounds
.
put
(
DBPDataKind
.
NUMERIC
,
colorRegistry
.
get
(
ThemeConstants
.
COLOR_SQL_RESULT_NUMERIC_FOREGROUND
));
this
.
dataTypesForegrounds
.
put
(
DBPDataKind
.
STRING
,
colorRegistry
.
get
(
ThemeConstants
.
COLOR_SQL_RESULT_STRING_FOREGROUND
));
}
}
plugins/org.jkiss.dbeaver.ui.editors.data/src/org/jkiss/dbeaver/ui/controls/resultset/ResultSetLabelProviderEmpty.java
0 → 100644
浏览文件 @
0b395d82
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2020 DBeaver Corp and others
*
* 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.controls.resultset
;
import
org.eclipse.swt.graphics.Color
;
import
org.jkiss.code.Nullable
;
import
org.jkiss.dbeaver.model.DBPImage
;
import
org.jkiss.dbeaver.model.data.DBDAttributeBinding
;
public
class
ResultSetLabelProviderEmpty
implements
IResultSetLabelProvider
{
public
static
final
ResultSetLabelProviderEmpty
INSTANCE
=
new
ResultSetLabelProviderEmpty
();
@Nullable
@Override
public
DBPImage
getCellImage
(
DBDAttributeBinding
attribute
,
ResultSetRow
row
)
{
return
null
;
}
@Nullable
@Override
public
Color
getCellForeground
(
DBDAttributeBinding
attribute
,
ResultSetRow
row
)
{
return
null
;
}
@Nullable
@Override
public
Color
getCellBackground
(
DBDAttributeBinding
attribute
,
ResultSetRow
row
)
{
return
null
;
}
}
plugins/org.jkiss.dbeaver.ui.editors.data/src/org/jkiss/dbeaver/ui/controls/resultset/ResultSetViewer.java
浏览文件 @
0b395d82
...
...
@@ -24,6 +24,7 @@ import org.eclipse.jface.action.*;
import
org.eclipse.jface.dialogs.IDialogConstants
;
import
org.eclipse.jface.dialogs.IDialogSettings
;
import
org.eclipse.jface.text.IFindReplaceTarget
;
import
org.eclipse.jface.util.IPropertyChangeListener
;
import
org.eclipse.jface.viewers.*
;
import
org.eclipse.osgi.util.NLS
;
import
org.eclipse.swt.SWT
;
...
...
@@ -41,15 +42,14 @@ import org.eclipse.swt.layout.GridLayout;
import
org.eclipse.swt.layout.RowData
;
import
org.eclipse.swt.layout.RowLayout
;
import
org.eclipse.swt.widgets.*
;
import
org.eclipse.ui.ISaveablePart2
;
import
org.eclipse.ui.IWorkbenchActionConstants
;
import
org.eclipse.ui.IWorkbenchCommandConstants
;
import
org.eclipse.ui.IWorkbenchPartSite
;
import
org.eclipse.ui.*
;
import
org.eclipse.ui.actions.CompoundContributionItem
;
import
org.eclipse.ui.menus.CommandContributionItem
;
import
org.eclipse.ui.menus.CommandContributionItemParameter
;
import
org.eclipse.ui.menus.IMenuService
;
import
org.eclipse.ui.texteditor.ITextEditorActionDefinitionIds
;
import
org.eclipse.ui.themes.ITheme
;
import
org.eclipse.ui.themes.IThemeManager
;
import
org.jkiss.code.NotNull
;
import
org.jkiss.code.Nullable
;
import
org.jkiss.dbeaver.DBException
;
...
...
@@ -153,6 +153,7 @@ public class ResultSetViewer extends Viewer
private
final
Composite
mainPanel
;
private
final
Composite
viewerPanel
;
private
final
IResultSetDecorator
decorator
;
private
final
ResultSetLabelProviderDefault
labelProviderDefault
;
@Nullable
private
ResultSetFilterPanel
filtersPanel
;
private
SashForm
viewerSash
;
...
...
@@ -217,6 +218,11 @@ public class ResultSetViewer extends Viewer
private
GC
sizingGC
;
private
VerticalButton
recordModeButton
;
// Theme listener
private
IPropertyChangeListener
themeChangeListener
;
private
long
lastThemeUpdateTime
;
public
ResultSetViewer
(
@NotNull
Composite
parent
,
@NotNull
IWorkbenchPartSite
site
,
@NotNull
IResultSetContainer
container
)
{
super
();
...
...
@@ -224,6 +230,7 @@ public class ResultSetViewer extends Viewer
this
.
site
=
site
;
this
.
recordMode
=
false
;
this
.
container
=
container
;
this
.
labelProviderDefault
=
new
ResultSetLabelProviderDefault
(
this
);
this
.
decorator
=
container
.
createResultSetDecorator
();
this
.
dataReceiver
=
new
ResultSetDataReceiver
(
this
);
this
.
dataPropertyListener
=
event
->
{
...
...
@@ -384,6 +391,26 @@ public class ResultSetViewer extends Viewer
}
// Listen property change
themeChangeListener
=
event
->
{
if
(
event
.
getProperty
().
equals
(
IThemeManager
.
CHANGE_CURRENT_THEME
)
||
event
.
getProperty
().
startsWith
(
ThemeConstants
.
RESULTS_PROP_PREFIX
))
{
if
(
lastThemeUpdateTime
>
0
&&
System
.
currentTimeMillis
()
-
lastThemeUpdateTime
<
500
)
{
// Do not update too often (theme change may trigger this hundreds of times)
return
;
}
lastThemeUpdateTime
=
System
.
currentTimeMillis
();
UIUtils
.
asyncExec
(()
->
{
ITheme
currentTheme
=
PlatformUI
.
getWorkbench
().
getThemeManager
().
getCurrentTheme
();
labelProviderDefault
.
applyThemeSettings
(
currentTheme
);
if
(
activePresentation
instanceof
AbstractPresentation
)
{
((
AbstractPresentation
)
activePresentation
).
applyThemeSettings
(
currentTheme
);
}
});
}
};
PlatformUI
.
getWorkbench
().
getThemeManager
().
addPropertyChangeListener
(
themeChangeListener
);
DBWorkbench
.
getPlatform
().
getPreferenceStore
().
addPropertyChangeListener
(
dataPropertyListener
);
DBWorkbench
.
getPlatform
().
getDataSourceProviderRegistry
().
getGlobalDataSourcePreferenceStore
().
addPropertyChangeListener
(
dataPropertyListener
);
}
...
...
@@ -409,6 +436,18 @@ public class ResultSetViewer extends Viewer
return
decorator
;
}
@NotNull
@Override
public
IResultSetLabelProvider
getLabelProvider
()
{
IResultSetLabelProvider
labelProvider
=
decorator
.
getDataLabelProvider
();
return
labelProvider
==
null
?
labelProviderDefault
:
labelProvider
;
}
@NotNull
public
IResultSetLabelProvider
getDefaultLabelProvider
()
{
return
labelProviderDefault
;
}
AutoRefreshControl
getAutoRefresh
()
{
return
autoRefreshControl
;
}
...
...
@@ -1691,6 +1730,11 @@ public class ResultSetViewer extends Viewer
private
void
dispose
()
{
if
(
themeChangeListener
!=
null
)
{
PlatformUI
.
getWorkbench
().
getThemeManager
().
removePropertyChangeListener
(
themeChangeListener
);
themeChangeListener
=
null
;
}
DBWorkbench
.
getPlatform
().
getDataSourceProviderRegistry
().
getGlobalDataSourcePreferenceStore
().
removePropertyChangeListener
(
dataPropertyListener
);
DBWorkbench
.
getPlatform
().
getPreferenceStore
().
removePropertyChangeListener
(
dataPropertyListener
);
...
...
plugins/org.jkiss.dbeaver.ui.editors.data/src/org/jkiss/dbeaver/ui/controls/resultset/panel/grouping/GroupingResultsDecorator.java
浏览文件 @
0b395d82
...
...
@@ -19,6 +19,7 @@ package org.jkiss.dbeaver.ui.controls.resultset.panel.grouping;
import
org.eclipse.jface.action.IContributionManager
;
import
org.eclipse.jface.dialogs.IDialogConstants
;
import
org.eclipse.swt.dnd.*
;
import
org.jkiss.code.NotNull
;
import
org.jkiss.dbeaver.DBException
;
import
org.jkiss.dbeaver.model.DBPDataSource
;
import
org.jkiss.dbeaver.model.DBPEvaluationContext
;
...
...
@@ -81,14 +82,14 @@ public class GroupingResultsDecorator extends ResultSetDecoratorBase {
}
@Override
public
void
fillContributions
(
IContributionManager
contributionManager
)
{
public
void
fillContributions
(
@NotNull
IContributionManager
contributionManager
)
{
contributionManager
.
add
(
new
GroupingPanel
.
EditColumnsAction
(
container
));
contributionManager
.
add
(
new
GroupingPanel
.
DeleteColumnAction
(
container
));
contributionManager
.
add
(
new
GroupingPanel
.
ClearGroupingAction
(
container
));
}
@Override
public
void
registerDragAndDrop
(
IResultSetPresentation
presentation
)
{
public
void
registerDragAndDrop
(
@NotNull
IResultSetPresentation
presentation
)
{
// Register drop target to accept columns dropping
Object
oldDropTarget
=
presentation
.
getControl
().
getData
(
DND
.
DROP_TARGET_KEY
);
if
(
oldDropTarget
instanceof
DropTarget
)
{
...
...
plugins/org.jkiss.dbeaver.ui.editors.data/src/org/jkiss/dbeaver/ui/controls/resultset/panel/references/ReferencesResultsDecorator.java
浏览文件 @
0b395d82
...
...
@@ -17,6 +17,7 @@
package
org.jkiss.dbeaver.ui.controls.resultset.panel.references
;
import
org.eclipse.jface.action.IContributionManager
;
import
org.jkiss.code.NotNull
;
import
org.jkiss.dbeaver.ui.controls.resultset.QueryResultsDecorator
;
/**
...
...
@@ -36,7 +37,7 @@ public class ReferencesResultsDecorator extends QueryResultsDecorator {
}
@Override
public
void
fillContributions
(
IContributionManager
contributionManager
)
{
public
void
fillContributions
(
@NotNull
IContributionManager
contributionManager
)
{
// contributionManager.add(new ReferencesPanel.EditColumnsAction(container));
// contributionManager.add(new ReferencesPanel.DeleteColumnAction(container));
// contributionManager.add(new ReferencesPanel.ClearGroupingAction(container));
...
...
plugins/org.jkiss.dbeaver.ui.editors.data/src/org/jkiss/dbeaver/ui/controls/resultset/plaintext/PlainTextPresentation.java
浏览文件 @
0b395d82
...
...
@@ -39,7 +39,6 @@ import org.eclipse.swt.widgets.Control;
import
org.eclipse.swt.widgets.ScrollBar
;
import
org.eclipse.swt.widgets.Shell
;
import
org.eclipse.ui.themes.ITheme
;
import
org.eclipse.ui.themes.IThemeManager
;
import
org.jkiss.code.NotNull
;
import
org.jkiss.code.Nullable
;
import
org.jkiss.dbeaver.ModelPreferences
;
...
...
@@ -124,7 +123,7 @@ public class PlainTextPresentation extends AbstractPresentation implements IAdap
findReplaceTarget
=
new
StyledTextFindReplaceTarget
(
text
);
TextEditorUtils
.
enableHostEditorKeyBindingsSupport
(
controller
.
getSite
(),
text
);
applyThemeSettings
();
apply
Current
ThemeSettings
();
registerContextMenu
();
activateTextKeyBindings
(
controller
,
text
);
...
...
@@ -141,11 +140,9 @@ public class PlainTextPresentation extends AbstractPresentation implements IAdap
}
@Override
protected
void
applyThemeSettings
()
{
IThemeManager
themeManager
=
controller
.
getSite
().
getWorkbenchWindow
().
getWorkbench
().
getThemeManager
();
curLineColor
=
themeManager
.
getCurrentTheme
().
getColorRegistry
().
get
(
ThemeConstants
.
COLOR_SQL_RESULT_CELL_ODD_BACK
);
protected
void
applyThemeSettings
(
ITheme
currentTheme
)
{
curLineColor
=
currentTheme
.
getColorRegistry
().
get
(
ThemeConstants
.
COLOR_SQL_RESULT_CELL_ODD_BACK
);
ITheme
currentTheme
=
themeManager
.
getCurrentTheme
();
Font
rsFont
=
currentTheme
.
getFontRegistry
().
get
(
ThemeConstants
.
FONT_SQL_RESULT_SET
);
if
(
rsFont
!=
null
)
{
int
fontHeight
=
rsFont
.
getFontData
()[
0
].
getHeight
();
...
...
plugins/org.jkiss.dbeaver.ui.editors.data/src/org/jkiss/dbeaver/ui/controls/resultset/spreadsheet/SpreadsheetPresentation.java
浏览文件 @
0b395d82
...
...
@@ -129,13 +129,10 @@ public class SpreadsheetPresentation extends AbstractPresentation implements IRe
private
Color
backgroundAdded
;
private
Color
backgroundDeleted
;
private
Color
backgroundModified
;
private
Color
backgroundError
;
private
Color
backgroundNormal
;
private
Color
backgroundOdd
;
private
Color
backgroundReadOnly
;
private
Color
foregroundDefault
;
private
Color
foregroundNull
;
private
final
Map
<
DBPDataKind
,
Color
>
dataTypesForegrounds
=
new
IdentityHashMap
<>();
private
Color
foregroundSelected
,
backgroundSelected
;
private
Color
backgroundMatched
;
private
Color
cellHeaderForeground
,
cellHeaderBackground
,
cellHeaderSelectionBackground
;
...
...
@@ -242,7 +239,7 @@ public class SpreadsheetPresentation extends AbstractPresentation implements IRe
activateTextKeyBindings
(
controller
,
spreadsheet
);
applyThemeSettings
();
apply
Current
ThemeSettings
();
trackPresentationControl
();
TextEditorUtils
.
enableHostEditorKeyBindingsSupport
(
controller
.
getSite
(),
spreadsheet
);
...
...
@@ -1125,9 +1122,8 @@ public class SpreadsheetPresentation extends AbstractPresentation implements IRe
// Themes
@Override
protected
void
applyThemeSettings
()
protected
void
applyThemeSettings
(
ITheme
currentTheme
)
{
ITheme
currentTheme
=
themeManager
.
getCurrentTheme
();
Font
rsFont
=
currentTheme
.
getFontRegistry
().
get
(
ThemeConstants
.
FONT_SQL_RESULT_SET
);
if
(
rsFont
!=
null
)
{
this
.
spreadsheet
.
setFont
(
rsFont
);
...
...
@@ -1144,7 +1140,6 @@ public class SpreadsheetPresentation extends AbstractPresentation implements IRe
this
.
backgroundAdded
=
colorRegistry
.
get
(
ThemeConstants
.
COLOR_SQL_RESULT_CELL_NEW_BACK
);
this
.
backgroundDeleted
=
colorRegistry
.
get
(
ThemeConstants
.
COLOR_SQL_RESULT_CELL_DELETED_BACK
);
this
.
backgroundModified
=
colorRegistry
.
get
(
ThemeConstants
.
COLOR_SQL_RESULT_CELL_MODIFIED_BACK
);
this
.
backgroundError
=
colorRegistry
.
get
(
ThemeConstants
.
COLOR_SQL_RESULT_CELL_ERROR_BACK
);
this
.
backgroundOdd
=
colorRegistry
.
get
(
ThemeConstants
.
COLOR_SQL_RESULT_CELL_ODD_BACK
);
this
.
backgroundReadOnly
=
colorRegistry
.
get
(
ThemeConstants
.
COLOR_SQL_RESULT_CELL_READ_ONLY
);
this
.
foregroundSelected
=
colorRegistry
.
get
(
ThemeConstants
.
COLOR_SQL_RESULT_SET_SELECTION_FORE
);
...
...
@@ -1165,14 +1160,6 @@ public class SpreadsheetPresentation extends AbstractPresentation implements IRe
50
);
this
.
cellHeaderSelectionBackground
=
new
Color
(
getSpreadsheet
().
getDisplay
(),
cellSel
);
}
this
.
foregroundNull
=
colorRegistry
.
get
(
ThemeConstants
.
COLOR_SQL_RESULT_NULL_FOREGROUND
);
this
.
dataTypesForegrounds
.
put
(
DBPDataKind
.
BINARY
,
colorRegistry
.
get
(
ThemeConstants
.
COLOR_SQL_RESULT_BINARY_FOREGROUND
));
this
.
dataTypesForegrounds
.
put
(
DBPDataKind
.
BOOLEAN
,
colorRegistry
.
get
(
ThemeConstants
.
COLOR_SQL_RESULT_BOOLEAN_FOREGROUND
));
this
.
dataTypesForegrounds
.
put
(
DBPDataKind
.
DATETIME
,
colorRegistry
.
get
(
ThemeConstants
.
COLOR_SQL_RESULT_DATETIME_FOREGROUND
));
this
.
dataTypesForegrounds
.
put
(
DBPDataKind
.
NUMERIC
,
colorRegistry
.
get
(
ThemeConstants
.
COLOR_SQL_RESULT_NUMERIC_FOREGROUND
));
this
.
dataTypesForegrounds
.
put
(
DBPDataKind
.
STRING
,
colorRegistry
.
get
(
ThemeConstants
.
COLOR_SQL_RESULT_STRING_FOREGROUND
));
this
.
spreadsheet
.
setLineColor
(
colorRegistry
.
get
(
ThemeConstants
.
COLOR_SQL_RESULT_LINES_NORMAL
));
this
.
spreadsheet
.
setLineSelectedColor
(
colorRegistry
.
get
(
ThemeConstants
.
COLOR_SQL_RESULT_LINES_SELECTED
));
...
...
@@ -1776,36 +1763,18 @@ public class SpreadsheetPresentation extends AbstractPresentation implements IRe
if
(
selected
)
{
return
foregroundSelected
;
}
ResultSetRow
row
=
(
ResultSetRow
)
(!
controller
.
isRecordMode
()
?
rowElement
:
colElement
);
if
(
row
.
colorInfo
!=
null
)
{
if
(
row
.
colorInfo
.
cellFgColors
!=
null
)
{
Color
cellFG
=
row
.
colorInfo
.
cellFgColors
[((
DBDAttributeBinding
)
(
rowElement
instanceof
DBDAttributeBinding
?
rowElement
:
colElement
)).
getOrdinalPosition
()];
if
(
cellFG
!=
null
)
{
return
cellFG
;
}
}
if
(
row
.
colorInfo
.
rowForeground
!=
null
)
{
return
row
.
colorInfo
.
rowForeground
;
}
}
boolean
recordMode
=
controller
.
isRecordMode
();
ResultSetRow
row
=
(
ResultSetRow
)
(!
recordMode
?
rowElement
:
colElement
);
DBDAttributeBinding
attribute
=
(
DBDAttributeBinding
)(!
recordMode
?
colElement
:
rowElement
);
Object
value
=
getCellValue
(
colElement
,
rowElement
,
false
,
false
);
if
(
DBUtils
.
isNullValue
(
value
))
{
return
foregroundNull
;
}
else
{
if
(
colorizeDataTypes
)
{
DBDAttributeBinding
attr
=
(
DBDAttributeBinding
)(
rowElement
instanceof
DBDAttributeBinding
?
rowElement
:
colElement
);
Color
color
=
dataTypesForegrounds
.
get
(
attr
.
getDataKind
());
if
(
color
!=
null
)
{
return
color
;
}
}
if
(
foregroundDefault
==
null
)
{
foregroundDefault
=
controller
.
getDefaultForeground
();
}
return
foregroundDefault
;
Color
fg
=
controller
.
getLabelProvider
().
getCellForeground
(
attribute
,
row
);
if
(
fg
!=
null
)
{
return
fg
;
}
if
(
foregroundDefault
==
null
)
{
foregroundDefault
=
controller
.
getDefaultForeground
();
}
return
foregroundDefault
;
}
@Nullable
...
...
@@ -1844,35 +1813,11 @@ public class SpreadsheetPresentation extends AbstractPresentation implements IRe
}
}
switch
(
row
.
getState
())
{
case
ResultSetRow
.
STATE_ADDED
:
return
backgroundAdded
;
case
ResultSetRow
.
STATE_REMOVED
:
return
backgroundDeleted
;
}
if
(
row
.
changes
!=
null
&&
row
.
changes
.
containsKey
(
attribute
))
{
return
backgroundModified
;
}
if
(
row
.
colorInfo
!=
null
)
{
if
(
row
.
colorInfo
.
cellBgColors
!=
null
)
{
Color
cellBG
=
row
.
colorInfo
.
cellBgColors
[((
DBDAttributeBinding
)
(
rowElement
instanceof
DBDAttributeBinding
?
rowElement
:
colElement
)).
getOrdinalPosition
()];
if
(
cellBG
!=
null
)
{
return
cellBG
;
}
}
if
(
row
.
colorInfo
.
rowBackground
!=
null
)
{
return
row
.
colorInfo
.
rowBackground
;
}
Color
bg
=
controller
.
getLabelProvider
().
getCellBackground
(
attribute
,
row
);
if
(
bg
!=
null
)
{
return
bg
;
}
Object
value
=
controller
.
getModel
().
getCellValue
(
attribute
,
row
);
if
(
value
!=
null
&&
value
.
getClass
()
==
DBDValueError
.
class
)
{
return
backgroundError
;
}
// if (attribute.getValueHandler() instanceof DBDValueHandlerComposite) {
// return backgroundReadOnly;
// }
if
(!
recordMode
&&
showOddRows
)
{
// Determine odd/even row
if
(
rowBatchSize
<
1
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录