com.intellij.ui.components.panels.NonOpaquePanel Java Examples

The following examples show how to use com.intellij.ui.components.panels.NonOpaquePanel. 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: QueryPanel.java    From nosql4idea with Apache License 2.0 6 votes vote down vote up
void notifyOnErrorForOperator(JComponent component, Exception ex) {
    String message;
    if (ex instanceof JSONParseException) {
        message = StringUtils.removeStart(ex.getMessage(), "\n");
    } else {
        message = String.format("%s: %s", ex.getClass().getSimpleName(), ex.getMessage());
    }
    NonOpaquePanel nonOpaquePanel = new NonOpaquePanel();
    JTextPane textPane = Messages.configureMessagePaneUi(new JTextPane(), message);
    textPane.setFont(COURIER_FONT);
    textPane.setBackground(MessageType.ERROR.getPopupBackground());
    nonOpaquePanel.add(textPane, BorderLayout.CENTER);
    nonOpaquePanel.add(new JLabel(MessageType.ERROR.getDefaultIcon()), BorderLayout.WEST);

    JBPopupFactory.getInstance().createBalloonBuilder(nonOpaquePanel)
            .setFillColor(MessageType.ERROR.getPopupBackground())
            .createBalloon()
            .show(new RelativePoint(component, new Point(0, 0)), Balloon.Position.above);
}
 
Example #2
Source File: RunAnythingPopupUI.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
@Nonnull
public JPanel createTopLeftPanel() {
  myTextFieldTitle = new JLabel(IdeBundle.message("run.anything.run.anything.title"));
  JPanel topPanel = new NonOpaquePanel(new BorderLayout());
  Color foregroundColor = UIUtil.getLabelForeground();


  myTextFieldTitle.setForeground(foregroundColor);
  myTextFieldTitle.setBorder(BorderFactory.createEmptyBorder(3, 5, 5, 0));
  if (SystemInfo.isMac) {
    myTextFieldTitle.setFont(myTextFieldTitle.getFont().deriveFont(Font.BOLD, myTextFieldTitle.getFont().getSize() - 1f));
  }
  else {
    myTextFieldTitle.setFont(myTextFieldTitle.getFont().deriveFont(Font.BOLD));
  }

  topPanel.add(myTextFieldTitle);

  return topPanel;
}
 
Example #3
Source File: RedisPanel.java    From nosql4idea with Apache License 2.0 6 votes vote down vote up
protected void buildQueryToolBar() {
    toolBarPanel.setLayout(new BorderLayout());

    filterField = new JBTextField("*");
    filterField.setColumns(10);

    NonOpaquePanel westPanel = new NonOpaquePanel();

    NonOpaquePanel filterPanel = new NonOpaquePanel();
    filterPanel.add(new JLabel("Filter: "), BorderLayout.WEST);
    filterPanel.add(filterField, BorderLayout.CENTER);
    filterPanel.add(Box.createHorizontalStrut(5), BorderLayout.EAST);
    westPanel.add(filterPanel, BorderLayout.WEST);

    toolBarPanel.add(westPanel, BorderLayout.WEST);

    addCommonsActions();
}
 
Example #4
Source File: DetailsComponent.java    From consulo with Apache License 2.0 6 votes vote down vote up
public DetailsComponent(boolean detailsEnabled, boolean paintBorder) {
  myDetailsEnabled = detailsEnabled;
  myPaintBorder = paintBorder;
  myComponent = new JPanel(new BorderLayout());

  myComponent.setOpaque(false);
  myContentGutter.setOpaque(false);
  myContentGutter.setBorder(null);

  myBanner = new NonOpaquePanel(new BorderLayout());
  myBannerLabel = new Banner();

  if (myDetailsEnabled) {
    myBanner.add(myBannerLabel, BorderLayout.CENTER);
  }

  myEmptyContentLabel = new JLabel("", SwingConstants.CENTER);

  revalidateDetailsMode();
}
 
