use of com.intellij.openapi.actionSystem.AnActionEvent in project intellij-plugins by JetBrains.
the class ShowGeneratedManifestTest method testMenuGroup.
@Test
public void testMenuGroup() {
ViewGeneratedManifestGroup group = (ViewGeneratedManifestGroup) ActionManager.getInstance().getAction("osmorc.viewGeneratedManifests");
assertNotNull(group);
@SuppressWarnings("deprecation") DataContext context = DataManager.getInstance().getDataContext();
AnActionEvent event = AnActionEvent.createFromAnAction(group, null, "", context);
AnAction[] actions = group.getChildren(event);
assertEquals(3, actions.length);
Arrays.sort(actions, (o1, o2) -> Comparing.compare(o1.getTemplatePresentation().getText(), o2.getTemplatePresentation().getText()));
assertEquals("[t0] t0.jar", actions[0].getTemplatePresentation().getText());
}
use of com.intellij.openapi.actionSystem.AnActionEvent in project intellij-plugins by JetBrains.
the class OptionsButton method addResetPreferencesActionTo.
private void addResetPreferencesActionTo(DefaultActionGroup actionGroup) {
myResetSettingsAction = new AnAction("Reset to default settings") {
public void actionPerformed(AnActionEvent e) {
try {
Preferences preferences = Preferences.userRoot().node("jetbrains.communicator");
preferences.removeNode();
preferences.flush();
} catch (BackingStoreException e1) {
LOG.error(e1.getMessage(), e1);
}
}
};
actionGroup.add(myResetSettingsAction);
}
use of com.intellij.openapi.actionSystem.AnActionEvent in project android by JetBrains.
the class ManifestPanel method registerGotoAction.
private void registerGotoAction() {
AnAction goToDeclarationAction = new AnAction() {
@Override
public void actionPerformed(AnActionEvent e) {
ManifestTreeNode node = (ManifestTreeNode) myTree.getLastSelectedPathComponent();
if (node != null) {
goToDeclaration(node.getUserObject());
}
}
};
goToDeclarationAction.registerCustomShortcutSet(ActionManager.getInstance().getAction(IdeActions.ACTION_GOTO_DECLARATION).getShortcutSet(), myTree);
}
use of com.intellij.openapi.actionSystem.AnActionEvent in project android by JetBrains.
the class AnalysisResultsManager method createActions.
@NotNull
@Override
protected AnAction[] createActions() {
return new AnAction[] { new ToggleAction(AndroidBundle.message("android.captures.analysis.results.manager.run.name"), AndroidBundle.message("android.captures.analysis.results.manager.run.description"), AllIcons.Toolwindows.ToolWindowRun) {
@Override
public boolean isSelected(AnActionEvent e) {
AnalysisResultsContent analysisResultsContent = getContentFromDesigner();
return analysisResultsContent != null && !analysisResultsContent.canRunAnalysis();
}
@Override
public void setSelected(AnActionEvent e, boolean state) {
if (state) {
AnalysisResultsContent analysisResultsContent = getContentFromDesigner();
if (analysisResultsContent != null && analysisResultsContent.canRunAnalysis()) {
analysisResultsContent.performAnalysis();
}
}
}
@Override
public void update(@NotNull AnActionEvent e) {
super.update(e);
Presentation presentation = e.getPresentation();
if (isSelected(e)) {
presentation.setText(AndroidBundle.message("android.captures.analysis.results.manager.run.disabled.name"));
presentation.setDescription(AndroidBundle.message("android.captures.analysis.results.manager.run.disabled.description"));
presentation.setIcon(AllIcons.Process.DisabledRun);
} else {
presentation.setText(AndroidBundle.message("android.captures.analysis.results.manager.run.enabled.name"));
presentation.setDescription(AndroidBundle.message("android.captures.analysis.results.manager.run.enabled.description"));
presentation.setIcon(AllIcons.Toolwindows.ToolWindowRun);
}
}
} };
}
use of com.intellij.openapi.actionSystem.AnActionEvent in project android by JetBrains.
the class AndroidBaseXmlRefactoringAction method update.
@Override
public void update(AnActionEvent e) {
final DataContext context = e.getDataContext();
final DataContext patchedContext = new DataContext() {
@Override
public Object getData(@NonNls String dataId) {
final Object data = context.getData(dataId);
if (data != null) {
return data;
}
if (CommonDataKeys.PSI_ELEMENT.is(dataId)) {
final XmlTag[] tags = getXmlTagsFromExternalContext(context);
return tags.length == 1 ? tags[0] : null;
} else if (LangDataKeys.PSI_ELEMENT_ARRAY.is(dataId)) {
return getXmlTagsFromExternalContext(context);
}
return null;
}
};
super.update(new AnActionEvent(e.getInputEvent(), patchedContext, e.getPlace(), e.getPresentation(), e.getActionManager(), e.getModifiers()));
}
Aggregations