Java Code Examples for com.intellij.openapi.editor.EditorFactory#getInstance()
The following examples show how to use
com.intellij.openapi.editor.EditorFactory#getInstance() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PromptConsole.java From reasonml-idea-plugin with MIT License | 6 votes |
PromptConsole(@NotNull Project project, ConsoleViewImpl consoleView) { m_consoleView = consoleView; EditorFactory editorFactory = EditorFactory.getInstance(); PsiFileFactory fileFactory = PsiFileFactory.getInstance(project); Document outputDocument = ((EditorFactoryImpl) editorFactory).createDocument(true); UndoUtil.disableUndoFor(outputDocument); m_outputEditor = (EditorImpl) editorFactory.createViewer(outputDocument, project, CONSOLE); PsiFile file = fileFactory.createFileFromText("PromptConsoleDocument.ml", OclLanguage.INSTANCE, ""); Document promptDocument = file.getViewProvider().getDocument(); m_promptEditor = (EditorImpl) editorFactory.createEditor(promptDocument, project, CONSOLE); setupOutputEditor(); setupPromptEditor(); m_consoleView.print("(* ctrl+enter to send a command, ctrl+up/down to cycle through history *)\r\n", USER_INPUT); m_mainPanel.add(m_outputEditor.getComponent(), BorderLayout.CENTER); m_mainPanel.add(m_promptEditor.getComponent(), BorderLayout.SOUTH); }
Example 2
Source File: ConsoleExecutionEditor.java From consulo with Apache License 2.0 | 6 votes |
public ConsoleExecutionEditor(@Nonnull LanguageConsoleImpl.Helper helper) { myHelper = helper; EditorFactory editorFactory = EditorFactory.getInstance(); myEditorDocument = helper.getDocument(); myConsoleEditor = (EditorEx)editorFactory.createEditor(myEditorDocument, helper.project); myConsoleEditor.getScrollPane().getHorizontalScrollBar().setEnabled(false); myConsoleEditor.addFocusListener(myFocusListener); myConsoleEditor.getSettings().setVirtualSpace(false); myCurrentEditor = myConsoleEditor; myConsoleEditor.putUserData(SEARCH_DISABLED, true); myConsolePromptDecorator = new ConsolePromptDecorator(myConsoleEditor); myConsoleEditor.getGutter().registerTextAnnotation(myConsolePromptDecorator); myBusConnection = getProject().getMessageBus().connect(); // action shortcuts are not yet registered ApplicationManager.getApplication().invokeLater(() -> installEditorFactoryListener(), getProject().getDisposed()); }
Example 3
Source File: SettingsPanel.java From json2java4idea with Apache License 2.0 | 6 votes |
private void createUIComponents() { final EditorFactory editorFactory = EditorFactory.getInstance(); previewDocument = editorFactory.createDocument(EMPTY_TEXT); previewEditor = editorFactory.createEditor(previewDocument, null, JavaFileType.INSTANCE, true); final EditorSettings settings = previewEditor.getSettings(); settings.setWhitespacesShown(true); settings.setLineMarkerAreaShown(false); settings.setIndentGuidesShown(false); settings.setLineNumbersShown(false); settings.setFoldingOutlineShown(false); settings.setRightMarginShown(false); settings.setVirtualSpace(false); settings.setWheelFontChangeEnabled(false); settings.setUseSoftWraps(false); settings.setAdditionalColumnsCount(0); settings.setAdditionalLinesCount(1); previewPanel = (JPanel) previewEditor.getComponent(); previewPanel.setName(PREVIEW_PANEL_NAME); previewPanel.setPreferredSize(new Dimension(PREFERRED_PREVIEW_WIDTH, PREFERRED_PREVIEW_HEIGHT)); }
Example 4
Source File: NewClassDialog.java From json2java4idea with Apache License 2.0 | 6 votes |
private void createUIComponents() { final EditorFactory editorFactory = EditorFactory.getInstance(); jsonDocument = editorFactory.createDocument(EMPTY_TEXT); jsonEditor = editorFactory.createEditor(jsonDocument, project, JsonFileType.INSTANCE, false); final EditorSettings settings = jsonEditor.getSettings(); settings.setWhitespacesShown(true); settings.setLineMarkerAreaShown(false); settings.setIndentGuidesShown(false); settings.setLineNumbersShown(true); settings.setFoldingOutlineShown(false); settings.setRightMarginShown(false); settings.setVirtualSpace(false); settings.setWheelFontChangeEnabled(false); settings.setUseSoftWraps(false); settings.setAdditionalColumnsCount(0); settings.setAdditionalLinesCount(1); final EditorColorsScheme colorsScheme = jsonEditor.getColorsScheme(); colorsScheme.setColor(EditorColors.CARET_ROW_COLOR, null); jsonEditor.getContentComponent().setFocusable(true); jsonPanel = (JPanel) jsonEditor.getComponent(); }
Example 5
Source File: PowerMode.java From power-mode-intellij-plugin with Apache License 2.0 | 6 votes |
@Override public void initComponent() { final EditorActionManager editorActionManager = EditorActionManager.getInstance(); final EditorFactory editorFactory = EditorFactory.getInstance(); particleContainerManager = new ParticleContainerManager(); editorFactory.addEditorFactoryListener(particleContainerManager, new Disposable() { @Override public void dispose() { } }); final TypedAction typedAction = editorActionManager.getTypedAction(); final TypedActionHandler rawHandler = typedAction.getRawHandler(); typedAction.setupRawHandler(new TypedActionHandler() { @Override public void execute(@NotNull final Editor editor, final char c, @NotNull final DataContext dataContext) { updateEditor(editor); rawHandler.execute(editor, c, dataContext); } }); }
Example 6
Source File: TemplateConfigurable.java From android-codegenerator-plugin-intellij with Apache License 2.0 | 6 votes |
private Editor createEditorInPanel(String string) { EditorFactory editorFactory = EditorFactory.getInstance(); Editor editor = editorFactory.createEditor(editorFactory.createDocument(string)); EditorSettings editorSettings = editor.getSettings(); editorSettings.setVirtualSpace(false); editorSettings.setLineMarkerAreaShown(false); editorSettings.setIndentGuidesShown(false); editorSettings.setLineNumbersShown(false); editorSettings.setFoldingOutlineShown(false); editorSettings.setAdditionalColumnsCount(3); editorSettings.setAdditionalLinesCount(3); editor.getDocument().addDocumentListener(new DocumentAdapter() { @Override public void documentChanged(DocumentEvent e) { onTextChanged(); } }); ((EditorEx) editor).setHighlighter(getEditorHighlighter()); addEditorToPanel(editor); return editor; }
Example 7
Source File: AnalyzeStacktraceUtil.java From consulo with Apache License 2.0 | 6 votes |
public static StacktraceEditorPanel createEditorPanel(Project project, @Nonnull Disposable parentDisposable) { EditorFactory editorFactory = EditorFactory.getInstance(); Document document = editorFactory.createDocument(""); Editor editor = editorFactory.createEditor(document, project); EditorSettings settings = editor.getSettings(); settings.setFoldingOutlineShown(false); settings.setLineMarkerAreaShown(false); settings.setIndentGuidesShown(false); settings.setLineNumbersShown(false); settings.setRightMarginShown(false); StacktraceEditorPanel editorPanel = new StacktraceEditorPanel(project, editor); editorPanel.setPreferredSize(new Dimension(600, 400)); Disposer.register(parentDisposable, editorPanel); return editorPanel; }
Example 8
Source File: TemplateEditorUtil.java From consulo with Apache License 2.0 | 6 votes |
private static Editor createEditor(boolean isReadOnly, final Document document, final Project project) { EditorFactory editorFactory = EditorFactory.getInstance(); Editor editor = (isReadOnly ? editorFactory.createViewer(document, project) : editorFactory.createEditor(document, project)); EditorSettings editorSettings = editor.getSettings(); editorSettings.setVirtualSpace(false); editorSettings.setLineMarkerAreaShown(false); editorSettings.setIndentGuidesShown(false); editorSettings.setLineNumbersShown(false); editorSettings.setFoldingOutlineShown(false); EditorColorsScheme scheme = editor.getColorsScheme(); scheme.setColor(EditorColors.CARET_ROW_COLOR, null); VirtualFile file = FileDocumentManager.getInstance().getFile(document); if (file != null) { EditorHighlighter highlighter = EditorHighlighterFactory.getInstance().createEditorHighlighter(file, scheme, project); ((EditorEx) editor).setHighlighter(highlighter); } return editor; }
Example 9
Source File: EncodingManagerImpl.java From consulo with Apache License 2.0 | 5 votes |
public EncodingManagerImpl() { ApplicationManager.getApplication().getMessageBus().connect().subscribe(AppLifecycleListener.TOPIC, new AppLifecycleListener() { @Override public void appClosing() { // should call before dispose in write action // prevent any further re-detection and wait for the queue to clear myDisposed.set(true); clearDocumentQueue(); } }); EditorFactory editorFactory = EditorFactory.getInstance(); editorFactory.getEventMulticaster().addDocumentListener(new DocumentListener() { @Override public void documentChanged(@Nonnull DocumentEvent e) { Document document = e.getDocument(); if (isEditorOpenedFor(document)) { queueUpdateEncodingFromContent(document); } } }, this); editorFactory.addEditorFactoryListener(new EditorFactoryListener() { @Override public void editorCreated(@Nonnull EditorFactoryEvent event) { queueUpdateEncodingFromContent(event.getEditor().getDocument()); } }, this); }
Example 10
Source File: DiffUtil.java From consulo with Apache License 2.0 | 5 votes |
public static EditorEx createEditor(Document document, Project project, boolean isViewer, @Nullable FileType fileType) { 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.getGutterComponentEx().revalidateMarkup(); if (fileType != null && project != null && !project.isDisposed()) { CodeStyleFacade codeStyleFacade = CodeStyleFacade.getInstance(project); editor.getSettings().setTabSize(codeStyleFacade.getTabSize(fileType)); editor.getSettings().setUseTabCharacter(codeStyleFacade.useTabCharacter(fileType)); } return editor; }
Example 11
Source File: CoverageLineMarkerRenderer.java From consulo with Apache License 2.0 | 5 votes |
private void showHint(final Editor editor, final Point point, final int lineNumber) { final JPanel panel = new JPanel(new BorderLayout()); panel.add(createActionsToolbar(editor, lineNumber), BorderLayout.NORTH); final LineData lineData = getLineData(lineNumber); final Editor uEditor; if (lineData != null && lineData.getStatus() != LineCoverage.NONE && !mySubCoverageActive) { final EditorFactory factory = EditorFactory.getInstance(); final Document doc = factory.createDocument(getReport(editor, lineNumber)); doc.setReadOnly(true); uEditor = factory.createEditor(doc, editor.getProject()); panel.add(EditorFragmentComponent.createEditorFragmentComponent(uEditor, 0, doc.getLineCount(), false, false), BorderLayout.CENTER); } else { uEditor = null; } final LightweightHint hint = new LightweightHint(panel){ @Override public void hide() { if (uEditor != null) EditorFactory.getInstance().releaseEditor(uEditor); super.hide(); } }; HintManagerImpl.getInstanceImpl().showEditorHint(hint, editor, point, HintManagerImpl.HIDE_BY_ANY_KEY | HintManagerImpl.HIDE_BY_TEXT_CHANGE | HintManagerImpl.HIDE_BY_OTHER_HINT | HintManagerImpl.HIDE_BY_SCROLLING, -1, false, new HintHint(editor, point)); }
Example 12
Source File: CallerChooserBase.java From consulo with Apache License 2.0 | 5 votes |
private Editor createEditor() { final EditorFactory editorFactory = EditorFactory.getInstance(); final Document document = editorFactory.createDocument(""); final Editor editor = editorFactory.createViewer(document, myProject); ((EditorEx)editor).setHighlighter(HighlighterFactory.createHighlighter(myProject, myFileName)); return editor; }
Example 13
Source File: ANTLRv4PluginController.java From intellij-plugin-v4 with BSD 3-Clause "New" or "Revised" License | 5 votes |
public Editor getEditor(VirtualFile vfile) { final FileDocumentManager fdm = FileDocumentManager.getInstance(); final Document doc = fdm.getDocument(vfile); if (doc == null) return null; EditorFactory factory = EditorFactory.getInstance(); final Editor[] editors = factory.getEditors(doc, previewPanel.project); if ( editors.length==0 ) { // no editor found for this file. likely an out-of-sequence issue // where Intellij is opening a project and doesn't fire events // in order we'd expect. return null; } return editors[0]; // hope just one }
Example 14
Source File: PreviewState.java From intellij-plugin-v4 with BSD 3-Clause "New" or "Revised" License | 5 votes |
public synchronized void releaseEditor() { // It would appear that the project closed event occurs before these // close grammars sometimes. Very strange. check for null editor. if (inputEditor != null) { final EditorFactory factory = EditorFactory.getInstance(); factory.releaseEditor(inputEditor); inputEditor = null; } }
Example 15
Source File: QueryPanel.java From nosql4idea with Apache License 2.0 | 5 votes |
protected Editor createEditor() { EditorFactory editorFactory = EditorFactory.getInstance(); Document editorDocument = editorFactory.createDocument(""); Editor editor = editorFactory.createEditor(editorDocument, project); fillEditorSettings(editor.getSettings()); EditorEx editorEx = (EditorEx) editor; attachHighlighter(editorEx); return editor; }
Example 16
Source File: Editors.java From CodeMaker with Apache License 2.0 | 5 votes |
public static Editor createSourceEditor(Project project, String language, String content, boolean readOnly) { final EditorFactory factory = EditorFactory.getInstance(); final Editor editor = factory.createEditor(factory.createDocument(content), project, FileTypeManager.getInstance() .getFileTypeByExtension(language), readOnly); editor.getSettings().setRefrainFromScrolling(false); return editor; }
Example 17
Source File: EditorPlace.java From consulo with Apache License 2.0 | 4 votes |
private static EditorFactory getEditorFactory() { return EditorFactory.getInstance(); }
Example 18
Source File: LocalHistoryActionsTest.java From consulo with Apache License 2.0 | 4 votes |
private static EditorFactory getEditorFactory() { return EditorFactory.getInstance(); }
Example 19
Source File: SimpleContent.java From consulo with Apache License 2.0 | 4 votes |
public SimpleContent(@Nonnull String text, @Nullable FileType type) { this(text, type, EditorFactory.getInstance()); }
Example 20
Source File: PromptConsole.java From reasonml-idea-plugin with MIT License | 4 votes |
@Override public void dispose() { EditorFactory editorFactory = EditorFactory.getInstance(); editorFactory.releaseEditor(m_outputEditor); editorFactory.releaseEditor(m_promptEditor); }