use of org.eclipse.jface.resource.ImageDescriptor in project translationstudio8 by heartsome.
the class Activator method getIconDescriptor.
/**
* 提供一个图片文件对插件的相对路径,返回该图片被伸缩变换为16*16像素的描述信息。
* @param path
* the path
* @return the icon descriptor
*/
public static ImageDescriptor getIconDescriptor(String path) {
ImageDescriptor image = getImageDescriptor(path);
ImageData data = image.getImageData();
data = data.scaledTo(16, 16);
image = ImageDescriptor.createFromImageData(data);
return image;
}
use of org.eclipse.jface.resource.ImageDescriptor in project translationstudio8 by heartsome.
the class TableExample method getImageRegistry.
public static ImageRegistry getImageRegistry() {
if (_imageRegistry == null) {
_imageRegistry = new ImageRegistry();
ImageDescriptor imgDesc = new ResourceImageDescriptor("/de/jaret/examples/table/splash.bmp");
_imageRegistry.put("splash", imgDesc);
imgDesc = new ResourceImageDescriptor("/de/jaret/examples/table/keyboard.png");
_imageRegistry.put("keyboard", imgDesc);
}
return _imageRegistry;
}
use of org.eclipse.jface.resource.ImageDescriptor in project translationstudio8 by heartsome.
the class LanguageLabelProvider method getImage.
public Image getImage(Object element) {
if (element instanceof Language) {
Language lang = (Language) element;
String code = lang.getCode();
String imagePath = lang.getImagePath();
if (imagePath != null && !imagePath.equals("")) {
ImageDescriptor imageDesc = Activator.getImageDescriptor(imagePath);
if (imageDesc != null) {
ImageData data = imageDesc.getImageData().scaledTo(16, 12);
Image image = new Image(Display.getDefault(), data);
// 销毁原来的图片
Image im = imageCache.put(code, image);
if (im != null && !im.isDisposed()) {
im.dispose();
}
return image;
}
}
}
return null;
}
use of org.eclipse.jface.resource.ImageDescriptor in project translationstudio8 by heartsome.
the class HtmlBrowserEditor method init.
@Override
public void init(IEditorSite site, IEditorInput input) throws PartInitException {
setSite(site);
setInput(input);
setPartName(input.getName());
Image oldTitleImage = titleImage;
if (input != null) {
IEditorRegistry editorRegistry = PlatformUI.getWorkbench().getEditorRegistry();
IEditorDescriptor editorDesc = editorRegistry.findEditor(getSite().getId());
ImageDescriptor imageDesc = editorDesc != null ? editorDesc.getImageDescriptor() : null;
titleImage = imageDesc != null ? imageDesc.createImage() : null;
}
setTitleImage(titleImage);
if (oldTitleImage != null && !oldTitleImage.isDisposed()) {
oldTitleImage.dispose();
}
FileEditorInput fileInput = (FileEditorInput) input;
htmlUrl = fileInput.getFile().getLocation().toOSString();
}
use of org.eclipse.jface.resource.ImageDescriptor in project translationstudio8 by heartsome.
the class XLFEditor method init.
@Override
public void init(IEditorSite site, IEditorInput input) throws PartInitException {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("init(IEditorSite site, IEditorInput input)");
}
setSite(site);
setInput(input);
// 设置Editor标题栏的显示名称,否则名称用plugin.xml中的name属性
setPartName(input.getName());
Image oldTitleImage = titleImage;
if (input != null) {
IEditorRegistry editorRegistry = PlatformUI.getWorkbench().getEditorRegistry();
IEditorDescriptor editorDesc = editorRegistry.findEditor(getSite().getId());
ImageDescriptor imageDesc = editorDesc != null ? editorDesc.getImageDescriptor() : null;
titleImage = imageDesc != null ? imageDesc.createImage() : null;
}
setTitleImage(titleImage);
if (oldTitleImage != null && !oldTitleImage.isDisposed()) {
oldTitleImage.dispose();
}
getSite().setSelectionProvider(this);
cursorIbeam = new Cursor(null, SWT.CURSOR_IBEAM);
cursorArrow = new Cursor(null, SWT.CURSOR_ARROW);
hookListener();
}
Aggregations