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

The following examples show how to use com.intellij.ui.SimpleTextAttributes#REGULAR_BOLD_ATTRIBUTES . 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: DartElementPresentationUtil.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
public static void renderElement(@NotNull Element element, @NotNull OutlineTreeCellRenderer renderer, boolean nameInBold) {
  final SimpleTextAttributes attributes =
    nameInBold ? SimpleTextAttributes.REGULAR_BOLD_ATTRIBUTES : SimpleTextAttributes.REGULAR_ATTRIBUTES;

  renderer.appendSearch(element.getName(), attributes);

  if (!StringUtil.isEmpty(element.getTypeParameters())) {
    renderer.appendSearch(element.getTypeParameters(), attributes);
  }
  if (!StringUtil.isEmpty(element.getParameters())) {
    renderer.appendSearch(element.getParameters(), attributes);
  }
  if (!StringUtil.isEmpty(element.getReturnType())) {
    renderer.append(" ");
    renderer.append(DartPresentableUtil.RIGHT_ARROW);
    renderer.append(" ");
    renderer.appendSearch(element.getReturnType(), SimpleTextAttributes.REGULAR_ATTRIBUTES);
  }
}
 
Example 2
Source File: DartElementPresentationUtil.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
public static void renderElement(@NotNull Element element, @NotNull OutlineTreeCellRenderer renderer, boolean nameInBold) {
  final SimpleTextAttributes attributes =
    nameInBold ? SimpleTextAttributes.REGULAR_BOLD_ATTRIBUTES : SimpleTextAttributes.REGULAR_ATTRIBUTES;

  renderer.appendSearch(element.getName(), attributes);

  if (!StringUtil.isEmpty(element.getTypeParameters())) {
    renderer.appendSearch(element.getTypeParameters(), attributes);
  }
  if (!StringUtil.isEmpty(element.getParameters())) {
    renderer.appendSearch(element.getParameters(), attributes);
  }
  if (!StringUtil.isEmpty(element.getReturnType())) {
    renderer.append(" ");
    renderer.append(DartPresentableUtil.RIGHT_ARROW);
    renderer.append(" ");
    renderer.appendSearch(element.getReturnType(), SimpleTextAttributes.REGULAR_ATTRIBUTES);
  }
}
 
Example 3
Source File: AbstractTreeNode.java    From consulo with Apache License 2.0 4 votes vote down vote up
protected void applyFilter(boolean apply) {
  myFilterAttributes = apply ? SimpleTextAttributes.REGULAR_BOLD_ATTRIBUTES : null;
}
 
Example 4
Source File: ProjectStructureElementRenderer.java    From consulo with Apache License 2.0 4 votes vote down vote up
@RequiredUIAccess
@Override
public void customizeCellRenderer(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) {
  if (value instanceof MasterDetailsComponent.MyNode) {
    final MasterDetailsComponent.MyNode node = (MasterDetailsComponent.MyNode)value;

    final NamedConfigurable namedConfigurable = node.getConfigurable();
    if (namedConfigurable == null) {
      return;
    }

    final String displayName = node.getDisplayName();
    final Image icon = namedConfigurable.getIcon(expanded);
    setIcon(icon);
    setToolTipText(null);
    setFont(UIUtil.getTreeFont());

    SimpleTextAttributes textAttributes = SimpleTextAttributes.REGULAR_ATTRIBUTES;
    if (node.isDisplayInBold()) {
      textAttributes = SimpleTextAttributes.REGULAR_BOLD_ATTRIBUTES;
    }
    else if (namedConfigurable instanceof ProjectStructureElementConfigurable) {
      final ProjectStructureElement projectStructureElement =
        ((ProjectStructureElementConfigurable)namedConfigurable).getProjectStructureElement();
      if (projectStructureElement != null) {
        final ProjectStructureDaemonAnalyzer daemonAnalyzer = myContext == null ? null : myContext.getDaemonAnalyzer();
        final ProjectStructureProblemsHolderImpl problemsHolder = daemonAnalyzer == null ? null : daemonAnalyzer.getProblemsHolder(projectStructureElement);
        if (problemsHolder != null && problemsHolder.containsProblems()) {
          final boolean isUnused = problemsHolder.containsProblems(ProjectStructureProblemType.Severity.UNUSED);
          final boolean haveWarnings = problemsHolder.containsProblems(ProjectStructureProblemType.Severity.WARNING);
          final boolean haveErrors = problemsHolder.containsProblems(ProjectStructureProblemType.Severity.ERROR);
          Color foreground = isUnused ? UIUtil.getInactiveTextColor() : null;
          final int style = haveWarnings || haveErrors ? SimpleTextAttributes.STYLE_WAVED : -1;
          final Color waveColor = haveErrors ? JBColor.RED : haveWarnings ? JBColor.GRAY : null;
          textAttributes = textAttributes.derive(style, foreground, null, waveColor);
          setToolTipText(problemsHolder.composeTooltipMessage());
        }

        append(displayName, textAttributes);
        String description = projectStructureElement.getDescription();
        if (description != null) {
          append(" (" + description + ")", SimpleTextAttributes.GRAY_ATTRIBUTES, false);
        }
        return;
      }
    }
    append(displayName, textAttributes);
  }
}
 
Example 5
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;
}