private void setupListeners()

in src/main/java/org/apache/log4j/chainsaw/LoggerNameTreePanel.java [1185:1300]


    private void setupListeners() {
        logTree.addMouseMotionListener(new MouseKeyIconListener());

        /**
         * Enable the actions depending on state of the tree selection
         */
        logTree.addTreeSelectionListener(e -> {
            TreePath path = e.getNewLeadSelectionPath();
            TreeNode node = null;

            if (path != null) {
                node = (TreeNode) path.getLastPathComponent();
            }
            boolean focusOnSelected = isFocusOnSelected();
            //          editLoggerAction.setEnabled(path != null);
            currentlySelectedLoggerName = getCurrentlySelectedLoggerName();
            focusOnAction.setEnabled(
                (path != null) && (node != null) && (node.getParent() != null)
                    && !hiddenSet.contains(currentlySelectedLoggerName));
            hideAction.setEnabled(
                (path != null) && (node != null) && (node.getParent() != null));
            if (!focusOnAction.isEnabled()) {
                setFocusOnSelected(false);
            } else {
            }

            expandAction.setEnabled(path != null);
            findAction.setEnabled(path != null);
            clearFindNextAction.setEnabled(true);
            defineColorRuleForLoggerAction.setEnabled(path != null);
            setRefineFocusAction.setEnabled(path != null);
            updateRefineFocusAction.setEnabled(path != null);
            updateFindAction.setEnabled(path != null);
            clearRefineFocusAction.setEnabled(true);

            if (currentlySelectedLoggerName != null) {
                boolean isHidden = hiddenSet.contains(currentlySelectedLoggerName);
                popupMenu.hideCheck.setSelected(isHidden);
                ignoreLoggerButton.setSelected(isHidden);
            }

            collapseAction.setEnabled(path != null);

            reconfigureMenuText();
            if (isFocusOnSelected()) {
                fireChangeEvent();
            }
            //fire change event if we toggled focus off
            if (focusOnSelected && !isFocusOnSelected()) {
                fireChangeEvent();
            }
            //trigger a table repaint
            logPanel.repaint();
        });

        logTree.addMouseListener(popupListener);

        /**
         * This listener ensures the Tool bar toggle button and popup menu check box
         * stay in sync, plus notifies all the ChangeListeners that
         * an effective filter criteria has been modified
         */
        focusOnAction.addPropertyChangeListener(evt -> {
            popupMenu.focusOnCheck.setSelected(isFocusOnSelected());
            focusOnLoggerButton.setSelected(isFocusOnSelected());

            if (logTree.getSelectionPath() != null) {
                logTreeModel.nodeChanged(
                    (TreeNode) logTree.getSelectionPath().getLastPathComponent());
            }
        });

        hideAction.addPropertyChangeListener(evt -> {
            if (logTree.getSelectionPath() != null) {
                logTreeModel.nodeChanged(
                    (TreeNode) logTree.getSelectionPath().getLastPathComponent());
            }
        });

        //    /**
        //     * Now add a MouseListener that fires the expansion
        //     * action if CTRL + DBL CLICK is done.
        //     */
        //    logTree.addMouseListener(
        //      new MouseAdapter() {
        //        public void mouseClicked(MouseEvent e) {
        //          if (
        //            (e.getClickCount() > 1)
        //              && ((e.getModifiers() & InputEvent.CTRL_MASK) > 0)
        //              && ((e.getModifiers() & InputEvent.BUTTON1_MASK) > 0)) {
        //            expandCurrentlySelectedNode();
        //            e.consume();
        //          } else if (e.getClickCount() > 1) {
        //            super.mouseClicked(e);
        //            logger.debug("Ignoring dbl click event " + e);
        //          }
        //        }
        //      });

        logTree.addMouseListener(new MouseFocusOnListener());

        /**
         * We listen for when the FocusOn action changes, and then  translate
         * that to a RuleChange
         */
        addChangeListener(evt -> {
            visibilityRuleDelegate.firePropertyChange("rule", null, null);
            updateDisplay();
        });

        visibilityRuleDelegate.addPropertyChangeListener(event -> {
            if (event.getPropertyName().equals("hiddenSet")) {
                updateDisplay();
            }
        });
    }