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

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

Introduction

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

Prototype

boolean isVerticalScrollingNeeded();

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;
                }/*ww  w  .java  2  s .  c om*/
            } 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;
}