當前位置: 首頁>>代碼示例>>Java>>正文


Java SimpleTextAttributes類代碼示例

本文整理匯總了Java中com.intellij.ui.SimpleTextAttributes的典型用法代碼示例。如果您正苦於以下問題:Java SimpleTextAttributes類的具體用法?Java SimpleTextAttributes怎麽用?Java SimpleTextAttributes使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


SimpleTextAttributes類屬於com.intellij.ui包,在下文中一共展示了SimpleTextAttributes類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: customizeCellRenderer

import com.intellij.ui.SimpleTextAttributes; //導入依賴的package包/類
@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);
}
 
開發者ID:hoai265,項目名稱:SearchResourcePlugin,代碼行數:18,代碼來源:ResultElementListCellRenderer.java

示例2: getPlainAttributes

import com.intellij.ui.SimpleTextAttributes; //導入依賴的package包/類
@Override
protected SimpleTextAttributes getPlainAttributes() {
  SimpleTextAttributes original = super.getPlainAttributes();

  int style = original.getStyle();
  Color color = original.getFgColor();
  boolean custom = false;

  if ("test".equals(myGoal) && MavenRunner.getInstance(myProject).getSettings().isSkipTests()) {
    color = SimpleTextAttributes.GRAYED_ATTRIBUTES.getFgColor();
    style |= SimpleTextAttributes.STYLE_STRIKEOUT;
    custom = true;
  }
  if (myGoal.equals(myMavenProject.getDefaultGoal())) {
    style |= SimpleTextAttributes.STYLE_BOLD;
    custom = true;
  }
  if (custom) return original.derive(style, color, null, null);
  return original;
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:21,代碼來源:MavenProjectsStructure.java

示例3: decorateTree

import com.intellij.ui.SimpleTextAttributes; //導入依賴的package包/類
@Override
public void decorateTree(SimpleColoredComponent renderer, AttributeWrapper wrapper) {
  XmlTag tag = getTag();
  StringBuilder value = new StringBuilder(" (");

  String namespace = getGridLayoutNamespace(this);

  String rowCount = tag.getAttributeValue(ATTR_ROW_COUNT, namespace);
  value.append(StringUtil.isEmpty(rowCount) ? "?" : rowCount).append(", ");

  String columnCount = tag.getAttributeValue(ATTR_COLUMN_COUNT, namespace);
  value.append(StringUtil.isEmpty(columnCount) ? "?" : columnCount).append(", ");

  value.append(isHorizontal() ? VALUE_HORIZONTAL : VALUE_VERTICAL);

  renderer.append(value.append(")").toString(), wrapper.getAttribute(SimpleTextAttributes.REGULAR_ATTRIBUTES));
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:18,代碼來源:RadGridLayoutComponent.java

示例4: formatRelativePath

import com.intellij.ui.SimpleTextAttributes; //導入依賴的package包/類
@NotNull
private static CellAppearanceEx formatRelativePath(@NotNull final ContentFolder folder, @NotNull final Icon icon) {
  LightFilePointer folderFile = new LightFilePointer(folder.getUrl());
  VirtualFile file = VirtualFileManager.getInstance().findFileByUrl(folder.getContentEntry().getUrl());
  if (file == null) return FileAppearanceService.getInstance().forInvalidUrl(folderFile.getPresentableUrl());

  String contentPath = file.getPath();
  String relativePath;
  SimpleTextAttributes textAttributes;
  VirtualFile folderFileFile = folderFile.getFile();
  if (folderFileFile == null) {
    String absolutePath = folderFile.getPresentableUrl();
    relativePath = absolutePath.startsWith(contentPath) ? absolutePath.substring(contentPath.length()) : absolutePath;
    textAttributes = SimpleTextAttributes.ERROR_ATTRIBUTES;
  }
  else {
    relativePath = VfsUtilCore.getRelativePath(folderFileFile, file, File.separatorChar);
    textAttributes = SimpleTextAttributes.REGULAR_ATTRIBUTES;
  }

  relativePath = StringUtil.isEmpty(relativePath) ? "." + File.separatorChar : relativePath;
  return new SimpleTextCellAppearance(relativePath, icon, textAttributes);
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:24,代碼來源:OrderEntryAppearanceServiceImpl.java

示例5: LanguageLevelCombo

import com.intellij.ui.SimpleTextAttributes; //導入依賴的package包/類
public LanguageLevelCombo(String defaultItem) {
  myDefaultItem = defaultItem;
  for (LanguageLevel level : LanguageLevel.values()) {
    addItem(level);
  }
  setRenderer(new ColoredListCellRendererWrapper() {
    @Override
    protected void doCustomize(JList list, Object value, int index, boolean selected, boolean hasFocus) {
      if (value instanceof LanguageLevel) {
        append(((LanguageLevel)value).getPresentableText());
      }
      else if (value instanceof String) {    // default for SDK or project
        append((String)value);
        LanguageLevel defaultLevel = getDefaultLevel();
        if (defaultLevel != null) {
          append(" (" + defaultLevel.getPresentableText() + ")", SimpleTextAttributes.GRAYED_ATTRIBUTES);
        }
      }
    }
  });
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:22,代碼來源:LanguageLevelCombo.java

示例6: render

import com.intellij.ui.SimpleTextAttributes; //導入依賴的package包/類
@Override
public void render(@NotNull PresentationData presentationData, SimpleTextAttributes mainAttributes,
                   SimpleTextAttributes commentAttributes) {
  final String name = myLibrary.getName();
  if (name != null) {
    presentationData.setIcon(PlatformIcons.LIBRARY_ICON);
    presentationData.addText(name, mainAttributes);
    presentationData.addText(LibraryElementPresentation.getLibraryTableComment(myLibrary), commentAttributes);
  }
  else {
    if (((LibraryEx)myLibrary).isDisposed()) {
      //todo[nik] disposed library should not be shown in the tree
      presentationData.addText("Invalid Library", SimpleTextAttributes.ERROR_ATTRIBUTES);
      return;
    }
    final VirtualFile[] files = myLibrary.getFiles(OrderRootType.CLASSES);
    if (files.length > 0) {
      final VirtualFile file = files[0];
      presentationData.setIcon(VirtualFilePresentation.getIcon(file));
      presentationData.addText(file.getName(), mainAttributes);
    }
    else {
      presentationData.addText("Empty Library", SimpleTextAttributes.ERROR_ATTRIBUTES);
    }
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:27,代碼來源:LibrarySourceItem.java

示例7: describe

import com.intellij.ui.SimpleTextAttributes; //導入依賴的package包/類
private void describe(@NotNull SimpleColoredRenderer renderer,
                      @NotNull AttributeWrapper wrapper,
                      @NotNull RadComponent component,
                      boolean showSelected,
                      int depth) {
  SimpleTextAttributes style = wrapper.getAttribute(SimpleTextAttributes.REGULAR_ATTRIBUTES);
  for (int i = 0; i < depth; i++) {
    renderer.append("    ", style);
  }

  if (showSelected && myPanel.getSurfaceArea().isSelected(component)) {
    renderer.append("*");
  }
  myPanel.getTreeDecorator().decorate(component, renderer, wrapper, true);
  renderer.append("\n", style);

  for (RadComponent child : component.getChildren()) {
    describe(renderer, wrapper, child, showSelected, depth + 1);
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:21,代碼來源:LayoutEditorFixture.java

示例8: getComponent

import com.intellij.ui.SimpleTextAttributes; //導入依賴的package包/類
@NotNull
@Override
public JComponent getComponent(@Nullable PropertiesContainer container,
                               PropertyContext context,
                               @Nullable Object object,
                               boolean selected,
                               boolean hasFocus) {
  clear();
  PropertyTable.updateRenderer(this, selected);

  String value = (String)object;
  RadComponent idComponent = container instanceof RadComponent ? getComponentById((RadComponent)container, value) : null;

  if (idComponent != null) {
    renderComponent(idComponent);
  }
  else if (!StringUtil.isEmpty(value)) {
    append("<not found>", SimpleTextAttributes.ERROR_ATTRIBUTES);
  }

  return this;
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:23,代碼來源:ComponentRenderer.java

示例9: decorate

import com.intellij.ui.SimpleTextAttributes; //導入依賴的package包/類
@Override
public void decorate(ProjectViewNode node, PresentationData data) {
  if (!(node instanceof ClassTreeNode)) {
    return;
  }
  PsiClass psiClass = ((ClassTreeNode) node).getPsiClass();
  if (psiClass == null) {
    return;
  }
  PsiFile psiFile = psiClass.getContainingFile();
  if (psiFile == null) {
    return;
  }
  VirtualFile virtualFile = psiFile.getVirtualFile();
  if (virtualFile == null) {
    return;
  }

  Project project = node.getProject();
  if (SyncStatusHelper.isUnsynced(project, virtualFile)) {
    data.clearText();
    data.addText(psiClass.getName(), SimpleTextAttributes.GRAY_ATTRIBUTES);
    data.addText(" (unsynced)", SimpleTextAttributes.GRAY_ATTRIBUTES);
  }
}
 
開發者ID:bazelbuild,項目名稱:intellij,代碼行數:26,代碼來源:BlazeJavaSyncStatusClassNodeDecorator.java

示例10: XValueGroupNodeImpl

import com.intellij.ui.SimpleTextAttributes; //導入依賴的package包/類
public XValueGroupNodeImpl(XDebuggerTree tree, XDebuggerTreeNode parent, @NotNull XValueGroup group) {
  super(tree, parent, group);
  setLeaf(false);
  setIcon(group.getIcon());
  myText.append(group.getName(), SimpleTextAttributes.REGULAR_ATTRIBUTES);
  String comment = group.getComment();
  if (comment != null) {
    XValuePresentationUtil.appendSeparator(myText, group.getSeparator());
    myText.append(comment, SimpleTextAttributes.GRAY_ATTRIBUTES);
  }

  if (group.isAutoExpand()) {
    ApplicationManager.getApplication().invokeLater(new Runnable() {
      @Override
      public void run() {
        if (!isObsolete()) {
          myTree.expandPath(getPath());
        }
      }
    });
  }
  myTree.nodeLoaded(this, group.getName());
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:24,代碼來源:XValueGroupNodeImpl.java

示例11: initChunks

import com.intellij.ui.SimpleTextAttributes; //導入依賴的package包/類
@NotNull
private TextChunk[] initChunks() {
  PsiFile psiFile = getPsiFile();
  Document document = psiFile == null ? null : PsiDocumentManager.getInstance(getProject()).getDocument(psiFile);
  TextChunk[] chunks;
  if (document == null) {
    // element over light virtual file
    PsiElement element = getElement();
    if (element == null) {
      chunks = new TextChunk[]{new TextChunk(SimpleTextAttributes.ERROR_ATTRIBUTES.toTextAttributes(), UsageViewBundle.message("node.invalid"))};
    }
    else {
      chunks = new TextChunk[] {new TextChunk(new TextAttributes(), element.getText())};
    }
  }
  else {
    chunks = ChunkExtractor.extractChunks(psiFile, this);
  }

  myTextChunks = new SoftReference<TextChunk[]>(chunks);
  return chunks;
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:23,代碼來源:UsageInfo2UsageAdapter.java

示例12: createInfoMessage

import com.intellij.ui.SimpleTextAttributes; //導入依賴的package包/類
public static MessageTreeNode createInfoMessage(XDebuggerTree tree, @NotNull String message, @Nullable HyperlinkListener hyperlinkListener) {
  Matcher matcher = MessageTreeNodeWithLinks.HREF_PATTERN.matcher(message);
  if (hyperlinkListener == null || !matcher.find()) {
    return new MessageTreeNode(tree, null, message, SimpleTextAttributes.REGULAR_ATTRIBUTES,
                               XDebuggerUIConstants.INFORMATION_MESSAGE_ICON);
  }

  List<Object> objects = new ArrayList<Object>();
  int prev = 0;
  do {
    if (matcher.start() != prev) {
      objects.add(message.substring(prev, matcher.start()));
    }
    objects.add(new HyperlinkListenerDelegator(matcher.group(2), matcher.group(1), hyperlinkListener));
    prev = matcher.end();
  }
  while (matcher.find());

  if (prev < message.length()) {
    objects.add(message.substring(prev));
  }
  return new MessageTreeNodeWithLinks(tree, objects);
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:24,代碼來源:MessageTreeNode.java

示例13: renderItem

import com.intellij.ui.SimpleTextAttributes; //導入依賴的package包/類
@Override
public void renderItem(ColoredListCellRenderer renderer) {
  if (myFrameworkType != null) {
    renderer.setIcon(myFrameworkType.getIcon());
    renderer.append(myFrameworkType.getPresentableName());
    if (myFile != null) {
      renderer.append(" in " + myFile.getName());
      renderer.append(" (" + myFile.getPresentableUrl() + ")", SimpleTextAttributes.GRAY_ATTRIBUTES);
    }
  }
  else {
    renderer.setIcon(VirtualFilePresentation.getIcon(myFile));
    renderer.append(myFile.getName());
    renderer.append(" (" + myFile.getPresentableUrl() + ")", SimpleTextAttributes.GRAY_ATTRIBUTES);
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:17,代碼來源:ValidExcludeListItem.java

示例14: doUpdate

import com.intellij.ui.SimpleTextAttributes; //導入依賴的package包/類
@Override
protected void doUpdate() {
  setUniformIcon(getNodeIcon());

  clearColoredText();

  final boolean showErrors = hasErrors();
  final int childrenCount = getChildren().length;

  if (childrenCount > 0) {
    final SimpleTextAttributes textAttributes =
      showErrors ? getWavedAttributes(SimpleTextAttributes.STYLE_BOLD) :  new SimpleTextAttributes(SimpleTextAttributes.STYLE_BOLD, SimpleTextAttributes.REGULAR_ATTRIBUTES.getFgColor());

    addColoredFragment(getNodeName(), textAttributes);
    addColoredFragment(" (" + childrenCount + ')', showErrors ? IdeBundle.message("dom.elements.tree.childs.contain.errors") : null,
                       SimpleTextAttributes.GRAY_ITALIC_ATTRIBUTES);
  }
  else {
    addColoredFragment(getNodeName(), SimpleTextAttributes.GRAYED_BOLD_ATTRIBUTES);
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:22,代碼來源:DomElementsGroupNode.java

示例15: PythonDocumentationPanel

import com.intellij.ui.SimpleTextAttributes; //導入依賴的package包/類
public PythonDocumentationPanel() {
  super(ourModel, new ArrayList<PythonDocumentationMap.Entry>());
  setRenderer(1, new ColoredTableCellRenderer() {
    @Override
    protected void customizeCellRenderer(JTable table, Object value, boolean selected, boolean hasFocus, int row, int column) {
      String text = value == null ? "" : (String) value;
      int pos = 0;
      while(pos < text.length()) {
        int openBrace = text.indexOf('{', pos);
        if (openBrace == -1) openBrace = text.length();
        append(text.substring(pos, openBrace));
        int closeBrace = text.indexOf('}', openBrace);
        if (closeBrace == -1)
          closeBrace = text.length();
        else
          closeBrace++;
        append(text.substring(openBrace, closeBrace), new SimpleTextAttributes(SimpleTextAttributes.STYLE_BOLD, JBColor.BLUE.darker()));
        pos = closeBrace;
      }
    }
  });
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:23,代碼來源:PythonDocumentationConfigurable.java


注:本文中的com.intellij.ui.SimpleTextAttributes類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。