use of com.intellij.ui.SimpleTextAttributes in project intellij-community by JetBrains.
the class TabInfo method setText.
public TabInfo setText(String text) {
List<SimpleTextAttributes> attributes = myText.getAttributes();
TextAttributes textAttributes = attributes.size() == 1 ? attributes.get(0).toTextAttributes() : null;
TextAttributes defaultAttributes = getDefaultAttributes().toTextAttributes();
if (!myText.toString().equals(text) || !Comparing.equal(textAttributes, defaultAttributes)) {
clearText(false);
append(text, getDefaultAttributes());
}
return this;
}
use of com.intellij.ui.SimpleTextAttributes in project intellij-community by JetBrains.
the class PluginsTableRenderer method getTableCellRendererComponent.
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
if (myPluginDescriptor != null) {
Couple<Color> colors = UIUtil.getCellColors(table, isSelected, row, column);
Color fg = colors.getFirst();
final Color background = colors.getSecond();
Color grayedFg = isSelected ? fg : new JBColor(Gray._130, Gray._120);
myPanel.setBackground(background);
myName.setForeground(fg);
myCategory.setForeground(grayedFg);
myStatus.setForeground(grayedFg);
myLastUpdated.setForeground(grayedFg);
myDownloads.setForeground(grayedFg);
myName.clear();
myName.setOpaque(false);
myCategory.clear();
myCategory.setOpaque(false);
String pluginName = myPluginDescriptor.getName() + " ";
Object query = table.getClientProperty(SpeedSearchSupply.SEARCH_QUERY_KEY);
SimpleTextAttributes attr = new SimpleTextAttributes(UIUtil.getListBackground(isSelected), UIUtil.getListForeground(isSelected), JBColor.RED, SimpleTextAttributes.STYLE_PLAIN);
Matcher matcher = NameUtil.buildMatcher("*" + query, NameUtil.MatchingCaseSensitivity.NONE);
if (query instanceof String) {
SpeedSearchUtil.appendColoredFragmentForMatcher(pluginName, myName, attr, matcher, UIUtil.getTableBackground(isSelected), true);
} else {
myName.append(pluginName);
}
String category = myPluginDescriptor.getCategory() == null ? null : StringUtil.toUpperCase(myPluginDescriptor.getCategory());
if (category != null) {
if (query instanceof String) {
SpeedSearchUtil.appendColoredFragmentForMatcher(category, myCategory, attr, matcher, UIUtil.getTableBackground(isSelected), true);
} else {
myCategory.append(category);
}
} else if (!myPluginsView) {
myCategory.append(AvailablePluginsManagerMain.N_A);
}
myStatus.setIcon(AllIcons.Nodes.Plugin);
if (myPluginDescriptor.isBundled()) {
myCategory.append(" [Bundled]");
myStatus.setIcon(AllIcons.Nodes.PluginJB);
}
String vendor = myPluginDescriptor.getVendor();
if (vendor != null && StringUtil.containsIgnoreCase(vendor, "jetbrains")) {
myStatus.setIcon(AllIcons.Nodes.PluginJB);
}
String downloads = myPluginDescriptor.getDownloads();
if (downloads != null && myPluginDescriptor instanceof PluginNode) {
if (downloads.length() > 3) {
downloads = new DecimalFormat("#,###").format(Integer.parseInt(downloads));
}
myDownloads.setText(downloads);
myRating.setRate(((PluginNode) myPluginDescriptor).getRating());
myLastUpdated.setText(DateFormatUtil.formatBetweenDates(((PluginNode) myPluginDescriptor).getDate(), System.currentTimeMillis()));
}
// plugin state-dependent rendering
PluginId pluginId = myPluginDescriptor.getPluginId();
IdeaPluginDescriptor installed = PluginManager.getPlugin(pluginId);
if (installed != null && ((IdeaPluginDescriptorImpl) installed).isDeleted()) {
// existing plugin uninstalled (both views)
myStatus.setIcon(AllIcons.Nodes.PluginRestart);
if (!isSelected)
myName.setForeground(FileStatus.DELETED.getColor());
myPanel.setToolTipText(IdeBundle.message("plugin.manager.uninstalled.tooltip"));
} else if (ourState.wasInstalled(pluginId)) {
// new plugin installed (both views)
myStatus.setIcon(AllIcons.Nodes.PluginRestart);
if (!isSelected)
myName.setForeground(FileStatus.ADDED.getColor());
myPanel.setToolTipText(IdeBundle.message("plugin.manager.installed.tooltip"));
} else if (ourState.wasUpdated(pluginId)) {
// existing plugin updated (both views)
myStatus.setIcon(AllIcons.Nodes.PluginRestart);
if (!isSelected)
myName.setForeground(FileStatus.ADDED.getColor());
myPanel.setToolTipText(IdeBundle.message("plugin.manager.updated.tooltip"));
} else if (ourState.hasNewerVersion(pluginId)) {
// existing plugin has a newer version (both views)
myStatus.setIcon(AllIcons.Nodes.Pluginobsolete);
if (!isSelected)
myName.setForeground(FileStatus.MODIFIED.getColor());
if (!myPluginsView && installed != null) {
myPanel.setToolTipText(IdeBundle.message("plugin.manager.new.version.tooltip", installed.getVersion()));
} else {
myPanel.setToolTipText(IdeBundle.message("plugin.manager.update.available.tooltip"));
}
} else if (isIncompatible(myPluginDescriptor, table.getModel())) {
// a plugin is incompatible with current installation (both views)
if (!isSelected)
myName.setForeground(JBColor.RED);
myPanel.setToolTipText(whyIncompatible(myPluginDescriptor, table.getModel()));
} else if (!myPluginDescriptor.isEnabled() && myPluginsView) {
// a plugin is disabled (plugins view only)
myStatus.setIcon(IconLoader.getDisabledIcon(myStatus.getIcon()));
}
}
return myPanel;
}
use of com.intellij.ui.SimpleTextAttributes in project intellij-community by JetBrains.
the class RepositoryNode method render.
public void render(@NotNull ColoredTreeCellRenderer renderer, @Nullable String syncEditingText) {
int repoFixedWidth = 120;
SimpleTextAttributes repositoryDetailsTextAttributes = PushLogTreeUtil.addTransparencyIfNeeded(SimpleTextAttributes.REGULAR_ATTRIBUTES, isChecked());
renderer.append(getRepoName(renderer, repoFixedWidth), repositoryDetailsTextAttributes);
renderer.appendTextPadding(repoFixedWidth);
renderer.append(myRepositoryPanel.getSourceName(), repositoryDetailsTextAttributes);
renderer.append(myRepositoryPanel.getArrow(), repositoryDetailsTextAttributes);
PushTargetPanel pushTargetPanel = myRepositoryPanel.getTargetPanel();
pushTargetPanel.render(renderer, renderer.getTree().isPathSelected(TreeUtil.getPathFromRoot(this)), isChecked(), syncEditingText);
}
use of com.intellij.ui.SimpleTextAttributes in project intellij-community by JetBrains.
the class InspectionTreeTailRenderer method appendTailText.
public void appendTailText(InspectionTreeNode node) {
appendText(" ");
final String customizedTailText = node.getCustomizedTailText();
if (customizedTailText != null) {
appendText(" ");
appendText(customizedTailText, SimpleTextAttributes.GRAYED_ATTRIBUTES);
} else {
myItemCounter.clear();
node.visitProblemSeverities(myItemCounter);
if (myItemCounter.size() > MAX_LEVEL_TYPES) {
appendText(InspectionsBundle.message("inspection.problem.descriptor.count", myItemCounter.values().stream().mapToInt(Integer::intValue).sum()) + " ", SimpleTextAttributes.GRAYED_ATTRIBUTES);
} else {
for (Map.Entry<HighlightDisplayLevel, Integer> entry : myItemCounter.entrySet()) {
final HighlightDisplayLevel level = entry.getKey();
final Integer occur = entry.getValue();
SimpleTextAttributes attrs = SimpleTextAttributes.GRAY_ATTRIBUTES;
attrs = attrs.derive(-1, level == HighlightDisplayLevel.ERROR && !myContext.getUIOptions().GROUP_BY_SEVERITY ? TREE_RED : TREE_GRAY, null, null);
appendText(occur + " " + getPresentableName(level, occur > 1) + " ", attrs);
}
}
}
}
use of com.intellij.ui.SimpleTextAttributes in project intellij-community by JetBrains.
the class JavaFramesListRenderer method customizePresentation.
public void customizePresentation(StackFrameDescriptorImpl descriptor, @NotNull ColoredTextContainer component, StackFrameDescriptorImpl selectedDescriptor) {
component.setIcon(descriptor.getIcon());
//final Object selectedValue = list.getSelectedValue();
final boolean shouldHighlightAsRecursive = isOccurrenceOfSelectedFrame(selectedDescriptor, descriptor);
final ValueMarkup markup = descriptor.getValueMarkup();
if (markup != null) {
component.append("[" + markup.getText() + "] ", new SimpleTextAttributes(SimpleTextAttributes.STYLE_BOLD, markup.getColor()));
}
boolean needSeparator = false;
//if (index > 0) {
// final int currentFrameIndex = descriptor.getUiIndex();
// final Object elementAt = list.getModel().getElementAt(index - 1);
// if (elementAt instanceof StackFrameDescriptorImpl) {
// StackFrameDescriptorImpl previousDescriptor = (StackFrameDescriptorImpl)elementAt;
// final int previousFrameIndex = previousDescriptor.getUiIndex();
// needSeparator = (currentFrameIndex - previousFrameIndex != 1);
// }
//}
//if (selected) {
// setBackground(UIUtil.getListSelectionBackground());
//}
//else {
// Color bg = descriptor.getBackgroundColor();
// if (bg == null) bg = UIUtil.getListBackground();
// if (shouldHighlightAsRecursive) bg = myColorScheme.getColor(DebuggerColors.RECURSIVE_CALL_ATTRIBUTES);
// setBackground(bg);
//}
//
//if (needSeparator) {
// final MatteBorder border = BorderFactory.createMatteBorder(1, 0, 0, 0, JBColor.GRAY);
// setBorder(border);
//}
//else {
// setBorder(null);
//}
final String label = descriptor.getLabel();
final int openingBrace = label.indexOf("{");
final int closingBrace = (openingBrace < 0) ? -1 : label.indexOf("}");
final SimpleTextAttributes attributes = getAttributes(descriptor);
if (openingBrace < 0 || closingBrace < 0) {
component.append(label, attributes);
} else {
component.append(label.substring(0, openingBrace - 1), attributes);
component.append(" (" + label.substring(openingBrace + 1, closingBrace) + ")", SimpleTextAttributes.GRAY_ITALIC_ATTRIBUTES);
component.append(label.substring(closingBrace + 1, label.length()), attributes);
if (shouldHighlightAsRecursive && descriptor.isRecursiveCall()) {
component.append(" [" + descriptor.getOccurrenceIndex() + "]", SimpleTextAttributes.REGULAR_BOLD_ATTRIBUTES);
}
}
}
Aggregations