Java Code Examples for com.intellij.ui.speedSearch.SpeedSearchUtil#applySpeedSearchHighlighting()

The following examples show how to use com.intellij.ui.speedSearch.SpeedSearchUtil#applySpeedSearchHighlighting() . 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: Switcher.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
protected void customizeCellRenderer(@Nonnull JList<? extends FileInfo> list, FileInfo value, int index, boolean selected, boolean hasFocus) {
  Project project = mySwitcherPanel.project;
  VirtualFile virtualFile = value.getFirst();
  String renderedName = value.getNameForRendering();
  setIcon(VfsIconUtil.getIcon(virtualFile, Iconable.ICON_FLAG_READ_STATUS, project));

  FileStatus fileStatus = FileStatusManager.getInstance(project).getStatus(virtualFile);
  open = FileEditorManager.getInstance(project).isFileOpen(virtualFile);

  boolean hasProblem = WolfTheProblemSolver.getInstance(project).isProblemFile(virtualFile);
  TextAttributes attributes = new TextAttributes(fileStatus.getColor(), null, hasProblem ? JBColor.red : null, EffectType.WAVE_UNDERSCORE, Font.PLAIN);
  append(renderedName, SimpleTextAttributes.fromTextAttributes(attributes));

  // calc color the same way editor tabs do this, i.e. including EPs
  Color color = EditorTabPresentationUtil.getFileBackgroundColor(project, virtualFile);

  if (!selected && color != null) {
    setBackground(color);
  }
  SpeedSearchUtil.applySpeedSearchHighlighting(mySwitcherPanel, this, false, selected);

  IdeDocumentHistoryImpl.appendTimestamp(project, this, virtualFile);
}
 
Example 2
Source File: ConnectionTreeCellRenderer.java    From p4ic4idea with Apache License 2.0 5 votes vote down vote up
@Override
public void customizeCellRenderer(@NotNull JTree tree, Object value,
        boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) {
    if (value instanceof DefaultMutableTreeNode) {
        Object other = ((DefaultMutableTreeNode) value).getUserObject();
        if (other != null) {
            value = other;
        }
    }
    if (value instanceof ClientConfigRoot) {
        renderClientConfigRoot((ClientConfigRoot) value);
    } else if (value instanceof P4ServerName) {
        renderP4ServerName((P4ServerName) value);
    } else if (value instanceof ClientServerRef) {
        renderClientServerRef((ClientServerRef) value);
    } else if (value instanceof PendingParentNode) {
        renderPendingParentNode((PendingParentNode) value);
    } else if (value instanceof ActionChoice) {
        renderActionChoice((ActionChoice) value);
    } else if (value instanceof FilePath) {
        renderFilePath((FilePath) value);
    } else if (value instanceof P4CommandRunner.ResultError) {
        renderResultError((P4CommandRunner.ResultError) value);
    } else {
        renderError(value);
    }

    SpeedSearchUtil.applySpeedSearchHighlighting(tree, this, true, selected);
}
 
Example 3
Source File: VcsLogGraphTable.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
protected void customizeCellRenderer(JTable table, Object value, boolean selected, boolean hasFocus, int row, int column) {
  setBorder(null);
  if (value == null) {
    return;
  }
  append(value.toString(), applyHighlighters(this, row, column, hasFocus, selected));
  SpeedSearchUtil.applySpeedSearchHighlighting(table, this, false, selected);
}
 
Example 4
Source File: ChangesBrowserNodeRenderer.java    From consulo with Apache License 2.0 5 votes vote down vote up
public void customizeCellRenderer(@Nonnull JTree tree,
                                  Object value,
                                  boolean selected,
                                  boolean expanded,
                                  boolean leaf,
                                  int row,
                                  boolean hasFocus) {
  ChangesBrowserNode node = (ChangesBrowserNode)value;
  node.render(this, selected, expanded, hasFocus);
  SpeedSearchUtil.applySpeedSearchHighlighting(tree, this, true, selected);
}
 
Example 5
Source File: P4HistoryProvider.java    From p4ic4idea with Apache License 2.0 4 votes vote down vote up
protected void customizeCellRenderer(JTable table, Object value, boolean selected, boolean hasFocus, int row, int column) {
    this.setOpaque(selected);
    this.append(value == null ? "?" : value.toString());
    SpeedSearchUtil.applySpeedSearchHighlighting(table, this, false, selected);
}
 
