Java Code Examples for org.eclipse.jface.text.source.SourceViewer#setEditable()

The following examples show how to use org.eclipse.jface.text.source.SourceViewer#setEditable() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TypeScriptTemplatePreferencePage.java    From typescript.java with MIT License 6 votes vote down vote up
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;
}
 
Example 2
Source File: JavaTemplatePreferencePage.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
@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;
}
 
Example 3
Source File: JavaTextViewer.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
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);

}
 
Example 4
Source File: SyntaxColoringPreferencePage.java    From editorconfig-eclipse with Apache License 2.0 6 votes vote down vote up
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();
	}
 
Example 5
Source File: PyContentViewer.java    From Pydev with Eclipse Public License 1.0 6 votes vote down vote up
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();
        }
    });
}
 
Example 6
Source File: GeneratedScriptPreviewPage.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
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());
}
 
Example 7
Source File: WizardPreviewProvider.java    From n4js with Eclipse Public License 1.0 5 votes vote down vote up
private void configureSourceViewer(SourceViewer viewer) {
	viewer.setEditable(false);

	viewer.addTextListener(new ITextListener() {
		@Override
		public void textChanged(TextEvent event) {
			updateHighlighting();
			sourceViewer.getTextWidget().setFont(editorFont);
		}
	});

}
 
Example 8
Source File: AbstractFormatterPreferencePage.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
/**
 * @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;
}
 
Example 9
Source File: CreateTextFileChangePreviewViewer.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * {@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());
}
 
Example 10
Source File: PropertiesFileViewer.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
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);
}
 
Example 11
Source File: LangTemplatePreferencePage.java    From goclipse with Eclipse Public License 1.0 5 votes vote down vote up
@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;
}
 
Example 12
Source File: AnnotationEditor.java    From uima-uimaj with Apache License 2.0 3 votes vote down vote up
@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;
}