/** * @param parent * @param ruler * @param styles */ public DiffViewer(Composite parent, IVerticalRuler ruler, int styles) { super(parent, ruler, styles); setDocument(new Document()); SourceViewerDecorationSupport support = new SourceViewerDecorationSupport(this, null, null, EditorsUI.getSharedTextColors()); support.setCursorLinePainterPreferenceKeys( AbstractDecoratedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE_COLOR); support.install(EditorsUI.getPreferenceStore()); if (ruler instanceof CompositeRuler) { lineNumberRuler = new LineNumberRulerColumn(); ((CompositeRuler) ruler).addDecorator(0, lineNumberRuler); } initListeners(); getControl() .addDisposeListener( new DisposeListener() { public void widgetDisposed(DisposeEvent e) { EditorsUI.getPreferenceStore().removePropertyChangeListener(editorPrefListener); PlatformUI.getWorkbench() .getThemeManager() .removePropertyChangeListener(themeListener); colors.dispose(); } }); refreshDiffColors(); styleViewer(); }
public MergeSourceViewer( SourceViewer sourceViewer, ResourceBundle bundle, ICompareContainer container) { Assert.isNotNull(sourceViewer); fSourceViewer = sourceViewer; fResourceBundle = bundle; fContainer = container; MenuManager menu = new MenuManager(); menu.setRemoveAllWhenShown(true); menu.addMenuListener(this); StyledText te = getSourceViewer().getTextWidget(); te.setMenu(menu.createContextMenu(te)); fContainer.registerContextMenu(menu, getSourceViewer()); // for listening to editor show/hide line number preference value fPreferenceChangeListener = new IPropertyChangeListener() { public void propertyChange(PropertyChangeEvent event) { MergeSourceViewer.this.handlePropertyChangeEvent(event); } }; EditorsUI.getPreferenceStore().addPropertyChangeListener(fPreferenceChangeListener); fShowLineNumber = EditorsUI.getPreferenceStore() .getBoolean(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_LINE_NUMBER_RULER); if (fShowLineNumber) { updateLineNumberRuler(); } IOperationHistory history = getHistory(); if (history != null) history.addOperationHistoryListener(this); // don't add save when in a dialog, IWorkbenchPart is null in dialog containers fAddSaveAction = fContainer.getWorkbenchPart() != null; }
public SpringPropertiesReconciler createReconciler( ISourceViewer sourceViewer, DocumentContextFinder documentContextFinder, IReconcileTrigger reconcileTigger) { IReconcilingStrategy strategy = null; if (!DISABLE_SPELL_CHECKER && EditorsUI.getPreferenceStore().getBoolean(SpellingService.PREFERENCE_SPELLING_ENABLED)) { IReconcilingStrategy spellcheck = new SpellingReconcileStrategy(sourceViewer, EditorsUI.getSpellingService()) { @Override protected IContentType getContentType() { return SpringPropertiesFileEditor.CONTENT_TYPE; } }; strategy = ReconcilingUtil.compose(strategy, spellcheck); } try { IReconcileEngine reconcileEngine = createEngine(); IReconcilingStrategy propertyChecker = new SpringPropertiesReconcileStrategy( sourceViewer, reconcileEngine, documentContextFinder, reconcileTigger); strategy = ReconcilingUtil.compose(strategy, propertyChecker); } catch (Exception e) { SpringPropertiesEditorPlugin.log(e); } if (strategy != null) { SpringPropertiesReconciler reconciler = new SpringPropertiesReconciler(strategy); reconciler.setDelay(500); return reconciler; } return null; }
public void initializeDefaultPreferences() { IPreferenceStore store = StringTemplateUI.getDefault().getPreferenceStore(); EditorsUI.useAnnotationsPreferencePage(store); EditorsUI.useQuickDiffPreferencePage(store); StringTemplatePreferenceConstants.initializeDefaultValues(store); }
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; }
private void styleViewer() { IPreferenceStore store = EditorsUI.getPreferenceStore(); Color foreground = null; if (!store.getBoolean(AbstractTextEditor.PREFERENCE_COLOR_FOREGROUND_SYSTEM_DEFAULT)) foreground = getEditorColor(AbstractTextEditor.PREFERENCE_COLOR_FOREGROUND); Color background = null; if (!store.getBoolean(AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT)) background = getEditorColor(AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND); Color selectionForeground = null; if (!store.getBoolean(AbstractTextEditor.PREFERENCE_COLOR_SELECTION_FOREGROUND_SYSTEM_DEFAULT)) selectionForeground = getEditorColor(AbstractTextEditor.PREFERENCE_COLOR_SELECTION_FOREGROUND); Color selectionBackground = null; if (!store.getBoolean(AbstractTextEditor.PREFERENCE_COLOR_SELECTION_BACKGROUND_SYSTEM_DEFAULT)) selectionBackground = getEditorColor(AbstractTextEditor.PREFERENCE_COLOR_SELECTION_BACKGROUND); StyledText text = getTextWidget(); text.setForeground(foreground); text.setBackground(background); text.setSelectionForeground(selectionForeground); text.setSelectionBackground(selectionBackground); text.setFont(JFaceResources.getFont(JFaceResources.TEXT_FONT)); if (lineNumberRuler != null) { lineNumberRuler.setFont(text.getFont()); lineNumberRuler.setForeground(foreground); lineNumberRuler.setBackground(background); } }
private Control createPreviewer(Composite parent) { IPreferenceStore generalTextStore = EditorsUI.getPreferenceStore(); IPreferenceStore store = new ChainedPreferenceStore(new IPreferenceStore[] {getPreferenceStore(), generalTextStore}); fPreviewViewer = new CSourceViewer( parent, null, null, false, SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER, store); SimpleCSourceViewerConfiguration configuration = new SimpleCSourceViewerConfiguration( fColorManager, store, null, ICPartitions.C_PARTITIONING, false); fPreviewViewer.configure(configuration); Font font = JFaceResources.getFont(PreferenceConstants.EDITOR_TEXT_FONT); fPreviewViewer.getTextWidget().setFont(font); CSourcePreviewerUpdater.registerPreviewer(fPreviewViewer, configuration, store); fPreviewViewer.setEditable(false); String content = loadPreviewContentFromFile("ColorSettingPreviewCode.txt"); // $NON-NLS-1$ IDocument document = new Document(content); CUIPlugin.getDefault() .getTextTools() .setupCDocumentPartitioner(document, ICPartitions.C_PARTITIONING, null); fPreviewViewer.setDocument(document); installSemanticHighlighting(); return fPreviewViewer.getControl(); }
public static String getAdditionalInfoAffordanceString() { if (!EditorsUI.getPreferenceStore() .getBoolean( AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SHOW_TEXT_HOVER_AFFORDANCE)) return null; return Messages.DLTKUIPlugin_additionalInfo_affordance; }
/** * The viewer is no longer part of the UI, it's a wrapper only. The disposal doesn't take place * while releasing the editor pane's children. The method have to be called it manually. The * wrapped viewer is disposed as a regular viewer, while disposing the UI. */ public void dispose() { getSourceViewer().removeTextListener(this); getSourceViewer().removeSelectionChangedListener(this); EditorsUI.getPreferenceStore().removePropertyChangeListener(fPreferenceChangeListener); IOperationHistory history = getHistory(); if (history != null) history.removeOperationHistoryListener(this); }
public TextEditorPropertyAction(String label, SourceViewer viewer, String preferenceKey) { super(label, IAction.AS_CHECK_BOX); this.viewer = viewer; this.preferenceKey = preferenceKey; this.store = EditorsUI.getPreferenceStore(); if (store != null) store.addPropertyChangeListener(this); synchronizeWithPreference(); }
public IPreferenceStore getCombinedPreferenceStore() { if (fCombinedPreferenceStore == null) { IPreferenceStore generalTextStore = EditorsUI.getPreferenceStore(); fCombinedPreferenceStore = new ChainedPreferenceStore( array(getPreferenceStore(), getCorePreferenceStore(), generalTextStore)); } return fCombinedPreferenceStore; }
@Override protected boolean isIncluded(Annotation annotation) { AnnotationPreference preference = EditorsUI.getAnnotationPreferenceLookup().getAnnotationPreference(annotation); if (preference != null && preference.getVerticalRulerPreferenceValue()) { return annotation.getText() != null; } return false; }
public HyperlinkDetectorsConfigurationBlock( PreferencePage preferencePage, OverlayPreferenceStore store) { Assert.isNotNull(store); Assert.isNotNull(preferencePage); fStore = store; fPreferencePage = preferencePage; fHyperlinkDetectorDescriptors = EditorsUI.getHyperlinkDetectorRegistry().getHyperlinkDetectorDescriptors(); fStore.addKeys(createOverlayStoreKeys()); }
/** @return */ public static int getTabWidthFromPreferences() { int tabw = ErlideUIPlugin.getDefault() .getPreferenceStore() .getInt(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_TAB_WIDTH); if (tabw == 0) { tabw = EditorsUI.getPreferenceStore() .getInt(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_TAB_WIDTH); } return tabw; }
public SelectQuickFixRulerAction( ResourceBundle bundle, String prefix, ITextEditor editor, IVerticalRulerInfo ruler) { super(bundle, prefix, editor, ruler); mTextEditor = editor; mAnnotationPreferenceLookup = EditorsUI.getAnnotationPreferenceLookup(); mStore = InstallOptionsPlugin.getDefault().getCombinedPreferenceStore(); PlatformUI.getWorkbench() .getHelpSystem() .setHelp(this, "installoptions_quickfix_context"); // $NON-NLS-1$ }
/** * Create a preference store combined from the Clojure, the EditorsUI and the PlatformUI * preference stores to inherit all the default text editor settings from the Eclipse preferences. * * <p>Beware, the combined preference store can only be instanciated from the UI Thread. * * @return the combined preference store. */ public IPreferenceStore getCombinedPreferenceStore() { if (prefs == null) { prefs = new ChainedPreferenceStore( new IPreferenceStore[] { CCWPlugin.getDefault().getPreferenceStore(), EditorsUI.getPreferenceStore(), PlatformUI.getPreferenceStore() }); } return prefs; }
public JavaSelectAnnotationRulerAction( ResourceBundle bundle, String prefix, ITextEditor editor, IVerticalRulerInfo ruler) { super(bundle, prefix, editor, ruler); fBundle = bundle; fTextEditor = editor; fAnnotationPreferenceLookup = EditorsUI.getAnnotationPreferenceLookup(); fStore = JavaPlugin.getDefault().getCombinedPreferenceStore(); PlatformUI.getWorkbench() .getHelpSystem() .setHelp(this, IJavaHelpContextIds.JAVA_SELECT_MARKER_RULER_ACTION); }
@Override protected void initializeEditor() { super.initializeEditor(); setDocumentProvider(getAutoconfDocumentProvider()); IPreferenceStore[] stores = new IPreferenceStore[2]; stores[0] = AutotoolsPlugin.getDefault().getPreferenceStore(); stores[1] = EditorsUI.getPreferenceStore(); ChainedPreferenceStore chainedStore = new ChainedPreferenceStore(stores); setPreferenceStore(chainedStore); setSourceViewerConfiguration(new AutoconfSourceViewerConfiguration(chainedStore, this)); AutotoolsEditorPreferenceConstants.initializeDefaultValues(stores[0]); AutoconfEditorPreferencePage.initDefaults(stores[0]); }
private void updateLineNumberColumnPresentation(boolean refresh) { if (fLineNumberColumn == null) return; RGB rgb = getColorFromStore( EditorsUI.getPreferenceStore(), AbstractDecoratedTextEditorPreferenceConstants.EDITOR_LINE_NUMBER_RULER_COLOR); if (rgb == null) rgb = new RGB(0, 0, 0); ISharedTextColors sharedColors = getSharedColors(); fLineNumberColumn.setForeground(sharedColors.getColor(rgb)); if (refresh) { fLineNumberColumn.redraw(); } }
@Override protected void initializeEditor() { super.initializeEditor(); setPreferenceStore( new ChainedPreferenceStore( new IPreferenceStore[] { Activator.getCurrent().getPreferenceStore(), EditorsUI.getPreferenceStore() })); JavaColorManager colorManager = Activator.getCurrent().getColorManager(); JavaSourceViewerConfiguration configuration = new JavaSourceViewerConfiguration( colorManager, getPreferenceStore(), this, IJavaPartitions.JAVA_PARTITIONING); setSourceViewerConfiguration(configuration); }
/** * Creates and returns a preference store which combines the preference stores from the text tools * and which is read-only. * * @param javaTextTools the Java text tools * @return the combined read-only preference store * @since 3.0 */ private static final IPreferenceStore createPreferenceStore(JavaTextTools javaTextTools) { Assert.isNotNull(javaTextTools); IPreferenceStore generalTextStore = EditorsUI.getPreferenceStore(); if (javaTextTools.getCorePreferenceStore() == null) return new ChainedPreferenceStore( new IPreferenceStore[] {javaTextTools.getPreferenceStore(), generalTextStore}); return new ChainedPreferenceStore( new IPreferenceStore[] { javaTextTools.getPreferenceStore(), new PreferencesAdapter(javaTextTools.getCorePreferenceStore()), generalTextStore }); }
private void initialize() { final IPreferenceStore store = EditorsUI.getPreferenceStore(); if (store == null) { return; } AnnotationPreferenceLookup lookup = EditorsUI.getAnnotationPreferenceLookup(); final AnnotationPreference commentedPref = lookup.getAnnotationPreference(CommentAnnotation.COMMENT_ANNOTATION_ID); updateCommentedColor(commentedPref, store); fDispatcher = new PropertyEventDispatcher(store); if (commentedPref != null) { fDispatcher.addPropertyChangeListener( commentedPref.getColorPreferenceKey(), new IPropertyChangeListener() { public void propertyChange(PropertyChangeEvent event) { updateCommentedColor(commentedPref, store); } }); } }
/** * handle show/hide line numbers from editor preferences * * @param event */ protected void handlePropertyChangeEvent(PropertyChangeEvent event) { String key = event.getProperty(); if (key.equals(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_LINE_NUMBER_RULER)) { boolean b = EditorsUI.getPreferenceStore() .getBoolean(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_LINE_NUMBER_RULER); if (b != fShowLineNumber) { toggleLineNumberRuler(); } } else if (key.equals( AbstractDecoratedTextEditorPreferenceConstants.EDITOR_LINE_NUMBER_RULER_COLOR)) { updateLineNumberColumnPresentation(true); } }
/** * Creates and returns a preference store which combines the preference stores from the text tools * and which is read-only. * * @param javaTextTools the Dart text tools * @return the combined read-only preference store */ @SuppressWarnings("unused") private static final IPreferenceStore createPreferenceStore(DartTextTools javaTextTools) { Assert.isNotNull(javaTextTools); IPreferenceStore generalTextStore = EditorsUI.getPreferenceStore(); if (javaTextTools.getCorePreferenceStore() == null) { return new ChainedPreferenceStore( new IPreferenceStore[] {javaTextTools.getPreferenceStore(), generalTextStore}); } return new ChainedPreferenceStore( new IPreferenceStore[] { javaTextTools.getPreferenceStore(), new PreferencesAdapter(javaTextTools.getCorePreferenceStore()), generalTextStore }); }
private void foldingSection() { final Composite group = createGroup(2, "Source folding"); Composite p0 = getFieldEditorParent(group); GridData gd = new GridData(); gd.horizontalSpan = 2; p0.setLayoutData(gd); enableFolding = new SpecialBoolFieldEditor(EDITOR_FOLDING_ENABLED, "Enable source folding", p0); enableFolding.load(); addField(enableFolding); final Composite composite = new Composite(group, SWT.NONE); GridLayout layout = new GridLayout(1, true); composite.setLayout(layout); GridData gd2 = new GridData(GridData.HORIZONTAL_ALIGN_FILL); gd2.grabExcessHorizontalSpace = true; composite.setLayoutData(gd2); final Composite p1 = getFieldEditorParent(composite); autoFoldImports = new BooleanFieldEditor(AUTO_FOLD_IMPORTS, "Automatically fold import lists", p1); autoFoldImports.load(); addField(autoFoldImports); final Composite p2 = getFieldEditorParent(composite); autoFoldComments = new BooleanFieldEditor(AUTO_FOLD_COMMENTS, "Automatically fold comments", p2); autoFoldComments.load(); addField(autoFoldComments); boolean enabled = EditorsUI.getPreferenceStore().getBoolean(EDITOR_FOLDING_ENABLED); autoFoldImports.setEnabled(enabled, p1); autoFoldComments.setEnabled(enabled, p2); // composite.setVisible(enabled); // composite.setEnabled(enabled); // ((GridData) composite.getLayoutData()).exclude = !enabled; enableFolding.setListener( new Listener() { @Override public void valueChanged(boolean oldValue, boolean newValue) { autoFoldImports.setEnabled(newValue, p1); autoFoldComments.setEnabled(newValue, p2); // composite.setVisible(newValue); // composite.setEnabled(newValue); // ((GridData) composite.getLayoutData()).exclude = !newValue; // group.layout(); } }); }
public static SourceViewer createErlangPreviewer( final Composite parent, IColorManager colorManager, Map<TokenHighlight, HighlightStyle> colors, final String content) { // TODO we should move this method, to a utility class (or maybe create // an ErlangPreviewSourceViewer class) if (colorManager == null) { colorManager = new ColorManager(); } if (colors == null) { colors = new HashMap<TokenHighlight, HighlightStyle>(); for (final TokenHighlight th : TokenHighlight.values()) { colors.put(th, th.getDefaultData()); } } final IPreferenceStore generalTextStore = EditorsUI.getPreferenceStore(); final IPreferenceStore store = new ChainedPreferenceStore( new IPreferenceStore[] { ErlideUIPlugin.getDefault().getPreferenceStore(), generalTextStore }); final SourceViewer viewer = new SourceViewer(parent, null, null, false, SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER); final IDocument document = new Document(content); viewer.setDocument(document); final ErlangDocumentSetupParticipant setupParticipant = new ErlangDocumentSetupParticipant(); setupParticipant.setup(document); final TextSourceViewerConfiguration configuration = new SyntaxColorPreviewEditorConfiguration(store, colorManager, colors); viewer.configure(configuration); final Font font = JFaceResources.getFont(PreferenceConstants.EDITOR_TEXT_FONT); viewer.getTextWidget().setFont(font); new ErlangSourceViewerUpdater(viewer, configuration, store); viewer.setEditable(false); final Cursor arrowCursor = viewer.getTextWidget().getDisplay().getSystemCursor(SWT.CURSOR_ARROW); viewer.getTextWidget().setCursor(arrowCursor); return viewer; }
private void initListeners() { PlatformUI.getWorkbench().getThemeManager().addPropertyChangeListener(this.themeListener); EditorsUI.getPreferenceStore().addPropertyChangeListener(this.editorPrefListener); getTextWidget() .addLineBackgroundListener( new LineBackgroundListener() { public void lineGetBackground(LineBackgroundEvent event) { StyledText text = getTextWidget(); if (event.lineOffset < text.getCharCount()) { StyleRange style = text.getStyleRangeAtOffset(event.lineOffset); if (style instanceof DiffStyleRange) event.lineBackground = ((DiffStyleRange) style).lineBackground; } } }); }
@Override public IReconciler getReconciler(ISourceViewer sourceViewer) { if (fPreferenceStore == null || !fPreferenceStore.getBoolean(SpellingService.PREFERENCE_SPELLING_ENABLED)) return null; SpellingService spellingService = EditorsUI.getSpellingService(); if (spellingService.getActiveSpellingEngineDescriptor(fPreferenceStore) == null) return null; // Overridden (just) to return a PyReconciler! IReconcilingStrategy strategy = new PyReconciler(sourceViewer, spellingService); MonoReconciler reconciler = new MonoReconciler(strategy, false); reconciler.setIsIncrementalReconciler(false); reconciler.setProgressMonitor(new NullProgressMonitor()); reconciler.setDelay(500); return reconciler; }
@Override protected void initializeEditor() { setRangeIndicator(new DefaultRangeIndicator()); setEditorContextMenuId("#MakefileEditorContext"); // $NON-NLS-1$ setRulerContextMenuId("#MakefileRulerContext"); // $NON-NLS-1$ setDocumentProvider(AutomakeEditorFactory.getDefault().getAutomakefileDocumentProvider()); IPreferenceStore[] stores = new IPreferenceStore[2]; stores[0] = AutotoolsPlugin.getDefault().getPreferenceStore(); stores[1] = EditorsUI.getPreferenceStore(); ChainedPreferenceStore chainedStore = new ChainedPreferenceStore(stores); setPreferenceStore(chainedStore); sourceViewerConfiguration = new AutomakefileSourceConfiguration(chainedStore, this); setSourceViewerConfiguration(sourceViewerConfiguration); AutotoolsEditorPreferenceConstants.initializeDefaultValues(stores[0]); AutomakeEditorPreferencePage.initDefaults(stores[0]); configureInsertMode(SMART_INSERT, false); setInsertMode(INSERT); }
@Override public boolean performOk() { bracketMatching.store(); IPreferenceStore store = EditorsUI.getPreferenceStore(); store.setValue(SELECTED_BRACKET, matchingBrackets.getSelection()); store.setValue(ENCLOSING_BRACKETS, enclosingBrackets.getSelection()); smartCaret.store(); pasteCorrectIndent.store(); pasteEscapeQuoted.store(); pasteImports.store(); autoFoldImports.store(); autoFoldComments.store(); closeAngles.store(); closeBackticks.store(); closeBraces.store(); closeBrackets.store(); closeParens.store(); closeQuotes.store(); enableFolding.store(); return true; }