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


Java UIUtil.getTreeTextBackground方法代碼示例

本文整理匯總了Java中com.intellij.util.ui.UIUtil.getTreeTextBackground方法的典型用法代碼示例。如果您正苦於以下問題:Java UIUtil.getTreeTextBackground方法的具體用法?Java UIUtil.getTreeTextBackground怎麽用?Java UIUtil.getTreeTextBackground使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.intellij.util.ui.UIUtil的用法示例。


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

示例1: appendFragmentsForSpeedSearch

import com.intellij.util.ui.UIUtil; //導入方法依賴的package包/類
public static void appendFragmentsForSpeedSearch(@NotNull JComponent speedSearchEnabledComponent,
                                                 @NotNull String text,
                                                 @NotNull SimpleTextAttributes attributes,
                                                 boolean selected,
                                                 @NotNull SimpleColoredComponent simpleColoredComponent) {
  final SpeedSearchSupply speedSearch = SpeedSearchSupply.getSupply(speedSearchEnabledComponent);
  if (speedSearch != null) {
    final Iterable<TextRange> fragments = speedSearch.matchingFragments(text);
    if (fragments != null) {
      final Color fg = attributes.getFgColor();
      final Color bg = selected ? UIUtil.getTreeSelectionBackground() : UIUtil.getTreeTextBackground();
      final int style = attributes.getStyle();
      final SimpleTextAttributes plain = new SimpleTextAttributes(style, fg);
      final SimpleTextAttributes highlighted = new SimpleTextAttributes(bg, fg, null, style | SimpleTextAttributes.STYLE_SEARCH_MATCH);
      appendColoredFragments(simpleColoredComponent, text, fragments, plain, highlighted);
      return;
    }
  }
  simpleColoredComponent.append(text, attributes);
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:21,代碼來源:SpeedSearchUtil.java

示例2: customizeCellRenderer

import com.intellij.util.ui.UIUtil; //導入方法依賴的package包/類
protected void customizeCellRenderer(JList list, Object value, int index, boolean selected, boolean hasFocus) {
  if (UIUtil.isUnderGTKLookAndFeel()) {
    final Color background = selected ? UIUtil.getTreeSelectionBackground() : UIUtil.getTreeTextBackground();
    UIUtil.changeBackGround(this, background);
  }

  IgnoredFileBean bean = (IgnoredFileBean)value;
  final String path = bean.getPath();
  if (path != null) {
    if (path.endsWith("/")) {
      append(VcsBundle.message("ignored.configure.item.directory", path), SimpleTextAttributes.REGULAR_ATTRIBUTES);
    }
    else {
      append(VcsBundle.message("ignored.configure.item.file", path), SimpleTextAttributes.REGULAR_ATTRIBUTES);
    }
  }
  else if (bean.getMask() != null) {
    append(VcsBundle.message("ignored.configure.item.mask", bean.getMask()), SimpleTextAttributes.REGULAR_ATTRIBUTES);
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:21,代碼來源:IgnoredSettingsPanel.java

示例3: getTreeCellRendererComponent

import com.intellij.util.ui.UIUtil; //導入方法依賴的package包/類
public final Component getTreeCellRendererComponent(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) {
  invalidate();
  if (value instanceof CheckedTreeNode) {
    CheckedTreeNode node = (CheckedTreeNode)value;

    NodeState state = getNodeStatus(node);
    myCheckbox.setVisible(true);
    myCheckbox.setSelected(state != NodeState.CLEAR);
    myCheckbox.setEnabled(node.isEnabled() && state != NodeState.PARTIAL);
    myCheckbox.setOpaque(false);
    myCheckbox.setBackground(null);
    setBackground(null);
  }
  else {
    myCheckbox.setVisible(false);
  }
  myTextRenderer.getTreeCellRendererComponent(tree, value, selected, expanded, leaf, row, hasFocus);

  if (UIUtil.isUnderGTKLookAndFeel()) {
    final Color background = selected ? UIUtil.getTreeSelectionBackground() : UIUtil.getTreeTextBackground();
    UIUtil.changeBackGround(this, background);
  }
  else if (UIUtil.isUnderNimbusLookAndFeel()) {
    UIUtil.changeBackGround(this, UIUtil.TRANSPARENT_COLOR);
  }
  customizeRenderer(tree, value, selected, expanded, leaf, row, hasFocus);
  revalidate();

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

示例4: doPaintTooltipImage

import com.intellij.util.ui.UIUtil; //導入方法依賴的package包/類
@Override
protected void doPaintTooltipImage(final Component rComponent,
                                   final Rectangle cellBounds,
                                   final Graphics2D g,
                                   Integer key) {
  final boolean opaque = rComponent.isOpaque();
  if (rComponent instanceof JComponent) {
    ((JComponent)rComponent).setOpaque(true);
  }

  if (myComponent.isRowSelected(key)) {
    rComponent.setBackground(UIUtil.getTreeSelectionBackground(myComponent.hasFocus()));
  } else {
    Color bg = UIUtil.getTreeTextBackground();
    if (myComponent instanceof Tree && ((Tree)myComponent).isFileColorsEnabled()) {
        final Color color = ((Tree)myComponent).getFileColorForPath(myComponent.getPathForRow(key));
        if (color != null) {
          bg = color;
        }
    }
    rComponent.setBackground(bg);
  }
  
  super.doPaintTooltipImage(rComponent, cellBounds, g, key);

  if (rComponent instanceof JComponent) {
    ((JComponent)rComponent).setOpaque(opaque);
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:30,代碼來源:TreeExpandableItemsHandler.java

示例5: customizeCellRenderer

import com.intellij.util.ui.UIUtil; //導入方法依賴的package包/類
@Override
public void customizeCellRenderer(@NotNull JTree tree,
                                  Object value,
                                  boolean selected,
                                  boolean expanded,
                                  boolean leaf,
                                  int row,
                                  boolean hasFocus) {
  final DefaultMutableTreeNode treeNode = (DefaultMutableTreeNode)value;
  final Object userObject = treeNode.getUserObject();
  if (userObject == null) return;

  final Color background = selected ? UIUtil.getTreeSelectionBackground(hasFocus) : UIUtil.getTreeTextBackground();
  final Color foreground = selected && hasFocus ? UIUtil.getTreeSelectionForeground() : UIUtil.getTreeTextForeground();

  final String text;
  final int style;
  if (userObject instanceof Configuration) {
    text = ((Configuration)userObject).getName();
    style = SimpleTextAttributes.STYLE_PLAIN;
  }
  else {
    text = userObject.toString();
    style = SimpleTextAttributes.STYLE_BOLD;
  }
  SearchUtil.appendFragments(mySpeedSearch.getEnteredPrefix(), text, style, foreground, background, this);
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:28,代碼來源:ExistingTemplatesComponent.java

示例6: customizeCellRenderer

import com.intellij.util.ui.UIUtil; //導入方法依賴的package包/類
@Override
protected void customizeCellRenderer(final JList list,
                                     final Object value,
                                     final int index,
                                     final boolean selected,
                                     final boolean hasFocus) {
  // Fix GTK background
  if (UIUtil.isUnderGTKLookAndFeel()){
    final Color background = selected ? UIUtil.getTreeSelectionBackground() : UIUtil.getTreeTextBackground();
    UIUtil.changeBackGround(this, background);
  }
  if (value == null) {
    append(XDebuggerBundle.message("stack.frame.loading.text"), SimpleTextAttributes.GRAY_ATTRIBUTES);
    return;
  }
  if (value instanceof String) {
    append((String)value, SimpleTextAttributes.ERROR_ATTRIBUTES);
    return;
  }

  XStackFrame stackFrame = (XStackFrame)value;
  if (!selected) {
    XSourcePosition position = stackFrame.getSourcePosition();
    if (position != null) {
      final VirtualFile virtualFile = position.getFile();
      if (virtualFile.isValid()) {
        Color c = myColorsManager.getFileColor(virtualFile);
        if (c != null) setBackground(c);
      }
    }
  }
  stackFrame.customizePresentation(this);
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:34,代碼來源:XDebuggerFramesList.java

示例7: PostfixTemplatesCheckboxTree

import com.intellij.util.ui.UIUtil; //導入方法依賴的package包/類
public PostfixTemplatesCheckboxTree() {
  super(new CheckboxTreeCellRenderer() {
    @Override
    public void customizeRenderer(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) {
      if (!(value instanceof CheckedTreeNode)) return;
      CheckedTreeNode node = (CheckedTreeNode)value;

      final Color background = selected ? UIUtil.getTreeSelectionBackground() : UIUtil.getTreeTextBackground();
      boolean isPostfixTemplate = node instanceof PostfixTemplateCheckedTreeNode;
      SimpleTextAttributes attributes = isPostfixTemplate
                                        ? SimpleTextAttributes.REGULAR_ATTRIBUTES
                                        : SimpleTextAttributes.REGULAR_BOLD_ATTRIBUTES;
      getTextRenderer().append(StringUtil.notNullize(value.toString()),
                               new SimpleTextAttributes(background, attributes.getFgColor(), JBColor.RED, attributes.getStyle()));
      if (isPostfixTemplate) {
        getTextRenderer()
          .append(" (" + ((PostfixTemplateCheckedTreeNode)node).getTemplate().getExample() + ")", SimpleTextAttributes.GRAY_ATTRIBUTES);
      }
    }
  }, new CheckedTreeNode(null));


  myModel = (DefaultTreeModel)getModel();
  myRoot = (CheckedTreeNode)myModel.getRoot();

  getSelectionModel().addTreeSelectionListener(new TreeSelectionListener() {
    @Override
    public void valueChanged(@NotNull TreeSelectionEvent event) {
      selectionChanged();
    }
  });
  setRootVisible(false);
  setShowsRootHandles(true);
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:35,代碼來源:PostfixTemplatesCheckboxTree.java

示例8: getTreeCellRendererComponent

import com.intellij.util.ui.UIUtil; //導入方法依賴的package包/類
@Override
public final Component getTreeCellRendererComponent(JTree tree,
                                                    Object value,
                                                    boolean selected,
                                                    boolean expanded,
                                                    boolean leaf,
                                                    int row,
                                                    boolean hasFocus) {
  if (!(value instanceof UpdaterTreeNode)) {
    return null;
  }
  UpdaterTreeNode node = (UpdaterTreeNode)value;
  invalidate();
  myCheckbox.setVisible(true);
  if (node.getCurrentState() == NodeStateHolder.SelectedState.MIXED) {
    myCheckbox.setState(ThreeStateCheckBox.State.DONT_CARE);
  }
  else {
    myCheckbox.setSelected(node.getCurrentState() == NodeStateHolder.SelectedState.INSTALLED);
  }
  myCheckbox.setOpaque(false);
  myCheckbox.setBackground(null);
  setBackground(null);
  myTextRenderer.getTreeCellRendererComponent(tree, value, selected, expanded, leaf, row, hasFocus);

  if (UIUtil.isUnderGTKLookAndFeel()) {
    final Color background = selected ? UIUtil.getTreeSelectionBackground() : UIUtil.getTreeTextBackground();
    UIUtil.changeBackGround(this, background);
  }
  else if (UIUtil.isUnderNimbusLookAndFeel()) {
    UIUtil.changeBackGround(this, UIUtil.TRANSPARENT_COLOR);
  }
  node.customizeRenderer(this, tree, selected, expanded, leaf, row, hasFocus);
  revalidate();

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

示例9: getBackground

import com.intellij.util.ui.UIUtil; //導入方法依賴的package包/類
@Override
protected Color getBackground() {
  return UIUtil.getTreeTextBackground();
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:5,代碼來源:GroupedElementsRenderer.java

示例10: applySpeedSearchHighlighting

import com.intellij.util.ui.UIUtil; //導入方法依賴的package包/類
public static void applySpeedSearchHighlighting(@NotNull JComponent speedSearchEnabledComponent,
                                                @NotNull SimpleColoredComponent coloredComponent,
                                                boolean mainTextOnly,
                                                boolean selected) {
  SpeedSearchSupply speedSearch = SpeedSearchSupply.getSupply(speedSearchEnabledComponent);
  // The bad thing is that SpeedSearch model is decoupled from UI presentation so we don't know the real matched text.
  // Our best guess is to get strgin from the ColoredComponent. We can only provide main-text-only option.
  Iterable<TextRange> ranges = speedSearch == null ? null : speedSearch.matchingFragments(coloredComponent.getCharSequence(mainTextOnly).toString());
  Iterator<TextRange> rangesIterator = ranges != null ? ranges.iterator() : null;
  if (rangesIterator == null || !rangesIterator.hasNext()) return;
  Color bg = selected ? UIUtil.getTreeSelectionBackground() : UIUtil.getTreeTextBackground();

  SimpleColoredComponent.ColoredIterator coloredIterator = coloredComponent.iterator();
  TextRange range = rangesIterator.next();
  main: while (coloredIterator.hasNext()) {
    coloredIterator.next();
    int offset = coloredIterator.getOffset();
    int endOffset = coloredIterator.getEndOffset();
    if (!range.intersectsStrict(offset, endOffset)) continue;
    SimpleTextAttributes attributes = coloredIterator.getTextAttributes();
    SimpleTextAttributes highlighted = new SimpleTextAttributes(bg, attributes.getFgColor(), null, attributes.getStyle() | SimpleTextAttributes.STYLE_SEARCH_MATCH);
    if (range.getStartOffset() > offset) {
      offset = coloredIterator.split(range.getStartOffset() - offset, attributes);
    }
    do {
      if (range.getEndOffset() <= endOffset) {
        offset = coloredIterator.split(range.getEndOffset() - offset, highlighted);
        if (rangesIterator.hasNext()) {
          range = rangesIterator.next();
        }
        else {
          break main;
        }
      }
      else {
        coloredIterator.split(endOffset - offset, highlighted);
        continue main;
      }
    }
    while (range.intersectsStrict(offset, endOffset));
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:43,代碼來源:SpeedSearchUtil.java

示例11: paint

import com.intellij.util.ui.UIUtil; //導入方法依賴的package包/類
public void paint(Graphics g) {
  int height = getHeight();
  int width = getWidth();
  int borderX = myLabelInsets.left - 1;
  int borderY = myLabelInsets.top - 1;
  int borderW = width - borderX - myLabelInsets.right + 2;
  int borderH = height - borderY - myLabelInsets.bottom + 1;

  if (myIcon != null) {
    int verticalIconPosition = (height - myIcon.getIconHeight())/2;
    myIcon.paintIcon(this, g, 0, verticalIconPosition);
    borderX += myIcon.getIconWidth();
    borderW -= myIcon.getIconWidth();
  }

  Color bgColor;
  Color fgColor;
  if (mySelected && myHasFocus){
    bgColor = UIUtil.getTreeSelectionBackground();
    fgColor = UIUtil.getTreeSelectionForeground();
  }
  else{
    bgColor = UIUtil.getTreeTextBackground();
    fgColor = getForeground();
  }

  // fill background
  if (!(myTree.getUI() instanceof WideSelectionTreeUI) || !((WideSelectionTreeUI)myTree.getUI()).isWideSelection()) {
    g.setColor(bgColor);
    g.fillRect(borderX, borderY, borderW, borderH);

    // draw border
    if (mySelected) {
      g.setColor(UIUtil.getTreeSelectionBorderColor());
      UIUtil.drawDottedRectangle(g, borderX, borderY, borderX + borderW - 1, borderY + borderH - 1);
    }
  }

  // paint text
  recalculateWraps();

  if (myTooSmall) { // TODO ???
    return;
  }

  int fontHeight = getCurrFontMetrics().getHeight();
  int currBaseLine = getCurrFontMetrics().getAscent();
  currBaseLine += myTextInsets.top;
  g.setFont(getFont());
  g.setColor(fgColor);
  UISettings.setupAntialiasing(g);

  if (!StringUtil.isEmpty(myPrefix)) {
    g.drawString(myPrefix, myTextInsets.left - myPrefixWidth + 1, currBaseLine);
  }

  for (int i = 0; i < myWraps.size(); i++) {
    String currLine = (String)myWraps.get(i);
    g.drawString(currLine, myTextInsets.left, currBaseLine);
    currBaseLine += fontHeight;  // first is getCurrFontMetrics().getAscent()
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:63,代碼來源:MultilineTreeCellRenderer.java

示例12: initTree

import com.intellij.util.ui.UIUtil; //導入方法依賴的package包/類
private void initTree() {
  myTree = new CheckboxTree(new CheckboxTree.CheckboxTreeCellRenderer(true) {
    @Override
    public void customizeRenderer(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) {
      if (!(value instanceof CheckedTreeNode)) return;
      CheckedTreeNode node = (CheckedTreeNode)value;
      SimpleTextAttributes attributes = node.getUserObject() instanceof IntentionActionMetaData ? SimpleTextAttributes.REGULAR_ATTRIBUTES : SimpleTextAttributes.REGULAR_BOLD_ATTRIBUTES;
      final String text = getNodeText(node);
      final Color background = selected ? UIUtil.getTreeSelectionBackground() : UIUtil.getTreeTextBackground();
      UIUtil.changeBackGround(this, background);
      if (text != null) {
        SearchUtil.appendFragments(myFilter != null ? myFilter.getFilter() : null,
                                   text,
                                   attributes.getStyle(),
                                   attributes.getFgColor(),
                                   background,
                                   getTextRenderer());
      }
    }
  }, new CheckedTreeNode(null));

  myTree.getSelectionModel().addTreeSelectionListener(new TreeSelectionListener() {
    @Override
    public void valueChanged(TreeSelectionEvent e) {
      TreePath path = e.getPath();
      Object userObject = ((DefaultMutableTreeNode)path.getLastPathComponent()).getUserObject();
      selectionChanged(userObject);
    }
  });

  myFilter = new MyFilterComponent();
  myComponent = new JPanel(new BorderLayout());
  JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(myTree);
  myNorthPanel = new JPanel(new BorderLayout());
  myNorthPanel.add(myFilter, BorderLayout.CENTER);

  final DefaultActionGroup group = new DefaultActionGroup();
  final CommonActionsManager actionManager = CommonActionsManager.getInstance();

  final DefaultTreeExpander treeExpander = new DefaultTreeExpander(myTree);
  group.add(actionManager.createExpandAllAction(treeExpander, myTree));
  group.add(actionManager.createCollapseAllAction(treeExpander, myTree));

  myNorthPanel.add(ActionManager.getInstance().createActionToolbar(ActionPlaces.UNKNOWN, group, true).getComponent(), BorderLayout.WEST);

  myComponent.add(myNorthPanel, BorderLayout.NORTH);
  myComponent.add(scrollPane, BorderLayout.CENTER);

  myFilter.reset();
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:51,代碼來源:IntentionSettingsTree.java


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