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);
}
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);
}
});
}
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;
}
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);
}
Aggregations