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

The following examples show how to use com.intellij.util.ui.JBUI#insets() . 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: TabsBorder.java    From consulo with Apache License 2.0 6 votes vote down vote up
public Insets getEffectiveBorder() {
  if (myEffectiveBorder != null && myTabs.getTabsPosition() == myPosition) return (Insets)myEffectiveBorder.clone();

  myPosition = myTabs.getTabsPosition();

  if (myTabs.isEditorTabs()) {
    // it seems like all of the borders should be defined in splitters. this is wrong, but I just can not fix it right now :(
    myEffectiveBorder = JBUI.insets(myPosition == JBTabsPosition.top ? TabsUtil.TABS_BORDER : 0, 0, 0, 0);
  }
  else {
    myEffectiveBorder = JBUI.insets(
      myPosition == JBTabsPosition.top ? myTabBorderSize : myBorderSize.top,
      myPosition == JBTabsPosition.left ? myTabBorderSize : myBorderSize.left,
      myPosition == JBTabsPosition.bottom ? myTabBorderSize : myBorderSize.bottom,
      myPosition == JBTabsPosition.right ? myTabBorderSize : myBorderSize.right
    );
  }


  return (Insets)myEffectiveBorder.clone();
}
 
Example 2
Source File: DaemonTooltipWithActionRenderer.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
protected void fillPanel(@Nonnull Editor editor,
                         @Nonnull JPanel grid,
                         @Nonnull LightweightHint hint,
                         @Nonnull HintHint hintHint,
                         @Nonnull List<? super AnAction> actions,
                         @Nonnull TooltipReloader tooltipReloader,
                         boolean newLayout,
                         boolean highlightActions) {
  super.fillPanel(editor, grid, hint, hintHint, actions, tooltipReloader, newLayout, highlightActions);

  boolean hasMore = LineTooltipRenderer.isActiveHtml(myText);

  if (tooltipAction == null && !hasMore) return;

  JComponent settingsComponent = createSettingsComponent(hintHint, tooltipReloader, hasMore, newLayout);

  GridBagConstraints settingsConstraints =
          new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.NORTH, GridBagConstraints.HORIZONTAL, JBUI.insets(newLayout ? 7 : 4, 7, newLayout ? 0 : 4, newLayout ? 2 : 4), 0, 0);

  grid.add(settingsComponent, settingsConstraints);

  if (TooltipActionProvider.isShowActions()) {
    addActionsRow(hintHint, hint, editor, actions, grid, newLayout, highlightActions);
  }
}
 
Example 3
Source File: ExtractWidgetAction.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
protected JComponent createNorthPanel() {
  final JPanel panel = new JPanel(new GridBagLayout());
  final GridBagConstraints gbConstraints = new GridBagConstraints();

  gbConstraints.insets = JBUI.insetsBottom(4);
  gbConstraints.gridx = 0;
  gbConstraints.gridy = 0;
  gbConstraints.gridwidth = 1;
  gbConstraints.weightx = 0;
  gbConstraints.weighty = 0;
  gbConstraints.fill = GridBagConstraints.NONE;
  gbConstraints.anchor = GridBagConstraints.WEST;
  final JLabel nameLabel = new JLabel("Widget name:");
  panel.add(nameLabel, gbConstraints);

  gbConstraints.insets = JBUI.insets(0, 4, 4, 0);
  gbConstraints.gridx = 1;
  gbConstraints.gridy = 0;
  gbConstraints.gridwidth = GridBagConstraints.REMAINDER;
  gbConstraints.weightx = 1;
  gbConstraints.weighty = 0;
  gbConstraints.fill = GridBagConstraints.BOTH;
  gbConstraints.anchor = GridBagConstraints.WEST;
  panel.add(myNameField, gbConstraints);
  myNameField.setPreferredSize(new Dimension(200, myNameField.getPreferredSize().height));

  return panel;
}
 
Example 4
Source File: ExtractWidgetAction.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
protected JComponent createNorthPanel() {
  final JPanel panel = new JPanel(new GridBagLayout());
  final GridBagConstraints gbConstraints = new GridBagConstraints();

  gbConstraints.insets = JBUI.insetsBottom(4);
  gbConstraints.gridx = 0;
  gbConstraints.gridy = 0;
  gbConstraints.gridwidth = 1;
  gbConstraints.weightx = 0;
  gbConstraints.weighty = 0;
  gbConstraints.fill = GridBagConstraints.NONE;
  gbConstraints.anchor = GridBagConstraints.WEST;
  final JLabel nameLabel = new JLabel("Widget name:");
  panel.add(nameLabel, gbConstraints);

  gbConstraints.insets = JBUI.insets(0, 4, 4, 0);
  gbConstraints.gridx = 1;
  gbConstraints.gridy = 0;
  gbConstraints.gridwidth = GridBagConstraints.REMAINDER;
  gbConstraints.weightx = 1;
  gbConstraints.weighty = 0;
  gbConstraints.fill = GridBagConstraints.BOTH;
  gbConstraints.anchor = GridBagConstraints.WEST;
  panel.add(myNameField, gbConstraints);
  myNameField.setPreferredSize(new Dimension(200, myNameField.getPreferredSize().height));

  return panel;
}
 
