Java Code Examples for com.intellij.ui.SimpleTextAttributes#STYLE_PLAIN

The following examples show how to use com.intellij.ui.SimpleTextAttributes#STYLE_PLAIN . 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 vote down vote up
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: LineParser.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Nullable
private SimpleTextAttributes readStyle() {
  if (!peek(1).equals("[")) {
    return null;
  }

  final String remainder = str.substring(index);
  final int escapeEndIndex = remainder.indexOf("m");
  if (escapeEndIndex == -1) {
    return null;
  }

  final String paramString = remainder.substring(1, escapeEndIndex);

  // Eat params + leading [ and trailing m
  eat(paramString.length() + 2);

  Color color = null;
  int fontStyle = SimpleTextAttributes.STYLE_PLAIN;

  for (String param : paramString.split(";")) {
    final Object style = toStyle(param);
    if (style instanceof Color) {
      color = (Color)style;
    }
    else if (style instanceof Integer) {
      fontStyle |= (int)style;
    }
  }

  return new SimpleTextAttributes(fontStyle, color);
}
 
Example 3
Source File: LineParser.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Nullable
private SimpleTextAttributes readStyle() {
  if (!peek(1).equals("[")) {
    return null;
  }

  final String remainder = str.substring(index);
  final int escapeEndIndex = remainder.indexOf("m");
  if (escapeEndIndex == -1) {
    return null;
  }

  final String paramString = remainder.substring(1, escapeEndIndex);

  // Eat params + leading [ and trailing m
  eat(paramString.length() + 2);

  Color color = null;
  int fontStyle = SimpleTextAttributes.STYLE_PLAIN;

  for (String param : paramString.split(";")) {
    final Object style = toStyle(param);
    if (style instanceof Color) {
      color = (Color)style;
    }
    else if (style instanceof Integer) {
      fontStyle |= (int)style;
    }
  }

  return new SimpleTextAttributes(fontStyle, color);
}
 
Example 4
Source File: TemplateTreeRenderer.java    From idea-gitignore with MIT License 5 votes vote down vote up
/**
 * Renders checkbox tree cell filled with @{link TemplateTreeNode} data.
 *
 * @param tree     current working tree
 * @param value    template data
 * @param selected node is selected
 * @param expanded node is expanded
 * @param leaf     node is a leaf
 * @param row      node is a row
 * @param hasFocus node has focus
 */
public void customizeRenderer(final JTree tree, final Object value, final boolean selected, final boolean expanded,
                              final boolean leaf, final int row, final boolean hasFocus) {
    if (!(value instanceof TemplateTreeNode)) {
        return;
    }
    TemplateTreeNode node = (TemplateTreeNode) value;

    final Color background = selected ? UIUtil.getTreeSelectionBackground(true) : UIUtil.getTreeBackground();
    UIUtil.changeBackGround(this, background);
    Color foreground = selected ? UIUtil.getTreeSelectionForeground(true) : node.getTemplate() == null ?
            PlatformColors.BLUE : UIUtil.getTreeForeground();
    int style = SimpleTextAttributes.STYLE_PLAIN;

    String text = "", hint = "";
    if (node.getTemplate() != null) { // template leaf
        text = node.getTemplate().getName();
    } else if (node.getContainer() != null) { // container group
        hint = IgnoreBundle.message("template.container." + node.getContainer().toString().toLowerCase());
        getCheckbox().setVisible(false);
    }

    SearchUtil.appendFragments(getFilter(), text, style, foreground, background, getTextRenderer());
    getTextRenderer().append(hint, selected
            ? new SimpleTextAttributes(SimpleTextAttributes.STYLE_PLAIN, foreground)
            : SimpleTextAttributes.GRAYED_ATTRIBUTES
    );
    setForeground(foreground);
}
 
Example 5
Source File: LiteralChooserObject.java    From intellij-plugin-v4 with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public void renderTreeNode(SimpleColoredComponent component, JTree tree) {
	String literal = getText();
	SimpleTextAttributes attributes =
		new SimpleTextAttributes(SimpleTextAttributes.STYLE_PLAIN, tree.getForeground());
	component.append(literal, attributes);
	component.setIcon(icon);
}
 
