Java 类com.intellij.openapi.actionSystem.impl.ActionButton 实例源码

项目:intellij-ce-playground    文件:JBMovePanel.java   
@NotNull
private ActionButton createButton(@NotNull final ButtonType type) {
  final AnAction action;
  switch (type) {
    case LEFT:
      action = new LeftAction();
      break;
    case RIGHT:
      action = new RightAction();
      break;
    case ALL_LEFT:
      action = new AllLeftAction();
      break;
    case ALL_RIGHT:
      action = new AllRightAction();
      break;
    default: throw new IllegalArgumentException("Unsupported button type: " + type);
  }


  ActionButton button = createButton(action);
  myButtons.put(type, button);
  return button;
}
项目:intellij-ce-playground    文件:SearchTextArea.java   
public SearchTextArea(boolean search) {
  myTextArea = new JTextArea();
  setBorder(JBUI.Borders.empty(6, 6, 6, 8));
  setLayout(new BorderLayout(JBUI.scale(4), 0));
  myTextArea.addPropertyChangeListener("background", this);
  myTextArea.addFocusListener(this);
  myTextArea.setBorder(null);
  myTextArea.setOpaque(false);
  JBScrollPane scrollPane = new JBScrollPane(myTextArea,
                                             ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
                                             ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
  scrollPane.getVerticalScrollBar().setBackground(UIUtil.TRANSPARENT_COLOR);
  scrollPane.getViewport().setBorder(null);
  scrollPane.getViewport().setOpaque(false);
  scrollPane.setBorder(JBUI.Borders.emptyRight(2));
  scrollPane.setOpaque(false);
  ShowHistoryAction historyAction = new ShowHistoryAction(search);
  ActionButton button =
    new ActionButton(historyAction, historyAction.getTemplatePresentation(), ActionPlaces.UNKNOWN, new Dimension(JBUI.scale(16), JBUI.scale(16)));
  button.setLook(new InplaceActionButtonLook());
  JPanel p = new NonOpaquePanel(new BorderLayout());
  p.add(button, BorderLayout.NORTH);
  add(p, BorderLayout.WEST);
  add(scrollPane, BorderLayout.CENTER);
}
项目:intellij-ce-playground    文件:ExecutionToolWindowFixture.java   
@TestOnly
public boolean stop() {
  for (ActionButton button : getToolbarButtons()) {
    final AnAction action = button.getAction();
    if (action != null && action.getClass().getName().equals("com.intellij.execution.actions.StopAction")) {
      //noinspection ConstantConditions
      boolean enabled = method("isButtonEnabled").withReturnType(boolean.class).in(button).invoke();
      if (enabled) {
        button.click();
        return true;
      }
      return false;
    }
  }
  return false;
}
项目:tools-idea    文件:JBMovePanel.java   
@NotNull
private ActionButton createButton(@NotNull final ButtonType type) {
  final AnAction action;
  switch (type) {
    case LEFT:
      action = new LeftAction();
      break;
    case RIGHT:
      action = new RightAction();
      break;
    case ALL_LEFT:
      action = new AllLeftAction();
      break;
    case ALL_RIGHT:
      action = new AllRightAction();
      break;
    default: throw new IllegalArgumentException("Unsupported button type: " + type);
  }


  ActionButton button = createButton(action);
  myButtons.put(type, button);
  return button;
}
项目:consulo    文件:ActionButtonUI.java   
private int getMnemonicCharIndex(ActionButton button, AnAction action, String text) {
  final int mnemonicIndex = button.getPresentation().getDisplayedMnemonicIndex();
  if (mnemonicIndex != -1) {
    return mnemonicIndex;
  }
  final ShortcutSet shortcutSet = action.getShortcutSet();
  final Shortcut[] shortcuts = shortcutSet.getShortcuts();
  for (int i = 0; i < shortcuts.length; i++) {
    Shortcut shortcut = shortcuts[i];
    if (shortcut instanceof KeyboardShortcut) {
      KeyboardShortcut keyboardShortcut = (KeyboardShortcut)shortcut;
      if (keyboardShortcut.getSecondKeyStroke() == null) { // we are interested only in "mnemonic-like" shortcuts
        final KeyStroke keyStroke = keyboardShortcut.getFirstKeyStroke();
        final int modifiers = keyStroke.getModifiers();
        if ((modifiers & KeyEvent.ALT_MASK) != 0) {
          return (keyStroke.getKeyChar() != KeyEvent.CHAR_UNDEFINED)
                 ? text.indexOf(keyStroke.getKeyChar())
                 : text.indexOf(KeyEvent.getKeyText(keyStroke.getKeyCode()));
        }
      }
    }
  }
  return -1;
}
项目:consulo    文件:ActionButtonUI.java   
private void paintDefaultButton(Graphics g, ActionButton c) {
  AnAction action = c.getAction();

  int state = c.getPopState();

  if (state != ActionButtonComponent.NORMAL) {
    paintBackground(c, g, c.getSize(), state);
    paintBorder(c, g, c.getSize(), state);
  }

  paintIcon(g, c, c.getIcon());

  if (action instanceof ActionGroup && ((ActionGroup)action).isPopup()) {

    int x = JBUI.scale(5);
    int y = JBUI.scale(4);

    if (state == ActionButtonComponent.PUSHED) {
      x += JBUI.scale(1);
      y += JBUI.scale(1);
    }

    AllIcons.General.Dropdown.paintIcon(c, g, x, y);
  }
}
项目:consulo    文件:ActionButtonUI.java   
protected void paintBorder(ActionButton button, Graphics g, Dimension size, int state) {
  if (UIUtil.isUnderAquaLookAndFeel()) {
    if (state == ActionButtonComponent.POPPED) {
      g.setColor(ALPHA_30);
      g.drawRoundRect(0, 0, size.width - 2, size.height - 2, 4, 4);
    }
  }
  else {
    final double shift = UIUtil.isUnderDarcula() ? 1 / 0.49 : 0.49;
    g.setColor(ColorUtil.shift(UIUtil.getPanelBackground(), shift));
    ((Graphics2D)g).setStroke(BASIC_STROKE);
    final GraphicsConfig config = GraphicsUtil.setupAAPainting(g);
    g.drawRoundRect(0, 0, size.width - JBUI.scale(2), size.height - JBUI.scale(2), JBUI.scale(4), JBUI.scale(4));
    config.restore();
  }
}
项目:consulo    文件:ActionButtonUI.java   
protected void paintBackground(ActionButton button, Graphics g, Dimension size, int state) {
  if (UIUtil.isUnderAquaLookAndFeel()) {
    if (state == ActionButtonComponent.PUSHED) {
      ((Graphics2D)g).setPaint(UIUtil.getGradientPaint(0, 0, ALPHA_40, size.width, size.height, ALPHA_20));
      g.fillRect(0, 0, size.width - 1, size.height - 1);

      g.setColor(ALPHA_120);
      g.drawLine(0, 0, 0, size.height - 2);
      g.drawLine(1, 0, size.width - 2, 0);

      g.setColor(ALPHA_30);
      g.drawRect(1, 1, size.width - 3, size.height - 3);
    }
    else if (state == ActionButtonComponent.POPPED) {
      ((Graphics2D)g).setPaint(UIUtil.getGradientPaint(0, 0, Gray._235, 0, size.height, Gray._200));
      g.fillRect(1, 1, size.width - 3, size.height - 3);
    }
  }
  else {
    final Color bg = UIUtil.getPanelBackground();
    final boolean dark = UIUtil.isUnderDarcula();
    g.setColor(state == ActionButtonComponent.PUSHED ? ColorUtil.shift(bg, dark ? 1d / 0.7d : 0.7d) : dark ? Gray._255.withAlpha(40) : ALPHA_40);
    g.fillRect(JBUI.scale(1), JBUI.scale(1), size.width - JBUI.scale(2), size.height - JBUI.scale(2));
  }
}
项目:consulo    文件:ContextMenuImpl.java   
private ActionToolbar createToolbar(final ActionGroup group) {
  final ActionToolbarImpl actionToolbar =
          new ActionToolbarImpl(ActionPlaces.CONTEXT_TOOLBAR, group, true, DataManager.getInstance(), ActionManagerEx.getInstanceEx(),
                                KeymapManagerEx.getInstanceEx()) {

            @Override
            protected ActionButton createToolbarButton(final AnAction action,
                                                       boolean minimalMode,
                                                       boolean decorateButtons,
                                                       final String place,
                                                       final Presentation presentation,
                                                       final Dimension minimumSize) {
              final ActionButton result = new ActionButton(action, presentation, place, minimumSize);
              result.setMinimalMode(minimalMode);
              result.setDecorateButtons(decorateButtons);
              return result;
            }
          };

  actionToolbar.setTargetComponent(myEditor.getContentComponent());
  return actionToolbar;
}
项目:consulo    文件:JBMovePanel.java   
@Nonnull
private ActionButton createButton(@Nonnull final ButtonType type) {
  final AnAction action;
  switch (type) {
    case LEFT:
      action = new LeftAction();
      break;
    case RIGHT:
      action = new RightAction();
      break;
    case ALL_LEFT:
      action = new AllLeftAction();
      break;
    case ALL_RIGHT:
      action = new AllRightAction();
      break;
    default: throw new IllegalArgumentException("Unsupported button type: " + type);
  }


  ActionButton button = createButton(action);
  myButtons.put(type, button);
  return button;
}
项目:IntelliJ-Key-Promoter-X    文件:KeyPromoterAction.java   
/**
 * Constructor used when have to fall back to inspect an AWT event instead of actions that are directly provided
 * by IDEA. Tool-window stripe buttons are such a case where I'm not notified by IDEA if one is pressed
 *
 * @param event mouse event that happened
 */
KeyPromoterAction(AWTEvent event) {
    final Object source = event.getSource();
    if (source instanceof ActionButton) {
        analyzeActionButton((ActionButton) source);
    } else if (source instanceof StripeButton) {
        analyzeStripeButton((StripeButton) source);
    } else if (source instanceof ActionMenuItem) {
        analyzeActionMenuItem((ActionMenuItem) source);
    } else if (source instanceof JButton) {
        analyzeJButton((JButton) source);
    }

}
项目:IntelliJ-Key-Promoter-X    文件:KeyPromoterAction.java   
/**
 * Information extraction for buttons on the toolbar
 *
 * @param source source of the action
 */
private void analyzeActionButton(ActionButton source) {
    final AnAction action = source.getAction();
    if (action != null) {
        fixValuesFromAction(action);
    }
    mySource = ActionSource.MAIN_TOOLBAR;
}
项目:force-shortcuts-intellij-plugin    文件:ShortcutActionFactory.java   
public static Optional<ShortcutAction> buildShortcutIfAvailable(Component eventSource) {
    ShortcutAction shortcut = null;

    if (isActionButton(eventSource)) {
        shortcut = buildShortcut((ActionButton) eventSource);
    } else if (isActionMenuItem(eventSource)) {
        shortcut = buildShortcut((ActionMenuItem) eventSource);
    }

    if (shortcut != null && StringUtil.isEmptyOrSpaces(shortcut.getShortcutText())) {
        return Optional.empty();
    }

    return Optional.ofNullable(shortcut);
}
项目:force-shortcuts-intellij-plugin    文件:ShortcutActionFactory.java   
public static ShortcutAction buildShortcut(ActionButton actionButton) {
    AnAction anAction = actionButton.getAction();
    if (anAction == null) {
        return null;
    }

    String shortcutText = KeymapUtil.getFirstKeyboardShortcutText(anAction);
    String description = anAction.getTemplatePresentation().getText();

    return new ShortcutAction(shortcutText, description);
}
项目:intellij-ce-playground    文件:JBMovePanel.java   
public void setShowButtons(@NotNull ButtonType... types) {
  for (ActionButton button : myButtons.values()) {
    button.setVisible(false);
  }
  for (ButtonType type : types) {
    myButtons.get(type).setVisible(true);
  }
}
项目:intellij-ce-playground    文件:JBMovePanel.java   
@Override
public void setEnabled(boolean enabled) {
  super.setEnabled(enabled);
  myLeftList.setEnabled(enabled);
  myRightList.setEnabled(enabled);
  for (ActionButton button : myButtons.values()) {
    button.setEnabled(enabled);
  }
}
项目:intellij-ce-playground    文件:JBMovePanel.java   
@NotNull
private static ActionButton createButton(@NotNull final AnAction action) {
  PresentationFactory presentationFactory = new PresentationFactory();
  Icon icon = AllIcons.Actions.AllLeft;
  Dimension size = new Dimension(icon.getIconWidth(), icon.getIconHeight());
  return new ActionButton(action, presentationFactory.getPresentation(action), MOVE_PANEL_PLACE, size);
}
项目:intellij-ce-playground    文件:ReloadableComboBoxPanel.java   
@NotNull
private JPanel createReloadButtonPanel() {
  ReloadAction reloadAction = new ReloadAction();
  ActionButton reloadButton = new ActionButton(
    reloadAction,
    reloadAction.getTemplatePresentation().clone(),
    CONTROL_PLACE,
    ActionToolbar.DEFAULT_MINIMUM_BUTTON_SIZE
  );
  JPanel panel = new JPanel(new BorderLayout(0, 0));
  panel.add(reloadButton, BorderLayout.WEST);
  return panel;
}
项目:intellij-ce-playground    文件:CtrlMouseHandler.java   
QuickDocInfoPane(@NotNull PsiElement documentationAnchor,
                 @NotNull PsiElement elementUnderMouse,
                 @NotNull JComponent baseDocControl) {
  myBaseDocControl = baseDocControl;

  PresentationFactory presentationFactory = new PresentationFactory();
  for (AbstractDocumentationTooltipAction action : ourTooltipActions) {
    Icon icon = action.getTemplatePresentation().getIcon();
    Dimension minSize = new Dimension(icon.getIconWidth(), icon.getIconHeight());
    myButtons.add(new ActionButton(action, presentationFactory.getPresentation(action), IdeTooltipManager.IDE_TOOLTIP_PLACE, minSize));
    action.setDocInfo(documentationAnchor, elementUnderMouse);
  }
  Collections.reverse(myButtons);

  setPreferredSize(baseDocControl.getPreferredSize());
  setMaximumSize(baseDocControl.getMaximumSize());
  setMinimumSize(baseDocControl.getMinimumSize());
  setBackground(baseDocControl.getBackground());

  add(baseDocControl, Integer.valueOf(0));
  int minWidth = 0;
  int minHeight = 0;
  int buttonWidth = 0;
  for (JComponent button : myButtons) {
    button.setBorder(null);
    button.setBackground(baseDocControl.getBackground());
    add(button, Integer.valueOf(1));
    button.setVisible(false);
    Dimension preferredSize = button.getPreferredSize();
    minWidth += preferredSize.width;
    minHeight = Math.max(minHeight, preferredSize.height);
    buttonWidth = Math.max(buttonWidth, preferredSize.width);
  }
  myButtonWidth = buttonWidth;

  int margin = 2;
  myMinWidth = minWidth + margin * 2 + (myButtons.size() - 1) * BUTTON_HGAP;
  myMinHeight = minHeight + margin * 2;
}
项目:intellij-ce-playground    文件:ShowMoreOptions.java   
@Override
public void actionPerformed(AnActionEvent e) {
  final ActionButton secondaryActions = myToolbarComponent.getSecondaryActionsButton();
  if (secondaryActions != null) {
    secondaryActions.click();
  }
}
项目:intellij-ce-playground    文件:SetTodoFilterAction.java   
@Override
public JComponent createCustomComponent(Presentation presentation) {
  ActionButton button = new ActionButton(
    this,
    presentation,
    ActionPlaces.TODO_VIEW_TOOLBAR,
    ActionToolbar.DEFAULT_MINIMUM_BUTTON_SIZE
  );
  presentation.putClientProperty("button", button);
  return button;
}
项目:intellij-ce-playground    文件:ExtendedDeviceChooserDialog.java   
private void createUIComponents() {
  myCloudProjectIdLabel = new CloudProjectIdLabel(MATRIX);

  AnAction action = new AnAction() {
    @Override
    public void actionPerformed(AnActionEvent e) {
      if (myCloudConfigurationProvider == null) {
        return;
      }

      String selectedProjectId =
        myCloudConfigurationProvider.openCloudProjectConfigurationDialog(myProject, myCloudProjectIdLabel.getText());

      if (selectedProjectId != null) {
        myCloudProjectIdLabel.updateCloudProjectId(selectedProjectId);
        updateOkButton();
      }
    }

    @Override
    public void update(AnActionEvent event) {
      Presentation presentation = event.getPresentation();
      presentation.setIcon(AllIcons.General.Settings);
    }
  };

  myCloudProjectIdUpdateButton =
    new ActionButton(action, new PresentationFactory().getPresentation(action), "MyPlace", new Dimension(25, 25));

  myCloudConfigurationCombo = new CloudConfigurationComboBox(MATRIX);
  Disposer.register(myDisposable, myCloudConfigurationCombo);
}
项目:intellij-ce-playground    文件:AndroidRunConfigurationEditor.java   
private void createUIComponents() {
  myAvdCombo = new AvdComboBox(myProject, true, false) {
    @Override
    public Module getModule() {
      return getModuleSelector().getModule();
    }
  };
  myAvdCombo.getComboBox().setRenderer(new ListCellRendererWrapper() {
    @Override
    public void customize(JList list, Object value, int index, boolean selected, boolean hasFocus) {
      if (value instanceof IdDisplay) {
        setText(((IdDisplay)value).getDisplay());
      }
      else {
        setText(String.format("<html><font color='red'>Unknown AVD %1$s</font></html>", value == null ? "" : value.toString()));
      }
    }
  });

  myAvdComboComponent = new ComboboxWithBrowseButton(myAvdCombo.getComboBox());

  myCloudMatrixProjectIdLabel = new CloudProjectIdLabel(MATRIX);
  myCloudMatrixConfigurationCombo = new CloudConfigurationComboBox(MATRIX);
  AnAction cloudMatrixProjectAction = new SelectCloudProjectAction(myCloudMatrixProjectIdLabel, myCloudMatrixConfigurationCombo);
  myCloudMatrixProjectIdUpdateButton = new ActionButton(
    cloudMatrixProjectAction, new PresentationFactory().getPresentation(cloudMatrixProjectAction), "MyPlace", new Dimension(25, 25));
  Disposer.register(this, myCloudMatrixConfigurationCombo);

  myCloudDeviceProjectIdLabel = new CloudProjectIdLabel(SINGLE_DEVICE);
  myCloudDeviceConfigurationCombo = new CloudConfigurationComboBox(SINGLE_DEVICE);
  AnAction cloudDeviceProjectAction = new SelectCloudProjectAction(myCloudDeviceProjectIdLabel, myCloudDeviceConfigurationCombo);
  myCloudDeviceProjectIdUpdateButton = new ActionButton(
    cloudDeviceProjectAction, new PresentationFactory().getPresentation(cloudDeviceProjectAction), "MyPlace", new Dimension(25, 25));
  Disposer.register(this, myCloudDeviceConfigurationCombo);
}
项目:intellij-ce-playground    文件:LaunchCloudDeviceDialog.java   
private void createUIComponents() {
  myCloudProjectIdLabel = new CloudProjectIdLabel(SINGLE_DEVICE);

  AnAction action = new AnAction() {
    @Override
    public void actionPerformed(AnActionEvent e) {
      if (myCloudConfigurationProvider == null) {
        return;
      }

      String selectedProjectId =
        myCloudConfigurationProvider.openCloudProjectConfigurationDialog(myProject, myCloudProjectIdLabel.getText());

      if (selectedProjectId != null) {
        myCloudProjectIdLabel.updateCloudProjectId(selectedProjectId);
        updateOkButton();
      }
    }

    @Override
    public void update(AnActionEvent event) {
      Presentation presentation = event.getPresentation();
      presentation.setIcon(AllIcons.General.Settings);
    }
  };

  myCloudProjectIdUpdateButton =
    new ActionButton(action, new PresentationFactory().getPresentation(action), "MyPlace", new Dimension(25, 25));

  myCloudConfigurationCombo = new CloudConfigurationComboBox(SINGLE_DEVICE);
  Disposer.register(myDisposable, myCloudConfigurationCombo);
}
项目:intellij-ce-playground    文件:ExecutionToolWindowFixture.java   
public boolean isExecutionInProgress() {
  // Consider that execution is in progress if 'stop' toolbar button is enabled.
  for (ActionButton button : getToolbarButtons()) {
    if ("com.intellij.execution.actions.StopAction".equals(button.getAction().getClass().getCanonicalName())) {
      //noinspection ConstantConditions
      return method("isButtonEnabled").withReturnType(boolean.class).in(button).invoke();
    }
  }
  return true;
}
项目:intellij-ce-playground    文件:ExecutionToolWindowFixture.java   
public void rerun() {
  for (ActionButton button : getToolbarButtons()) {
    if ("com.intellij.execution.runners.FakeRerunAction".equals(button.getAction().getClass().getCanonicalName())) {
      myRobot.click(button);
      return;
    }
  }

  throw new IllegalStateException("Could not find the Re-run button.");
}
项目:intellij-ce-playground    文件:LibraryPropertiesDialogFixture.java   
@NotNull
public LibraryPropertiesDialogFixture addAttachment(@NotNull File path) {
  final ActionButton addButton = robot().finder().find(target(), new GenericTypeMatcher<ActionButton>(ActionButton.class) {
    @Override
    protected boolean isMatching(@NotNull ActionButton button) {
      String toolTipText = button.getToolTipText();
      return button.isShowing() && isNotEmpty(toolTipText) && toolTipText.startsWith("Add");
    }
  });
  robot().moveMouse(addButton);
  //noinspection SSBasedInspection
  SwingUtilities.invokeLater(new Runnable() {
    @Override
    public void run() {
      addButton.click();
    }
  });

  VirtualFile attachment = findFileByIoFile(path, true);
  FileChooserDialogFixture fileChooser = FileChooserDialogFixture.findDialog(robot(), new GenericTypeMatcher<JDialog>(JDialog.class) {
    @Override
    protected boolean isMatching(@NotNull JDialog dialog) {
      String title = dialog.getTitle();
      return dialog.isShowing() && isNotEmpty(title) && title.startsWith("Attach Files or Directories to Library");
    }
  });
  assertNotNull("Failed to find VirtualFile with path " + quote(path.getPath()), attachment);
  fileChooser.select(attachment)
             .clickOk();
  return this;
}
项目:intellij-ce-playground    文件:TableTabAction.java   
public TableTabAction(PropertyTablePanel panel, PropertyTableTab tab) {
  myPanel = panel;
  myTab = tab;

  Presentation presentation = getTemplatePresentation();
  String text = tab.getDescription();
  presentation.setText(text);
  presentation.setDescription(text);
  presentation.setIcon(tab.getIcon());

  myButton = new ActionButton(this, presentation, ActionPlaces.UNKNOWN, ActionToolbar.DEFAULT_MINIMUM_BUTTON_SIZE);

  updateState();
}
项目:intellij-ce-playground    文件:PropertyTablePanel.java   
public void setCurrentTab(@NotNull PropertyTableTab currentTab) {
  myCurrentTab = currentTab;

  for (Component component : myTabPanel.getComponents()) {
    ActionButton button = (ActionButton)component;
    TableTabAction action = (TableTabAction)button.getAction();
    action.updateState();
  }

  myPropertyTable.update();
}
项目:tools-idea    文件:JBMovePanel.java   
public void setShowButtons(@NotNull ButtonType... types) {
  for (ActionButton button : myButtons.values()) {
    button.setVisible(false);
  }
  for (ButtonType type : types) {
    myButtons.get(type).setVisible(true);
  }
}
项目:tools-idea    文件:JBMovePanel.java   
@Override
public void setEnabled(boolean enabled) {
  super.setEnabled(enabled);
  myLeftList.setEnabled(enabled);
  myRightList.setEnabled(enabled);
  for (ActionButton button : myButtons.values()) {
    button.setEnabled(enabled);
  }
}
项目:tools-idea    文件:JBMovePanel.java   
@NotNull
private static ActionButton createButton(@NotNull final AnAction action) {
  PresentationFactory presentationFactory = new PresentationFactory();
  Icon icon = AllIcons.Actions.AllLeft;
  Dimension size = new Dimension(icon.getIconWidth(), icon.getIconHeight());
  return new ActionButton(action, presentationFactory.getPresentation(action), MOVE_PANEL_PLACE, size);
}
项目:tools-idea    文件:CtrlMouseHandler.java   
QuickDocInfoPane(@NotNull PsiElement documentationAnchor,
                 @NotNull PsiElement elementUnderMouse,
                 @NotNull JComponent baseDocControl) {
  myBaseDocControl = baseDocControl;

  PresentationFactory presentationFactory = new PresentationFactory();
  for (AbstractDocumentationTooltipAction action : ourTooltipActions) {
    Icon icon = action.getTemplatePresentation().getIcon();
    Dimension minSize = new Dimension(icon.getIconWidth(), icon.getIconHeight());
    myButtons.add(new ActionButton(action, presentationFactory.getPresentation(action), IdeTooltipManager.IDE_TOOLTIP_PLACE, minSize));
    action.setDocInfo(documentationAnchor, elementUnderMouse);
  }
  Collections.reverse(myButtons);

  setPreferredSize(baseDocControl.getPreferredSize());
  setMaximumSize(baseDocControl.getMaximumSize());
  setMinimumSize(baseDocControl.getMinimumSize());
  setBackground(baseDocControl.getBackground());

  add(baseDocControl, Integer.valueOf(0));
  int minWidth = 0;
  int minHeight = 0;
  int buttonWidth = 0;
  for (JComponent button : myButtons) {
    button.setBorder(null);
    button.setBackground(baseDocControl.getBackground());
    add(button, Integer.valueOf(1));
    button.setVisible(false);
    Dimension preferredSize = button.getPreferredSize();
    minWidth += preferredSize.width;
    minHeight = Math.max(minHeight, preferredSize.height);
    buttonWidth = Math.max(buttonWidth, preferredSize.width);
  }
  myButtonWidth = buttonWidth;

  int margin = 2;
  myMinWidth = minWidth + margin * 2 + (myButtons.size() - 1) * BUTTON_HGAP;
  myMinHeight = minHeight + margin * 2;
}
项目:tools-idea    文件:GithubProjectGeneratorPeer.java   
@NotNull
private JPanel createReloadButtonPanel() {
  ReloadAction reloadAction = new ReloadAction();
  ActionButton reloadButton = new ActionButton(
    reloadAction,
    reloadAction.getTemplatePresentation().clone(),
    CONTROL_PLACE,
    ActionToolbar.DEFAULT_MINIMUM_BUTTON_SIZE
  );
  JPanel panel = new JPanel(new BorderLayout(0, 0));
  panel.add(reloadButton, BorderLayout.WEST);
  return panel;
}
项目:tools-idea    文件:ShowMoreOptions.java   
@Override
public void actionPerformed(AnActionEvent e) {
  final ActionButton secondaryActions = ((ActionToolbarImpl)myToolbarComponent).getSecondaryActionsButton();
  if (secondaryActions != null) {
    secondaryActions.click();
  }
}
项目:tools-idea    文件:SetTodoFilterAction.java   
@Override
public JComponent createCustomComponent(Presentation presentation) {
  ActionButton button = new ActionButton(
    this,
    presentation,
    ActionPlaces.TODO_VIEW_TOOLBAR,
    ActionToolbar.DEFAULT_MINIMUM_BUTTON_SIZE
  );
  presentation.putClientProperty("button", button);
  return button;
}
项目:tools-idea    文件:GitManualPushToBranch.java   
GitManualPushToBranch(@NotNull Collection<GitRepository> repositories,
                      @NotNull final Runnable performOnRefresh) {
  super();
  myRepositories = repositories;

  myManualPush = new JCheckBox("Push current branch to alternative branch: ", false);
  myManualPush.setMnemonic('b');

  myDestBranchTextField = new JTextField(20);

  myComment = new JBLabel("This will apply to all selected repositories", UIUtil.ComponentStyle.SMALL);

  myRefreshAction = new GitPushLogRefreshAction() {
    @Override public void actionPerformed(AnActionEvent e) {
      performOnRefresh.run();
    }
  };
  myRefreshButton = new ActionButton(myRefreshAction,  myRefreshAction.getTemplatePresentation(), myRefreshAction.getTemplatePresentation().getText(), ActionToolbar.DEFAULT_MINIMUM_BUTTON_SIZE);
  myRefreshButton.setFocusable(true);
  final ShortcutSet shortcutSet = ActionManager.getInstance().getAction(IdeActions.ACTION_REFRESH).getShortcutSet();
  myRefreshAction.registerCustomShortcutSet(shortcutSet, myRefreshButton);

  myRemoteSelector = new RemoteSelector(getRemotesWithCommonNames(repositories));
  myRemoteSelectorComponent = myRemoteSelector.createComponent();

  setDefaultComponentsEnabledState(myManualPush.isSelected());
  myManualPush.addActionListener(new ActionListener() {
    @Override
    public void actionPerformed(ActionEvent e) {
      boolean isManualPushSelected = myManualPush.isSelected();
      setDefaultComponentsEnabledState(isManualPushSelected);
      if (isManualPushSelected) {
        myDestBranchTextField.requestFocus();
        myDestBranchTextField.selectAll();
      }
    }
  });

  layoutComponents();
}
项目:tools-idea    文件:TableTabAction.java   
public TableTabAction(PropertyTablePanel panel, PropertyTableTab tab) {
  myPanel = panel;
  myTab = tab;

  Presentation presentation = getTemplatePresentation();
  String text = tab.getDescription();
  presentation.setText(text);
  presentation.setDescription(text);
  presentation.setIcon(tab.getIcon());

  myButton = new ActionButton(this, presentation, ActionPlaces.UNKNOWN, ActionToolbar.DEFAULT_MINIMUM_BUTTON_SIZE);

  updateState();
}
项目:tools-idea    文件:PropertyTablePanel.java   
public void setCurrentTab(@NotNull PropertyTableTab currentTab) {
  myCurrentTab = currentTab;

  for (Component component : myTabPanel.getComponents()) {
    ActionButton button = (ActionButton)component;
    TableTabAction action = (TableTabAction)button.getAction();
    action.updateState();
  }

  myPropertyTable.update();
}
项目:cordovastudio    文件:TableTabAction.java   
public TableTabAction(PropertyTablePanel panel, PropertyTableTab tab) {
  myPanel = panel;
  myTab = tab;

  Presentation presentation = getTemplatePresentation();
  String text = tab.getDescription();
  presentation.setText(text);
  presentation.setDescription(text);
  presentation.setIcon(tab.getIcon());

  myButton = new ActionButton(this, presentation, ActionPlaces.UNKNOWN, ActionToolbar.DEFAULT_MINIMUM_BUTTON_SIZE);

  updateState();
}