use of com.intellij.openapi.actionSystem.AnActionEvent in project intellij-plugins by JetBrains.
the class FlexExtractSuperTest method checkAction.
private void checkAction(String actionId, boolean enabled, int pos) {
AnAction action = ActionManager.getInstance().getAction(actionId);
AnActionEvent e = new TestActionEvent(DataManager.getInstance().getDataContext(getEditor().getComponent()), action);
action.beforeActionPerformedUpdate(e);
assertEquals("Action " + actionId + " should be " + (enabled ? "enabled" : "disabled") + " at position " + pos, enabled, e.getPresentation().isEnabled());
}
use of com.intellij.openapi.actionSystem.AnActionEvent in project intellij-plugins by JetBrains.
the class OpenFileActionTest method assertEnabled.
private void assertEnabled(String msg, boolean enabled) throws IllegalAccessException, InvocationTargetException, InstantiationException {
AnActionEvent e = createActionEvent(myOpenFileAction.getTemplatePresentation());
myOpenFileAction.update(e);
assertEquals(msg, enabled, e.getPresentation().isEnabled());
}
use of com.intellij.openapi.actionSystem.AnActionEvent in project intellij-plugins by JetBrains.
the class ShowUiRouterStatesNewDiagramAction method actionPerformed.
@Override
public void actionPerformed(AnActionEvent e) {
UsageTrigger.trigger(USAGE_KEY);
final Project project = e.getProject();
if (project == null)
return;
final AngularUiRouterDiagramProvider diagramProvider = (AngularUiRouterDiagramProvider) DiagramProvider.findByID(AngularUiRouterDiagramProvider.ANGULAR_UI_ROUTER);
if (diagramProvider == null)
return;
List<Pair<String, AngularUiRouterGraphBuilder>> graphBuilders = new ArrayList<>();
ProgressManager.getInstance().runProcessWithProgressSynchronously(() -> {
ApplicationManager.getApplication().runReadAction(() -> {
final AngularUiRouterDiagramBuilder builder = new AngularUiRouterDiagramBuilder(project);
builder.build();
final Map<VirtualFile, RootTemplate> rootTemplates = builder.getRootTemplates();
for (Map.Entry<VirtualFile, Map<String, UiRouterState>> entry : builder.getDefiningFiles2States().entrySet()) {
final AngularUiRouterGraphBuilder graphBuilder = new AngularUiRouterGraphBuilder(project, entry.getValue(), builder.getTemplatesMap(), null, entry.getKey());
graphBuilders.add(Pair.create(entry.getKey().getName(), graphBuilder));
}
for (Map.Entry<VirtualFile, Map<String, UiRouterState>> entry : builder.getRootTemplates2States().entrySet()) {
final AngularUiRouterGraphBuilder graphBuilder = new AngularUiRouterGraphBuilder(project, entry.getValue(), builder.getTemplatesMap(), rootTemplates.get(entry.getKey()), entry.getKey());
graphBuilders.add(Pair.create(entry.getKey().getName(), graphBuilder));
}
});
}, "Building " + diagramProvider.getPresentableName() + " diagram", false, project);
final AngularUiRouterProviderContext routerProviderContext = AngularUiRouterProviderContext.getInstance(project);
routerProviderContext.reset();
final Consumer<AngularUiRouterGraphBuilder> consumer = graphBuilder -> {
final AngularUiRouterGraphBuilder.GraphNodesBuilder nodesBuilder = graphBuilder.createDataModel(diagramProvider);
routerProviderContext.registerNodesBuilder(nodesBuilder);
final DiagramObject element = nodesBuilder.getRootNode().getIdentifyingElement();
final Runnable callback = show(element, diagramProvider, project, null, Collections.emptyList());
if (callback != null) {
callback.run();
}
};
if (graphBuilders.isEmpty()) {
Messages.showInfoMessage(project, "No router states found.", DESCRIPTION);
return;
}
if (graphBuilders.size() == 1)
consumer.consume(graphBuilders.get(0).getSecond());
else
filterGraphBuilders(project, graphBuilders, consumer);
}
use of com.intellij.openapi.actionSystem.AnActionEvent in project android by JetBrains.
the class NlBooleanIconEditor method setProperty.
public void setProperty(@NotNull NlProperty property) {
myAction.setProperty(property);
updateDescription(property);
// This will update the selected state of the ActionButton:
AnActionEvent event = new AnActionEvent(null, DataManager.getInstance().getDataContext(myButton), INSPECTOR_PLACE, myPresentation, ActionManager.getInstance(), 0);
ActionUtil.performDumbAwareUpdate(myAction, event, false);
myButton.updateIcon();
}
use of com.intellij.openapi.actionSystem.AnActionEvent in project intellij-community by JetBrains.
the class ImportTree method createExcludeAction.
public AnAction createExcludeAction() {
return new AnAction(CvsBundle.message("import.wizard.exclude.from.import.action.name"), null, PlatformIcons.DELETE_ICON) {
public void update(AnActionEvent e) {
final VirtualFile[] selectedFiles = myFileSystemTree.getSelectedFiles();
final Presentation presentation = e.getPresentation();
presentation.setEnabled(isAtLeastOneFileIncluded(selectedFiles));
}
public void actionPerformed(AnActionEvent e) {
final VirtualFile[] selectedFiles = myFileSystemTree.getSelectedFiles();
for (VirtualFile selectedFile : selectedFiles) {
exclude(selectedFile);
}
myWizard.updateStep();
myFileSystemTree.getTree().repaint();
}
};
}
Aggregations