Example 6
Source File: GraphCommitCellRenderer.java    From consulo with Apache License 2.0 4 votes vote down vote up
private void appendText(@Nonnull GraphCommitCell cell, @Nonnull SimpleTextAttributes style, boolean isSelected) {
  myIssueLinkRenderer.appendTextWithLinks(StringUtil.replace(cell.getText(), "\t", " ").trim(), style);
  SpeedSearchUtil.applySpeedSearchHighlighting(myGraphTable, this, false, isSelected);
}
 
Example 7
Source File: RecentLocationsRenderer.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nonnull
private static SimpleColoredComponent createTitleTextComponent(@Nonnull Project project,
                                                               @Nonnull JList<? extends RecentLocationItem> list,
                                                               @Nonnull SpeedSearch speedSearch,
                                                               @Nonnull IdeDocumentHistoryImpl.PlaceInfo placeInfo,
                                                               @Nonnull EditorColorsScheme colorsScheme,
                                                               @Nullable String breadcrumbText,
                                                               boolean selected) {
  SimpleColoredComponent titleTextComponent = new SimpleColoredComponent();

  String fileName = placeInfo.getFile().getName();
  String text = fileName;
  titleTextComponent.append(fileName, createFileNameTextAttributes(colorsScheme, selected));

  if (StringUtil.isNotEmpty(breadcrumbText) && !StringUtil.equals(breadcrumbText, fileName)) {
    text += " " + breadcrumbText;
    titleTextComponent.append("  ");
    titleTextComponent.append(breadcrumbText, createBreadcrumbsTextAttributes(colorsScheme, selected));
  }

  Image icon = fetchIcon(project, placeInfo);

  if (icon != null) {
    titleTextComponent.setIcon(icon);
    titleTextComponent.setIconTextGap(4);
  }

  titleTextComponent.setBorder(JBUI.Borders.empty());

  if (!SystemInfo.isWindows) {
    titleTextComponent.setFont(FontUtil.minusOne(UIUtil.getLabelFont()));
  }

  if (speedSearch.matchingFragments(text) != null) {
    SpeedSearchUtil.applySpeedSearchHighlighting(list, titleTextComponent, false, selected);
  }

  long timeStamp = placeInfo.getTimeStamp();
  if (UISettings.getInstance().getShowInplaceComments() && Registry.is("show.last.visited.timestamps") && timeStamp != -1) {
    titleTextComponent.append(" " + DateFormatUtil.formatPrettyDateTime(timeStamp), SimpleTextAttributes.GRAYED_SMALL_ATTRIBUTES);
  }

  return titleTextComponent;
}
 
Example 8
Source File: UiInspectorAction.java    From consulo with Apache License 2.0 4 votes vote down vote up
@RequiredUIAccess
@Override
public void customizeCellRenderer(@Nonnull JTree tree,
                                  Object value,
                                  boolean selected,
                                  boolean expanded,
                                  boolean leaf,
                                  int row,
                                  boolean hasFocus) {
  Color foreground = selected ? UIUtil.getTreeSelectionForeground() : UIUtil.getTreeForeground();
  Color background = selected ? UIUtil.getTreeSelectionBackground() : null;
  if (value instanceof HierarchyTree.ComponentNode) {
    HierarchyTree.ComponentNode componentNode = (HierarchyTree.ComponentNode)value;
    Component component = componentNode.getComponent();

    if (!selected) {
      if (!component.isVisible()) {
        foreground = JBColor.GRAY;
      }
      else if (component.getWidth() == 0 || component.getHeight() == 0) {
        foreground = new JBColor(new Color(128, 10, 0), JBColor.BLUE);
      }
      else if (component.getPreferredSize() != null &&
               (component.getSize().width < component.getPreferredSize().width
                || component.getSize().height < component.getPreferredSize().height)) {
        foreground = JBColor.BLUE;
      }

      if (myInitialSelection == componentNode.getComponent()) {
        background = new Color(31, 128, 8, 58);
      }
    }
    append(getComponentName(component));
    append(": " + RectangleRenderer.toString(component.getBounds()), SimpleTextAttributes.GRAYED_ATTRIBUTES);
    if (component.isOpaque()) {
      append(", opaque", SimpleTextAttributes.GRAYED_ATTRIBUTES);
    }
    if (component.isDoubleBuffered()) {
      append(", double-buffered", SimpleTextAttributes.GRAYED_ATTRIBUTES);
    }
    componentNode.setText(toString());
    setIcon(createColorIcon(component.getForeground(), component.getBackground()));
  }
  if (value instanceof HierarchyTree.ClickInfoNode) {
    append(value.toString());
    setIcon(AllIcons.Ide.Rating);
  }

  setForeground(foreground);
  setBackground(background);

  SpeedSearchUtil.applySpeedSearchHighlighting(tree, this, false, selected);
}