Java Code Examples for com.intellij.util.ui.UIUtil#getListBackground()

The following examples show how to use com.intellij.util.ui.UIUtil#getListBackground() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: StringElementListCellRenderer.java    From android-strings-search-plugin with Apache License 2.0 6 votes vote down vote up
@Override
protected void customizeCellRenderer(JList list, Object value, int index, boolean selected, boolean hasFocus) {
    Color bgColor = UIUtil.getListBackground();
    setPaintFocusBorder(hasFocus && UIUtil.isToUseDottedCellBorder());

    if (value instanceof StringElement) {
        StringElement element = (StringElement) value;
        String stringKeyText = "(" + element.getName() + ")";
        String text = new StringEllipsisPolicy().ellipsizeText(element.getValue(), matcher);

        SimpleTextAttributes nameAttributes = new SimpleTextAttributes(Font.PLAIN, list.getForeground());
        SpeedSearchUtil.appendColoredFragmentForMatcher(text, this, nameAttributes, matcher, bgColor, selected);
        // TODO Change icon
        setIcon(AndroidIcons.EmptyFlag);

        append(" " + stringKeyText, new SimpleTextAttributes(Font.PLAIN, JBColor.GRAY));
    }

    setBackground(selected ? UIUtil.getListSelectionBackground() : bgColor);
}
 
Example 2
Source File: ContentChooser.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
protected void customizeCellRenderer(JList list, Object value, int index, boolean selected, boolean hasFocus) {
  setIcon(myListEntryIcon);
  if (myUseIdeaEditor) {
    int max = list.getModel().getSize();
    String indexString = String.valueOf(index + 1);
    int count = String.valueOf(max).length() - indexString.length();
    char[] spaces = new char[count];
    Arrays.fill(spaces, ' ');
    String prefix = indexString + new String(spaces) + "  ";
    append(prefix, SimpleTextAttributes.GRAYED_ATTRIBUTES);
  }
  else if (UIUtil.isUnderGTKLookAndFeel()) {
    // Fix GTK background
    Color background = selected ? UIUtil.getListSelectionBackground() : UIUtil.getListBackground();
    UIUtil.changeBackGround(this, background);
  }
  String text = ((Item)value).shortText;

  FontMetrics metrics = list.getFontMetrics(list.getFont());
  int charWidth = metrics.charWidth('m');
  int maxLength = list.getParent().getParent().getWidth() * 3 / charWidth / 2;
  text = StringUtil.first(text, maxLength, true); // do not paint long strings
  append(text, SimpleTextAttributes.REGULAR_ATTRIBUTES);
}
 
Example 3
Source File: RunAnythingItemBase.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Nonnull
@Override
public Component createComponent(@Nullable String pattern, boolean isSelected, boolean hasFocus) {
  Component oldComponent = createComponent(isSelected);
  if (oldComponent != null) {
    return oldComponent;
  }

  JPanel component = new JPanel(new BorderLayout());
  Color background = UIUtil.getListBackground(isSelected, true);
  component.setBackground(background);

  SimpleColoredComponent textComponent = new SimpleColoredComponent();
  SpeedSearchUtil
          .appendColoredFragmentForMatcher(StringUtil.notNullize(getCommand()), textComponent, REGULAR_ATTRIBUTES, RunAnythingGroup.RUN_ANYTHING_MATCHER_BUILDER.fun(pattern).build(), background,
                                           isSelected);
  component.add(textComponent, BorderLayout.WEST);
  textComponent.appendTextPadding(20);
  setupIcon(textComponent, myIcon);
  addDescription(component, isSelected);

  return component;
}
 
Example 4
Source File: InspectionListCellRenderer.java    From consulo with Apache License 2.0 5 votes vote down vote up
public InspectionListCellRenderer() {
  SELECTED = new SimpleTextAttributes(UIUtil.getListSelectionBackground(),
                                      UIUtil.getListSelectionForeground(),
                                      JBColor.RED,
                                      SimpleTextAttributes.STYLE_PLAIN);
  PLAIN = new SimpleTextAttributes(UIUtil.getListBackground(),
                                   UIUtil.getListForeground(),
                                   JBColor.RED,
                                   SimpleTextAttributes.STYLE_PLAIN);
}
 
