@Override protected void configureSourceViewerDecorationSupport( SourceViewerDecorationSupport support) { super.configureSourceViewerDecorationSupport(support); char[] matchChars = { '<', '>' }; // which brackets to match ICharacterPairMatcher matcher = new DefaultCharacterPairMatcher( matchChars, IDocumentExtension3.DEFAULT_PARTITIONING); support.setCharacterPairMatcher(matcher); support.setMatchingCharacterPainterPreferenceKeys( EDITOR_MATCHING_BRACKETS, EDITOR_MATCHING_BRACKETS_COLOR); // Enable bracket highlighting in the preference store IPreferenceStore store = getPreferenceStore(); store.setDefault(EDITOR_MATCHING_BRACKETS, true); store.setDefault(EDITOR_MATCHING_BRACKETS_COLOR, "128,128,128"); }
@Override protected void configureSourceViewerDecorationSupport(SourceViewerDecorationSupport support) { super.configureSourceViewerDecorationSupport(support); DefaultCharacterPairMatcher matcher = new DefaultCharacterPairMatcher( new char[]{'[', ']'}, EditorConstants.BF_PARTITIONING, true); support.setCharacterPairMatcher(matcher); support.setMatchingCharacterPainterPreferenceKeys( EditorConstants.PREF_EDITOR_MATCHING_BRACKETS, EditorConstants.PREF_EDITOR_MATCHING_BRACKETS_COLOR, EditorConstants.PREF_EDITOR_MATCHING_BRACKETS_SHOW_CARET, EditorConstants.PREF_EDITOR_MATCHING_BRACKETS_SHOW_ENCLOSING); }
/** * Creates decoration support for the sourceViewer. code is entirely copied * from {@link XtextEditor} and its super class * {@link AbstractDecoratedTextEditor}. * */ protected void configureSourceViewerDecorationSupport(SourceViewerDecorationSupport support) { MarkerAnnotationPreferences annotationPreferences = new MarkerAnnotationPreferences(); @SuppressWarnings("unchecked") List<AnnotationPreference> prefs = annotationPreferences.getAnnotationPreferences(); for (AnnotationPreference annotationPreference : prefs) { support.setAnnotationPreference(annotationPreference); } support.setCharacterPairMatcher(characterPairMatcher); support.setMatchingCharacterPainterPreferenceKeys(BracketMatchingPreferencesInitializer.IS_ACTIVE_KEY, BracketMatchingPreferencesInitializer.COLOR_KEY); support.install(preferenceStoreAccess.getPreferenceStore()); }
@Override public void createPartControl(Composite parent) { JsonPreferenceStore jsonPreferenceStore = JsonPreferenceStore.getJsonPreferenceStore(); viewerConfiguration = new JsonSourceViewerConfiguration(this, jsonPreferenceStore); setSourceViewerConfiguration(viewerConfiguration); super.createPartControl(parent); ProjectionViewer viewer =(ProjectionViewer) getSourceViewer(); projectionSupport = new ProjectionSupport(viewer,getAnnotationAccess(),getSharedColors()); projectionSupport.install(); //turn projection mode on viewer.doOperation(ProjectionViewer.TOGGLE); annotationModel = viewer.getProjectionAnnotationModel(); SourceViewerDecorationSupport support = getSourceViewerDecorationSupport(viewer); support.install(getPreferenceStore()); IFile file = (IFile) getEditorInput().getAdapter(IFile.class); platformPreferenceListener = new PlatformPreferenceListener(viewerConfiguration, jsonPreferenceStore); platformPreferenceListener.setPreferenceChangeListener(file); }
/** * Installs an additional source viewer support which uses editor * preferences instead of standard text preferences. If standard source * viewer support would be set with editor preferences all standard * preferences would be lost or had to be reimplmented. To avoid this * another source viewer support is installed... */ private void installAdditionalSourceViewerSupport() { additionalSourceViewerSupport = new SourceViewerDecorationSupport(getSourceViewer(), getOverviewRuler(), getAnnotationAccess(), getSharedColors()); additionalSourceViewerSupport.setCharacterPairMatcher(bracketMatcher); additionalSourceViewerSupport.setMatchingCharacterPainterPreferenceKeys( P_EDITOR_MATCHING_BRACKETS_ENABLED.getId(), P_EDITOR_MATCHING_BRACKETS_COLOR.getId(), P_EDITOR_HIGHLIGHT_BRACKET_AT_CARET_LOCATION.getId(), P_EDITOR_ENCLOSING_BRACKETS.getId()); IPreferenceStore preferenceStoreForDecorationSupport = BatchEditorUtil.getPreferences().getPreferenceStore(); additionalSourceViewerSupport.install(preferenceStoreForDecorationSupport); }
/** * Installs an additional source viewer support which uses editor * preferences instead of standard text preferences. If standard source * viewer support would be set with editor preferences all standard * preferences would be lost or had to be reimplmented. To avoid this * another source viewer support is installed... */ private void installAdditionalSourceViewerSupport() { additionalSourceViewerSupport = new SourceViewerDecorationSupport(getSourceViewer(), getOverviewRuler(), getAnnotationAccess(), getSharedColors()); additionalSourceViewerSupport.setCharacterPairMatcher(bracketMatcher); additionalSourceViewerSupport.setMatchingCharacterPainterPreferenceKeys( P_EDITOR_MATCHING_BRACKETS_ENABLED.getId(), P_EDITOR_MATCHING_BRACKETS_COLOR.getId(), P_EDITOR_HIGHLIGHT_BRACKET_AT_CARET_LOCATION.getId(), P_EDITOR_ENCLOSING_BRACKETS.getId()); IPreferenceStore preferenceStoreForDecorationSupport = BashEditorUtil.getPreferences().getPreferenceStore(); additionalSourceViewerSupport.install(preferenceStoreForDecorationSupport); }
private void configureSourceViewerDecorationSupport(SourceViewerDecorationSupport support) { Iterator e = fAnnotationPreferences.getAnnotationPreferences().iterator(); while (e.hasNext()) { support.setAnnotationPreference((AnnotationPreference) e.next()); } support.setCursorLinePainterPreferenceKeys(CURRENT_LINE, CURRENT_LINE_COLOR); support.setMarginPainterPreferenceKeys(PRINT_MARGIN, PRINT_MARGIN_COLOR, PRINT_MARGIN_COLUMN); support.setSymbolicFontName(JFaceResources.TEXT_FONT); }
/** * Installs an additional source viewer support which uses editor * preferences instead of standard text preferences. If standard source * viewer support would be set with editor preferences all standard * preferences would be lost or had to be reimplmented. To avoid this * another source viewer support is installed... */ private void installAdditionalSourceViewerSupport() { additionalSourceViewerSupport = new SourceViewerDecorationSupport(getSourceViewer(), getOverviewRuler(), getAnnotationAccess(), getSharedColors()); additionalSourceViewerSupport.setCharacterPairMatcher(bracketMatcher); additionalSourceViewerSupport.setMatchingCharacterPainterPreferenceKeys( getPreferences().getP_EDITOR_MATCHING_BRACKETS_ENABLED().getId(), getPreferences().getP_EDITOR_MATCHING_BRACKETS_COLOR().getId(), getPreferences().getP_EDITOR_HIGHLIGHT_BRACKET_AT_CARET_LOCATION().getId(), getPreferences().getP_EDITOR_ENCLOSING_BRACKETS().getId()); IPreferenceStore preferenceStoreForDecorationSupport = getPreferences().getPreferenceStore(); additionalSourceViewerSupport.install(preferenceStoreForDecorationSupport); }
@Override protected void configureSourceViewerDecorationSupport(SourceViewerDecorationSupport support) { super.configureSourceViewerDecorationSupport(support); char[] matchChars = { '(', ')', '[', ']', '{', '}' }; // which brackets // to match matcher = new DefaultCharacterPairMatcher(matchChars, IDocumentExtension3.DEFAULT_PARTITIONING); support.setCharacterPairMatcher(matcher); support.setMatchingCharacterPainterPreferenceKeys(EDITOR_MATCHING_BRACKETS, EDITOR_MATCHING_BRACKETS_COLOR); // Enable bracket highlighting in the preference store IPreferenceStore store = getPreferenceStore(); store.setDefault(EDITOR_MATCHING_BRACKETS, true); store.setDefault(EDITOR_MATCHING_BRACKETS_COLOR, "128,128,128"); }
protected void configureSourceViewerDecorationSupport(SourceViewerDecorationSupport support) { // copy the necessary values from plugin preferences instead of overwriting editor preferences getPreferenceStore().setValue(TexlipseProperties.MATCHING_BRACKETS, TexlipsePlugin.getPreference(TexlipseProperties.MATCHING_BRACKETS)); getPreferenceStore().setValue(TexlipseProperties.MATCHING_BRACKETS_COLOR, TexlipsePlugin.getPreference(TexlipseProperties.MATCHING_BRACKETS_COLOR)); support.setCharacterPairMatcher(fBracketMatcher); support.setMatchingCharacterPainterPreferenceKeys(TexlipseProperties.MATCHING_BRACKETS, TexlipseProperties.MATCHING_BRACKETS_COLOR); super.configureSourceViewerDecorationSupport(support); }
/** * @see org.eclipse.ui.texteditor.AbstractDecoratedTextEditor#configureSourceViewerDecorationSupport(org.eclipse.ui.texteditor.SourceViewerDecorationSupport) */ protected void configureSourceViewerDecorationSupport(SourceViewerDecorationSupport support) { // copy the necessary values from plugin preferences instead of overwriting editor preferences getPreferenceStore().setValue(TexlipseProperties.MATCHING_BRACKETS, TexlipsePlugin.getPreference(TexlipseProperties.MATCHING_BRACKETS)); getPreferenceStore().setValue(TexlipseProperties.MATCHING_BRACKETS_COLOR, TexlipsePlugin.getPreference(TexlipseProperties.MATCHING_BRACKETS_COLOR)); support.setCharacterPairMatcher(fBracketMatcher); support.setMatchingCharacterPainterPreferenceKeys(TexlipseProperties.MATCHING_BRACKETS, TexlipseProperties.MATCHING_BRACKETS_COLOR); super.configureSourceViewerDecorationSupport(support); }
private SourceViewerDecorationSupport configureAnnotationPreferences() { ISharedTextColors textColors = EditorsUI.getSharedTextColors(); IAnnotationAccess annotationAccess = new DefaultMarkerAnnotationAccess(); final SourceViewerDecorationSupport support = new SourceViewerDecorationSupport( sourceViewer, null, annotationAccess, textColors); List annotationPreferences = new MarkerAnnotationPreferences() .getAnnotationPreferences(); Iterator e = annotationPreferences.iterator(); while (e.hasNext()) support.setAnnotationPreference((AnnotationPreference) e.next()); support.install(EditorsUI.getPreferenceStore()); return support; }
@Override protected void configureSourceViewerDecorationSupport(SourceViewerDecorationSupport support) { fBracketMatcher.setSourceVersion(getPreferenceStore().getString(JavaScriptCore.COMPILER_SOURCE)); support.setCharacterPairMatcher(fBracketMatcher); support.setMatchingCharacterPainterPreferenceKeys(MATCHING_BRACKETS, MATCHING_BRACKETS_COLOR); super.configureSourceViewerDecorationSupport(support); }
@Override protected void configureSourceViewerDecorationSupport(SourceViewerDecorationSupport support) { super.configureSourceViewerDecorationSupport(support); if (characterPairMatcher != null) { support.setCharacterPairMatcher(characterPairMatcher); support.setMatchingCharacterPainterPreferenceKeys(BracketMatchingPreferencesInitializer.IS_ACTIVE_KEY, BracketMatchingPreferencesInitializer.COLOR_KEY); } }
/** * Creates decoration support for the sourceViewer. code is entirely copied from * {@link XtextEditor} and its super class {@link AbstractDecoratedTextEditor}. * */ protected void configureSourceViewerDecorationSupport(SourceViewerDecorationSupport support) { MarkerAnnotationPreferences annotationPreferences = new MarkerAnnotationPreferences(); List<AnnotationPreference> prefs = annotationPreferences.getAnnotationPreferences(); for (AnnotationPreference annotationPreference : prefs) { support.setAnnotationPreference(annotationPreference); } support.setCharacterPairMatcher(getCharacterPairMatcher()); support.setMatchingCharacterPainterPreferenceKeys(BracketMatchingPreferencesInitializer.IS_ACTIVE_KEY, BracketMatchingPreferencesInitializer.COLOR_KEY); support.install(getPreferenceStoreAccess().getPreferenceStore()); }
protected void createXtextSourceViewer() { sourceviewer = new XtextSourceViewerEx(styledText, preferenceStoreAccess.getPreferenceStore()); sourceviewer.configure(configuration); sourceviewer.setDocument(document, new AnnotationModel()); SourceViewerDecorationSupport support = new SourceViewerDecorationSupport(sourceviewer, null, new DefaultMarkerAnnotationAccess(), getSharedColors()); configureSourceViewerDecorationSupport(support); }
@Override protected void configureSourceViewerDecorationSupport(SourceViewerDecorationSupport support) { super.configureSourceViewerDecorationSupport(support); support.setCharacterPairMatcher(new CharacterPairMatcher(getPairMatchingCharacters())); support.setMatchingCharacterPainterPreferenceKeys(IPreferenceConstants.ENABLE_CHARACTER_PAIR_COLORING, IPreferenceConstants.CHARACTER_PAIR_COLOR); }
@Override protected void configureSourceViewerDecorationSupport(SourceViewerDecorationSupport support) { fBracketMatcher.setSourceVersion(getPreferenceStore().getString(JavaCore.COMPILER_SOURCE)); support.setCharacterPairMatcher(fBracketMatcher); support.setMatchingCharacterPainterPreferenceKeys(MATCHING_BRACKETS, MATCHING_BRACKETS_COLOR, HIGHLIGHT_BRACKET_AT_CARET_LOCATION, ENCLOSING_BRACKETS); super.configureSourceViewerDecorationSupport(support); }
@Override protected void configureSourceViewerDecorationSupport(SourceViewerDecorationSupport support) { // JavaPairMatcher only matches "<>" for certain compiler versions fBracketMatcher.setSourceVersion(getPreferenceStore().getString(PreferenceConstants.COMPILER_SOURCE)); support.setCharacterPairMatcher(fBracketMatcher); support.setMatchingCharacterPainterPreferenceKeys(PreferenceConstants.EDITOR_MATCHING_BRACKETS, PreferenceConstants.EDITOR_MATCHING_BRACKETS_COLOR); super.configureSourceViewerDecorationSupport(support); }
@Override protected ISourceViewer createSourceViewer(Composite parent, IVerticalRuler ruler, int styles) { // if (true) return super.createSourceViewer(parent, ruler, styles); // Create with code-folding ISourceViewer viewer = new ProjectionViewer(parent, ruler, getOverviewRuler(), isOverviewRulerVisible(), styles); // ensure decoration support has been created and configured. SourceViewerDecorationSupport decSupport = getSourceViewerDecorationSupport(viewer); // SourceViewer viewer = (SourceViewer) super.createSourceViewer(parent, ruler, styles); // Setup word-wrapping final StyledText widget = viewer.getTextWidget(); // Listen to pref changes prefChangeListener = new IPropertyChangeListener() { public void propertyChange(PropertyChangeEvent event) { if (event.getProperty().equals(MarkdownPreferencePage.PREF_WORD_WRAP)) { widget.setWordWrap(MarkdownPreferencePage.wordWrap()); } } }; pStore.addPropertyChangeListener(prefChangeListener); // Switch on word-wrapping if (MarkdownPreferencePage.wordWrap()) { widget.setWordWrap(true); } return viewer; }
@Override protected void configureSourceViewerDecorationSupport (@Nullable SourceViewerDecorationSupport support) { super.configureSourceViewerDecorationSupport(support); IPreferenceStore store = getPreferenceStore(); char[] matchChars = {'(', ')', '[', ']', '{', '}'}; //which brackets to match ICharacterPairMatcher matcher = new DefaultCharacterPairMatcher(matchChars , IDocumentExtension3.DEFAULT_PARTITIONING); support.setCharacterPairMatcher(matcher); support.setMatchingCharacterPainterPreferenceKeys(RustConstants.EDITOR_MATCHING_BRACKETS,RustConstants. EDITOR_MATCHING_BRACKETS_COLOR); //Enable bracket highlighting in the preference store store.setDefault(RustConstants.EDITOR_MATCHING_BRACKETS, true); store.setDefault(RustConstants.EDITOR_MATCHING_BRACKETS_COLOR, RustConstants.DEFAULT_MATCHING_BRACKETS_COLOR); }
@Override protected void configureSourceViewerDecorationSupport(SourceViewerDecorationSupport support) { support.setCharacterPairMatcher(pairsMatcher); support.setMatchingCharacterPainterPreferenceKeys(JsonPreferenceStore.EDITOR_MATCHING_BRACKETS, JsonPreferenceStore.EDITOR_MATCHING_BRACKETS_COLOR); super.configureSourceViewerDecorationSupport(support); }
@Override protected void configureSourceViewerDecorationSupport(SourceViewerDecorationSupport support) { super.configureSourceViewerDecorationSupport(support); support.setCharacterPairMatcher(fBracketMatcher); support.setMatchingCharacterPainterPreferenceKeys(PydevEditorPrefs.USE_MATCHING_BRACKETS, PydevEditorPrefs.MATCHING_BRACKETS_COLOR); }
protected void configureBracketMatcher(SourceViewerDecorationSupport support) { support.setCharacterPairMatcher(fBracketMatcher); support.setMatchingCharacterPainterPreferenceKeys( EditorPrefConstants.MATCHING_BRACKETS_.key, EditorPrefConstants.MATCHING_BRACKETS_COLOR2.getActiveKey(), EditorPrefConstants.HIGHLIGHT_BRACKET_AT_CARET_LOCATION, EditorPrefConstants.ENCLOSING_BRACKETS); }
@Override protected void configureSourceViewerDecorationSupport(SourceViewerDecorationSupport support) { // @formatter:off super.configureSourceViewerDecorationSupport(support); // @formatter:on }
public void createPartControl(Composite parent) { int VERTICAL_RULER_WIDTH = 12; int styles = SWT.V_SCROLL | SWT.H_SCROLL | SWT.MULTI | SWT.BORDER | SWT.FULL_SELECTION; ISharedTextColors sharedColors = EditorsPlugin.getDefault().getSharedTextColors(); IOverviewRuler overviewRuler = new OverviewRuler(null, VERTICAL_RULER_WIDTH, sharedColors); CompositeRuler ruler = new CompositeRuler(VERTICAL_RULER_WIDTH); _document = new Document(); _document.set(_docString); _annotationModel = new AnnotationModel(); _annotationModel.connect(_document); _sourceViewer = new SourceViewer(parent, ruler, overviewRuler, true, styles); _sourceViewer.configure(new SourceViewerConfiguration()); _sds = new SourceViewerDecorationSupport(_sourceViewer, overviewRuler, null, sharedColors); AnnotationPreference ap = new AnnotationPreference(); ap.setColorPreferenceKey(ANNO_KEY_COLOR); ap.setHighlightPreferenceKey(ANNO_KEY_HIGHLIGHT); ap.setVerticalRulerPreferenceKey(ANNO_KEY_VERTICAL); ap.setOverviewRulerPreferenceKey(ANNO_KEY_OVERVIEW); ap.setTextPreferenceKey(ANNO_KEY_TEXT); ap.setAnnotationType(ANNO_TYPE); _sds.setAnnotationPreference(ap); // _sds.install(EditorsPlugin.getDefault().getPreferenceStore()); _sourceViewer.setDocument(_document, _annotationModel); _sourceViewer.getControl().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); ruler.addDecorator(0, new LineNumberRulerColumn()); Annotation annotation = new Annotation(false); annotation.setType(ANNO_TYPE); Position position = new Position(0, 4); _annotationModel.addAnnotation(annotation, position); parent.layout(); }
protected void unconfigureSourceViewerDecorationSupport(SourceViewerDecorationSupport support) { support.uninstall(); }
protected SourceViewerDecorationSupport createSourceViewerDecorationSupport() { return new SourceViewerDecorationSupport(getXtextSourceviewer(), null, new DefaultMarkerAnnotationAccess(), getSharedColors()); }
protected SourceViewerDecorationSupport getDecorationSupport() { return this.decorationSupport; }
@Override protected void configureSourceViewerDecorationSupport(SourceViewerDecorationSupport support) { configureBracketMatcher(support); super.configureSourceViewerDecorationSupport(support); }