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)); }
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(); }
private void doTest(String name) { VirtualFile file = configureByTaskFile(name + CCTestsUtil.BEFORE_POSTFIX); CCShowPreview action = new CCShowPreview(); TestActionEvent e = getActionEvent(action,PsiManager.getInstance(getProject()).findFile(file)); action.beforeActionPerformedUpdate(e); assertTrue(e.getPresentation().isEnabled() && e.getPresentation().isVisible()); action.actionPerformed(e); Editor editor = EditorFactory.getInstance().getAllEditors()[1]; try { Pair<Document, List<AnswerPlaceholder>> pair = getPlaceholders(name + CCTestsUtil.AFTER_POSTFIX); assertEquals("Files don't match", pair.getFirst().getText(), editor.getDocument().getText()); for (AnswerPlaceholder placeholder : pair.getSecond()) { assertNotNull("No highlighter for placeholder:" + CCTestsUtil.getPlaceholderPresentation(placeholder), getHighlighter(editor.getMarkupModel(), placeholder)); } } finally { EditorFactory.getInstance().releaseEditor(editor); } }
public void initComponent() { final int port = mySettings.getPortNumber(); final boolean allowRequestsFromLocalhostOnly = mySettings.isAllowRequestsFromLocalhostOnly(); EditorEventMulticaster eventMulticaster = EditorFactory.getInstance().getEventMulticaster(); eventMulticaster.addDocumentListener(new DocumentChangeListener()); try { serverSocket = new ServerSocket(); serverSocket.bind(new InetSocketAddress(allowRequestsFromLocalhostOnly ? "localhost" : "0.0.0.0", port)); log.info("Listening " + port); } catch (IOException e) { ApplicationManager.getApplication().invokeLater(new Runnable() { public void run() { Messages.showMessageDialog("Can't bind with " + port + " port. Appetizer plugin won't work", "Appetizer Plugin Error", Messages.getErrorIcon()); } }); return; } MessageNotifier messageNotifier = new SocketMessageNotifier(serverSocket); messageNotifier.addMessageHandler(new OpenFileMessageHandler(new FileNavigatorImpl())); listenerThread = new Thread(messageNotifier); listenerThread.start(); }
/** * Invokes action in intentionActionDescriptor on file found in path and writes the file to disk. * * @param path * @param fileContent * @param intentionActionDescriptor * @return */ public static String doFix(String path, @Nullable String fileContent, HighlightInfo.IntentionActionDescriptor intentionActionDescriptor) { UIUtil.invokeAndWaitIfNeeded((Runnable)() -> { PsiFile psiFile = EmbeditorUtil.findTargetFile(path); Project project = psiFile.getProject(); PsiFile fileCopy = fileContent != null ? EmbeditorUtil.createDummyPsiFile(project, fileContent, psiFile) : EmbeditorUtil.createDummyPsiFile(project, psiFile.getText(), psiFile); VirtualFile targetVirtualFile = psiFile.getVirtualFile(); Document document = fileCopy.getViewProvider().getDocument(); Editor editor = EditorFactory.getInstance().createEditor(document, project, targetVirtualFile, false); intentionActionDescriptor.getAction().invoke(project, editor, fileCopy); FileDocumentManager.getInstance().saveDocument(psiFile.getViewProvider().getDocument()); }); return null; }
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); } }
private void setupAutoStartDocumentListener(boolean enabled) { final EditorEventMulticaster editorEventMulticaster = EditorFactory.getInstance().getEventMulticaster(); if (autoStartDocumentListener != null) { editorEventMulticaster.removeDocumentListener(autoStartDocumentListener); autoStartDocumentListener = null; } if (enabled) { editorEventMulticaster.addDocumentListener(autoStartDocumentListener = new DocumentListener() { @Override public void documentChanged(DocumentEvent e) { if (running) return; //getSelectedTextEditor() must be run from event dispatch thread EventQueue.invokeLater(() -> { final Editor selectedTextEditor = FileEditorManager.getInstance(project).getSelectedTextEditor(); if (selectedTextEditor == null) return; if(e.getDocument().equals(selectedTextEditor.getDocument())) { setRunning(true); } }); } }); } }
/** * Force re-highlighting in all open editors that belong to specified project. */ public static void rehighlightOpenEditors(final @NotNull Project project) { ApplicationManager.getApplication().runWriteAction(new Runnable() { @Override public void run() { 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); } } } } }); }
@Override @Nullable public Document getDocument() { if (myDocument == null) { if (isBinary()) return null; String text = null; try { Charset charset = ObjectUtils.notNull(myCharset, EncodingProjectManager.getInstance(myProject).getDefaultCharset()); text = CharsetToolkit.bytesToString(myBytes, charset); } catch (IllegalCharsetNameException ignored) { } // Still NULL? only if not supported or an exception was thrown. // Decode a string using the truly default encoding. if (text == null) text = new String(myBytes); text = LineTokenizer.correctLineSeparators(text); myDocument = EditorFactory.getInstance().createDocument(text); myDocument.setReadOnly(true); } return myDocument; }
public ChangeSignatureGestureDetector(final PsiDocumentManager psiDocumentManager, final FileDocumentManager documentManager, final PsiManager psiManager, final FileEditorManager fileEditorManager, final Project project) { myDocumentManager = documentManager; myPsiDocumentManager = psiDocumentManager; myPsiManager = psiManager; myFileEditorManager = fileEditorManager; myProject = project; myPsiManager.addPsiTreeChangeListener(this, this); EditorFactory.getInstance().addEditorFactoryListener(this, this); Disposer.register(this, new Disposable() { @Override public void dispose() { LOG.assertTrue(myListenerMap.isEmpty(), myListenerMap); } }); }
public void testCreateFromEditorWithoutFile() throws Throwable { VirtualFile file = myProjectRoot.findFileByRelativePath("file.txt"); assertNotNull(file); Document document = FileDocumentManager.getInstance().getDocument(file); assertNotNull(document); myEditor = EditorFactory.getInstance().createEditor(document, myProject); assertNotNull(myEditor); List<FileContent> expected = new ArrayList<FileContent>(); expected.add(new FileContent("", "file.txt content")); List<FileContent> actual = GithubCreateGistAction.collectContents(myProject, myEditor, null, null); checkEquals(expected, actual); }
public void activate() { if (myConnection == null) { myListenerDisposable = Disposer.newDisposable(); Disposer.register(myProject, myListenerDisposable); EditorFactory.getInstance().getEventMulticaster().addDocumentListener(myListener, myListenerDisposable); myConnection = ApplicationManager.getApplication().getMessageBus().connect(myProject); myConnection.subscribe(AppTopics.FILE_DOCUMENT_SYNC, new FileDocumentManagerAdapter() { @Override public void beforeAllDocumentsSaving() { myDocumentSavingInProgress = true; ApplicationManager.getApplication().invokeLater(new Runnable() { @Override public void run() { myDocumentSavingInProgress = false; } }, ModalityState.any()); } }); } }
private static void tweakEditorAndFireUpdateUI(UISettings settings, boolean inPresentation) { EditorColorsScheme globalScheme = EditorColorsManager.getInstance().getGlobalScheme(); int fontSize = inPresentation ? settings.PRESENTATION_MODE_FONT_SIZE : globalScheme.getEditorFontSize(); if (inPresentation) { ourSavedConsoleFontSize = globalScheme.getConsoleFontSize(); globalScheme.setConsoleFontSize(fontSize); } else { globalScheme.setConsoleFontSize(ourSavedConsoleFontSize); } for (Editor editor : EditorFactory.getInstance().getAllEditors()) { if (editor instanceof EditorEx) { ((EditorEx)editor).setFontSize(fontSize); } } UISettings.getInstance().fireUISettingsChanged(); LafManager.getInstance().updateUI(); EditorUtil.reinitSettings(); }
public static StacktraceEditorPanel createEditorPanel(Project project, @NotNull 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(JBUI.size(600, 400)); Disposer.register(parentDisposable, editorPanel); return editorPanel; }
private static Editor createEditor(final Project project, final String text, final String fileName) { final FileType fileType = getFileType(fileName); final Document doc = createDocument(fileName, fileType, text); final Editor editor = EditorFactory.getInstance().createEditor(doc, project); ((EditorEx)editor).setEmbeddedIntoDialogWrapper(true); final EditorSettings settings = editor.getSettings(); settings.setLineNumbersShown(false); settings.setFoldingOutlineShown(false); settings.setRightMarginShown(false); settings.setLineMarkerAreaShown(false); settings.setIndentGuidesShown(false); ((EditorEx)editor).setHighlighter(HighlighterFactory.createHighlighter(fileType, DefaultColorSchemesManager.getInstance().getFirstScheme(), project)); return editor; }
@Override public void projectOpened() { StartupManager.getInstance(myProject).registerPreStartupActivity(new Runnable() { @Override public void run() { final MyFileStatusListener fileStatusListener = new MyFileStatusListener(); final EditorFactoryListener editorFactoryListener = new MyEditorFactoryListener(); final MyVirtualFileListener virtualFileListener = new MyVirtualFileListener(); final EditorColorsListener editorColorsListener = new MyEditorColorsListener(); final FileStatusManager fsManager = FileStatusManager.getInstance(myProject); fsManager.addFileStatusListener(fileStatusListener, myDisposable); final EditorFactory editorFactory = EditorFactory.getInstance(); editorFactory.addEditorFactoryListener(editorFactoryListener, myDisposable); final VirtualFileManager virtualFileManager = VirtualFileManager.getInstance(); virtualFileManager.addVirtualFileListener(virtualFileListener, myDisposable); final EditorColorsManager editorColorsManager = EditorColorsManager.getInstance(); editorColorsManager.addEditorColorsListener(editorColorsListener, myDisposable); } }); }
/** * Instructs the manager to enable or disable 'show quick doc automatically when the mouse goes over an editor element' mode. * * @param enabled flag that identifies if quick doc should be automatically shown */ public void setEnabled(boolean enabled) { myEnabled = enabled; myApplicationActive = enabled; if (!enabled) { closeQuickDocIfPossible(); myAlarm.cancelAllRequests(); } EditorFactory factory = EditorFactory.getInstance(); if (factory == null) { return; } for (Editor editor : factory.getAllEditors()) { if (enabled) { registerListeners(editor); } else { unRegisterListeners(editor); } } }
public void testCreateFromEditor() throws Throwable { VirtualFile file = myProjectRoot.findFileByRelativePath("file.txt"); assertNotNull(file); Document document = FileDocumentManager.getInstance().getDocument(file); assertNotNull(document); myEditor = EditorFactory.getInstance().createEditor(document, myProject); assertNotNull(myEditor); List<FileContent> expected = new ArrayList<FileContent>(); expected.add(new FileContent("file.txt", "file.txt content")); List<FileContent> actual = GithubCreateGistAction.collectContents(myProject, myEditor, file, null); checkEquals(expected, actual); }
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)); editor.getContentComponent().setFocusable(!isReadOnly); EditorSettings editorSettings = editor.getSettings(); editorSettings.setVirtualSpace(false); editorSettings.setLineMarkerAreaShown(false); editorSettings.setIndentGuidesShown(false); editorSettings.setLineNumbersShown(false); editorSettings.setFoldingOutlineShown(false); editorSettings.setCaretRowShown(false); EditorColorsScheme scheme = editor.getColorsScheme(); VirtualFile file = FileDocumentManager.getInstance().getFile(document); if (file != null) { EditorHighlighter highlighter = EditorHighlighterFactory.getInstance().createEditorHighlighter(file, scheme, project); ((EditorEx) editor).setHighlighter(highlighter); } return editor; }
public PsiAwareFileEditorManagerImpl(final Project project, final PsiManager psiManager, final WolfTheProblemSolver problemSolver, DockManager dockManager, MessageBus messageBus, EditorHistoryManager editorHistoryManager) { super(project, dockManager, editorHistoryManager); myPsiManager = psiManager; myProblemSolver = problemSolver; myPsiTreeChangeListener = new MyPsiTreeChangeListener(); myProblemListener = new MyProblemListener(); registerExtraEditorDataProvider(new TextEditorPsiDataProvider(), null); // reinit syntax highlighter for Groovy. In power save mode keywords are highlighted by GroovySyntaxHighlighter insteadof // GrKeywordAndDeclarationHighlighter. So we need to drop caches for token types attributes in LayeredLexerEditorHighlighter messageBus.connect().subscribe(PowerSaveMode.TOPIC, new PowerSaveMode.Listener() { @Override public void powerSaveStateChanged() { for (Editor editor : EditorFactory.getInstance().getAllEditors()) { ((EditorEx)editor).reinitSettings(); } } }); }
private void addVmEditor(String template) { EditorFactory factory = EditorFactory.getInstance(); Document velocityTemplate = factory.createDocument(template); editor = factory.createEditor(velocityTemplate, null, FileTypeManager.getInstance() .getFileTypeByExtension("vm"), false); GridConstraints constraints = new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(300, 300), null, 0, true); editorPane.add(editor.getComponent(), constraints); }
@Override public void projectOpened() { m_documentListener = new RmlDocumentListener(myProject); EditorFactory.getInstance().getEventMulticaster().addDocumentListener(m_documentListener); m_messageBusConnection = myProject.getMessageBus().connect(); m_messageBusConnection.subscribe(FileEditorManagerListener.FILE_EDITOR_MANAGER, new RmlFileEditorListener(myProject)); m_vfListener = new VirtualFileListener(myProject); VirtualFileManager.getInstance().addVirtualFileListener(m_vfListener); }
@Override public void projectClosed() { EditorFactory.getInstance().getEventMulticaster().removeDocumentListener(m_documentListener); VirtualFileManager.getInstance().removeVirtualFileListener(m_vfListener); m_documentListener.projectClosed(); m_messageBusConnection.disconnect(); }
@Override public void dispose() { Collections.list(styleGroup.getElements()).forEach(button -> button.removeActionListener(this)); classNamePrefixField.getDocument().removeDocumentListener(this); classNameSuffixField.getDocument().removeDocumentListener(this); generatedAnnotationCheckBox.removeActionListener(this); suppressWarningsAnnotationCheckBox.removeActionListener(this); if (previewEditor == null || previewEditor.isDisposed()) { return; } EditorFactory.getInstance().releaseEditor(previewEditor); }
@Override protected void dispose() { if (jsonEditor != null && !jsonEditor.isDisposed()) { EditorFactory.getInstance().releaseEditor(jsonEditor); } super.dispose(); }
@Test public void disposeShouldReleaseEditor() throws Exception { // exercise application.invokeAndWait(() -> underTest.dispose()); // verify final Editor[] actual = EditorFactory.getInstance().getAllEditors(); assertThat(actual) .isEmpty(); }
@Override public void dispose() { if (templatesEditor != null && !templatesEditor.isDisposed()) { EditorFactory.getInstance().releaseEditor(templatesEditor); } templatesEditor = null; }
private static void convertToAbsoluteOffset(JsonObject taskFileObject, JsonObject placeholderObject) { int line = placeholderObject.getAsJsonPrimitive(LINE).getAsInt(); int start = placeholderObject.getAsJsonPrimitive(START).getAsInt(); if (line == -1) { placeholderObject.addProperty(OFFSET, start); } else { Document document = EditorFactory.getInstance().createDocument(taskFileObject.getAsJsonPrimitive(TEXT).getAsString()); placeholderObject.addProperty(OFFSET, document.getLineStartOffset(line) + start); } }
private static void showPreviewDialog(@NotNull Project project, @NotNull TaskFile taskFile) { final FrameWrapper showPreviewFrame = new FrameWrapper(project); final LightVirtualFile userFile = new LightVirtualFile(taskFile.name, taskFile.text); showPreviewFrame.setTitle(userFile.getName()); LabeledEditor labeledEditor = new LabeledEditor(null); final EditorFactory factory = EditorFactory.getInstance(); Document document = FileDocumentManager.getInstance().getDocument(userFile); if (document == null) { return; } final EditorEx createdEditor = (EditorEx)factory.createEditor(document, project, userFile, true); Disposer.register(project, () -> factory.releaseEditor(createdEditor)); for (AnswerPlaceholder answerPlaceholder : taskFile.getActivePlaceholders()) { if (answerPlaceholder.getActiveSubtaskInfo().isNeedInsertText()) { answerPlaceholder.setLength(answerPlaceholder.getTaskText().length()); } Integer minIndex = Collections.min(answerPlaceholder.getSubtaskInfos().keySet()); answerPlaceholder.setUseLength(minIndex >= answerPlaceholder.getActiveSubtaskIndex()); EduAnswerPlaceholderPainter.drawAnswerPlaceholder(createdEditor, answerPlaceholder, JBColor.BLUE); } JPanel header = new JPanel(); header.setLayout(new BoxLayout(header, BoxLayout.Y_AXIS)); header.setBorder(new EmptyBorder(10, 10, 10, 10)); header.add(new JLabel("Read-only preview.")); String timeStamp = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss").format(Calendar.getInstance().getTime()); header.add(new JLabel(String.format("Created %s.", timeStamp))); JComponent editorComponent = createdEditor.getComponent(); labeledEditor.setComponent(editorComponent, header); createdEditor.setCaretVisible(false); createdEditor.setCaretEnabled(false); showPreviewFrame.setComponent(labeledEditor); if (!ApplicationManager.getApplication().isUnitTestMode()) { showPreviewFrame.setSize(new Dimension(500, 500)); showPreviewFrame.show(); } }
public Pair<Document, List<AnswerPlaceholder>> getPlaceholders(String name, boolean useLength, boolean removeMarkers) { try { String text = StringUtil.convertLineSeparators(FileUtil.loadFile(new File(getBasePath(), name))); Document tempDocument = EditorFactory.getInstance().createDocument(text); if (removeMarkers) { EditorTestUtil.extractCaretAndSelectionMarkers(tempDocument); } List<AnswerPlaceholder> placeholders = getPlaceholders(tempDocument, useLength); return Pair.create(tempDocument, placeholders); } catch (IOException e) { LOG.error(e); } return Pair.create(null, null); }
private void createUIComponents() { // TODO: place custom component creation code here rootPanel = new JPanel(); sqlPanel = new JPanel(); sqlPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); // 设置 sql text editor Document document = EditorFactory.getInstance().createDocument(""); sqlTextArea = EditorFactory.getInstance().createEditor(document, ideaContext.getProject(), SqlFileType.INSTANCE, false); sqlScrollPane = new JBScrollPane(); sqlScrollPane.setViewportView(sqlTextArea.getComponent()); }
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); }
@Override public void dispose() { for (Editor editor : editors.values()) { EditorFactory.getInstance().releaseEditor(editor); } Disposer.dispose(textEditor); Disposer.dispose(this); }
public void documentChanged(DocumentEvent event) { Editor[] editors = EditorFactory.getInstance().getEditors(event.getDocument()); for (Editor editor : editors) { editor.getMarkupModel().removeAllHighlighters(); HighLight.removeAll(); } }
private void updateViewerForSelection() { if (myAllContents.isEmpty()) return; String fullString = getSelectedText(); if (myViewer != null) { EditorFactory.getInstance().releaseEditor(myViewer); } if (myUseIdeaEditor) { myViewer = createIdeaEditor(fullString); JComponent component = myViewer.getComponent(); JComponent aboveEditorComponent = getAboveEditorComponent(); component.setPreferredSize(JBUI.size(300, 500)); if (aboveEditorComponent != null) { JPanel panel = JBUI.Panels.simplePanel(0, 10) .addToTop(aboveEditorComponent) .addToCenter(component); mySplitter.setSecondComponent(panel); } else { mySplitter.setSecondComponent(component); } updateViewerForSelection(myViewer, myAllContents, getSelectedIndices()); } else { final JTextArea textArea = new JTextArea(fullString); textArea.setRows(3); textArea.setWrapStyleWord(true); textArea.setLineWrap(true); textArea.setSelectionStart(0); textArea.setSelectionEnd(textArea.getText().length()); textArea.setEditable(false); mySplitter.setSecondComponent(ScrollPaneFactory.createScrollPane(textArea)); } mySplitter.revalidate(); }
protected Editor createIdeaEditor(String text) { Document doc = EditorFactory.getInstance().createDocument(text); Editor editor = EditorFactory.getInstance().createViewer(doc, myProject); editor.getSettings().setFoldingOutlineShown(false); editor.getSettings().setLineNumbersShown(false); editor.getSettings().setLineMarkerAreaShown(false); editor.getSettings().setIndentGuidesShown(false); return editor; }
@Override public void dispose() { super.dispose(); SplitterProportionsData d = new SplitterProportionsDataImpl(); d.externalizeToDimensionService(getClass().getName()); d.saveSplitterProportions(mySplitter); if (myViewer != null) { EditorFactory.getInstance().releaseEditor(myViewer); myViewer = null; } }
public void dispose() { if (myOutput != null) { EditorFactory.getInstance().releaseEditor(myOutput); myOutput = null; } if (myErrorsView != null) { myErrorsView.dispose(); myErrorsView = null; } }
public void startIfNeeded() { if (TRACKING.compareAndSet(false, true)) ApplicationManager.getApplication().invokeLater(() -> ApplicationManager.getApplication().runWriteAction(() -> { VirtualFileManager.getInstance().addVirtualFileListener(new StylintConfigFileVfsListener(), StylintConfigFileChangeTracker.this.project); EditorEventMulticaster multicaster = EditorFactory.getInstance().getEventMulticaster(); multicaster.addDocumentListener(new StylintConfigFileDocumentListener(), StylintConfigFileChangeTracker.this.project); })); }
private void startListener() { if (LISTENING.compareAndSet(false, true)) ApplicationManager.getApplication().invokeLater(new Runnable() { public void run() { ApplicationManager.getApplication().runWriteAction(new Runnable() { public void run() { VirtualFileManager.getInstance().addVirtualFileListener(new SassLintConfigFileVfsListener(), SassLintConfigFileListener.this.project); EditorEventMulticaster multicaster = EditorFactory.getInstance().getEventMulticaster(); multicaster.addDocumentListener(new SassLintConfigFileDocumentListener(), SassLintConfigFileListener.this.project); } }); } }); }