Java 类com.intellij.openapi.editor.ex.EditorMarkupModel 实例源码

项目:intellij-ce-playground    文件:ThreesideTextDiffViewer.java   
@NotNull
@Override
protected List<TextEditorHolder> createEditorHolders(@NotNull EditorHolderFactory<TextEditorHolder> factory) {
  List<TextEditorHolder> holders = super.createEditorHolders(factory);

  boolean[] forceReadOnly = TextDiffViewerUtil.checkForceReadOnly(myContext, myRequest);
  for (int i = 0; i < 3; i++) {
    if (forceReadOnly[i]) holders.get(i).getEditor().setViewer(true);
  }

  ThreeSide.LEFT.select(holders).getEditor().setVerticalScrollbarOrientation(EditorEx.VERTICAL_SCROLLBAR_LEFT);
  ((EditorMarkupModel)ThreeSide.BASE.select(holders).getEditor().getMarkupModel()).setErrorStripeVisible(false);

  if (Registry.is("diff.divider.repainting.disable.blitting")) {
    for (TextEditorHolder holder : holders) {
      holder.getEditor().getScrollPane().getViewport().setScrollMode(JViewport.SIMPLE_SCROLL_MODE);
    }
  }

  return holders;
}
项目:intellij-ce-playground    文件:DiffUtil.java   
@NotNull
public static EditorEx createEditor(@NotNull Document document, @Nullable Project project, boolean isViewer, boolean enableFolding) {
  EditorFactory factory = EditorFactory.getInstance();
  EditorEx editor = (EditorEx)(isViewer ? factory.createViewer(document, project) : factory.createEditor(document, project));

  editor.putUserData(DiffManagerImpl.EDITOR_IS_DIFF_KEY, Boolean.TRUE);

  editor.getSettings().setLineNumbersShown(true);
  ((EditorMarkupModel)editor.getMarkupModel()).setErrorStripeVisible(true);
  editor.getGutterComponentEx().setShowDefaultGutterPopup(false);

  if (enableFolding) {
    setFoldingModelSupport(editor);
  } else {
    editor.getSettings().setFoldingOutlineShown(false);
    editor.getFoldingModel().setFoldingEnabled(false);
  }

  UIUtil.removeScrollBorder(editor.getComponent());

  return editor;
}
项目:intellij-ce-playground    文件:MergePanel2.java   
@Nullable
public EditorEx createEditor() {
  Document document = getDocument();
  if (document == null) return null;
  Project project = myData.getProject();
  EditorEx editor = DiffUtil.createEditor(document, project, myIndex != 1);

  if (editor == null) return editor;
  //FileType type = getFileType();
  //editor.setHighlighter(HighlighterFactory.createHighlighter(project, type));
  if (myIndex == 0) editor.setVerticalScrollbarOrientation(EditorEx.VERTICAL_SCROLLBAR_LEFT);
  if (myIndex != 1) ((EditorMarkupModel)editor.getMarkupModel()).setErrorStripeVisible(true);
  editor.getSettings().setFoldingOutlineShown(false);
  editor.getFoldingModel().setFoldingEnabled(false);
  editor.getSettings().setLineMarkerAreaShown(false);
  editor.getSettings().setFoldingOutlineShown(false);
  editor.getGutterComponentEx().setShowDefaultGutterPopup(false);
  initEditorSettings(editor);

  return editor;
}
项目:intellij-ce-playground    文件:TrafficLightRenderer.java   
static void setOrRefreshErrorStripeRenderer(@NotNull EditorMarkupModel editorMarkupModel,
                                            @NotNull Project project,
                                            @NotNull Document document,
                                            PsiFile file) {
  ApplicationManager.getApplication().assertIsDispatchThread();
  if (!editorMarkupModel.isErrorStripeVisible() || !DaemonCodeAnalyzer.getInstance(project).isHighlightingAvailable(file)) {
    return;
  }
  ErrorStripeRenderer renderer = editorMarkupModel.getErrorStripeRenderer();
  if (renderer instanceof TrafficLightRenderer) {
    TrafficLightRenderer tlr = (TrafficLightRenderer)renderer;
    tlr.refresh();
    ((EditorMarkupModelImpl)editorMarkupModel).repaintVerticalScrollBar();
    if (tlr.myFile == null || tlr.myFile.isValid()) return;
    Disposer.dispose(tlr);
  }
  EditorImpl editor = (EditorImpl)editorMarkupModel.getEditor();

  if (!editor.isDisposed()) {
    renderer = new TrafficLightRenderer(project, document, file);
    Disposer.register(editor.getDisposable(), (Disposable)renderer);
    editorMarkupModel.setErrorStripeRenderer(renderer);
  }
}
项目:tools-idea    文件:TextEditorComponent.java   
/**
 * @return created editor. This editor should be released by {@link #disposeEditor(Editor) }
 * method.
 */
