Example usage for com.intellij.openapi.options.colors ColorSettingsPage getDemoText

List of usage examples for com.intellij.openapi.options.colors ColorSettingsPage getDemoText

Introduction

In this page you can find the example usage for com.intellij.openapi.options.colors ColorSettingsPage getDemoText.

Prototype

@NonNls
@NotNull
String getDemoText();

Source Link

Document

Returns the text shown in the preview pane.

Usage

From source file:com.intellij.application.options.colors.NewColorAndFontPanel.java

License:Apache License

public NewColorAndFontPanel(final SchemesPanel schemesPanel, final OptionsPanel optionsPanel,
        final PreviewPanel previewPanel, final String category, final Collection<String> optionList,
        final ColorSettingsPage page) {
    super(new BorderLayout(0, 10));
    mySchemesPanel = schemesPanel;//w  w w .java2s  . c  o  m
    myOptionsPanel = optionsPanel;
    myPreviewPanel = previewPanel;
    myCategory = category;
    myOptionList = optionList;
    mySettingsPage = page;

    JPanel top = new JPanel(new BorderLayout());

    top.add(mySchemesPanel, BorderLayout.NORTH);
    top.add(myOptionsPanel.getPanel(), BorderLayout.CENTER);

    // We don't want to show non-used preview panel (it's considered to be not in use if it doesn't contain text).
    if (myPreviewPanel.getPanel() != null
            && (page == null || !StringUtil.isEmptyOrSpaces(page.getDemoText()))) {
        add(top, BorderLayout.NORTH);
        add(myPreviewPanel.getPanel(), BorderLayout.CENTER);
    } else {
        add(top, BorderLayout.CENTER);
    }

    previewPanel.addListener(new ColorAndFontSettingsListener.Abstract() {
        @Override
        public void selectionInPreviewChanged(final String typeToSelect) {
            optionsPanel.selectOption(typeToSelect);
        }
    });

    optionsPanel.addListener(new ColorAndFontSettingsListener.Abstract() {
        @Override
        public void settingsChanged() {
            if (schemesPanel.updateDescription(true)) {
                optionsPanel.applyChangesToScheme();
                previewPanel.updateView();
            }
        }

        @Override
        public void selectedOptionChanged(final Object selected) {
            if (ApplicationManager.getApplication().isDispatchThread()) {
                myPreviewPanel.blinkSelectedHighlightType(selected);
            }
        }

    });
    mySchemesPanel.addListener(new ColorAndFontSettingsListener.Abstract() {
        @Override
        public void schemeChanged(final Object source) {
            myOptionsPanel.updateOptionsList();
            myPreviewPanel.updateView();
        }
    });

}

From source file:com.intellij.application.options.colors.SimpleEditorPreview.java

License:Apache License

public SimpleEditorPreview(final ColorAndFontOptions options, final ColorSettingsPage page,
        final boolean navigatable) {
    myOptions = options;//w  ww.  j a  v  a2s.  c  o m
    myPage = page;

    String text = page.getDemoText();

    HighlightsExtractor extractant2 = new HighlightsExtractor(
            page.getAdditionalHighlightingTagToDescriptorMap());
    List<HighlightData> highlights = new ArrayList<HighlightData>();
    String stripped = extractant2.extractHighlights(text, highlights);
    myHighlightData = highlights.toArray(new HighlightData[highlights.size()]);
    int selectedLine = -1;
    myEditor = (EditorEx) FontEditorPreview.createPreviewEditor(stripped, 10, 3, selectedLine, myOptions,
            false);

    FontEditorPreview.installTrafficLights(myEditor);
    myBlinkingAlarm = new Alarm().setActivationComponent(myEditor.getComponent());
    if (navigatable) {
        addMouseMotionListener(myEditor, page.getHighlighter(), myHighlightData, false);

        CaretListener listener = new CaretAdapter() {
            @Override
            public void caretPositionChanged(CaretEvent e) {
                navigate(myEditor, true, e.getNewPosition(), page.getHighlighter(), myHighlightData, false);
            }
        };
        myEditor.getCaretModel().addCaretListener(listener);
    }
}