javax.swing.text.html.ImageView#com.intellij.openapi.actionSystem.impl.ActionButton源码实例Demo

下面列出了javax.swing.text.html.ImageView#com.intellij.openapi.actionSystem.impl.ActionButton 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: consulo   文件: SearchTextArea.java
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;
}
 
源代码2 项目: consulo   文件: RunAnythingAction.java
@Nonnull
@Override
public JComponent createCustomComponent(@Nonnull Presentation presentation, @Nonnull String place) {
  return new ActionButton(this, presentation, place, ActionToolbar.DEFAULT_MINIMUM_BUTTON_SIZE) {

    @Nullable
    @Override
    protected String getShortcutText() {
      if (myIsDoubleCtrlRegistered) {
        return IdeBundle.message("run.anything.double.ctrl.shortcut", SystemInfo.isMac ? FontUtil.thinSpace() + MacKeymapUtil.CONTROL : "Ctrl");
      }
      //keymap shortcut is added automatically
      return null;
    }

    @Override
    public void setToolTipText(String s) {
      String shortcutText = getShortcutText();
      super.setToolTipText(StringUtil.isNotEmpty(shortcutText) ? (s + " (" + shortcutText + ")") : s);
    }
  };
}
 
源代码3 项目: consulo   文件: SearchEverywhereAction.java
@Nonnull
@Override
public JComponent createCustomComponent(Presentation presentation, String place) {
  return new ActionButton(this, presentation, place, ActionToolbar.DEFAULT_MINIMUM_BUTTON_SIZE) {
    @Override
    protected void updateToolTipText() {
      String shortcutText = getShortcut();

      if (Registry.is("ide.helptooltip.enabled")) {
        HelpTooltip.dispose(this);

        new HelpTooltip().setTitle(myPresentation.getText()).setShortcut(shortcutText).setDescription("Searches for:<br/> - Classes<br/> - Files<br/> - Tool Windows<br/> - Actions<br/> - Settings")
                .installOn(this);
      }
      else {
        setToolTipText("<html><body>Search Everywhere<br/>Press <b>" + shortcutText + "</b> to access<br/> - Classes<br/> - Files<br/> - Tool Windows<br/> - Actions<br/> - Settings</body></html>");
      }
    }
  };
}
 
源代码4 项目: consulo   文件: DarculaActionButtonUI.java
@Override
public void paintBackground(ActionButton button, Graphics g, Dimension size, int state) {
  if (state == ActionButtonComponent.NORMAL && !button.isBackgroundSet()) return;

  Rectangle rect = new Rectangle(button.getSize());
  JBInsets.removeFrom(rect, button.getInsets());

  Color color = state == ActionButtonComponent.PUSHED ? JBUI.CurrentTheme.ActionButton.pressedBackground() : JBUI.CurrentTheme.ActionButton.hoverBackground();
  Graphics2D g2 = (Graphics2D)g.create();

  try {
    g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    g2.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_NORMALIZE);
    g2.setColor(color);

    float arc = DarculaUIUtil.BUTTON_ARC.getFloat();
    g2.fill(new RoundRectangle2D.Float(rect.x, rect.y, rect.width, rect.height, arc, arc));
  }
  finally {
    g2.dispose();
  }
}
 
源代码5 项目: 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;
}
 
源代码6 项目: consulo   文件: ActionButtonUI.java
private void paintDefaultButton(Graphics g, ActionButton c) {
  int state = c.getPopState();

  paintBackground(c, g, c.getSize(), state);
  if(!c.isWithoutBorder()) {
    paintBorder(c, g, c.getSize(), state);
  }
  paintIcon(g, c, c.getIcon());

  if (c.shallPaintDownArrow()) {
    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);
  }
}
 
源代码7 项目: consulo   文件: ActionButtonUI.java
public void paintBorder(ActionButton button, Graphics g, Dimension size, int state) {
  if (state == ActionButtonComponent.NORMAL && !button.isBackgroundSet()) return;

  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();
  }
}
 
/**
 * 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);
  }

}
 
/**
 * 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;
}
 
源代码10 项目: flutter-intellij   文件: IdeaFrameFixture.java
/**
 * Finds the button while refreshing over the toolbar.
 * <p>
 * Due to IJ refresh policy (will only refresh if it detects mouse movement over its window),
 * the toolbar needs to be intermittently updated before the ActionButton moves to the target
 * location and update to its final state.
 */
