com.intellij.openapi.editor.EditorSettings Java Examples

The following examples show how to use com.intellij.openapi.editor.EditorSettings. 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 vote down vote up
private void setupOutputEditor() {
    ((EditorEx) m_outputEditor).getContentComponent().setFocusCycleRoot(false);
    ((EditorEx) m_outputEditor).setHorizontalScrollbarVisible(true);
    ((EditorEx) m_outputEditor).setVerticalScrollbarVisible(true);
    ((EditorEx) m_outputEditor).getScrollPane().setBorder(null);

    EditorSettings editorSettings = ((EditorEx) m_outputEditor).getSettings();
    editorSettings.setLineNumbersShown(false);
    editorSettings.setIndentGuidesShown(false);
    editorSettings.setLineMarkerAreaShown(false);
    editorSettings.setFoldingOutlineShown(true);
    editorSettings.setRightMarginShown(false);
    editorSettings.setVirtualSpace(false);
    editorSettings.setAdditionalPageAtBottom(false);
    editorSettings.setAdditionalLinesCount(0);
    editorSettings.setAdditionalColumnsCount(0);
    editorSettings.setLineCursorWidth(1);
    editorSettings.setCaretRowShown(false);

    // output only editor
    m_outputEditor.setRendererMode(true);

    // tiny separation between output and prompt
    m_outputEditor.getComponent().setBorder(new SideBorder(JBColor.LIGHT_GRAY, SideBorder.BOTTOM));
}
 
Example #2
Source File: SettingsPanel.java    From json2java4idea with Apache License 2.0 6 votes vote down vote up
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 #3
Source File: NewClassDialog.java    From json2java4idea with Apache License 2.0 6 votes vote down vote up
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 #4
Source File: AnalyzeStacktraceUtil.java    From consulo with Apache License 2.0 6 votes vote down vote up
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 #5
Source File: TemplateEditorUtil.java    From consulo with Apache License 2.0 6 votes vote down vote up
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 #6
Source File: ExportToFileUtil.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
protected JComponent createCenterPanel() {
  final Document document = ((EditorFactoryImpl)EditorFactory.getInstance()).createDocument(true);
  ((DocumentImpl)document).setAcceptSlashR(true);

  myTextArea = EditorFactory.getInstance().createEditor(document, myProject, PlainTextFileType.INSTANCE, true);
  final EditorSettings settings = myTextArea.getSettings();
  settings.setLineNumbersShown(false);
  settings.setLineMarkerAreaShown(false);
  settings.setFoldingOutlineShown(false);
  settings.setRightMarginShown(false);
  settings.setAdditionalLinesCount(0);
  settings.setAdditionalColumnsCount(0);
  settings.setAdditionalPageAtBottom(false);
  ((EditorEx)myTextArea).setBackgroundColor(UIUtil.getInactiveTextFieldBackgroundColor());
  return myTextArea.getComponent();
}
 
Example #7
Source File: ProjectViewUi.java    From intellij with Apache License 2.0 6 votes vote down vote up
private static EditorEx createEditor(String tooltip) {
  Project project = getProject();
  Document document =
      LanguageTextField.createDocument(
          /* value= */ "", ProjectViewLanguage.INSTANCE, project, new SimpleDocumentCreator());
  EditorEx editor =
      (EditorEx)
          EditorFactory.getInstance()
              .createEditor(document, project, ProjectViewFileType.INSTANCE, false);
  final EditorSettings settings = editor.getSettings();
  settings.setLineNumbersShown(false);
  settings.setLineMarkerAreaShown(false);
  settings.setFoldingOutlineShown(false);
  settings.setRightMarginShown(false);
  settings.setAdditionalPageAtBottom(false);
  editor.getComponent().setMinimumSize(getEditorSize());
  editor.getComponent().setPreferredSize(getEditorSize());
  editor.getComponent().setToolTipText(tooltip);
  editor.getComponent().setFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, null);
  editor.getComponent().setFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS, null);
  return editor;
}
 
Example #8
Source File: TemplateConfigurable.java    From android-codegenerator-plugin-intellij with Apache License 2.0 6 votes vote down vote up
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 #9
Source File: IdeUtils.java    From StringManipulation with Apache License 2.0 6 votes vote down vote up
public static EditorImpl createEditorPreview(String text, boolean editable) {
	EditorColorsScheme scheme = EditorColorsManager.getInstance().getGlobalScheme();
	ColorAndFontOptions options = new ColorAndFontOptions();
	options.reset();
	options.selectScheme(scheme.getName());

	EditorFactory editorFactory = EditorFactory.getInstance();
	Document editorDocument = editorFactory.createDocument(text);
	EditorEx editor = (EditorEx) (editable ? editorFactory.createEditor(editorDocument) : editorFactory.createViewer(editorDocument));
	editor.setColorsScheme(scheme);
	EditorSettings settings = editor.getSettings();
	settings.setLineNumbersShown(true);
	settings.setWhitespacesShown(false);
	settings.setLineMarkerAreaShown(false);
	settings.setIndentGuidesShown(false);
	settings.setFoldingOutlineShown(false);
	settings.setAdditionalColumnsCount(0);
	settings.setAdditionalLinesCount(0);
	settings.setRightMarginShown(false);

	return (EditorImpl) editor;
}
 
