提交 76c359b1 编写于 作者: J jurgen

Icons model refactoring

Former-commit-id: df9086ad
上级 7b4c6656
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2015 Serge Rieder (serge@jkiss.org)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License (version 2)
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package org.jkiss.dbeaver.model;
import java.io.File;
import java.io.IOException;
/**
* Image with overlays
*/
public class DBIconCustom implements DBPImage
{
private final DBPImage main;
private final boolean disabled;
private final DBPImage topLeft, topRight, bottomLeft, bottomRight;
public DBIconCustom(DBPImage main, boolean disabled, DBPImage topLeft, DBPImage topRight, DBPImage bottomLeft, DBPImage bottomRight) {
this.main = main;
this.disabled = disabled;
this.topLeft = topLeft;
this.topRight = topRight;
this.bottomLeft = bottomLeft;
this.bottomRight = bottomRight;
}
public boolean isDisabled() {
return disabled;
}
public DBPImage getTopLeft() {
return topLeft;
}
public DBPImage getTopRight() {
return topRight;
}
public DBPImage getBottomLeft() {
return bottomLeft;
}
public DBPImage getBottomRight() {
return bottomRight;
}
@Override
public String getLocation() {
return main.getLocation();
}
@Override
public File getFile() throws IOException {
return main.getFile();
}
}
......@@ -22,9 +22,10 @@ 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.osgi.framework.Bundle;
import java.io.IOException;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.net.URL;
import java.util.HashMap;
import java.util.Map;
......@@ -46,8 +47,12 @@ public class DBeaverIcons
public static void initRegistry()
{
for (DBIcon icon : DBIcon.values()) {
for (Field field : DBIcon.class.getDeclaredFields()) {
if ((field.getModifiers() & Modifier.STATIC) == 0 || field.getType() != DBIcon.class) {
continue;
}
try {
DBIcon icon = (DBIcon) field.get(null);
ImageDescriptor imageDescriptor = ImageDescriptor.createFromURL(new URL(icon.getLocation()));
IconDescriptor iconDescriptor = new IconDescriptor();
iconDescriptor.id = icon;
......@@ -58,7 +63,7 @@ public class DBeaverIcons
continue;
}
iconMap.put(icon.getToken(), iconDescriptor);
} catch (IOException e) {
} catch (Exception e) {
log.error(e);
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册