Example #5
Source File: SearchTextArea.java    From consulo with Apache License 2.0 6 votes vote down vote up
public List<Component> setExtraActions(AnAction... actions) {
  myExtraActionsPanel.removeAll();
  myExtraActionsPanel.setBorder(JBUI.Borders.empty());
  ArrayList<Component> addedButtons = new ArrayList<>();
  if (actions != null && actions.length > 0) {
    JPanel buttonsGrid = new NonOpaquePanel(new GridLayout(1, actions.length, 0, 0));
    for (AnAction action : actions) {
      ActionButton button = new MyActionButton(action, true);
      addedButtons.add(button);
      buttonsGrid.add(button);
    }
    myExtraActionsPanel.setLayout(new BorderLayout());
    myExtraActionsPanel.add(buttonsGrid, BorderLayout.NORTH);
    myExtraActionsPanel.setBorder(new CompoundBorder(JBUI.Borders.customLine(JBUI.CurrentTheme.CustomFrameDecorations.separatorForeground(), 0, 1, 0, 0), JBUI.Borders.emptyLeft(4)));
  }
  return addedButtons;
}
 
Example #6
Source File: SearchTextArea.java    From consulo with Apache License 2.0 6 votes vote down vote up
protected void updateLayout() {
  JPanel historyButtonWrapper = new NonOpaquePanel(new BorderLayout());
  historyButtonWrapper.setBorder(JBUI.Borders.emptyTop(1));
  historyButtonWrapper.add(myHistoryPopupButton, BorderLayout.NORTH);
  JPanel iconsPanelWrapper = new NonOpaquePanel(new BorderLayout());
  iconsPanelWrapper.setBorder(JBUI.Borders.emptyTop(1));
  JPanel p = new NonOpaquePanel(new BorderLayout());
  p.add(myIconsPanel, BorderLayout.NORTH);
  iconsPanelWrapper.add(p, BorderLayout.WEST);
  iconsPanelWrapper.add(myExtraActionsPanel, BorderLayout.CENTER);

  removeAll();
  setLayout(new BorderLayout(JBUIScale.scale(3), 0));
  setBorder(JBUI.Borders.empty(SystemInfo.isLinux ? JBUI.scale(2) : JBUI.scale(1)));
  add(historyButtonWrapper, BorderLayout.WEST);
  add(myScrollPane, BorderLayout.CENTER);
  add(iconsPanelWrapper, BorderLayout.EAST);
  updateIconsLayout();
}
 
Example #7
Source File: DesktopContentManagerImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nonnull
@Override
public JComponent getComponent() {
  if (myComponent == null) {
    myComponent = new MyNonOpaquePanel();

    NonOpaquePanel contentComponent = new NonOpaquePanel();
    contentComponent.setContent(myUI.getComponent());
    contentComponent.setFocusCycleRoot(true);

    myComponent.add(contentComponent, BorderLayout.CENTER);
  }
  return myComponent;
}
 
Example #8
Source File: GraphQLEditConfigAction.java    From js-graphql-intellij-plugin with MIT License 5 votes vote down vote up
@Nullable
@Override
protected JComponent createCenterPanel() {
    comboBox = new ComboBox<>(new CollectionComboBoxModel<>(configDirectoryCandidates));
    comboBox.setRenderer(new DefaultPsiElementCellRenderer());
    comboBox.setMinimumAndPreferredWidth(450);
    if (comboBox.getItemCount() > 0) {
        comboBox.setSelectedIndex(0);
    }
    final NonOpaquePanel panel = new NonOpaquePanel();
    panel.add(comboBox, BorderLayout.NORTH);
    return panel;
}
 
