/* (non-Javadoc)
   * @see org.eclipse.jface.viewers.LabelProvider#getImage(java.lang.Object)
   */
  @Override
  public Image getImage(Object element) {
    NavigatorViewItem viewItem = (NavigatorViewItem) element;

    ILabelProvider labelProvider =
        (ILabelProvider)
            AdapterManager.getDefault().getAdapter(viewItem.getReference(), ILabelProvider.class);
    if (labelProvider != null) {
      return labelProvider.getImage(element);
    }

    if (viewItem.getReference() instanceof IMarket) {
      return marketIcon;
    }
    if (viewItem.getReference() instanceof ISecurity) {
      return securityIcon;
    }
    if (viewItem.getReference() instanceof IWatchList) {
      return watchListIcon;
    }

    if (viewItem.getItemCount() != 0) {
      return folderIcon;
    }

    return blankIcon;
  }
  /* (non-Javadoc)
   * @see org.eclipse.jface.viewers.LabelProvider#getText(java.lang.Object)
   */
  @Override
  public String getText(Object element) {
    NavigatorViewItem viewItem = (NavigatorViewItem) element;

    ILabelProvider labelProvider =
        (ILabelProvider)
            AdapterManager.getDefault().getAdapter(viewItem.getReference(), ILabelProvider.class);
    if (labelProvider != null) {
      return labelProvider.getText(element);
    }

    if (viewItem.getReference() instanceof IMarket) {
      return ((IMarket) element).getName();
    }
    if (viewItem.getReference() instanceof ISecurity) {
      return ((ISecurity) element).getName();
    }
    if (viewItem.getReference() instanceof IWatchList) {
      return ((IWatchList) element).getName();
    }

    return super.getText(element);
  }