use of com.intellij.openapi.actionSystem.AnAction in project intellij-community by JetBrains.
the class UsageNodeTreeBuilderTest method buildUsageTree.
private GroupNode buildUsageTree(int[] indices, UsageGroupingRule[] rules) {
Usage[] usages = new Usage[indices.length];
for (int i = 0; i < usages.length; i++) {
usages[i] = createUsage(indices[i]);
}
UsageViewPresentation presentation = new UsageViewPresentation();
presentation.setUsagesString("searching for mock usages");
ExtensionsArea area = Extensions.getRootArea();
ExtensionPoint<UsageGroupingRuleProvider> point = area.getExtensionPoint(UsageGroupingRuleProvider.EP_NAME);
UsageGroupingRuleProvider provider = new UsageGroupingRuleProvider() {
@NotNull
@Override
public UsageGroupingRule[] getActiveRules(Project project) {
return rules;
}
@NotNull
@Override
public AnAction[] createGroupingActions(UsageView view) {
return AnAction.EMPTY_ARRAY;
}
};
point.registerExtension(provider);
try {
UsageViewImpl usageView = new UsageViewImpl(getProject(), presentation, UsageTarget.EMPTY_ARRAY, null);
Disposer.register(getTestRootDisposable(), usageView);
for (Usage usage : usages) {
usageView.appendUsage(usage);
}
UIUtil.dispatchAllInvocationEvents();
return usageView.getRoot();
} finally {
point.unregisterExtension(provider);
}
}
use of com.intellij.openapi.actionSystem.AnAction in project intellij-community by JetBrains.
the class ImportTestsGroup method getChildren.
@NotNull
@Override
public AnAction[] getChildren(@Nullable AnActionEvent e) {
if (e == null)
return EMPTY_ARRAY;
final Project project = e.getProject();
if (project == null)
return EMPTY_ARRAY;
final Collection<String> filePaths = TestHistoryConfiguration.getInstance(project).getFiles();
final File testHistoryRoot = TestStateStorage.getTestHistoryRoot(project);
final List<File> fileNames = ContainerUtil.map(filePaths, fileName -> new File(testHistoryRoot, fileName));
Collections.sort(fileNames, (f1, f2) -> f1.lastModified() > f2.lastModified() ? -1 : 1);
final int historySize = fileNames.size();
final AnAction[] actions = new AnAction[historySize + 2];
for (int i = 0; i < historySize; i++) {
actions[i] = new ImportTestsFromHistoryAction(myProperties, project, fileNames.get(i).getName());
}
actions[historySize] = Separator.getInstance();
actions[historySize + 1] = new ImportTestsFromFileAction(myProperties);
return actions;
}
use of com.intellij.openapi.actionSystem.AnAction in project intellij-community by JetBrains.
the class ActionLinkFixture method findByActionId.
@NotNull
public static ActionLinkFixture findByActionId(@NotNull final String actionId, @NotNull final Robot robot, @NotNull final Container container) {
final Ref<ActionLink> actionLinkRef = new Ref<ActionLink>();
pause(new Condition("Find ActionLink with ID '" + actionId + "'") {
@Override
public boolean test() {
Collection<ActionLink> found = robot.finder().findAll(container, new GenericTypeMatcher<ActionLink>(ActionLink.class) {
@Override
protected boolean isMatching(@NotNull ActionLink actionLink) {
if (actionLink.isVisible()) {
AnAction action = actionLink.getAction();
String id = ActionManager.getInstance().getId(action);
return actionId.equals(id);
}
return false;
}
});
if (found.size() == 1) {
actionLinkRef.set(getFirstItem(found));
return true;
}
return false;
}
}, SHORT_TIMEOUT);
ActionLink actionLink = actionLinkRef.get();
if (actionLink == null) {
throw new ComponentLookupException("Failed to find ActionLink with ID '" + actionId + "'");
}
return new ActionLinkFixture(robot, actionLink);
}
use of com.intellij.openapi.actionSystem.AnAction in project intellij-community by JetBrains.
the class IdeFrameFixture method invokeMainMenu.
/**
* Invokes an action from main menu
*
* @param mainMenuAction is the typical AnAction with ActionPlaces.MAIN_MENU
*/
public void invokeMainMenu(@NotNull String mainMenuActionId) {
ActionManager actionManager = ActionManager.getInstance();
AnAction mainMenuAction = actionManager.getAction(mainMenuActionId);
JMenuBar jMenuBar = this.target().getRootPane().getJMenuBar();
MouseEvent fakeMainMenuMouseEvent = new MouseEvent(jMenuBar, MouseEvent.MOUSE_CLICKED, System.currentTimeMillis(), 0, MouseInfo.getPointerInfo().getLocation().x, MouseInfo.getPointerInfo().getLocation().y, 1, false);
ApplicationManager.getApplication().invokeLater(() -> actionManager.tryToExecute(mainMenuAction, fakeMainMenuMouseEvent, null, ActionPlaces.MAIN_MENU, true));
}
use of com.intellij.openapi.actionSystem.AnAction in project intellij-community by JetBrains.
the class CompositeCommittedChangesProvider method createActions.
@Nullable
public VcsCommittedViewAuxiliary createActions(final DecoratorManager manager, final RepositoryLocation location) {
JTabbedPane tabbedPane = null;
List<AnAction> actions = null;
List<AnAction> toolbarActions = null;
final List<Runnable> calledOnDispose = new ArrayList<>();
for (AbstractVcs baseVcs : myBaseVcss) {
final CommittedChangesProvider provider = baseVcs.getCommittedChangesProvider();
if (provider != null) {
VcsCommittedViewAuxiliary auxiliary = provider.createActions(manager, location);
if (auxiliary != null) {
if (tabbedPane == null) {
tabbedPane = new JBTabbedPane();
actions = new ArrayList<>();
toolbarActions = new ArrayList<>();
}
actions.addAll(auxiliary.getPopupActions());
toolbarActions.addAll(auxiliary.getToolbarActions());
calledOnDispose.add(auxiliary.getCalledOnViewDispose());
}
}
}
if (tabbedPane != null) {
final JPanel panel = new JPanel();
panel.add(tabbedPane);
return new VcsCommittedViewAuxiliary(actions, new Runnable() {
public void run() {
for (Runnable runnable : calledOnDispose) {
runnable.run();
}
}
}, toolbarActions);
}
return null;
}
Aggregations