Example #9
Source File: PopupFactoryImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nonnull
@Override
public BalloonBuilder createHtmlTextBalloonBuilder(@Nonnull final String htmlContent, @Nullable final Icon icon, Color textColor, final Color fillColor, @Nullable final HyperlinkListener listener) {
  JEditorPane text = IdeTooltipManager.initPane(htmlContent, new HintHint().setTextFg(textColor).setAwtTooltip(true), null);

  if (listener != null) {
    text.addHyperlinkListener(listener);
  }
  text.setEditable(false);
  NonOpaquePanel.setTransparent(text);
  text.setBorder(null);


  JLabel label = new JLabel();
  final JPanel content = new NonOpaquePanel(new BorderLayout((int)(label.getIconTextGap() * 1.5), (int)(label.getIconTextGap() * 1.5)));

  final NonOpaquePanel textWrapper = new NonOpaquePanel(new GridBagLayout());
  JScrollPane scrolledText = ScrollPaneFactory.createScrollPane(text, true);
  scrolledText.setBackground(fillColor);
  scrolledText.getViewport().setBackground(fillColor);
  textWrapper.add(scrolledText);
  content.add(textWrapper, BorderLayout.CENTER);
  if (icon != null) {
    final NonOpaquePanel north = new NonOpaquePanel(new BorderLayout());
    north.add(new JLabel(icon), BorderLayout.NORTH);
    content.add(north, BorderLayout.WEST);
  }

  content.setBorder(JBUI.Borders.empty(2, 4));

  final BalloonBuilder builder = createBalloonBuilder(content);

  builder.setFillColor(fillColor);

  return builder;
}
 
Example #10
Source File: ActionMacroManager.java    From consulo with Apache License 2.0 5 votes vote down vote up
private Widget(StatusBar statusBar) {
  myStatusBar = statusBar;
  myPresentation = new WidgetPresentation() {
    @Override
    public String getTooltipText() {
      return "Macro is being recorded now";
    }

    @Override
    public Consumer<MouseEvent> getClickConsumer() {
      return Widget.this;
    }
  };


  new BaseButtonBehavior(myIcon) {
    @Override
    protected void execute(MouseEvent e) {
      showBalloon();
    }
  };

  myBalloonComponent = new NonOpaquePanel(new BorderLayout());

  final AnAction stopAction = ActionManager.getInstance().getAction("StartStopMacroRecording");
  final DefaultActionGroup group = new DefaultActionGroup();
  group.add(stopAction);
  final ActionToolbar tb = ActionManager.getInstance().createActionToolbar(ActionPlaces.STATUS_BAR_PLACE, group, true);
  tb.setMiniMode(true);

  final NonOpaquePanel top = new NonOpaquePanel(new BorderLayout());
  top.add(tb.getComponent(), BorderLayout.WEST);
  myText = new JLabel(RECORDED + "..." + TYPING_SAMPLE, SwingConstants.LEFT);
  final Dimension preferredSize = myText.getPreferredSize();
  myText.setPreferredSize(preferredSize);
  myText.setText("Macro recording started...");
  myLastTyping = "";
  top.add(myText, BorderLayout.CENTER);
  myBalloonComponent.add(top, BorderLayout.CENTER);
}
 
Example #11
Source File: RepositoryWithBranchPanel.java    From consulo with Apache License 2.0 5 votes vote down vote up
private void layoutComponents() {
  add(myRepositoryCheckbox, BorderLayout.WEST);
  JPanel panel = new NonOpaquePanel(new BorderLayout());
  panel.add(myTextRenderer, BorderLayout.WEST);
  panel.add(myDestPushTargetPanelComponent, BorderLayout.CENTER);
  add(panel, BorderLayout.CENTER);
}
 
Example #12
Source File: BranchActionGroupPopup.java    From consulo with Apache License 2.0 5 votes vote down vote up
private void createTitlePanelToolbar(@Nonnull String dimensionKey) {
  myTitleToolbarPanel = new NonOpaquePanel();
  myTitleToolbarPanel.setLayout(new BoxLayout(myTitleToolbarPanel, BoxLayout.LINE_AXIS));
  myTitleToolbarPanel.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
  myRestoreSizeButton = new MyToolbarButton("Restore Size", CollapseComponent, CollapseComponentHover, e -> {
    WindowStateService.getInstance(myProject).putSizeFor(myProject, dimensionKey, null);
    myInternalSizeChanged = true;
    pack(true, true);
  }) {
    @Override
    protected boolean isButtonEnabled() {
      return myUserSizeChanged;
    }
  };

  mySettingsButton = new MyToolbarButton("Settings", AllIcons.General.GearPlain, null, e -> {
    final ActionPopupMenu popupMenu = ActionManager.getInstance().createActionPopupMenu(BRANCH_POPUP, new DefaultActionGroup(mySettingsActions));
    popupMenu.getComponent().show(mySettingsButton, 0, assertNotNull(mySettingsButton).getHeight());
  }) {
    @Override
    protected boolean isButtonEnabled() {
      return !mySettingsActions.isEmpty();
    }
  };

  myTitleToolbarPanel.add(mySettingsButton);
  myTitleToolbarPanel.add(myRestoreSizeButton);
  getTitle().setButtonComponent(new ActiveComponent.Adapter() {
    @Nonnull
    @Override
    public JComponent getComponent() {
      return myTitleToolbarPanel;
    }
  }, JBUI.Borders.emptyRight(2));
}
 
