use of com.intellij.openapi.actionSystem.AnActionEvent in project intellij-community by JetBrains.
the class IdeMessagePanel method showErrorNotification.
private void showErrorNotification(@Nullable String notificationText, @NotNull Project project) {
Notification notification = new Notification("", AllIcons.Ide.FatalError, notificationText == null ? ERROR_TITLE : "", null, notificationText == null ? "" : notificationText, NotificationType.ERROR, null);
if (notificationText == null) {
notification.addAction(new NotificationAction(ERROR_LINK) {
@Override
public void actionPerformed(@NotNull AnActionEvent e, @NotNull Notification notification) {
notification.expire();
_openFatals(null);
}
});
}
BalloonLayout layout = myFrame.getBalloonLayout();
assert layout != null;
BalloonLayoutData layoutData = BalloonLayoutData.createEmpty();
layoutData.fadeoutTime = 5000;
layoutData.fillColor = new JBColor(0XF5E6E7, 0X593D41);
layoutData.borderColor = new JBColor(0XE0A8A9, 0X73454B);
assert myBalloon == null;
myBalloon = NotificationsManagerImpl.createBalloon(myFrame, notification, false, false, new Ref<>(layoutData), project);
Disposer.register(myBalloon, () -> myBalloon = null);
layout.add(myBalloon);
}
use of com.intellij.openapi.actionSystem.AnActionEvent in project intellij-community by JetBrains.
the class TabbedPaneImpl method installKeyboardNavigation.
@SuppressWarnings({ "NonStaticInitializer" })
private void installKeyboardNavigation(final PrevNextActionsDescriptor installKeyboardNavigation) {
myNextTabAction = new AnAction() {
{
setEnabledInModalContext(true);
}
@Override
public void actionPerformed(final AnActionEvent e) {
int index = getSelectedIndex() + 1;
if (index >= getTabCount()) {
index = 0;
}
setSelectedIndex(index);
}
};
final AnAction nextAction = ActionManager.getInstance().getAction(installKeyboardNavigation.getNextActionId());
LOG.assertTrue(nextAction != null, "Cannot find action with specified id: " + installKeyboardNavigation.getNextActionId());
myNextTabAction.registerCustomShortcutSet(nextAction.getShortcutSet(), this);
myPreviousTabAction = new AnAction() {
{
setEnabledInModalContext(true);
}
@Override
public void actionPerformed(final AnActionEvent e) {
int index = getSelectedIndex() - 1;
if (index < 0) {
index = getTabCount() - 1;
}
setSelectedIndex(index);
}
};
final AnAction prevAction = ActionManager.getInstance().getAction(installKeyboardNavigation.getPrevActionId());
LOG.assertTrue(prevAction != null, "Cannot find action with specified id: " + installKeyboardNavigation.getPrevActionId());
myPreviousTabAction.registerCustomShortcutSet(prevAction.getShortcutSet(), this);
}
use of com.intellij.openapi.actionSystem.AnActionEvent in project intellij-community by JetBrains.
the class AbstractLanguageInjectionSupport method createDefaultEditAction.
public static AnAction createDefaultEditAction(final Project project, final Factory<BaseInjection> producer) {
return new AnAction() {
@Override
public void actionPerformed(AnActionEvent e) {
final BaseInjection originalInjection = producer.create();
final BaseInjection newInjection = showDefaultInjectionUI(project, originalInjection.copy());
if (newInjection != null) {
originalInjection.copyFrom(newInjection);
}
}
};
}
use of com.intellij.openapi.actionSystem.AnActionEvent in project intellij-community by JetBrains.
the class JavaLanguageInjectionSupport method createEditAction.
@Override
public AnAction createEditAction(final Project project, final Factory<BaseInjection> producer) {
return new AnAction() {
@Override
public void actionPerformed(final AnActionEvent e) {
final BaseInjection originalInjection = producer.create();
final MethodParameterInjection injection = createFrom(project, originalInjection, null, false);
if (injection != null) {
final boolean mergeEnabled = !project.isInitialized() || JavaPsiFacade.getInstance(project).findClass(injection.getClassName(), GlobalSearchScope.allScope(project)) == null;
final BaseInjection newInjection = showInjectionUI(project, injection);
if (newInjection != null) {
newInjection.mergeOriginalPlacesFrom(originalInjection, mergeEnabled);
originalInjection.copyFrom(newInjection);
}
} else {
createDefaultEditAction(project, producer).actionPerformed(null);
}
}
};
}
use of com.intellij.openapi.actionSystem.AnActionEvent in project intellij-community by JetBrains.
the class MarkAsOriginalTypeAction method update.
@Override
public void update(AnActionEvent e) {
EnforcedPlainTextFileTypeManager typeManager = EnforcedPlainTextFileTypeManager.getInstance();
JBIterable<VirtualFile> selectedFiles = JBIterable.of(e.getData(CommonDataKeys.VIRTUAL_FILE_ARRAY)).filter(file -> !file.isDirectory() && typeManager.isMarkedAsPlainText(file));
FileTypeManager fileTypeManager = FileTypeManager.getInstance();
boolean enabled = e.getProject() != null && !selectedFiles.isEmpty();
Set<FileType> fileTypes = selectedFiles.map(file -> fileTypeManager.getFileTypeByFileName(file.getName())).toSet();
if (fileTypes.size() == 1) {
FileType original = fileTypes.iterator().next();
String originalName = original.getName();
String text = ActionsBundle.actionText("MarkAsOriginalTypeAction").replace("Original File Type", originalName);
e.getPresentation().setText(text);
e.getPresentation().setIcon(original.getIcon());
}
e.getPresentation().setEnabledAndVisible(enabled);
}
Aggregations