Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
suliangchun
dbeaver
提交
4ebdd535
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,发现更多精彩内容 >>
提交
4ebdd535
编写于
3月 11, 2021
作者:
N
Nikita Akilov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
#10841 fix background color problems with notification popups
Former-commit-id:
49e0c58f
上级
c483fbdb
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
32 addition
and
232 deletion
+32
-232
plugins/org.jkiss.dbeaver.ui/src/org/jkiss/dbeaver/ui/notifications/AbstractNotificationPopup.java
...s/dbeaver/ui/notifications/AbstractNotificationPopup.java
+32
-14
plugins/org.jkiss.dbeaver.ui/src/org/jkiss/dbeaver/ui/notifications/GradientColors.java
...rc/org/jkiss/dbeaver/ui/notifications/GradientColors.java
+0
-218
未找到文件。
plugins/org.jkiss.dbeaver.ui/src/org/jkiss/dbeaver/ui/notifications/AbstractNotificationPopup.java
浏览文件 @
4ebdd535
...
...
@@ -14,8 +14,10 @@ import org.eclipse.core.runtime.IProgressMonitor;
import
org.eclipse.core.runtime.IStatus
;
import
org.eclipse.core.runtime.Status
;
import
org.eclipse.core.runtime.jobs.Job
;
import
org.eclipse.jface.resource.DeviceResourceException
;
import
org.eclipse.jface.resource.JFaceResources
;
import
org.eclipse.jface.resource.LocalResourceManager
;
import
org.eclipse.jface.resource.ResourceManager
;
import
org.eclipse.jface.window.Window
;
import
org.eclipse.swt.SWT
;
import
org.eclipse.swt.events.*
;
...
...
@@ -23,8 +25,10 @@ import org.eclipse.swt.graphics.*;
import
org.eclipse.swt.layout.GridData
;
import
org.eclipse.swt.layout.GridLayout
;
import
org.eclipse.swt.widgets.*
;
import
org.jkiss.code.NotNull
;
import
org.jkiss.dbeaver.ui.DBeaverIcons
;
import
org.jkiss.dbeaver.ui.UIIcon
;
import
org.jkiss.dbeaver.ui.UIStyles
;
import
org.jkiss.dbeaver.utils.GeneralUtils
;
/**
...
...
@@ -55,8 +59,6 @@ public abstract class AbstractNotificationPopup extends Window {
protected
LocalResourceManager
resources
;
private
GradientColors
color
;
private
final
Display
display
;
private
Shell
shell
;
...
...
@@ -103,6 +105,13 @@ public abstract class AbstractNotificationPopup extends Window {
private
boolean
fadingEnabled
;
@NotNull
private
final
Color
titleForegroundColor
;
@NotNull
private
final
Color
borderColor
;
@NotNull
private
final
Color
backgroundColor
;
public
AbstractNotificationPopup
(
Display
display
)
{
this
(
display
,
SWT
.
NO_TRIM
|
SWT
.
ON_TOP
|
SWT
.
NO_FOCUS
|
SWT
.
TOOL
);
}
...
...
@@ -113,11 +122,22 @@ public abstract class AbstractNotificationPopup extends Window {
this
.
display
=
display
;
resources
=
new
LocalResourceManager
(
JFaceResources
.
getResources
());
initResources
();
titleForegroundColor
=
getColor
(
resources
,
display
.
getSystemColor
(
SWT
.
COLOR_WIDGET_DARK_SHADOW
).
getRGB
());
borderColor
=
display
.
getSystemColor
(
SWT
.
COLOR_DARK_GRAY
);
backgroundColor
=
UIStyles
.
getDefaultWidgetBackground
();
closeJob
.
setSystem
(
true
);
}
private
static
Color
getColor
(
@NotNull
ResourceManager
manager
,
RGB
rgb
)
{
try
{
return
manager
.
createColor
(
rgb
);
}
catch
(
DeviceResourceException
e
)
{
return
manager
.
getDevice
().
getSystemColor
(
SWT
.
COLOR_BLACK
);
}
}
public
boolean
isFadingEnabled
()
{
return
fadingEnabled
;
}
...
...
@@ -196,11 +216,7 @@ public abstract class AbstractNotificationPopup extends Window {
}
protected
Color
getTitleForeground
()
{
return
color
.
getTitleText
();
}
private
void
initResources
()
{
color
=
new
GradientColors
(
display
,
resources
);
return
titleForegroundColor
;
}
@Override
...
...
@@ -208,7 +224,7 @@ public abstract class AbstractNotificationPopup extends Window {
super
.
configureShell
(
newShell
);
shell
=
newShell
;
newShell
.
setBackground
(
color
.
getBorder
()
);
newShell
.
setBackground
(
borderColor
);
}
@Override
...
...
@@ -326,7 +342,9 @@ public abstract class AbstractNotificationPopup extends Window {
drawGradient
(
gc
,
clArea
);
/* Fix Region Shape */
fixRegion
(
gc
,
clArea
);
if
(!
UIStyles
.
isDarkTheme
())
{
fixRegion
(
gc
,
clArea
);
}
gc
.
dispose
();
...
...
@@ -339,13 +357,13 @@ public abstract class AbstractNotificationPopup extends Window {
}
private
void
drawGradient
(
GC
gc
,
Rectangle
clArea
)
{
gc
.
setForeground
(
color
.
getGradientBegin
()
);
gc
.
setBackground
(
color
.
getGradientEnd
()
);
gc
.
setForeground
(
backgroundColor
);
gc
.
setBackground
(
backgroundColor
);
gc
.
fillGradientRectangle
(
clArea
.
x
,
clArea
.
y
,
clArea
.
width
,
clArea
.
height
,
true
);
}
private
void
fixRegion
(
GC
gc
,
Rectangle
clArea
)
{
gc
.
setForeground
(
color
.
getBorder
()
);
gc
.
setForeground
(
borderColor
);
/* Fill Top Left */
gc
.
drawPoint
(
2
,
0
);
...
...
@@ -423,7 +441,7 @@ public abstract class AbstractNotificationPopup extends Window {
middleContentCircle
.
setLayout
(
layout
);
middleContentCircle
.
setLayoutData
(
new
GridData
(
SWT
.
FILL
,
SWT
.
FILL
,
true
,
true
));
middleContentCircle
.
setBackground
(
color
.
getBorder
()
);
middleContentCircle
.
setBackground
(
borderColor
);
/* Inner composite containing the content controls */
Composite
innerContent
=
new
Composite
(
middleContentCircle
,
SWT
.
NO_FOCUS
);
...
...
plugins/org.jkiss.dbeaver.ui/src/org/jkiss/dbeaver/ui/notifications/GradientColors.java
已删除
100644 → 0
浏览文件 @
c483fbdb
/*******************************************************************************
* Copyright (c) 2004, 2015 Tasktop Technologies and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Benjamin Pasero - initial API and implementation
* Tasktop Technologies - improvements
*******************************************************************************/
package
org.jkiss.dbeaver.ui.notifications
;
import
org.eclipse.core.runtime.Platform
;
import
org.eclipse.jface.resource.DeviceResourceException
;
import
org.eclipse.jface.resource.ResourceManager
;
import
org.eclipse.swt.SWT
;
import
org.eclipse.swt.graphics.Color
;
import
org.eclipse.swt.graphics.RGB
;
import
org.eclipse.swt.widgets.Display
;
/**
* Based on FormColors of UI Forms.
*
* @author Benjamin Pasero (initial contribution from RSSOwl, see bug 177974)
* @author Mik Kersten
* @since 3.7
*/
public
class
GradientColors
{
private
final
Display
display
;
private
Color
titleText
;
private
Color
gradientBegin
;
private
Color
gradientEnd
;
private
Color
border
;
private
final
ResourceManager
resourceManager
;
public
GradientColors
(
Display
display
,
ResourceManager
resourceManager
)
{
this
.
display
=
display
;
this
.
resourceManager
=
resourceManager
;
createColors
();
}
private
void
createColors
()
{
createBorderColor
();
createGradientColors
();
// previously used SWT.COLOR_TITLE_INACTIVE_FOREGROUND, but too light on Windows XP
titleText
=
getColor
(
resourceManager
,
getSystemColor
(
SWT
.
COLOR_WIDGET_DARK_SHADOW
));
}
public
Color
getGradientBegin
()
{
return
gradientBegin
;
}
public
Color
getGradientEnd
()
{
return
gradientEnd
;
}
public
Color
getBorder
()
{
return
border
;
}
public
Color
getTitleText
()
{
return
titleText
;
}
private
void
createBorderColor
()
{
RGB
tbBorder
=
getSystemColor
(
SWT
.
COLOR_TITLE_BACKGROUND
);
RGB
bg
=
getBackground
();
// Group 1
// Rule: If at least 2 of the RGB values are equal to or between 180 and
// 255, then apply specified opacity for Group 1
// Examples: Vista, XP Silver, Wn High Con #2
// Keyline = TITLE_BACKGROUND @ 70% Opacity over LIST_BACKGROUND
if
(
testTwoPrimaryColors
(
tbBorder
,
179
,
256
))
{
tbBorder
=
blend
(
tbBorder
,
bg
,
70
);
}
else
if
(
testTwoPrimaryColors
(
tbBorder
,
120
,
180
))
{
tbBorder
=
blend
(
tbBorder
,
bg
,
50
);
}
else
{
tbBorder
=
blend
(
tbBorder
,
bg
,
30
);
}
border
=
getColor
(
resourceManager
,
tbBorder
);
}
private
void
createGradientColors
()
{
RGB
titleBg
=
getSystemColor
(
SWT
.
COLOR_TITLE_BACKGROUND
);
RGB
bg
=
getBackground
();
RGB
bottom
,
top
;
// Group 1
// Rule: If at least 2 of the RGB values are equal to or between 180 and
// 255, then apply specified opacity for Group 1
// Examples: Vista, XP Silver, Wn High Con #2
// Gradient Bottom = TITLE_BACKGROUND @ 30% Opacity over LIST_BACKGROUND
// Gradient Top = TITLE BACKGROUND @ 0% Opacity over LIST_BACKGROUND
if
(
testTwoPrimaryColors
(
titleBg
,
179
,
256
))
{
bottom
=
blend
(
titleBg
,
bg
,
30
);
top
=
bg
;
}
// Group 2
// Rule: If at least 2 of the RGB values are equal to or between 121 and
// 179, then apply specified opacity for Group 2
// Examples: XP Olive, OSX Graphite, Linux GTK, Wn High Con Black
// Gradient Bottom = TITLE_BACKGROUND @ 20% Opacity over LIST_BACKGROUND
// Gradient Top = TITLE BACKGROUND @ 0% Opacity over LIST_BACKGROUND
else
if
(
testTwoPrimaryColors
(
titleBg
,
120
,
180
))
{
bottom
=
blend
(
titleBg
,
bg
,
20
);
top
=
bg
;
}
// Group 3
// Rule: If at least 2 of the RGB values are equal to or between 0 and
// 120, then apply specified opacity for Group 3
// Examples: XP Default, Wn Classic Standard, Wn Marine, Wn Plum, OSX
// Aqua, Wn High Con White, Wn High Con #1
// Gradient Bottom = TITLE_BACKGROUND @ 10% Opacity over LIST_BACKGROUND
// Gradient Top = TITLE BACKGROUND @ 0% Opacity over LIST_BACKGROUND
else
{
bottom
=
blend
(
titleBg
,
bg
,
10
);
top
=
bg
;
}
gradientBegin
=
getColor
(
resourceManager
,
top
);
gradientEnd
=
getColor
(
resourceManager
,
bottom
);
}
private
RGB
blend
(
RGB
c1
,
RGB
c2
,
int
ratio
)
{
int
r
=
blend
(
c1
.
red
,
c2
.
red
,
ratio
);
int
g
=
blend
(
c1
.
green
,
c2
.
green
,
ratio
);
int
b
=
blend
(
c1
.
blue
,
c2
.
blue
,
ratio
);
return
new
RGB
(
r
,
g
,
b
);
}
private
int
blend
(
int
v1
,
int
v2
,
int
ratio
)
{
int
b
=
(
ratio
*
v1
+
(
100
-
ratio
)
*
v2
)
/
100
;
return
Math
.
min
(
255
,
b
);
}
private
boolean
testTwoPrimaryColors
(
RGB
rgb
,
int
from
,
int
to
)
{
int
total
=
0
;
if
(
testPrimaryColor
(
rgb
.
red
,
from
,
to
))
{
total
++;
}
if
(
testPrimaryColor
(
rgb
.
green
,
from
,
to
))
{
total
++;
}
if
(
testPrimaryColor
(
rgb
.
blue
,
from
,
to
))
{
total
++;
}
return
total
>=
2
;
}
private
boolean
testPrimaryColor
(
int
value
,
int
from
,
int
to
)
{
return
value
>
from
&&
value
<
to
;
}
private
RGB
getSystemColor
(
int
code
)
{
return
getDisplay
().
getSystemColor
(
code
).
getRGB
();
}
private
Color
getImpliedBackground
()
{
return
display
.
getSystemColor
(
SWT
.
COLOR_LIST_BACKGROUND
);
}
private
Display
getDisplay
()
{
return
display
;
}
private
Color
getColor
(
ResourceManager
manager
,
RGB
rgb
)
{
try
{
return
manager
.
createColor
(
rgb
);
}
catch
(
DeviceResourceException
e
)
{
return
manager
.
getDevice
().
getSystemColor
(
SWT
.
COLOR_BLACK
);
}
}
private
RGB
getBackground
()
{
RGB
themeBg
=
getRGBFromTheme
(
"background-color"
);
//$NON-NLS-1$
RGB
impliedBg
=
getImpliedBackground
().
getRGB
();
if
(
themeBg
==
null
)
{
return
impliedBg
;
}
// use the theme background only if it is significantly different than the implied
if
(
absoluteDifference
(
themeBg
.
red
,
impliedBg
.
red
)
<
40
&&
absoluteDifference
(
themeBg
.
blue
,
impliedBg
.
blue
)
<
40
&&
absoluteDifference
(
themeBg
.
green
,
impliedBg
.
green
)
<
40
)
{
return
impliedBg
;
}
return
themeBg
;
}
private
int
absoluteDifference
(
int
a
,
int
b
)
{
return
Math
.
abs
(
a
-
b
);
}
private
RGB
getRGBFromTheme
(
String
value
)
{
if
(
Platform
.
getBundle
(
"org.eclipse.e4.ui.css.swt.theme"
)
!=
null
)
{
//$NON-NLS-1$
String
backgroundColor
=
E4ThemeColor
.
getCssValueFromTheme
(
display
,
value
);
if
(
backgroundColor
!=
null
)
{
RGB
themeColor
=
E4ThemeColor
.
getRGBFromCssString
(
backgroundColor
);
if
(
themeColor
!=
null
)
{
return
themeColor
;
}
}
}
return
null
;
}
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录