Runtime

org.eclipse.gmf.runtime.common.ui.preferences
Class FontFieldEditor

java.lang.Object
  extended byorg.eclipse.jface.preference.FieldEditor
      extended byorg.eclipse.gmf.runtime.common.ui.preferences.FontFieldEditor

public class FontFieldEditor
extends FieldEditor

A field editor for a font type preference. Very similar to the org.eclipse.jface.preference.FontFieldEditor. The difference is that the ability to change the selected font without a user action (using the change font button) is provided. Subclassing from the jface FontFieldEditor was not an option because the needed methods and instance variables were private.


Field Summary
 
Fields inherited from class org.eclipse.jface.preference.FieldEditor
HORIZONTAL_GAP, IS_VALID, VALUE
 
Constructor Summary
FontFieldEditor(java.lang.String name, java.lang.String labelText, Composite parent)
          Creates a font field editor without a preview.
FontFieldEditor(java.lang.String name, java.lang.String labelText, java.lang.String previewAreaText, Composite parent)
          Creates a font field editor with an optional preview area.
 
Method Summary
protected  void adjustForNumColumns(int numColumns)
           
protected  void applyFont()
           
protected  void doFillIntoGrid(Composite parent, int numColumns)
           
protected  void doLoad()
           
protected  void doLoadDefault()
           
protected  void doStore()
           
protected  Button getChangeControl(Composite parent)
          Returns the change button for this field editor.
 int getNumberOfControls()
           
 int getPreferredPreviewHeight()
          Returns the preferred preview height.
 Control getPreviewControl()
          Returns the preview control for this field editor.
protected  Label getValueControl(Composite parent)
          Returns the value control for this field editor.
 void setChangeButtonText(java.lang.String text)
          Sets the text of the change button.
 void setEnabled(boolean enabled, Composite parent)
           
 void setFont(FontData newFont)
          Sets the displayed/selected font to be the font for FontData newFont.
protected  void setToDefault()
          Store the default preference for the field being edited
 
Methods inherited from class org.eclipse.jface.preference.FieldEditor
checkParent, clearErrorMessage, clearMessage, convertHorizontalDLUsToPixels, convertVerticalDLUsToPixels, createControl, dispose, fillIntoGrid, fireStateChanged, fireValueChanged, getFieldEditorFontName, getLabelControl, getLabelControl, getLabelText, getPage, getPreferenceName, getPreferencePage, getPreferenceStore, init, isValid, load, loadDefault, presentsDefaultValue, refreshValidState, setButtonLayoutData, setFocus, setLabelText, setPage, setPreferenceName, setPreferencePage, setPreferenceStore, setPresentsDefaultValue, setPropertyChangeListener, showErrorMessage, showMessage, store
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FontFieldEditor

public FontFieldEditor(java.lang.String name,
                       java.lang.String labelText,
                       java.lang.String previewAreaText,
                       Composite parent)
Creates a font field editor with an optional preview area.

Parameters:
name - the name of the preference this field editor works on
labelText - the label text of the field editor
previewAreaText - the text used for the preview window. If it is null there will be no preview area,
parent - the parent of the field editor's control

FontFieldEditor

public FontFieldEditor(java.lang.String name,
                       java.lang.String labelText,
                       Composite parent)
Creates a font field editor without a preview.

Parameters:
name - the name of the preference this field editor works on
labelText - the label text of the field editor
parent - the parent of the field editor's control
Method Detail

adjustForNumColumns

protected void adjustForNumColumns(int numColumns)

applyFont

protected void applyFont()

doFillIntoGrid

protected void doFillIntoGrid(Composite parent,
                              int numColumns)

doLoad

protected void doLoad()

doLoadDefault

protected void doLoadDefault()

doStore

protected void doStore()

getChangeControl

protected Button getChangeControl(Composite parent)
Returns the change button for this field editor.

Parameters:
parent - The Composite to create the button in if required.
Returns:
the change button

getNumberOfControls

public int getNumberOfControls()

getPreferredPreviewHeight

public int getPreferredPreviewHeight()
Returns the preferred preview height.

Returns:
the height, or -1 if no previewer is installed

getPreviewControl

public Control getPreviewControl()
Returns the preview control for this field editor.

Returns:
the preview control

getValueControl

protected Label getValueControl(Composite parent)
Returns the value control for this field editor. The value control displays the currently selected font name.

Parameters:
parent - The Composite to create the viewer in if required
Returns:
the value control

setChangeButtonText

public void setChangeButtonText(java.lang.String text)
Sets the text of the change button.

Parameters:
text - the new text

setToDefault

protected void setToDefault()
Store the default preference for the field being edited


setEnabled

public void setEnabled(boolean enabled,
                       Composite parent)

setFont

public void setFont(FontData newFont)
Sets the displayed/selected font to be the font for FontData newFont.

Parameters:
newFont -

Runtime

Guidelines for using Eclipse APIs.

Copyright (c) IBM Corp., Borland Software Corp., and others 2005,2006. All rights reserved.