private boolean customize(Object value) {
   final Object userObject = ((DefaultMutableTreeNode) value).getUserObject();
   if (!(userObject instanceof TreeElementWrapper)) {
     return false;
   }
   final TreeElement treeElement = ((TreeElementWrapper) userObject).getValue();
   if (treeElement == null) {
     return false;
   }
   final ItemPresentation presentation = treeElement.getPresentation();
   if (presentation instanceof TextAttributesPresentation) {
     final TextAttributesPresentation textAttributesPresentation =
         (TextAttributesPresentation) presentation;
     final String text = textAttributesPresentation.getPresentableText();
     if (text != null) {
       final SimpleTextAttributes attr =
           SimpleTextAttributes.fromTextAttributes(
               textAttributesPresentation.getTextAttributes(getColorsScheme()));
       append(
           text,
           new SimpleTextAttributes(
               attr.getBgColor(),
               attr.getFgColor(),
               attr.getWaveColor(),
               attr.getStyle() | SimpleTextAttributes.STYLE_OPAQUE));
       return true;
     }
   }
   return false;
 }
コード例 #2
0
  private void setStructureViewSelection(@NotNull final String propertyName) {
    if (myStructureViewComponent.isDisposed()) {
      return;
    }
    JTree tree = myStructureViewComponent.getTree();
    if (tree == null) {
      return;
    }

    Object root = tree.getModel().getRoot();
    if (AbstractTreeUi.isLoadingChildrenFor(root)) {
      mySelectionChangeAlarm.cancelAllRequests();
      mySelectionChangeAlarm.addRequest(
          new Runnable() {
            @Override
            public void run() {
              mySelectionChangeAlarm.cancelAllRequests();
              setStructureViewSelection(propertyName);
            }
          },
          500);
      return;
    }

    Stack<TreeElement> toCheck = ContainerUtilRt.newStack();
    toCheck.push(myStructureViewComponent.getTreeModel().getRoot());

    while (!toCheck.isEmpty()) {
      TreeElement element = toCheck.pop();
      PsiElement value =
          element instanceof ResourceBundlePropertyStructureViewElement
              ? ((ResourceBundlePropertyStructureViewElement) element).getValue()
              : null;
      if (value instanceof IProperty
          && propertyName.equals(((IProperty) value).getUnescapedKey())) {
        myStructureViewComponent.select(value, true);
        selectionChanged();
        return;
      } else {
        for (TreeElement treeElement : element.getChildren()) {
          toCheck.push(treeElement);
        }
      }
    }
  }