show jdk name only (wo version) in module jdk combo in module settings (version will be shown in cb popup)

This commit is contained in:
Alexey Pegov
2010-09-24 13:45:09 +04:00
parent 2e0919f07c
commit 280d31dc3b
3 changed files with 14 additions and 7 deletions
@@ -29,7 +29,7 @@ import javax.swing.*;
public class ProjectJdkListRenderer extends ColoredListCellRenderer {
protected void customizeCellRenderer(JList list, Object value, int index, boolean selected, boolean hasFocus) {
if (value == null || value instanceof Sdk) {
OrderEntryCellAppearanceUtils.forJdk((Sdk)value, false, selected).customize(this);
OrderEntryCellAppearanceUtils.forJdk((Sdk)value, false, selected, index != -1).customize(this);
}
else {
final String str = value.toString();
@@ -24,6 +24,7 @@ import com.intellij.openapi.project.ProjectBundle;
import com.intellij.openapi.projectRoots.Sdk;
import com.intellij.openapi.roots.ui.configuration.projectRoot.JdkListConfigurable;
import com.intellij.openapi.roots.ui.configuration.projectRoot.ProjectSdksModel;
import com.intellij.openapi.ui.ComboBoxWithWidePopup;
import com.intellij.openapi.ui.popup.JBPopupFactory;
import com.intellij.openapi.util.Computable;
import com.intellij.openapi.util.Condition;
@@ -44,7 +45,7 @@ import java.util.Comparator;
* @author Eugene Zhuravlev
* Date: May 18, 2005
*/
class JdkComboBox extends JComboBox{
class JdkComboBox extends ComboBoxWithWidePopup {
private final JButton myEditButton = new JButton(ApplicationBundle.message("button.edit"));
public JdkComboBox(final ProjectSdksModel jdksModel) {
@@ -100,7 +100,7 @@ public class OrderEntryCellAppearanceUtils {
return testSource ? Icons.TEST_SOURCE_FOLDER : Icons.SOURCE_FOLDERS_ICON;
}
public static CellAppearance forJdk(Sdk jdk, boolean isInComboBox, final boolean selected) {
public static CellAppearance forJdk(Sdk jdk, boolean isInComboBox, final boolean selected, final boolean showVersion) {
if (jdk == null) {
return SimpleTextCellAppearance.invalid(NO_JDK, CellAppearanceUtils.INVALID_ICON);
}
@@ -112,14 +112,20 @@ public class OrderEntryCellAppearanceUtils {
homeDirectory != null && homeDirectory.isValid() ? CellAppearanceUtils.createSimpleCellAttributes(selected) : SimpleTextAttributes.ERROR_ATTRIBUTES;
CompositeAppearance.DequeEnd ending = appearance.getEnding();
ending.addText(name, attributes);
String versionString = jdk.getVersionString();
if (versionString != null && !versionString.equals(name)) {
SimpleTextAttributes textAttributes = isInComboBox ? SimpleTextAttributes.SYNTHETIC_ATTRIBUTES : SimpleTextAttributes.GRAY_ATTRIBUTES;
ending.addComment(versionString, textAttributes);
if (showVersion) {
String versionString = jdk.getVersionString();
if (versionString != null && !versionString.equals(name)) {
SimpleTextAttributes textAttributes = isInComboBox ? SimpleTextAttributes.SYNTHETIC_ATTRIBUTES : SimpleTextAttributes.GRAY_ATTRIBUTES;
ending.addComment(versionString, textAttributes);
}
}
return ending.getAppearance();
}
public static CellAppearance forJdk(Sdk jdk, boolean isInComboBox, final boolean selected) {
return forJdk(jdk, isInComboBox, selected, true);
}
public static SimpleTextCellAppearance forSourceFolder(SourceFolder folder) {
return formatRelativePath(folder, Icons.FOLDER_ICON);
}