Newer
Older
MagnetRON / src / org / ntlab / traceanalyzer / CallTreeLabelProvider.java
Aki Hongo on 3 Mar 2020 1 KB first commit
package org.ntlab.traceanalyzer;

import org.eclipse.jface.resource.ImageRegistry;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.swt.graphics.Image;
import org.eclipse.ui.ISharedImages;
import org.eclipse.ui.PlatformUI;

public class CallTreeLabelProvider extends LabelProvider {
	public Image getImage(Object element) {
		if (element instanceof MarkedMethodExecution){
			int uniqueness = ((MarkedMethodExecution)element).isUniqueMethodInvokedFrom();
			ImageRegistry registry = Activator.getDefault().getImageRegistry();			
			Image image;
			switch (uniqueness) {
			case 1:
				image = registry.get("TraceAnalyzer.STACK_FRAME_IMAGE2");
				break;
			case 2:
				image = registry.get("TraceAnalyzer.STACK_FRAME_IMAGE3");
				break;
			case 0:
			default:
				image = registry.get("TraceAnalyzer.STACK_FRAME_IMAGE");
			}
			return image;
		} else if(element instanceof MarkedThread){
			int uniqueness = ((MarkedThread)element).isUniqueMethodInvokedFrom();
			ImageRegistry registry = Activator.getDefault().getImageRegistry();
			Image image;
			switch (uniqueness) {
			case 1:
				image = registry.get("TraceAnalyzer.THREAD_IMAGE2");
				break;
			case 0:
			default:
				image = registry.get("TraceAnalyzer.THREAD_IMAGE");
			}
			return image;
		} else {
			return null;
		}
    }

    public String getText(Object element) {
    	String name = null;
		if (element instanceof MarkedMethodExecution){
			MarkedMethodExecution method = (MarkedMethodExecution)element;
	    	name = method.getSignature();
		} else if (element instanceof MarkedThread){
			name = ((MarkedThread)element).getId();
		}
    	return name;
	}
}