/*******************************************************************************
* Copyright (c) 2000, 2005 IBM Corporation 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
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.rubypeople.rdt.internal.ui.rubyeditor;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.text.source.Annotation;
import org.eclipse.swt.graphics.Image;
import org.eclipse.ui.texteditor.IAnnotationImageProvider;
import org.rubypeople.rdt.internal.ui.RubyPluginImages;
/**
* Image provider for {@link org.rubypeople.rdt.internal.ui.rubyeditor.OverrideIndicatorManager.OverrideIndicator} annotations.
*
* @since 3.0
*/
public class OverrideIndicatorImageProvider implements IAnnotationImageProvider {
// TODO Rip out the implements stuff
/*
* @see org.eclipse.ui.texteditor.IAnnotationImageProvider#getManagedImage(org.eclipse.jface.text.source.Annotation)
*/
private static final String OVERRIDE_IMG_DESC_ID= "RubyPluginImages.DESC_OBJ_OVERRIDES"; //$NON-NLS-1$
private static final String OVERWRITE_IMG_DESC_ID= "RubyPluginImages.DESC_OBJ_IMPLEMENTS"; //$NON-NLS-1$
public Image getManagedImage(Annotation annotation) {
return null;
}
/*
* @see org.eclipse.ui.texteditor.IAnnotationImageProvider#getImageDescriptorId(org.eclipse.jface.text.source.Annotation)
*/
public String getImageDescriptorId(Annotation annotation) {
if (!isImageProviderFor(annotation))
return null;
if (isOverwriting(annotation))
return OVERWRITE_IMG_DESC_ID;
else
return OVERRIDE_IMG_DESC_ID;
}
/*
* @see org.eclipse.ui.texteditor.IAnnotationImageProvider#getImageDescriptor(java.lang.String)
*/
public ImageDescriptor getImageDescriptor(String imageDescritporId) {
if (OVERWRITE_IMG_DESC_ID.equals(imageDescritporId))
return RubyPluginImages.DESC_OBJ_IMPLEMENTS;
else if (OVERRIDE_IMG_DESC_ID.equals(imageDescritporId))
return RubyPluginImages.DESC_OBJ_OVERRIDES;
return null;
}
private boolean isImageProviderFor(Annotation annotation) {
return annotation != null && OverrideIndicatorManager.ANNOTATION_TYPE.equals(annotation.getType());
}
private boolean isOverwriting(Annotation annotation) {
return ((OverrideIndicatorManager.OverrideIndicator)annotation).isOverwriteIndicator();
}
}