@NotNull
private ActionButtonFixture findActionButtonWithRefresh(@NotNull String actionId, boolean enabled) {
  Ref<ActionButtonFixture> fixtureRef = new Ref<>();
  Wait.seconds(30)
    .expecting("button to enable")
    .until(() -> {
      updateToolbars();
      // Actions can somehow get replaced, so we need to re-get the action when we attempt to check its state.
      ActionButtonFixture fixture = locateActionButtonByActionId(actionId);
      fixtureRef.set(fixture);
      if (hasValidWindowAncestor(fixture.target())) {
        return execute(new GuiQuery<Boolean>() {
          @Nullable
          @Override
          protected Boolean executeInEDT() {
            if (WindowAncestorFinder.windowAncestorOf(fixture.target()) != null) {
              ActionButton button = fixture.target();
              AnAction action = button.getAction();
              Presentation presentation = action.getTemplatePresentation();
              return presentation.isEnabledAndVisible() &&
                     button.isEnabled() == enabled &&
                     button.isShowing() &&
                     button.isVisible();
            }
            return false;
          }
        });
      }

      return false;
    });
  return fixtureRef.get();
}
 
源代码11 项目: flutter-intellij   文件: IdeaFrameFixture.java
@NotNull
public IdeSettingsDialogFixture invokeSdkManager() {
  ActionButton sdkButton = waitUntilShowingAndEnabled(robot(), target(), new GenericTypeMatcher<ActionButton>(ActionButton.class) {
    @Override
    protected boolean isMatching(@NotNull ActionButton actionButton) {
      return "SDK Manager".equals(actionButton.getAccessibleContext().getAccessibleName());
    }
  });
  robot().click(sdkButton);
  return IdeSettingsDialogFixture.find(robot());
}
 
源代码12 项目: consulo   文件: DesktopEditorAnalyzeStatusPanel.java
@Override
public void addLayoutComponent(String s, Component component) {
  JComponent jc = (JComponent)component;
  if (ActionToolbar.CUSTOM_COMPONENT_CONSTRAINT.equals(s) && jc instanceof StatusButton) {
    statusComponent = jc;
  }
  else if (ActionToolbar.ACTION_BUTTON_CONSTRAINT.equals(s) && jc instanceof ActionButton) {
    actionButtons.add(jc);
  }
}
 
源代码13 项目: consulo   文件: DesktopEditorAnalyzeStatusPanel.java
@Override
public void removeLayoutComponent(Component component) {
  JComponent jc = (JComponent)component;
  if (jc instanceof StatusButton) {
    statusComponent = null;
  }
  else if (jc instanceof ActionButton) {
    actionButtons.remove(jc);
  }
}
 
源代码14 项目: consulo   文件: DaemonTooltipWithActionRenderer.java
private JComponent createSettingsComponent(HintHint hintHint, TooltipReloader reloader, boolean hasMore, boolean newLayout) {
  Presentation presentation = new Presentation();
  presentation.setIcon(AllIcons.Actions.More);
  presentation.putClientProperty(ActionButton.HIDE_DROPDOWN_ICON, true);

  List<AnAction> actions = new ArrayList<>();
  actions.add(new ShowActionsAction(reloader, tooltipAction != null));
  ShowDocAction docAction = new ShowDocAction(reloader, hasMore);
  actions.add(docAction);
  AnAction actionGroup = new SettingsActionGroup(actions);
  int buttonSize = newLayout ? 20 : 18;

  ActionButton settingsButton = new ActionButton(actionGroup, presentation, ActionPlaces.UNKNOWN, new Dimension(buttonSize, buttonSize));

  settingsButton.setNoIconsInPopup(true);
  settingsButton.setBorder(JBUI.Borders.empty());
  settingsButton.setOpaque(false);

  JPanel wrapper = new JPanel(new BorderLayout());

  wrapper.add(settingsButton, BorderLayout.EAST);

  wrapper.setBorder(JBUI.Borders.empty());

  wrapper.setBackground(hintHint.getTextBackground());

  wrapper.setOpaque(false);

  return wrapper;
}
 
