private JComponent createActionLink(
     final String text, final String groupId, Icon icon, boolean focusListOnLeft) {
   final Ref<ActionLink> ref = new Ref<ActionLink>(null);
   AnAction action =
       new AnAction() {
         @Override
         public void actionPerformed(@NotNull AnActionEvent e) {
           ActionGroup configureGroup =
               (ActionGroup) ActionManager.getInstance().getAction(groupId);
           final PopupFactoryImpl.ActionGroupPopup popup =
               (PopupFactoryImpl.ActionGroupPopup)
                   JBPopupFactory.getInstance()
                       .createActionGroupPopup(
                           null,
                           new IconsFreeActionGroup(configureGroup),
                           e.getDataContext(),
                           JBPopupFactory.ActionSelectionAid.SPEEDSEARCH,
                           false,
                           ActionPlaces.WELCOME_SCREEN);
           popup.showUnderneathOfLabel(ref.get());
           UsageTrigger.trigger("welcome.screen." + groupId);
         }
       };
   ref.set(new ActionLink(text, icon, action));
   ref.get().setPaintUnderline(false);
   ref.get().setNormalColor(getLinkNormalColor());
   NonOpaquePanel panel = new NonOpaquePanel(new BorderLayout());
   panel.setBorder(JBUI.Borders.empty(4, 6, 4, 6));
   panel.add(ref.get());
   panel.add(createArrow(ref.get()), BorderLayout.EAST);
   installFocusable(panel, action, KeyEvent.VK_UP, KeyEvent.VK_DOWN, focusListOnLeft);
   return panel;
 }
    private JComponent createLogo() {
      NonOpaquePanel panel = new NonOpaquePanel(new BorderLayout());
      ApplicationInfoEx app = ApplicationInfoEx.getInstanceEx();
      JLabel logo = new JLabel(IconLoader.getIcon(app.getWelcomeScreenLogoUrl()));
      logo.setBorder(JBUI.Borders.empty(30, 0, 10, 0));
      logo.setHorizontalAlignment(SwingConstants.CENTER);
      panel.add(logo, BorderLayout.NORTH);
      JLabel appName = new JLabel(ApplicationNamesInfo.getInstance().getFullProductName());
      Font font = getProductFont();
      appName.setForeground(JBColor.foreground());
      appName.setFont(font.deriveFont(JBUI.scale(36f)).deriveFont(Font.PLAIN));
      appName.setHorizontalAlignment(SwingConstants.CENTER);
      String appVersion = "Version " + app.getFullVersion();

      if (app.isEAP() && app.getBuild().getBuildNumber() < Integer.MAX_VALUE) {
        appVersion += " (" + app.getBuild().asString() + ")";
      }

      JLabel version = new JLabel(appVersion);
      version.setFont(getProductFont().deriveFont(JBUI.scale(16f)));
      version.setHorizontalAlignment(SwingConstants.CENTER);
      version.setForeground(Gray._128);

      panel.add(appName);
      panel.add(version, BorderLayout.SOUTH);
      panel.setBorder(JBUI.Borders.emptyBottom(20));
      return panel;
    }
 private JComponent createBody() {
   NonOpaquePanel panel = new NonOpaquePanel(new BorderLayout());
   panel.add(createLogo(), BorderLayout.NORTH);
   panel.add(createActionPanel(), BorderLayout.CENTER);
   panel.add(createSettingsAndDocs(), BorderLayout.SOUTH);
   return panel;
 }
  @NotNull
  @Override
  public BalloonBuilder createHtmlTextBalloonBuilder(
      @NotNull final String htmlContent,
      @Nullable final Icon icon,
      final Color fillColor,
      @Nullable final HyperlinkListener listener) {

    JEditorPane text =
        IdeTooltipManager.initPane(htmlContent, new HintHint().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 = new JScrollPane(text);
    scrolledText.setBackground(fillColor);
    scrolledText.getViewport().setBackground(fillColor);
    scrolledText.getViewport().setBorder(null);
    scrolledText.setBorder(null);
    textWrapper.add(scrolledText);
    content.add(textWrapper, BorderLayout.CENTER);

    final NonOpaquePanel north = new NonOpaquePanel(new BorderLayout());
    north.add(new JLabel(icon), BorderLayout.NORTH);
    content.add(north, BorderLayout.WEST);

    content.setBorder(new EmptyBorder(2, 4, 2, 4));

    final BalloonBuilder builder = createBalloonBuilder(content);

    builder.setFillColor(fillColor);

    return builder;
  }
 @Override
 public JComponent createCustomComponent(final Presentation presentation) {
   ComboBoxButton button = createComboBoxButton(presentation);
   button.setBorder(BorderFactory.createEmptyBorder(0, 2, 0, 2));
   NonOpaquePanel panel = new NonOpaquePanel(new BorderLayout());
   panel.setBorder(IdeBorderFactory.createEmptyBorder(0, 0, 0, 2));
   panel.add(button);
   return panel;
 }
    private JComponent createSettingsAndDocs() {
      JPanel panel = new NonOpaquePanel(new BorderLayout());
      NonOpaquePanel toolbar = new NonOpaquePanel();
      AnAction register = ActionManager.getInstance().getAction("Register");
      boolean registeredVisible = false;
      if (register != null) {
        AnActionEvent e =
            AnActionEvent.createFromAnAction(
                register,
                null,
                ActionPlaces.WELCOME_SCREEN,
                DataManager.getInstance().getDataContext(this));
        register.update(e);
        Presentation presentation = e.getPresentation();
        if (presentation.isEnabled()) {
          ActionLink registerLink = new ActionLink("Register", register);
          registerLink.setNormalColor(getLinkNormalColor());
          NonOpaquePanel button = new NonOpaquePanel(new BorderLayout());
          button.setBorder(JBUI.Borders.empty(4, 10));
          button.add(registerLink);
          installFocusable(button, register, KeyEvent.VK_UP, KeyEvent.VK_RIGHT, true);
          NonOpaquePanel wrap = new NonOpaquePanel();
          wrap.setBorder(JBUI.Borders.emptyLeft(10));
          wrap.add(button);
          panel.add(wrap, BorderLayout.WEST);
          registeredVisible = true;
        }
      }

      toolbar.setLayout(new BoxLayout(toolbar, BoxLayout.X_AXIS));
      toolbar.add(
          createActionLink(
              "Configure",
              IdeActions.GROUP_WELCOME_SCREEN_CONFIGURE,
              AllIcons.General.GearPlain,
              !registeredVisible));
      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;
    }
Ejemplo n.º 7
0
 public void addAction(final Action action) {
   action.addPropertyChangeListener(this);
   final LinkLabel label =
       new LinkLabel(
           null,
           null,
           new LinkListener() {
             public void linkSelected(final LinkLabel aSource, final Object aLinkData) {
               action.actionPerformed(
                   new ActionEvent(
                       Banner.this, ActionEvent.ACTION_PERFORMED, Action.ACTION_COMMAND_KEY));
             }
           });
   myActions.put(action, label);
   myActionsPanel.add(label);
   updateAction(action);
 }