/**
   * This method returns the image associate to the type of the parameter
   *
   * @see org.eclipse.jface.viewers.ILabelProvider#getImage(java.lang.Object)
   */
  public Image getImage(Object item) {
    if (mapImage == null) initMapImage();

    if (item instanceof AtlVariable) {
      String imageName = null;
      AtlVariable atlVar = (AtlVariable) item;
      //			String typeVar = null;
      //			try {
      //				typeVar = atlVar.getReferenceTypeName();
      //			} catch (DebugException e) {
      //				e.printStackTrace();
      //			}
      switch (atlVar.getDescription()) {
        case AtlVariable.ATTRIBUTE:
          imageName = "attribute.gif";
          break;
        case AtlVariable.ELEMENT:
          imageName = "element.gif";
          break;
        case AtlVariable.LOCALVARIABLE:
          imageName = "localVariable.gif";
          break;
        case AtlVariable.REFERENCE:
          imageName = "reference.gif";
          break;
        case AtlVariable.SUPERTYPE:
          imageName = "supertype.gif";
          break;
        default:
          return null;
      }
      if (mapImage.get(new Integer(atlVar.getDescription())) == null) {
        mapImage.put(new Integer(atlVar.getDescription()), createImage(iconPath + imageName));
      }
      return (Image) mapImage.get(new Integer(atlVar.getDescription()));
    } else if (item instanceof AtlBreakpoint) {
      if (mapImage.get(new Integer(BREAKPOINT)) == null) {
        mapImage.put(new Integer(BREAKPOINT), createImage(iconPath + "breakpoint.gif"));
      }
      return (Image) mapImage.get(new Integer(BREAKPOINT));
    } else if (item instanceof IMarker) {
      if (mapImage.get(new Integer(BREAKPOINT)) == null) {
        mapImage.put(new Integer(BREAKPOINT), createImage(iconPath + "breakpoint.gif"));
      }
      return (Image) mapImage.get(new Integer(BREAKPOINT));
    }
    return null;
  }
  /**
   * This method returns the text associate to the parameter
   *
   * @see org.eclipse.jface.viewers.ILabelProvider#getText(java.lang.Object)
   */
  public String getText(Object item) {
    if (item instanceof AtlDebugTarget) {
      AtlDebugTarget target = (AtlDebugTarget) item;
      String name = "";
      try {
        name = target.getName();
      } catch (DebugException e) {
        e.printStackTrace();
      }
      return name
          + Messages.getString("AtlDebugModelPresentation.CONNECTEDONHOST")
          + target.getHost()
          + Messages.getString("AtlDebugModelPresentation.PORT")
          + target.getPort(); // $NON-NLS-1$ //$NON-NLS-2$
    } else if (item instanceof AtlThread) {
      AtlThread thread = (AtlThread) item;
      try {
        String currentState;
        String message = "";
        switch (((AtlDebugTarget) thread.getDebugTarget()).getState()) {
          case AtlDebugTarget.stateDisconnected:
            currentState = Messages.getString("AtlDebugModelPresentation.DISCONNECTED");
            break; //$NON-NLS-1$
          case AtlDebugTarget.stateRunning:
            currentState = Messages.getString("AtlDebugModelPresentation.RUNNING");
            break; //$NON-NLS-1$
          case AtlDebugTarget.stateSuspended:
            currentState = Messages.getString("AtlDebugModelPresentation.SUSPENDED"); // $NON-NLS-1$
            message = ((AtlDebugTarget) thread.getDebugTarget()).getMessageFromDebuggee();
            return thread.getName()
                + " ("
                + currentState
                + " ("
                + message
                + "))"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
          case AtlDebugTarget.stateTerminated:
            currentState = Messages.getString("AtlDebugModelPresentation.TERMINATED");
            break; //$NON-NLS-1$
          default:
            currentState = Messages.getString("AtlDebugModelPresentation.UNKNOWN"); // $NON-NLS-1$
        }
        return thread.getName() + " (" + currentState + ")";
      } catch (DebugException e) {
        return null;
      }
    } else if (item instanceof AtlStackFrame) return null;
    else if (item instanceof AtlVariable) {
      AtlVariable atlVar = (AtlVariable) item;
      String typeVar = null;
      try {
        if (isShowVariableTypeNames()) typeVar = atlVar.getReferenceTypeName();
        else typeVar = "";

        String rtn = atlVar.getValue().getReferenceTypeName();
        if (rtn.equals("Boolean") || rtn.equals("Integer") || rtn.equals("Real"))
          return typeVar + " " + atlVar.getName() + " = " + atlVar.getValue().getValueString();
        else if (rtn.equals("String"))
          return typeVar
              + " "
              + atlVar.getName()
              + " = '"
              + atlVar.getValue().getValueString()
              + "'";
        else if (rtn.equals("EnumLiteral"))
          return typeVar + " " + atlVar.getName() + " = #" + atlVar.getValue().getValueString();
        else if (rtn.equals("Map Element")) return atlVar.getName();
        else
          return typeVar
              + " "
              + atlVar.getName()
              + " = "
              + atlVar.getReferenceTypeName()
              + " (id = "
              + atlVar.getIdVariable()
              + ")";
      } catch (DebugException e) {
        e.printStackTrace();
      }
    } else if (item instanceof AtlBreakpoint) {
      IMarker marker = ((AtlBreakpoint) item).getMarker();
      String location;
      try {
        location = (String) marker.getResource().getName();
        Integer lineNumber = (Integer) marker.getAttribute(IMarker.LINE_NUMBER);
        Integer charStart = (Integer) marker.getAttribute(IMarker.CHAR_START);
        Integer charEnd = (Integer) marker.getAttribute(IMarker.CHAR_END);
        return location
            + " [line: "
            + lineNumber
            + ", charStart: "
            + charStart
            + ", charEnd: "
            + charEnd
            + "]";
      } catch (CoreException e) {
        e.printStackTrace();
      }
    }

    return null;
  }