use of com.intellij.openapi.actionSystem.ActionManager in project intellij-community by JetBrains.
the class KeymapGenerator method main.
@Override
public void main(String[] args) {
ActionManager actionManager = ActionManager.getInstance();
StringBuilder xml = new StringBuilder();
xml.append("<Keymaps>\n");
for (Keymap keymap : KeymapManagerEx.getInstanceEx().getAllKeymaps()) {
xml.append(" <Keymap name=\"").append(keymap.getPresentableName()).append("\">\n");
for (String id : keymap.getActionIdList()) {
String shortcuts = KeymapUtil.getShortcutsText(keymap.getShortcuts(id));
if (!StringUtil.isEmpty(shortcuts)) {
AnAction action = actionManager.getAction(id);
xml.append(" <Action id=\"").append(id).append("\">\n");
Set<String> addedShortcuts = new THashSet<>();
for (Shortcut shortcut : keymap.getShortcuts(id)) {
// Different shortcuts may have equal display strings (e.g. shift+minus and shift+subtract)
// We don't want them do be duplicated for users
String shortcutText = KeymapUtil.getShortcutText(shortcut);
if (addedShortcuts.add(shortcutText)) {
xml.append(" <Shortcut>").append(shortcutText).append("</Shortcut>\n");
}
}
if (action != null) {
String text = action.getTemplatePresentation().getText();
if (text != null) {
xml.append(" <Text>").append(StringUtil.escapeXml(text)).append("</Text>\n");
}
}
xml.append(" </Action>\n");
}
}
xml.append(" </Keymap>\n");
}
xml.append("</Keymaps>");
final String path = args.length == 2 ? args[1] : PathManager.getHomePath() + File.separator + "AllKeymaps.xml";
File out = new File(path);
try {
FileUtil.writeToFile(out, xml.toString());
System.out.println("Saved to: " + out.getAbsolutePath());
} catch (IOException e) {
e.printStackTrace();
System.exit(1);
}
System.exit(0);
}
use of com.intellij.openapi.actionSystem.ActionManager in project android by JetBrains.
the class GradleDslMethodNotFoundErrorHandler method getApplyGradlePluginHyperlink.
@NotNull
private static NotificationHyperlink getApplyGradlePluginHyperlink(@NotNull final VirtualFile virtualFile, @NotNull final NotificationData notification) {
return new NotificationHyperlink("apply.gradle.plugin", "Apply Gradle plugin") {
@Override
protected void execute(@NotNull Project project) {
openFile(virtualFile, notification, project);
ActionManager actionManager = ActionManager.getInstance();
String actionId = AddGradleDslPluginAction.ID;
AnAction action = actionManager.getAction(actionId);
assert action instanceof AddGradleDslPluginAction;
AddGradleDslPluginAction addPluginAction = (AddGradleDslPluginAction) action;
actionManager.tryToExecute(addPluginAction, ActionCommand.getInputEvent(actionId), null, ActionPlaces.UNKNOWN, true);
}
};
}
use of com.intellij.openapi.actionSystem.ActionManager in project intellij-community by JetBrains.
the class GradleToolWindowPanel method initContent.
public void initContent() {
final ActionManager actionManager = ActionManager.getInstance();
final ActionGroup actionGroup = (ActionGroup) actionManager.getAction(TOOL_WINDOW_TOOLBAR_ID);
ActionToolbar actionToolbar = actionManager.createActionToolbar(myPlace, actionGroup, true);
JPanel toolbarControl = new JPanel(new GridBagLayout());
GridBagConstraints constraints = new GridBagConstraints();
constraints.gridwidth = GridBagConstraints.REMAINDER;
constraints.weightx = 1;
constraints.fill = GridBagConstraints.HORIZONTAL;
constraints.anchor = GridBagConstraints.WEST;
toolbarControl.add(actionToolbar.getComponent(), constraints);
for (JComponent component : getToolbarControls()) {
component.setBorder(IdeBorderFactory.createBorder(SideBorder.TOP));
toolbarControl.add(component, constraints);
}
setToolbar(toolbarControl);
final JComponent payloadControl = buildContent();
JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(payloadControl);
JScrollBar scrollBar = scrollPane.getVerticalScrollBar();
myContent.add(scrollPane, CONTENT_CARD_NAME);
RichTextControlBuilder builder = new RichTextControlBuilder();
builder.setBackgroundColor(payloadControl.getBackground());
builder.setForegroundColor(UIUtil.getInactiveTextColor());
builder.setFont(payloadControl.getFont());
builder.setText(GradleBundle.message("gradle.toolwindow.text.no.linked.project"));
final JComponent noLinkedProjectControl = builder.build();
myContent.add(noLinkedProjectControl, NON_LINKED_CARD_NAME);
update();
}
use of com.intellij.openapi.actionSystem.ActionManager in project intellij-community by JetBrains.
the class DvcsQuickListContentProvider method getVcsActions.
@Nullable
public List<AnAction> getVcsActions(@Nullable Project project, @Nullable AbstractVcs activeVcs, @Nullable DataContext dataContext) {
if (activeVcs == null || !getVcsName().equals(activeVcs.getName())) {
return null;
}
final ActionManager manager = ActionManager.getInstance();
final List<AnAction> actions = new ArrayList<>();
actions.add(new Separator(activeVcs.getDisplayName()));
add("CheckinProject", manager, actions);
add("CheckinFiles", manager, actions);
add("ChangesView.Revert", manager, actions);
addSeparator(actions);
add("Vcs.ShowTabbedFileHistory", manager, actions);
add("Annotate", manager, actions);
add("Compare.SameVersion", manager, actions);
addSeparator(actions);
addVcsSpecificActions(manager, actions);
return actions;
}
use of com.intellij.openapi.actionSystem.ActionManager in project intellij-plugins by JetBrains.
the class AngularUiRouterInitializer method runActivity.
@Override
public void runActivity(@NotNull Project project) {
if (myInitialized)
return;
final ActionManager actionManager = ActionManager.getInstance();
final AnAction action = actionManager.getAction("UML.EditorGroup");
final AnAction showUiRouter = actionManager.getAction("AngularJS.Show.Ui.Router.States.Diagram.Action");
if (action instanceof DefaultActionGroup) {
((DefaultActionGroup) action).add(showUiRouter);
}
myInitialized = true;
}
Aggregations