KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ui > texteditor > WorkbenchChainedTextFontFieldEditor


1 /*******************************************************************************
2  * Copyright (c) 2000, 2005 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11
12
13 package org.eclipse.ui.texteditor;
14
15
16 import org.eclipse.swt.widgets.Composite;
17
18 import org.eclipse.core.runtime.Platform;
19 import org.eclipse.core.runtime.Plugin;
20
21 import org.eclipse.jface.preference.IPreferenceStore;
22 import org.eclipse.jface.resource.JFaceResources;
23 import org.eclipse.jface.text.PropagatingFontFieldEditor;
24
25 import org.eclipse.ui.plugin.AbstractUIPlugin;
26
27
28 /**
29  * This font field editor implements chaining between the workbench's preference
30  * store and a given target preference store. Any time the workbench's preference
31  * for the text font changes, the change is propagated to the target store.
32  * Propagation means that the actual text font stored in the workbench store is set as
33  * default text font in the target store. If the target store does not contain a value
34  * rather than the default text font, the new default text font is immediately effective.
35  *
36  * @see org.eclipse.jface.preference.FontFieldEditor
37  * @deprecated since 3.0 not longer in use, no longer supported, use a
38  * <code>ChainedPreferenceStore</code> to access preferences from the
39  * <code>org.eclipse.ui.editors</code> plug-in.
40  * @since 2.0
41  */

42 public class WorkbenchChainedTextFontFieldEditor extends PropagatingFontFieldEditor {
43
44     /**
45      * Creates a new font field editor with the given parameters.
46      *
47      * @param name the editor's name
48      * @param labelText the text shown as editor description
49      * @param parent the editor's parent widget
50      */

51     public WorkbenchChainedTextFontFieldEditor(String JavaDoc name, String JavaDoc labelText, Composite parent) {
52         super(name, labelText, parent, EditorMessages.WorkbenchChainedTextFontFieldEditor_defaultWorkbenchTextFont);
53     }
54
55     /**
56      * Starts the propagation of the text font preference set in the workbench
57      * to given target preference store using the given preference key.
58      *
59      * @param target the target preference store
60      * @param targetKey the key to be used in the target preference store
61      */

62     public static void startPropagate(IPreferenceStore target, String JavaDoc targetKey) {
63         Plugin plugin= Platform.getPlugin("org.eclipse.ui.workbench"); //$NON-NLS-1$
64
if (plugin instanceof AbstractUIPlugin) {
65             AbstractUIPlugin uiPlugin= (AbstractUIPlugin) plugin;
66             IPreferenceStore store= uiPlugin.getPreferenceStore();
67             if (store != null)
68                 PropagatingFontFieldEditor.startPropagate(store, JFaceResources.TEXT_FONT, target, targetKey);
69         }
70     }
71 }
72
73
Popular Tags