Java 类com.intellij.openapi.ui.Queryable 实例源码

项目:intellij-ce-playground    文件:PlatformTestUtil.java   
@Nullable
protected static String toString(@Nullable Object node, @Nullable Queryable.PrintInfo printInfo) {
  if (node instanceof AbstractTreeNode) {
    if (printInfo != null) {
      return ((AbstractTreeNode)node).toTestString(printInfo);
    }
    else {
      @SuppressWarnings({"deprecation", "UnnecessaryLocalVariable"})
      final String presentation = ((AbstractTreeNode)node).getTestPresentation();
      return presentation;
    }
  }
  if (node == null) {
    return "NULL";
  }
  return node.toString();
}
项目:intellij-ce-playground    文件:WindowSystemPlaybackCall.java   
private static LinkedHashMap<String, String> getFocusInfo() {
  final Component owner = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner();

  if (owner == null) {
    return null;
  }

  Component eachParent = owner;
  final LinkedHashMap<String, String> actual = new LinkedHashMap<String, String>();
  while (eachParent != null) {
    if (eachParent instanceof Queryable) {
      ((Queryable)eachParent).putInfo(actual);
    }

    eachParent = eachParent.getParent();
  }
  return actual;
}
项目:tools-idea    文件:PlatformTestUtil.java   
@Nullable
protected static String toString(@Nullable Object node, @Nullable Queryable.PrintInfo printInfo) {
  if (node instanceof AbstractTreeNode) {
    if (printInfo != null) {
      return ((AbstractTreeNode)node).toTestString(printInfo);
    }
    else {
      @SuppressWarnings({"deprecation", "UnnecessaryLocalVariable"})
      final String presentation = ((AbstractTreeNode)node).getTestPresentation();
      return presentation;
    }
  }
  if (node == null) {
    return "NULL";
  }
  return node.toString();
}
项目:tools-idea    文件:WindowSystemPlaybackCall.java   
private static LinkedHashMap<String, String> getFocusInfo() {
  final Component owner = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner();

  if (owner == null) {
    return null;
  }

  Component eachParent = owner;
  final LinkedHashMap<String, String> actual = new LinkedHashMap<String, String>();
  while (eachParent != null) {
    if (eachParent instanceof Queryable) {
      ((Queryable)eachParent).putInfo(actual);
    }

    eachParent = eachParent.getParent();
  }
  return actual;
}
项目:consulo    文件:PlatformTestUtil.java   
@Nullable
protected static String toString(@Nullable Object node, @Nullable Queryable.PrintInfo printInfo) {
  if (node instanceof AbstractTreeNode) {
    if (printInfo != null) {
      return ((AbstractTreeNode)node).toTestString(printInfo);
    }
    else {
      @SuppressWarnings({"deprecation", "UnnecessaryLocalVariable"})
      final String presentation = ((AbstractTreeNode)node).getTestPresentation();
      return presentation;
    }
  }
  if (node == null) {
    return "NULL";
  }
  return node.toString();
}
项目:intellij-ce-playground    文件:PsiClassImpl.java   
public static void putInfo(@NotNull PsiClass psiClass, @NotNull Map<String, String> info) {
  info.put("className", psiClass.getName());
  info.put("qualifiedClassName", psiClass.getQualifiedName());
  PsiFile file = psiClass.getContainingFile();
  if (file instanceof Queryable) {
    ((Queryable)file).putInfo(info);
  }
}
项目:intellij-ce-playground    文件:PackageElement.java   
@Override
public void putInfo(@NotNull Map<String, String> info) {
  PsiPackage pkg = getPackage();
  if (pkg instanceof Queryable) {
    ((Queryable)pkg).putInfo(info);
  }
}
项目:intellij-ce-playground    文件:PlatformTestUtil.java   
public static String print(JTree tree, Object root, 
                           boolean withSelection,
                           @Nullable Queryable.PrintInfo printInfo,
                           @Nullable Condition<String> nodePrintCondition) {
  StringBuilder buffer = new StringBuilder();
  final Collection<String> strings = printAsList(tree, root, withSelection, printInfo, nodePrintCondition);
  for (String string : strings) {
    buffer.append(string).append("\n");
  }
  return buffer.toString();
}
项目:intellij-ce-playground    文件:PlatformTestUtil.java   
private static Collection<String> printAsList(JTree tree, Object root, 
                                              boolean withSelection,
                                              @Nullable Queryable.PrintInfo printInfo,
                                              Condition<String> nodePrintCondition) {
  Collection<String> strings = new ArrayList<String>();
  printImpl(tree, root, strings, 0, withSelection, printInfo, nodePrintCondition);
  return strings;
}
项目:intellij-ce-playground    文件:PlatformTestUtil.java   
public static StringBuilder print(AbstractTreeStructure structure,
                                  Object node,
                                  int currentLevel,
                                  @Nullable Comparator comparator,
                                  int maxRowCount,
                                  char paddingChar,
                                  @Nullable Queryable.PrintInfo printInfo) {
  StringBuilder buffer = new StringBuilder();
  doPrint(buffer, currentLevel, node, structure, comparator, maxRowCount, 0, paddingChar, printInfo);
  return buffer;
}
项目:intellij-ce-playground    文件:PlatformTestUtil.java   
private static int doPrint(StringBuilder buffer,
                           int currentLevel,
                           Object node,
                           AbstractTreeStructure structure,
                           @Nullable Comparator comparator,
                           int maxRowCount,
                           int currentLine,
                           char paddingChar,
                           @Nullable Queryable.PrintInfo printInfo) {
  if (currentLine >= maxRowCount && maxRowCount != -1) return currentLine;

  StringUtil.repeatSymbol(buffer, paddingChar, currentLevel);
  buffer.append(toString(node, printInfo)).append("\n");
  currentLine++;
  Object[] children = structure.getChildElements(node);

  if (comparator != null) {
    ArrayList<?> list = new ArrayList<Object>(Arrays.asList(children));
    @SuppressWarnings({"UnnecessaryLocalVariable", "unchecked"}) Comparator<Object> c = comparator;
    Collections.sort(list, c);
    children = ArrayUtil.toObjectArray(list);
  }
  for (Object child : children) {
    currentLine = doPrint(buffer, currentLevel + 1, child, structure, comparator, maxRowCount, currentLine, paddingChar, printInfo);
  }

  return currentLine;
}
项目:intellij-ce-playground    文件:PlatformTestUtil.java   
public static Comparator<AbstractTreeNode> createComparator(final Queryable.PrintInfo printInfo) {
  return new Comparator<AbstractTreeNode>() {
    @Override
    public int compare(final AbstractTreeNode o1, final AbstractTreeNode o2) {
      String displayText1 = o1.toTestString(printInfo);
      String displayText2 = o2.toTestString(printInfo);
      return Comparing.compare(displayText1, displayText2);
    }
  };
}
项目:intellij-ce-playground    文件:ProjectViewTestUtil.java   
public static void assertStructureEqual(AbstractTreeStructure structure,
                                        String expected,
                                        int maxRowCount,
                                        @Nullable Comparator comparator,
                                        Object rootNode,
                                        @Nullable Queryable.PrintInfo printInfo) {
  checkGetParentConsistency(structure, rootNode);
  String actual = PlatformTestUtil.print(structure, rootNode, 0, comparator, maxRowCount, ' ', printInfo).toString();
  Assert.assertEquals(expected, actual);
}
项目:intellij-ce-playground    文件:AbstractTreeNode.java   
@Nullable
public String toTestString(@Nullable Queryable.PrintInfo printInfo) {
  if (getValue() instanceof Queryable) {
    String text = Queryable.Util.print((Queryable)getValue(), printInfo, this);
    if (text != null) return text;
  }

  return getTestPresentation();
}
项目:intellij-ce-playground    文件:AndroidResFileNode.java   
@Nullable
@Override
public String toTestString(@Nullable Queryable.PrintInfo printInfo) {
  PsiFile psiFile = getValue();
  String qualifier = getQualifier();
  return psiFile.getName() + (qualifier == null ? "" : qualifier);
}
项目:intellij-ce-playground    文件:AndroidManifestFileNode.java   
@Nullable
@Override
public String toTestString(@Nullable Queryable.PrintInfo printInfo) {
  StringBuilder sb = new StringBuilder();
  PsiFile file = getValue();
  sb.append(file.getName());
  sb.append(" (");
  sb.append(getSourceProvider(myFacet, getValue()).getName());
  sb.append(")");
  return sb.toString();
}
项目:intellij-ce-playground    文件:AndroidResGroupNode.java   
@Nullable
@Override
public String toTestString(@Nullable Queryable.PrintInfo printInfo) {
  StringBuilder sb = new StringBuilder(myResName);
  sb.append(" (");
  sb.append(myFiles.size());
  sb.append(")");
  return sb.toString();
}
项目:intellij-ce-playground    文件:AndroidProjectViewTest.java   
public void testCommonRoots() throws Exception {
  loadProject("projects/navigator/packageview/commonroots");

  myPane = createPane();
  TestAndroidTreeStructure structure = new TestAndroidTreeStructure(getProject(), myTestRootDisposable);

  Queryable.PrintInfo printInfo = new Queryable.PrintInfo();
  PsiDirectory dir = getBaseFolder();
  assertNotNull(dir);

  Module[] modules = ModuleManager.getInstance(getProject()).getModules();
  assertEquals(1, modules.length);

  String projectName = getProject().getName();
  String expected =
    projectName + "\n" +
    " Gradle Scripts\n" +
    "  build.gradle (Module: " + modules[0].getName() + ")\n" +
    "  gradle-wrapper.properties (Gradle Version)\n" +
    " " + modules[0].getName() + " (Android)\n" +
    "  java\n" +
    "   foo (main)\n" +
    "    Foo.java\n" +
    "  manifests\n" +
    "   AndroidManifest.xml (main)\n" +
    "  res\n" +
    "   values\n" +
    "    dimens.xml (w820dp)\n" +
    "  resources\n" +
    "   sample_resource.txt\n";
  int numLines = expected.split("\n").length;
  ProjectViewTestUtil
    .assertStructureEqual(structure, expected, numLines, PlatformTestUtil.createComparator(printInfo), structure.getRootElement(),
                          printInfo);
}
项目:tools-idea    文件:PsiClassImpl.java   
public static void putInfo(@NotNull PsiClass psiClass, @NotNull Map<String, String> info) {
  info.put("className", psiClass.getName());
  info.put("qualifiedClassName", psiClass.getQualifiedName());
  PsiFile file = psiClass.getContainingFile();
  if (file instanceof Queryable) {
    ((Queryable)file).putInfo(info);
  }
}
项目:tools-idea    文件:PackageElement.java   
@Override
public void putInfo(@NotNull Map<String, String> info) {
  PsiPackage pkg = getPackage();
  if (pkg instanceof Queryable) {
    ((Queryable)pkg).putInfo(info);
  }
}
项目:tools-idea    文件:AbstractTreeNode.java   
@Nullable
public String toTestString(@Nullable Queryable.PrintInfo printInfo) {
  if (getValue() instanceof Queryable) {
    String text = Queryable.Util.print((Queryable)getValue(), printInfo, this);
    if (text != null) return text;
  }

  return getTestPresentation();
}
项目:tools-idea    文件:PlatformTestUtil.java   
public static StringBuilder print(AbstractTreeStructure structure,
                                  Object node,
                                  int currentLevel,
                                  @Nullable Comparator comparator,
                                  int maxRowCount,
                                  char paddingChar,
                                  @Nullable Queryable.PrintInfo printInfo) {
  StringBuilder buffer = new StringBuilder();
  doPrint(buffer, currentLevel, node, structure, comparator, maxRowCount, 0, paddingChar, printInfo);
  return buffer;
}
项目:tools-idea    文件:PlatformTestUtil.java   
private static int doPrint(StringBuilder buffer,
                           int currentLevel,
                           Object node,
                           AbstractTreeStructure structure,
                           @Nullable Comparator comparator,
                           int maxRowCount,
                           int currentLine,
                           char paddingChar,
                           @Nullable Queryable.PrintInfo printInfo) {
  if (currentLine >= maxRowCount && maxRowCount != -1) return currentLine;

  StringUtil.repeatSymbol(buffer, paddingChar, currentLevel);
  buffer.append(toString(node, printInfo)).append("\n");
  currentLine++;
  Object[] children = structure.getChildElements(node);

  if (comparator != null) {
    ArrayList<?> list = new ArrayList<Object>(Arrays.asList(children));
    @SuppressWarnings({"UnnecessaryLocalVariable", "unchecked"}) Comparator<Object> c = comparator;
    Collections.sort(list, c);
    children = ArrayUtil.toObjectArray(list);
  }
  for (Object child : children) {
    currentLine = doPrint(buffer, currentLevel + 1, child, structure, comparator, maxRowCount, currentLine, paddingChar, printInfo);
  }

  return currentLine;
}
项目:tools-idea    文件:PlatformTestUtil.java   
public static Comparator<AbstractTreeNode> createComparator(final Queryable.PrintInfo printInfo) {
  return new Comparator<AbstractTreeNode>() {
    @Override
    public int compare(final AbstractTreeNode o1, final AbstractTreeNode o2) {
      String displayText1 = o1.toTestString(printInfo);
      String displayText2 = o2.toTestString(printInfo);
      return Comparing.compare(displayText1, displayText2);
    }
  };
}
项目:tools-idea    文件:ProjectViewTestUtil.java   
public static void assertStructureEqual(AbstractTreeStructure structure,
                                        String expected,
                                        int maxRowCount,
                                        @Nullable Comparator comparator,
                                        Object rootNode,
                                        @Nullable Queryable.PrintInfo printInfo) {
  checkGetParentConsistency(structure, rootNode);
  String actual = PlatformTestUtil.print(structure, rootNode, 0, comparator, maxRowCount, ' ', printInfo).toString();
  Assert.assertEquals(expected, actual);
}
项目:consulo    文件:PlatformTestUtil.java   
public static StringBuilder print(AbstractTreeStructure structure,
                                  Object node,
                                  int currentLevel,
                                  @javax.annotation.Nullable Comparator comparator,
                                  int maxRowCount,
                                  char paddingChar,
                                  @Nullable Queryable.PrintInfo printInfo) {
  StringBuilder buffer = new StringBuilder();
  doPrint(buffer, currentLevel, node, structure, comparator, maxRowCount, 0, paddingChar, printInfo);
  return buffer;
}
项目:consulo    文件:PlatformTestUtil.java   
private static int doPrint(StringBuilder buffer,
                           int currentLevel,
                           Object node,
                           AbstractTreeStructure structure,
                           @Nullable Comparator comparator,
                           int maxRowCount,
                           int currentLine,
                           char paddingChar,
                           @Nullable Queryable.PrintInfo printInfo) {
  if (currentLine >= maxRowCount && maxRowCount != -1) return currentLine;

  StringUtil.repeatSymbol(buffer, paddingChar, currentLevel);
  buffer.append(toString(node, printInfo)).append("\n");
  currentLine++;
  Object[] children = structure.getChildElements(node);

  if (comparator != null) {
    ArrayList<?> list = new ArrayList<Object>(Arrays.asList(children));
    @SuppressWarnings({"UnnecessaryLocalVariable", "unchecked"}) Comparator<Object> c = comparator;
    Collections.sort(list, c);
    children = ArrayUtil.toObjectArray(list);
  }
  for (Object child : children) {
    currentLine = doPrint(buffer, currentLevel + 1, child, structure, comparator, maxRowCount, currentLine, paddingChar, printInfo);
  }

  return currentLine;
}
项目:consulo    文件:PlatformTestUtil.java   
public static Comparator<AbstractTreeNode> createComparator(final Queryable.PrintInfo printInfo) {
  return new Comparator<AbstractTreeNode>() {
    @Override
    public int compare(final AbstractTreeNode o1, final AbstractTreeNode o2) {
      String displayText1 = o1.toTestString(printInfo);
      String displayText2 = o2.toTestString(printInfo);
      return Comparing.compare(displayText1, displayText2);
    }
  };
}
项目:consulo    文件:ProjectViewTestUtil.java   
public static void assertStructureEqual(AbstractTreeStructure structure,
                                        String expected,
                                        int maxRowCount,
                                        @Nullable Comparator comparator,
                                        Object rootNode,
                                        @Nullable Queryable.PrintInfo printInfo) {
  checkGetParentConsistency(structure, rootNode);
  String actual = PlatformTestUtil.print(structure, rootNode, 0, comparator, maxRowCount, ' ', printInfo).toString();
  Assert.assertEquals(expected, actual);
}
项目:consulo    文件:AbstractTreeNode.java   
@Nullable
public String toTestString(@Nullable Queryable.PrintInfo printInfo) {
  if (getValue() instanceof Queryable) {
    String text = Queryable.Util.print((Queryable)getValue(), printInfo, this);
    if (text != null) return text;
  }

  return getTestPresentation();
}
项目:consulo    文件:PackageElement.java   
@Override
public void putInfo(@Nonnull Map<String, String> info) {
  PsiPackage pkg = getPackage();
  if (pkg instanceof Queryable) {
    ((Queryable)pkg).putInfo(info);
  }
}
项目:consulo    文件:NavBarPopup.java   
private static JComponent createPopupContent(NavBarPanel panel, Object[] siblings) {
  class MyList<E> extends JBList<E> implements DataProvider, Queryable {
    @Override
    public void putInfo(@Nonnull Map<String, String> info) {
      panel.putInfo(info);
    }

    @Nullable
    @Override
    public Object getData(Key dataId) {
      return panel.getDataImpl(dataId, () -> JBIterable.of(getSelectedValuesList()));
    }
  }
  JBList<Object> list = new MyList<>();
  list.setModel(new CollectionListModel<>(siblings));
  HintUpdateSupply.installSimpleHintUpdateSupply(list);
  List<Disposable> disposables = new ArrayList<>();
  list.putClientProperty(DISPOSED_OBJECTS, disposables);
  list.installCellRenderer(obj -> {
    final NavBarItem navBarItem = new NavBarItem(panel, obj, null);
    disposables.add(navBarItem);
    return navBarItem;
  });
  list.setBorder(JBUI.Borders.empty(5));
  installMoveAction(list, panel, -1, KeyEvent.VK_LEFT);
  installMoveAction(list, panel, 1, KeyEvent.VK_RIGHT);
  installEnterAction(list, panel, KeyEvent.VK_ENTER);
  installEscapeAction(list, panel, KeyEvent.VK_ESCAPE);
  JComponent component = ListWithFilter.wrap(list, new NavBarListWrapper(list), o -> panel.getPresentation().getPresentableText(o));
  component.putClientProperty(JBLIST_KEY, list);
  return component;
}
项目:consulo-java    文件:PsiClassImpl.java   
public static void putInfo(@NotNull PsiClass psiClass, @NotNull Map<String, String> info)
{
    info.put("className", psiClass.getName());
    info.put("qualifiedClassName", psiClass.getQualifiedName());
    PsiFile file = psiClass.getContainingFile();
    if(file instanceof Queryable)
    {
        ((Queryable) file).putInfo(info);
    }
}
项目:intellij-ce-playground    文件:ToDoTreeStructureTest.java   
@Override
protected void setUp() throws Exception {
  super.setUp();
  myPrintInfo = new Queryable.PrintInfo(new String[] {"className", "fileName", "fieldName", "methodName", "packageName"}, new String[] {"toDoFileCount", "toDoItemCount"});
}
项目:intellij-ce-playground    文件:ProjectTreeSortingTest.java   
private void assertTree(String expected) {
  DefaultMutableTreeNode element = myPane.getTreeBuilder().getNodeForElement(getContentDirectory());
  assertNotNull("Element for " + getContentDirectory() + " not found", element);
  assertEquals(expected, PlatformTestUtil.print(myPane.getTree(), element, new Queryable.PrintInfo(), false));
}
项目:intellij-ce-playground    文件:ProjectTreeStructureTest.java   
@Override
protected void setUp() throws Exception {
  super.setUp();
  myPrintInfo = new Queryable.PrintInfo();
}
项目:intellij-ce-playground    文件:ClassNameConvertor.java   
@NotNull
@Override
public Collection<AbstractTreeNode> modify(@NotNull AbstractTreeNode parent, @NotNull Collection<AbstractTreeNode> children, ViewSettings settings) {
  ArrayList<AbstractTreeNode> result = new ArrayList<AbstractTreeNode>();

  for (final AbstractTreeNode aChildren : children) {
    ProjectViewNode treeNode = (ProjectViewNode)aChildren;
    Object o = treeNode.getValue();
    if (o instanceof PsiFile && ((PsiFile)o).getVirtualFile().getExtension().equals("java")) {
      final String name = ((PsiFile)o).getName();
      ProjectViewNode viewNode = new ProjectViewNode<PsiFile>(myProject, (PsiFile)o, settings) {
        @Override
        @NotNull
        public Collection<AbstractTreeNode> getChildren() {
          return Collections.emptyList();
        }

        @Override
        public String toTestString(Queryable.PrintInfo printInfo) {
          return super.toTestString(printInfo) + " converted";
        }

        @Override
        public String getTestPresentation() {
          return name + " converted";
        }

        @Override
        public boolean contains(@NotNull VirtualFile file) {
          return false;
        }

        @Override
        public void update(PresentationData presentation) {
        }

      };
      result.add(viewNode);
    }
    else {
      result.add(treeNode);
    }
  }
  return result;
}
项目:intellij-ce-playground    文件:TabInfo.java   
public TabInfo setTestableUi(Queryable queryable) {
  myQueryable = queryable;
  return this;
}
项目:intellij-ce-playground    文件:PlatformTestUtil.java   
public static String print(JTree tree, Object root, @Nullable Queryable.PrintInfo printInfo, boolean withSelection) {
  return print(tree, root,  withSelection, printInfo, null);
}
项目:intellij-ce-playground    文件:PlatformTestUtil.java   
private static void printImpl(JTree tree,
                              Object root,
                              Collection<String> strings,
                              int level,
                              boolean withSelection,
                              @Nullable Queryable.PrintInfo printInfo,
                              @Nullable Condition<String> nodePrintCondition) {
  DefaultMutableTreeNode defaultMutableTreeNode = (DefaultMutableTreeNode)root;

  final Object userObject = defaultMutableTreeNode.getUserObject();
  String nodeText;
  if (userObject != null) {
    nodeText = toString(userObject, printInfo);
  }
  else {
    nodeText = "null";
  }

  if (nodePrintCondition != null && !nodePrintCondition.value(nodeText)) return;

  final StringBuilder buff = new StringBuilder();
  StringUtil.repeatSymbol(buff, ' ', level);

  final boolean expanded = tree.isExpanded(new TreePath(defaultMutableTreeNode.getPath()));
  if (!defaultMutableTreeNode.isLeaf()) {
    buff.append(expanded ? "-" : "+");
  }

  final boolean selected = tree.getSelectionModel().isPathSelected(new TreePath(defaultMutableTreeNode.getPath()));
  if (withSelection && selected) {
    buff.append("[");
  }

  buff.append(nodeText);

  if (withSelection && selected) {
    buff.append("]");
  }

  strings.add(buff.toString());

  int childCount = tree.getModel().getChildCount(root);
  if (expanded) {
    for (int i = 0; i < childCount; i++) {
      printImpl(tree, tree.getModel().getChild(root, i), strings, level + 1, withSelection, printInfo, nodePrintCondition);
    }
  }
}