01: /*******************************************************************************
02: * Copyright (c) 2000, 2005 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.ui.texteditor;
11:
12: import org.eclipse.swt.widgets.Composite;
13:
14: import org.eclipse.core.runtime.Platform;
15: import org.eclipse.core.runtime.Plugin;
16:
17: import org.eclipse.jface.preference.IPreferenceStore;
18: import org.eclipse.jface.resource.JFaceResources;
19: import org.eclipse.jface.text.PropagatingFontFieldEditor;
20:
21: import org.eclipse.ui.plugin.AbstractUIPlugin;
22:
23: /**
24: * This font field editor implements chaining between the workbench's preference
25: * store and a given target preference store. Any time the workbench's preference
26: * for the text font changes, the change is propagated to the target store.
27: * Propagation means that the actual text font stored in the workbench store is set as
28: * default text font in the target store. If the target store does not contain a value
29: * rather than the default text font, the new default text font is immediately effective.
30: *
31: * @see org.eclipse.jface.preference.FontFieldEditor
32: * @deprecated since 3.0 not longer in use, no longer supported, use a
33: * <code>ChainedPreferenceStore</code> to access preferences from the
34: * <code>org.eclipse.ui.editors</code> plug-in.
35: * @since 2.0
36: */
37: public class WorkbenchChainedTextFontFieldEditor extends
38: PropagatingFontFieldEditor {
39:
40: /**
41: * Creates a new font field editor with the given parameters.
42: *
43: * @param name the editor's name
44: * @param labelText the text shown as editor description
45: * @param parent the editor's parent widget
46: */
47: public WorkbenchChainedTextFontFieldEditor(String name,
48: String labelText, Composite parent) {
49: super (
50: name,
51: labelText,
52: parent,
53: EditorMessages.WorkbenchChainedTextFontFieldEditor_defaultWorkbenchTextFont);
54: }
55:
56: /**
57: * Starts the propagation of the text font preference set in the workbench
58: * to given target preference store using the given preference key.
59: *
60: * @param target the target preference store
61: * @param targetKey the key to be used in the target preference store
62: */
63: public static void startPropagate(IPreferenceStore target,
64: String targetKey) {
65: Plugin plugin = Platform.getPlugin("org.eclipse.ui.workbench"); //$NON-NLS-1$
66: if (plugin instanceof AbstractUIPlugin) {
67: AbstractUIPlugin uiPlugin = (AbstractUIPlugin) plugin;
68: IPreferenceStore store = uiPlugin.getPreferenceStore();
69: if (store != null)
70: PropagatingFontFieldEditor.startPropagate(store,
71: JFaceResources.TEXT_FONT, target, targetKey);
72: }
73: }
74: }
|