com.intellij.application.options.colors.ColorAndFontOptions Java Examples

The following examples show how to use com.intellij.application.options.colors.ColorAndFontOptions. 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: 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 #2
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 #3
Source File: CoverageLineMarkerRenderer.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void actionPerformed(AnActionEvent e) {
  final ColorAndFontOptions colorAndFontOptions = new ColorAndFontOptions(){
    @Override
    protected List<ColorAndFontPanelFactory> createPanelFactories() {
      final GeneralColorsPage colorsPage = new GeneralColorsPage();
      final ColorAndFontPanelFactory panelFactory = new ColorAndFontPanelFactory() {
        @Nonnull
        @Override
        public NewColorAndFontPanel createPanel(@Nonnull ColorAndFontOptions options) {
          final SimpleEditorPreview preview = new SimpleEditorPreview(options, colorsPage);
          return NewColorAndFontPanel.create(preview, colorsPage.getDisplayName(), options, null, colorsPage);
        }

        @Nonnull
        @Override
        public String getPanelDisplayName() {
          return "Editor | " + getDisplayName() + " | " + colorsPage.getDisplayName();
        }
      };
      return Collections.singletonList(panelFactory);
    }
  };
  final Configurable[] configurables = colorAndFontOptions.buildConfigurables();
  try {
    final SearchableConfigurable general = colorAndFontOptions.findSubConfigurable(GeneralColorsPage.class);
    if (general != null) {
      final LineData lineData = getLineData(myLineNumber);
      ShowSettingsUtil.getInstance().editConfigurable(myEditor.getProject(), general,
                                                      general.enableSearch(getAttributesKey(lineData).getExternalName()));
    }
  }
  finally {
    for (Configurable configurable : configurables) {
      configurable.disposeUIResources();
    }
    colorAndFontOptions.disposeUIResources();
  }
}