📄 imagescontext.java
字号:
package com.zdh.sms.system;
import java.net.URL;
import org.eclipse.core.runtime.FileLocator;
import org.eclipse.core.runtime.Path;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.resource.ImageRegistry;
import org.eclipse.swt.graphics.Image;
import com.zdh.sms.Activator;
public class ImagesContext {
private final static String ICONS_PATH = "icons/";
public final static String EDITING = "EDITING";
public final static String NOTE = "NOTE";
public final static String REPORT = "REPORT";
public final static String STUDENT = "STUDENT";
public final static String SYSCONFIG = "SYSCONFIG";
public final static String USER = "USER";
public final static String LOGON = "LOGON";
public final static String LOGOFF = "USER";
public final static String REMOVE = "REMOVE";
public final static String NEXT = "NEXT";
public final static String PREV = "PREV";
public final static String FIRST = "FIRST";
public final static String LAST = "LAST";
//系统只需要一个ImageRegistry对象
private static ImageRegistry imageRegistry;
public static ImageRegistry getImageRegistry() {
if (imageRegistry == null) {
imageRegistry = new ImageRegistry();
declareImages();// 将图像注册
}
return imageRegistry;
}
// 在此处进行图像注册
private final static void declareImages() {
declareRegistryImage(EDITING, ICONS_PATH + "editing.gif");
declareRegistryImage(NOTE, ICONS_PATH + "note.gif");
declareRegistryImage(REPORT, ICONS_PATH + "report.gif");
declareRegistryImage(STUDENT, ICONS_PATH + "student.gif");
declareRegistryImage(SYSCONFIG, ICONS_PATH + "sysconfig.gif");
declareRegistryImage(USER, ICONS_PATH + "user.gif");
declareRegistryImage(LOGON, ICONS_PATH + "logon.gif");
declareRegistryImage(REMOVE, ICONS_PATH + "remove.gif");
declareRegistryImage(NEXT, ICONS_PATH + "next.gif");
declareRegistryImage(PREV, ICONS_PATH + "prev.gif");
declareRegistryImage(FIRST, ICONS_PATH + "first.gif");
declareRegistryImage(LAST, ICONS_PATH + "last.gif");
}
private final static void declareRegistryImage(String key, String path) {
try {
URL url= FileLocator.find(Activator.getDefault().getBundle(), new Path(path), null);
if (url != null) {
ImageDescriptor image = ImageDescriptor.createFromURL(url);
getImageRegistry().put(key, image);
}
} catch (Exception e) {e.printStackTrace();}
}
public static Image getImage(String key) {
return getImageRegistry().get(key);
}
public static ImageDescriptor getImageDescriptor(String key) {
return getImageRegistry().getDescriptor(key);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -