Class AbstractEncodingFieldEditor
- java.lang.Object
-
- org.eclipse.jface.preference.FieldEditor
-
- org.eclipse.ui.ide.dialogs.AbstractEncodingFieldEditor
-
- Direct Known Subclasses:
EncodingFieldEditor
,ResourceEncodingFieldEditor
public abstract class AbstractEncodingFieldEditor extends FieldEditor
The abstract superclass of field editors used to set an encoding. Any user entered encodings will be added to the list of encodings available viaIDEEncoding
.Subclasses may extend, but must call
createEncodingGroup
duringdoFillIntoGrid
.- Since:
- 3.1
- See Also:
IDEEncoding
-
-
Field Summary
-
Fields inherited from class org.eclipse.jface.preference.FieldEditor
HORIZONTAL_GAP, IS_VALID, VALUE
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractEncodingFieldEditor()
Creates a new encoding field editor with no settings set.protected
AbstractEncodingFieldEditor(String name, String labelText, String groupTitle, Composite parent)
Creates a new encoding field editor with the given preference name, label and parent.protected
AbstractEncodingFieldEditor(String name, String labelText, Composite parent)
Creates a new encoding field editor with the given preference name, label and parent.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected void
adjustForNumColumns(int numColumns)
Adjusts the horizontal span of this field editor's basic controls.protected Composite
createEncodingGroup(Composite parent, int numColumns)
Creates a composite with all the encoding controls.protected String
defaultButtonText()
Returns the text for the default encoding button.protected void
doFillIntoGrid(Composite parent, int numColumns)
Fills this field editor's basic controls into the given parent.protected void
doLoad()
Initializes this field editor with the preference value from the preference store.protected void
doLoadDefault()
Initializes this field editor with the default preference value from the preference store.protected String
findDefaultEncoding()
Returns the default encoding for the object being shown.protected String
getDefaultEnc()
Returns the default encoding.int
getNumberOfControls()
Returns the number of basic controls this field editor consists of.protected String
getSelectedEncoding()
Returns the currently selected encoding.protected abstract String
getStoredValue()
Returns the value that is currently stored for the encoding.protected boolean
hasSameEncoding(String encodingSetting)
Returns whether or not the encoding setting changed.boolean
isValid()
Returns whether this field editor contains a valid value.protected void
refreshValidState()
Refreshes this field editor's valid state after a value change and fires anIS_VALID
property change event if warranted.void
setEnabled(boolean enabled, Composite parent)
Set whether or not the controls in the field editor are enabled.void
setGroupTitle(String groupTitle)
Set the title of the group to groupTitle.void
setPreferenceStore(IPreferenceStore store)
Sets the preference store used by this field editor.-
Methods inherited from class org.eclipse.jface.preference.FieldEditor
applyFont, checkParent, clearErrorMessage, clearMessage, convertHorizontalDLUsToPixels, convertVerticalDLUsToPixels, createControl, dispose, doStore, fillIntoGrid, fireStateChanged, fireValueChanged, getFieldEditorFontName, getLabelControl, getLabelControl, getLabelText, getPage, getPreferenceName, getPreferencePage, getPreferenceStore, init, load, loadDefault, presentsDefaultValue, setButtonLayoutData, setFocus, setLabelText, setPage, setPreferenceName, setPreferencePage, setPresentsDefaultValue, setPropertyChangeListener, showErrorMessage, showMessage, store
-
-
-
-
Constructor Detail
-
AbstractEncodingFieldEditor
protected AbstractEncodingFieldEditor()
Creates a new encoding field editor with no settings set.
-
AbstractEncodingFieldEditor
protected AbstractEncodingFieldEditor(String name, String labelText, Composite parent)
Creates a new encoding field editor with the given preference name, label and parent.- Parameters:
name
- the name of the preference this field editor works onlabelText
- the label text of the field editorparent
- the parent of the field editor's control
-
AbstractEncodingFieldEditor
protected AbstractEncodingFieldEditor(String name, String labelText, String groupTitle, Composite parent)
Creates a new encoding field editor with the given preference name, label and parent.- Parameters:
name
- the name of the preference this field editor works onlabelText
- the label text of the field editorgroupTitle
- the title for the field editor's control. If groupTitle isnull
the control will be unlabelled (by default aComposite
instead of aGroup
.parent
- the parent of the field editor's control- Since:
- 3.3
- See Also:
setGroupTitle(String)
-
-
Method Detail
-
adjustForNumColumns
protected void adjustForNumColumns(int numColumns)
Description copied from class:FieldEditor
Adjusts the horizontal span of this field editor's basic controls.Subclasses must implement this method to adjust the horizontal span of controls so they appear correct in the given number of columns.
The number of columns will always be equal to or greater than the value returned by this editor's
getNumberOfControls
method.- Specified by:
adjustForNumColumns
in classFieldEditor
- Parameters:
numColumns
- the number of columns
-
doFillIntoGrid
protected void doFillIntoGrid(Composite parent, int numColumns)
Description copied from class:FieldEditor
Fills this field editor's basic controls into the given parent.Subclasses must implement this method to create the controls for this field editor.
Note this method may be called by the constructor, so it must not access fields on the receiver object because they will not be fully initialized.
- Specified by:
doFillIntoGrid
in classFieldEditor
- Parameters:
parent
- the composite used as a parent for the basic controls; the parent's layout must be aGridLayout
numColumns
- the number of columns
-
doLoad
protected void doLoad()
Description copied from class:FieldEditor
Initializes this field editor with the preference value from the preference store.Subclasses must implement this method to properly initialize the field editor.
- Specified by:
doLoad
in classFieldEditor
-
getStoredValue
protected abstract String getStoredValue()
Returns the value that is currently stored for the encoding.- Returns:
- the currently stored encoding
-
doLoadDefault
protected void doLoadDefault()
Description copied from class:FieldEditor
Initializes this field editor with the default preference value from the preference store.Subclasses must implement this method to properly initialize the field editor.
- Specified by:
doLoadDefault
in classFieldEditor
-
getNumberOfControls
public int getNumberOfControls()
Description copied from class:FieldEditor
Returns the number of basic controls this field editor consists of.- Specified by:
getNumberOfControls
in classFieldEditor
- Returns:
- the number of controls
-
isValid
public boolean isValid()
Description copied from class:FieldEditor
Returns whether this field editor contains a valid value.The default implementation of this framework method returns
true
. Subclasses wishing to perform validation should override both this method andrefreshValidState
.- Overrides:
isValid
in classFieldEditor
- Returns:
true
if the field value is valid, andfalse
if invalid- See Also:
FieldEditor.refreshValidState()
-
refreshValidState
protected void refreshValidState()
Description copied from class:FieldEditor
Refreshes this field editor's valid state after a value change and fires anIS_VALID
property change event if warranted.The default implementation of this framework method does nothing. Subclasses wishing to perform validation should override both this method and
isValid
.- Overrides:
refreshValidState
in classFieldEditor
- See Also:
FieldEditor.isValid()
-
setPreferenceStore
public void setPreferenceStore(IPreferenceStore store)
Description copied from class:FieldEditor
Sets the preference store used by this field editor.- Overrides:
setPreferenceStore
in classFieldEditor
- Parameters:
store
- the preference store, ornull
if none- See Also:
FieldEditor.getPreferenceStore()
-
createEncodingGroup
protected Composite createEncodingGroup(Composite parent, int numColumns)
Creates a composite with all the encoding controls.Subclasses may extend.
- Parameters:
parent
- the parent widgetnumColumns
- the number of columns in the parent- Returns:
- the group control
-
setEnabled
public void setEnabled(boolean enabled, Composite parent)
Description copied from class:FieldEditor
Set whether or not the controls in the field editor are enabled.- Overrides:
setEnabled
in classFieldEditor
- Parameters:
enabled
- The enabled state.parent
- The parent of the controls in the group. Used to create the controls if required.
-
findDefaultEncoding
protected String findDefaultEncoding()
Returns the default encoding for the object being shown.- Returns:
- the default encoding for the object being shown
-
defaultButtonText
protected String defaultButtonText()
Returns the text for the default encoding button.- Returns:
- the text for the default encoding button
-
getSelectedEncoding
protected String getSelectedEncoding()
Returns the currently selected encoding.- Returns:
- the currently selected encoding
-
getDefaultEnc
protected String getDefaultEnc()
Returns the default encoding.- Returns:
- the default encoding
-
hasSameEncoding
protected boolean hasSameEncoding(String encodingSetting)
Returns whether or not the encoding setting changed.- Parameters:
encodingSetting
- the setting from the page.- Returns:
- boolean
true
if the resource encoding is the same as before.
-
setGroupTitle
public void setGroupTitle(String groupTitle)
Set the title of the group to groupTitle. If this is not called a default title is used. If groupTitle isnull
the control will be unlabelled (by default aComposite
instead of aGroup
. NOTE this value must be set beforeFieldEditor.createControl(Composite)
is called or it will be ignored.- Parameters:
groupTitle
- The groupTitle to set.- Since:
- 3.3
-
-