Search in sources :

Example 26 with DataContext

use of com.intellij.openapi.actionSystem.DataContext in project intellij-community by JetBrains.

the class IpnbMergeCellBelowAction method update.

@Override
public void update(AnActionEvent e) {
    final DataContext context = e.getDataContext();
    final IpnbFileEditor ipnbEditor = IpnbFileEditor.DATA_KEY.getData(context);
    if (ipnbEditor != null) {
        final IpnbFilePanel ipnbFilePanel = ipnbEditor.getIpnbFilePanel();
        final IpnbEditablePanel cell = ipnbFilePanel.getSelectedCellPanel();
        final boolean isEnabled = cell != null && ipnbFilePanel.hasNextCell(cell);
        e.getPresentation().setEnabled(isEnabled);
    }
}
Also used : DataContext(com.intellij.openapi.actionSystem.DataContext) IpnbFilePanel(org.jetbrains.plugins.ipnb.editor.panels.IpnbFilePanel) IpnbFileEditor(org.jetbrains.plugins.ipnb.editor.IpnbFileEditor) IpnbEditablePanel(org.jetbrains.plugins.ipnb.editor.panels.IpnbEditablePanel)

Example 27 with DataContext

use of com.intellij.openapi.actionSystem.DataContext in project intellij-community by JetBrains.

the class IpnbMergeCellBelowAction method actionPerformed.

@Override
public void actionPerformed(AnActionEvent e) {
    final DataContext context = e.getDataContext();
    final IpnbFileEditor ipnbEditor = IpnbFileEditor.DATA_KEY.getData(context);
    if (ipnbEditor != null) {
        final IpnbFilePanel ipnbFilePanel = ipnbEditor.getIpnbFilePanel();
        mergeCell(ipnbFilePanel);
    }
}
Also used : DataContext(com.intellij.openapi.actionSystem.DataContext) IpnbFilePanel(org.jetbrains.plugins.ipnb.editor.panels.IpnbFilePanel) IpnbFileEditor(org.jetbrains.plugins.ipnb.editor.IpnbFileEditor)

Example 28 with DataContext

use of com.intellij.openapi.actionSystem.DataContext in project intellij-community by JetBrains.

the class IpnbMoveCellDownAction method actionPerformed.

@Override
public void actionPerformed(@NotNull AnActionEvent event) {
    final DataContext context = event.getDataContext();
    final FileEditor editor = PlatformDataKeys.FILE_EDITOR.getData(context);
    if (editor instanceof IpnbFileEditor) {
        final IpnbFilePanel ipnbFilePanel = ((IpnbFileEditor) editor).getIpnbFilePanel();
        CommandProcessor.getInstance().executeCommand(ipnbFilePanel.getProject(), () -> ApplicationManager.getApplication().runWriteAction(() -> ipnbFilePanel.moveCell(true)), "Ipnb.moveCell", new Object());
    }
}
Also used : DataContext(com.intellij.openapi.actionSystem.DataContext) FileEditor(com.intellij.openapi.fileEditor.FileEditor) IpnbFileEditor(org.jetbrains.plugins.ipnb.editor.IpnbFileEditor) IpnbFilePanel(org.jetbrains.plugins.ipnb.editor.panels.IpnbFilePanel) IpnbFileEditor(org.jetbrains.plugins.ipnb.editor.IpnbFileEditor)

Example 29 with DataContext

use of com.intellij.openapi.actionSystem.DataContext in project intellij-community by JetBrains.

the class IpnbMoveCellUpAction method actionPerformed.

@Override
public void actionPerformed(@NotNull AnActionEvent event) {
    final DataContext context = event.getDataContext();
    final FileEditor editor = PlatformDataKeys.FILE_EDITOR.getData(context);
    if (editor instanceof IpnbFileEditor) {
        final IpnbFilePanel ipnbFilePanel = ((IpnbFileEditor) editor).getIpnbFilePanel();
        CommandProcessor.getInstance().executeCommand(ipnbFilePanel.getProject(), new Runnable() {

            public void run() {
                ApplicationManager.getApplication().runWriteAction(new Runnable() {

                    public void run() {
                        ipnbFilePanel.moveCell(false);
                    }
                });
            }
        }, "Ipnb.moveCell", new Object());
    }
}
Also used : DataContext(com.intellij.openapi.actionSystem.DataContext) FileEditor(com.intellij.openapi.fileEditor.FileEditor) IpnbFileEditor(org.jetbrains.plugins.ipnb.editor.IpnbFileEditor) IpnbFilePanel(org.jetbrains.plugins.ipnb.editor.panels.IpnbFilePanel) IpnbFileEditor(org.jetbrains.plugins.ipnb.editor.IpnbFileEditor)

Example 30 with DataContext

use of com.intellij.openapi.actionSystem.DataContext in project intellij-community by JetBrains.

the class IpnbPasteCellAction method actionPerformed.

@Override
public void actionPerformed(@NotNull AnActionEvent event) {
    final DataContext context = event.getDataContext();
    final FileEditor editor = PlatformDataKeys.FILE_EDITOR.getData(context);
    if (editor instanceof IpnbFileEditor) {
        final IpnbFilePanel component = ((IpnbFileEditor) editor).getIpnbFilePanel();
        pasteCell(component);
    }
}
Also used : DataContext(com.intellij.openapi.actionSystem.DataContext) FileEditor(com.intellij.openapi.fileEditor.FileEditor) IpnbFileEditor(org.jetbrains.plugins.ipnb.editor.IpnbFileEditor) IpnbFilePanel(org.jetbrains.plugins.ipnb.editor.panels.IpnbFilePanel) IpnbFileEditor(org.jetbrains.plugins.ipnb.editor.IpnbFileEditor)

Aggregations

DataContext (com.intellij.openapi.actionSystem.DataContext)202 Project (com.intellij.openapi.project.Project)71 VirtualFile (com.intellij.openapi.vfs.VirtualFile)28 NotNull (org.jetbrains.annotations.NotNull)23 IpnbFileEditor (org.jetbrains.plugins.ipnb.editor.IpnbFileEditor)23 Editor (com.intellij.openapi.editor.Editor)21 Nullable (org.jetbrains.annotations.Nullable)21 FileEditor (com.intellij.openapi.fileEditor.FileEditor)20 PsiFile (com.intellij.psi.PsiFile)16 IpnbFilePanel (org.jetbrains.plugins.ipnb.editor.panels.IpnbFilePanel)16 Module (com.intellij.openapi.module.Module)13 PsiElement (com.intellij.psi.PsiElement)13 SimpleDataContext (com.intellij.openapi.actionSystem.impl.SimpleDataContext)11 DataManager (com.intellij.ide.DataManager)9 Presentation (com.intellij.openapi.actionSystem.Presentation)9 List (java.util.List)9 AnActionEvent (com.intellij.openapi.actionSystem.AnActionEvent)8 Consumer (com.intellij.util.Consumer)7 AnAction (com.intellij.openapi.actionSystem.AnAction)6 Transferable (java.awt.datatransfer.Transferable)6