package com.vectrace.MercurialEclipse.team;



import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.swt.graphics.ImageData;

/**
 * Set of images that are used for decorating resources are maintained
 * here. This acts as a image registry and hence there is a single copy
 * of the image files floating around the project. 
 * 
 */
public class DecoratorImages
{
  /**
   * Added Image Descriptor
   */ 
  public static final ImageDescriptor addedDescriptor = ImageDescriptor.createFromFile (DecoratorStatus.class, "images/mercury/added.gif");
  
  /**
   * Deleted but still tracked Image Descriptor
   */ 
  public static final ImageDescriptor deletedStillTrackedDescriptor = ImageDescriptor.createFromFile (DecoratorStatus.class, "images/mercury/deleted_still_tracked.gif");
  
  /**
   * Ignored Image Descriptor
   */ 
  public static final ImageDescriptor ignoredDescriptor = ImageDescriptor.createFromFile (DecoratorStatus.class, "images/mercury/ignored.gif");
    
  /**
   * Modified Image Descriptor
   */ 
  public static final ImageDescriptor modifiedDescriptor = ImageDescriptor.createFromFile (DecoratorStatus.class, "images/mercury/modified.gif");

  /**
   * Not tracked Image Descriptor
   */ 
  public static final ImageDescriptor notTrackedDescriptor = ImageDescriptor.createFromFile (DecoratorStatus.class, "images/mercury/not_tracked.gif");
  /**
   * Removed Image Descriptor
   */ 
  public static final ImageDescriptor removedDescriptor = ImageDescriptor.createFromFile (DecoratorStatus.class, "images/mercury/removed.gif");

  /**
   * Managed Image Descriptor
   */ 
  public static final ImageDescriptor managedDescriptor = ImageDescriptor.createFromFile (DecoratorStatus.class, "images/mercury/managed.gif");
  
  
  /**
   * Constructor for DemoImages.
   */
  public DecoratorImages()
  {
    super();
  }


  
  /**
   * Get the image data depending on the key
   * 
   * @return image data 
   * 
   */ 
  public ImageData getImageData(String imageKey)
  {
    ImageDescriptor imagedescriptor=getImageDescriptor(imageKey);
    if(imagedescriptor!=null)
    {
      return imagedescriptor.getImageData();
    }
    else
    {
      return null;
    }
  }
   
  /**
   * Get the image descriptor depending on the key
   * 
   * @return image descriptor 
   * 
   */ 
  public static final ImageDescriptor getImageDescriptor(String imageKey)
  {
    //Input is the output from the "hg status <file>" comamnd
    if(imageKey==null)
    {
      //hg status <file> has no output in an a managed file
      return managedDescriptor;
    }

    // Look at the first letter
    if (imageKey.startsWith("M"))
    {
      return modifiedDescriptor;
    }
    if (imageKey.startsWith("A"))
    {
      return addedDescriptor;
    }
    if (imageKey.startsWith("R"))
    {
      return removedDescriptor;
    }
    if (imageKey.startsWith("!"))
    {
      return deletedStillTrackedDescriptor;
    }
    if (imageKey.startsWith("?"))
    {
      return notTrackedDescriptor;
    }
    if (imageKey.startsWith("I"))
    {
      return ignoredDescriptor;
    }
    return null;
  }

  // public ImageDescriptor 

}

@@ -537,25 +537,17 @@
 ges/
-mercury/
 added.
-gif
+png
 %22);%0A
@@ -743,24 +743,16 @@
 %22images/
-mercury/
 deleted_
@@ -761,27 +761,27 @@
 ill_tracked.
-gif
+png
 %22);%0A  %0A  /**
@@ -943,24 +943,16 @@
 ges/
-mercury/
 ignored.
 gif%22
@@ -947,19 +947,19 @@
 ignored.
-gif
+png
 %22);%0A    
@@ -1125,24 +1125,16 @@
 %22images/
-mercury/
 modified
@@ -1134,19 +1134,19 @@
 odified.
-gif
+png
 %22);%0A%0A  /
@@ -1313,24 +1313,16 @@
 %22images/
-mercury/
 not_trac
@@ -1325,19 +1325,19 @@
 tracked.
-gif
+png
 %22);%0A  /*
@@ -1500,24 +1500,16 @@
 ges/
-mercury/
 removed.
 gif%22
@@ -1504,19 +1504,19 @@
 removed.
-gif
+png
 %22);%0A%0A  /
@@ -1680,24 +1680,16 @@
 ges/
-mercury/
 managed.
 gif%22
@@ -1688,11 +1688,11 @@
 ged.
-gif
+png
 %22);%0A

Fix repository below project root see ticket #61 for more info.