Java Code Examples for com.intellij.openapi.wm.ToolWindow#getAnchor()

The following examples show how to use com.intellij.openapi.wm.ToolWindow#getAnchor() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RoutesView.java    From railways with MIT License 5 votes vote down vote up
private void updateToolWindowOrientation(ToolWindow toolWindow) {
    if (toolWindow.isDisposed())
        return;

    ToolWindowAnchor anchor = toolWindow.getAnchor();
    boolean isVertical = (anchor == ToolWindowAnchor.LEFT ||
            anchor == ToolWindowAnchor.RIGHT);

    mainPanel.setOrientation(isVertical);
}
 
Example 2
Source File: DesktopToolWindowPanelImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
private void stretch(@Nonnull ToolWindow wnd, int value) {
  Pair<Resizer, Component> pair = findResizerAndComponent(wnd);
  if (pair == null) return;

  boolean vertical = wnd.getAnchor() == ToolWindowAnchor.TOP || wnd.getAnchor() == ToolWindowAnchor.BOTTOM;
  int actualSize = (vertical ? pair.second.getHeight() : pair.second.getWidth()) + value;
  boolean first = wnd.getAnchor() == ToolWindowAnchor.LEFT || wnd.getAnchor() == ToolWindowAnchor.TOP;
  int maxValue = vertical ? myVerticalSplitter.getMaxSize(first) : myHorizontalSplitter.getMaxSize(first);
  int minValue = vertical ? myVerticalSplitter.getMinSize(first) : myHorizontalSplitter.getMinSize(first);

  pair.first.setSize(Math.max(minValue, Math.min(maxValue, actualSize)));
}
 
Example 3
Source File: DesktopToolWindowHeader.java    From consulo with Apache License 2.0 5 votes vote down vote up
private Image getHideIcon(ToolWindow toolWindow) {
  ToolWindowAnchor anchor = toolWindow.getAnchor();
  if (anchor == ToolWindowAnchor.BOTTOM) {
    return AllIcons.General.HideDownPart;
  }
  else if (anchor == ToolWindowAnchor.RIGHT) {
    return AllIcons.General.HideRightPart;
  }

  return AllIcons.General.HideLeftPart;
}
 
Example 4
Source File: DesktopToolWindowPanelImpl.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nullable
private Pair<Resizer, Component> findResizerAndComponent(@Nonnull ToolWindow wnd) {
  if (!wnd.isVisible()) return null;

  Resizer resizer = null;
  Component cmp = null;

  if (wnd.getType() == ToolWindowType.DOCKED) {
    cmp = getComponentAt(wnd.getAnchor());

    if (cmp != null) {
      if (wnd.getAnchor().isHorizontal()) {
        resizer = myVerticalSplitter.getFirstComponent() == cmp ? new Resizer.Splitter.FirstComponent(myVerticalSplitter) : new Resizer.Splitter.LastComponent(myVerticalSplitter);
      }
      else {
        resizer = myHorizontalSplitter.getFirstComponent() == cmp ? new Resizer.Splitter.FirstComponent(myHorizontalSplitter) : new Resizer.Splitter.LastComponent(myHorizontalSplitter);
      }
    }
  }
  else if (wnd.getType() == ToolWindowType.SLIDING) {
    cmp = wnd.getComponent();
    while (cmp != null) {
      if (cmp.getParent() == myLayeredPane) break;
      cmp = cmp.getParent();
    }

    if (cmp != null) {
      if (wnd.getAnchor() == ToolWindowAnchor.TOP) {
        resizer = new Resizer.LayeredPane.Top(cmp);
      }
      else if (wnd.getAnchor() == ToolWindowAnchor.BOTTOM) {
        resizer = new Resizer.LayeredPane.Bottom(cmp);
      }
      else if (wnd.getAnchor() == ToolWindowAnchor.LEFT) {
        resizer = new Resizer.LayeredPane.Left(cmp);
      }
      else if (wnd.getAnchor() == ToolWindowAnchor.RIGHT) {
        resizer = new Resizer.LayeredPane.Right(cmp);
      }
    }
  }

  return resizer != null ? Pair.create(resizer, cmp) : null;
}