Search in sources :

Example 1 with ChainedPreferenceStore

use of org.eclipse.ui.texteditor.ChainedPreferenceStore in project eclipse.platform.text by eclipse.

the class ChainedPreferenceStoreTest method testChainedStore1.

/**
 * Assertion failed in ChainedPreferenceStore.handlePropertyChangeEvent(..)
 * https://bugs.eclipse.org/bugs/show_bug.cgi?id=52827
 */
@Test
public void testChainedStore1() {
    IPreferenceStore store1 = new PreferenceStore();
    IPreferenceStore store2 = new PreferenceStore();
    IPreferenceStore chainedStore = new ChainedPreferenceStore(new IPreferenceStore[] { store1, store2 });
    chainedStore.addPropertyChangeListener(fPropertyChangeListener);
    // simulated removal with newValue != null
    store1.firePropertyChangeEvent(PROPERTY, VALUE, DEFAULT_DEFAULT_VALUE);
    chainedStore.removePropertyChangeListener(fPropertyChangeListener);
    assertEquals(1, fEvents.size());
    PropertyChangeEvent event = fEvents.get(0);
    assertEquals(store1, event.getSource());
    assertEquals(PROPERTY, event.getProperty());
    assertEquals(VALUE, event.getOldValue());
    assertEquals(DEFAULT_DEFAULT_VALUE, event.getNewValue());
}
Also used : PropertyChangeEvent(org.eclipse.jface.util.PropertyChangeEvent) ChainedPreferenceStore(org.eclipse.ui.texteditor.ChainedPreferenceStore) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore) ChainedPreferenceStore(org.eclipse.ui.texteditor.ChainedPreferenceStore) PreferenceStore(org.eclipse.jface.preference.PreferenceStore) Test(org.junit.Test)

Example 2 with ChainedPreferenceStore

use of org.eclipse.ui.texteditor.ChainedPreferenceStore in project eclipse.platform.text by eclipse.

the class ChainedPreferenceStoreTest method testChainedStore0.

/**
 * [implementation] ChainedPreferenceStore
 * https://bugs.eclipse.org/bugs/show_bug.cgi?id=69419
 */
@Test
public void testChainedStore0() {
    IPreferenceStore store1 = new PreferenceStore();
    IPreferenceStore store2 = new PreferenceStore();
    IPreferenceStore chainedStore = new ChainedPreferenceStore(new IPreferenceStore[] { store1, store2 });
    store2.setDefault(PROPERTY, DEFAULT_VALUE);
    chainedStore.addPropertyChangeListener(fPropertyChangeListener);
    // simulated removal with newValue != null
    store1.firePropertyChangeEvent(PROPERTY, VALUE, DEFAULT_DEFAULT_VALUE);
    chainedStore.removePropertyChangeListener(fPropertyChangeListener);
    assertEquals(1, fEvents.size());
    PropertyChangeEvent event = fEvents.get(0);
    assertEquals(chainedStore, event.getSource());
    assertEquals(PROPERTY, event.getProperty());
    assertEquals(VALUE, event.getOldValue());
    assertEquals(DEFAULT_VALUE, event.getNewValue());
}
Also used : PropertyChangeEvent(org.eclipse.jface.util.PropertyChangeEvent) ChainedPreferenceStore(org.eclipse.ui.texteditor.ChainedPreferenceStore) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore) ChainedPreferenceStore(org.eclipse.ui.texteditor.ChainedPreferenceStore) PreferenceStore(org.eclipse.jface.preference.PreferenceStore) Test(org.junit.Test)

Example 3 with ChainedPreferenceStore

use of org.eclipse.ui.texteditor.ChainedPreferenceStore in project erlide_eclipse by erlang.

the class ErlangSourceViewer method createErlangPreviewer.

