Search in sources :

Example 21 with DataContext

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

the class StudyShowHintAction method showHintPopUp.

private static void showHintPopUp(Project project, StudyState studyState, Editor editor, StudyToolWindow hintComponent) {
    final JBPopup popup = JBPopupFactory.getInstance().createComponentPopupBuilder(hintComponent, hintComponent).setDimensionServiceKey(project, "StudyHint", false).setResizable(true).setMovable(true).setRequestFocus(true).setTitle(studyState.getTask().getName()).createPopup();
    Disposer.register(popup, hintComponent);
    final Component focusOwner = IdeFocusManager.getInstance(project).getFocusOwner();
    DataContext dataContext = DataManager.getInstance().getDataContext(focusOwner);
    PopupPositionManager.positionPopupInBestPosition(popup, editor, dataContext);
}
Also used : DataContext(com.intellij.openapi.actionSystem.DataContext) JBPopup(com.intellij.openapi.ui.popup.JBPopup)

Example 22 with DataContext

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

the class IpnbAddCellAboveAction 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();
        addCell(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)

Example 23 with DataContext

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

the class IpnbHeadingCellActionBase 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) {
        changeTypeToHeading((IpnbFileEditor) editor);
    }
}
Also used : DataContext(com.intellij.openapi.actionSystem.DataContext) FileEditor(com.intellij.openapi.fileEditor.FileEditor) IpnbFileEditor(org.jetbrains.plugins.ipnb.editor.IpnbFileEditor) IpnbFileEditor(org.jetbrains.plugins.ipnb.editor.IpnbFileEditor)

Example 24 with DataContext

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

the class IpnbMergeCellAboveAction 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.hasPrevCell(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 25 with DataContext

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

the class IpnbMergeCellAboveAction 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)

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