use of com.intellij.openapi.actionSystem.impl.PresentationFactory in project intellij-community by JetBrains.
the class UnversionedViewDialog method registerUnversionedActionsShortcuts.
@NotNull
public static List<AnAction> registerUnversionedActionsShortcuts(@NotNull DataContext dataContext, @NotNull JComponent component) {
ActionManager manager = ActionManager.getInstance();
List<AnAction> actions = ContainerUtil.newArrayList();
Utils.expandActionGroup(LaterInvocator.isInModalContext(), getUnversionedActionGroup(), actions, new PresentationFactory(), dataContext, "", manager);
for (AnAction action : actions) {
action.registerCustomShortcutSet(action.getShortcutSet(), component);
}
return actions;
}
use of com.intellij.openapi.actionSystem.impl.PresentationFactory in project intellij-community by JetBrains.
the class CardActionsPanel method buildComponents.
private List<JComponent> buildComponents(ActionGroup group, String parentId) {
AnAction[] actions = group.getChildren(null);
List<JComponent> components = new ArrayList<>();
PresentationFactory factory = new PresentationFactory();
for (AnAction action : actions) {
Presentation presentation = action.getTemplatePresentation().clone();
if (!USE_ICONS) {
presentation.setIcon(null);
}
if (action instanceof ActionGroup) {
ActionGroup childGroup = (ActionGroup) action;
if (childGroup.isPopup()) {
final String id = String.valueOf(++nCards);
createCardForGroup(childGroup, id, parentId);
components.add(new Button(new ActivateCard(id), presentation));
} else {
components.addAll(buildComponents(childGroup, parentId));
}
} else if (action instanceof AbstractActionWithPanel) {
final JPanel panel = ((AbstractActionWithPanel) action).createPanel();
components.add(panel);
} else {
action.update(new AnActionEvent(null, DataManager.getInstance().getDataContext(this), ActionPlaces.WELCOME_SCREEN, presentation, ActionManager.getInstance(), 0));
if (presentation.isVisible()) {
components.add(new Button(action, presentation));
}
}
}
return components;
}
use of com.intellij.openapi.actionSystem.impl.PresentationFactory in project intellij-community by JetBrains.
the class JBMovePanel method createButton.
@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);
}
use of com.intellij.openapi.actionSystem.impl.PresentationFactory 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;
}
Aggregations