Java 类com.intellij.ui.components.labels.ActionLink 实例源码

项目:intellij-ce-playground    文件:FlatWelcomeFrame.java   
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;
}
项目:intellij-ce-playground    文件:VcsPushDialog.java   
@NotNull
private JComponent createForcePushInfoLabel() {
  JPanel text = new JPanel();
  text.setLayout(new BoxLayout(text, BoxLayout.X_AXIS));
  JLabel label = new JLabel("You can enable and configure Force Push in " + ShowSettingsUtil.getSettingsMenuName() + ".");
  label.setEnabled(false);
  label.setFont(JBUI.Fonts.smallFont());
  text.add(label);
  ActionLink here = new ActionLink("Configure", new AnAction() {
    @Override
    public void actionPerformed(AnActionEvent e) {
      Project project = myController.getProject();
      VcsPushDialog.this.doCancelAction(e.getInputEvent());
      ShowSettingsUtilImpl.showSettingsDialog(project, "vcs.Git", "force push");
    }
  });
  here.setFont(JBUI.Fonts.smallFont());
  text.add(here);
  return JBUI.Panels.simplePanel().addToRight(text).withBorder(JBUI.Borders.emptyBottom(4));
}
项目:consulo    文件:FlatWelcomePanel.java   
private JComponent createActionLink(final String text, final String groupId, Icon icon, boolean focusListOnLeft) {
  final Ref<ActionLink> ref = new Ref<>(null);
  AnAction action = new AnAction() {
    @RequiredDispatchThread
    @Override
    public void actionPerformed(@Nonnull 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);
    }
  };
  JComponent panel = createActionLink(text, icon, ref, action);
  installFocusable(panel, action, KeyEvent.VK_UP, KeyEvent.VK_DOWN, focusListOnLeft);
  return panel;
}
项目:intellij-ce-playground    文件:FlatWelcomeFrame.java   
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;
}
项目:intellij-ce-playground    文件:FlatWelcomeFrame.java   
private static JLabel createArrow(final ActionLink link) {
  JLabel arrow = new JLabel(AllIcons.General.Combo3);
  arrow.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
  arrow.setVerticalAlignment(SwingConstants.BOTTOM);
  new ClickListener() {
    @Override
    public boolean onClick(@NotNull MouseEvent e, int clickCount) {
      final MouseEvent newEvent = MouseEventAdapter.convert(e, link, e.getX(), e.getY());
      link.doClick(newEvent);
      return true;
    }
  }.installOn(arrow);
  return arrow;
}
项目:intellij-ce-playground    文件:RunConfigurable.java   
private void drawPressAddButtonMessage(final ConfigurationType configurationType) {
  JPanel panel = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0));
  panel.setBorder(new EmptyBorder(30, 0, 0, 0));
  panel.add(new JLabel("Press the"));

  ActionLink addIcon = new ActionLink("", ADD_ICON, myAddAction);
  addIcon.setBorder(new EmptyBorder(0, 0, 0, 5));
  panel.add(addIcon);

  final String configurationTypeDescription = configurationType != null
                                              ? configurationType.getConfigurationTypeDescription()
                                              : ExecutionBundle.message("run.configuration.default.type.description");
  panel.add(new JLabel(ExecutionBundle.message("empty.run.configuration.panel.text.label3", configurationTypeDescription)));
  JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(panel, true);

  myRightPanel.removeAll();
  myRightPanel.add(scrollPane, BorderLayout.CENTER);
  if (configurationType == null) {
    JPanel settingsPanel = new JPanel(new GridBagLayout());
    GridBag grid = new GridBag().setDefaultAnchor(GridBagConstraints.NORTHWEST);

    for (Pair<UnnamedConfigurable, JComponent> each : myAdditionalSettings) {
      settingsPanel.add(each.second, grid.nextLine().next());
    }
    settingsPanel.add(createSettingsPanel(), grid.nextLine().next());

    JPanel wrapper = new JPanel(new BorderLayout());
    wrapper.add(settingsPanel, BorderLayout.WEST);
    wrapper.add(Box.createGlue(), BorderLayout.CENTER);

    myRightPanel.add(wrapper, BorderLayout.SOUTH);
  }
  myRightPanel.revalidate();
  myRightPanel.repaint();
}
项目:tools-idea    文件:RunConfigurable.java   
private void drawPressAddButtonMessage(final ConfigurationType configurationType) {
  JPanel panel = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0));
  panel.setBorder(new EmptyBorder(30, 0, 0, 0));
  panel.add(new JLabel("Press the"));

  ActionLink addIcon = new ActionLink("", ADD_ICON, myAddAction);
  addIcon.setBorder(new EmptyBorder(0, 0, 0, 5));
  panel.add(addIcon);

  final String configurationTypeDescription = configurationType != null
                                              ? configurationType.getConfigurationTypeDescription()
                                              : ExecutionBundle.message("run.configuration.default.type.description");
  panel.add(new JLabel(ExecutionBundle.message("empty.run.configuration.panel.text.label3", configurationTypeDescription)));
  JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(panel, true);

  myRightPanel.removeAll();
  myRightPanel.add(scrollPane, BorderLayout.CENTER);
  if (configurationType == null) {
    JPanel settingsPanel = new JPanel(new GridBagLayout());
    GridBag grid = new GridBag().setDefaultAnchor(GridBagConstraints.NORTHWEST);

    for (Pair<UnnamedConfigurable, JComponent> each : myAdditionalSettings) {
      settingsPanel.add(each.second, grid.nextLine().next());
    }
    settingsPanel.add(createSettingsPanel(), grid.nextLine().next());

    JPanel wrapper = new JPanel(new BorderLayout());
    wrapper.add(settingsPanel, BorderLayout.WEST);
    wrapper.add(Box.createGlue(), BorderLayout.CENTER);

    myRightPanel.add(wrapper, BorderLayout.SOUTH);
  }
  myRightPanel.revalidate();
  myRightPanel.repaint();
}
项目:idea-gitignore    文件:IgnoreSettingsPanel.java   
/**
 * Creates {@link ActionLink} component with URL open action.
 *
 * @param title title of link
 * @param url   url to open
 * @return {@link ActionLink} component
 */
