Java Code Examples for com.intellij.util.ui.JBUI#emptyInsets()

The following examples show how to use com.intellij.util.ui.JBUI#emptyInsets() . 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: JBTabsImpl.java    From consulo with Apache License 2.0 6 votes vote down vote up
public Rectangle layoutComp(int componentX, int componentY, final JComponent comp, int deltaWidth, int deltaHeight) {
  final Insets insets = getLayoutInsets();

  final Insets border = isHideTabs() ? JBUI.emptyInsets() : myBorder.getEffectiveBorder();

  final Insets inner = getInnerInsets();
  border.top += inner.top;
  border.bottom += inner.bottom;
  border.left += inner.left;
  border.right += inner.right;


  int x = insets.left + componentX + border.left;
  int y = insets.top + componentY + border.top;
  int width = getWidth() - insets.left - insets.right - componentX - border.left - border.right;
  int height = getHeight() - insets.top - insets.bottom - componentY - border.top - border.bottom;

  return layout(comp, x, y, width, height);
}
 
Example 2
Source File: BlazeSelectWorkspaceControl.java    From intellij with Apache License 2.0 6 votes vote down vote up
private JPanel getSideBar() {
  // initially generated by IntelliJ IDEA GUI Designer
  JPanel sidebar = new JPanel(new GridLayoutManager(1, 1, JBUI.emptyInsets(), -1, -1));
  sidebar.putClientProperty("BorderFactoryClass", PlainSmallWithoutIndent.class.getName());
  JBScrollPane scrollPane = new JBScrollPane();
  scrollPane.setViewportView(workspaceTypeList);
  sidebar.add(
      scrollPane,
      new GridConstraints(
          0,
          0,
          1,
          1,
          GridConstraints.ANCHOR_CENTER,
          GridConstraints.FILL_BOTH,
          GridConstraints.SIZEPOLICY_FIXED,
          GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW,
          null,
          null,
          null,
          0,
          false));
  return sidebar;
}
 
Example 3
Source File: MultiIconSimpleColoredComponent.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public final synchronized int computePreferredHeight() {
  int height = myIpad.top + myIpad.bottom;

  Font font = getBaseFont();

  final FontMetrics metrics = getFontMetrics(font);
  int textHeight = Math.max(JBUI.scale(16), metrics.getHeight()); //avoid too narrow rows

  Insets borderInsets = myBorder != null ? myBorder.getBorderInsets(this) : JBUI.emptyInsets();
  textHeight += borderInsets.top + borderInsets.bottom;

  if (!myIcons.isEmpty()) {
    for (PositionedIcon icon : myIcons) {
      height += Math.max(icon.icon.getIconHeight(), textHeight);
    }
  }
  else {
    height += textHeight;
  }

  // Take into account that the component itself can have a border
  final Insets insets = getInsets();
  if (insets != null) {
    height += insets.top + insets.bottom;
  }

  return height;
}
 
Example 4
Source File: TrafficProgressPanel.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
protected void paintComponent(@Nonnull Graphics g) {
  Insets insets = getInsets();
  if (insets == null) {
    insets = JBUI.emptyInsets();
  }
  g.setColor(myHintHint.getTextForeground());
  g.drawLine(insets.left, insets.top, getWidth() - insets.left - insets.right, insets.top);
}
 
Example 5
Source File: JBTabsImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
public Insets getLayoutInsets() {
  Insets insets = getInsets();
  if (insets == null) {
    insets = JBUI.emptyInsets();
  }
  return insets;
}
 
Example 6
Source File: BlazeSelectWorkspaceControl.java    From intellij with Apache License 2.0 5 votes vote down vote up
private JPanel initPanel() {
  // initially generated by IntelliJ IDEA GUI Designer
  JPanel topLevelPanel = new JPanel(new GridLayoutManager(1, 2, JBUI.emptyInsets(), -1, -1));
  topLevelPanel.add(
      getSideBar(),
      new GridConstraints(
          0,
          0,
          1,
          1,
          GridConstraints.ANCHOR_CENTER,
          GridConstraints.FILL_BOTH,
          GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW,
          GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW,
          null,
          null,
          null,
          0,
          false));
  topLevelPanel.add(
      cardPanel,
      new GridConstraints(
          0,
          1,
          1,
          1,
          GridConstraints.ANCHOR_CENTER,
          GridConstraints.FILL_BOTH,
          GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW,
          GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW,
          null,
          null,
          null,
          0,
          false));
  return topLevelPanel;
}
 
