private InspectorPanel()

in flutter-idea/src/io/flutter/view/InspectorPanel.java [150:304]


  private InspectorPanel(FlutterView flutterView,
                         @NotNull FlutterApp flutterApp,
                         @NotNull InspectorService inspectorService,
                         @NotNull Computable<Boolean> isApplicable,
                         @NotNull InspectorService.FlutterTreeType treeType,
                         boolean detailsSubtree,
                         @Nullable InspectorPanel parentTree,
                         boolean isSummaryTree,
                         boolean legacyMode,
                         @NotNull EventStream<Boolean> shouldAutoHorizontalScroll,
                         @NotNull EventStream<Boolean> highlightNodesShownInBothTrees) {
    super(new BorderLayout());

    this.treeType = treeType;
    this.flutterApp = flutterApp;
    this.inspectorService = inspectorService;
    this.treeGroups = new InspectorObjectGroupManager(inspectorService, "tree");
    this.selectionGroups = new InspectorObjectGroupManager(inspectorService, "selection");
    this.isApplicable = isApplicable;
    this.detailsSubtree = detailsSubtree;
    this.isSummaryTree = isSummaryTree;
    this.parentTree = parentTree;
    this.legacyMode = legacyMode;

    this.defaultIcon = iconMaker.fromInfo("Default");

    if (!Disposer.isDisposed(flutterApp)) {
      // Only process refresh requests if the app is still running.
      refreshRateLimiter = new AsyncRateLimiter(REFRESH_FRAMES_PER_SECOND, this::refresh, flutterApp);
    }

    final String parentTreeDisplayName = (parentTree != null) ? parentTree.treeType.displayName : null;

    myRootsTree = new InspectorTree(
      new DefaultMutableTreeNode(null),
      treeType.displayName,
      detailsSubtree,
      parentTreeDisplayName,
      treeType != InspectorService.FlutterTreeType.widget || (!isSummaryTree && !legacyMode),
      legacyMode,
      flutterApp
    );

    // We want to reserve double clicking for navigation within the detail
    // tree and in the future for editing values in the tree.
    myRootsTree.setHorizontalAutoScrollingEnabled(false);
    myRootsTree.setAutoscrolls(false);
    myRootsTree.setToggleClickCount(0);

    myRootsTree.addTreeExpansionListener(new MyTreeExpansionListener());
    final InspectorTreeMouseListener mouseListener = new InspectorTreeMouseListener(this, myRootsTree);
    myRootsTree.addMouseListener(mouseListener);
    myRootsTree.addMouseMotionListener(mouseListener);

    if (isSummaryTree && !legacyMode) {
      subtreePanel = new InspectorPanel(
        flutterView,
        flutterApp,
        inspectorService,
        isApplicable,
        treeType,
        true,
        this,
        false,
        legacyMode,
        shouldAutoHorizontalScroll,
        highlightNodesShownInBothTrees
      );
    }
    else {
      subtreePanel = null;
    }

    initTree(myRootsTree);
    myRootsTree.getSelectionModel().addTreeSelectionListener(this::selectionChanged);

    treeScrollPane = (JBScrollPane)ScrollPaneFactory.createScrollPane(myRootsTree);
    treeScrollPane.setAutoscrolls(false);

    scrollAnimator = new TreeScrollAnimator(myRootsTree, treeScrollPane);
    shouldAutoHorizontalScroll.listen(scrollAnimator::setAutoHorizontalScroll, true);
    highlightNodesShownInBothTrees.listen(this::setHighlightNodesShownInBothTrees, true);
    myRootsTree.setScrollAnimator(scrollAnimator);

    if (!detailsSubtree) {
      treeSplitter = new Splitter(false);
      treeSplitter.setProportion(flutterView.getState().getSplitterProportion());
      flutterView.getState().addListener(e -> {
        final float newProportion = flutterView.getState().getSplitterProportion();
        if (treeSplitter.getProportion() != newProportion) {
          treeSplitter.setProportion(newProportion);
        }
      });
      //noinspection Convert2Lambda
      treeSplitter.addPropertyChangeListener("proportion", new PropertyChangeListener() {
        @Override
        public void propertyChange(PropertyChangeEvent evt) {
          flutterView.getState().setSplitterProportion(treeSplitter.getProportion());
        }
      });

      if (subtreePanel == null) {
        myPropertiesPanel = new PropertiesPanel(flutterApp, inspectorService);
        treeSplitter.setSecondComponent(ScrollPaneFactory.createScrollPane(myPropertiesPanel));
      }
      else {
        myPropertiesPanel = null; /// This InspectorPanel doesn't have its own property panel.
        treeSplitter.setSecondComponent(subtreePanel);
      }

      Disposer.register(this, treeSplitter::dispose);
      Disposer.register(this, scrollAnimator::dispose);
      treeSplitter.setFirstComponent(treeScrollPane);
      add(treeSplitter);
    }
    else {
      treeSplitter = null;
      myPropertiesPanel = null;
      add(treeScrollPane);
    }

    this.addComponentListener(new ComponentListener() {
      @Override
      public void componentResized(ComponentEvent e) {
        determineSplitterOrientation();
      }

      @Override
      public void componentMoved(ComponentEvent e) {

      }

      @Override
      public void componentShown(ComponentEvent e) {
        determineSplitterOrientation();
      }

      @Override
      public void componentHidden(ComponentEvent e) {
      }
    });

    determineSplitterOrientation();

    if (isDetailsSubtree()) {
      // Draw a separator line between the main inspector tree and the details tree.
      setBorder(JBUI.Borders.customLine(JBColor.border(), 1, 0, 0, 0));
    }

    flutterIsolateSubscription = inspectorService.getApp().getVMServiceManager().getCurrentFlutterIsolate((IsolateRef flutterIsolate) -> {
      if (flutterIsolate == null) {
        onIsolateStopped();
      }
    }, true);
  }