Example 5
Source File: CamelEditDialog.java    From camel-idea-plugin with Apache License 2.0 5 votes vote down vote up
@Nullable
@Override
protected JComponent createCenterPanel() {
    JPanel panel = new JPanel(new GridBagLayout());
    Insets insets = JBUI.insets(0, 5, 5, 5);
    GridBagConstraints gbc = new GridBagConstraints(0, 1, 2, 1, 1, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, insets, 0, 0);
    panel.add(textfield, gbc);

    textfield.setPreferredSize(new Dimension(350, textfield.getPreferredSize().height));

    return panel;
}
 
Example 6
Source File: ScopeBasedTodosPanel.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
protected JComponent createCenterComponent() {
  JPanel panel = new JPanel(new BorderLayout());
  final JComponent component = super.createCenterComponent();
  panel.add(component, BorderLayout.CENTER);
  String preselect = PropertiesComponent.getInstance(myProject).getValue(SELECTED_SCOPE);
  myScopes = new ScopeChooserCombo(myProject, false, true, preselect);
  Disposer.register(this, myScopes);
  myScopes.setCurrentSelection(false);
  myScopes.setUsageView(false);

  JPanel chooserPanel = new JPanel(new GridBagLayout());
  final JLabel scopesLabel = new JLabel("Scope:");
  scopesLabel.setDisplayedMnemonic('S');
  scopesLabel.setLabelFor(myScopes);
  final GridBagConstraints gc =
          new GridBagConstraints(GridBagConstraints.RELATIVE, 0, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE,
                                 JBUI.insets(2), 0, 0);
  chooserPanel.add(scopesLabel, gc);
  chooserPanel.add(myScopes, gc);

  gc.fill = GridBagConstraints.HORIZONTAL;
  gc.weightx = 1;
  chooserPanel.add(Box.createHorizontalBox(), gc);
  panel.add(chooserPanel, BorderLayout.NORTH);
  return panel;
}
 
Example 7
Source File: DarculaCheckBoxBorder.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public Insets getBorderInsets(Component c) {
  return ComponentUtil.getParentOfType((Class<? extends CellRendererPane>)CellRendererPane.class, c) != null
         ? JBUI.emptyInsets().asUIResource()
         : JBUI.insets(borderWidthPropertyName(), JBUI.insets(1));
}
 
Example 8
Source File: MultiIconSimpleColoredComponent.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
public MyBorder() {
  myInsets = JBUI.insets(1);
}
 
Example 9
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 10
Source File: DarculaMenuItemBorder.java    From consulo with Apache License 2.0 4 votes vote down vote up
public DarculaMenuItemBorder() {
  super(JBUI.insets(2));
}
 
Example 11
Source File: SafeDeleteDialog.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
protected JComponent createNorthPanel() {
  final JPanel panel = new JPanel(new GridBagLayout());
  final GridBagConstraints gbc = new GridBagConstraints();

  final String promptKey = isDelete() ? "prompt.delete.elements" : "search.for.usages.and.delete.elements";
  final String warningMessage = DeleteUtil.generateWarningMessage(IdeBundle.message(promptKey), myElements);

  gbc.insets = JBUI.insets(4, 8);
  gbc.weighty = 1;
  gbc.weightx = 1;
  gbc.gridx = 0;
  gbc.gridy = 0;
  gbc.gridwidth = 2;
  gbc.fill = GridBagConstraints.BOTH;
  gbc.anchor = GridBagConstraints.WEST;
  panel.add(new JLabel(warningMessage), gbc);

  if (isDelete()) {
    gbc.gridy++;
    gbc.gridx = 0;
    gbc.weightx = 0.0;
    gbc.gridwidth = 1;
    gbc.insets = JBUI.insets(4, 8, 0, 8);
    myCbSafeDelete = new JCheckBox(IdeBundle.message("checkbox.safe.delete.with.usage.search"));
    panel.add(myCbSafeDelete, gbc);
    myCbSafeDelete.addActionListener(new ActionListener() {
      @Override
      public void actionPerformed(ActionEvent e) {
        updateControls(myCbSearchInComments);
        updateControls(myCbSearchTextOccurrences);
      }
    });
  }

  gbc.gridy++;
  gbc.gridx = 0;
  gbc.weightx = 0.0;
  gbc.gridwidth = 1;
  myCbSearchInComments = new StateRestoringCheckBox();
  myCbSearchInComments.setText(RefactoringBundle.getSearchInCommentsAndStringsText());
  panel.add(myCbSearchInComments, gbc);

  if (needSearchForTextOccurrences()) {
    gbc.gridx++;
    myCbSearchTextOccurrences = new StateRestoringCheckBox();
    myCbSearchTextOccurrences.setText(RefactoringBundle.getSearchForTextOccurrencesText());
    panel.add(myCbSearchTextOccurrences, gbc);
  }

  final RefactoringSettings refactoringSettings = RefactoringSettings.getInstance();
  if (myCbSafeDelete != null) {
    myCbSafeDelete.setSelected(refactoringSettings.SAFE_DELETE_WHEN_DELETE);
  }
  myCbSearchInComments.setSelected(myDelegate != null ? myDelegate.isToSearchInComments(myElements[0]) : refactoringSettings.SAFE_DELETE_SEARCH_IN_COMMENTS);
  if (myCbSearchTextOccurrences != null) {
    myCbSearchTextOccurrences.setSelected(myDelegate != null ? myDelegate.isToSearchForTextOccurrences(myElements[0]) : refactoringSettings.SAFE_DELETE_SEARCH_IN_NON_JAVA);
  }
  updateControls(myCbSearchTextOccurrences);
  updateControls(myCbSearchInComments);
  return panel;
}
 
