Search in sources :

Example 6 with EditorMarkupModel

use of com.intellij.openapi.editor.ex.EditorMarkupModel in project intellij-community by JetBrains.

the class FontEditorPreview method installTrafficLights.

static void installTrafficLights(@NotNull EditorEx editor) {
    TrafficLightRenderer renderer = new TrafficLightRenderer(null, null, null) {

        @NotNull
        @Override
        protected DaemonCodeAnalyzerStatus getDaemonCodeAnalyzerStatus(@NotNull SeverityRegistrar severityRegistrar) {
            DaemonCodeAnalyzerStatus status = new DaemonCodeAnalyzerStatus();
            status.errorAnalyzingFinished = true;
            status.errorCount = new int[] { 1, 2 };
            return status;
        }
    };
    Disposer.register((Disposable) editor.getCaretModel(), renderer);
    ((EditorMarkupModel) editor.getMarkupModel()).setErrorStripeRenderer(renderer);
    ((EditorMarkupModel) editor.getMarkupModel()).setErrorStripeVisible(true);
}
Also used : TrafficLightRenderer(com.intellij.codeInsight.daemon.impl.TrafficLightRenderer) SeverityRegistrar(com.intellij.codeInsight.daemon.impl.SeverityRegistrar) NotNull(org.jetbrains.annotations.NotNull) EditorMarkupModel(com.intellij.openapi.editor.ex.EditorMarkupModel)

Example 7 with EditorMarkupModel

use of com.intellij.openapi.editor.ex.EditorMarkupModel in project intellij-community by JetBrains.

the class DiffPanelImpl method onContentChangedIn.

public void onContentChangedIn(EditorSource source) {
    myDiffUpdater.contentRemoved(source);
    final EditorEx editor = source.getEditor();
    if (myIsHorizontal && source.getSide() == FragmentSide.SIDE1 && editor != null) {
        editor.setVerticalScrollbarOrientation(EditorEx.VERTICAL_SCROLLBAR_LEFT);
    }
    DiffSideView viewSide = getSideView(source.getSide());
    viewSide.setEditorSource(getProject(), source);
    Disposer.dispose(myScrollSupport);
    if (editor == null) {
        if (!myDisposed) {
            rediff();
        }
        return;
    }
    final MouseListener mouseListener = PopupHandler.installUnknownPopupHandler(editor.getContentComponent(), new MergeActionGroup(this, source.getSide()), ActionManager.getInstance());
    myDiffUpdater.contentAdded(source);
    editor.getSettings().setLineNumbersShown(true);
    editor.getSettings().setFoldingOutlineShown(false);
    editor.getFoldingModel().setFoldingEnabled(false);
    ((EditorMarkupModel) editor.getMarkupModel()).setErrorStripeVisible(true);
    Editor editor1 = getEditor(FragmentSide.SIDE1);
    Editor editor2 = getEditor(FragmentSide.SIDE2);
    if (editor1 != null && editor2 != null && myIsSyncScroll) {
        myScrollSupport.install(new EditingSides[] { this });
    }
    final VisibleAreaListener visibleAreaListener = mySplitter.getVisibleAreaListener();
    final ScrollingModel scrollingModel = editor.getScrollingModel();
    if (visibleAreaListener != null) {
        scrollingModel.addVisibleAreaListener(visibleAreaListener);
        scrollingModel.addVisibleAreaListener(myVisibleAreaListener);
    }
    myFontSizeSynchronizer.synchronize(editor);
    source.addDisposable(new Disposable() {

        public void dispose() {
            myFontSizeSynchronizer.stopSynchronize(editor);
        }
    });
    source.addDisposable(new Disposable() {

        public void dispose() {
            if (visibleAreaListener != null) {
                scrollingModel.removeVisibleAreaListener(visibleAreaListener);
                scrollingModel.removeVisibleAreaListener(myVisibleAreaListener);
            }
            editor.getContentComponent().removeMouseListener(mouseListener);
        }
    });
}
Also used : Disposable(com.intellij.openapi.Disposable) EditorEx(com.intellij.openapi.editor.ex.EditorEx) MouseListener(java.awt.event.MouseListener) ScrollingModel(com.intellij.openapi.editor.ScrollingModel) VisibleAreaListener(com.intellij.openapi.editor.event.VisibleAreaListener) Editor(com.intellij.openapi.editor.Editor) EditorMarkupModel(com.intellij.openapi.editor.ex.EditorMarkupModel) MergeActionGroup(com.intellij.openapi.diff.actions.MergeActionGroup)

Example 8 with EditorMarkupModel

use of com.intellij.openapi.editor.ex.EditorMarkupModel in project intellij-community by JetBrains.

the class TextEditorComponent method createEditor.

