Java 类com.intellij.ui.LoadingNode 实例源码

项目:intellij-ce-playground    文件:NotificationMessageElement.java   
protected void updateStyle(@NotNull JEditorPane editorPane, @Nullable JTree tree, Object value, boolean selected, boolean hasFocus) {
  final HTMLDocument htmlDocument = (HTMLDocument)editorPane.getDocument();
  final Style style = htmlDocument.getStyleSheet().getStyle(MSG_STYLE);
  if (value instanceof LoadingNode) {
    StyleConstants.setForeground(style, JBColor.GRAY);
  }
  else {
    if (selected) {
      StyleConstants.setForeground(style, hasFocus ? UIUtil.getTreeSelectionForeground() : UIUtil.getTreeTextForeground());
    }
    else {
      StyleConstants.setForeground(style, UIUtil.getTreeTextForeground());
    }
  }

  if (UIUtil.isUnderGTKLookAndFeel() ||
      UIUtil.isUnderNimbusLookAndFeel() && selected && hasFocus ||
      tree != null && tree.getUI() instanceof WideSelectionTreeUI && ((WideSelectionTreeUI)tree.getUI()).isWideSelection()) {
    editorPane.setOpaque(false);
  }
  else {
    editorPane.setOpaque(selected && hasFocus);
  }

  htmlDocument.setCharacterAttributes(0, htmlDocument.getLength(), style, false);
}
项目:consulo    文件:NotificationMessageElement.java   
protected void updateStyle(@Nonnull JEditorPane editorPane, @javax.annotation.Nullable JTree tree, Object value, boolean selected, boolean hasFocus) {
  final HTMLDocument htmlDocument = (HTMLDocument)editorPane.getDocument();
  final Style style = htmlDocument.getStyleSheet().getStyle(MSG_STYLE);
  if (value instanceof LoadingNode) {
    StyleConstants.setForeground(style, JBColor.GRAY);
  }
  else {
    if (selected) {
      StyleConstants.setForeground(style, hasFocus ? UIUtil.getTreeSelectionForeground() : UIUtil.getTreeTextForeground());
    }
    else {
      StyleConstants.setForeground(style, UIUtil.getTreeTextForeground());
    }
  }

  if (UIUtil.isUnderGTKLookAndFeel() ||
      UIUtil.isUnderNimbusLookAndFeel() && selected && hasFocus ||
      tree != null && tree.getUI() instanceof WideSelectionTreeUI && ((WideSelectionTreeUI)tree.getUI()).isWideSelection()) {
    editorPane.setOpaque(false);
  }
  else {
    editorPane.setOpaque(selected && hasFocus);
  }

  htmlDocument.setCharacterAttributes(0, htmlDocument.getLength(), style, false);
}
项目:intellij-ce-playground    文件:AbstractTreeUi.java   
private void insertLoadingNode(final DefaultMutableTreeNode node, boolean addToUnbuilt) {
  if (!isLoadingChildrenFor(node)) {
    myTreeModel.insertNodeInto(new LoadingNode(), node, 0);
  }

  if (addToUnbuilt) {
    addToUnbuilt(node);
  }
}
项目:intellij-ce-playground    文件:NewErrorTreeEditor.java   
public Component getTreeCellEditorComponent(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row) {
  myPanel.removeAll();
  myPanel.add(myLeft.getTreeCellRendererComponent(tree, value, false, expanded, leaf, row, true), BorderLayout.WEST);
  myPanel.add(myRight.getTreeCellEditorComponent(tree, value, selected, expanded, leaf, row), BorderLayout.EAST);

  if (UIUtil.isFullRowSelectionLAF()) {
    myPanel.setBackground(selected ? UIUtil.getTreeSelectionBackground() : null);
  }
  else if (tree.getUI() instanceof WideSelectionTreeUI && ((WideSelectionTreeUI)tree.getUI()).isWideSelection()) {
    if (selected) {
      myPanel.setBackground(UIUtil.getTreeSelectionBackground());
    }
  }
  else if (selected) {
    myPanel.setBackground(UIUtil.getTreeSelectionBackground());
  }
  else {
    myPanel.setBackground(null);
  }

  if (value instanceof LoadingNode) {
    myPanel.setForeground(JBColor.GRAY);
  }
  else {
    myPanel.setForeground(tree.getForeground());
  }

  if (UIUtil.isUnderGTKLookAndFeel() ||
      UIUtil.isUnderNimbusLookAndFeel() && selected ||
      tree.getUI() instanceof WideSelectionTreeUI && ((WideSelectionTreeUI)tree.getUI()).isWideSelection()) {
    myPanel.setOpaque(false);
  }
  return myPanel;
}
项目:intellij-ce-playground    文件:LayoutEditorFixture.java   
private void describe(@NotNull SimpleColoredRenderer renderer,
                      @NotNull AttributeWrapper wrapper,
                      @NotNull ComponentTree componentTree,
                      @NotNull TreeModel model,
                      @NotNull Object node,
                      boolean showSelected,
                      int depth) {
  SimpleTextAttributes style = wrapper.getAttribute(SimpleTextAttributes.REGULAR_ATTRIBUTES);
  for (int i = 0; i < depth; i++) {
    renderer.append("    ", style);
  }

  if (!model.isLeaf(node) && model.getChildCount(node) > 0 &&
    model.getChild(node, 0) instanceof LoadingNode) {
    renderer.append("> ", style);
  }

  RadComponent component = componentTree.extractComponent(node);
  if (component != null) {
    if (showSelected && myPanel.getSurfaceArea().isSelected(component)) {
      renderer.append("*");
    }
    myPanel.getTreeDecorator().decorate(component, renderer, wrapper, true);
  }
  else {
    renderer.append("<missing component>", style);
  }
  renderer.append("\n", style);

  if (!model.isLeaf(node)) {
    for (int i = 0, n = model.getChildCount(node); i < n; i++) {
      Object child = model.getChild(node, i);
      if (child instanceof LoadingNode) {
        continue;
      }
      describe(renderer, wrapper, componentTree, model, child, showSelected, depth + 1);
    }
  }
}
项目:tools-idea    文件:AbstractTreeUi.java   
private void insertLoadingNode(final DefaultMutableTreeNode node, boolean addToUnbuilt) {
  if (!isLoadingChildrenFor(node)) {
    myTreeModel.insertNodeInto(new LoadingNode(), node, 0);
  }

  if (addToUnbuilt) {
    addToUnbuilt(node);
  }
}
项目:consulo    文件:AbstractTreeUi.java   
private void insertLoadingNode(final DefaultMutableTreeNode node, boolean addToUnbuilt) {
  if (!isLoadingChildrenFor(node)) {
    myTreeModel.insertNodeInto(new LoadingNode(), node, 0);
  }

  if (addToUnbuilt) {
    addToUnbuilt(node);
  }
}
项目:consulo    文件:NewErrorTreeEditor.java   
public Component getTreeCellEditorComponent(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row) {
  myPanel.removeAll();
  myPanel.add(myLeft.getTreeCellRendererComponent(tree, value, false, expanded, leaf, row, true), BorderLayout.WEST);
  myPanel.add(myRight.getTreeCellEditorComponent(tree, value, selected, expanded, leaf, row), BorderLayout.EAST);

  if (UIUtil.isFullRowSelectionLAF()) {
    myPanel.setBackground(selected ? UIUtil.getTreeSelectionBackground() : null);
  }
  else if (tree.getUI() instanceof WideSelectionTreeUI && ((WideSelectionTreeUI)tree.getUI()).isWideSelection()) {
    if (selected) {
      myPanel.setBackground(UIUtil.getTreeSelectionBackground());
    }
  }
  else if (selected) {
    myPanel.setBackground(UIUtil.getTreeSelectionBackground());
  }
  else {
    myPanel.setBackground(null);
  }

  if (value instanceof LoadingNode) {
    myPanel.setForeground(JBColor.GRAY);
  }
  else {
    myPanel.setForeground(tree.getForeground());
  }

  if (UIUtil.isUnderGTKLookAndFeel() ||
      UIUtil.isUnderNimbusLookAndFeel() && selected ||
      tree.getUI() instanceof WideSelectionTreeUI && ((WideSelectionTreeUI)tree.getUI()).isWideSelection()) {
    myPanel.setOpaque(false);
  }
  return myPanel;
}
项目:intellij-ce-playground    文件:AbstractTreeUi.java   
public static boolean isLoadingNode(final Object node) {
  return node instanceof LoadingNode;
}
项目:intellij-ce-playground    文件:TreeUiTest.java   
public void testUpdateCollapsedBuiltNode() throws Exception {
  buildStructure(myRoot, false);

  myCom.removeAll();
  myAlwaysShowPlus.add(new NodeElement("com"));

  activate();

  buildNode("/", false);
  assertTree("-/\n" +
             " +com\n" +
             " +jetbrains\n" +
             " +org\n" +
             " +xUnit\n");

  final DefaultMutableTreeNode com = findNode("com", false);
  assertNotNull(com);
  assertEquals(1, com.getChildCount());
  assertEquals(LoadingNode.getText(), com.getChildAt(0).toString());

  expand(getPath("com"));
  assertTree("-/\n" +
             " com\n" +
             " +jetbrains\n" +
             " +org\n" +
             " +xUnit\n");

  myCom.addChild(myIntellij);
  updateFrom(new NodeElement("com"));
  assertTree("-/\n" +
             " +com\n" +
             " +jetbrains\n" +
             " +org\n" +
             " +xUnit\n");
  assertEquals(1, com.getChildCount());
  assertEquals("intellij", com.getChildAt(0).toString());

  myCom.removeAll();
  updateFrom(new NodeElement("com"));

  expand(getPath("com"));
  assertTree("-/\n" +
             " com\n" +
             " +jetbrains\n" +
             " +org\n" +
             " +xUnit\n");
}
项目:js-graphql-intellij-plugin    文件:JSGraphQLSchemaLanguageProjectService.java   
private void selectProjectSchemaInTree(@NotNull FileEditorManagerEvent event) {
    if(!isProjectSchemaFile(event.getNewFile())) {
        return;
    }
    try {
        JSGraphQLSchemaFileNode node = project.getUserData(JSGraphQLSchemaFileNode.GRAPHQL_SCHEMA_TREE_NODE);
        if(node != null) {
            final ProjectView projectView = ProjectView.getInstance(project);
            if(projectView.isAutoscrollFromSource(projectView.getCurrentViewId())) {
                final AbstractProjectViewPane projectViewPane = projectView.getCurrentProjectViewPane();
                if(projectViewPane != null) {
                    if(projectViewPane.getSelectedDescriptor() != node) {
                        final JTree tree = projectViewPane.getTree();
                        final TreeNode root = (TreeNode) tree.getModel().getRoot();
                        if(root != null) {
                            for(int c = 0; c < root.getChildCount(); c++) {
                                final TreeNode schemaDirectory = root.getChildAt(c);
                                if(schemaDirectory instanceof DefaultMutableTreeNode) {
                                    final Object userObject = ((DefaultMutableTreeNode) schemaDirectory).getUserObject();
                                    if(userObject instanceof JSGraphQLSchemaDirectoryNode) {
                                        if(schemaDirectory.getChildCount() == 1) {
                                            final TreeNode schemaNode = schemaDirectory.getChildAt(0);
                                            final TreePath treePath = new TreePath(
                                                    new Object[]{root, schemaDirectory, schemaNode}
                                            );
                                            TreeModelListener treeModelListener = project.getUserData(SCHEMA_TREE_MODEL_LISTENER);
                                            if(treeModelListener == null) {
                                                treeModelListener = new TreeModelListener() {
                                                    @Override
                                                    public void treeNodesInserted(TreeModelEvent treeModelEvent) {
                                                        // idea uses "Loading..." nodes, so listen for inserts
                                                        if(Boolean.TRUE.equals(project.getUserData(SCHEMA_TREE_SELECT_ON_INSERT))) {
                                                            if(treeModelEvent.getChildren() != null) {
                                                                Object child = treeModelEvent.getChildren()[0];
                                                                if(child instanceof DefaultMutableTreeNode) {
                                                                    final DefaultMutableTreeNode insertedNode = (DefaultMutableTreeNode) child;
                                                                    if(insertedNode.getUserObject() instanceof JSGraphQLSchemaFileNode) {
                                                                        final TreePath insertTreePath = new TreePath(insertedNode.getPath());
                                                                        tree.setSelectionPath(insertTreePath);
                                                                        tree.scrollPathToVisible(insertTreePath);
                                                                        project.putUserData(SCHEMA_TREE_SELECT_ON_INSERT, false);
                                                                    }
                                                                }
                                                            }
                                                        }
                                                    }
                                                    @Override
                                                    public void treeNodesChanged(TreeModelEvent treeModelEvent) {}
                                                    @Override
                                                    public void treeNodesRemoved(TreeModelEvent treeModelEvent) {}
                                                    @Override
                                                    public void treeStructureChanged(TreeModelEvent treeModelEvent) {}
                                                };
                                                tree.getModel().addTreeModelListener(treeModelListener);
                                                project.putUserData(SCHEMA_TREE_MODEL_LISTENER, treeModelListener);
                                            }
                                            tree.expandPath(treePath);
                                            tree.setSelectionPath(treePath);
                                            tree.scrollPathToVisible(treePath);
                                            project.putUserData(SCHEMA_TREE_SELECT_ON_INSERT, schemaNode instanceof LoadingNode);
                                            break;
                                        }
                                    }
                                }
                            }
                        }

                    }
                }
            }
        }
    } catch (Exception e) {
        log.warn("Unable to select GraphQL schema node", e);
    }
}
项目:tools-idea    文件:AbstractTreeUi.java   
public static boolean isLoadingNode(final Object node) {
  return node instanceof LoadingNode;
}
项目:tools-idea    文件:TreeUiTest.java   
public void testUpdateCollapsedBuiltNode() throws Exception {
  buildStructure(myRoot, false);

  myCom.removeAll();
  myAlwaysShowPlus.add(new NodeElement("com"));

  activate();

  buildNode("/", false);
  assertTree("-/\n" +
             " +com\n" +
             " +jetbrains\n" +
             " +org\n" +
             " +xUnit\n");

  final DefaultMutableTreeNode com = findNode("com", false);
  assertNotNull(com);
  assertEquals(1, com.getChildCount());
  assertEquals(LoadingNode.getText(), com.getChildAt(0).toString());

  expand(getPath("com"));
  assertTree("-/\n" +
             " com\n" +
             " +jetbrains\n" +
             " +org\n" +
             " +xUnit\n");

  myCom.addChild(myIntellij);
  updateFrom(new NodeElement("com"));
  assertTree("-/\n" +
             " +com\n" +
             " +jetbrains\n" +
             " +org\n" +
             " +xUnit\n");
  assertEquals(1, com.getChildCount());
  assertEquals("intellij", com.getChildAt(0).toString());

  myCom.removeAll();
  updateFrom(new NodeElement("com"));

  expand(getPath("com"));
  assertTree("-/\n" +
             " com\n" +
             " +jetbrains\n" +
             " +org\n" +
             " +xUnit\n");
}
项目:consulo    文件:TreeUiTest.java   
public void testUpdateCollapsedBuiltNode() throws Exception {
  buildStructure(myRoot, false);

  myCom.removeAll();
  myAlwaysShowPlus.add(new NodeElement("com"));

  activate();

  buildNode("/", false);
  assertTree("-/\n" +
             " +com\n" +
             " +jetbrains\n" +
             " +org\n" +
             " +xUnit\n");

  final DefaultMutableTreeNode com = findNode("com", false);
  assertNotNull(com);
  assertEquals(1, com.getChildCount());
  assertEquals(LoadingNode.getText(), com.getChildAt(0).toString());

  expand(getPath("com"));
  assertTree("-/\n" +
             " com\n" +
             " +jetbrains\n" +
             " +org\n" +
             " +xUnit\n");

  myCom.addChild(myIntellij);
  updateFrom(new NodeElement("com"));
  assertTree("-/\n" +
             " +com\n" +
             " +jetbrains\n" +
             " +org\n" +
             " +xUnit\n");
  assertEquals(1, com.getChildCount());
  assertEquals("intellij", com.getChildAt(0).toString());

  myCom.removeAll();
  updateFrom(new NodeElement("com"));

  expand(getPath("com"));
  assertTree("-/\n" +
             " com\n" +
             " +jetbrains\n" +
             " +org\n" +
             " +xUnit\n");
}
项目:consulo    文件:AbstractTreeUi.java   
public static boolean isLoadingNode(final Object node) {
  return node instanceof LoadingNode;
}