use of com.intellij.ui.SimpleColoredComponent in project intellij-community by JetBrains.
the class ShortcutDialog method setShortcut.
void setShortcut(T shortcut) {
if (!equal(shortcut, myShortcutPanel.getShortcut())) {
myShortcutPanel.setShortcut(shortcut);
}
myConflictsContainer.removeAll();
if (shortcut != null) {
for (String id : getConflicts(shortcut, myActionId, myKeymap)) {
String path = id.equals(myActionId) ? null : getActionPath(id);
if (path != null) {
SimpleColoredComponent component = new SimpleColoredComponent();
fill(component, id, path);
myConflictsContainer.add(VerticalLayout.TOP, component);
}
}
myConflictsPanel.revalidate();
myConflictsPanel.repaint();
}
myConflictsPanel.setVisible(0 < myConflictsContainer.getComponentCount());
}
use of com.intellij.ui.SimpleColoredComponent in project intellij-community by JetBrains.
the class XValueHint method evaluateAndShowHint.
@Override
protected void evaluateAndShowHint() {
myEvaluator.evaluate(myExpression, new XEvaluationCallbackBase() {
@Override
public void evaluated(@NotNull final XValue result) {
result.computePresentation(new XValueNodePresentationConfigurator.ConfigurableXValueNodeImpl() {
private XFullValueEvaluator myFullValueEvaluator;
private boolean myShown = false;
@Override
public void applyPresentation(@Nullable Icon icon, @NotNull XValuePresentation valuePresenter, boolean hasChildren) {
if (isHintHidden()) {
return;
}
SimpleColoredText text = new SimpleColoredText();
text.append(StringUtil.trimMiddle(myValueName, 200), XDebuggerUIConstants.VALUE_NAME_ATTRIBUTES);
XValueNodeImpl.buildText(valuePresenter, text);
if (!hasChildren) {
SimpleColoredComponent component = HintUtil.createInformationComponent();
text.appendToComponent(component);
if (myFullValueEvaluator != null) {
component.append(myFullValueEvaluator.getLinkText(), XDebuggerTreeNodeHyperlink.TEXT_ATTRIBUTES, (Consumer<MouseEvent>) event -> DebuggerUIUtil.showValuePopup(myFullValueEvaluator, event, getProject(), getEditor()));
LinkMouseListenerBase.installSingleTagOn(component);
}
showHint(component);
} else if (getType() == ValueHintType.MOUSE_CLICK_HINT) {
if (!myShown) {
showTree(result);
}
} else {
if (getType() == ValueHintType.MOUSE_OVER_HINT) {
text.insert(0, "(" + KeymapUtil.getFirstKeyboardShortcutText("ShowErrorDescription") + ") ", SimpleTextAttributes.GRAYED_ATTRIBUTES);
}
JComponent component = createExpandableHintComponent(text, () -> showTree(result));
showHint(component);
}
myShown = true;
}
@Override
public void setFullValueEvaluator(@NotNull XFullValueEvaluator fullValueEvaluator) {
myFullValueEvaluator = fullValueEvaluator;
}
@Override
public boolean isObsolete() {
return isHintHidden();
}
}, XValuePlace.TOOLTIP);
}
@Override
public void errorOccurred(@NotNull final String errorMessage) {
if (getType() == ValueHintType.MOUSE_CLICK_HINT) {
ApplicationManager.getApplication().invokeLater(() -> showHint(HintUtil.createErrorLabel(errorMessage)));
}
LOG.debug("Cannot evaluate '" + myExpression + "':" + errorMessage);
}
}, myExpressionPosition);
}
use of com.intellij.ui.SimpleColoredComponent in project intellij-community by JetBrains.
the class SimpleColoredComponentLinkMouseListener method tryGetTag.
@Override
protected Object tryGetTag(@NotNull MouseEvent e, @NotNull JTable table, int row, int column) {
TableCellRenderer cellRenderer = table.getCellRenderer(row, column);
Component component = cellRenderer.getTableCellRendererComponent(table, table.getValueAt(row, column), false, false, row, column);
if (component instanceof SimpleColoredComponent) {
Rectangle rc = table.getCellRect(row, column, false);
return ((SimpleColoredComponent) component).getFragmentTagAt(e.getX() - rc.x);
}
return super.tryGetTag(e, table, row, column);
}
use of com.intellij.ui.SimpleColoredComponent in project intellij-community by JetBrains.
the class AbstractFindUsagesDialog method createNorthPanel.
@Override
protected JComponent createNorthPanel() {
JPanel panel = new JPanel(new GridBagLayout());
GridBagConstraints gbConstraints = new GridBagConstraints();
gbConstraints.insets = new Insets(0, 0, UIUtil.DEFAULT_VGAP, 0);
gbConstraints.fill = GridBagConstraints.NONE;
gbConstraints.weightx = 1;
gbConstraints.weighty = 1;
gbConstraints.anchor = GridBagConstraints.WEST;
final SimpleColoredComponent coloredComponent = new SimpleColoredComponent();
coloredComponent.setIpad(new Insets(0, 0, 0, 0));
coloredComponent.setMyBorder(null);
configureLabelComponent(coloredComponent);
panel.add(coloredComponent, gbConstraints);
return panel;
}
use of com.intellij.ui.SimpleColoredComponent in project intellij-community by JetBrains.
the class ShowUsagesTableCellRenderer method appendGroupText.
private void appendGroupText(JTable table, final GroupNode node, JPanel panel, Color fileBgColor, boolean isSelected) {
UsageGroup group = node == null ? null : node.getGroup();
if (group == null)
return;
GroupNode parentGroup = (GroupNode) node.getParent();
appendGroupText(table, parentGroup, panel, fileBgColor, isSelected);
if (node.canNavigateToSource()) {
SimpleColoredComponent renderer = new SimpleColoredComponent();
renderer.setIcon(group.getIcon(false));
SimpleTextAttributes attributes = deriveAttributesWithColor(SimpleTextAttributes.REGULAR_ATTRIBUTES, fileBgColor);
renderer.append(group.getText(myUsageView), attributes);
renderer.setBorder(null);
SpeedSearchUtil.applySpeedSearchHighlighting(table, renderer, false, isSelected);
panel.add(renderer);
}
}
Aggregations