01: /*******************************************************************************
02: * Copyright (c) 2006 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.examples.views.properties.tabbed.article.views;
11:
12: import org.eclipse.jface.viewers.DialogCellEditor;
13: import org.eclipse.swt.graphics.FontData;
14: import org.eclipse.swt.widgets.Composite;
15: import org.eclipse.swt.widgets.Control;
16: import org.eclipse.swt.widgets.FontDialog;
17: import org.eclipse.ui.PlatformUI;
18:
19: /**
20: * a new Font dialog cell editor.
21: *
22: * @author Anthony Hunter
23: */
24: public class FontDialogCellEditor extends DialogCellEditor {
25:
26: /**
27: * Creates a new Font dialog cell editor parented under the given control.
28: * The cell editor value is <code>null</code> initially, and has no
29: * validator.
30: *
31: * @param parent
32: * the parent control
33: */
34: protected FontDialogCellEditor(Composite parent) {
35: super (parent);
36: }
37:
38: /**
39: * @see org.eclipse.jface.viewers.DialogCellEditor#openDialogBox(Control)
40: */
41: protected Object openDialogBox(Control cellEditorWindow) {
42: FontDialog ftDialog = new FontDialog(PlatformUI.getWorkbench()
43: .getActiveWorkbenchWindow().getShell());
44:
45: String value = (String) getValue();
46:
47: if ((value != null) && (value.length() > 0)) {
48: ftDialog
49: .setFontList(new FontData[] { new FontData(value) });
50: }
51: FontData fData = ftDialog.open();
52:
53: if (fData != null) {
54: value = fData.toString();
55: }
56: return value;
57: }
58:
59: }
|