Package bndtools.shared

Source Code of bndtools.shared.URLLabelProvider

package bndtools.shared;

import org.eclipse.jface.viewers.StyledCellLabelProvider;
import org.eclipse.jface.viewers.StyledString;
import org.eclipse.jface.viewers.ViewerCell;
import org.eclipse.swt.graphics.Device;
import org.eclipse.swt.graphics.Image;
import org.eclipse.ui.plugin.AbstractUIPlugin;

import bndtools.Plugin;

public class URLLabelProvider extends StyledCellLabelProvider {

    private final Image linkImg;

    public URLLabelProvider(Device device) {
        linkImg = AbstractUIPlugin.imageDescriptorFromPlugin(Plugin.PLUGIN_ID, "/icons/link.png").createImage(device);
    }

    @Override
    public void update(ViewerCell cell) {
        cell.setImage(linkImg);

        Object element = cell.getElement();
        if (element instanceof OBRLink) {
            StyledString label = ((OBRLink) element).getLabel();
            cell.setStyleRanges(label.getStyleRanges());
            cell.setText(label.getString());
        } else {
            cell.setText(element == null ? "null" : element.toString());
        }
    }

    @Override
    public void dispose() {
        super.dispose();
        linkImg.dispose();
    }
}
TOP

Related Classes of bndtools.shared.URLLabelProvider

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.