org.eclipse.jface.text.source.SourceViewerConfiguration Java Examples

The following examples show how to use org.eclipse.jface.text.source.SourceViewerConfiguration. 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: CompilationUnitEditor.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
@Override
protected void installTabsToSpacesConverter() {
	ISourceViewer sourceViewer= getSourceViewer();
	SourceViewerConfiguration config= getSourceViewerConfiguration();
	if (config != null && sourceViewer instanceof ITextViewerExtension7) {
		int tabWidth= config.getTabWidth(sourceViewer);
		TabsToSpacesConverter tabToSpacesConverter= new TabsToSpacesConverter();
		tabToSpacesConverter.setNumberOfSpacesPerTab(tabWidth);
		IDocumentProvider provider= getDocumentProvider();
		if (provider instanceof ICompilationUnitDocumentProvider) {
			ICompilationUnitDocumentProvider cup= (ICompilationUnitDocumentProvider) provider;
			tabToSpacesConverter.setLineTracker(cup.createLineTracker(getEditorInput()));
		} else
			tabToSpacesConverter.setLineTracker(new DefaultLineTracker());
		((ITextViewerExtension7)sourceViewer).setTabsToSpacesConverter(tabToSpacesConverter);
		updateIndentPrefixes();
	}
}
 
Example #2
Source File: CommonProjectionViewer.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void configure(SourceViewerConfiguration configuration)
{
	super.configure(configuration);

	fSnippetContentAssistant = new SnippetsContentAssistant();
	fSnippetContentAssistant.install(this);
	fKeyListener = new ExpandSnippetVerifyKeyListener((ITextEditor) getAdapter(ITextEditor.class), this,
			fSnippetContentAssistant);
	// add listener to our viewer
	prependVerifyKeyListener(fKeyListener);

	fPreferenceStore = EclipseUtil.instanceScope().getNode(CommonEditorPlugin.PLUGIN_ID);
	if (fPreferenceStore != null)
	{
		fPreferenceStore.addPreferenceChangeListener(this);
		setSnippetProcessorEnablement();
	}
}
 
Example #3
Source File: DefaultMergeViewer.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
protected SourceViewerConfiguration createSourceViewerConfiguration(SourceViewer sourceViewer,
		IEditorInput editorInput) {
	SourceViewerConfiguration sourceViewerConfiguration = null;
	if (editorInput != null && getEditor(sourceViewer) != null) {
		DefaultMergeEditor mergeEditor = getEditor(sourceViewer);
		sourceViewerConfiguration = mergeEditor.getXtextSourceViewerConfiguration();
		try {
			mergeEditor.init((IEditorSite) mergeEditor.getSite(), editorInput);
			mergeEditor.createActions();
		} catch (PartInitException partInitException) {
			throw new WrappedException(partInitException);
		}
	} else {
		sourceViewerConfiguration = sourceViewerConfigurationProvider.get();
	}
	return sourceViewerConfiguration;
}
 
Example #4
Source File: DefaultMergeViewer.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
protected void configureSourceViewer(SourceViewer sourceViewer) {
	IEditorInput editorInput = getEditorInput(sourceViewer);
	SourceViewerConfiguration sourceViewerConfiguration = createSourceViewerConfiguration(sourceViewer, editorInput);
	sourceViewer.unconfigure();
	sourceViewer.configure(sourceViewerConfiguration);
	IXtextDocument xtextDocument = xtextDocumentUtil.getXtextDocument(sourceViewer);
	if (xtextDocument != null) {
		if (!xtextDocument.readOnly(TEST_EXISTING_XTEXT_RESOURCE)) {
			String[] configuredContentTypes = sourceViewerConfiguration.getConfiguredContentTypes(sourceViewer);
			for (String contentType : configuredContentTypes) {
				sourceViewer.removeTextHovers(contentType);
			}
			sourceViewer.setHyperlinkDetectors(null, sourceViewerConfiguration.getHyperlinkStateMask(sourceViewer));
		}
	}
}
 
