package com.intellij.openapi.projectRoots.impl;

import com.intellij.ui.ColoredListCellRenderer;
import com.intellij.ui.SimpleTextAttributes;
import com.intellij.openapi.projectRoots.Sdk;
import com.intellij.openapi.util.io.FileUtil;

import javax.swing.*;

/**
 * @author yole
*/
public class SdkListCellRenderer extends ColoredListCellRenderer {
  private String myNullText = "";

  public SdkListCellRenderer() {
  }

  public SdkListCellRenderer(final String nullText) {
    myNullText = nullText;
  }

  protected void customizeCellRenderer(final JList list,
                                       final Object value,
                                       final int index,
                                       final boolean selected,
                                       final boolean hasFocus) {
    final Sdk sdk = (Sdk) value;
    if (sdk != null) {
      // icon
      setIcon(sdk.getSdkType().getIcon());
      // text
      append(sdk.getName() + " (" + FileUtil.toSystemDependentName(sdk.getHomePath()) + ")", SimpleTextAttributes.REGULAR_ATTRIBUTES);
    }
    else {
      append(myNullText, SimpleTextAttributes.REGULAR_ATTRIBUTES);
    }
  }
}

@@ -46,101 +46,8 @@
 l;%0A%0A
-import com.intellij.ui.ColoredListCellRenderer;%0Aimport com.intellij.ui.SimpleTextAttributes;%0A
 impo
@@ -133,16 +133,64 @@
 ileUtil;
+%0Aimport com.intellij.ui.ColoredListCellRenderer;
 %0A%0Aimport
@@ -329,16 +329,50 @@
 xt = %22%22;
+%0A  private boolean myShowHomePath;
 %0A%0A  publ
@@ -489,16 +489,153 @@
 t;%0A  %7D%0A%0A
+  public SdkListCellRenderer(String nullText, boolean showHomePath) %7B%0A    myNullText = nullText;%0A    myShowHomePath = showHomePath;%0A  %7D%0A%0A
   protec
@@ -1079,19 +1079,62 @@
 etName()
- + 
+);%0A      if (myShowHomePath) %7B%0A        append(
 %22 (%22 + F
@@ -1191,133 +1191,59 @@
  %22)%22
-, SimpleTextAttributes.REGULAR_ATTRIBUTES);%0A    %7D%0A    else %7B%0A      append(myNullText, SimpleTextAttributes.REGULAR_ATTRIBUTES
+);%0A      %7D%0A    %7D%0A    else %7B%0A      append(myNullText
 );%0A 

use common implementation of SdkListCellRenderer