Java Code Examples for com.intellij.ui.SimpleColoredComponent#append()
The following examples show how to use
com.intellij.ui.SimpleColoredComponent#append() .
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: VirtualFileCellRenderer.java From intellij-reference-diagram with Apache License 2.0 | 6 votes |
public static void render(SimpleColoredComponent renderer, FileFQNReference ref, Project project) { VirtualFile virtualFile = ref.getPsiElement().getContainingFile().getVirtualFile(); PsiJavaFile psiFile = (PsiJavaFile) PsiManager.getInstance(project).findFile(virtualFile); int style = SimpleTextAttributes.STYLE_PLAIN; Color color = SimpleTextAttributes.LINK_BOLD_ATTRIBUTES.getFgColor(); Icon icon = getIcon(virtualFile); String comment = null; if (!virtualFile.isValid()) style |= SimpleTextAttributes.STYLE_STRIKEOUT; boolean fileHidden = isFileHidden(virtualFile); if (fileHidden) { color = HIDDEN; } ; renderer.setIcon(!fileHidden || icon == null ? icon : getTransparentIcon(icon)); SimpleTextAttributes attributes = new SimpleTextAttributes(style, color); renderer.append(psiFile.getPackageName() + "." + psiFile.getName(), attributes); renderer.append(" " + ref.toUsageString(), new SimpleTextAttributes(SimpleTextAttributes.STYLE_PLAIN, SimpleTextAttributes.GRAY_ATTRIBUTES.getFgColor())); if (comment != null) renderer.append(comment, attributes); }
Example 2
Source File: SetValueInplaceEditor.java From consulo with Apache License 2.0 | 6 votes |
private SetValueInplaceEditor(final XValueNodeImpl node, @Nonnull final String nodeName) { super(node, "setValue"); myValueNode = node; myModifier = myValueNode.getValueContainer().getModifier(); SimpleColoredComponent nameLabel = new SimpleColoredComponent(); nameLabel.getIpad().right = 0; nameLabel.getIpad().left = 0; nameLabel.setIcon(myNode.getIcon()); nameLabel.append(nodeName, XDebuggerUIConstants.VALUE_NAME_ATTRIBUTES); XValuePresentation presentation = node.getValuePresentation(); if (presentation != null) { XValuePresentationUtil.appendSeparator(nameLabel, presentation.getSeparator()); } myNameOffset = nameLabel.getPreferredSize().width; myEditorPanel = JBUI.Panels.simplePanel(myExpressionEditor.getComponent()); }
Example 3
Source File: ShowUsagesTableCellRenderer.java From consulo with Apache License 2.0 | 6 votes |
private void appendGroupText(final GroupNode node, JPanel panel, Color fileBgColor) { UsageGroup group = node == null ? null : node.getGroup(); if (group == null) return; GroupNode parentGroup = (GroupNode)node.getParent(); appendGroupText(parentGroup, panel, fileBgColor); if (node.canNavigateToSource()) { SimpleColoredComponent renderer = new SimpleColoredComponent(); renderer.setIcon(group.getIcon()); SimpleTextAttributes attributes = deriveAttributesWithColor(SimpleTextAttributes.REGULAR_ATTRIBUTES, fileBgColor); renderer.append(group.getText(myUsageView), attributes); renderer.append(" ", attributes); renderer.setIpad(new Insets(0,0,0,0)); renderer.setBorder(null); panel.add(renderer); } }
Example 4
Source File: SpeedSearchUtil.java From consulo with Apache License 2.0 | 6 votes |
public static void appendColoredFragmentForMatcher(@Nonnull String text, SimpleColoredComponent component, @Nonnull final SimpleTextAttributes attributes, Matcher matcher, Color selectedBg, boolean selected) { if (!(matcher instanceof MinusculeMatcher) || (Registry.is("ide.highlight.match.in.selected.only") && !selected)) { component.append(text, attributes); return; } final Iterable<TextRange> iterable = ((MinusculeMatcher)matcher).matchingFragments(text); if (iterable != null) { final Color fg = attributes.getFgColor(); final int style = attributes.getStyle(); final SimpleTextAttributes plain = new SimpleTextAttributes(style, fg); final SimpleTextAttributes highlighted = new SimpleTextAttributes(selectedBg, fg, null, style | SimpleTextAttributes.STYLE_SEARCH_MATCH); appendColoredFragments(component, text, iterable, plain, highlighted); } else { component.append(text, attributes); } }
Example 5
Source File: ShowUsagesTableCellRenderer.java From otto-intellij-plugin with Apache License 2.0 | 6 votes |
private void appendGroupText(final GroupNode node, JPanel panel, Color fileBgColor) { UsageGroup group = node == null ? null : node.getGroup(); if (group == null) return; GroupNode parentGroup = (GroupNode)node.getParent(); appendGroupText(parentGroup, panel, fileBgColor); 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.append(" ", attributes); renderer.setIpad(new Insets(0,0,0,0)); renderer.setBorder(null); panel.add(renderer); } }
Example 6
Source File: RunAnythingHelpItem.java From consulo with Apache License 2.0 | 6 votes |
private static void parseAndApplyStyleToParameters(@Nonnull SimpleColoredComponent component, @Nonnull String placeholder) { int lt = StringUtil.indexOf(placeholder, "<"); if (lt == -1) { component.append(placeholder); return; } int gt = StringUtil.indexOf(placeholder, ">", lt); //appends leading component.append(gt > -1 ? placeholder.substring(0, lt) : placeholder); while (lt > -1 && gt > -1) { component.append(placeholder.substring(lt, gt + 1), SimpleTextAttributes.GRAY_ATTRIBUTES); lt = StringUtil.indexOf(placeholder, "<", gt); if (lt == -1) { component.append(placeholder.substring(gt + 1)); break; } component.append(placeholder.substring(gt + 1, lt)); gt = StringUtil.indexOf(placeholder, ">", lt); } }
Example 7
Source File: UnknownFileTypeDiffRequest.java From consulo with Apache License 2.0 | 6 votes |
@Nonnull @Override public JComponent getComponent(@Nonnull final DiffContext context) { final SimpleColoredComponent label = new SimpleColoredComponent(); label.setTextAlign(SwingConstants.CENTER); label.append("Can't show diff for unknown file type. ", new SimpleTextAttributes(SimpleTextAttributes.STYLE_PLAIN, UIUtil.getInactiveTextColor())); if (myFileName != null) { label.append("Associate", SimpleTextAttributes.LINK_ATTRIBUTES, new Runnable() { @Override public void run() { FileType type = FileTypeChooser.associateFileType(myFileName); if (type != null) onSuccess(context); } }); LinkMouseListenerBase.installSingleTagOn(label); } return JBUI.Panels.simplePanel(label).withBorder(JBUI.Borders.empty(5)); }
Example 8
Source File: ShowUsagesTableCellRenderer.java From dagger-intellij-plugin with Apache License 2.0 | 6 votes |
private void appendGroupText(final GroupNode node, JPanel panel, Color fileBgColor) { UsageGroup group = node == null ? null : node.getGroup(); if (group == null) return; GroupNode parentGroup = (GroupNode) node.getParent(); appendGroupText(parentGroup, panel, fileBgColor); 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.append(" ", attributes); renderer.setIpad(new Insets(0, 0, 0, 0)); renderer.setBorder(null); panel.add(renderer); } }
Example 9
Source File: BaseTextCommentCellAppearance.java From consulo with Apache License 2.0 | 5 votes |
public void customize(@Nonnull final SimpleColoredComponent component) { component.setIcon(getIcon()); component.append(getPrimaryText(), myTextAttributes); final String secondaryText = getSecondaryText(); if (!StringUtil.isEmptyOrSpaces(secondaryText)) { component.append(" (" + secondaryText + ")", myCommentAttributes); } }
Example 10
Source File: RunAnythingItemBase.java From consulo with Apache License 2.0 | 5 votes |
protected static void appendDescription(@Nonnull SimpleColoredComponent component, @Nullable String description, @Nonnull Color foreground) { if (description != null) { SimpleTextAttributes smallAttributes = new SimpleTextAttributes(STYLE_SMALLER, foreground); component.append(StringUtil.shortenTextWithEllipsis(description, 40, 0), smallAttributes); component.appendTextPadding(660, SwingConstants.RIGHT); } }
Example 11
Source File: RunAnythingItemBase.java From consulo with Apache License 2.0 | 5 votes |
private void addDescription(@Nonnull JPanel panel, boolean isSelected) { String description = getDescription(); if (description == null) { return; } SimpleColoredComponent descriptionComponent = new SimpleColoredComponent(); descriptionComponent.append(description, getDescriptionAttributes(isSelected)); descriptionComponent.setTextAlign(SwingConstants.RIGHT); panel.add(descriptionComponent, BorderLayout.CENTER); }
Example 12
Source File: HotfixGroupElement.java From consulo with Apache License 2.0 | 5 votes |
public void customizeCellRenderer(SimpleColoredComponent renderer, JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) { renderer.append(" "); if (myInProgress) { renderer.append("fixing...", SimpleTextAttributes.REGULAR_ITALIC_ATTRIBUTES); } else { renderer.append("Fix: " + myFixDescription, SimpleTextAttributes.LINK_BOLD_ATTRIBUTES, myRunner); } }
Example 13
Source File: ArrangementStandardSettingsManager.java From consulo with Apache License 2.0 | 5 votes |
private int parseWidth(@Nonnull ArrangementSettingsToken token, @Nonnull SimpleColoredComponent renderer) { renderer.clear(); final String value = getPresentationValue(token); renderer.append(value, SimpleTextAttributes.fromTextAttributes(myColorsProvider.getTextAttributes(token, true))); int result = renderer.getPreferredSize().width; renderer.clear(); renderer.append(value, SimpleTextAttributes.fromTextAttributes(myColorsProvider.getTextAttributes(token, false))); return Math.max(result, renderer.getPreferredSize().width); }
Example 14
Source File: XBreakpointItem.java From consulo with Apache License 2.0 | 5 votes |
@Override public void setupGenericRenderer(SimpleColoredComponent renderer, boolean plainView) { if (plainView) { renderer.setIcon(getIcon()); } final SimpleTextAttributes attributes = myBreakpoint.isEnabled() ? SimpleTextAttributes.SIMPLE_CELL_ATTRIBUTES : SimpleTextAttributes.GRAYED_ATTRIBUTES; renderer.append(StringUtil.notNullize(getDisplayText()), attributes); String description = getUserDescription(); if (!StringUtil.isEmpty(description)) { renderer.append(" (" + description + ")", SimpleTextAttributes.REGULAR_ITALIC_ATTRIBUTES); } }
Example 15
Source File: ApplyPatchDifferentiatedDialog.java From consulo with Apache License 2.0 | 5 votes |
public void decorate(Change change, SimpleColoredComponent component, boolean isShowFlatten) { if (change instanceof AbstractFilePatchInProgress.PatchChange) { final AbstractFilePatchInProgress.PatchChange patchChange = (AbstractFilePatchInProgress.PatchChange)change; final AbstractFilePatchInProgress patchInProgress = patchChange.getPatchInProgress(); if (patchInProgress.getCurrentStrip() > 0) { component.append(" stripped " + patchInProgress.getCurrentStrip(), SimpleTextAttributes.GRAY_ITALIC_ATTRIBUTES); } final String text; if (FilePatchStatus.ADDED.equals(patchInProgress.getStatus())) { text = "Added"; } else if (FilePatchStatus.DELETED.equals(patchInProgress.getStatus())) { text = "Deleted"; } else { text = "Modified"; } component.append(" "); component.append(text, SimpleTextAttributes.GRAY_ATTRIBUTES); if (!patchInProgress.baseExistsOrAdded()) { component.append(" "); component.append("Select missing base", new SimpleTextAttributes(STYLE_PLAIN, JBUI.CurrentTheme.Link.linkColor()), (Runnable)myChangesTreeList::handleInvalidChangesAndToggle); } else { if (!patchInProgress.getStatus().equals(FilePatchStatus.ADDED) && basePathWasChanged(patchInProgress)) { component.append(" "); component.append("New base detected", SimpleTextAttributes.GRAYED_ITALIC_ATTRIBUTES); component.setToolTipText(String.format("was: %s (base dir: %s)", patchInProgress.getOriginalBeforePath(), myProject.getBasePath()) + "<br/>" + String.format("now: %s (base dir: %s)", patchInProgress.getPatch().getBeforeName(), patchInProgress.getBase().getPath())); } } } }
Example 16
Source File: RemoteStatusChangeNodeDecorator.java From consulo with Apache License 2.0 | 5 votes |
public void decorate(Change change, SimpleColoredComponent component, boolean isShowFlatten) { final boolean state = myRemoteRevisionsCache.isUpToDate(change); if (myListState != null) myListState.report(myIdx, state); if (!state) { component.append(" "); component.append(VcsBundle.message("change.nodetitle.change.is.outdated"), SimpleTextAttributes.ERROR_ATTRIBUTES); } }
Example 17
Source File: SimpleTextCellAppearance.java From consulo with Apache License 2.0 | 4 votes |
@Override public void customize(@Nonnull final SimpleColoredComponent component) { component.setIcon(myIcon); component.append(myText, myTextAttributes); }
Example 18
Source File: BaseNodeDescriptor.java From aem-ide-tooling-4-intellij with Apache License 2.0 | 4 votes |
@Override public void customize(@NotNull SimpleColoredComponent component) { component.append(toString(), SimpleTextAttributes.REGULAR_ATTRIBUTES); }
Example 19
Source File: CommonFindUsagesDialog.java From consulo with Apache License 2.0 | 4 votes |
@Override public void configureLabelComponent(@Nonnull SimpleColoredComponent coloredComponent) { coloredComponent.append(StringUtil.capitalize(UsageViewUtil.getType(myPsiElement))); coloredComponent.append(" "); coloredComponent.append(DescriptiveNameUtil.getDescriptiveName(myPsiElement), SimpleTextAttributes.REGULAR_BOLD_ATTRIBUTES); }
Example 20
Source File: ShowUsagesTableCellRenderer.java From consulo with Apache License 2.0 | 4 votes |
@Nonnull private static Component textComponentSpanningWholeRow(@Nonnull SimpleColoredComponent chunks, Color panelBackground, Color panelForeground, final int column, @Nonnull final JTable table, int row) { final SimpleColoredComponent component = new SimpleColoredComponent() { @Override protected void doPaint(Graphics2D g) { int offset = 0; int i = 0; final TableColumnModel columnModel = table.getColumnModel(); while (i < column) { offset += columnModel.getColumn(i).getWidth(); i++; } g.translate(-offset, 0); //if (column == columnModel.getColumnCount()-1) { //} setSize(getWidth()+offset, getHeight()); // should increase the column width so that selection background will be visible even after offset translation super.doPaint(g); g.translate(+offset, 0); } @Nonnull @Override public Dimension getPreferredSize() { //return super.getPreferredSize(); return column == table.getColumnModel().getColumnCount()-1 ? super.getPreferredSize() : new Dimension(0,0); // it should span the whole row, so we can't return any specific value here, // because otherwise it would be used in the "max width" calculation in com.intellij.find.actions.ShowUsagesAction.calcMaxWidth } }; component.setIpad(new Insets(0,0,0,0)); component.setBorder(null); component.setBackground(panelBackground); component.setForeground(panelForeground); for (SimpleColoredComponent.ColoredIterator iterator = chunks.iterator(); iterator.hasNext(); ) { iterator.next(); String fragment = iterator.getFragment(); SimpleTextAttributes attributes = iterator.getTextAttributes(); attributes = attributes.derive(attributes.getStyle(), panelForeground, panelBackground, attributes.getWaveColor()); component.append(fragment, attributes); } return component; }