Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
suliangchun
dbeaver
提交
c6fbb80b
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,发现更多精彩内容 >>
提交
c6fbb80b
编写于
3月 11, 2021
作者:
N
Nikita Akilov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
#10841 delete E4ThemeColor.java
Former-commit-id:
e5c38301
上级
4ebdd535
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
0 addition
and
111 deletion
+0
-111
plugins/org.jkiss.dbeaver.ui/src/org/jkiss/dbeaver/ui/notifications/E4ThemeColor.java
.../src/org/jkiss/dbeaver/ui/notifications/E4ThemeColor.java
+0
-111
未找到文件。
plugins/org.jkiss.dbeaver.ui/src/org/jkiss/dbeaver/ui/notifications/E4ThemeColor.java
已删除
100644 → 0
浏览文件 @
4ebdd535
/*******************************************************************************
* Copyright (c) 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:
* Tasktop Technologies - initial API and implementation
*******************************************************************************/
package
org.jkiss.dbeaver.ui.notifications
;
import
org.eclipse.e4.ui.css.swt.theme.IThemeEngine
;
import
org.eclipse.e4.ui.css.swt.theme.IThemeManager
;
import
org.eclipse.swt.graphics.RGB
;
import
org.eclipse.swt.widgets.Display
;
import
org.eclipse.swt.widgets.Shell
;
import
org.jkiss.dbeaver.Log
;
import
org.osgi.framework.BundleContext
;
import
org.osgi.framework.FrameworkUtil
;
import
org.osgi.framework.ServiceReference
;
import
org.w3c.dom.css.CSSStyleDeclaration
;
import
org.w3c.dom.css.CSSValue
;
public
class
E4ThemeColor
{
private
static
final
Log
log
=
Log
.
getLog
(
E4ThemeColor
.
class
);
private
static
boolean
loggedError
=
false
;
public
static
RGB
getRGBFromCssString
(
String
cssValue
)
{
try
{
if
(
cssValue
.
startsWith
(
"rgb("
))
{
//$NON-NLS-1$
String
rest
=
cssValue
.
substring
(
4
,
cssValue
.
length
());
int
idx
=
rest
.
indexOf
(
"rgb("
);
//$NON-NLS-1$
if
(
idx
!=
-
1
)
{
rest
=
rest
.
substring
(
idx
+
4
,
rest
.
length
());
}
idx
=
rest
.
indexOf
(
")"
);
//$NON-NLS-1$
if
(
idx
!=
-
1
)
{
rest
=
rest
.
substring
(
0
,
idx
);
}
String
[]
rgbValues
=
rest
.
split
(
","
);
//$NON-NLS-1$
if
(
rgbValues
.
length
==
3
)
{
return
new
RGB
(
Integer
.
parseInt
(
rgbValues
[
0
].
trim
()),
Integer
.
parseInt
(
rgbValues
[
1
].
trim
()),
Integer
.
parseInt
(
rgbValues
[
2
].
trim
()));
}
}
else
if
(
cssValue
.
startsWith
(
"#"
))
{
//$NON-NLS-1$
String
rest
=
cssValue
.
substring
(
1
,
cssValue
.
length
());
int
idx
=
rest
.
indexOf
(
"#"
);
//$NON-NLS-1$
if
(
idx
!=
-
1
)
{
rest
=
rest
.
substring
(
idx
+
1
,
rest
.
length
());
}
if
(
rest
.
length
()
>
5
)
{
return
new
RGB
(
Integer
.
parseInt
(
rest
.
substring
(
0
,
2
),
16
),
Integer
.
parseInt
(
rest
.
substring
(
2
,
4
),
16
),
Integer
.
parseInt
(
rest
.
substring
(
4
,
6
),
16
));
}
}
throw
new
IllegalArgumentException
(
"RGB: "
+
cssValue
);
//$NON-NLS-1$
}
catch
(
IllegalArgumentException
e
)
{
logOnce
(
e
);
return
null
;
}
}
public
static
String
getCssValueFromTheme
(
Display
display
,
String
value
)
{
// use reflection so that this can build against Eclipse 3.x
BundleContext
context
=
FrameworkUtil
.
getBundle
(
E4ThemeColor
.
class
).
getBundleContext
();
ServiceReference
<
IThemeManager
>
reference
=
context
.
getServiceReference
(
IThemeManager
.
class
);
if
(
reference
!=
null
)
{
IThemeManager
iThemeManager
=
context
.
getService
(
reference
);
if
(
iThemeManager
!=
null
)
{
IThemeEngine
themeEngine
=
iThemeManager
.
getEngineForDisplay
(
display
);
if
(
themeEngine
!=
null
)
{
CSSStyleDeclaration
shellStyle
=
getStyleDeclaration
(
themeEngine
,
display
);
if
(
shellStyle
!=
null
)
{
CSSValue
cssValue
=
shellStyle
.
getPropertyCSSValue
(
value
);
if
(
cssValue
!=
null
)
{
return
cssValue
.
getCssText
();
}
}
}
}
}
return
null
;
}
private
static
CSSStyleDeclaration
getStyleDeclaration
(
IThemeEngine
themeEngine
,
Display
display
)
{
Shell
shell
=
display
.
getActiveShell
();
CSSStyleDeclaration
shellStyle
=
null
;
if
(
shell
!=
null
)
{
shellStyle
=
themeEngine
.
getStyle
(
shell
);
}
else
{
for
(
Shell
input
:
display
.
getShells
())
{
shellStyle
=
themeEngine
.
getStyle
(
input
);
if
(
shellStyle
!=
null
)
{
break
;
}
}
}
return
shellStyle
;
}
private
static
void
logOnce
(
Exception
e
)
{
if
(!
loggedError
)
{
log
.
error
(
e
);
loggedError
=
true
;
}
}
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录