@NotNull
private Editor createEditor() {
    Editor editor = EditorFactory.getInstance().createEditor(myDocument, myProject);
    ((EditorMarkupModel) editor.getMarkupModel()).setErrorStripeVisible(true);
    ((EditorEx) editor).getGutterComponentEx().setForceShowRightFreePaintersArea(true);
    ((EditorEx) editor).setFile(myFile);
    ((EditorEx) editor).setContextMenuGroupId(IdeActions.GROUP_EDITOR_POPUP);
    ((EditorImpl) editor).setDropHandler(new FileDropHandler(editor));
    TextEditorProvider.putTextEditor(editor, myTextEditor);
    return editor;
}
Also used : EditorEx(com.intellij.openapi.editor.ex.EditorEx) EditorImpl(com.intellij.openapi.editor.impl.EditorImpl) Editor(com.intellij.openapi.editor.Editor) FileEditor(com.intellij.openapi.fileEditor.FileEditor) EditorMarkupModel(com.intellij.openapi.editor.ex.EditorMarkupModel) NotNull(org.jetbrains.annotations.NotNull)

Example 9 with EditorMarkupModel

use of com.intellij.openapi.editor.ex.EditorMarkupModel in project intellij-community by JetBrains.

the class EmmetPreviewHint method createHint.

@NotNull
public static EmmetPreviewHint createHint(@NotNull final EditorEx parentEditor, @NotNull String templateText, @NotNull FileType fileType) {
    EditorFactory editorFactory = EditorFactory.getInstance();
    Document document = editorFactory.createDocument(templateText);
    final EditorEx previewEditor = (EditorEx) editorFactory.createEditor(document, parentEditor.getProject(), fileType, true);
    MarkupModelEx model = previewEditor.getMarkupModel();
    if (model instanceof EditorMarkupModel) {
        ((EditorMarkupModel) model).setErrorStripeVisible(true);
    }
    final EditorSettings settings = previewEditor.getSettings();
    settings.setLineNumbersShown(false);
    settings.setAdditionalLinesCount(1);
    settings.setAdditionalColumnsCount(1);
    settings.setRightMarginShown(false);
    settings.setFoldingOutlineShown(false);
    settings.setLineMarkerAreaShown(false);
    settings.setIndentGuidesShown(false);
    settings.setVirtualSpace(false);
    settings.setWheelFontChangeEnabled(false);
    settings.setAdditionalPageAtBottom(false);
    settings.setCaretRowShown(false);
    previewEditor.setCaretEnabled(false);
    previewEditor.setBorder(IdeBorderFactory.createEmptyBorder());
    JBPanel panel = new JBPanel(new BorderLayout()) {

        @NotNull
        @Override
        public Dimension getPreferredSize() {
            Dimension size = super.getPreferredSize();
            Dimension parentEditorSize = parentEditor.getScrollPane().getSize();
            int maxWidth = (int) parentEditorSize.getWidth() / 3;
            int maxHeight = (int) parentEditorSize.getHeight() / 2;
            final int width = settings.isUseSoftWraps() ? maxWidth : Math.min((int) size.getWidth(), maxWidth);
            final int height = Math.min((int) size.getHeight(), maxHeight);
            return new Dimension(width, height);
        }

        @NotNull
        @Override
        public Insets getInsets() {
            return new Insets(1, 2, 0, 0);
        }
    };
    panel.setBackground(previewEditor.getBackgroundColor());
    panel.add(previewEditor.getComponent(), BorderLayout.CENTER);
    return new EmmetPreviewHint(panel, previewEditor, parentEditor);
}
Also used : EditorEx(com.intellij.openapi.editor.ex.EditorEx) MarkupModelEx(com.intellij.openapi.editor.ex.MarkupModelEx) EditorMarkupModel(com.intellij.openapi.editor.ex.EditorMarkupModel) JBPanel(com.intellij.ui.components.JBPanel) HintHint(com.intellij.ui.HintHint) LightweightHint(com.intellij.ui.LightweightHint) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

EditorMarkupModel (com.intellij.openapi.editor.ex.EditorMarkupModel)9 EditorEx (com.intellij.openapi.editor.ex.EditorEx)4 NotNull (org.jetbrains.annotations.NotNull)4 Editor (com.intellij.openapi.editor.Editor)3 HintHint (com.intellij.ui.HintHint)2 SeverityRegistrar (com.intellij.codeInsight.daemon.impl.SeverityRegistrar)1 TrafficLightRenderer (com.intellij.codeInsight.daemon.impl.TrafficLightRenderer)1 TooltipController (com.intellij.codeInsight.hint.TooltipController)1 TextEditorHolder (com.intellij.diff.tools.holders.TextEditorHolder)1 Disposable (com.intellij.openapi.Disposable)1 Application (com.intellij.openapi.application.Application)1 MergeActionGroup (com.intellij.openapi.diff.actions.MergeActionGroup)1 ScrollingModel (com.intellij.openapi.editor.ScrollingModel)1 VisibleAreaListener (com.intellij.openapi.editor.event.VisibleAreaListener)1 MarkupModelEx (com.intellij.openapi.editor.ex.MarkupModelEx)1 EditorImpl (com.intellij.openapi.editor.impl.EditorImpl)1 FileEditor (com.intellij.openapi.fileEditor.FileEditor)1 Pair (com.intellij.openapi.util.Pair)1 LightweightHint (com.intellij.ui.LightweightHint)1 RelativePoint (com.intellij.ui.awt.RelativePoint)1