下面列出了org.eclipse.jface.text.source.SourceViewer#setEditable ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
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;
}
@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;
}
JavaTextViewer(Composite parent) {
fSourceViewer= new SourceViewer(parent, null, SWT.LEFT_TO_RIGHT | SWT.H_SCROLL | SWT.V_SCROLL);
JavaTextTools tools= JavaCompareUtilities.getJavaTextTools();
if (tools != null) {
IPreferenceStore store= JavaPlugin.getDefault().getCombinedPreferenceStore();
fSourceViewer.configure(new JavaSourceViewerConfiguration(tools.getColorManager(), store, null, IJavaPartitions.JAVA_PARTITIONING));
}
fSourceViewer.setEditable(false);
String symbolicFontName= JavaMergeViewer.class.getName();
Font font= JFaceResources.getFont(symbolicFontName);
if (font != null)
fSourceViewer.getTextWidget().setFont(font);
}
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();
}
PyContentViewer(Composite parent, CompareConfiguration mp) {
fSourceViewer = new SourceViewer(parent, null, SWT.LEFT_TO_RIGHT | SWT.H_SCROLL | SWT.V_SCROLL);
IPreferenceStore store = PyDevUiPrefs.getChainedPrefStore();
final ColorAndStyleCache c = new ColorAndStyleCache(store);
// Ideally we wouldn't pass null for the grammarVersionProvider... although
// I haven't been able to get to this code at all (is this something still needed?)
// It seems that Eclipse (in 4.5m5 at least) never gets to use the org.eclipse.compare.contentViewers
// as it seems to use what's provided by org.eclipse.compare.contentMergeViewers or the
// editor directly... if that's not the case, first we need to discover how that's still needed.
fSourceViewer.configure(new PyEditConfigurationWithoutEditor(c, store, null));
fSourceViewer.setEditable(false);
parent.addDisposeListener(new DisposeListener() {
@Override
public void widgetDisposed(DisposeEvent e) {
c.dispose();
}
});
}
protected void createScriptPreviewComposite(final Composite mainComposite) {
final Composite previewComposite = new Composite(mainComposite, SWT.NONE);
previewComposite.setLayout(new FillLayout(SWT.VERTICAL));
previewComposite.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).span(2, 0).create());
final GroovyViewer groovyViewer = sourceViewerFactory.createSourceViewer(previewComposite, true);
groovyViewer.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).hint(SWT.DEFAULT, 300).create());
final SourceViewer sourceViewer = groovyViewer.getSourceViewer();
sourceViewer.setEditable(false);
sourceViewer.setEventConsumer(new IEventConsumer() {
@Override
public void processEvent(final VerifyEvent event) {
event.doit = false;
}
});
document = groovyViewer.getDocument();
document.set(generatedExpression.getContent());
}
private void configureSourceViewer(SourceViewer viewer) {
viewer.setEditable(false);
viewer.addTextListener(new ITextListener() {
@Override
public void textChanged(TextEvent event) {
updateHighlighting();
sourceViewer.getTextWidget().setFont(editorFont);
}
});
}
/**
* @param composite
*/
public SourceViewer createSourcePreview(Composite composite, IScriptFormatterFactory factory)
{
IPreferenceStore generalTextStore = EditorsUI.getPreferenceStore();
// TODO - Note that we pass the factory's preferences store and not calling to this.getPrefereceStore.
// In case we decide to unify the preferences into the this plugin, we might need to change this.
IPreferenceStore store = new ChainedPreferenceStore(new IPreferenceStore[] { factory.getPreferenceStore(),
generalTextStore });
SourceViewer fPreviewViewer = createPreviewViewer(composite, null, null, false, SWT.V_SCROLL | SWT.H_SCROLL
| SWT.BORDER, store);
if (fPreviewViewer == null)
{
return null;
}
SourceViewerConfiguration configuration = (SourceViewerConfiguration) factory
.createSimpleSourceViewerConfiguration(fColorManager, store, null, false);
fPreviewViewer.configure(configuration);
if (fPreviewViewer.getTextWidget().getTabs() == 0)
{
fPreviewViewer.getTextWidget().setTabs(4);
}
new ScriptSourcePreviewerUpdater(fPreviewViewer, configuration, store);
fPreviewViewer.setEditable(false);
IDocument document = new Document();
fPreviewViewer.setDocument(document);
IPartitioningConfiguration partitioningConfiguration = (IPartitioningConfiguration) factory
.getPartitioningConfiguration();
CompositePartitionScanner partitionScanner = new CompositePartitionScanner(
partitioningConfiguration.createSubPartitionScanner(), new NullSubPartitionScanner(),
new NullPartitionerSwitchStrategy());
IDocumentPartitioner partitioner = new ExtendedFastPartitioner(partitionScanner,
partitioningConfiguration.getContentTypes());
partitionScanner.setPartitioner((IExtendedPartitioner) partitioner);
partitioner.connect(document);
document.setDocumentPartitioner(partitioner);
return fPreviewViewer;
}
/**
* {@inheritDoc}
*/
public void createControl(Composite parent) {
fPane= new CreateTextFilePreviewer(parent, SWT.BORDER | SWT.FLAT);
Dialog.applyDialogFont(fPane);
fSourceViewer= new SourceViewer(fPane, null, SWT.V_SCROLL | SWT.H_SCROLL | SWT.MULTI | SWT.FULL_SELECTION);
fSourceViewer.setEditable(false);
fSourceViewer.getControl().setFont(JFaceResources.getFont(PreferenceConstants.EDITOR_TEXT_FONT));
fPane.setContent(fSourceViewer.getControl());
}
PropertiesFileViewer(Composite parent) {
fSourceViewer= new SourceViewer(parent, null, SWT.LEFT_TO_RIGHT | SWT.H_SCROLL | SWT.V_SCROLL);
JavaTextTools tools= JavaCompareUtilities.getJavaTextTools();
if (tools != null) {
IPreferenceStore store= JavaPlugin.getDefault().getCombinedPreferenceStore();
fSourceViewer.configure(new PropertiesFileSourceViewerConfiguration(tools.getColorManager(), store, null, IPropertiesFilePartitions.PROPERTIES_FILE_PARTITIONING));
}
fSourceViewer.setEditable(false);
String symbolicFontName= PropertiesFileMergeViewer.class.getName();
Font font= JFaceResources.getFont(symbolicFontName);
if (font != null)
fSourceViewer.getTextWidget().setFont(font);
}
@Override
protected SourceViewer createViewer(Composite parent) {
SourceViewer viewer = new LangSourceViewer(parent, null, null, false,
SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
viewer.configure(createPreviewerSourceViewerConfiguration());
viewer.setEditable(false);
viewer.setDocument(createViewerDocument());
return viewer;
}
@Override
protected ISourceViewer createSourceViewer(Composite parent,
org.eclipse.jface.text.source.IVerticalRuler ruler, int styles) {
SourceViewer sourceViewer = new SourceViewer(parent, ruler, styles);
sourceViewer.setEditable(false);
mPainter = new AnnotationPainter(sourceViewer, new AnnotationAccess());
sourceViewer.addPainter(mPainter);
return sourceViewer;
}