// 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.util.ui.tree;

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

import javax.swing.JTree;

/**
 * This class allows to change the default behaviour of expanding/collapsing tree nodes by double-clicking.
 */
public enum ExpandOnDoubleClick {
  NEVER, ALWAYS, NAVIGATABLE, DEFAULT;

  private static final String KEY = "ide.tree.expand.on.double.click";

  public void installOn(@NotNull JTree tree) {
    tree.putClientProperty(KEY, this);
  }

  public static @NotNull ExpandOnDoubleClick getBehavior(@NotNull JTree tree) {
    Object property = tree.getClientProperty(KEY);
    if (property instanceof ExpandOnDoubleClick) return (ExpandOnDoubleClick)property;
    String option = Registry.get(KEY).getSelectedOption();
    if (NEVER.name().equalsIgnoreCase(option)) return NEVER;
    if (ALWAYS.name().equalsIgnoreCase(option)) return ALWAYS;
    if (NAVIGATABLE.name().equalsIgnoreCase(option)) return NAVIGATABLE;
    return DEFAULT;
  }
}

@@ -222,16 +222,117 @@
 gistry;%0A
+import com.intellij.util.EditSourceOnDoubleClickHandler;%0Aimport org.jetbrains.annotations.ApiStatus;%0A
 import o
@@ -365,16 +365,16 @@
 otNull;%0A
-
 %0Aimport 
@@ -509,16 +509,40 @@
 ng.%0A */%0A
+@ApiStatus.Experimental%0A
 public e
@@ -679,16 +679,83 @@
 lick%22;%0A%0A
+  /**%0A   * Changes the default behaviour for the given tree.%0A   */%0A
   public
@@ -837,16 +837,146 @@
 );%0A  %7D%0A%0A
+  /**%0A   * @return the preferable behaviour for the given tree.%0A   * @see EditSourceOnDoubleClickHandler#isExpandPreferable%0A   */%0A
   public

add javadoc to experimental API