Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright (c) 2010 itemis AG (http://www.itemis.eu) and others. 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 /
 
 package org.eclipse.xtext.ui.editor.outline.impl;
 
import  org.eclipse.jface.resource.ImageDescriptor;
import  org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider;
import  org.eclipse.jface.viewers.ILabelProvider;
import  org.eclipse.jface.viewers.StyledString;
import  org.eclipse.swt.graphics.Image;

Author(s):
Jan Koehnlein - Initial contribution and API
public class OutlineNodeLabelProvider extends DelegatingStyledCellLabelProvider implements ILabelProvider {
	public OutlineNodeLabelProvider(Delegate delegate) {
		super(delegate);
	}
	public static class Delegate extends AbstractLabelProvider {
		protected Object doGetText(Object element) {
			if (element instanceof IOutlineNode) {
				return ((IOutlineNodeelement).getText();
			}
			return super.doGetText(element);
		}
		protected Object doGetImage(Object element) {
			if (element instanceof IOutlineNode.Extension) {
				ImageDescriptor imageDescriptor = ((IOutlineNode.Extensionelement).getImageDescriptor();
				if (imageDescriptor != null)
					return imageDescriptor;
			}
			if (element instanceof IOutlineNode) {
				Image image = ((IOutlineNodeelement).getImage();
				if (image != null
					return image;
			}
			return super.doGetImage(element);
		}
		protected Object getDefaultImage() {
			return .getImage("defaultoutlinenode.gif");
		}
		protected String getDefaultText() {
			return "<null>";
		}
		public Image getImage(Object element) {
			return super.getImage(element);
		}
		public String getText(Object element) {
			return super.getText(element);
		}
	}
	public String getText(Object element) {
		final StyledString styledText = getStyledText(element);
		return styledText != nullstyledText.toString() : null;
	}
New to GrepCode? Check out our FAQ X