Package com.e1c.langtool.ui.external
Class AbstractTranslationPreferencePage
java.lang.Object
org.eclipse.jface.dialogs.DialogPage
org.eclipse.jface.preference.PreferencePage
com.e1c.langtool.ui.external.AbstractTranslationPreferencePage
- All Implemented Interfaces:
org.eclipse.jface.dialogs.IDialogPage,org.eclipse.jface.dialogs.IMessageProvider,org.eclipse.jface.preference.IPreferencePage,org.eclipse.ui.IWorkbenchPreferencePage
- Direct Known Subclasses:
GoogleTranslatePreferencePage,MicrosoftTranslatorPreferencePage,YandexTranslatePreferencePage
public abstract class AbstractTranslationPreferencePage
extends org.eclipse.jface.preference.PreferencePage
implements org.eclipse.ui.IWorkbenchPreferencePage
An abstract class of a preference page for external translation services.
field to input a license key of translation service
button to clear a cache of translations
button to check a license key for validity
- This abstract realization of a preference page contains:
A subclasses should set a preference
store in init(workbanch) method.
- See Also:
-
PreferencePage.setPreferenceStore(org.eclipse.jface.preference.IPreferenceStore)IWorkbenchPreferencePage.init(org.eclipse.ui.IWorkbench)
-
Field Summary
FieldsFields inherited from interface org.eclipse.jface.dialogs.IMessageProvider
ERROR, INFORMATION, NONE, WARNING -
Constructor Summary
ConstructorsConstructorDescriptionAbstractTranslationPreferencePage(ITranslationCacheManager translationCacheManager, String providerId) Constructs a new abstract preference page for external translation service. -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract booleancheckAccessKey(String key) Checks an access key for validity.protected voidClears the cache of translations.protected abstract voidcreateAccessKeyGroup(org.eclipse.swt.widgets.Composite parent) Creates a group that contains components to work with access (API) key.protected voidcreateCheckAccessKeyButton(org.eclipse.swt.widgets.Composite parent) Creates a button to check a validity of access key.protected voidcreateClearCacheButton(org.eclipse.swt.widgets.Composite parent) Creates a button to clear translations cache.protected voidcreateClearCacheGroup(org.eclipse.swt.widgets.Composite parent) Creates a group that contains components to clear translation cache.protected org.eclipse.swt.widgets.ControlcreateContents(org.eclipse.swt.widgets.Composite parent) protected voidcreateGetAccessKeyLink(org.eclipse.swt.widgets.Composite parent) Creates a link to get API key.protected abstract org.eclipse.swt.events.SelectionListenerCreates a selection listener to handle clicks by link to get API key.protected org.eclipse.jface.preference.IPreferenceStoreprotected abstract StringReturns inputed API key to check if it valid incheckAccessKey(String).protected abstract voidInitialize values from preference storo to UI elements.protected voidbooleanprotected abstract voidReload a view that associated with this preference page.protected abstract voidStore values into preference store on apply or OK buttons.Methods inherited from class org.eclipse.jface.preference.PreferencePage
applyData, applyDialogFont, computeSize, contributeButtons, createControl, createDescriptionLabel, createNoteComposite, doComputeSize, getApplyButton, getContainer, getDefaultsButton, getPreferenceStore, isValid, noDefaultAndApplyButton, noDefaultButton, okToLeave, performApply, performCancel, performHelp, setContainer, setErrorMessage, setMessage, setPreferenceStore, setSize, setTitle, setValid, toString, updateApplyButtonMethods inherited from class org.eclipse.jface.dialogs.DialogPage
convertHeightInCharsToPixels, convertHorizontalDLUsToPixels, convertVerticalDLUsToPixels, convertWidthInCharsToPixels, dispose, getControl, getDescription, getDialogFontName, getErrorMessage, getFont, getImage, getMessage, getMessageType, getShell, getTitle, getToolTipText, initializeDialogUnits, isControlCreated, setButtonLayoutData, setControl, setDescription, setImageDescriptor, setMessage, setVisibleMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.eclipse.jface.dialogs.IDialogPage
createControl, dispose, getControl, getDescription, getErrorMessage, getImage, getMessage, getTitle, performHelp, setDescription, setImageDescriptor, setTitle, setVisibleMethods inherited from interface org.eclipse.jface.preference.IPreferencePage
computeSize, isValid, okToLeave, performCancel, setContainer, setSizeMethods inherited from interface org.eclipse.ui.IWorkbenchPreferencePage
init
-
Field Details
-
isApiKeyValueChanged
protected boolean isApiKeyValueChanged
-
-
Constructor Details
-
AbstractTranslationPreferencePage
public AbstractTranslationPreferencePage(ITranslationCacheManager translationCacheManager, String providerId) Constructs a new abstract preference page for external translation service.The given provider's id is necessary for clearing a cache of translations.
- Parameters:
providerId- external translation service's provider id
-
-
Method Details
-
performOk
public boolean performOk()- Specified by:
performOkin interfaceorg.eclipse.jface.preference.IPreferencePage- Overrides:
performOkin classorg.eclipse.jface.preference.PreferencePage
-
performDefaults
protected void performDefaults()- Overrides:
performDefaultsin classorg.eclipse.jface.preference.PreferencePage
-
createContents
protected org.eclipse.swt.widgets.Control createContents(org.eclipse.swt.widgets.Composite parent) - Specified by:
createContentsin classorg.eclipse.jface.preference.PreferencePage
-
createAccessKeyGroup
protected abstract void createAccessKeyGroup(org.eclipse.swt.widgets.Composite parent) Creates a group that contains components to work with access (API) key.This method creates a group contains a text field to input access key for translation api and button to validate it.
- Parameters:
parent- the composite to which this component will be added- See Also:
-
createGetAccessKeyLink
protected void createGetAccessKeyLink(org.eclipse.swt.widgets.Composite parent) Creates a link to get API key.This method creates a
Linkcomponent withSelectionListenercreated bycreateLinkSelectionListener()factory method.- Parameters:
parent- the composite to which this component will be added
-
clearCache
protected void clearCache()Clears the cache of translations. -
createClearCacheButton
protected void createClearCacheButton(org.eclipse.swt.widgets.Composite parent) Creates a button to clear translations cache.- Parameters:
parent- the composite to which this component will be added
-
createClearCacheGroup
protected void createClearCacheGroup(org.eclipse.swt.widgets.Composite parent) Creates a group that contains components to clear translation cache.This method creates a group contains a simple label and button to clear cache.
- Parameters:
parent- the composite to which this component will be added- See Also:
-
createCheckAccessKeyButton
protected void createCheckAccessKeyButton(org.eclipse.swt.widgets.Composite parent) Creates a button to check a validity of access key.- Parameters:
parent- the composite to which this component will be added
-
doGetPreferenceStore
protected org.eclipse.jface.preference.IPreferenceStore doGetPreferenceStore()- Overrides:
doGetPreferenceStorein classorg.eclipse.jface.preference.PreferencePage
-
getAccessKey
Returns inputed API key to check if it valid incheckAccessKey(String).- Returns:
- an access (API) key
-
checkAccessKey
Checks an access key for validity.- Parameters:
key- an access key- Returns:
- true if a given key is valid
- Throws:
ServiceUnavailableException- if the translation service is unavailable or there was connection error
-
reloadView
protected abstract void reloadView()Reload a view that associated with this preference page.- See Also:
-
createLinkSelectionListener
protected abstract org.eclipse.swt.events.SelectionListener createLinkSelectionListener()Creates a selection listener to handle clicks by link to get API key.- See Also:
-
SelectionListenercreateGetAccessKeyLink(Composite)
-
initializeValues
protected abstract void initializeValues()Initialize values from preference storo to UI elements. -
storeValues
protected abstract void storeValues()Store values into preference store on apply or OK buttons.
-