Example #13
Source File: ChangesTreeList.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public Component getTreeCellRendererComponent(JTree tree,
                                              Object value,
                                              boolean selected,
                                              boolean expanded,
                                              boolean leaf,
                                              int row,
                                              boolean hasFocus) {

  if (UIUtil.isUnderGTKLookAndFeel() || UIUtil.isUnderNimbusLookAndFeel()) {
    NonOpaquePanel.setTransparent(this);
    NonOpaquePanel.setTransparent(myCheckBox);
  } else {
    setBackground(null);
    myCheckBox.setBackground(null);
    myCheckBox.setOpaque(false);
  }

  myTextRenderer.setOpaque(false);
  myTextRenderer.setTransparentIconBackground(true);
  myTextRenderer.setToolTipText(null);
  myTextRenderer.getTreeCellRendererComponent(tree, value, selected, expanded, leaf, row, hasFocus);
  if (myShowCheckboxes) {
    @SuppressWarnings("unchecked")
    CheckboxTree.NodeState state = getNodeStatus((ChangesBrowserNode)value);
    myCheckBox.setSelected(state != CheckboxTree.NodeState.CLEAR);
    //noinspection unchecked
    myCheckBox.setEnabled(tree.isEnabled() && isNodeEnabled((ChangesBrowserNode)value));
    revalidate();

    return this;
  }
  else {
    return myTextRenderer;
  }
}
 
Example #14
Source File: RunConfigurationsComboBoxAction.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nonnull
@Override
public JComponent createCustomComponent(final Presentation presentation) {
  ComboBoxButton button = createComboBoxButton(presentation);
  NonOpaquePanel panel = new NonOpaquePanel(new BorderLayout());
  panel.setBorder(IdeBorderFactory.createEmptyBorder(0, 0, 0, 2));
  panel.add(button.getComponent());
  return panel;
}
 
Example #15
Source File: MnemonicChooser.java    From consulo with Apache License 2.0 5 votes vote down vote up
public MnemonicChooser() {
  super(new VerticalFlowLayout());
  JPanel numbers = new NonOpaquePanel(new GridLayout(2, 5, 2, 2));
  for (char i = '1'; i <= '9'; i++) {
    numbers.add(new MnemonicLabel(i));
  }
  numbers.add(new MnemonicLabel('0'));
  

  JPanel letters = new NonOpaquePanel(new GridLayout(5, 6, 2, 2));
  for (char c = 'A'; c <= 'Z'; c++) {
    letters.add(new MnemonicLabel(c));
  }

  add(numbers);
  add(new JSeparator());
  add(letters);
  setBackground(UIUtil.getListBackground());

  addKeyListener(new KeyAdapter() {
    @Override
    public void keyPressed(KeyEvent e) {
      if (e.getKeyCode() == KeyEvent.VK_ESCAPE) {
        onCancelled();
      }
      else if (e.getModifiersEx() == 0) {
        final char typed = Character.toUpperCase(e.getKeyChar());
        if (typed >= '0' && typed <= '9' || typed >= 'A' && typed <= 'Z') {
          onMnemonicChosen(typed);
        }
      }
    }
  });

  setFocusable(true);
}
 
