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

The following examples show how to use com.intellij.ui.SimpleTextAttributes#GRAYED_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: TfsTreeNode.java    From azure-devops-intellij with MIT License 6 votes vote down vote up
@Override
protected void update(final PresentationData presentation) {
    if (isRoot()) {
        //noinspection ConstantConditions
        presentation.addText(treeContext.serverContext.getUri().getPath(), getPlainAttributes());
        presentation.setIcon(Icons.VSLogoSmall);
    } else {
        if (isDirectory()) {
            presentation.setIcon(PlatformIcons.DIRECTORY_CLOSED_ICON);
        } else {
            presentation.setIcon(FileTypeManager.getInstance().getFileTypeByFileName(getFileName()).getIcon());
        }
        SimpleTextAttributes attrs;
        if (isVirtual) {
            attrs = VIRTUAL_ATTRS;
        } else if (treeContext.isAccepted(path)) {
            attrs = getPlainAttributes();
        } else {
            attrs = SimpleTextAttributes.GRAYED_ATTRIBUTES;
        }
        presentation.addText(getFileName(), attrs);
    }
}
 
Example 2
Source File: PsiElementListCellRenderer.java    From consulo with Apache License 2.0 6 votes vote down vote up
private void appendLocationText(boolean selected, Color bgColor, boolean isProblemFile, String containerText) {
  SimpleTextAttributes locationAttrs = SimpleTextAttributes.GRAYED_ATTRIBUTES;
  if (isProblemFile) {
    SimpleTextAttributes wavedAttributes = SimpleTextAttributes.merge(new SimpleTextAttributes(SimpleTextAttributes.STYLE_WAVED, UIUtil.getInactiveTextColor(), JBColor.RED), locationAttrs);
    java.util.regex.Matcher matcher = CONTAINER_PATTERN.matcher(containerText);
    if (matcher.matches()) {
      String prefix = matcher.group(1);
      SpeedSearchUtil.appendColoredFragmentForMatcher(" " + ObjectUtils.notNull(prefix, ""), this, locationAttrs, myMatchers.locationMatcher, bgColor, selected);

      String strippedContainerText = matcher.group(2);
      SpeedSearchUtil.appendColoredFragmentForMatcher(ObjectUtils.notNull(strippedContainerText, ""), this, wavedAttributes, myMatchers.locationMatcher, bgColor, selected);

      String suffix = matcher.group(3);
      if (suffix != null) {
        SpeedSearchUtil.appendColoredFragmentForMatcher(suffix, this, locationAttrs, myMatchers.locationMatcher, bgColor, selected);
      }
      return;
    }
    locationAttrs = wavedAttributes;
  }
  SpeedSearchUtil.appendColoredFragmentForMatcher(" " + containerText, this, locationAttrs, myMatchers.locationMatcher, bgColor, selected);
}
 
Example 3
Source File: HaxeDebugRunner.java    From intellij-haxe with Apache License 2.0 5 votes vote down vote up
public void customizePresentation
  (@NotNull ColoredTextContainer component) {
  SimpleTextAttributes attr = (mSourcePosition == null) ?
                              SimpleTextAttributes.GRAYED_ATTRIBUTES :
                              SimpleTextAttributes.REGULAR_ATTRIBUTES;

  component.append(mClassAndFunctionName + "  [" + mFileName +
                   ":" + mLineNumber + "]", attr);
  component.setIcon(AllIcons.Debugger.StackFrame);
}
 
Example 4
Source File: XBreakpointItem.java    From consulo with Apache License 2.0 5 votes vote down vote up
@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 5
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 6
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 7
Source File: MessageTreeNode.java    From consulo with Apache License 2.0 4 votes vote down vote up
public static MessageTreeNode createEllipsisNode(XDebuggerTree tree, XDebuggerTreeNode parent, final int remaining) {
  String message = remaining == -1
                   ? XDebuggerBundle.message("node.text.ellipsis.0.unknown.more.nodes.double.click.to.show")
                   : XDebuggerBundle.message("node.text.ellipsis.0.more.nodes.double.click.to.show", remaining);
  return new MessageTreeNode(tree, parent, message, SimpleTextAttributes.GRAYED_ATTRIBUTES, null, true, null);
}
 
Example 8
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;
}