Search in sources :

Example 61 with ImageDescriptor

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;
}
Also used : ImageData(org.eclipse.swt.graphics.ImageData) ImageDescriptor(org.eclipse.jface.resource.ImageDescriptor)

Example 62 with ImageDescriptor

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;
}
Also used : ImageRegistry(org.eclipse.jface.resource.ImageRegistry) ResourceImageDescriptor(de.jaret.util.ui.ResourceImageDescriptor) ResourceImageDescriptor(de.jaret.util.ui.ResourceImageDescriptor) ImageDescriptor(org.eclipse.jface.resource.ImageDescriptor)

Example 63 with ImageDescriptor

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;
}
Also used : Language(net.heartsome.cat.common.locale.Language) ImageData(org.eclipse.swt.graphics.ImageData) ImageDescriptor(org.eclipse.jface.resource.ImageDescriptor) Image(org.eclipse.swt.graphics.Image)

Example 64 with ImageDescriptor

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();
}
Also used : IEditorDescriptor(org.eclipse.ui.IEditorDescriptor) FileEditorInput(org.eclipse.ui.part.FileEditorInput) ImageDescriptor(org.eclipse.jface.resource.ImageDescriptor) Image(org.eclipse.swt.graphics.Image) IEditorRegistry(org.eclipse.ui.IEditorRegistry)

Example 65 with ImageDescriptor

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();
}
Also used : IEditorDescriptor(org.eclipse.ui.IEditorDescriptor) ImageDescriptor(org.eclipse.jface.resource.ImageDescriptor) Image(org.eclipse.swt.graphics.Image) Cursor(org.eclipse.swt.graphics.Cursor) IEditorRegistry(org.eclipse.ui.IEditorRegistry)

Aggregations

ImageDescriptor (org.eclipse.jface.resource.ImageDescriptor)106 Image (org.eclipse.swt.graphics.Image)25 ArrayList (java.util.ArrayList)21 List (java.util.List)18 ToolEntry (org.eclipse.gef.palette.ToolEntry)14 URL (java.net.URL)12 ImageData (org.eclipse.swt.graphics.ImageData)11 ResourceImageDescriptor (de.jaret.util.ui.ResourceImageDescriptor)9 Point (org.eclipse.swt.graphics.Point)6 Node (org.talend.designer.core.ui.editor.nodes.Node)6 Path (org.eclipse.core.runtime.Path)5 JavaElementImageDescriptor (org.eclipse.jdt.ui.JavaElementImageDescriptor)5 File (java.io.File)4 HashMap (java.util.HashMap)4 IPreferenceStore (org.eclipse.jface.preference.IPreferenceStore)4 IComponent (org.talend.core.model.components.IComponent)4 INode (org.talend.core.model.process.INode)4 MalformedURLException (java.net.MalformedURLException)3 Set (java.util.Set)3 IConfigurationElement (org.eclipse.core.runtime.IConfigurationElement)3