@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 SearchResultElement) { SearchResultElement element = (SearchResultElement) 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); append(" " + stringKeyText, new SimpleTextAttributes(Font.PLAIN, JBColor.GRAY)); } setBackground(selected ? UIUtil.getListSelectionBackground() : bgColor); }
@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); }
protected void customizeCellRenderer(JList list, Object value, int index, boolean selected, boolean hasFocus) { if (value instanceof FileInfo) { Project project = mySwitcherPanel.project; VirtualFile virtualFile = ((FileInfo)value).getFirst(); String renderedName = ((FileInfo)value).getNameForRendering(); setIcon(IconUtil.getIcon(virtualFile, Iconable.ICON_FLAG_READ_STATUS, project)); FileStatus fileStatus = FileStatusManager.getInstance(project).getStatus(virtualFile); open = FileEditorManager.getInstance(project).isFileOpen(virtualFile); TextAttributes attributes = new TextAttributes(fileStatus.getColor(), null, null, EffectType.LINE_UNDERSCORE, Font.PLAIN); append(renderedName, SimpleTextAttributes.fromTextAttributes(attributes)); // calc color the same way editor tabs do this, i.e. including EPs Color color = EditorTabbedContainer.calcTabColor(project, virtualFile); if (!selected && color != null) { setBackground(color); } SpeedSearchUtil.applySpeedSearchHighlighting(mySwitcherPanel, this, false, selected); } }
private void renderItemName(LookupElement item, Color foreground, boolean selected, @SimpleTextAttributes.StyleAttributeConstant int style, String name, final SimpleColoredComponent nameComponent) { final SimpleTextAttributes base = new SimpleTextAttributes(style, foreground); final String prefix = item instanceof EmptyLookupItem ? "" : myLookup.itemPattern(item); if (prefix.length() > 0) { Iterable<TextRange> ranges = getMatchingFragments(prefix, name); if (ranges != null) { SimpleTextAttributes highlighted = new SimpleTextAttributes(style, selected ? SELECTED_PREFIX_FOREGROUND_COLOR : PREFIX_FOREGROUND_COLOR); SpeedSearchUtil.appendColoredFragments(nameComponent, name, ranges, base, highlighted); return; } } nameComponent.append(name, base); }
private static void appendWithColoredMatches(SimpleColoredComponent nameComponent, String name, String pattern, Color fg, boolean selected) { SimpleTextAttributes plain = new SimpleTextAttributes(STYLE_PLAIN, fg); SimpleTextAttributes highlighted = new SimpleTextAttributes(null, fg, null, STYLE_SEARCH_MATCH); List<TextRange> fragments = ContainerUtil.newArrayList(); if (selected) { int matchStart = StringUtil.indexOfIgnoreCase(name, pattern, 0); if (matchStart >= 0) { fragments.add(TextRange.from(matchStart, pattern.length())); } } SpeedSearchUtil.appendColoredFragments(nameComponent, name, fragments, plain, highlighted); }
@Override protected void customizeCellRenderer(@Nonnull JList list, Object value, int index, boolean selected, boolean hasFocus) { if (value instanceof FileInfo) { Project project = mySwitcherPanel.project; VirtualFile virtualFile = ((FileInfo)value).getFirst(); String renderedName = ((FileInfo)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); TextAttributes attributes = new TextAttributes(fileStatus.getColor(), null, null, EffectType.LINE_UNDERSCORE, Font.PLAIN); append(renderedName, SimpleTextAttributes.fromTextAttributes(attributes)); // calc color the same way editor tabs do this, i.e. including EPs Color color = EditorTabbedContainer.calcTabColor(project, virtualFile); if (!selected && color != null) { setBackground(color); } SpeedSearchUtil.applySpeedSearchHighlighting(mySwitcherPanel, this, false, selected); } }
@Override protected void addText(@NotNull Object value, boolean isSelected, int row) { String presentation = ((ReferenceType) value).name(); append(" "); if(isSelected) { FList<TextRange> textRanges = myMatcher.matchingFragments(presentation); if(textRanges != null) { SimpleTextAttributes attributes = new SimpleTextAttributes(getBackground(), getForeground(), null, SimpleTextAttributes.STYLE_SEARCH_MATCH); SpeedSearchUtil.appendColoredFragments(this, presentation, textRanges, SimpleTextAttributes.REGULAR_ATTRIBUTES, attributes); } } else { append(String.format("%s", presentation), SimpleTextAttributes.REGULAR_ATTRIBUTES); } }
public void customizeCellRenderer(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) { AbstractTreeNode treeNode = (AbstractTreeNode)value; append(treeNode.getText(), treeNode.getAttributes()); final String errorText = treeNode.getErrorText(); if (errorText != null) { append(" - ", SimpleTextAttributes.REGULAR_ATTRIBUTES); append("Error: ", SimpleTextAttributes.ERROR_ATTRIBUTES); append(errorText, SimpleTextAttributes.REGULAR_ATTRIBUTES); } setIcon(treeNode.getIcon(false)); SpeedSearchUtil.applySpeedSearchHighlighting(tree, this, true, selected); }
public void customizeCellRenderer(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); }
@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(getIcon(toolWrapper)); icon.setBackground(bg); icon.setForeground(fg); right.add(icon, BorderLayout.EAST); panel.add(right, BorderLayout.EAST); } else { // E.g. "..." item return value == ChooseByNameBase.NON_PREFIX_SEPARATOR ? ChooseByNameBase.renderNonPrefixSeparatorComponent(UIUtil.getListBackground()) : super.getListCellRendererComponent(list, value, index, sel, focus); } return panel; }
@Override public Component getListCellRendererComponent(JList jList, Object value, int i, boolean sel, boolean focus) { JPanel jPanel = new JPanel(new BorderLayout()); jPanel.setOpaque(true); final Color bg = sel ? UIUtil.getListSelectionBackground() : UIUtil.getListBackground(); final Color fg = sel ? UIUtil.getListSelectionForeground() : UIUtil.getListForeground(); jPanel.setBackground(bg); jPanel.setForeground(fg); SimpleTextAttributes attr = sel ? SELECTED : PLAIN; if (value instanceof EmberItem) { EmberItem item = (EmberItem) value; final SimpleColoredComponent c = new SimpleColoredComponent(); SpeedSearchUtil.appendColoredFragmentForMatcher(" " + item.getItemName(), c, attr, null, bg, sel); jPanel.add(c, BorderLayout.WEST); final SimpleColoredComponent group = new SimpleColoredComponent(); SpeedSearchUtil.appendColoredFragmentForMatcher(item.getItemType() + " ", group, attr, null, bg, sel); final JPanel right = new JPanel(new BorderLayout()); right.setBackground(bg); right.setForeground(fg); right.add(group, BorderLayout.CENTER); jPanel.add(right, BorderLayout.EAST); } else { // E.g. "..." item return ChooseByNameBase.renderNonPrefixSeparatorComponent(UIUtil.getListBackground()); } return jPanel; }
@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); }
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); }
@Override public void renderTreeNode(SimpleColoredComponent component, JTree tree) { SpeedSearchUtil.appendFragmentsForSpeedSearch(tree, getText(), SimpleTextAttributes.REGULAR_ATTRIBUTES, false, component); component.setIcon(myParameter.getIcon(0)); }
@Override public void customizeCellRenderer(@NotNull 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(); Class<?> clazz0 = component.getClass(); Class<?> clazz = clazz0.isAnonymousClass() ? clazz0.getSuperclass() : clazz0; String name = component.getName(); if (!selected) { if (!component.isVisible()) { foreground = JBColor.GRAY; } else if (component.getWidth() == 0 || component.getHeight() == 0) { foreground = new Color(128, 10, 0); } else if (component.getPreferredSize() != null && (component.getSize().width < component.getPreferredSize().width || component.getSize().height < component.getPreferredSize().height)) { foreground = PlatformColors.BLUE; } if (myInitialSelection == componentNode.getComponent()) { background = new Color(31, 128, 8, 58); } } append(clazz.getSimpleName()); if (StringUtil.isNotEmpty(name)) { append(" \"" + name + "\""); } 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(new TwoColorsIcon(11, component.getForeground(), component.getBackground())); } setForeground(foreground); setBackground(background); SpeedSearchUtil.applySpeedSearchHighlighting(tree, this, false, selected); }
@Override public void renderTreeNode(SimpleColoredComponent component, JTree tree) { SpeedSearchUtil.appendFragmentsForSpeedSearch(tree, getText(), getTextAttributes(tree), false, component); component.setIcon(myIcon); }
protected GitRebaseEditor(@NotNull Project project, @NotNull VirtualFile gitRoot, @NotNull List<GitRebaseEntry> entries) throws IOException { super(project, true); myProject = project; myRoot = gitRoot; setTitle(GitBundle.getString("rebase.editor.title")); setOKButtonText(GitBundle.getString("rebase.editor.button")); myTableModel = new MyTableModel(entries); myCommitsTable = new JBTable(myTableModel); myCommitsTable.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION); myCommitsTable.setIntercellSpacing(JBUI.emptySize()); final JComboBox editorComboBox = new ComboBox(); for (Object option : GitRebaseEntry.Action.values()) { editorComboBox.addItem(option); } TableColumn actionColumn = myCommitsTable.getColumnModel().getColumn(MyTableModel.ACTION_COLUMN); actionColumn.setCellEditor(new DefaultCellEditor(editorComboBox)); actionColumn.setCellRenderer(ComboBoxTableCellRenderer.INSTANCE); myCommitsTable.setDefaultRenderer(String.class, new ColoredTableCellRenderer() { @Override protected void customizeCellRenderer(JTable table, Object value, boolean selected, boolean hasFocus, int row, int column) { if (value != null) { append(value.toString()); SpeedSearchUtil.applySpeedSearchHighlighting(myCommitsTable, this, true, selected); } } }); myTableModel.addTableModelListener(new TableModelListener() { public void tableChanged(final TableModelEvent e) { validateFields(); } }); installSpeedSearch(); myCopyProvider = new MyCopyProvider(); adjustColumnWidth(0); adjustColumnWidth(1); init(); }
@Override protected void customizeCellRenderer(final JList list, final Object value, final int index, final boolean selected, final boolean hasFocus) { // Fix GTK background if (UIUtil.isUnderGTKLookAndFeel()){ final Color background = selected ? UIUtil.getTreeSelectionBackground() : UIUtil.getTreeTextBackground(); UIUtil.changeBackGround(this, background); } Color color = UIUtil.getListForeground(); SimpleTextAttributes attributes = null; String locationString = null; setBorder(BorderFactory.createEmptyBorder(1, 0, 1, 0)); // for separator, see below if (value instanceof NodeDescriptor) { final NodeDescriptor descriptor = (NodeDescriptor)value; setIcon(descriptor.getIcon()); final Color elementColor = descriptor.getColor(); if (elementColor != null) { color = elementColor; } if (descriptor instanceof AbstractTreeNode) { final AbstractTreeNode treeNode = (AbstractTreeNode)descriptor; final TextAttributesKey attributesKey = treeNode.getAttributesKey(); if (attributesKey != null) { final TextAttributes textAttributes = EditorColorsManager.getInstance().getGlobalScheme().getAttributes(attributesKey); if (textAttributes != null) attributes = SimpleTextAttributes.fromTextAttributes(textAttributes); } locationString = treeNode.getLocationString(); final PresentationData presentation = treeNode.getPresentation(); if (presentation.hasSeparatorAbove() && !selected) { setBorder(BorderFactory.createCompoundBorder(BorderFactory.createMatteBorder(1, 0, 0, 0, GroupedElementsRenderer.POPUP_SEPARATOR_FOREGROUND), BorderFactory.createEmptyBorder(0, 0, 1, 0))); } } } if(attributes == null) attributes = new SimpleTextAttributes(Font.PLAIN, color); final String text = value.toString(); if (myCommanderPanel.isEnableSearchHighlighting()) { JList list1 = myCommanderPanel.getList(); if (list1 != null) { SpeedSearchUtil.appendFragmentsForSpeedSearch(list1, text, attributes, selected, this); } } else { append(text != null ? text : "", attributes); } if (locationString != null && locationString.length() > 0) { append(" (" + locationString + ")", SimpleTextAttributes.GRAY_ATTRIBUTES); } }
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); }
@RequiredDispatchThread @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 = PlatformColors.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); }
@Override public void renderTreeNode(SimpleColoredComponent component, JTree tree) { SpeedSearchUtil.appendFragmentsForSpeedSearch(tree, getText(), SimpleTextAttributes.REGULAR_ATTRIBUTES, false, component); component.setIcon(IconDescriptorUpdaters.getIcon(myParameter, 0)); }