// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.ui.tree;

import com.intellij.openapi.util.registry.Registry;
import org.jetbrains.annotations.Nullable;

import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.TreePath;

public interface DoubleClickExpandable {
  boolean expandOnDoubleClick();

  static boolean isExpandOnDoubleClickAllowed(@Nullable TreePath path) {
    if (path == null || Registry.is("ide.tree.expand.on.double.click.disabled", false)) return false;
    Object component = path.getLastPathComponent();
    if (component instanceof DefaultMutableTreeNode) {
      DefaultMutableTreeNode node = (DefaultMutableTreeNode)component;
      component = node.getUserObject(); // TreeUtil.getLastUserObject(path)
    }
    if (component instanceof DoubleClickExpandable) {
      DoubleClickExpandable expandable = (DoubleClickExpandable)component;
      return expandable.expandOnDoubleClick();
    }
    return true;
  }
}

@@ -348,48 +348,388 @@
 h;%0A%0A
-public interface DoubleClickExpandable %7B
+/**%0A * This interface is intended for a tree node so that double click on it%0A * navigates to the source code instead of node expanding/collapsing.%0A *%0A * @see com.intellij.util.EditSourceOnDoubleClickHandler#isToggleEvent%0A */%0Apublic interface DoubleClickExpandable %7B%0A  /**%0A   * @return %7B@code true%7D to expand/collapse the node, %7B@code false%7D to navigate to source if possible%0A   */
 %0A  b

add javadoc