Example #5
Source File: PydevConsole.java    From Pydev with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public SourceViewerConfiguration createSourceViewerConfiguration() {
    PyContentAssistant contentAssist = new PyContentAssistant();
    IContentAssistProcessor processor = createConsoleCompletionProcessor(contentAssist);
    contentAssist.setContentAssistProcessor(processor, PydevScriptConsoleSourceViewerConfiguration.PARTITION_TYPE);

    contentAssist.enableAutoActivation(true);
    contentAssist.enableAutoInsert(false);
    contentAssist.setAutoActivationDelay(PyCodeCompletionPreferences.getAutocompleteDelay());

    PyCorrectionAssistant quickAssist = new PyCorrectionAssistant();
    // next create a content assistant processor to populate the completions window
    IQuickAssistProcessor quickAssistProcessor = createConsoleQuickAssistProcessor(quickAssist);

    // Correction assist works on all
    quickAssist.setQuickAssistProcessor(quickAssistProcessor);

    SourceViewerConfiguration cfg = new PydevScriptConsoleSourceViewerConfiguration(createHover(), contentAssist,
            quickAssist);
    return cfg;
}
 
Example #6
Source File: LangTemplatePreferencePage.java    From goclipse with Eclipse Public License 1.0 6 votes vote down vote up
@Override
protected SourceViewer createViewer(Composite parent) {
	LangSourceViewer viewer = new LangSourceViewer(parent, null, null, false,
		SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
	
	final IContentAssistProcessor templateProcessor = getTemplateProcessor();
	
	IDocument document = new Document();
	LangDocumentPartitionerSetup.getInstance().setup(document);
	
	IPreferenceStore store = LangUIPlugin.getDefault().getCombinedPreferenceStore();
	SourceViewerConfiguration configuration = EditorSettings_Actual
			.createTemplateEditorSourceViewerConfiguration(store, templateProcessor);
	viewer.configure(configuration);
	viewer.setEditable(true);
	viewer.setDocument(document);
	
	return viewer;
}
 
Example #7
Source File: PropertiesFileMergeViewer.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
@Override
protected void configureTextViewer(TextViewer textViewer) {
	if (!(textViewer instanceof SourceViewer))
		return;

	if (fPreferenceStore == null) {
		fSourceViewerConfigurations= new ArrayList<SourceViewerConfiguration>(3);
		fPreferenceStore= JavaPlugin.getDefault().getCombinedPreferenceStore();
		fPreferenceChangeListener= new IPropertyChangeListener() {
			public void propertyChange(PropertyChangeEvent event) {
				Iterator<SourceViewerConfiguration> iter= fSourceViewerConfigurations.iterator();
				while (iter.hasNext())
					((PropertiesFileSourceViewerConfiguration)iter.next()).handlePropertyChangeEvent(event);
				invalidateTextPresentation();
			}
		};
		fPreferenceStore.addPropertyChangeListener(fPreferenceChangeListener);
	}

	SourceViewerConfiguration sourceViewerConfiguration= new PropertiesFileSourceViewerConfiguration(JavaPlugin.getDefault().getJavaTextTools().getColorManager(), fPreferenceStore, null,
			getDocumentPartitioning());

	fSourceViewerConfigurations.add(sourceViewerConfiguration);
	((SourceViewer)textViewer).configure(sourceViewerConfiguration);
}
 
Example #8
Source File: TypeScriptEditor.java    From typescript.java with MIT License 6 votes vote down vote up
@Override
protected void installTabsToSpacesConverter() {
	ISourceViewer sourceViewer = getSourceViewer();
	SourceViewerConfiguration config = getSourceViewerConfiguration();
	if (config != null && sourceViewer instanceof ITextViewerExtension7) {
		int tabWidth = config.getTabWidth(sourceViewer);
		TabsToSpacesConverter tabToSpacesConverter = new TabsToSpacesConverter();
		tabToSpacesConverter.setNumberOfSpacesPerTab(tabWidth);
		IDocumentProvider provider = getDocumentProvider();
		if (provider instanceof ICompilationUnitDocumentProvider) {
			ICompilationUnitDocumentProvider cup = (ICompilationUnitDocumentProvider) provider;
			tabToSpacesConverter.setLineTracker(cup.createLineTracker(getEditorInput()));
		} else
			tabToSpacesConverter.setLineTracker(new DefaultLineTracker());
		((ITextViewerExtension7) sourceViewer).setTabsToSpacesConverter(tabToSpacesConverter);
		updateIndentPrefixes();
	}
}
 
Example #9
Source File: JavaEditor.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
@Override
protected void setPreferenceStore(IPreferenceStore store) {
	super.setPreferenceStore(store);
	SourceViewerConfiguration sourceViewerConfiguration= getSourceViewerConfiguration();
	if (sourceViewerConfiguration == null || sourceViewerConfiguration instanceof JavaSourceViewerConfiguration) {
		JavaTextTools textTools= JavaPlugin.getDefault().getJavaTextTools();
		setSourceViewerConfiguration(new JavaSourceViewerConfiguration(textTools.getColorManager(), store, this, IJavaPartitions.JAVA_PARTITIONING));
	}

	if (getSourceViewer() instanceof JavaSourceViewer)
		((JavaSourceViewer)getSourceViewer()).setPreferenceStore(store);

	fMarkOccurrenceAnnotations= store.getBoolean(PreferenceConstants.EDITOR_MARK_OCCURRENCES);
	fStickyOccurrenceAnnotations= store.getBoolean(PreferenceConstants.EDITOR_STICKY_OCCURRENCES);
	fMarkTypeOccurrences= store.getBoolean(PreferenceConstants.EDITOR_MARK_TYPE_OCCURRENCES);
	fMarkMethodOccurrences= store.getBoolean(PreferenceConstants.EDITOR_MARK_METHOD_OCCURRENCES);
	fMarkConstantOccurrences= store.getBoolean(PreferenceConstants.EDITOR_MARK_CONSTANT_OCCURRENCES);
	fMarkFieldOccurrences= store.getBoolean(PreferenceConstants.EDITOR_MARK_FIELD_OCCURRENCES);
	fMarkLocalVariableypeOccurrences= store.getBoolean(PreferenceConstants.EDITOR_MARK_LOCAL_VARIABLE_OCCURRENCES);
	fMarkExceptions= store.getBoolean(PreferenceConstants.EDITOR_MARK_EXCEPTION_OCCURRENCES);
	fMarkImplementors= store.getBoolean(PreferenceConstants.EDITOR_MARK_IMPLEMENTORS);
	fMarkMethodExitPoints= store.getBoolean(PreferenceConstants.EDITOR_MARK_METHOD_EXIT_POINTS);
	fMarkBreakContinueTargets= store.getBoolean(PreferenceConstants.EDITOR_MARK_BREAK_CONTINUE_TARGETS);
}
 
Example #10
Source File: ProjectionViewerExt.java    From goclipse with Eclipse Public License 1.0 5 votes vote down vote up
public void doConfigure(SourceViewerConfiguration configuration) {
	super.configure(configuration);
	
	if(configuration instanceof AbstractLangBasicSourceViewerConfiguration) {
		AbstractLangBasicSourceViewerConfiguration svc = (AbstractLangBasicSourceViewerConfiguration) configuration;
		svc.configureViewer(this);
	}
}
 
Example #11
Source File: ToggleSLCommentAction.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
public void configure(ISourceViewer sourceViewer, SourceViewerConfiguration configuration) {
	fPrefixesMap= null;

	String[] types= configuration.getConfiguredContentTypes(sourceViewer);
	Map<String, String[]> prefixesMap= new HashMap<String, String[]>(types.length);
	for (int i= 0; i < types.length; i++) {
		String type= types[i];
		String[] prefixes= configuration.getDefaultPrefixes(sourceViewer, type);
		if (prefixes != null && prefixes.length > 0) {
			int emptyPrefixes= 0;
			for (int j= 0; j < prefixes.length; j++)
				if (prefixes[j].length() == 0)
					emptyPrefixes++;

			if (emptyPrefixes > 0) {
				String[] nonemptyPrefixes= new String[prefixes.length - emptyPrefixes];
				for (int j= 0, k= 0; j < prefixes.length; j++) {
					String prefix= prefixes[j];
					if (prefix.length() != 0) {
						nonemptyPrefixes[k]= prefix;
						k++;
					}
				}
				prefixes= nonemptyPrefixes;
			}

			prefixesMap.put(type, prefixes);
		}
	}
	fDocumentPartitioning= configuration.getConfiguredDocumentPartitioning(sourceViewer);
	fPrefixesMap= prefixesMap;
}
 
Example #12
Source File: ToggleCommentAction.java    From goclipse with Eclipse Public License 1.0 5 votes vote down vote up
public void configure(ISourceViewer sourceViewer, SourceViewerConfiguration configuration) {
	fPrefixesMap= null;

	String[] types= configuration.getConfiguredContentTypes(sourceViewer);
	Map<String, String[]> prefixesMap= new HashMap<String, String[]>(types.length);
	for (int i= 0; i < types.length; i++) {
		String type= types[i];
		String[] prefixes= configuration.getDefaultPrefixes(sourceViewer, type);
		if (prefixes != null && prefixes.length > 0) {
			int emptyPrefixes= 0;
			for (int j= 0; j < prefixes.length; j++)
				if (prefixes[j].length() == 0)
					emptyPrefixes++;

			if (emptyPrefixes > 0) {
				String[] nonemptyPrefixes= new String[prefixes.length - emptyPrefixes];
				for (int j= 0, k= 0; j < prefixes.length; j++) {
					String prefix= prefixes[j];
					if (prefix.length() != 0) {
						nonemptyPrefixes[k]= prefix;
						k++;
					}
				}
				prefixes= nonemptyPrefixes;
			}

			prefixesMap.put(type, prefixes);
		}
	}
	fDocumentPartitioning= configuration.getConfiguredDocumentPartitioning(sourceViewer);
	fPrefixesMap= prefixesMap;
}
 
Example #13
Source File: LangTextMergeViewer.java    From goclipse with Eclipse Public License 1.0 5 votes vote down vote up
protected SourceViewerConfiguration getSourceViewerConfiguration(ISourceViewer sourceViewer) {
	
	SourceViewerSourceBuffer sourceBuffer;
	if(sourceViewerNumber == 0) {
		// Ancestor viewer
		sourceBuffer = new SourceViewerSourceBuffer(sourceViewer);
	} else if(sourceViewerNumber == 1) {
		// Left viewer
		sourceBuffer = new SourceViewerSourceBuffer(sourceViewer) {
			@Override
			public Location getLocation_orNull() {
				return EditorUtils.getLocationOrNull(getEditorInput(sourceViewer));
			}
			@Override
			public boolean isDirty() {
				return isLeftDirty();
			}
		};
	} else {
		// Right viewer
		sourceBuffer = new SourceViewerSourceBuffer(sourceViewer) {
			@Override
			public Location getLocation_orNull() {
				return EditorUtils.getLocationOrNull(getEditorInput(sourceViewer));
			}
		};
	}
	
	return new LangSourceViewerConfiguration(getPreferenceStore(), sourceBuffer, null);
}
 
Example #14
Source File: DefaultContentAssistantFactory.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
protected void setContentAssistProcessor(ContentAssistant assistant, SourceViewerConfiguration configuration, ISourceViewer sourceViewer) {
	if (contentAssistProcessor != null) {
		for(String contentType: configuration.getConfiguredContentTypes(sourceViewer)) {
			assistant.setContentAssistProcessor(contentAssistProcessor, contentType);
		}
		if (contentAssistProcessor instanceof ICompletionListener) {
			assistant.setRepeatedInvocationMode(true);
			assistant.setStatusLineVisible(true);
			assistant.addCompletionListener((ICompletionListener) contentAssistProcessor);
		}
	}
}
 
Example #15
Source File: AbstractLangEditor.java    From goclipse with Eclipse Public License 1.0 5 votes vote down vote up
public AbstractLangSourceViewerConfiguration getSourceViewerConfiguration_asLang() {
	SourceViewerConfiguration svc = getSourceViewerConfiguration(); 
	if(svc instanceof AbstractLangSourceViewerConfiguration) {
		return (AbstractLangSourceViewerConfiguration) svc;
	}
	return null;
}
 
Example #16
Source File: DefaultContentAssistantFactory.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
private void configureDefaults(ContentAssistant assistant, SourceViewerConfiguration configuration, ISourceViewer sourceViewer) {
	setAutoInsert(assistant);
	setAutoActivation(assistant);
	setContentAssistProcessor(assistant, configuration, sourceViewer);
	setInformationControlCreator(assistant, configuration, sourceViewer);
	setDialogSettings(assistant);
	setColoredLabels(assistant);
}
 
Example #17
Source File: CompilationUnitEditor.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Configures the toggle comment action
 *
 * @since 3.0
 */
private void configureToggleCommentAction() {
	IAction action= getAction("ToggleComment"); //$NON-NLS-1$
	if (action instanceof ToggleCommentAction) {
		ISourceViewer sourceViewer= getSourceViewer();
		SourceViewerConfiguration configuration= getSourceViewerConfiguration();
		((ToggleCommentAction)action).configure(sourceViewer, configuration);
	}
}
 
Example #18
Source File: ToggleCommentAction.java    From tlaplus with MIT License 5 votes vote down vote up
/**
 * Configures the action
 * @param sourceViewer
 * @param configuration
 */
public void configure(ISourceViewer sourceViewer, SourceViewerConfiguration configuration)
{
    fPrefixesMap = null;

    String[] types = configuration.getConfiguredContentTypes(sourceViewer);
    Map prefixesMap = new HashMap(types.length);
    for (int i = 0; i < types.length; i++)
    {
        String type = types[i];
        String[] prefixes = configuration.getDefaultPrefixes(sourceViewer, type);
        if (prefixes != null && prefixes.length > 0)
        {
            int emptyPrefixes = 0;
            for (int j = 0; j < prefixes.length; j++)
                if (prefixes[j].length() == 0)
                    emptyPrefixes++;

            if (emptyPrefixes > 0)
            {
                String[] nonemptyPrefixes = new String[prefixes.length - emptyPrefixes];
                for (int j = 0, k = 0; j < prefixes.length; j++)
                {
                    String prefix = prefixes[j];
                    if (prefix.length() != 0)
                    {
                        nonemptyPrefixes[k] = prefix;
                        k++;
                    }
                }
                prefixes = nonemptyPrefixes;
            }

            prefixesMap.put(type, prefixes);
        }
    }
    fDocumentPartitioning = configuration.getConfiguredDocumentPartitioning(sourceViewer);
    fPrefixesMap = prefixesMap;
}
 
Example #19
Source File: AbstractThemeableEditor.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Added so we can set TM_TAB_SIZE for scripting.
 * 
 * @return
 */
public int getTabSize()
{
	SourceViewerConfiguration config = getSourceViewerConfiguration();
	if (config != null)
	{
		return config.getTabWidth(getSourceViewer());
	}
	return 4;
}
 
Example #20
Source File: FormHelper.java    From tlaplus with MIT License 5 votes vote down vote up
public static SourceViewer createFormsSourceViewer(FormToolkit toolkit, Composite parent, int flags, SourceViewerConfiguration config)
{
    SourceViewer sourceViewer = createSourceViewer(parent, flags, config);
    sourceViewer.setData(FormToolkit.KEY_DRAW_BORDER, FormToolkit.TREE_BORDER);

    sourceViewer.getTextWidget().setData(FormToolkit.KEY_DRAW_BORDER, FormToolkit.TEXT_BORDER);
    toolkit.adapt(sourceViewer.getTextWidget(), true, true);

    return sourceViewer;
}
 
Example #21
Source File: FormHelper.java    From tlaplus with MIT License 5 votes vote down vote up
/**
 * Creates the source viewer
 * @param parent
 * @param flags
 * @return
 */
public static SourceViewer createOutputViewer(Composite parent, int flags)
{
    SourceViewer sourceViewer = new SourceViewer(parent, null, null, false, flags);
    SourceViewerConfiguration configuration = new SourceViewerConfiguration();
    sourceViewer.configure(configuration);
    sourceViewer.setTabsToSpacesConverter(getTabToSpacesConverter());

    StyledText control = sourceViewer.getTextWidget();
    control.setFont(TLCUIActivator.getDefault().getOutputFont());
    control.setEditable(false);
    return sourceViewer;
}
 
Example #22
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 #23
Source File: FormHelper.java    From tlaplus with MIT License 5 votes vote down vote up
public static SourceViewer createSourceViewer(Composite parent, int flags, SourceViewerConfiguration config)
{
    SourceViewer sourceViewer = new SourceViewer(parent, null, null, false, flags);
    sourceViewer.configure(config);
    sourceViewer.setTabsToSpacesConverter(getTabToSpacesConverter());

    StyledText control = sourceViewer.getTextWidget();
    control.setWordWrap(true);
    control.setFont(TLCUIActivator.getDefault().getCourierFont());
    control.setEditable(true);
    return sourceViewer;
}
 
Example #24
Source File: TypeScriptEditor.java    From typescript.java with MIT License 5 votes vote down vote up
/**
 * Configures the toggle comment action
 *
 * 
 */
private void configureToggleCommentAction() {
	IAction action = getAction("ToggleComment"); //$NON-NLS-1$
	if (action instanceof ToggleCommentAction) {
		ISourceViewer sourceViewer = getSourceViewer();
		SourceViewerConfiguration configuration = getSourceViewerConfiguration();
		((ToggleCommentAction) action).configure(sourceViewer, configuration);
	}
}
 
Example #25
Source File: TypeScriptSourceViewer.java    From typescript.java with MIT License 5 votes vote down vote up
@Override
public void configure(SourceViewerConfiguration configuration) {
	super.configure(configuration);
	if (configuration instanceof TypeScriptSourceViewerConfiguration) {
		TypeScriptSourceViewerConfiguration tsConfiguration = (TypeScriptSourceViewerConfiguration) configuration;
		implementationPresenter = tsConfiguration.getImplementationPresenter(this);
		if (implementationPresenter != null)
			implementationPresenter.install(this);
	}
}
 
Example #26
Source File: XtextSourceViewerEx.java    From statecharts with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void configure(SourceViewerConfiguration configuration) {
	// We have to set the preference store via reflection here because Xtext
	// uses package visibility for the setter
	Field declaredField;
	try {
		declaredField = TextSourceViewerConfiguration.class
				.getDeclaredField("fPreferenceStore");
		declaredField.setAccessible(true);
		declaredField.set(configuration, this.preferenceStore);
	} catch (Exception e) {
		e.printStackTrace();
	}
	super.configure(configuration);
}
 
Example #27
Source File: ToggleCommentAction.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
public void configure(ISourceViewer sourceViewer, SourceViewerConfiguration configuration) {
	fPrefixesMap= null;

	String[] types= configuration.getConfiguredContentTypes(sourceViewer);
	Map<String, String[]> prefixesMap= new HashMap<String, String[]>(types.length);
	for (int i= 0; i < types.length; i++) {
		String type= types[i];
		String[] prefixes= configuration.getDefaultPrefixes(sourceViewer, type);
		if (prefixes != null && prefixes.length > 0) {
			int emptyPrefixes= 0;
			for (int j= 0; j < prefixes.length; j++)
				if (prefixes[j].length() == 0)
					emptyPrefixes++;

			if (emptyPrefixes > 0) {
				String[] nonemptyPrefixes= new String[prefixes.length - emptyPrefixes];
				for (int j= 0, k= 0; j < prefixes.length; j++) {
					String prefix= prefixes[j];
					if (prefix.length() != 0) {
						nonemptyPrefixes[k]= prefix;
						k++;
					}
				}
				prefixes= nonemptyPrefixes;
			}

			prefixesMap.put(type, prefixes);
		}
	}
	fDocumentPartitioning= configuration.getConfiguredDocumentPartitioning(sourceViewer);
	fPrefixesMap= prefixesMap;
}
 
Example #28
Source File: KaizenTemplatePreferences.java    From KaiZen-OpenAPI-Editor with Eclipse Public License 1.0 5 votes vote down vote up
public KaizenTemplatePreferences(SourceViewerConfiguration sourceViewerConfiguration,
        IPreferenceStore preferenceStore, TemplateStore templateStore, ContextTypeRegistry contextTypeRegistry) {
    this.sourceViewerConfiguration = sourceViewerConfiguration;
    setPreferenceStore(preferenceStore);
    setTemplateStore(templateStore);
    setContextTypeRegistry(contextTypeRegistry);
}
 
Example #29
Source File: PropertiesFileEditor.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Configures the toggle comment action.
 *
 * @since 3.4
 */
private void configureToggleCommentAction() {
	IAction action= getAction(IJavaEditorActionDefinitionIds.TOGGLE_COMMENT);
	if (action instanceof ToggleCommentAction) {
		ISourceViewer sourceViewer= getSourceViewer();
		SourceViewerConfiguration configuration= getSourceViewerConfiguration();
		((ToggleCommentAction)action).configure(sourceViewer, configuration);
	}
}
 
Example #30
Source File: XtendContentAssistFactory.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@Override
protected void setContentAssistProcessor(ContentAssistant assistant, SourceViewerConfiguration configuration,
		ISourceViewer sourceViewer) {
	super.setContentAssistProcessor(assistant, configuration, sourceViewer);
	assistant.setContentAssistProcessor(javaDocContentAssistProcessor,TokenTypeToPartitionMapper.JAVA_DOC_PARTITION);
	assistant.setContentAssistProcessor(null, TerminalsTokenTypeToPartitionMapper.SL_COMMENT_PARTITION);
	assistant.setContentAssistProcessor(null, TerminalsTokenTypeToPartitionMapper.COMMENT_PARTITION);
}