Example #10
Source File: Utils.java    From idea-gitignore with MIT License 6 votes vote down vote up
/**
 * Creates and configures template preview editor.
 *
 * @param document virtual editor document
 * @param project  current project
 * @return editor
 */
@NotNull
public static Editor createPreviewEditor(@NotNull Document document, @Nullable Project project, boolean isViewer) {
    EditorEx editor = (EditorEx) EditorFactory.getInstance().createEditor(document, project,
            IgnoreFileType.INSTANCE, isViewer);
    editor.setCaretEnabled(!isViewer);

    final EditorSettings settings = editor.getSettings();
    settings.setLineNumbersShown(false);
    settings.setAdditionalColumnsCount(1);
    settings.setAdditionalLinesCount(0);
    settings.setRightMarginShown(false);
    settings.setFoldingOutlineShown(false);
    settings.setLineMarkerAreaShown(false);
    settings.setIndentGuidesShown(false);
    settings.setVirtualSpace(false);
    settings.setWheelFontChangeEnabled(false);

    EditorColorsScheme colorsScheme = editor.getColorsScheme();
    colorsScheme.setColor(EditorColors.CARET_ROW_COLOR, null);

    return editor;
}
 
Example #11
Source File: GoalEditor.java    From MavenHelper with Apache License 2.0 6 votes vote down vote up
@NotNull
private static Editor createEditor() {
	EditorColorsScheme scheme = EditorColorsManager.getInstance().getGlobalScheme();
	ColorAndFontOptions options = new ColorAndFontOptions();
	options.reset();
	options.selectScheme(scheme.getName());
	EditorFactory editorFactory = EditorFactory.getInstance();
	Document editorDocument = editorFactory.createDocument("");


	EditorEx editor = (EditorEx) (true ? editorFactory.createEditor(editorDocument) : editorFactory.createViewer(editorDocument));
	editor.setColorsScheme(scheme);
	EditorSettings settings = editor.getSettings();
	settings.setLineNumbersShown(false);
	settings.setUseSoftWraps(true);
	settings.setWhitespacesShown(false);
	settings.setLineMarkerAreaShown(false);
	settings.setIndentGuidesShown(false);
	settings.setFoldingOutlineShown(false);
	settings.setAdditionalColumnsCount(0);
	settings.setAdditionalLinesCount(0);
	settings.setRightMarginShown(false);

	return editor;
}
 
Example #12
Source File: PromptConsole.java    From reasonml-idea-plugin with MIT License 5 votes vote down vote up
private void setupPromptEditor() {
    EditorSettings editorSettings = ((EditorEx) m_promptEditor).getSettings();
    editorSettings.setAdditionalLinesCount(0);

    m_promptEditor.getComponent().setPreferredSize(new Dimension(0, 100));

    // add copy/paste actions
    m_promptEditor.addEditorMouseListener(EditorActionUtil.createEditorPopupHandler(IdeActions.GROUP_CUT_COPY_PASTE));

    // hook some key event on prompt editor
    m_promptEditor.getContentComponent().addKeyListener(new KeyAdapter() {
        @Override
        public void keyReleased(@NotNull KeyEvent e) {
            if (m_promptEnabled && e.isControlDown()) {
                int keyCode = e.getKeyCode();
                if (keyCode == KeyEvent.VK_ENTER) {
                    String command = normalizeCommand(m_promptEditor.getDocument().getText());
                    m_history.addInHistory(command);
                    m_consoleView.print(command + "\r\n", USER_INPUT);
                    m_consoleView.scrollToEnd();
                    ApplicationManager.getApplication().runWriteAction(() -> setPromptCommand(""));
                } else if (keyCode == KeyEvent.VK_UP || keyCode == KeyEvent.VK_DOWN) {
                    String history = m_history.getFromHistory(keyCode == KeyEvent.VK_DOWN);
                    if (history != null) {
                        ApplicationManager.getApplication().runWriteAction(() -> setPromptCommand(history));
                    }
                }
            }
        }
    });
}
 
