use of com.intellij.openapi.editor.EditorFactory in project intellij-community by JetBrains.
the class SearchDialog method createEditor.
protected Editor createEditor(final SearchContext searchContext, String text) {
Editor editor = null;
if (fileTypes != null) {
final FileType fileType = (FileType) fileTypes.getSelectedItem();
final Language dialect = (Language) dialects.getSelectedItem();
final StructuralSearchProfile profile = StructuralSearchUtil.getProfileByFileType(fileType);
if (profile != null) {
editor = profile.createEditor(searchContext, fileType, dialect, text, useLastConfiguration);
}
}
if (editor == null) {
final EditorFactory factory = EditorFactory.getInstance();
final Document document = factory.createDocument("");
editor = factory.createEditor(document, searchContext.getProject());
editor.getSettings().setFoldingOutlineShown(false);
}
editor.getDocument().addDocumentListener(new DocumentListener() {
@Override
public void beforeDocumentChange(final DocumentEvent event) {
}
@Override
public void documentChanged(final DocumentEvent event) {
initiateValidation();
}
});
return editor;
}
use of com.intellij.openapi.editor.EditorFactory in project intellij-community by JetBrains.
the class GuiEditor method showFormSource.
public void showFormSource() {
EditorFactory editorFactory = EditorFactory.getInstance();
Editor editor = editorFactory.createViewer(myDocument, myProject);
try {
((EditorEx) editor).setHighlighter(new LexerEditorHighlighter(new XmlFileHighlighter(), EditorColorsManager.getInstance().getGlobalScheme()));
JComponent component = editor.getComponent();
component.setPreferredSize(new Dimension(640, 480));
DialogBuilder dialog = new DialogBuilder(myProject);
dialog.title("Form - " + myFile.getPresentableName()).dimensionKey("GuiDesigner.FormSource.Dialog");
dialog.centerPanel(component).setPreferredFocusComponent(editor.getContentComponent());
dialog.addOkAction();
dialog.show();
} finally {
editorFactory.releaseEditor(editor);
}
}
use of com.intellij.openapi.editor.EditorFactory in project intellij-community by JetBrains.
the class ConfigProjectComponent method runActivity.
@Override
public void runActivity(@NotNull Project project) {
// Register project-level config managers
final EditorFactory editorFactory = EditorFactory.getInstance();
MessageBus bus = project.getMessageBus();
EditorSettingsManager editorSettingsManager = new EditorSettingsManager(project);
EncodingManager encodingManager = new EncodingManager(project);
LineEndingsManager lineEndingsManager = new LineEndingsManager(project);
bus.connect().subscribe(AppTopics.FILE_DOCUMENT_SYNC, encodingManager);
bus.connect().subscribe(AppTopics.FILE_DOCUMENT_SYNC, editorSettingsManager);
bus.connect().subscribe(AppTopics.FILE_DOCUMENT_SYNC, lineEndingsManager);
VirtualFileManager.getInstance().addVirtualFileListener(new VirtualFileAdapter() {
@Override
public void fileCreated(@NotNull VirtualFileEvent event) {
updateOpenEditors(event);
}
@Override
public void fileDeleted(@NotNull VirtualFileEvent event) {
updateOpenEditors(event);
}
@Override
public void contentsChanged(@NotNull VirtualFileEvent event) {
updateOpenEditors(event);
}
private void updateOpenEditors(VirtualFileEvent event) {
final VirtualFile file = event.getFile();
if (".editorconfig".equals(file.getName())) {
if (ProjectRootManager.getInstance(project).getFileIndex().isInContent(file) || !Registry.is("editor.config.stop.at.project.root")) {
for (Editor editor : editorFactory.getAllEditors()) {
if (editor.isDisposed())
continue;
;
((EditorEx) editor).reinitSettings();
}
}
}
}
}, project);
}
use of com.intellij.openapi.editor.EditorFactory in project intellij-community by JetBrains.
the class StructuralSearchProfile method createEditor.
@NotNull
public Editor createEditor(@NotNull SearchContext searchContext, @NotNull FileType fileType, Language dialect, String text, boolean useLastConfiguration) {
PsiFile codeFragment = createCodeFragment(searchContext.getProject(), text, null);
if (codeFragment == null) {
codeFragment = createFileFragment(searchContext, fileType, dialect, text);
}
if (codeFragment != null) {
final Document doc = PsiDocumentManager.getInstance(searchContext.getProject()).getDocument(codeFragment);
assert doc != null : "code fragment element should be physical";
DaemonCodeAnalyzer.getInstance(searchContext.getProject()).setHighlightingEnabled(codeFragment, false);
return UIUtil.createEditor(doc, searchContext.getProject(), true, true, getTemplateContextType());
}
final EditorFactory factory = EditorFactory.getInstance();
final Document document = factory.createDocument(text);
final EditorEx editor = (EditorEx) factory.createEditor(document, searchContext.getProject());
editor.getSettings().setFoldingOutlineShown(false);
return editor;
}
use of com.intellij.openapi.editor.EditorFactory in project intellij-community by JetBrains.
the class PyQuickFixUtil method getEditor.
@Nullable
public static Editor getEditor(@NotNull PsiElement element) {
Document document = PsiDocumentManager.getInstance(element.getProject()).getDocument(element.getContainingFile());
if (document != null) {
final EditorFactory instance = EditorFactory.getInstance();
if (instance == null)
return null;
Editor[] editors = instance.getEditors(document);
if (editors.length > 0) {
return editors[0];
}
}
return null;
}
Aggregations