下面列出了org.eclipse.jface.text.source.SourceViewer#getControl ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
private SourceViewer createEditor(Composite parent) {
SourceViewer viewer= createViewer(parent);
int numberOfLines= viewer.getDocument().getNumberOfLines();
if (numberOfLines < 7) {
numberOfLines= 7;
} else if (numberOfLines > 14) {
numberOfLines= 14;
}
Control control= viewer.getControl();
GridData data= new GridData(GridData.FILL_BOTH);
data.widthHint= convertWidthInCharsToPixels(80);
data.heightHint= convertHeightInCharsToPixels(numberOfLines);
control.setLayoutData(data);
return viewer;
}
protected SourceViewer createViewer(Composite parent) {
IDocument document= new Document();
JavaScriptTextTools tools= JSDTTypeScriptUIPlugin.getDefault().getJavaTextTools();
tools.setupJavaDocumentPartitioner(document, IJavaScriptPartitions.JAVA_PARTITIONING);
IPreferenceStore store= JSDTTypeScriptUIPlugin.getDefault().getCombinedPreferenceStore();
SourceViewer viewer= new JavaSourceViewer(parent, null, null, false, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL, store);
SimpleJavaSourceViewerConfiguration configuration= new SimpleJavaSourceViewerConfiguration(tools.getColorManager(), store, null, IJavaScriptPartitions.JAVA_PARTITIONING, false);
viewer.configure(configuration);
viewer.setEditable(false);
viewer.setDocument(document);
Font font= JFaceResources.getFont(PreferenceConstants.EDITOR_TEXT_FONT);
viewer.getTextWidget().setFont(font);
new TypeScriptSourcePreviewerUpdater(viewer, configuration, store);
Control control= viewer.getControl();
GridData data= new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.FILL_VERTICAL);
control.setLayoutData(data);
return viewer;
}
private SourceViewer createEditor(final Composite parent) {
final SourceViewer viewer = createViewer(parent);
int numberOfLines = viewer.getDocument().getNumberOfLines();
if (numberOfLines < 7) {
numberOfLines = 7;
} else if (numberOfLines > 14) {
numberOfLines = 14;
}
final Control control = viewer.getControl();
final GridData data = new GridData(GridData.FILL_BOTH);
data.widthHint = convertWidthInCharsToPixels(80);
data.heightHint = convertHeightInCharsToPixels(numberOfLines);
control.setLayoutData(data);
return viewer;
}
@Override
protected SourceViewer createViewer(Composite parent) {
IDocument document= new Document();
JavaTextTools tools= JavaPlugin.getDefault().getJavaTextTools();
tools.setupJavaDocumentPartitioner(document, IJavaPartitions.JAVA_PARTITIONING);
IPreferenceStore store= JavaPlugin.getDefault().getCombinedPreferenceStore();
SourceViewer viewer= new JavaSourceViewer(parent, null, null, false, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL, store);
SimpleJavaSourceViewerConfiguration configuration= new SimpleJavaSourceViewerConfiguration(tools.getColorManager(), store, null, IJavaPartitions.JAVA_PARTITIONING, false);
viewer.configure(configuration);
viewer.setEditable(false);
viewer.setDocument(document);
Font font= JFaceResources.getFont(PreferenceConstants.EDITOR_TEXT_FONT);
viewer.getTextWidget().setFont(font);
new JavaSourcePreviewerUpdater(viewer, configuration, store);
Control control= viewer.getControl();
GridData data= new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.FILL_VERTICAL);
control.setLayoutData(data);
return viewer;
}
private Control createPreviewer(Composite parent) {
IPreferenceStore store = new ChainedPreferenceStore(new IPreferenceStore[] { fOverlayStore,
EditorConfigUIPlugin.getDefault().getCombinedPreferenceStore() });
fPreviewViewer = new SourceViewer(parent, null, null, false, SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER);
fColorManager = new EditorConfigColorManager(false);
EditorConfigSourceViewerConfiguration configuration = new EditorConfigSourceViewerConfiguration(fColorManager,
store, null, IEditorConfigPartitions.EDITOR_CONFIG_PARTITIONING);
fPreviewViewer.configure(configuration);
Font font = JFaceResources.getFont(PreferenceConstants.EDITOR_CONFIG_EDITOR_TEXT_FONT);
fPreviewViewer.getTextWidget().setFont(font);
new SourcePreviewerUpdater(fPreviewViewer, configuration, store);
fPreviewViewer.setEditable(false);
String content = loadPreviewContentFromFile("EditorConfigEditorColorSettingPreviewCode.txt"); //$NON-NLS-1$
IDocument document = new Document(content);
EditorConfigDocumentSetupParticipant.setupDocument(document);
fPreviewViewer.setDocument(document);
return fPreviewViewer.getControl();
}