/** * Handles a property change event describing a change of the editor's preference delta and updates * the preference related editor properties. * * @param event the property change event */ @Override protected void handlePreferenceStoreChanged(PropertyChangeEvent event) { String property = event.getProperty(); try { SourceViewerConfiguration config = getSourceViewerConfiguration(); if (config != null) ((FluentMkSourceViewerConfiguration) config).handlePropertyChangeEvent(event); if (Prefs.EDITOR_TAB_WIDTH.equals(property)) { StyledText textWidget = getViewer().getTextWidget(); int tabWidth = getSourceViewerConfiguration().getTabWidth(getViewer()); if (textWidget.getTabs() != tabWidth) { textWidget.setTabs(tabWidth); } uninstallTabsToSpacesConverter(); if (isTabsToSpacesConversionEnabled()) { installTabsToSpacesConverter(); } else { updateIndentPrefixes(); } return; } } finally { super.handlePreferenceStoreChanged(event); } }
@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(); } }
/** * Creates the viewer to be used to display the pattern. Subclasses may override. * * @param parent the parent composite of the viewer * @return a configured <code>SourceViewer</code> */ protected SourceViewer createViewer(Composite parent) { SourceViewer viewer= new SourceViewer(parent, null, null, false, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL); SourceViewerConfiguration configuration= new SourceViewerConfiguration() { @Override public IContentAssistant getContentAssistant(ISourceViewer sourceViewer) { ContentAssistant assistant= new ContentAssistant(); assistant.enableAutoActivation(true); assistant.enableAutoInsert(true); assistant.setContentAssistProcessor(fTemplateProcessor, IDocument.DEFAULT_CONTENT_TYPE); return assistant; } }; viewer.configure(configuration); return viewer; }
protected void configureSourceViewer(SourceViewer sourceViewer) { IEditorInput editorInput = getEditorInput(sourceViewer); SourceViewerConfiguration sourceViewerConfiguration = createSourceViewerConfiguration(sourceViewer, editorInput); sourceViewer.unconfigure(); sourceViewer.configure(sourceViewerConfiguration); if (sourceViewer.getDocument() instanceof IXtextDocument) { IXtextDocument xtextDocument = (IXtextDocument) sourceViewer.getDocument(); 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)); } } }
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; }
@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(); } }
@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(); } }
@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); }
@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); }
private NSISSourceViewer createPreviewer(Composite parent) { NSISSourceViewer previewer = new NSISSourceViewer(parent, null, null, false, SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER | SWT.WRAP); NSISTextUtility.hookSourceViewer(previewer); SourceViewerConfiguration configuration = new NSISSourceViewerConfiguration( new ChainedPreferenceStore(new IPreferenceStore[] { NSISPreferences.getInstance().getPreferenceStore(), EditorsUI.getPreferenceStore() })); previewer.configure(configuration); new NSISDocumentSetupParticipant().setup(mCommandDoc); previewer.setDocument(mCommandDoc); previewer.setEditable(false); final StyledText textWidget = previewer.getTextWidget(); textWidget.getCaret().setVisible(false); textWidget.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { textWidget.setSelectionRange(e.x, 0); } }); return previewer; }
private Control createPreviewer(Composite parent) { mPreviewer= new NSISSourceViewer(parent, null, null, false, SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER); NSISTextUtility.hookSourceViewer(mPreviewer); SourceViewerConfiguration configuration= new NSISSourceViewerConfiguration(new ChainedPreferenceStore(new IPreferenceStore[]{mPreferenceStore,getPreferenceStore(), EditorsUI.getPreferenceStore()})); mPreviewer.configure(configuration); InputStream is = null; String content= ""; //$NON-NLS-1$ try { is = getClass().getResourceAsStream("NSISPreview.txt"); //$NON-NLS-1$ content= new String(IOUtility.loadContentFromStream(is)); } catch(Exception e) { EclipseNSISPlugin.getDefault().log(e); } finally { IOUtility.closeIO(is); } IDocument document= new Document(content); new NSISDocumentSetupParticipant().setup(document); mPreviewer.setDocument(document); mPreviewer.setEditable(false); return mPreviewer.getControl(); }
@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(PyCodeCompletionPreferencesPage.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; }
@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; }
@Override protected void setContentAssistProcessor(ContentAssistant assistant, SourceViewerConfiguration configuration, ISourceViewer sourceViewer) { super.setContentAssistProcessor(assistant, configuration, sourceViewer); assistant.setContentAssistProcessor(jsDocContentAssistProcessor, TokenTypeToPartitionMapper.JS_DOC_PARTITION); assistant.setContentAssistProcessor(null, TokenTypeToPartitionMapper.REG_EX_PARTITION); assistant.setContentAssistProcessor(null, TokenTypeToPartitionMapper.TEMPLATE_LITERAL_PARTITION); assistant.setContentAssistProcessor(null, TerminalsTokenTypeToPartitionMapper.SL_COMMENT_PARTITION); assistant.setContentAssistProcessor(null, TerminalsTokenTypeToPartitionMapper.COMMENT_PARTITION); }
public void handleColorSettingsChanged() { // done like in TextEditor for spelling ISourceViewer viewer = getSourceViewer(); SourceViewerConfiguration configuration = getSourceViewerConfiguration(); if (viewer instanceof ISourceViewerExtension2) { ISourceViewerExtension2 viewerExtension2 = (ISourceViewerExtension2) viewer; viewerExtension2.unconfigure(); if (configuration instanceof BatchSourceViewerConfiguration) { BatchSourceViewerConfiguration gconf = (BatchSourceViewerConfiguration) configuration; gconf.updateTextScannerDefaultColorToken(); } viewer.configure(configuration); } }
public void setSourceViewerConfiguration() { SourceViewerConfiguration configuration; JavaScriptTextTools jstt = new JavaScriptTextTools(getPreferenceStore()); configuration = new MyJSEditorSourceViewerConfiguration(jstt.getColorManager(), getPreferenceStore(), this, null); setSourceViewerConfiguration(configuration); }
public void handleColorSettingsChanged() { // done like in TextEditor for spelling ISourceViewer viewer = getSourceViewer(); SourceViewerConfiguration configuration = getSourceViewerConfiguration(); if (viewer instanceof ISourceViewerExtension2) { ISourceViewerExtension2 viewerExtension2 = (ISourceViewerExtension2) viewer; viewerExtension2.unconfigure(); if (configuration instanceof BashSourceViewerConfiguration) { BashSourceViewerConfiguration gconf = (BashSourceViewerConfiguration) configuration; gconf.updateTextScannerDefaultColorToken(); } viewer.configure(configuration); } }
private static void setPreferenceStoreOfSourceViewerConfiguration(ITextEditor textEditor, IPreferenceStore preferenceStore) throws Exception { Field f = AbstractTextEditor.class.getDeclaredField("fConfiguration"); f.setAccessible(true); SourceViewerConfiguration oldConfig = (SourceViewerConfiguration) f.get(textEditor); if (oldConfig instanceof TextSourceViewerConfiguration) { Field f2 = TextSourceViewerConfiguration.class.getDeclaredField("fPreferenceStore"); f2.setAccessible(true); f2.set(oldConfig, preferenceStore); } }
public void handleColorSettingsChanged() { // done like in TextEditor for spelling ISourceViewer viewer = getSourceViewer(); SourceViewerConfiguration configuration = getSourceViewerConfiguration(); if (viewer instanceof ISourceViewerExtension2) { ISourceViewerExtension2 viewerExtension2 = (ISourceViewerExtension2) viewer; viewerExtension2.unconfigure(); if (configuration instanceof ExtendedSourceViewerConfiguration) { ExtendedSourceViewerConfiguration gconf = (ExtendedSourceViewerConfiguration) configuration; gconf.updateTextScannerDefaultColorToken(); } viewer.configure(configuration); } }
@Override public void configure(SourceViewerConfiguration config) { super.configure(config); if (config instanceof Configuration) { configuration = (Configuration) config; configurePreferenceKeys(); // Install a listener hyperlinkChangeListener = new IPropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent event) { String property = event.getProperty(); if (preferenceKeysForEnablement.contains(property)) { resetHyperlinkDetectors(); final Control control = getControl(); if (control != null && !control.isDisposed()) { control.getDisplay().asyncExec(new Runnable() { @Override public void run() { if (!control.isDisposed()) { refresh(); } } }); } } else if (preferenceKeysForActivation.contains(property)) { resetHyperlinkDetectors(); } } }; EditorsUI.getPreferenceStore() .addPropertyChangeListener(hyperlinkChangeListener); } else { configuration = null; hyperlinkChangeListener = null; } }
/** * 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; }
/** * 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; }
/** * Creates the source viewer * @param parent * @param flags * @return */ public static SourceViewer createSourceViewer(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.setWordWrap(true); control.setFont(TLCUIActivator.getDefault().getCourierFont()); control.setEditable(true); return sourceViewer; }
@Override protected void initializeEditor() { super.initializeEditor(); createListeners(); initEditorPreferenceStore(); colorManager = FluentMkUI.getDefault().getColorMgr(); tools = FluentMkUI.getDefault().getTextTools(); SourceViewerConfiguration config = tools.createSourceViewerConfiguraton(getPreferenceStore(), this); setSourceViewerConfiguration(config); setDocumentProvider(getDocumentProvider()); pageModel = new PageRoot(this); converter = new FluentMkConverter(); htmlGen = new HtmlGen(this, converter); }
@Override protected boolean affectsTextPresentation(PropertyChangeEvent event) { SourceViewerConfiguration configuration = getSourceViewerConfiguration(); if (configuration instanceof FluentMkSourceViewerConfiguration) { return ((FluentMkSourceViewerConfiguration) configuration).affectsTextPresentation(event); } return false; }
protected void createViewer(int style, Composite composite) { FluentMkUI mkUI = FluentMkUI.getDefault(); FluentMkTextTools textTools = mkUI.getTextTools(); IPreferenceStore store = mkUI.getPreferenceStore(); SourceViewerConfiguration viewerConfig = textTools.createSimpleSourceViewerConfiguration(store); viewer = new FluentMkSourceViewer(composite, null, null, false, style, store); viewer.configure(viewerConfig); }
/** * 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); } }
@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); } }
/** * Creates, configures and returns a source viewer to present the template * pattern on the preference page. Clients may override to provide a custom * source viewer featuring e.g. syntax coloring. * * @param parent the parent control * @return a configured source viewer */ protected SourceViewer createViewer(Composite parent) { SourceViewer viewer= new SourceViewer(parent, null, null, false, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL); SourceViewerConfiguration configuration= new SourceViewerConfiguration(); viewer.configure(configuration); IDocument document= new Document(); viewer.setDocument(document); return viewer; }
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); }
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); } } }
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; }
@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); }
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; }
private void configureToggleCommentAction() { IAction action = getAction(IVelocityActionConstants.TOGGLE_COMMENT); //$NON-NLS-1$ if (action instanceof ToggleCommentAction) { ISourceViewer sourceViewer = getSourceViewer(); SourceViewerConfiguration configuration = getSourceViewerConfiguration(); ((ToggleCommentAction) action).configure(sourceViewer, configuration); } }
public KaizenTemplatePreferences(SourceViewerConfiguration sourceViewerConfiguration, IPreferenceStore preferenceStore, TemplateStore templateStore, ContextTypeRegistry contextTypeRegistry) { this.sourceViewerConfiguration = sourceViewerConfiguration; setPreferenceStore(preferenceStore); setTemplateStore(templateStore); setContextTypeRegistry(contextTypeRegistry); }
@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, preferenceStore); } catch (Exception e) { e.printStackTrace(); } super.configure(configuration); }