@NotNull
private Editor createEditor(){
  Editor editor = EditorFactory.getInstance().createEditor(myDocument, myProject);
  ((EditorMarkupModel) editor.getMarkupModel()).setErrorStripeVisible(true);
  EditorHighlighter highlighter = EditorHighlighterFactory.getInstance().createEditorHighlighter(myFile, EditorColorsManager.getInstance().getGlobalScheme(), myProject);
  ((EditorEx) editor).setHighlighter(highlighter);
  ((EditorEx) editor).setFile(myFile);

  editor.addEditorMouseListener(myEditorMouseListener);

  ((EditorImpl) editor).setDropHandler(new FileDropHandler(editor));

  TextEditorProvider.putTextEditor(editor, myTextEditor);
  return editor;
}
项目:tools-idea    文件:MergePanel2.java   
@Nullable
public EditorEx createEditor() {
  Document document = getDocument();
  if (document == null) return null;
  Project project = myData.getProject();
  EditorEx editor = DiffUtil.createEditor(document, project, myIndex != 1);

  if (editor == null) return editor;
  //FileType type = getFileType();
  //editor.setHighlighter(HighlighterFactory.createHighlighter(project, type));
  if (myIndex == 0) editor.setVerticalScrollbarOrientation(EditorEx.VERTICAL_SCROLLBAR_LEFT);
  if (myIndex != 1) ((EditorMarkupModel)editor.getMarkupModel()).setErrorStripeVisible(true);
  editor.getSettings().setFoldingOutlineShown(false);
  editor.getFoldingModel().setFoldingEnabled(false);
  editor.getSettings().setLineMarkerAreaShown(false);
  editor.getSettings().setFoldingOutlineShown(false);
  editor.getGutterComponentEx().setShowDefaultGutterPopup(false);
  initEditorSettings(editor);

  return editor;
}
项目:tools-idea    文件:EventLogConsole.java   
private Editor createLogEditor() {
  Project project = myProjectModel.getProject();
  final Editor editor = ConsoleViewUtil.setupConsoleEditor(project, false, false);
  Disposer.register(myProjectModel, new Disposable() {
    @Override
    public void dispose() {
      EditorFactory.getInstance().releaseEditor(editor);
    }
  });

  ((EditorMarkupModel)editor.getMarkupModel()).setErrorStripeVisible(true);

  final ClearLog clearLog = new ClearLog();
  clearLog.registerCustomShortcutSet(ActionManager.getInstance().getAction(IdeActions.CONSOLE_CLEAR_ALL).getShortcutSet(), editor.getContentComponent());

  editor.addEditorMouseListener(new EditorPopupHandler() {
    public void invokePopup(final EditorMouseEvent event) {
      final ActionManager actionManager = ActionManager.getInstance();
      final ActionPopupMenu menu = actionManager.createActionPopupMenu(ActionPlaces.EDITOR_POPUP, createPopupActions(actionManager, clearLog));
      final MouseEvent mouseEvent = event.getMouseEvent();
      menu.getComponent().show(mouseEvent.getComponent(), mouseEvent.getX(), mouseEvent.getY());
    }
  });
  return editor;
}
项目:tools-idea    文件:PsiChangeHandler.java   
private void updateChangesForDocument(@NotNull final Document document) {
  if (DaemonListeners.isUnderIgnoredAction(null)) return;
  List<Pair<PsiElement, Boolean>> toUpdate = changedElements.get(document);
  if (toUpdate == null) return;
  Application application = ApplicationManager.getApplication();
  final Editor editor = FileEditorManager.getInstance(myProject).getSelectedTextEditor();
  if (editor != null && !application.isUnitTestMode()) {
    application.invokeLater(new Runnable() {
      @Override
      public void run() {
        EditorMarkupModel markupModel = (EditorMarkupModel)editor.getMarkupModel();
        PsiFile file = PsiDocumentManager.getInstance(myProject).getPsiFile(editor.getDocument());
        TrafficLightRenderer.setOrRefreshErrorStripeRenderer(markupModel, myProject, editor.getDocument(), file);
      }
    }, ModalityState.stateForComponent(editor.getComponent()), myProject.getDisposed());
  }

  for (Pair<PsiElement, Boolean> changedElement : toUpdate) {
    PsiElement element = changedElement.getFirst();
    Boolean whiteSpaceOptimizationAllowed = changedElement.getSecond();
    updateByChange(element, document, whiteSpaceOptimizationAllowed);
  }
  changedElements.remove(document);
}
项目:tools-idea    文件:TrafficLightRenderer.java   
public static void setOrRefreshErrorStripeRenderer(@NotNull EditorMarkupModel editorMarkupModel,
                                                   @NotNull Project project,
                                                   @NotNull Document document,
                                                   PsiFile file) {
  ApplicationManager.getApplication().assertIsDispatchThread();
  if (!editorMarkupModel.isErrorStripeVisible() || !DaemonCodeAnalyzer.getInstance(project).isHighlightingAvailable(file)) {
    return;
  }
  ErrorStripeRenderer renderer = editorMarkupModel.getErrorStripeRenderer();
  if (renderer instanceof TrafficLightRenderer) {
    TrafficLightRenderer tlr = (TrafficLightRenderer)renderer;
    tlr.refresh();
    ((EditorMarkupModelImpl)editorMarkupModel).repaintVerticalScrollBar();
    if (tlr.myFile == null || tlr.myFile.isValid()) return;
    Disposer.dispose(tlr);
  }
  renderer = new TrafficLightRenderer(project, document, file);
  Disposer.register(((EditorImpl)editorMarkupModel.getEditor()).getDisposable(), (Disposable)renderer);
  editorMarkupModel.setErrorStripeRenderer(renderer);
}
项目:consulo    文件:ThreesideTextDiffViewer.java   
@Nonnull
@Override
protected List<TextEditorHolder> createEditorHolders(@Nonnull EditorHolderFactory<TextEditorHolder> factory) {
  List<TextEditorHolder> holders = super.createEditorHolders(factory);

  boolean[] forceReadOnly = TextDiffViewerUtil.checkForceReadOnly(myContext, myRequest);
  for (int i = 0; i < 3; i++) {
    if (forceReadOnly[i]) holders.get(i).getEditor().setViewer(true);
  }

  ThreeSide.LEFT.select(holders).getEditor().setVerticalScrollbarOrientation(EditorEx.VERTICAL_SCROLLBAR_LEFT);
  ((EditorMarkupModel)ThreeSide.BASE.select(holders).getEditor().getMarkupModel()).setErrorStripeVisible(false);

  for (TextEditorHolder holder : holders) {
    DiffUtil.disableBlitting(holder.getEditor());
  }

  return holders;
}
项目:consulo    文件:DiffUtil.java   
@Nonnull
public static EditorEx createEditor(@Nonnull Document document, @Nullable Project project, boolean isViewer, boolean enableFolding) {
  EditorFactory factory = EditorFactory.getInstance();
  EditorEx editor = (EditorEx)(isViewer ? factory.createViewer(document, project) : factory.createEditor(document, project));

  editor.putUserData(DiffManagerImpl.EDITOR_IS_DIFF_KEY, Boolean.TRUE);

  editor.getSettings().setShowIntentionBulb(false);
  ((EditorMarkupModel)editor.getMarkupModel()).setErrorStripeVisible(true);
  editor.getGutterComponentEx().setShowDefaultGutterPopup(false);

  if (enableFolding) {
    setFoldingModelSupport(editor);
  } else {
    editor.getSettings().setFoldingOutlineShown(false);
    editor.getFoldingModel().setFoldingEnabled(false);
  }

  UIUtil.removeScrollBorder(editor.getComponent());

  return editor;
}
项目:consulo    文件:MergePanel2.java   
@Nullable
public EditorEx createEditor() {
  Document document = getDocument();
  if (document == null) return null;
  Project project = myData.getProject();
  EditorEx editor = DiffUtil.createEditor(document, project, myIndex != 1);

  if (editor == null) return editor;
  //FileType type = getFileType();
  //editor.setHighlighter(HighlighterFactory.createHighlighter(project, type));
  if (myIndex == 0) editor.setVerticalScrollbarOrientation(EditorEx.VERTICAL_SCROLLBAR_LEFT);
  if (myIndex != 1) ((EditorMarkupModel)editor.getMarkupModel()).setErrorStripeVisible(true);
  editor.getSettings().setFoldingOutlineShown(false);
  editor.getFoldingModel().setFoldingEnabled(false);
  editor.getSettings().setLineMarkerAreaShown(false);
  editor.getSettings().setFoldingOutlineShown(false);
  editor.getGutterComponentEx().setShowDefaultGutterPopup(false);
  initEditorSettings(editor);

  return editor;
}
项目:consulo    文件:TrafficLightRenderer.java   
@RequiredDispatchThread
static void setOrRefreshErrorStripeRenderer(@Nonnull EditorMarkupModel editorMarkupModel,
                                            @Nonnull Project project,
                                            @Nonnull Document document,
                                            PsiFile file) {
  ApplicationManager.getApplication().assertIsDispatchThread();
  if (!editorMarkupModel.isErrorStripeVisible() || !DaemonCodeAnalyzer.getInstance(project).isHighlightingAvailable(file)) {
    return;
  }
  ErrorStripeRenderer renderer = editorMarkupModel.getErrorStripeRenderer();
  if (renderer instanceof TrafficLightRenderer) {
    TrafficLightRenderer tlr = (TrafficLightRenderer)renderer;
    tlr.refresh();
    ((EditorMarkupModelImpl)editorMarkupModel).repaintVerticalScrollBar();
    if (tlr.myFile == null || tlr.myFile.isValid()) return;
    Disposer.dispose(tlr);
  }
  EditorImpl editor = (EditorImpl)editorMarkupModel.getEditor();

  if (!editor.isDisposed()) {
    renderer = new TrafficLightRenderer(project, document, file);
    Disposer.register(editor.getDisposable(), (Disposable)renderer);
    editorMarkupModel.setErrorStripeRenderer(renderer);
  }
}
项目:MultiHighlight    文件:ColorPreviewPanel.java   
public ColorPreviewPanel() {
    final EditorFactory editorFactory = EditorFactory.getInstance();
    myEditor = (EditorEx) editorFactory.createViewer(editorFactory.createDocument(""));

    final EditorSettings settings = myEditor.getSettings();
    settings.setLineNumbersShown(true);
    settings.setWhitespacesShown(true);
    settings.setLineMarkerAreaShown(false);
    settings.setIndentGuidesShown(false);
    settings.setFoldingOutlineShown(false);
    settings.setAdditionalColumnsCount(0);
    settings.setAdditionalLinesCount(0);
    settings.setRightMarginShown(true);
    settings.setRightMargin(60);

    /** {@link FontEditorPreview#installTrafficLights(EditorEx)} */
    TrafficLightRenderer renderer = new TrafficLightRenderer(null, null, null) {

        private final DaemonCodeAnalyzerStatus status = new DaemonCodeAnalyzerStatus();

        {
            status.errorAnalyzingFinished = true;
            status.errorCount = new int[]{ 0 };
        }

        @NotNull
        @Override
        protected DaemonCodeAnalyzerStatus getDaemonCodeAnalyzerStatus(
                @NotNull SeverityRegistrar severityRegistrar) {
            return status;
        }
    };

    Disposer.register((Disposable) myEditor.getCaretModel(), renderer);
    EditorMarkupModel markupModel = (EditorMarkupModel) myEditor.getMarkupModel();
    markupModel.setErrorStripeRenderer(renderer);
    markupModel.setErrorStripeVisible(true);
}
项目:intellij-ce-playground    文件:TextEditorComponent.java   
@NotNull
private Editor createEditor(){
  Editor editor = EditorFactory.getInstance().createEditor(myDocument, myProject);
  ((EditorMarkupModel) editor.getMarkupModel()).setErrorStripeVisible(true);
  EditorHighlighter highlighter = EditorHighlighterFactory.getInstance().createEditorHighlighter(myFile, EditorColorsManager.getInstance().getGlobalScheme(), myProject);
  ((EditorEx) editor).setHighlighter(highlighter);
  ((EditorEx) editor).setFile(myFile);

  ((EditorEx)editor).setContextMenuGroupId(IdeActions.GROUP_EDITOR_POPUP);

  ((EditorImpl) editor).setDropHandler(new FileDropHandler(editor));

  TextEditorProvider.putTextEditor(editor, myTextEditor);
  return editor;
}
项目:intellij-ce-playground    文件:DaemonListeners.java   
static void repaintErrorStripeRenderer(@NotNull Editor editor, @NotNull Project project) {
  ApplicationManager.getApplication().assertIsDispatchThread();
  if (!project.isInitialized()) return;
  final Document document = editor.getDocument();
  final PsiFile psiFile = PsiDocumentManager.getInstance(project).getPsiFile(document);
  final EditorMarkupModel markup = (EditorMarkupModel)editor.getMarkupModel();
  markup.setErrorPanelPopupHandler(new DaemonEditorPopup(psiFile));
  markup.setErrorStripTooltipRendererProvider(new DaemonTooltipRendererProvider(project));
  markup.setMinMarkHeight(DaemonCodeAnalyzerSettings.getInstance().ERROR_STRIPE_MARK_MIN_HEIGHT);
  TrafficLightRenderer.setOrRefreshErrorStripeRenderer(markup, project, document, psiFile);
}
项目:intellij-ce-playground    文件:FontEditorPreview.java   
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);
}
项目:intellij-ce-playground    文件:ConsoleGutterComponent.java   
@Override
public void mouseMoved(MouseEvent e) {
  int line = EditorUtil.yPositionToLogicalLine(editor, e.getPoint());
  if (line == lastGutterToolTipLine) {
    return;
  }

  TooltipController controller = TooltipController.getInstance();
  if (lastGutterToolTipLine != -1) {
    controller.cancelTooltip(TOOLTIP_GROUP, e, true);
  }

  String toolTip = gutterContentProvider.getToolTip(line, editor);
  setCursor(toolTip == null ? Cursor.getDefaultCursor() : Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
  if (toolTip == null) {
    lastGutterToolTipLine = -1;
    controller.cancelTooltip(TOOLTIP_GROUP, e, false);
  }
  else {
    lastGutterToolTipLine = line;
    RelativePoint showPoint = new RelativePoint(this, e.getPoint());
    controller.showTooltipByMouseMove(editor,
                                      showPoint,
                                      ((EditorMarkupModel)editor.getMarkupModel()).getErrorStripTooltipRendererProvider().calcTooltipRenderer(toolTip),
                                      false,
                                      TOOLTIP_GROUP,
                                      new HintHint(this, e.getPoint()).setAwtTooltip(true));
  }
}
项目:tools-idea    文件:DaemonCodeAnalyzerImpl.java   
void repaintErrorStripeRenderer(@NotNull Editor editor) {
  if (!myProject.isInitialized()) return;
  final Document document = editor.getDocument();
  final PsiFile psiFile = PsiDocumentManager.getInstance(myProject).getPsiFile(document);
  final EditorMarkupModel markup = (EditorMarkupModel)editor.getMarkupModel();
  markup.setErrorPanelPopupHandler(new DaemonEditorPopup(psiFile));
  markup.setErrorStripTooltipRendererProvider(new DaemonTooltipRendererProvider(myProject));
  markup.setMinMarkHeight(DaemonCodeAnalyzerSettings.getInstance().ERROR_STRIPE_MARK_MIN_HEIGHT);
  TrafficLightRenderer.setOrRefreshErrorStripeRenderer(markup, myProject, document, psiFile);
}
项目:tools-idea    文件:FontEditorPreview.java   
static void installTrafficLights(@NotNull EditorEx editor) {
  TrafficLightRenderer renderer = new TrafficLightRenderer(null, null,null){
    @Override
    protected DaemonCodeAnalyzerStatus getDaemonCodeAnalyzerStatus(boolean fillErrorsCount, 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);
}
项目:consulo    文件:TextEditorComponent.java   
@Nonnull
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;
}
项目:consulo    文件:DaemonListeners.java   
static void repaintErrorStripeRenderer(@Nonnull Editor editor, @Nonnull Project project) {
  ApplicationManager.getApplication().assertIsDispatchThread();
  if (!project.isInitialized()) return;
  final Document document = editor.getDocument();
  final PsiFile psiFile = PsiDocumentManager.getInstance(project).getPsiFile(document);
  final EditorMarkupModel markup = (EditorMarkupModel)editor.getMarkupModel();
  markup.setErrorPanelPopupHandler(new DaemonEditorPopup(psiFile));
  markup.setErrorStripTooltipRendererProvider(new DaemonTooltipRendererProvider(project));
  markup.setMinMarkHeight(DaemonCodeAnalyzerSettings.getInstance().ERROR_STRIPE_MARK_MIN_HEIGHT);
  TrafficLightRenderer.setOrRefreshErrorStripeRenderer(markup, project, document, psiFile);
}
项目:consulo    文件:FontEditorPreview.java   
static void installTrafficLights(@Nonnull EditorEx editor) {
  TrafficLightRenderer renderer = new TrafficLightRenderer(null, null,null) {
    @Nonnull
    @Override
    protected DaemonCodeAnalyzerStatus getDaemonCodeAnalyzerStatus(@Nonnull 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);
}
项目:consulo    文件:ConsoleGutterComponent.java   
@Override
public void mouseMoved(MouseEvent e) {
  int line = EditorUtil.yPositionToLogicalLine(editor, e.getPoint());
  if (line == lastGutterToolTipLine) {
    return;
  }

  TooltipController controller = TooltipController.getInstance();
  if (lastGutterToolTipLine != -1) {
    controller.cancelTooltip(TOOLTIP_GROUP, e, true);
  }

  String toolTip = gutterContentProvider.getToolTip(line, editor);
  setCursor(toolTip == null ? Cursor.getDefaultCursor() : Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
  if (toolTip == null) {
    lastGutterToolTipLine = -1;
    controller.cancelTooltip(TOOLTIP_GROUP, e, false);
  }
  else {
    lastGutterToolTipLine = line;
    RelativePoint showPoint = new RelativePoint(this, e.getPoint());
    controller.showTooltipByMouseMove(editor,
                                      showPoint,
                                      ((EditorMarkupModel)editor.getMarkupModel()).getErrorStripTooltipRendererProvider().calcTooltipRenderer(toolTip),
                                      false,
                                      TOOLTIP_GROUP,
                                      new HintHint(this, e.getPoint()).setAwtTooltip(true));
  }
}
项目:intellij-ce-playground    文件:TooltipController.java   
public void showTooltip(@NotNull Editor editor, @NotNull Point p, @NotNull String text, boolean alignToRight, @NotNull TooltipGroup group) {
  TooltipRenderer tooltipRenderer = ((EditorMarkupModel)editor.getMarkupModel()).getErrorStripTooltipRendererProvider().calcTooltipRenderer(text);
  showTooltip(editor, p, tooltipRenderer, alignToRight, group);
}
项目:intellij-ce-playground    文件:TooltipController.java   
public void showTooltip(@NotNull Editor editor, @NotNull Point p, @NotNull String text, int currentWidth, boolean alignToRight, @NotNull TooltipGroup group) {
  TooltipRenderer tooltipRenderer = ((EditorMarkupModel)editor.getMarkupModel()).getErrorStripTooltipRendererProvider().calcTooltipRenderer(text, currentWidth);
  showTooltip(editor, p, tooltipRenderer, alignToRight, group);
}
项目:intellij-ce-playground    文件:TooltipController.java   
public void showTooltip(@NotNull Editor editor, @NotNull Point p, @NotNull String text, int currentWidth, boolean alignToRight, @NotNull TooltipGroup group, @NotNull HintHint hintHint) {
  TooltipRenderer tooltipRenderer = ((EditorMarkupModel)editor.getMarkupModel()).getErrorStripTooltipRendererProvider().calcTooltipRenderer(text, currentWidth);
  showTooltip(editor, p, tooltipRenderer, alignToRight, group, hintHint);
}
项目:intellij-ce-playground    文件:DiffPanelImpl.java   
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);
    }
  });
}
项目:intellij-ce-playground    文件:EmmetPreviewHint.java   
@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);
}
项目:tools-idea    文件:TooltipController.java   
public void showTooltip(@NotNull Editor editor, @NotNull Point p, @NotNull String text, boolean alignToRight, @NotNull TooltipGroup group) {
  TooltipRenderer tooltipRenderer = ((EditorMarkupModel)editor.getMarkupModel()).getErrorStripTooltipRendererProvider().calcTooltipRenderer(text);
  showTooltip(editor, p, tooltipRenderer, alignToRight, group);
}
项目:tools-idea    文件:TooltipController.java   
public void showTooltip(@NotNull Editor editor, @NotNull Point p, @NotNull String text, int currentWidth, boolean alignToRight, @NotNull TooltipGroup group) {
  TooltipRenderer tooltipRenderer = ((EditorMarkupModel)editor.getMarkupModel()).getErrorStripTooltipRendererProvider().calcTooltipRenderer(text, currentWidth);
  showTooltip(editor, p, tooltipRenderer, alignToRight, group);
}
项目:tools-idea    文件:TooltipController.java   
public void showTooltip(@NotNull Editor editor, @NotNull Point p, @NotNull String text, int currentWidth, boolean alignToRight, @NotNull TooltipGroup group, @NotNull HintHint hintHint) {
  TooltipRenderer tooltipRenderer = ((EditorMarkupModel)editor.getMarkupModel()).getErrorStripTooltipRendererProvider().calcTooltipRenderer(text, currentWidth);
  showTooltip(editor, p, tooltipRenderer, alignToRight, group, hintHint);
}
项目:tools-idea    文件:DiffPanelImpl.java   
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);
    }
  });
}
项目:intellij-plugin-v4    文件:InputPanel.java   
public Editor createPreviewEditor(final VirtualFile grammarFile, Document doc) {
        LOG.info("createEditor: create new editor for "+grammarFile.getPath()+" "+previewPanel.project.getName());
        final EditorFactory factory = EditorFactory.getInstance();
        doc.addDocumentListener(
            new DocumentAdapter() {
                VirtualFile grammarFileForThisPreviewEditor;

                {
                    { // faux ctor
                        this.grammarFileForThisPreviewEditor = grammarFile;
                    }
                }

                @Override
                public void documentChanged(DocumentEvent event) {
                    previewPanel.updateParseTreeFromDoc(grammarFileForThisPreviewEditor);
                }
            }
                               );
        final Editor editor = factory.createEditor(doc, previewPanel.project);
        // force right margin
        ((EditorMarkupModel) editor.getMarkupModel()).setErrorStripeVisible(true);
        EditorSettings settings = editor.getSettings();
        settings.setWhitespacesShown(true);
        settings.setLineNumbersShown(true);
        settings.setLineMarkerAreaShown(true);
        installListeners(editor);

//      EditorGutter gutter = editor.getGutter();
//      gutter.registerTextAnnotation(
//          new TextAnnotationGutterProvider() {
//              @Nullable
//              @Override
//              public String getLineText(int line, Editor editor) {
//                  return "foo";
//              }
//
//              @Nullable
//              @Override
//              public String getToolTip(int line, Editor editor) {
//                  return "tool tip";
//              }
//
//              @Override
//              public EditorFontType getStyle(int line, Editor editor) {
//                  return null;
//              }
//
//              @Nullable
//              @Override
//              public ColorKey getColor(int line, Editor editor) {
//                  return EditorColors.MODIFIED_LINES_COLOR;
//              }
//
//              @Nullable
//              @Override
//              public Color getBgColor(int line, Editor editor) {
//                  return JBColor.WHITE;
//              }
//
//              @Override
//              public List<AnAction> getPopupActions(int line, Editor editor) {
//                  return null;
//              }
//
//              @Override
//              public void gutterClosed() {
//
//              }
//          }
//      );

        return editor;
    }