Example 5
Source File: InspectionListCellRenderer.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public Component getListCellRendererComponent(JList list, Object value, int index, boolean sel, boolean focus) {
  final JPanel panel = new JPanel(new BorderLayout());
  panel.setOpaque(true);

  final Color bg = sel ? UIUtil.getListSelectionBackground() : UIUtil.getListBackground();
  final Color fg = sel ? UIUtil.getListSelectionForeground() : UIUtil.getListForeground();
  panel.setBackground(bg);
  panel.setForeground(fg);

  SimpleTextAttributes attr = sel ? SELECTED : PLAIN;
  if (value instanceof InspectionToolWrapper) {
    final InspectionToolWrapper toolWrapper = (InspectionToolWrapper)value;
    final SimpleColoredComponent c = new SimpleColoredComponent();
    SpeedSearchUtil.appendColoredFragmentForMatcher("  " + toolWrapper.getDisplayName(), c, attr, myMatcher, bg, sel);
    panel.add(c, BorderLayout.WEST);

    final SimpleColoredComponent group = new SimpleColoredComponent();
    SpeedSearchUtil.appendColoredFragmentForMatcher(toolWrapper.getGroupDisplayName() + "  ", group, attr, myMatcher, bg, sel);
    final JPanel right = new JPanel(new BorderLayout());
    right.setBackground(bg);
    right.setForeground(fg);
    right.add(group, BorderLayout.CENTER);
    final JLabel icon = new JLabel(TargetAWT.to(getIcon(toolWrapper)));
    icon.setBackground(bg);
    icon.setForeground(fg);
    right.add(icon, BorderLayout.EAST);
    panel.add(right, BorderLayout.EAST);
  }
  else {
    // E.g. "..." item
    return super.getListCellRendererComponent(list, value, index, sel, focus);
  }

  return panel;
}
 
Example 6
Source File: ManagePackagesDialog.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public Component getListCellRendererComponent(JList list,
                                              Object value,
                                              int index,
                                              boolean isSelected,
                                              boolean cellHasFocus) {
  if (value instanceof RepoPackage) {
    RepoPackage repoPackage = (RepoPackage) value;
    String name = repoPackage.getName();
    if (myCurrentlyInstalling.contains(name)) {
      final String colorCode = UIUtil.isUnderDarcula() ? "589df6" : "0000FF";
      name = "<html><body>" + repoPackage.getName() + " <font color=\"#" + colorCode + "\">(installing)</font></body></html>";
    }
    myNameLabel.setText(name);
    myRepositoryLabel.setText(repoPackage.getRepoUrl());
    Component orig = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
    final Color fg = orig.getForeground();
    myNameLabel.setForeground(myInstalledPackages.contains(name) ? JBColor.BLUE : fg);
  }
  myRepositoryLabel.setForeground(JBColor.GRAY);

  final Color bg;
  if (isSelected) {
    bg = UIUtil.getListSelectionBackground();
  }
  else {
    bg = index % 2 == 1 ? UIUtil.getListBackground() : UIUtil.getDecoratedRowColor();
  }
  myPanel.setBackground(bg);
  myNameLabel.setBackground(bg);
  myRepositoryLabel.setBackground(bg);
  return myPanel;
}
 
Example 7
Source File: PsiElementListCellRenderer.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nullable
protected static Color getBackgroundColor(@Nullable Object value) {
  PsiElement psiElement = NavigationItemListCellRenderer.getPsiElement(value);
  VirtualFile virtualFile = PsiUtilCore.getVirtualFile(psiElement);
  Color fileColor = virtualFile == null ? null : getFileBackgroundColor(psiElement.getProject(), virtualFile);
  return fileColor != null ? fileColor : UIUtil.getListBackground();
}
 
Example 8
Source File: JBColor.java    From consulo with Apache License 2.0 5 votes vote down vote up
public static Color background() {
  return new JBColor(new NotNullProducer<Color>() {
    @Nonnull
    @Override
    public Color produce() {
      return UIUtil.getListBackground();
    }
  });
}
 
Example 9
Source File: GroupedElementsRenderer.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
protected Color getBackground() {
  return UIUtil.getListBackground();
}
 
Example 10
Source File: AbstractNavBarUI.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public Color getBackground(boolean selected, boolean focused) {
  return selected && focused ? UIUtil.getListSelectionBackground(true) : UIUtil.getListBackground();
}
 
Example 11
Source File: RecentProjectPanel.java    From consulo with Apache License 2.0 4 votes vote down vote up
protected Color getListBackground(boolean isSelected, boolean hasFocus) {
  return UIUtil.getListBackground(isSelected);
}
 
Example 12
Source File: JBColor.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
Color getDarkVariant() {
  return UIUtil.getListBackground();
}
 
Example 13
Source File: MacButtonlessScrollbarUI.java    From consulo with Apache License 2.0 4 votes vote down vote up
private static JBColor getTrackBackground() {
  return new JBColor(LightColors.SLIGHTLY_GRAY, UIUtil.getListBackground());
}
 
Example 14
Source File: MacButtonlessScrollbarUI.java    From consulo with Apache License 2.0 4 votes vote down vote up
private static JBColor getTrackBorderColor() {
  return new JBColor(Gray._230, UIUtil.getListBackground());
}
 
Example 15
Source File: IntelliJButtonlessScrollBarUI.java    From consulo with Apache License 2.0 4 votes vote down vote up
public static JBColor getTrackBackground() {
  return new JBColor(LightColors.SLIGHTLY_GRAY, UIUtil.getListBackground());
}
 
Example 16
Source File: IntelliJButtonlessScrollBarUI.java    From consulo with Apache License 2.0 4 votes vote down vote up
public static JBColor getTrackBorderColor() {
  return new JBColor(Gray._230, UIUtil.getListBackground());
}