Example 7
Source File: MultiIconSimpleColoredComponent.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public final synchronized int computePreferredHeight() {
  int height = myIpad.top + myIpad.bottom;

  Font font = getBaseFont();

  final FontMetrics metrics = getFontMetrics(font);
  int textHeight = Math.max(JBUI.scale(16), metrics.getHeight()); //avoid too narrow rows

  Insets borderInsets = myBorder != null ? myBorder.getBorderInsets(this) : JBUI.emptyInsets();
  textHeight += borderInsets.top + borderInsets.bottom;

  if (!myIcons.isEmpty()) {
    for (PositionedIcon icon : myIcons) {
      height += Math.max(icon.icon.getIconHeight(), textHeight);
    }
  }
  else {
    height += textHeight;
  }

  // Take into account that the component itself can have a border
  final Insets insets = getInsets();
  if (insets != null) {
    height += insets.top + insets.bottom;
  }

  return height;
}
 
Example 8
Source File: MultiIconSimpleColoredComponent.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@NotNull
public final synchronized Dimension computePreferredSize(final boolean mainTextOnly) {
  // Calculate width
  int width = myIpad.left;

  for (PositionedIcon icon : myIcons) {
    width += icon.icon.getIconWidth() + myIconTextGap;
  }

  final Insets borderInsets = myBorder != null ? myBorder.getBorderInsets(this) : JBUI.emptyInsets();
  width += borderInsets.left;

  Font font = getBaseFont();

  width += computeTextWidth(font, mainTextOnly);
  width += myIpad.right + borderInsets.right;

  // Take into account that the component itself can have a border
  final Insets insets = getInsets();
  if (insets != null) {
    width += insets.left + insets.right;
  }

  int height = computePreferredHeight();

  return new Dimension(width, height);
}
 
Example 9
Source File: MultiIconSimpleColoredComponent.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@NotNull
public final synchronized Dimension computePreferredSize(final boolean mainTextOnly) {
  // Calculate width
  int width = myIpad.left;

  for (PositionedIcon icon : myIcons) {
    width += icon.icon.getIconWidth() + myIconTextGap;
  }

  final Insets borderInsets = myBorder != null ? myBorder.getBorderInsets(this) : JBUI.emptyInsets();
  width += borderInsets.left;

  Font font = getBaseFont();

  width += computeTextWidth(font, mainTextOnly);
  width += myIpad.right + borderInsets.right;

  // Take into account that the component itself can have a border
  final Insets insets = getInsets();
  if (insets != null) {
    width += insets.left + insets.right;
  }

  int height = computePreferredHeight();

  return new Dimension(width, height);
}
 
Example 10
Source File: TestConfigurationEditor.java    From buck with Apache License 2.0 4 votes vote down vote up
public TestConfigurationEditor() {
  root = new JPanel(new GridBagLayout());
  final JBLabel targetLabel = new JBLabel();
  targetLabel.setText("Targets");
  mTargets = new JBTextField();
  mTargets.getEmptyText().setText("Specify buck targets to test");

  final JBLabel testSelectorLabel = new JBLabel();
  testSelectorLabel.setText("Test selectors (--test-selectors)");
  mTestSelectors = new JBTextField();
  mTestSelectors
      .getEmptyText()
      .setText("Select tests to run using <class>, <#method> or <class#method>.");

  final JBLabel additionalParamsLabel = new JBLabel();
  additionalParamsLabel.setText("Additional params");
  mAdditionalParams = new JBTextField();
  mAdditionalParams.getEmptyText().setText("May be empty");

  final GridBagConstraints constraints =
      new GridBagConstraints(
          0,
          0,
          1,
          1,
          0,
          0,
          GridBagConstraints.WEST,
          GridBagConstraints.NONE,
          JBUI.emptyInsets(),
          0,
          0);
  constraints.insets = JBUI.insetsRight(8);
  root.add(targetLabel, constraints);
  constraints.gridx = 1;
  constraints.gridy = 0;
  constraints.weightx = 1;
  constraints.fill = GridBagConstraints.HORIZONTAL;
  root.add(mTargets, constraints);

  constraints.gridx = 0;
  constraints.gridy = 1;
  constraints.weightx = 0;
  constraints.fill = GridBagConstraints.NONE;
  root.add(testSelectorLabel, constraints);

  constraints.gridx = 1;
  constraints.gridy = 1;
  constraints.weightx = 1;
  constraints.fill = GridBagConstraints.HORIZONTAL;
  root.add(mTestSelectors, constraints);

  constraints.gridx = 0;
  constraints.gridy = 2;
  constraints.weightx = 0;
  constraints.fill = GridBagConstraints.NONE;
  root.add(additionalParamsLabel, constraints);

  constraints.gridx = 1;
  constraints.gridy = 2;
  constraints.weightx = 1;
  constraints.fill = GridBagConstraints.HORIZONTAL;
  root.add(mAdditionalParams, constraints);
}
 
