use of com.intellij.openapi.actionSystem.impl.ActionButton in project intellij-community by JetBrains.
the class ActionButtonFixture method findByActionId.
@NotNull
public static ActionButtonFixture findByActionId(@NotNull final String actionId, @NotNull final Robot robot, @NotNull final Container container, Timeout timeout) {
final Ref<ActionButton> actionButtonRef = new Ref<ActionButton>();
Pause.pause(new Condition("Find ActionButton with ID '" + actionId + "'") {
@Override
public boolean test() {
Collection<ActionButton> found = robot.finder().findAll(container, new GenericTypeMatcher<ActionButton>(ActionButton.class) {
@Override
protected boolean isMatching(@NotNull ActionButton button) {
if (button.isVisible()) {
AnAction action = button.getAction();
if (action != null) {
String id = ActionManager.getInstance().getId(action);
return actionId.equals(id);
}
}
return false;
}
});
if (found.size() == 1) {
actionButtonRef.set(getFirstItem(found));
return true;
}
return false;
}
}, timeout);
ActionButton button = actionButtonRef.get();
if (button == null) {
throw new ComponentLookupException("Failed to find ActionButton with ID '" + actionId + "'");
}
return new ActionButtonFixture(robot, button);
}
use of com.intellij.openapi.actionSystem.impl.ActionButton in project intellij-community by JetBrains.
the class PropertyTablePanel method setCurrentTab.
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();
}
use of com.intellij.openapi.actionSystem.impl.ActionButton in project intellij-community by JetBrains.
the class RichTextActionProcessor method process.
@Override
public JComponent process(@NotNull String s) {
final ActionManager actionManager = ActionManager.getInstance();
final AnAction action = actionManager.getAction(s);
if (action == null) {
return null;
}
final Presentation presentation = action.getTemplatePresentation();
if (presentation.getIcon() != null) {
return new ActionButton(action, presentation.clone(), GradleConstants.TOOL_WINDOW_TOOLBAR_PLACE, JBUI.emptySize()) {
@Override
protected void paintButtonLook(Graphics g) {
// Don't draw border at the inline button.
ActionButtonLook look = getButtonLook();
look.paintBackground(g, this);
look.paintIcon(g, this, getIcon());
}
};
}
final String text = action.getTemplatePresentation().getText();
JLabel result = new JLabel(text) {
public void paint(Graphics g) {
super.paint(g);
final int y = g.getClipBounds().height - getFontMetrics(getFont()).getDescent() + 2;
final int width = getFontMetrics(getFont()).stringWidth(getText());
g.drawLine(0, y, width, y);
}
};
Color color = UIUtil.isUnderDarcula() ? Color.ORANGE : Color.BLUE;
result.setForeground(color);
result.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
new ClickListener() {
@Override
public boolean onClick(@NotNull MouseEvent e, int clickCount) {
final AsyncResult<DataContext> callback = DataManager.getInstance().getDataContextFromFocus();
final DataContext context = callback.getResult();
if (context == null) {
return false;
}
final Presentation presentation = new PresentationFactory().getPresentation(action);
action.actionPerformed(new AnActionEvent(e, context, GradleConstants.TOOL_WINDOW_TOOLBAR_PLACE, presentation, ActionManager.getInstance(), e.getModifiers()));
return true;
}
}.installOn(result);
return result;
}
use of com.intellij.openapi.actionSystem.impl.ActionButton in project android by JetBrains.
the class AttachedToolWindowTest method findButtonByName.
private static ActionButton findButtonByName(@NotNull Container container, @NotNull String name) {
for (Component component : container.getComponents()) {
if (component instanceof ActionButton) {
ActionButton button = (ActionButton) component;
AnAction action = button.getAction();
if (action != null && name.equals(action.getTemplatePresentation().getText())) {
return button;
}
}
if (component instanceof Container) {
ActionButton button = findButtonByName((Container) component, name);
if (button != null) {
return button;
}
}
}
return null;
}
use of com.intellij.openapi.actionSystem.impl.ActionButton in project android by JetBrains.
the class AttachedToolWindowTest method getPopupMenuFromGearButtonInHeader.
private DefaultActionGroup getPopupMenuFromGearButtonInHeader() {
ActionButton button = findButtonByName(myToolWindow.getComponent(), "Gear");
assertThat(button).isNotNull();
button.click();
ArgumentCaptor<ActionGroup> menuCaptor = ArgumentCaptor.forClass(ActionGroup.class);
verify(myActionManager).createActionPopupMenu(eq(ToolWindowContentUi.POPUP_PLACE), menuCaptor.capture());
return (DefaultActionGroup) menuCaptor.getValue();
}
Aggregations