use of com.intellij.openapi.editor.ex.EditorEx in project intellij-community by JetBrains.
the class StudyToolWindow method enterEditingMode.
public void enterEditingMode(VirtualFile taskFile, Project project) {
final EditorFactory factory = EditorFactory.getInstance();
Document document = FileDocumentManager.getInstance().getDocument(taskFile);
if (document == null) {
return;
}
WebBrowserManager.getInstance().setShowBrowserHover(false);
final EditorEx createdEditor = (EditorEx) factory.createEditor(document, project, taskFile, false);
Disposer.register(project, new Disposable() {
public void dispose() {
factory.releaseEditor(createdEditor);
}
});
JComponent editorComponent = createdEditor.getComponent();
editorComponent.setBorder(new EmptyBorder(10, 20, 0, 10));
editorComponent.setBackground(EditorColorsManager.getInstance().getGlobalScheme().getDefaultBackground());
EditorSettings editorSettings = createdEditor.getSettings();
editorSettings.setLineMarkerAreaShown(false);
editorSettings.setLineNumbersShown(false);
editorSettings.setFoldingOutlineShown(false);
mySplitPane.setFirstComponent(editorComponent);
mySplitPane.repaint();
StudyTaskManager.getInstance(project).setToolWindowMode(StudyToolWindowMode.EDITING);
}
use of com.intellij.openapi.editor.ex.EditorEx in project intellij-community by JetBrains.
the class ResourceBundleEditor method createEditor.
private EditorEx createEditor() {
EditorFactory editorFactory = EditorFactory.getInstance();
Document document = editorFactory.createDocument("");
EditorEx editor = (EditorEx) editorFactory.createEditor(document);
reinitSettings(editor);
editor.putUserData(RESOURCE_BUNDLE_EDITOR_KEY, this);
return editor;
}
use of com.intellij.openapi.editor.ex.EditorEx in project intellij-community by JetBrains.
the class PyUtil method rehighlightOpenEditors.
/**
* Force re-highlighting in all open editors that belong to specified project.
*/
public static void rehighlightOpenEditors(@NotNull final Project project) {
ApplicationManager.getApplication().runWriteAction(() -> {
for (Editor editor : EditorFactory.getInstance().getAllEditors()) {
if (editor instanceof EditorEx && editor.getProject() == project) {
final VirtualFile vFile = ((EditorEx) editor).getVirtualFile();
if (vFile != null) {
final EditorHighlighter highlighter = EditorHighlighterFactory.getInstance().createEditorHighlighter(project, vFile);
((EditorEx) editor).setHighlighter(highlighter);
}
}
}
});
}
use of com.intellij.openapi.editor.ex.EditorEx in project intellij-community by JetBrains.
the class GStringTypedActionHandler method charTyped.
@Override
public Result charTyped(char c, Project project, @NotNull Editor editor, @NotNull PsiFile file) {
if (c != '{' || project == null || !HandlerUtils.canBeInvoked(editor, project)) {
return Result.CONTINUE;
}
if (!(file instanceof GroovyFile))
return Result.CONTINUE;
int caret = editor.getCaretModel().getOffset();
final EditorHighlighter highlighter = ((EditorEx) editor).getHighlighter();
if (caret < 1)
return Result.CONTINUE;
HighlighterIterator iterator = highlighter.createIterator(caret - 1);
if (iterator.getTokenType() != GroovyTokenTypes.mLCURLY)
return Result.CONTINUE;
iterator.retreat();
if (iterator.atEnd() || iterator.getTokenType() != GroovyTokenTypes.mDOLLAR)
return Result.CONTINUE;
iterator.advance();
if (iterator.atEnd())
return Result.CONTINUE;
iterator.advance();
if (iterator.getTokenType() != GroovyTokenTypes.mGSTRING_BEGIN)
return Result.CONTINUE;
editor.getDocument().insertString(caret, "}");
return Result.STOP;
}
use of com.intellij.openapi.editor.ex.EditorEx in project intellij-community by JetBrains.
the class SvnPropertiesDiffViewer method setupHighlighting.
private void setupHighlighting(@NotNull DiffChange change, @NotNull Side side) {
PropertyRecord record = change.getRecord();
List<? extends LineFragment> fragments = change.getFragments();
assert fragments != null;
EditorEx editor = getEditor(side);
DocumentEx document = editor.getDocument();
int changeStartLine = change.getStartLine(side);
for (LineFragment fragment : fragments) {
List<DiffFragment> innerFragments = fragment.getInnerFragments();
int startLine = side.getStartLine(fragment) + changeStartLine;
int endLine = side.getEndLine(fragment) + changeStartLine;
int start = document.getLineStartOffset(startLine);
TextDiffType type = DiffUtil.getLineDiffType(fragment);
DiffDrawUtil.createHighlighter(editor, startLine, endLine, type, innerFragments != null);
// TODO: we can paint LineMarker here, but it looks ugly for small editors
if (innerFragments != null) {
for (DiffFragment innerFragment : innerFragments) {
int innerStart = side.getStartOffset(innerFragment);
int innerEnd = side.getEndOffset(innerFragment);
TextDiffType innerType = DiffUtil.getDiffType(innerFragment);
innerStart += start;
innerEnd += start;
DiffDrawUtil.createInlineHighlighter(editor, innerStart, innerEnd, innerType);
}
}
}
}
Aggregations