Class ContextFileStorage
java.lang.Object
com.e1c.langtool.storage.AbstractFileStorage
com.e1c.langtool.internal.storage.ContextFileStorage
- All Implemented Interfaces:
ITranslationStorageProvider.ContextStorage,ITranslationStorageProvider.Storage
public class ContextFileStorage
extends AbstractFileStorage
implements ITranslationStorageProvider.ContextStorage
The default implementation of file resource storage that stores only context data.
Storage get translation file path by
context resource path and
select external project by the translation language.
Implementation supports to load file's data according to configured format in storage settings.-
Nested Class Summary
Nested classes/interfaces inherited from interface com.e1c.langtool.storage.ITranslationStorageProvider.Storage
ITranslationStorageProvider.Storage.Type -
Field Summary
Fields inherited from class com.e1c.langtool.storage.AbstractFileStorage
batchUpdate, fileMediator, id, project -
Constructor Summary
ConstructorsConstructorDescriptionContextFileStorage(org.eclipse.core.resources.IProject project, StorageID id, ContextStorageSettings settings, ITranslatingProjectManager translatingProjectManager) -
Method Summary
Modifier and TypeMethodDescriptiongetComment(ContextTranslationKey key, TranslateLanguage language) Gets the comment by the translation key.getTranslation(FeatureValue source, TranslateLanguage language) Gets the translation from storage.getTranslation(ContextTranslationKey key, TranslateLanguage language) Gets the translation from the context storage.protected com.google.inject.Provider<ITranslationFileEditorFactory<?>>getType()Returns the type of translation storage.booleanhasKeyForValue(String value, TranslateLanguage language, ContextTranslationKey skipTranslationKey) Checks that context storage has key for the value except the given skip key.voidmoveComment(ContextTranslationKey fromKey, ContextTranslationKey toKey, TranslateLanguage language, boolean autoSave) Move only comment from one translation key to another.voidmoveTranslation(FeatureValue fromSource, FeatureValue toSource, TranslateLanguage language, boolean autoSave) Move translation inside the storage from one key to enother.voidmoveTranslation(ContextTranslationKey fromKey, ContextTranslationKey toKey, TranslateLanguage language, boolean autoSave) Move translation from one key to another inside this single storage.voidremoveComment(ContextTranslationKey key, TranslateLanguage language, boolean autoSave) Removes the comment of the translation key.voidremoveTranslation(FeatureValue source, TranslateLanguage language, boolean autoSave) Removes the translation from storage.voidremoveTranslation(ContextTranslationKey key, TranslateLanguage language, boolean autoSave) Removes the translation.Map<org.eclipse.core.resources.IFile,byte[]> saveFiles(Collection<ContextTranslationKey> affectedKeys, TranslateLanguage language, com.google.common.hash.HashFunction hashFunction) Saves affected translation files explicitly in case if translation data existvoidsetComment(ContextTranslationKey key, TranslateLanguage language, String comment, boolean autoSave) Sets the comment for some translation key.voidsetTranslation(FeatureValue source, TranslateLanguage language, String translation, boolean autoSave) Sets the translation.voidsetTranslation(ContextTranslationKey key, TranslateLanguage language, String translation, boolean autoSave) Sets the translation of context storage.Methods inherited from class com.e1c.langtool.storage.AbstractFileStorage
addBatchUpdateNotification, addValueChangedListener, beginBatchUpdate, dispose, endBatchUpdate, firePostValueChanged, getId, getSegment, isReadOnly, removeValueChangedListenerMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.e1c.langtool.storage.ITranslationStorageProvider.Storage
addBatchUpdateNotification, addValueChangedListener, beginBatchUpdate, endBatchUpdate, getId, getSegment, isReadOnly, removeValueChangedListener
-
Constructor Details
-
ContextFileStorage
public ContextFileStorage(org.eclipse.core.resources.IProject project, StorageID id, ContextStorageSettings settings, ITranslatingProjectManager translatingProjectManager)
-
-
Method Details
-
getTranslation
Description copied from interface:ITranslationStorageProvider.StorageGets the translation from storage.- Specified by:
getTranslationin interfaceITranslationStorageProvider.ContextStorage- Specified by:
getTranslationin interfaceITranslationStorageProvider.Storage- Parameters:
source- the source feature valuelanguage- the language- Returns:
- the translation
-
setTranslation
public void setTranslation(FeatureValue source, TranslateLanguage language, String translation, boolean autoSave) Description copied from interface:ITranslationStorageProvider.StorageSets the translation.- Specified by:
setTranslationin interfaceITranslationStorageProvider.ContextStorage- Specified by:
setTranslationin interfaceITranslationStorageProvider.Storage- Parameters:
source- the source feature valuelanguage- the languagetranslation- the translation
-
removeTranslation
Description copied from interface:ITranslationStorageProvider.StorageRemoves the translation from storage.- Specified by:
removeTranslationin interfaceITranslationStorageProvider.ContextStorage- Specified by:
removeTranslationin interfaceITranslationStorageProvider.Storage- Parameters:
source- the source feature valuelanguage- the language
-
moveTranslation
public void moveTranslation(FeatureValue fromSource, FeatureValue toSource, TranslateLanguage language, boolean autoSave) Description copied from interface:ITranslationStorageProvider.StorageMove translation inside the storage from one key to enother.- Specified by:
moveTranslationin interfaceITranslationStorageProvider.ContextStorage- Specified by:
moveTranslationin interfaceITranslationStorageProvider.Storage- Parameters:
fromSource- the source feature value to move fromtoSource- the source feature value to move tolanguage- the language
-
getType
Description copied from interface:ITranslationStorageProvider.StorageReturns the type of translation storage.- Specified by:
getTypein interfaceITranslationStorageProvider.ContextStorage- Specified by:
getTypein interfaceITranslationStorageProvider.Storage- Returns:
- the type of storage
- See Also:
-
getTranslation
Description copied from interface:ITranslationStorageProvider.ContextStorageGets the translation from the context storage.- Specified by:
getTranslationin interfaceITranslationStorageProvider.ContextStorage- Parameters:
key- the context translation key, cannot benull.language- the language, cannot benull.- Returns:
- the translation, can return
null.
-
setTranslation
public void setTranslation(ContextTranslationKey key, TranslateLanguage language, String translation, boolean autoSave) Description copied from interface:ITranslationStorageProvider.ContextStorageSets the translation of context storage.- Specified by:
setTranslationin interfaceITranslationStorageProvider.ContextStorage- Parameters:
key- the context translation key, cannot benull.language- the language, cannot benull.translation- the translation, can benull.autoSave- turns auto save feature on/off
-
saveFiles
public Map<org.eclipse.core.resources.IFile,byte[]> saveFiles(Collection<ContextTranslationKey> affectedKeys, TranslateLanguage language, com.google.common.hash.HashFunction hashFunction) Description copied from interface:ITranslationStorageProvider.ContextStorageSaves affected translation files explicitly in case if translation data exist- Specified by:
saveFilesin interfaceITranslationStorageProvider.ContextStoragehashFunction- Hash function to use during the export. May not benull- Returns:
- Hash code of saved file. May be
nullin case if no file is saved
-
removeTranslation
public void removeTranslation(ContextTranslationKey key, TranslateLanguage language, boolean autoSave) Description copied from interface:ITranslationStorageProvider.ContextStorageRemoves the translation.- Specified by:
removeTranslationin interfaceITranslationStorageProvider.ContextStorage- Parameters:
key- the context translation key, cannot benull.language- the language, cannot benull.autoSave- turns auto save feature on/of
-
moveTranslation
public void moveTranslation(ContextTranslationKey fromKey, ContextTranslationKey toKey, TranslateLanguage language, boolean autoSave) Description copied from interface:ITranslationStorageProvider.ContextStorageMove translation from one key to another inside this single storage. Attantion! Implementation should move the comment of source translation key to new one.- Specified by:
moveTranslationin interfaceITranslationStorageProvider.ContextStorage- Parameters:
fromKey- the from translation key, cannot benull.toKey- the to translation key, cannot benull.language- the language, cannot benull.
-
getComment
Description copied from interface:ITranslationStorageProvider.ContextStorageGets the comment by the translation key.- Specified by:
getCommentin interfaceITranslationStorageProvider.ContextStorage- Parameters:
key- the key, cannot benull.language- the language, cannot benull.- Returns:
- the comment, can return
null.
-
setComment
public void setComment(ContextTranslationKey key, TranslateLanguage language, String comment, boolean autoSave) Description copied from interface:ITranslationStorageProvider.ContextStorageSets the comment for some translation key.- Specified by:
setCommentin interfaceITranslationStorageProvider.ContextStorage- Parameters:
key- the context translation key, cannot benull.language- the language, cannot benull.comment- the comment, can benull.
-
removeComment
Description copied from interface:ITranslationStorageProvider.ContextStorageRemoves the comment of the translation key.- Specified by:
removeCommentin interfaceITranslationStorageProvider.ContextStorage- Parameters:
key- the translation key, cannot benull.language- the language, cannot benull.
-
moveComment
public void moveComment(ContextTranslationKey fromKey, ContextTranslationKey toKey, TranslateLanguage language, boolean autoSave) Description copied from interface:ITranslationStorageProvider.ContextStorageMove only comment from one translation key to another. Note! The translation value of the source key will not move with it's comment.- Specified by:
moveCommentin interfaceITranslationStorageProvider.ContextStorage- Parameters:
fromKey- the from translation key, cannot benull.toKey- the to translation key, cannot benull.language- the language, cannot benull.
-
hasKeyForValue
public boolean hasKeyForValue(String value, TranslateLanguage language, ContextTranslationKey skipTranslationKey) Description copied from interface:ITranslationStorageProvider.ContextStorageChecks that context storage has key for the value except the given skip key.- Specified by:
hasKeyForValuein interfaceITranslationStorageProvider.ContextStorage- Parameters:
value- the value, cannot benull.language- the translate language, cannot benull.skipTranslationKey- the context key which need to skip in the check, can benull.- Returns:
- true, if context storage has key for the value
-
getTranslationFileEditorFactory
protected com.google.inject.Provider<ITranslationFileEditorFactory<?>> getTranslationFileEditorFactory(StorageSettings settings) - Specified by:
getTranslationFileEditorFactoryin classAbstractFileStorage
-