Example #13
Source File: CopyrightConfigurable.java    From consulo with Apache License 2.0 5 votes vote down vote up
static void setupEditor(Editor editor) {
  EditorSettings settings = editor.getSettings();
  settings.setLineNumbersShown(false);
  settings.setFoldingOutlineShown(false);
  settings.setIndentGuidesShown(false);
  settings.setLineMarkerAreaShown(false);
}
 
Example #14
Source File: AbstractToggleUseSoftWrapsAction.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void update(@Nonnull AnActionEvent e) {
  if (myGlobal) {
    Editor editor = getEditor(e);
    if (editor != null) {
      EditorSettings settings = editor.getSettings();
      if (settings instanceof SettingsImpl && ((SettingsImpl)settings).getSoftWrapAppliancePlace() != myAppliancePlace) {
        e.getPresentation().setEnabledAndVisible(false);
        return;
      }
    }
  }
  super.update(e);
}
 
Example #15
Source File: QueryPanel.java    From nosql4idea with Apache License 2.0 5 votes vote down vote up
private static void fillEditorSettings(final EditorSettings editorSettings) {
    editorSettings.setWhitespacesShown(true);
    editorSettings.setLineMarkerAreaShown(false);
    editorSettings.setIndentGuidesShown(false);
    editorSettings.setLineNumbersShown(false);
    editorSettings.setAllowSingleLogicalLineFolding(true);
    editorSettings.setAdditionalColumnsCount(0);
    editorSettings.setAdditionalLinesCount(1);
    editorSettings.setUseSoftWraps(true);
    editorSettings.setUseTabCharacter(false);
    editorSettings.setCaretInsideTabs(false);
    editorSettings.setVirtualSpace(false);
}
 
Example #16
Source File: CsvFileEditorTest.java    From intellij-csv-validator with Apache License 2.0 5 votes vote down vote up
public void testCsvEditorSettingsAreApplied() {
    CsvEditorSettings csvEditorSettings = CsvEditorSettings.getInstance();
    csvEditorSettings.setCaretRowShown(false);
    csvEditorSettings.setUseSoftWraps(true);

    TextEditor textEditor = getCurrentTextEditor();

    EditorSettings editorSettings = textEditor.getEditor().getSettings();
    assertEquals(csvEditorSettings.isCaretRowShown(), editorSettings.isCaretRowShown());
    assertEquals(csvEditorSettings.isUseSoftWraps(), editorSettings.isUseSoftWraps());

    disposeTextEditor(textEditor);
}
 
Example #17
Source File: CsvFileEditorTest.java    From intellij-csv-validator with Apache License 2.0 5 votes vote down vote up
public void testCsvEditorIsTextEditorWithInitialCsvEditorSettings() {
    FileEditorProvider[] fileEditorProviders = FileEditorProviderManager.getInstance().getProviders(myFixture.getProject(), myFixture.getFile().getVirtualFile());
    FileEditor fileEditor = fileEditorProviders[0].createEditor(myFixture.getProject(), myFixture.getFile().getVirtualFile());
    assertInstanceOf(fileEditor, TextEditor.class);

    TextEditor textEditor = (TextEditor)fileEditor;

    CsvEditorSettings csvEditorSettings = CsvEditorSettings.getInstance();
    EditorSettings editorSettings = textEditor.getEditor().getSettings();
    assertEquals(csvEditorSettings.isCaretRowShown(), editorSettings.isCaretRowShown());
    assertEquals(csvEditorSettings.isUseSoftWraps(), editorSettings.isUseSoftWraps());

    disposeTextEditor(textEditor);
}
 
Example #18
Source File: CsvFileEditorProvider.java    From intellij-csv-validator with Apache License 2.0 5 votes vote down vote up
protected void applySettings(EditorSettings editorSettings, CsvEditorSettings csvEditorSettings) {
    if (editorSettings == null || csvEditorSettings == null) {
        return;
    }
    editorSettings.setCaretRowShown(csvEditorSettings.isCaretRowShown());
    editorSettings.setUseSoftWraps(csvEditorSettings.isUseSoftWraps());
}
 
Example #19
Source File: TemplateEditorUI.java    From CodeGen with MIT License 5 votes vote down vote up
/**
 * 创建编辑器
 */
private Editor createEditor(String template, String extension) {
    Document velocityTemplate = factory.createDocument(template);
    Editor editor = factory.createEditor(velocityTemplate,
            null, FileProviderFactory.getFileType(extension), false);

    EditorSettings editorSettings = editor.getSettings();
    editorSettings.setLineNumbersShown(true);
    return editor;
}
 
Example #20
Source File: EditorTextFieldProviderImpl.java    From consulo with Apache License 2.0 4 votes vote down vote up
private static void applyDefaultSettings(EditorEx ex) {
  EditorSettings settings = ex.getSettings();
  settings.setAdditionalColumnsCount(3);
  settings.setVirtualSpace(false);
}