Example 6
Source File: TreeRenderer.java    From MavenHelper with Apache License 2.0 5 votes vote down vote up
public TreeRenderer(JCheckBox showGroupId, GuiForm guiForm) {
	this.showGroupId = showGroupId;
	this.guiForm = guiForm;
	errorBoldAttributes = new SimpleTextAttributes(SimpleTextAttributes.STYLE_BOLD, SimpleTextAttributes.ERROR_ATTRIBUTES.getFgColor());

	testAttributes = new SimpleTextAttributes(SimpleTextAttributes.STYLE_PLAIN, new JBColor(new Color(4, 111, 0), new Color(0x69AF80)));
	testBoldAttributes = new SimpleTextAttributes(SimpleTextAttributes.STYLE_BOLD, testAttributes.getFgColor());

	providedAttributes = new SimpleTextAttributes(SimpleTextAttributes.STYLE_PLAIN, new JBColor(new Color(0x02516D), new Color(0x028BBA)));
	providedBoldAttributes = new SimpleTextAttributes(SimpleTextAttributes.STYLE_BOLD, providedAttributes.getFgColor());

	runtimeAttributes = new SimpleTextAttributes(SimpleTextAttributes.STYLE_PLAIN, new JBColor(new Color(0x8D4E81), new Color(0xB264A5)));
	runtimeBoldAttributes = new SimpleTextAttributes(SimpleTextAttributes.STYLE_BOLD, runtimeAttributes.getFgColor());
}
 
Example 7
Source File: TabInfo.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nonnull
private SimpleTextAttributes getDefaultAttributes() {
  SimpleTextAttributes attributes = myDefaultAttributes;
  if (attributes == null) {
    myDefaultAttributes = attributes = new SimpleTextAttributes(myDefaultStyle != -1 ? myDefaultStyle : SimpleTextAttributes.STYLE_PLAIN,
                                                                myDefaultForeground, myDefaultWaveColor);

  }
  return attributes;
}
 
Example 8
Source File: WolfChangesFileNameDecorator.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void appendFileName(final ChangesBrowserNodeRenderer renderer, final VirtualFile vFile, final String fileName, final Color color, final boolean highlightProblems) {
  int style = SimpleTextAttributes.STYLE_PLAIN;
  Color underlineColor = null;
  if (highlightProblems && vFile != null && !vFile.isDirectory() && myProblemSolver.isProblemFile(vFile)) {
    underlineColor = JBColor.RED;
    style = SimpleTextAttributes.STYLE_WAVED;
  }
  renderer.append(fileName, new SimpleTextAttributes(style, color, underlineColor));
}
 
Example 9
Source File: InspectionListCellRenderer.java    From consulo with Apache License 2.0 5 votes vote down vote up
public InspectionListCellRenderer() {
  SELECTED = new SimpleTextAttributes(UIUtil.getListSelectionBackground(),
                                      UIUtil.getListSelectionForeground(),
                                      JBColor.RED,
                                      SimpleTextAttributes.STYLE_PLAIN);
  PLAIN = new SimpleTextAttributes(UIUtil.getListBackground(),
                                   UIUtil.getListForeground(),
                                   JBColor.RED,
                                   SimpleTextAttributes.STYLE_PLAIN);
}
 
Example 10
Source File: OrderEntryAppearanceServiceImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nonnull
@Override
public CellAppearanceEx forSdk(@Nullable final Sdk jdk, final boolean isInComboBox, final boolean selected, final boolean showVersion) {
  if (jdk == null) {
    return SimpleTextCellAppearance.invalid(ProjectBundle.message("unknown.sdk"), AllIcons.Toolbar.Unknown);
  }

  String name = jdk.getName();
  CompositeAppearance appearance = new CompositeAppearance();
  SdkType sdkType = (SdkType)jdk.getSdkType();
  appearance.setIcon(SdkUtil.getIcon(jdk));
  SimpleTextAttributes attributes = getTextAttributes(sdkType.sdkHasValidPath(jdk), selected);
  CompositeAppearance.DequeEnd ending = appearance.getEnding();
  ending.addText(name, attributes);

  if (showVersion) {
    String versionString = jdk.getVersionString();
    if (versionString != null && !versionString.equals(name)) {
      SimpleTextAttributes textAttributes = isInComboBox && !selected ? SimpleTextAttributes.SYNTHETIC_ATTRIBUTES :
                                            SystemInfo.isMac && selected ? new SimpleTextAttributes(SimpleTextAttributes.STYLE_PLAIN, 
                                                                                                    Color.WHITE): SimpleTextAttributes.GRAY_ATTRIBUTES;
      ending.addComment(versionString, textAttributes);
    }
  }

  return ending.getAppearance();
}
 