项目:consulo    文件:TooltipController.java   
public void showTooltip(@Nonnull Editor editor, @Nonnull Point p, @Nonnull String text, boolean alignToRight, @Nonnull TooltipGroup group) {
  TooltipRenderer tooltipRenderer = ((EditorMarkupModel)editor.getMarkupModel()).getErrorStripTooltipRendererProvider().calcTooltipRenderer(text);
  showTooltip(editor, p, tooltipRenderer, alignToRight, group);
}
项目:consulo    文件:TooltipController.java   
public void showTooltip(@Nonnull Editor editor, @Nonnull Point p, @Nonnull String text, int currentWidth, boolean alignToRight, @Nonnull TooltipGroup group) {
  TooltipRenderer tooltipRenderer = ((EditorMarkupModel)editor.getMarkupModel()).getErrorStripTooltipRendererProvider().calcTooltipRenderer(text, currentWidth);
  showTooltip(editor, p, tooltipRenderer, alignToRight, group);
}
项目:consulo    文件:TooltipController.java   
public void showTooltip(@Nonnull Editor editor, @Nonnull Point p, @Nonnull String text, int currentWidth, boolean alignToRight, @Nonnull TooltipGroup group, @Nonnull HintHint hintHint) {
  TooltipRenderer tooltipRenderer = ((EditorMarkupModel)editor.getMarkupModel()).getErrorStripTooltipRendererProvider().calcTooltipRenderer(text, currentWidth);
  showTooltip(editor, p, tooltipRenderer, alignToRight, group, hintHint);
}
项目:consulo    文件:DiffPanelImpl.java   
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);
    }
  });
}
项目:consulo    文件:ApplyPatchViewer.java   
public ApplyPatchViewer(@Nonnull DiffContext context, @Nonnull ApplyPatchRequest request) {
  myProject = context.getProject();
  myContext = context;
  myPatchRequest = request;


  DocumentContent resultContent = request.getResultContent();
  DocumentContent patchContent = DiffContentFactory.getInstance().create(new DocumentImpl("", true), resultContent);

  myResultHolder = TextEditorHolder.create(myProject, resultContent);
  myPatchHolder = TextEditorHolder.create(myProject, patchContent);

  myResultEditor = myResultHolder.getEditor();
  myPatchEditor = myPatchHolder.getEditor();

  if (isReadOnly()) myResultEditor.setViewer(true);
  myPatchEditor.setViewer(true);

  DiffUtil.disableBlitting(myResultEditor);
  DiffUtil.disableBlitting(myPatchEditor);

  ((EditorMarkupModel)myResultEditor.getMarkupModel()).setErrorStripeVisible(false);
  myResultEditor.setVerticalScrollbarOrientation(EditorEx.VERTICAL_SCROLLBAR_LEFT);

  myPatchEditor.getGutterComponentEx().setForceShowRightFreePaintersArea(true);
  ((EditorMarkupModel)myPatchEditor.getMarkupModel()).setErrorStripeVisible(false);


  List<TextEditorHolder> holders = ContainerUtil.list(myResultHolder, myPatchHolder);
  List<EditorEx> editors = ContainerUtil.list(myResultEditor, myPatchEditor);
  JComponent resultTitle = DiffUtil.createTitle(myPatchRequest.getResultTitle());
  JComponent patchTitle = DiffUtil.createTitle(myPatchRequest.getPatchTitle());
  List<JComponent> titleComponents = DiffUtil.createSyncHeightComponents(ContainerUtil.list(resultTitle, patchTitle));

  myContentPanel = new TwosideContentPanel(holders, titleComponents);
  myPanel = new SimpleDiffPanel(myContentPanel, this, myContext);

  myModel = new MyModel(myProject, myResultEditor.getDocument());

  myFocusTrackerSupport = new FocusTrackerSupport.Twoside(holders);
  myFocusTrackerSupport.setCurrentSide(Side.LEFT);
  myPrevNextDifferenceIterable = new MyPrevNextDifferenceIterable();
  myStatusPanel = new MyStatusPanel();
  myFoldingModel = new MyFoldingModel(myResultEditor, this);


  new MyFocusOppositePaneAction().install(myPanel);
  new TextDiffViewerUtil.EditorActionsPopup(createEditorPopupActions()).install(editors);

  new TextDiffViewerUtil.EditorFontSizeSynchronizer(editors).install(this);

  myEditorSettingsAction = new SetEditorSettingsAction(getTextSettings(), editors);
  myEditorSettingsAction.applyDefaults();

  if (!isReadOnly()) {
    DiffUtil.registerAction(new ApplySelectedChangesAction(true), myPanel);
    DiffUtil.registerAction(new IgnoreSelectedChangesAction(true), myPanel);
  }

  ProxyUndoRedoAction.register(myProject, myResultEditor, myContentPanel);
}