Example #16
Source File: NavigationItemListCellRenderer.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
  removeAll();

  final boolean hasRightRenderer = UISettings.getInstance().getShowIconInQuickNavigation();

  final LeftRenderer left = new LeftRenderer(true, MatcherHolder.getAssociatedMatcher(list));
  final Component leftCellRendererComponent = left.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
  final Color listBg = leftCellRendererComponent.getBackground();
  add(leftCellRendererComponent, BorderLayout.WEST);

  setBackground(isSelected ? UIUtil.getListSelectionBackground(true) : listBg);

  if (hasRightRenderer) {
    final DefaultListCellRenderer moduleRenderer = new PsiElementModuleRenderer();

    final Component rightCellRendererComponent = moduleRenderer.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
    ((JComponent)rightCellRendererComponent).setOpaque(false);
    rightCellRendererComponent.setBackground(listBg);
    add(rightCellRendererComponent, BorderLayout.EAST);
    final JPanel spacer = new NonOpaquePanel();

    final Dimension size = rightCellRendererComponent.getSize();
    spacer.setSize(new Dimension((int)(size.width * 0.015 + leftCellRendererComponent.getSize().width * 0.015), size.height));
    spacer.setBackground(isSelected ? UIUtil.getListSelectionBackground(true) : listBg);
    add(spacer, BorderLayout.CENTER);
  }
  return this;
}
 
Example #17
Source File: FlatWelcomePanel.java    From consulo with Apache License 2.0 5 votes vote down vote up
private JComponent createSettingsAndDocs() {
  JPanel panel = new NonOpaquePanel(new BorderLayout());
  NonOpaquePanel toolbar = new NonOpaquePanel();

  toolbar.setLayout(new BoxLayout(toolbar, BoxLayout.X_AXIS));
  toolbar.add(createEventsLink());
  toolbar.add(createActionLink("Configure", IdeActions.GROUP_WELCOME_SCREEN_CONFIGURE, AllIcons.General.GearPlain, true));
  toolbar.add(createActionLink("Get Help", IdeActions.GROUP_WELCOME_SCREEN_DOC, null, false));

  panel.add(toolbar, BorderLayout.EAST);


  panel.setBorder(JBUI.Borders.empty(0, 0, 8, 11));
  return panel;
}
 