Example 11
Source File: RunConfigurationsSEContributor.java    From consulo with Apache License 2.0 5 votes vote down vote up
private void fillExecutorInfo(ChooseRunConfigurationPopup.ItemWrapper wrapper, JList<?> list, boolean selected) {

      SimpleTextAttributes commandAttributes = selected ? new SimpleTextAttributes(SimpleTextAttributes.STYLE_PLAIN, list.getSelectionForeground()) : SimpleTextAttributes.GRAYED_ATTRIBUTES;
      SimpleTextAttributes shortcutAttributes = selected ? new SimpleTextAttributes(SimpleTextAttributes.STYLE_PLAIN, list.getSelectionForeground()) : SimpleTextAttributes.GRAY_ATTRIBUTES;

      String input = myCommandSupplier.get();
      if (isCommand(input, RUN_COMMAND)) {
        fillWithMode(wrapper, RUN_MODE, commandAttributes);
        return;
      }
      if (isCommand(input, DEBUG_COMMAND)) {
        fillWithMode(wrapper, DEBUG_MODE, commandAttributes);
        return;
      }

      Executor debugExecutor = ExecutorRegistry.getInstance().getExecutorById(ToolWindowId.DEBUG);
      Executor runExecutor = DefaultRunExecutor.getRunExecutorInstance();

      KeyStroke enterStroke = KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0);
      KeyStroke shiftEnterStroke = KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, InputEvent.SHIFT_DOWN_MASK);
      if (debugExecutor != null) {
        executorInfo.append(debugExecutor.getId(), commandAttributes);
        executorInfo.append("(" + KeymapUtil.getKeystrokeText(enterStroke) + ")", shortcutAttributes);
        if (runExecutor != null) {
          executorInfo.append(" / " + runExecutor.getId(), commandAttributes);
          executorInfo.append("(" + KeymapUtil.getKeystrokeText(shiftEnterStroke) + ")", shortcutAttributes);
        }
      }
      else {
        if (runExecutor != null) {
          executorInfo.append(runExecutor.getId(), commandAttributes);
          executorInfo.append("(" + KeymapUtil.getKeystrokeText(enterStroke) + ")", shortcutAttributes);
        }
      }
    }
 
Example 12
Source File: SuggestionTreeCellRenderer.java    From size-analyzer with Apache License 2.0 4 votes vote down vote up
@Override
public Component getTreeCellRendererComponent(
    JTree tree,
    Object value,
    boolean selected,
    boolean expanded,
    boolean leaf,
    int row,
    boolean hasFocus) {
  final Component rendererComponent =
      parentRenderer.getTreeCellRendererComponent(
          tree, value, selected, expanded, leaf, row, hasFocus);
  if (rendererComponent instanceof SimpleColoredComponent) {
    Object nodeObject = ((DefaultMutableTreeNode) value).getUserObject();
    for (SimpleColoredComponent.ColoredIterator it =
        ((SimpleColoredComponent) rendererComponent).iterator();
        it.hasNext(); ) {
      it.next();
      int offset = it.getOffset();
      int endOffset = it.getEndOffset();
      if (selected) {
        if (nodeObject instanceof CategoryData) {
          it.split(
              endOffset - offset,
              new SimpleTextAttributes(SimpleTextAttributes.STYLE_BOLD, JBColor.WHITE));
        } else if (nodeObject instanceof SuggestionData || nodeObject instanceof IssueTypeData) {
          it.split(
              endOffset - offset,
              new SimpleTextAttributes(SimpleTextAttributes.STYLE_PLAIN, JBColor.WHITE));
        }
      } else {
        if (nodeObject instanceof CategoryData) {
          it.split(endOffset - offset, SimpleTextAttributes.REGULAR_BOLD_ATTRIBUTES);
        }
      }
    }

    SimpleTextAttributes annotationStyle =
        selected
            ? new SimpleTextAttributes(SimpleTextAttributes.STYLE_PLAIN, JBColor.WHITE)
            : SimpleTextAttributes.GRAYED_ATTRIBUTES;
    if (nodeObject instanceof CategoryData) {
      CategoryData category = (CategoryData) nodeObject;
      ((SimpleColoredComponent) rendererComponent)
          .append(
              "  " + category.totalSuggestions(), annotationStyle);
      ((SimpleColoredComponent) rendererComponent)
          .append(
              category.totalSuggestions() == 1 ? " recommendation" : " recommendations",
              annotationStyle);
      if (category.totalSizeSaved() != null) {
        ((SimpleColoredComponent) rendererComponent)
            .append(", " + category.totalSizeSaved(), annotationStyle);
      }
    } else if (nodeObject instanceof IssueTypeData) {
      IssueTypeData issueType = (IssueTypeData) nodeObject;
      if (issueType.totalSuggestions() == 1) {
        ((SimpleColoredComponent) rendererComponent)
            .append(
                "  " + issueType.totalSuggestions() + " recommendation", annotationStyle);
      } else {
        ((SimpleColoredComponent) rendererComponent)
            .append(
                "  " + issueType.totalSuggestions() + " recommendations", annotationStyle);
      }
      if (issueType.totalSizeSaved() != null) {
        ((SimpleColoredComponent) rendererComponent)
            .append(", " + issueType.totalSizeSaved(), annotationStyle);
      }
    } else if (nodeObject instanceof SuggestionData) {
      SuggestionData suggestion = (SuggestionData) nodeObject;
      if (suggestion.getBytesSaved() != null) {
        ((SimpleColoredComponent) rendererComponent)
            .append("  " + suggestion.getBytesSaved(), annotationStyle);
      }
    }
  }
  return rendererComponent;
}
 
