Esempio n. 1
0
  private void updatePopup() {
    int count = myBalloonPanel.getComponentCount();
    List<NotificationType> types = new ArrayList<NotificationType>(count);
    for (int i = 0; i < count; i++) {
      types.add(
          (NotificationType)
              ((JComponent) myBalloonPanel.getComponent(i)).getClientProperty(TYPE_KEY));
    }
    myListener.run(types);

    if (myVisible) {
      layoutPopup();
    }
  }
Esempio n. 2
0
  private void addToPopup(
      @NotNull final BalloonImpl balloon, @NotNull BalloonLayoutData layoutData) {
    layoutData.doLayout =
        new Runnable() {
          @Override
          public void run() {
            WelcomeBalloonLayoutImpl.this.layoutPopup();
          }
        };
    layoutData.configuration =
        layoutData.configuration.replace(
            JBUI.scale(myPopupBalloon == null ? 7 : 5), JBUI.scale(12));

    if (myPopupBalloon == null) {
      final JScrollPane pane =
          NotificationsManagerImpl.createBalloonScrollPane(myBalloonPanel, true);
      pane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
      pane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);

      pane.getVerticalScrollBar()
          .addComponentListener(
              new ComponentAdapter() {
                @Override
                public void componentShown(ComponentEvent e) {
                  pane.setBorder(
                      IdeBorderFactory.createEmptyBorder(SystemInfo.isMac ? 2 : 1, 0, 1, 1));
                }

                @Override
                public void componentHidden(ComponentEvent e) {
                  pane.setBorder(IdeBorderFactory.createEmptyBorder());
                }
              });

      myPopupBalloon =
          new BalloonImpl(
              pane,
              BORDER_COLOR,
              new Insets(0, 0, 0, 0),
              FILL_COLOR,
              true,
              false,
              false,
              false,
              true,
              0,
              false,
              false,
              null,
              false,
              0,
              0,
              0,
              0,
              false,
              null,
              null,
              false,
              false,
              false,
              null,
              false);
      myPopupBalloon.setAnimationEnabled(false);
      myPopupBalloon.setShadowBorderProvider(
          new NotificationBalloonShadowBorderProvider(FILL_COLOR, BORDER_COLOR));
      myPopupBalloon.setHideListener(
          new Runnable() {
            @Override
            public void run() {
              myPopupBalloon.getComponent().setVisible(false);
            }
          });
      myPopupBalloon.setActionProvider(
          new BalloonImpl.ActionProvider() {
            private BalloonImpl.ActionButton myAction;

            @NotNull
            @Override
            public List<BalloonImpl.ActionButton> createActions() {
              myAction =
                  myPopupBalloon
                  .new ActionButton(
                      AllIcons.Ide.Notification.Close, null, null, Consumer.EMPTY_CONSUMER);
              return Collections.singletonList(myAction);
            }

            @Override
            public void layout(@NotNull Rectangle bounds) {
              myAction.setBounds(0, 0, 0, 0);
            }
          });
    }

    myBalloonPanel.add(balloon.getContent());
    balloon.getContent().putClientProperty(TYPE_KEY, layoutData.type);
    Disposer.register(
        balloon,
        new Disposable() {
          @Override
          public void dispose() {
            myBalloons.remove(balloon);
            myBalloonPanel.remove(balloon.getContent());
            updatePopup();
          }
        });
    myBalloons.add(balloon);

    updatePopup();
  }