Package bndtools.utils

Source Code of bndtools.utils.JavaContentProposalLabelProvider

/*******************************************************************************
* Copyright (c) 2010 Neil Bartlett.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
*     Neil Bartlett - initial API and implementation
*******************************************************************************/
package bndtools.utils;

import org.eclipse.jface.fieldassist.IContentProposal;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.swt.graphics.Image;
import org.eclipse.ui.plugin.AbstractUIPlugin;

import bndtools.Plugin;

public class JavaContentProposalLabelProvider extends LabelProvider {

    private Image classImg = AbstractUIPlugin.imageDescriptorFromPlugin(Plugin.PLUGIN_ID, "icons/class_obj.gif").createImage();
    private Image interfaceImg = AbstractUIPlugin.imageDescriptorFromPlugin(Plugin.PLUGIN_ID, "icons/interface_obj.gif").createImage();

    @Override
    public Image getImage(Object element) {
        Image result = null;

        if (element instanceof JavaContentProposal) {
            result = classImg;
            if (((JavaContentProposal) element).isInterface()) {
                result = interfaceImg;
            } else {
                result = classImg;
            }
        }

        return result;
    }

    @Override
    public String getText(Object element) {
        IContentProposal proposal = (IContentProposal) element;

        return proposal.getLabel();
    }

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

Related Classes of bndtools.utils.JavaContentProposalLabelProvider

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.