Example 13
Source File: GraphQLConfigSchemaNode.java    From js-graphql-intellij-plugin with MIT License 4 votes vote down vote up
@Override
protected void update(PresentationData presentation) {
    super.update(presentation);
    final int style = representsCurrentFile() ? SimpleTextAttributes.STYLE_BOLD : SimpleTextAttributes.STYLE_PLAIN;
    presentation.addText(getName(), new SimpleTextAttributes(style, getColor()));
}
 
Example 14
Source File: RailwaysColors.java    From railways with MIT License 4 votes vote down vote up
private static SimpleTextAttributes plainTextAttr(Color fgColor, Color bgColor) {
    return new SimpleTextAttributes(bgColor, fgColor,
            null, SimpleTextAttributes.STYLE_PLAIN);
}
 
Example 15
Source File: MemberChooserObjectBase.java    From consulo with Apache License 2.0 4 votes vote down vote up
protected SimpleTextAttributes getTextAttributes(JTree tree) {
  return new SimpleTextAttributes(SimpleTextAttributes.STYLE_PLAIN, tree.getForeground());
}
 
Example 16
Source File: NavBarPresentation.java    From consulo with Apache License 2.0 4 votes vote down vote up
protected SimpleTextAttributes getTextAttributes(final Object object, final boolean selected) {
  if (!NavBarModel.isValid(object)) return SimpleTextAttributes.REGULAR_ATTRIBUTES;
  if (object instanceof PsiElement) {
    if (!ApplicationManager.getApplication().runReadAction(new Computable<Boolean>() {
      @Override
      public Boolean compute() {
        return ((PsiElement)object).isValid();
      }
    }).booleanValue()) {
      return SimpleTextAttributes.GRAYED_ATTRIBUTES;
    }
    PsiFile psiFile = ((PsiElement)object).getContainingFile();
    if (psiFile != null) {
      final VirtualFile virtualFile = psiFile.getVirtualFile();
      return new SimpleTextAttributes(null, selected ? null : FileStatusManager.getInstance(myProject).getStatus(virtualFile).getColor(), JBColor.red,
                                      WolfTheProblemSolver.getInstance(myProject).isProblemFile(virtualFile) ? SimpleTextAttributes.STYLE_WAVED : SimpleTextAttributes.STYLE_PLAIN);
    }
    else {
      if (object instanceof PsiDirectory) {
        VirtualFile vDir = ((PsiDirectory)object).getVirtualFile();
        if (vDir.getParent() == null || ProjectRootsUtil.isModuleContentRoot(vDir, myProject)) {
          return SimpleTextAttributes.REGULAR_BOLD_ATTRIBUTES;
        }
      }

      if (wolfHasProblemFilesBeneath((PsiElement)object)) {
        return WOLFED;
      }
    }
  }
  else if (object instanceof Module) {
    if (WolfTheProblemSolver.getInstance(myProject).hasProblemFilesBeneath((Module)object)) {
      return WOLFED;
    }

  }
  else if (object instanceof Project) {
    final Project project = (Project)object;
    final Module[] modules = ApplicationManager.getApplication().runReadAction(new Computable<Module[]>() {
      @Override
      public Module[] compute() {
        return ModuleManager.getInstance(project).getModules();
      }
    });
    for (Module module : modules) {
      if (WolfTheProblemSolver.getInstance(project).hasProblemFilesBeneath(module)) {
        return WOLFED;
      }
    }
  }
  return SimpleTextAttributes.REGULAR_ATTRIBUTES;
}