public static SourceViewer createErlangPreviewer(final Composite parent, final IColorManager colorManager0, final IPreferenceStore topStore, final Map<TokenHighlight, HighlightStyle> colors0, final String content) {
    // TODO we should move this method, to a utility class (or maybe create
    // an ErlangPreviewSourceViewer class)
    final IColorManager colorManager = colorManager0 != null ? colorManager0 : new ColorManager();
    Map<TokenHighlight, HighlightStyle> colors;
    if (colors0 == null) {
        colors = Maps.newHashMap();
        for (final TokenHighlight th : TokenHighlight.values()) {
            colors.put(th, null);
        }
    } else {
        colors = colors0;
    }
    final IPreferenceStore generalTextStore = EditorsUI.getPreferenceStore();
    final IPreferenceStore store = topStore == null ? new ChainedPreferenceStore(new IPreferenceStore[] { generalTextStore }) : new ChainedPreferenceStore(new IPreferenceStore[] { topStore, 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 ErlangSourceViewerConfiguration configuration = new SyntaxColorPreviewEditorConfiguration(store, colorManager);
    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;
}
Also used : SourceViewer(org.eclipse.jface.text.source.SourceViewer) IColorManager(org.erlide.ui.util.IColorManager) ChainedPreferenceStore(org.eclipse.ui.texteditor.ChainedPreferenceStore) Document(org.eclipse.jface.text.Document) IDocument(org.eclipse.jface.text.IDocument) Cursor(org.eclipse.swt.graphics.Cursor) TokenHighlight(org.erlide.ui.prefs.TokenHighlight) Font(org.eclipse.swt.graphics.Font) HighlightStyle(org.erlide.ui.prefs.HighlightStyle) ErlangSourceViewerUpdater(org.erlide.ui.prefs.plugin.internal.ErlangSourceViewerUpdater) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore) IColorManager(org.erlide.ui.util.IColorManager) ColorManager(org.erlide.ui.util.ColorManager) IDocument(org.eclipse.jface.text.IDocument)

Example 4 with ChainedPreferenceStore

use of org.eclipse.ui.texteditor.ChainedPreferenceStore in project egit by eclipse.

the class DiffEditorPage method initializeEditor.

@Override
protected void initializeEditor() {
    super.initializeEditor();
    overviewStore = new ThemePreferenceStore();
    setPreferenceStore(new ChainedPreferenceStore(new IPreferenceStore[] { overviewStore, EditorsUI.getPreferenceStore() }));
    setDocumentProvider(new DiffDocumentProvider());
    setSourceViewerConfiguration(new DiffViewer.Configuration(getPreferenceStore()) {

        @Override
        public IReconciler getReconciler(ISourceViewer sourceViewer) {
            // Switch off spell-checking
            return null;
        }
    });
}
Also used : IReconciler(org.eclipse.jface.text.reconciler.IReconciler) ChainedPreferenceStore(org.eclipse.ui.texteditor.ChainedPreferenceStore) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore) ISourceViewer(org.eclipse.jface.text.source.ISourceViewer)

Example 5 with ChainedPreferenceStore

use of org.eclipse.ui.texteditor.ChainedPreferenceStore in project webtools.sourceediting by eclipse.

the class StructuredTextEditor method createCombinedPreferenceStore.

/**
 * Create a preference store that combines the source editor preferences
 * with the base editor's preferences.
 *
 * @return IPreferenceStore
 */
private IPreferenceStore createCombinedPreferenceStore() {
    IPreferenceStore sseEditorPrefs = SSEUIPlugin.getDefault().getPreferenceStore();
    IPreferenceStore baseEditorPrefs = EditorsUI.getPreferenceStore();
    return new ChainedPreferenceStore(new IPreferenceStore[] { sseEditorPrefs, baseEditorPrefs });
}
Also used : ChainedPreferenceStore(org.eclipse.ui.texteditor.ChainedPreferenceStore) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore)

Aggregations

ChainedPreferenceStore (org.eclipse.ui.texteditor.ChainedPreferenceStore)18 IPreferenceStore (org.eclipse.jface.preference.IPreferenceStore)17 Test (org.junit.Test)5 PreferenceStore (org.eclipse.jface.preference.PreferenceStore)4 SourceViewerConfiguration (org.eclipse.jface.text.source.SourceViewerConfiguration)4 PropertyChangeEvent (org.eclipse.jface.util.PropertyChangeEvent)4 ColorManager (org.eclipse.titan.designer.editors.ColorManager)4 ForwardingDocumentProvider (org.eclipse.ui.editors.text.ForwardingDocumentProvider)4 TextFileDocumentProvider (org.eclipse.ui.editors.text.TextFileDocumentProvider)4 ConfigurationScope (org.eclipse.core.runtime.preferences.ConfigurationScope)3 InstanceScope (org.eclipse.core.runtime.preferences.InstanceScope)3 FixedScopedPreferenceStore (org.eclipse.xtext.ui.editor.preferences.FixedScopedPreferenceStore)2 Activator (org.eclipse.xtext.ui.internal.Activator)2 IProject (org.eclipse.core.resources.IProject)1 ProjectScope (org.eclipse.core.resources.ProjectScope)1 Document (org.eclipse.jface.text.Document)1 IDocument (org.eclipse.jface.text.IDocument)1 IReconciler (org.eclipse.jface.text.reconciler.IReconciler)1 ISourceViewer (org.eclipse.jface.text.source.ISourceViewer)1 SourceViewer (org.eclipse.jface.text.source.SourceViewer)1