editable preview in font configuration (IDEA-73342)

This commit is contained in:
Dmitry Jemerov
2011-10-12 18:17:31 +02:00
parent ec6a01022d
commit 4302a60aa9
3 changed files with 8 additions and 7 deletions
@@ -348,7 +348,8 @@ public class ColorAndFontOptions extends SearchableConfigurable.Parent.Abstract
private static class FontConfigurableFactory implements ColorAndFontPanelFactory {
public NewColorAndFontPanel createPanel(ColorAndFontOptions options) {
return new NewColorAndFontPanel(new SchemesPanel(options), new FontOptions(options), new FontEditorPreview(options), "Font", null, null){
FontEditorPreview previewPanel = new FontEditorPreview(options, true);
return new NewColorAndFontPanel(new SchemesPanel(options), new FontOptions(options), previewPanel, "Font", null, null){
@Override
public boolean containsFontOptions() {
return true;
@@ -363,7 +364,7 @@ public class ColorAndFontOptions extends SearchableConfigurable.Parent.Abstract
private static class ConsoleFontConfigurableFactory implements ColorAndFontPanelFactory {
public NewColorAndFontPanel createPanel(ColorAndFontOptions options) {
FontEditorPreview previewPanel = new FontEditorPreview(options) {
FontEditorPreview previewPanel = new FontEditorPreview(options, false) {
@Override
protected EditorColorsScheme updateOptionsScheme(EditorColorsScheme selectedScheme) {
return ConsoleViewUtil.updateConsoleColorScheme(selectedScheme);
@@ -36,12 +36,12 @@ public class FontEditorPreview implements PreviewPanel{
private final EventDispatcher<ColorAndFontSettingsListener> myDispatcher = EventDispatcher.create(ColorAndFontSettingsListener.class);
public FontEditorPreview(final ColorAndFontOptions options) {
public FontEditorPreview(final ColorAndFontOptions options, boolean editable) {
myOptions = options;
@Nls String text = getIDEDemoText();
myEditor = (EditorEx)createPreviewEditor(text, 10, 3, -1, myOptions);
myEditor = (EditorEx)createPreviewEditor(text, 10, 3, -1, myOptions, editable);
installTrafficLights(myEditor);
}
@@ -70,10 +70,10 @@ public class FontEditorPreview implements PreviewPanel{
((EditorMarkupModel)editor.getMarkupModel()).setErrorStripeVisible(true);
}
static Editor createPreviewEditor(String text, int column, int line, int selectedLine, ColorAndFontOptions options) {
static Editor createPreviewEditor(String text, int column, int line, int selectedLine, ColorAndFontOptions options, boolean editable) {
EditorFactory editorFactory = EditorFactory.getInstance();
Document editorDocument = editorFactory.createDocument(text);
EditorEx editor = (EditorEx)editorFactory.createViewer(editorDocument);
EditorEx editor = (EditorEx) (editable ? editorFactory.createEditor(editorDocument) : editorFactory.createViewer(editorDocument));
editor.setColorsScheme(options.getSelectedScheme());
EditorSettings settings = editor.getSettings();
settings.setLineNumbersShown(true);
@@ -66,7 +66,7 @@ public class SimpleEditorPreview implements PreviewPanel{
myHighlightData = extractant2.extractHighlights(text);
int selectedLine = -1;
myEditor = (EditorEx)FontEditorPreview.createPreviewEditor(extractant2.cutDefinedTags(text), 10, 3, selectedLine, myOptions);
myEditor = (EditorEx)FontEditorPreview.createPreviewEditor(extractant2.cutDefinedTags(text), 10, 3, selectedLine, myOptions, false);
FontEditorPreview.installTrafficLights(myEditor);
myBlinkingAlarm = new Alarm().setActivationComponent(myEditor.getComponent());