private ActionLink createLink(@NotNull String title, @NotNull final String url) {
    final ActionLink action = new ActionLink(title, new AnAction() {
        @Override
        public void actionPerformed(AnActionEvent anActionEvent) {
            BrowserUtil.browse(url);
        }
    });
    action.setBorder(new EmptyBorder(0, 5, 0, 5));
    return action;
}
项目:consulo    文件:RunConfigurable.java   
private void drawPressAddButtonMessage(final ConfigurationType configurationType) {
  JPanel panel = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0));
  panel.setBorder(new EmptyBorder(7, 10, 0, 0));
  panel.add(new JLabel("Press the"));

  ActionLink addIcon = new ActionLink("", ADD_ICON, myAddAction);
  addIcon.setBorder(new EmptyBorder(0, 5, 0, 5));
  panel.add(addIcon);

  final String configurationTypeDescription = configurationType != null
                                              ? configurationType.getConfigurationTypeDescription()
                                              : ExecutionBundle.message("run.configuration.default.type.description");
  panel.add(new JLabel(ExecutionBundle.message("empty.run.configuration.panel.text.label3", configurationTypeDescription)));
  JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(panel, true);

  myRightPanel.removeAll();
  myRightPanel.add(scrollPane, BorderLayout.CENTER);
  if (configurationType == null) {
    JPanel settingsPanel = new JPanel(new GridBagLayout());
    settingsPanel.setBorder(new EmptyBorder(7, 10, 0, 0));
    GridBag grid = new GridBag().setDefaultAnchor(GridBagConstraints.NORTHWEST);

    for (Pair<UnnamedConfigurable, JComponent> each : myAdditionalSettings) {
      settingsPanel.add(each.second, grid.nextLine().next());
    }
    settingsPanel.add(createSettingsPanel(), grid.nextLine().next());

    JPanel wrapper = new JPanel(new BorderLayout());
    wrapper.add(settingsPanel, BorderLayout.WEST);
    wrapper.add(Box.createGlue(), BorderLayout.CENTER);

    myRightPanel.add(wrapper, BorderLayout.SOUTH);
  }
  myRightPanel.revalidate();
  myRightPanel.repaint();
}
项目:consulo    文件:FlatWelcomePanel.java   
private JComponent createEventsLink() {
  final Ref<ActionLink> actionLinkRef = new Ref<>();
  final JComponent panel = createActionLink("Events", AllIcons.Ide.Notification.NoEvents, actionLinkRef, new AnAction() {
    @RequiredDispatchThread
    @Override
    public void actionPerformed(@Nonnull AnActionEvent e) {
      ((WelcomeDesktopBalloonLayoutImpl)myFlatWelcomeFrame.getBalloonLayout()).showPopup();
    }
  });
  panel.setVisible(false);
  myEventListener = types -> {
    NotificationType type1 = null;
    for (NotificationType t : types) {
      if (NotificationType.ERROR == t) {
        type1 = NotificationType.ERROR;
        break;
      }
      if (NotificationType.WARNING == t) {
        type1 = NotificationType.WARNING;
      }
      else if (type1 == null && NotificationType.INFORMATION == t) {
        type1 = NotificationType.INFORMATION;
      }
    }

    actionLinkRef.get().setIcon(IdeNotificationArea.createIconWithNotificationCount(actionLinkRef.get(), type1, types.size()));
    panel.setVisible(true);
  };
  myEventLocation = () -> {
    Point location = SwingUtilities.convertPoint(panel, 0, 0, getRootPane().getLayeredPane());
    return new Point(location.x, location.y + 5);
  };
  return panel;
}
项目:consulo    文件:FlatWelcomePanel.java   
private JComponent createActionLink(String text, Icon icon, Ref<ActionLink> ref, AnAction action) {
  ActionLink link = new ActionLink(text, icon, action);
  ref.set(link);
  // Don't allow focus, as the containing panel is going to focusable.
  link.setFocusable(false);
  link.setPaintUnderline(false);
  link.setNormalColor(WelcomeScreenConstants.getLinkNormalColor());
  JActionLinkPanel panel = new JActionLinkPanel(link);
  panel.setBorder(JBUI.Borders.empty(4, 6, 4, 6));
  panel.add(createArrow(link), BorderLayout.EAST);
  return panel;
}
项目:consulo    文件:FlatWelcomePanel.java   
public static JLabel createArrow(final ActionLink link) {
  JLabel arrow = new JLabel(AllIcons.General.Combo3);
  arrow.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
  arrow.setVerticalAlignment(SwingConstants.BOTTOM);
  new ClickListener() {
    @Override
    public boolean onClick(@Nonnull MouseEvent e, int clickCount) {
      final MouseEvent newEvent = MouseEventAdapter.convert(e, link, e.getX(), e.getY());
      link.doClick(newEvent);
      return true;
    }
  }.installOn(arrow);
  return arrow;
}
项目:intellij-ce-playground    文件:ChangeProjectIconForm.java   
private void createUIComponents() {
  mySetIcon = new ActionLink("Change...", new ChangeProjectIcon(false));
  mySetIconDark = new ActionLink("Change...", new ChangeProjectIcon(true));
  myClear = new ActionLink("Reset", new ResetProjectIcon(false));
  myClearDark = new ActionLink("Reset", new ResetProjectIcon(true));
}
项目:intellij-ce-playground    文件:FlatWelcomeFrame.java   
private JComponent createActionPanel() {
  JPanel actions = new NonOpaquePanel();
  actions.setBorder(JBUI.Borders.emptyLeft(10));
  actions.setLayout(new BoxLayout(actions, BoxLayout.Y_AXIS));
  ActionManager actionManager = ActionManager.getInstance();
  ActionGroup quickStart = (ActionGroup)actionManager.getAction(IdeActions.GROUP_WELCOME_SCREEN_QUICKSTART);
  DefaultActionGroup group = new DefaultActionGroup();
  collectAllActions(group, quickStart);

  for (AnAction action : group.getChildren(null)) {
    JPanel button = new JPanel(new BorderLayout());
    button.setOpaque(false);
    button.setBorder(JBUI.Borders.empty(8, 20));
    AnActionEvent e =
      AnActionEvent.createFromAnAction(action, null, ActionPlaces.WELCOME_SCREEN, DataManager.getInstance().getDataContext(this));
    action.update(e);
    Presentation presentation = e.getPresentation();
    if (presentation.isVisible()) {
      String text = presentation.getText();
      if (text != null && text.endsWith("...")) {
        text = text.substring(0, text.length() - 3);
      }
      Icon icon = presentation.getIcon();
      if (icon.getIconHeight() != JBUI.scale(16) || icon.getIconWidth() != JBUI.scale(16)) {
        icon = JBUI.emptyIcon(16);
      }
      action = wrapGroups(action);
      ActionLink link = new ActionLink(text, icon, action, createUsageTracker(action));
      link.setPaintUnderline(false);
      link.setNormalColor(getLinkNormalColor());
      button.add(link);
      if (action instanceof WelcomePopupAction) {
        button.add(createArrow(link), BorderLayout.EAST);
      }
      installFocusable(button, action, KeyEvent.VK_UP, KeyEvent.VK_DOWN, true);
      actions.add(button);
    }
  }

  WelcomeScreenActionsPanel panel = new WelcomeScreenActionsPanel();
  panel.actions.add(actions);
  return panel.root;
}
项目:consulo    文件:FlatWelcomeScreen.java   
@RequiredDispatchThread
private JComponent createActionPanel(FlatWelcomePanel welcomePanel) {
  JPanel actions = new NonOpaquePanel();
  actions.setBorder(JBUI.Borders.emptyLeft(10));
  actions.setLayout(new BoxLayout(actions, BoxLayout.Y_AXIS));
  ActionManager actionManager = ActionManager.getInstance();
  ActionGroup quickStart = (ActionGroup)actionManager.getAction(IdeActions.GROUP_WELCOME_SCREEN_QUICKSTART);
  List<AnAction> group = new ArrayList<>();
  collectAllActions(group, quickStart);

  for (AnAction action : group) {
    AnActionEvent e = AnActionEvent.createFromAnAction(action, null, ActionPlaces.WELCOME_SCREEN, DataManager.getInstance().getDataContext(welcomePanel));
    action.update(e);

    if (action instanceof WelcomeScreenSlideAction) {
      final WelcomeScreenSlideAction oldAction = (WelcomeScreenSlideAction)action;
      action = new AnAction() {
        @RequiredDispatchThread
        @Override
        public void actionPerformed(@Nonnull AnActionEvent e) {
          JComponent panel = oldAction.createSlide(myWelcomeFrame, myWelcomeFrame::setTitle);
          JBCardLayout layout = (JBCardLayout)FlatWelcomeScreen.this.getLayout();
          String id = oldAction.getClass().getName();

          FlatWelcomeScreen.this.add(panel, id);

          layout.swipe(FlatWelcomeScreen.this, id, JBCardLayout.SwipeDirection.FORWARD);
        }
      };
      action.copyFrom(oldAction);
    }

    Presentation presentation = e.getPresentation();
    if (presentation.isVisible()) {
      String text = presentation.getText();
      if (text != null && text.endsWith("...")) {
        text = text.substring(0, text.length() - 3);
      }
      ActionLink link = new ActionLink(text, presentation.getIcon(), action, createUsageTracker(action));
      // Don't allow focus, as the containing panel is going to focusable.
      link.setFocusable(false);
      link.setPaintUnderline(false);
      link.setNormalColor(WelcomeScreenConstants.getLinkNormalColor());
      FlatWelcomePanel.JActionLinkPanel button = new FlatWelcomePanel.JActionLinkPanel(link);
      button.setBorder(JBUI.Borders.empty(8, 20));
      if (action instanceof WelcomePopupAction) {
        button.add(FlatWelcomePanel.createArrow(link), BorderLayout.EAST);
      }
      welcomePanel.installFocusable(button, action, KeyEvent.VK_UP, KeyEvent.VK_DOWN, true);
      actions.add(button);
    }
  }

  JPanel panel = new JPanel();
  //panel.setBackground(FlatWelcomeFrame.getMainBackground());
  panel.add(actions);
  return panel;
}
项目:consulo    文件:FlatWelcomePanel.java   
public JActionLinkPanel(@Nonnull ActionLink actionLink) {
  super(new BorderLayout());
  myActionLink = actionLink;
  add(myActionLink);
  NonOpaquePanel.setTransparent(this);
}