Search in sources :

Example 86 with AnActionEvent

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);
}
Also used : Ref(com.intellij.openapi.util.Ref) BalloonLayout(com.intellij.ui.BalloonLayout) NotificationAction(com.intellij.notification.NotificationAction) BalloonLayoutData(com.intellij.ui.BalloonLayoutData) JBColor(com.intellij.ui.JBColor) AnActionEvent(com.intellij.openapi.actionSystem.AnActionEvent) Notification(com.intellij.notification.Notification)

Example 87 with AnActionEvent

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);
}
Also used : AnActionEvent(com.intellij.openapi.actionSystem.AnActionEvent) AnAction(com.intellij.openapi.actionSystem.AnAction)

Example 88 with AnActionEvent

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);
            }
        }
    };
}
Also used : AnActionEvent(com.intellij.openapi.actionSystem.AnActionEvent) AnAction(com.intellij.openapi.actionSystem.AnAction) BaseInjection(org.intellij.plugins.intelliLang.inject.config.BaseInjection)

Example 89 with AnActionEvent

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);
            }
        }
    };
}
Also used : MethodParameterInjection(org.intellij.plugins.intelliLang.inject.config.MethodParameterInjection) AnActionEvent(com.intellij.openapi.actionSystem.AnActionEvent) AnAction(com.intellij.openapi.actionSystem.AnAction) BaseInjection(org.intellij.plugins.intelliLang.inject.config.BaseInjection)

Example 90 with AnActionEvent

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);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) EnforcedPlainTextFileTypeManager(com.intellij.openapi.file.exclude.EnforcedPlainTextFileTypeManager) DumbAwareAction(com.intellij.openapi.project.DumbAwareAction) FileTypeManager(com.intellij.openapi.fileTypes.FileTypeManager) JBIterable(com.intellij.util.containers.JBIterable) VfsUtilCore(com.intellij.openapi.vfs.VfsUtilCore) VirtualFile(com.intellij.openapi.vfs.VirtualFile) AnActionEvent(com.intellij.openapi.actionSystem.AnActionEvent) Project(com.intellij.openapi.project.Project) Set(java.util.Set) CommonDataKeys(com.intellij.openapi.actionSystem.CommonDataKeys) FileType(com.intellij.openapi.fileTypes.FileType) ActionsBundle(com.intellij.idea.ActionsBundle) FileType(com.intellij.openapi.fileTypes.FileType) EnforcedPlainTextFileTypeManager(com.intellij.openapi.file.exclude.EnforcedPlainTextFileTypeManager) EnforcedPlainTextFileTypeManager(com.intellij.openapi.file.exclude.EnforcedPlainTextFileTypeManager) FileTypeManager(com.intellij.openapi.fileTypes.FileTypeManager)

Aggregations

AnActionEvent (com.intellij.openapi.actionSystem.AnActionEvent)130 AnAction (com.intellij.openapi.actionSystem.AnAction)67 Project (com.intellij.openapi.project.Project)27 NotNull (org.jetbrains.annotations.NotNull)25 DumbAwareAction (com.intellij.openapi.project.DumbAwareAction)22 VirtualFile (com.intellij.openapi.vfs.VirtualFile)21 Nullable (org.jetbrains.annotations.Nullable)20 DefaultActionGroup (com.intellij.openapi.actionSystem.DefaultActionGroup)15 List (java.util.List)14 CustomShortcutSet (com.intellij.openapi.actionSystem.CustomShortcutSet)13 ArrayList (java.util.ArrayList)11 Presentation (com.intellij.openapi.actionSystem.Presentation)10 StringUtil (com.intellij.openapi.util.text.StringUtil)9 CommonDataKeys (com.intellij.openapi.actionSystem.CommonDataKeys)8 JBTable (com.intellij.ui.table.JBTable)8 DataContext (com.intellij.openapi.actionSystem.DataContext)7 Pair (com.intellij.openapi.util.Pair)7 Logger (com.intellij.openapi.diagnostic.Logger)6 Ref (com.intellij.openapi.util.Ref)6 AnActionButton (com.intellij.ui.AnActionButton)6