FileDocCategorySizeDatePackage
FolderDecorator.javaAPI DocAndroid 1.5 API4284Wed May 06 22:41:10 BST 2009com.android.ide.eclipse.adt.project

FolderDecorator

public class FolderDecorator extends Object implements org.eclipse.jface.viewers.ILightweightLabelDecorator
A {@link ILabelDecorator} associated with an org.eclipse.ui.decorators extension. This is used to add android icons in some special folders in the package explorer.

Fields Summary
private org.eclipse.jface.resource.ImageDescriptor
mDescriptor
Constructors Summary
public FolderDecorator()

        mDescriptor = AdtPlugin.getImageDescriptor("/icons/android_project.png"); //$NON-NLS-1$
    
Methods Summary
public voidaddListener(org.eclipse.jface.viewers.ILabelProviderListener listener)

        // No state change will affect the rendering.
    
public voiddecorate(java.lang.Object element, org.eclipse.jface.viewers.IDecoration decoration)

        if (element instanceof IFolder) {
            IFolder folder = (IFolder)element;
            
            // get the project and make sure this is an android project
            IProject project = folder.getProject();

            try {
                if (project.hasNature(AndroidConstants.NATURE)) {
                    // check the folder is directly under the project.
                    if (folder.getParent().getType() == IResource.PROJECT) {
                        String name = folder.getName();
                        if (name.equals(SdkConstants.FD_ASSETS)) {
                            doDecoration(decoration, null);
                        } else if (name.equals(SdkConstants.FD_RESOURCES)) {
                            doDecoration(decoration, null);
                        } else if (name.equals(SdkConstants.FD_GEN_SOURCES)) {
                            doDecoration(decoration, " [Generated Java Files]");
                      } else if (name.equals(SdkConstants.FD_NATIVE_LIBS)) {
                          doDecoration(decoration, null);
                        }
                    }
                }
            } catch (CoreException e) {
                // log the error
                AdtPlugin.log(e, "Unable to get nature of project '%s'.", project.getName());
            }
        }
    
public voiddispose()

        // nothing to dispose
    
public voiddoDecoration(org.eclipse.jface.viewers.IDecoration decoration, java.lang.String suffix)

        decoration.addOverlay(mDescriptor, IDecoration.TOP_LEFT);

        if (suffix != null) {
            decoration.addSuffix(suffix);

            // this is broken as it changes the color of the whole text, not only of the decoration.
            // TODO: figure out how to change the color of the decoration only.
//            ITheme theme = PlatformUI.getWorkbench().getThemeManager().getCurrentTheme();
//            ColorRegistry registry = theme.getColorRegistry();
//            decoration.setForegroundColor(
//                    registry.get("org.eclipse.jdt.ui.ColoredLabels.decorations")); //$NON-NLS-1$
        }

    
public booleanisLabelProperty(java.lang.Object element, java.lang.String property)

        // Property change do not affect the label
        return false;
    
public voidremoveListener(org.eclipse.jface.viewers.ILabelProviderListener listener)

        // No state change will affect the rendering.