Example usage for com.intellij.openapi.wm ToolWindowScrollable isHorizontalScrollingNeeded

List of usage examples for com.intellij.openapi.wm ToolWindowScrollable isHorizontalScrollingNeeded

Introduction

In this page you can find the example usage for com.intellij.openapi.wm ToolWindowScrollable isHorizontalScrollingNeeded.

Prototype

boolean isHorizontalScrollingNeeded();

Source Link

Usage

From source file:com.intellij.ide.actions.ResizeToolWindowAction.java

License:Apache License

@Nullable
private ToolWindowScrollable getScrollable(ToolWindow wnd, boolean isHorizontalStretchingOffered) {
    KeyboardFocusManager mgr = KeyboardFocusManager.getCurrentKeyboardFocusManager();

    Component eachComponent = mgr.getFocusOwner();
    ToolWindowScrollable scrollable = null;
    while (eachComponent != null) {
        if (!SwingUtilities.isDescendingFrom(eachComponent, wnd.getComponent()))
            break;

        if (eachComponent instanceof ToolWindowScrollable) {
            ToolWindowScrollable eachScrollable = (ToolWindowScrollable) eachComponent;
            if (isHorizontalStretchingOffered) {
                if (eachScrollable.isHorizontalScrollingNeeded()) {
                    scrollable = eachScrollable;
                    break;
                }//  w w w .jav  a 2  s  .c  o m
            } else {
                if (eachScrollable.isVerticalScrollingNeeded()) {
                    scrollable = eachScrollable;
                    break;
                }
            }
        }

        eachComponent = eachComponent.getParent();
    }

    if (scrollable == null) {
        scrollable = new DefaultToolWindowScrollable();
    }

    if (isHorizontalStretchingOffered && scrollable.isHorizontalScrollingNeeded())
        return scrollable;
    if (!isHorizontalStretchingOffered && scrollable.isVerticalScrollingNeeded())
        return scrollable;

    return null;
}