Search in sources :

Example 1 with SplitFileEditor

use of org.intellij.plugins.markdown.ui.split.SplitFileEditor in project intellij-plugins by JetBrains.

the class BaseChangeSplitLayoutAction method actionPerformed.

@Override
public void actionPerformed(AnActionEvent e) {
    final SplitFileEditor splitFileEditor = MarkdownActionUtil.findSplitEditor(e);
    if (splitFileEditor != null) {
        if (myLayoutToSet == null) {
            splitFileEditor.triggerLayoutChange();
        } else {
            splitFileEditor.triggerLayoutChange(myLayoutToSet);
            e.getPresentation().putClientProperty(SELECTED_PROPERTY, true);
        }
    }
}
Also used : SplitFileEditor(org.intellij.plugins.markdown.ui.split.SplitFileEditor)

Example 2 with SplitFileEditor

use of org.intellij.plugins.markdown.ui.split.SplitFileEditor in project intellij-plugins by JetBrains.

the class BaseChangeSplitLayoutAction method update.

@Override
public void update(AnActionEvent e) {
    final SplitFileEditor splitFileEditor = MarkdownActionUtil.findSplitEditor(e);
    e.getPresentation().setEnabled(splitFileEditor != null);
    if (myLayoutToSet != null && splitFileEditor != null) {
        e.getPresentation().putClientProperty(SELECTED_PROPERTY, splitFileEditor.getCurrentEditorLayout() == myLayoutToSet);
    }
}
Also used : SplitFileEditor(org.intellij.plugins.markdown.ui.split.SplitFileEditor)

Example 3 with SplitFileEditor

use of org.intellij.plugins.markdown.ui.split.SplitFileEditor in project intellij-plugins by JetBrains.

the class MarkdownActionUtil method findMarkdownTextEditor.

@Nullable
public static Editor findMarkdownTextEditor(AnActionEvent e) {
    final SplitFileEditor splitEditor = findSplitEditor(e);
    if (splitEditor == null) {
        // This fallback is used primarily for testing
        final PsiFile psiFile = e.getData(CommonDataKeys.PSI_FILE);
        if (psiFile != null && psiFile.getLanguage() == MarkdownLanguage.INSTANCE && ApplicationManager.getApplication().isUnitTestMode()) {
            return e.getData(CommonDataKeys.EDITOR);
        } else {
            return null;
        }
    }
    if (!(splitEditor.getMainEditor() instanceof TextEditor)) {
        return null;
    }
    final TextEditor mainEditor = (TextEditor) splitEditor.getMainEditor();
    if (!mainEditor.getComponent().isVisible()) {
        return null;
    }
    return mainEditor.getEditor();
}
Also used : TextEditor(com.intellij.openapi.fileEditor.TextEditor) PsiFile(com.intellij.psi.PsiFile) SplitFileEditor(org.intellij.plugins.markdown.ui.split.SplitFileEditor) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

SplitFileEditor (org.intellij.plugins.markdown.ui.split.SplitFileEditor)3 TextEditor (com.intellij.openapi.fileEditor.TextEditor)1 PsiFile (com.intellij.psi.PsiFile)1 Nullable (org.jetbrains.annotations.Nullable)1