Example 12
Source File: DarculaCheckBoxBorder.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public Insets getBorderInsets(Component c) {
  final int a = SystemInfo.isMac || UIUtil.getParentOfType(CellRendererPane.class, c) != null ? 0 : 2;
  return JBUI.insets(a, a, a, a);
}
 
Example 13
Source File: AbstractNavBarUI.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public JBInsets getElementPadding() {
  return JBUI.insets(3);
}
 
Example 14
Source File: ConfigurationErrorsComponent.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public Insets getInsets() {
  return JBUI.insets(2);
}
 
Example 15
Source File: DarculaEditorTextFieldBorder.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nullable
@Override
public Insets getVisualPaddings(@Nonnull Component component) {
  return JBUI.insets(3);
}
 
Example 16
Source File: DarculaComboBoxUI.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nonnull
private static JBInsets getDefaultComboBoxInsets() {
  return JBUI.insets(3);
}
 
Example 17
Source File: ApplyPatchDifferentiatedDialog.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
protected JComponent createCenterPanel() {
  if (myCenterPanel == null) {
    myCenterPanel = new JPanel(new GridBagLayout());
    final GridBagConstraints gb = new GridBagConstraints(0, 0, 1, 1, 1, 0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, JBUI.insets(1), 0, 0);

    myPatchFileLabel = new JLabel(VcsBundle.message("patch.apply.file.name.field"));
    myPatchFileLabel.setLabelFor(myPatchFile);
    myCenterPanel.add(myPatchFileLabel, gb);

    gb.fill = GridBagConstraints.HORIZONTAL;
    ++gb.gridy;
    myCenterPanel.add(myPatchFile, gb);

    final DefaultActionGroup group = new DefaultActionGroup();
    final AnAction[] treeActions = myChangesTreeList.getTreeActions();
    group.addAll(treeActions);
    group.add(new MapDirectory());

    final MyShowDiff diffAction = new MyShowDiff();
    diffAction.registerCustomShortcutSet(CommonShortcuts.getDiff(), getRootPane());
    group.add(diffAction);

    group.add(new StripUp());
    group.add(new StripDown());
    group.add(new ResetStrip());
    group.add(new ZeroStrip());
    if (myCanChangePatchFile) {
      group.add(new AnAction("Refresh", "Refresh", AllIcons.Actions.Refresh) {
        @Override
        public void actionPerformed(AnActionEvent e) {
          syncUpdatePatchFileAndScheduleReloadIfNeeded(null);
        }
      });
    }

    final ActionToolbar toolbar = ActionManager.getInstance().createActionToolbar("APPLY_PATCH", group, true);
    ++gb.gridy;
    gb.fill = GridBagConstraints.HORIZONTAL;
    myCenterPanel.add(toolbar.getComponent(), gb);

    ++gb.gridy;
    gb.weighty = 1;
    gb.fill = GridBagConstraints.BOTH;
    myCenterPanel.add(ScrollPaneFactory.createScrollPane(myChangesTreeList), gb);

    ++gb.gridy;
    gb.weighty = 0;
    gb.fill = GridBagConstraints.NONE;
    gb.insets.bottom = UIUtil.DEFAULT_VGAP;
    myCenterPanel.add(myCommitLegendPanel.getComponent(), gb);

    ++gb.gridy;
    gb.fill = GridBagConstraints.HORIZONTAL;
    myCenterPanel.add(myChangeListChooser, gb);
  }
  return myCenterPanel;
}
 
Example 18
Source File: ActionButton.java    From consulo with Apache License 2.0 4 votes vote down vote up
public void setIconInsets(@Nullable Insets insets) {
  myInsets = insets != null ? JBUI.insets(insets) : new Insets(0, 0, 0, 0);
}
 
Example 19
Source File: JBTabsImpl.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
@Nonnull
public UiDecoration getDecoration() {
  return new UiDecoration(null, JBUI.insets(0, 4, 0, 5));
}
 
Example 20
Source File: ModernComboBoxUI.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
protected void installDefaults() {
  super.installDefaults();
  Insets insets = UIManager.getInsets("ComboBox.padding");
  myPadding = insets == null ? null : JBUI.insets(insets);
}