Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
suliangchun
dbeaver
提交
113634f6
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,发现更多精彩内容 >>
提交
113634f6
编写于
6月 23, 2015
作者:
J
jurgen
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Icons model refactoring
Former-commit-id:
2db5512c
上级
76c359b1
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
40 addition
and
32 deletion
+40
-32
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/core/DBeaverUI.java
...ss.dbeaver.core/src/org/jkiss/dbeaver/core/DBeaverUI.java
+1
-1
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/AbstractDescriptor.java
...re/src/org/jkiss/dbeaver/registry/AbstractDescriptor.java
+1
-1
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/DBeaverIcons.java
...s.dbeaver.core/src/org/jkiss/dbeaver/ui/DBeaverIcons.java
+38
-30
未找到文件。
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/core/DBeaverUI.java
浏览文件 @
113634f6
...
...
@@ -104,7 +104,7 @@ public class DBeaverUI {
private
void
initialize
()
{
DBeaverIcons
.
initRegistry
();
DBeaverIcons
.
getPredefinedImages
();
this
.
sharedTextColors
=
new
SharedTextColors
();
...
...
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/AbstractDescriptor.java
浏览文件 @
113634f6
...
...
@@ -195,7 +195,7 @@ public abstract class AbstractDescriptor {
return
null
;
}
else
if
(
icon
.
startsWith
(
"#"
))
{
// Predefined image
return
DBeaverIcons
.
getImage
(
icon
.
substring
(
1
));
return
DBeaverIcons
.
getImage
ById
(
icon
.
substring
(
1
));
}
else
{
URL
iconPath
=
getContributorBundle
().
getEntry
(
icon
);
if
(
iconPath
!=
null
)
{
...
...
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/DBeaverIcons.java
浏览文件 @
113634f6
...
...
@@ -22,11 +22,13 @@ import org.eclipse.jface.resource.ImageDescriptor;
import
org.eclipse.swt.graphics.Image
;
import
org.jkiss.dbeaver.core.Log
;
import
org.jkiss.dbeaver.model.DBIcon
;
import
org.jkiss.dbeaver.model.DBPImage
;
import
java.io.IOException
;
import
java.lang.reflect.Field
;
import
java.lang.reflect.Modifier
;
import
java.net.URL
;
import
java.util.ArrayList
;
import
java.util.Collection
;
import
java.util.HashMap
;
import
java.util.Map
;
...
...
@@ -38,15 +40,20 @@ public class DBeaverIcons
static
final
Log
log
=
Log
.
getLog
(
DBeaverIcons
.
class
);
private
static
class
IconDescriptor
{
DBIcon
id
;
String
id
;
ImageDescriptor
imageDescriptor
;
Image
image
;
public
IconDescriptor
(
String
id
,
ImageDescriptor
imageDescriptor
)
{
this
.
id
=
id
;
this
.
imageDescriptor
=
imageDescriptor
;
this
.
image
=
imageDescriptor
.
createImage
(
false
);
}
}
private
static
Map
<
String
,
IconDescriptor
>
iconMap
=
new
HashMap
<
String
,
IconDescriptor
>();
public
static
void
initRegistry
()
{
static
{
for
(
Field
field
:
DBIcon
.
class
.
getDeclaredFields
())
{
if
((
field
.
getModifiers
()
&
Modifier
.
STATIC
)
==
0
||
field
.
getType
()
!=
DBIcon
.
class
)
{
continue
;
...
...
@@ -54,10 +61,7 @@ public class DBeaverIcons
try
{
DBIcon
icon
=
(
DBIcon
)
field
.
get
(
null
);
ImageDescriptor
imageDescriptor
=
ImageDescriptor
.
createFromURL
(
new
URL
(
icon
.
getLocation
()));
IconDescriptor
iconDescriptor
=
new
IconDescriptor
();
iconDescriptor
.
id
=
icon
;
iconDescriptor
.
imageDescriptor
=
imageDescriptor
;
iconDescriptor
.
image
=
imageDescriptor
.
createImage
(
false
);
IconDescriptor
iconDescriptor
=
new
IconDescriptor
(
icon
.
getLocation
(),
imageDescriptor
);
if
(
iconDescriptor
.
image
==
null
)
{
log
.
warn
(
"Bad image '"
+
icon
.
getToken
()
+
"' location: "
+
icon
.
getLocation
());
continue
;
...
...
@@ -69,22 +73,23 @@ public class DBeaverIcons
}
}
public
static
Image
getImage
(
DBIcon
icon
)
{
return
getImage
(
icon
.
getToken
());
public
static
Collection
<
String
>
getPredefinedImages
()
{
return
new
ArrayList
<
String
>(
iconMap
.
keySet
());
}
public
static
Image
Descriptor
getImageDescriptor
(
DBIcon
icon
)
public
static
Image
getImage
(
DBPImage
image
)
{
return
getImageDescriptor
(
icon
.
getToken
());
IconDescriptor
icon
=
getIconByLocation
(
image
.
getLocation
());
return
icon
==
null
?
null
:
icon
.
image
;
}
public
static
Image
createImage
(
DBIcon
icon
)
public
static
Image
Descriptor
getImageDescriptor
(
DBPImage
image
)
{
return
createImage
(
icon
.
getToken
());
IconDescriptor
icon
=
getIconByLocation
(
image
.
getLocation
());
return
icon
==
null
?
null
:
icon
.
imageDescriptor
;
}
public
static
Image
getImage
(
String
token
)
public
static
Image
getImage
ById
(
String
token
)
{
IconDescriptor
iconDescriptor
=
iconMap
.
get
(
token
);
if
(
iconDescriptor
==
null
)
{
...
...
@@ -93,21 +98,24 @@ public class DBeaverIcons
return
iconDescriptor
.
image
;
}
public
static
ImageDescriptor
getImageDescriptor
(
String
token
)
{
IconDescriptor
iconDescriptor
=
iconMap
.
get
(
token
);
if
(
iconDescriptor
==
null
)
{
return
null
;
private
static
IconDescriptor
getIconByLocation
(
String
location
)
{
IconDescriptor
icon
=
iconMap
.
get
(
location
);
if
(
icon
==
null
)
{
try
{
ImageDescriptor
imageDescriptor
=
ImageDescriptor
.
createFromURL
(
new
URL
(
location
));
icon
=
new
IconDescriptor
(
location
,
imageDescriptor
);
if
(
icon
.
image
==
null
)
{
log
.
warn
(
"Bad image: "
+
location
);
return
null
;
}
else
{
iconMap
.
put
(
location
,
icon
);
}
}
catch
(
Exception
e
)
{
log
.
error
(
e
);
return
null
;
}
}
return
icon
Descriptor
.
imageDescriptor
;
return
icon
;
}
public
static
Image
createImage
(
String
token
)
{
IconDescriptor
iconDescriptor
=
iconMap
.
get
(
token
);
if
(
iconDescriptor
==
null
)
{
return
null
;
}
return
iconDescriptor
.
imageDescriptor
.
createImage
();
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录