use of com.intellij.openapi.actionSystem.AnActionEvent in project intellij-community by JetBrains.
the class LocalHistoryActionsTest method testShowSelectionHistoryActionForSelection.
public void testShowSelectionHistoryActionForSelection() throws Exception {
editor.getSelectionModel().setSelection(0, 2);
ShowSelectionHistoryAction a = new ShowSelectionHistoryAction();
AnActionEvent e = createEventFor(a, new VirtualFile[] { f }, myProject);
a.update(e);
assertTrue(e.getPresentation().isEnabled());
assertEquals("Show History for Selection", e.getPresentation().getText());
}
use of com.intellij.openapi.actionSystem.AnActionEvent in project intellij-community by JetBrains.
the class ModifierKeyDoubleClickHandlerTest method setUp.
@Override
public void setUp() throws Exception {
super.setUp();
Clock.setTime(0);
ActionManager.getInstance().registerAction(MY_SHIFT_SHIFT_ACTION, new AnAction() {
@Override
public void actionPerformed(AnActionEvent e) {
myShiftShiftActionInvocationCount++;
}
});
ActionManager.getInstance().registerAction(MY_SHIFT_KEY_ACTION, new AnAction() {
@Override
public void actionPerformed(AnActionEvent e) {
myShiftKeyActionInvocationCount++;
}
});
ActionManager.getInstance().registerAction(MY_SHIFT_SHIFT_KEY_ACTION, new AnAction() {
@Override
public void actionPerformed(AnActionEvent e) {
myShiftShiftKeyActionInvocationCount++;
}
});
ActionManager.getInstance().registerAction(MY_SHIFT_OTHER_KEY_ACTION, new AnAction() {
@Override
public void actionPerformed(AnActionEvent e) {
myShiftOtherKeyActionInvocationCount++;
}
});
KeymapManager.getInstance().getActiveKeymap().addShortcut(MY_SHIFT_KEY_ACTION, SHIFT_KEY_SHORTCUT);
KeymapManager.getInstance().getActiveKeymap().addShortcut(MY_SHIFT_OTHER_KEY_ACTION, SHIFT_OTHER_KEY_SHORTCUT);
ModifierKeyDoubleClickHandler.getInstance().registerAction(MY_SHIFT_SHIFT_ACTION, KeyEvent.VK_SHIFT, -1);
ModifierKeyDoubleClickHandler.getInstance().registerAction(MY_SHIFT_SHIFT_KEY_ACTION, KeyEvent.VK_SHIFT, KeyEvent.VK_BACK_SPACE);
}
use of com.intellij.openapi.actionSystem.AnActionEvent in project intellij-community by JetBrains.
the class XValueHint method showHint.
@Override
protected boolean showHint(final JComponent component) {
boolean result = super.showHint(component);
if (result && getType() == ValueHintType.MOUSE_OVER_HINT) {
myDisposable = Disposer.newDisposable();
ShortcutSet shortcut = ActionManager.getInstance().getAction("ShowErrorDescription").getShortcutSet();
new DumbAwareAction() {
@Override
public void actionPerformed(@NotNull AnActionEvent e) {
hideHint();
final Point point = new Point(myPoint.x, myPoint.y + getEditor().getLineHeight());
new XValueHint(getProject(), getEditor(), point, ValueHintType.MOUSE_CLICK_HINT, myExpressionInfo, myEvaluator, myDebugSession).invokeHint();
}
}.registerCustomShortcutSet(shortcut, getEditor().getContentComponent(), myDisposable);
}
if (result) {
XValueHint prev = getEditor().getUserData(HINT_KEY);
if (prev != null) {
prev.hideHint();
}
getEditor().putUserData(HINT_KEY, this);
}
return result;
}
use of com.intellij.openapi.actionSystem.AnActionEvent in project intellij-community by JetBrains.
the class AbstractLanguageInjectionSupport method createDefaultAddAction.
public static AnAction createDefaultAddAction(final Project project, final Consumer<BaseInjection> consumer, final AbstractLanguageInjectionSupport support) {
final String supportTitle = StringUtil.capitalize(support.getId());
Icon icon = FileTypeManager.getInstance().getFileTypeByExtension(support.getId()).getIcon();
return new AnAction("Generic " + supportTitle, null, icon) {
@Override
public void actionPerformed(AnActionEvent e) {
final BaseInjection injection = new BaseInjection(support.getId());
injection.setDisplayName("New " + supportTitle + " Injection");
final BaseInjection newInjection = showDefaultInjectionUI(project, injection);
if (newInjection != null) {
consumer.consume(injection);
}
}
};
}
use of com.intellij.openapi.actionSystem.AnActionEvent in project intellij-community by JetBrains.
the class ImportTree method createIncludeAction.
public AnAction createIncludeAction() {
return new AnAction(CvsBundle.message("import.wizard.include.to.import.action.name"), null, IconUtil.getAddIcon()) {
public void update(AnActionEvent e) {
final VirtualFile[] selectedFiles = myFileSystemTree.getSelectedFiles();
final Presentation presentation = e.getPresentation();
presentation.setEnabled(isAtLeastOneFileExcluded(selectedFiles));
}
public void actionPerformed(AnActionEvent e) {
final VirtualFile[] selectedFiles = myFileSystemTree.getSelectedFiles();
for (VirtualFile selectedFile : selectedFiles) {
include(selectedFile);
}
myWizard.updateStep();
myFileSystemTree.getTree().repaint();
}
};
}
Aggregations