Example #18
Source File: DesktopInternalDecorator.java    From consulo with Apache License 2.0 5 votes vote down vote up
private void init(boolean dumbAware) {
  enableEvents(AWTEvent.COMPONENT_EVENT_MASK);

  final JPanel contentPane = new JPanel(new BorderLayout());
  installFocusTraversalPolicy(contentPane, new LayoutFocusTraversalPolicy());
  contentPane.add(myHeader, BorderLayout.NORTH);

  JPanel innerPanel = new JPanel(new BorderLayout());
  JComponent toolWindowComponent = myToolWindow.getComponent();
  if (!dumbAware) {
    toolWindowComponent = DumbService.getInstance(myProject).wrapGently(toolWindowComponent, myProject);
  }
  innerPanel.add(toolWindowComponent, BorderLayout.CENTER);

  final NonOpaquePanel inner = new NonOpaquePanel(innerPanel);

  contentPane.add(inner, BorderLayout.CENTER);
  add(contentPane, BorderLayout.CENTER);
  if (SystemInfo.isMac) {
    setBackground(new JBColor(Gray._200, Gray._90));
  }

  // Add listeners
  registerKeyboardAction(new ActionListener() {
    @Override
    public void actionPerformed(final ActionEvent e) {
      ToolWindowManager.getInstance(myProject).activateEditorComponent();
    }
  }, KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
}
 
Example #19
Source File: DesktopEditorComposite.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nonnull
private List<JComponent> getTopBottomComponents(@Nonnull FileEditor editor, boolean top) {
  SmartList<JComponent> result = new SmartList<>();
  JComponent container = top ? myTopComponents.get(editor) : myBottomComponents.get(editor);
  for (Component each : container.getComponents()) {
    if (each instanceof NonOpaquePanel) {
      result.add(((NonOpaquePanel)each).getTargetComponent());
    }
  }
  return Collections.unmodifiableList(result);
}
 
Example #20
Source File: QueryPanel.java    From nosql4idea with Apache License 2.0 5 votes vote down vote up
private AggregatorPanel() {
    this.editor = createEditor();

    setLayout(new BorderLayout());
    NonOpaquePanel headPanel = new NonOpaquePanel();
    JLabel operatorLabel = new JLabel("Aggregation");
    headPanel.add(operatorLabel, BorderLayout.WEST);
    add(headPanel, BorderLayout.NORTH);
    add(this.editor.getComponent(), BorderLayout.CENTER);

    this.operatorCompletionAction = new OperatorCompletionAction(project, editor);


    myUpdateAlarm.setActivationComponent(this.editor.getComponent());
}
 
Example #21
Source File: QueryPanel.java    From nosql4idea with Apache License 2.0 5 votes vote down vote up
private JPanel createSubOperatorPanel(String title, Editor subOperatorEditor) {
    JPanel selectPanel = new JPanel();
    selectPanel.setLayout(new BorderLayout());
    NonOpaquePanel headPanel = new NonOpaquePanel();
    JLabel operatorLabel = new JLabel(title);
    headPanel.add(operatorLabel, BorderLayout.WEST);
    selectPanel.add(headPanel, BorderLayout.NORTH);
    selectPanel.add(subOperatorEditor.getComponent(), BorderLayout.CENTER);

    myUpdateAlarm.setActivationComponent(subOperatorEditor.getComponent());

    return selectPanel;
}
 
Example #22
Source File: MongoPanel.java    From nosql4idea with Apache License 2.0 5 votes vote down vote up
private void initToolBar() {
    toolBar.setLayout(new BorderLayout());

    rowLimitField.setColumns(5);
    rowLimitField.setDocument(new NumberDocument());

    JPanel rowLimitPanel = new NonOpaquePanel();
    rowLimitPanel.add(new JLabel("Row limit:"), BorderLayout.WEST);
    rowLimitPanel.add(rowLimitField, BorderLayout.CENTER);
    rowLimitPanel.add(Box.createHorizontalStrut(5), BorderLayout.EAST);
    toolBar.add(rowLimitPanel, BorderLayout.WEST);

    installResultPanelActions();
}
 
Example #23
Source File: CouchbasePanel.java    From nosql4idea with Apache License 2.0 5 votes vote down vote up
private void initToolbar() {
    toolBarPanel.setLayout(new BorderLayout());

    rowLimitField.setColumns(5);
    rowLimitField.setDocument(new NumberDocument());
    rowLimitField.setText("100");

    JPanel rowLimitPanel = new NonOpaquePanel();
    rowLimitPanel.add(new JLabel("Row limit:"), BorderLayout.WEST);
    rowLimitPanel.add(rowLimitField, BorderLayout.CENTER);
    rowLimitPanel.add(Box.createHorizontalStrut(5), BorderLayout.EAST);
    toolBarPanel.add(rowLimitPanel, BorderLayout.WEST);

    addCommonsActions();
}
 
Example #24
Source File: LoadingDecorator.java    From consulo with Apache License 2.0 5 votes vote down vote up
protected NonOpaquePanel customizeLoadingLayer(JPanel parent, JLabel text, AsyncProcessIcon icon) {
  parent.setLayout(new GridBagLayout());

  final Font font = text.getFont();
  text.setFont(font.deriveFont(font.getStyle(), font.getSize() + 8));
  //text.setForeground(Color.black);

  final int gap = new JLabel().getIconTextGap();
  final NonOpaquePanel result = new NonOpaquePanel(new FlowLayout(FlowLayout.CENTER, gap * 3, 0));
  result.add(icon);
  result.add(text);
  parent.add(result);

  return result;
}
 
Example #25
Source File: GroupedElementsRenderer.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
protected void layout() {
  myRendererComponent.add(mySeparatorComponent, BorderLayout.NORTH);

  JComponent centerComponent = new NonOpaquePanel(myComponent) {
    @Override
    public Dimension getPreferredSize() {
      return UIUtil.updateListRowHeight(super.getPreferredSize());
    }
  };

  myRendererComponent.add(centerComponent, BorderLayout.CENTER);
}
 
Example #26
Source File: ActionPanel.java    From consulo with Apache License 2.0 5 votes vote down vote up
public ActionPanel(JBTabsImpl tabs, TabInfo tabInfo, Pass<MouseEvent> pass) {
  myTabs = tabs;
  ActionGroup group = tabInfo.getTabLabelActions() != null ? tabInfo.getTabLabelActions() : new DefaultActionGroup();
  AnAction[] children = group.getChildren(null);

  final NonOpaquePanel wrapper = new NonOpaquePanel(new BorderLayout());
  wrapper.add(Box.createHorizontalStrut(2), BorderLayout.WEST);
  NonOpaquePanel inner = new NonOpaquePanel();
  inner.setLayout(new BoxLayout(inner, BoxLayout.X_AXIS));
  wrapper.add(inner, BorderLayout.CENTER);
  for (AnAction each : children) {
    ActionButton eachButton = new ActionButton(myTabs, tabInfo, each, tabInfo.getTabActionPlace(), pass, tabs.getTabActionsMouseDeadzone()) {
      @Override
      protected void repaintComponent(final Component c) {
        TabLabel tabLabel = (TabLabel) SwingUtilities.getAncestorOfClass(TabLabel.class, c);
        if (tabLabel != null) {
          Point point = SwingUtilities.convertPoint(c, new Point(0, 0), tabLabel);
          Dimension d = c.getSize();
          tabLabel.repaint(point.x, point.y, d.width, d.height);
        } else {
          super.repaintComponent(c);
        }
      }
    };

    myButtons.add(eachButton);
    InplaceButton component = eachButton.getComponent();
    inner.add(component);
  }

  add(wrapper);
}
 
Example #27
Source File: SwingHelper.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nonnull
public static JEditorPane createHtmlViewer(boolean lineWrap, @Nullable Font font, @Nullable Color background, @Nullable Color foreground) {
  final JEditorPane textPane;
  if (lineWrap) {
    textPane = new JEditorPane() {
      @Override
      public Dimension getPreferredSize() {
        // This trick makes text component to carry text over to the next line
        // if the text line width exceeds parent's width
        Dimension dimension = super.getPreferredSize();
        dimension.width = 0;
        return dimension;
      }
    };
  }
  else {
    textPane = new JEditorPane();
  }
  textPane.setFont(font != null ? font : UIUtil.getLabelFont());
  textPane.setEditorKit(UIUtil.getHTMLEditorKit());
  textPane.setEditable(false);
  if (background != null) {
    textPane.setBackground(background);
  }
  else {
    NonOpaquePanel.setTransparent(textPane);
  }
  textPane.setForeground(foreground != null ? foreground : UIUtil.getLabelForeground());
  textPane.setFocusable(false);
  return textPane;
}
 
Example #28
Source File: ProgressStripe.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
protected NonOpaquePanel customizeLoadingLayer(JPanel parent, JLabel text, AsyncProcessIcon icon) {
  parent.setLayout(new BorderLayout());

  NonOpaquePanel result = new NonOpaquePanel();
  result.setLayout(new BoxLayout(result, BoxLayout.Y_AXIS));
  result.add(icon);

  parent.add(result, BorderLayout.NORTH);

  return result;
}
 
Example #29
Source File: InlineProgressIndicator.java    From consulo with Apache License 2.0 5 votes vote down vote up
protected void createCompactTextAndProgress() {
  JPanel textAndProgress = new NonOpaquePanel(new BorderLayout());
  textAndProgress.add(myText, BorderLayout.CENTER);

  final NonOpaquePanel progressWrapper = new NonOpaquePanel(new BorderLayout());
  progressWrapper.setBorder(JBUI.Borders.empty(0, 4));
  progressWrapper.add(myProgress, BorderLayout.CENTER);

  textAndProgress.add(progressWrapper, BorderLayout.EAST);
  myComponent.add(textAndProgress, BorderLayout.CENTER);
}
 
Example #30
Source File: InlineProgressIndicator.java    From consulo with Apache License 2.0 5 votes vote down vote up
static JPanel createButtonPanel(Iterable<? extends JComponent> components) {
  JPanel iconsPanel = new NonOpaquePanel(new GridBagLayout());
  GridBag gb = new GridBag().setDefaultFill(GridBagConstraints.BOTH);
  for (JComponent component : components) {
    iconsPanel.add(component, gb.next());
  }
  return iconsPanel;
}