Example 11
Source File: EditorTabbedContainer.java    From consulo with Apache License 2.0 4 votes vote down vote up
private void updateTabBorder() {
  if (!myProject.isOpen()) return;

  ToolWindowManagerEx mgr = (ToolWindowManagerEx)ToolWindowManager.getInstance(myProject);

  String[] ids = mgr.getToolWindowIds();

  Insets border = JBUI.emptyInsets();

  UISettings uiSettings = UISettings.getInstance();

  List<String> topIds = mgr.getIdsOn(ToolWindowAnchor.TOP);
  List<String> bottom = mgr.getIdsOn(ToolWindowAnchor.BOTTOM);
  List<String> rightIds = mgr.getIdsOn(ToolWindowAnchor.RIGHT);
  List<String> leftIds = mgr.getIdsOn(ToolWindowAnchor.LEFT);

  if (!uiSettings.getHideToolStripes() && !uiSettings.getPresentationMode()) {
    border.top = !topIds.isEmpty() ? 1 : 0;
    border.bottom = !bottom.isEmpty() ? 1 : 0;
    border.left = !leftIds.isEmpty() ? 1 : 0;
    border.right = !rightIds.isEmpty() ? 1 : 0;
  }

  for (String each : ids) {
    ToolWindow eachWnd = mgr.getToolWindow(each);
    if (eachWnd == null || !eachWnd.isAvailable()) continue;

    if (eachWnd.isVisible() && eachWnd.getType() == ToolWindowType.DOCKED) {
      ToolWindowAnchor eachAnchor = eachWnd.getAnchor();
      if (eachAnchor == ToolWindowAnchor.TOP) {
        border.top = 0;
      }
      else if (eachAnchor == ToolWindowAnchor.BOTTOM) {
        border.bottom = 0;
      }
      else if (eachAnchor == ToolWindowAnchor.LEFT) {
        border.left = 0;
      }
      else if (eachAnchor == ToolWindowAnchor.RIGHT) {
        border.right = 0;
      }
    }
  }

  myTabs.getPresentation().setPaintBorder(border.top, border.left, border.right, border.bottom).setTabSidePaintBorder(5);
}
 
Example 12
Source File: EditorTabbedContainer.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public Insets getBorderInsets(Component component) {
  return JBUI.emptyInsets();
}
 
Example 13
Source File: TextComponentEditorImpl.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public Insets getInsets() {
  return JBUI.emptyInsets();
}
 
Example 14
Source File: AbstractNavBarUI.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public Insets getElementIpad(boolean isPopupElement) {
  return isPopupElement ? JBInsets.create(1, 2) : JBUI.emptyInsets();
}
 
Example 15
Source File: PopupBorder.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public Insets getBorderInsets(final Component c) {
  return myVisible ? JBUI.insets(1) : JBUI.emptyInsets();
}
 
Example 16
Source File: TextFieldWithPopupHandlerUI.java    From consulo with Apache License 2.0 4 votes vote down vote up
protected Insets getDefaultMargins() {
  return JBUI.emptyInsets();
}
 
Example 17
Source File: DarculaTableHeaderBorder.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public Insets getBorderInsets(Component c) {
  return JBUI.emptyInsets();
}