コード例 #1
0
  private Control createPreviewer(Composite parent) {
    IPreferenceStore generalTextStore = EditorsUI.getPreferenceStore();
    IPreferenceStore store =
        new ChainedPreferenceStore(new IPreferenceStore[] {getPreferenceStore(), generalTextStore});
    fPreviewViewer =
        new CSourceViewer(
            parent, null, null, false, SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER, store);
    SimpleCSourceViewerConfiguration configuration =
        new SimpleCSourceViewerConfiguration(
            fColorManager, store, null, ICPartitions.C_PARTITIONING, false);
    fPreviewViewer.configure(configuration);
    Font font = JFaceResources.getFont(PreferenceConstants.EDITOR_TEXT_FONT);
    fPreviewViewer.getTextWidget().setFont(font);
    CSourcePreviewerUpdater.registerPreviewer(fPreviewViewer, configuration, store);
    fPreviewViewer.setEditable(false);

    String content = loadPreviewContentFromFile("ColorSettingPreviewCode.txt"); // $NON-NLS-1$
    IDocument document = new Document(content);
    CUIPlugin.getDefault()
        .getTextTools()
        .setupCDocumentPartitioner(document, ICPartitions.C_PARTITIONING, null);
    fPreviewViewer.setDocument(document);

    installSemanticHighlighting();

    return fPreviewViewer.getControl();
  }