源代码15 项目: consulo   文件: ArrangementListRowDecorator.java
public ArrangementListRowDecorator(@Nonnull ArrangementUiComponent delegate,
                                   @Nonnull ArrangementMatchingRulesControl control)
{
  myDelegate = delegate;
  myControl = control;

  mySortLabel.setVisible(false);

  AnAction action = ActionManager.getInstance().getAction("Arrangement.Rule.Edit");
  Presentation presentation = action.getTemplatePresentation().clone();
  Icon editIcon = presentation.getIcon();
  Dimension buttonSize = new Dimension(editIcon.getIconWidth(), editIcon.getIconHeight());
  myEditButton = new ActionButton(action, presentation, ArrangementConstants.MATCHING_RULES_CONTROL_PLACE, buttonSize);
  myEditButton.setVisible(false);

  FontMetrics metrics = getFontMetrics(getFont());
  int maxWidth = 0;
  for (int i = 0; i <= 99; i++) {
    maxWidth = Math.max(metrics.stringWidth(String.valueOf(i)), maxWidth);
  }
  int height = metrics.getHeight() - metrics.getDescent() - metrics.getLeading();
  int diameter = Math.max(maxWidth, height) * 5 / 3;
  myRowIndexControl = new ArrangementRuleIndexControl(diameter, height);

  setOpaque(true);
  init();
}
 
源代码16 项目: consulo   文件: ShowMoreOptions.java
@Override
public void actionPerformed(@Nonnull AnActionEvent e) {
  final ActionButton secondaryActions = myToolbarComponent.getSecondaryActionsButton();
  if (secondaryActions != null) {
    secondaryActions.click();
  }
}
 
源代码17 项目: consulo   文件: 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;
}
 
源代码18 项目: consulo   文件: DarculaActionButtonUI.java
@Override
public void paintBorder(ActionButton button, Graphics g, Dimension size, int state) {
  if (state == ActionButtonComponent.NORMAL && !button.isBackgroundSet()) return;

  Rectangle rect = new Rectangle(button.getSize());
  JBInsets.removeFrom(rect, button.getInsets());

  Graphics2D g2 = (Graphics2D)g.create();
  g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
  g2.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_NORMALIZE);

  try {
    Color color = state == ActionButtonComponent.PUSHED ? JBUI.CurrentTheme.ActionButton.pressedBorder() : JBUI.CurrentTheme.ActionButton.hoverBorder();

    g2.setColor(color);

    float arc = DarculaUIUtil.BUTTON_ARC.getFloat();
    float lw = DarculaUIUtil.LW.getFloat();
    Path2D border = new Path2D.Float(Path2D.WIND_EVEN_ODD);
    border.append(new RoundRectangle2D.Float(rect.x, rect.y, rect.width, rect.height, arc, arc), false);
    border.append(new RoundRectangle2D.Float(rect.x + lw, rect.y + lw, rect.width - lw * 2, rect.height - lw * 2, arc - lw, arc - lw), false);

    g2.fill(border);
  }
  finally {
    g2.dispose();
  }
}
 
源代码19 项目: consulo   文件: ActionButtonUI.java
@Override
public void paint(Graphics g, JComponent c) {
  if(c instanceof ActionButtonWithText) {
    paintTextButton(g, (ActionButtonWithText)c);
  }
  else {
    paintDefaultButton(g, (ActionButton)c);
  }
}
 
源代码20 项目: consulo   文件: ActionButtonUI.java
public void paintBackground(ActionButton button, Graphics g, Dimension size, int state) {
  if (state == ActionButtonComponent.NORMAL && !button.isBackgroundSet()) return;

  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));
  }
}
 
源代码21 项目: consulo   文件: ModernActionButtonUI.java
@Override
public void paintBorder(ActionButton button, Graphics g, Dimension size, int state) {
  if (state == ActionButtonComponent.NORMAL && !button.isBackgroundSet()) return;

  final GraphicsConfig config = GraphicsUtil.setupAAPainting(g);
  g.setColor(state == ActionButtonComponent.POPPED || state == ActionButtonComponent.PUSHED
             ? ModernUIUtil.getSelectionBackground()
             : ModernUIUtil.getBorderColor(button));
  RectanglePainter2D.DRAW.paint((Graphics2D)g, 0, 0, size.getWidth(), size.getHeight());
  config.restore();
}
 
源代码22 项目: consulo   文件: ModernActionButtonUI.java
@Override
public void paintBackground(ActionButton button, Graphics g, Dimension size, int state) {
  if (state == ActionButtonComponent.PUSHED) {
    g.setColor(ColorUtil.toAlpha(ModernUIUtil.getSelectionBackground(), 100));
    RectanglePainter2D.FILL.paint((Graphics2D)g, 0, 0, size.getWidth(), size.getHeight());
  }
}
 
源代码23 项目: flutter-intellij   文件: IdeaFrameFixture.java
@NotNull
public ActionButtonFixture findAttachDebuggerToAndroidProcessButton() {
  GenericTypeMatcher<ActionButton> matcher = Matchers.byText(ActionButton.class, "Attach Debugger to Android Process").andIsShowing();
  return ActionButtonFixture.findByMatcher(matcher, robot(), target());
}
 
源代码24 项目: consulo   文件: LookupUi.java
LookupUi(@Nonnull LookupImpl lookup, Advertiser advertiser, JBList list) {
  myLookup = lookup;
  myAdvertiser = advertiser;
  myList = list;

  myProcessIcon.setVisible(false);
  myLookup.resort(false);

  MenuAction menuAction = new MenuAction();
  menuAction.add(new ChangeSortingAction());
  menuAction.add(new DelegatedAction(ActionManager.getInstance().getAction(IdeActions.ACTION_QUICK_JAVADOC)) {
    @Override
    public void update(@Nonnull AnActionEvent e) {
      e.getPresentation().setVisible(!CodeInsightSettings.getInstance().AUTO_POPUP_JAVADOC_INFO);
    }
  });
  menuAction.add(new DelegatedAction(ActionManager.getInstance().getAction(IdeActions.ACTION_QUICK_IMPLEMENTATIONS)));

  Presentation presentation = new Presentation();
  presentation.setIcon(AllIcons.Actions.More);
  presentation.putClientProperty(ActionButton.HIDE_DROPDOWN_ICON, Boolean.TRUE);

  myMenuButton = new ActionButton(menuAction, presentation, ActionPlaces.EDITOR_POPUP, ActionToolbar.NAVBAR_MINIMUM_BUTTON_SIZE);

  AnAction hintAction = new HintAction();
  myHintButton = new ActionButton(hintAction, hintAction.getTemplatePresentation(), ActionPlaces.EDITOR_POPUP, ActionToolbar.NAVBAR_MINIMUM_BUTTON_SIZE);
  myHintButton.setVisible(false);

  myBottomPanel = new NonOpaquePanel(new LookupBottomLayout());
  myBottomPanel.add(myAdvertiser.getAdComponent());
  myBottomPanel.add(myProcessIcon);
  myBottomPanel.add(myHintButton);
  myBottomPanel.add(myMenuButton);

  LookupLayeredPane layeredPane = new LookupLayeredPane();
  layeredPane.mainPanel.add(myBottomPanel, BorderLayout.SOUTH);

  myScrollPane = ScrollPaneFactory.createScrollPane(lookup.getList(), true);
  myScrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
  UIUtil.putClientProperty(myScrollPane.getVerticalScrollBar(), JBScrollPane.IGNORE_SCROLLBAR_IN_INSETS, true);

  lookup.getComponent().add(layeredPane, BorderLayout.CENTER);

  layeredPane.mainPanel.add(myScrollPane, BorderLayout.CENTER);

  myModalityState = ModalityState.stateForComponent(lookup.getTopLevelEditor().getComponent());

  addListeners();

  Disposer.register(lookup, myProcessIcon);
  Disposer.register(lookup, myHintAlarm);
}
 
源代码25 项目: consulo   文件: SearchTextArea.java
public void updateExtraActions() {
  for (ActionButton button : UIUtil.findComponentsOfType(myExtraActionsPanel, ActionButton.class)) {
    button.update();
  }
}
 
源代码26 项目: consulo   文件: ActionButtonUI.java
void paintBackground(ActionButton button, Graphics g, Dimension size, int state);