Class HistoryTransPrefs

java.lang.Object
com.e1c.langtool.history.prefs.HistoryTransPrefs

public final class HistoryTransPrefs extends Object
Utility class that provides an access to IEclipsePreferences of core History plug-in.

Note that the all preferences have instance scope.

  • Field Details

  • Method Details

    • getMaxTranslations

      public static int getMaxTranslations()
      Returns the max number of translations returning by translation provider.
      Returns:
      the max number of translations
      Throws:
      NumberFormatException - if the value from preferences cannot be parsed as an integer
      See Also:
    • setMaxTranslations

      public static void setMaxTranslations(int maxNum)
      Sets the max number of translations returning by translation provider.
      Parameters:
      maxNum - the max number of translations (must be > 0)
      Throws:
      IllegalArgumentException - if the given argument is not positive
      RuntimeException - if this operation cannot be completed due to a failure in the preference store, or inability to communicate with it
      See Also:
    • getColorPrefKeyByScopeId

      public static Optional<String> getColorPrefKeyByScopeId(String scopeId)
      Returns preference key for scope color that is associated with the given scope id.
      Parameters:
      scopeId - the scope id to find associated preference key for scope color
      Returns:
      an Optional describing preference key for color of scope, or an empty Optional if there is not any associated preference key with the given scope id
    • getEnabledPrefKeyByScopeId

      public static Optional<String> getEnabledPrefKeyByScopeId(String scopeId)
      Returns preference key that is associated with the given scope id for describing enabled status of scope.
      Parameters:
      scopeId - the scope id to find associated preference key
      Returns:
      an Optional describing preference key for scope enabled status, or an empty Optional if there is not any associated preference key with the given scope id
    • getDefaultScopeIds

      public static List<String> getDefaultScopeIds()
      Returns the default order of scope id's.

      This method ensures that order of id's returning by this method is idempotent.

      Returns:
      the default order of scope id's
    • getScopeIds

      public static List<String> getScopeIds()
      Returns the current order of scope id's stored in preferences.
      Returns:
      the current order of scope id's
    • setScopeIds

      public static void setScopeIds(List<String> scopeIds)
      Stores the orders of scope id's in preferences.
      Parameters:
      scopeIds - a new order of scope id's
      Throws:
      RuntimeException - if this operation cannot be completed due to a failure in the preference store, or inability to communicate with it
    • isScopeEnabled

      public static Optional<Boolean> isScopeEnabled(String scopeEnabledPredKey)
      Returns the value associated with the given preference key that describing scope enabled status.
      Parameters:
      scopeEnabledPredKey - enabled scope preference key
      Returns:
      an Optional describing value of scope enabled status, or an empty Optional if there is not any value with the given preference key
      Throws:
      NumberFormatException - if the value from preferences cannot be parsed as an boolean
    • setScopeEnabled

      public static void setScopeEnabled(String scopeEnabledPrefKey, boolean isEnabled)
      Sets value at the given preference key that describes enabled scope status.
      Parameters:
      scopeEnabledPrefKey - scope enabled preference key
      isEnabled - an enabled status
      Throws:
      RuntimeException - if this operation cannot be completed due to a failure in the preference store, or inability to communicate with it
    • setScopeEnabledByScopeId

      public static void setScopeEnabledByScopeId(String scopeId, boolean isEnabled)
      Sets enabled status for the given scope id.

      This method does nothing if there are not any associated preference keys with the given scope id for enabled status.

      Parameters:
      scopeId - the scope id to set enabled status
      isEnabled - an enabled status
      Throws:
      RuntimeException - if this operation cannot be completed due to a failure in the preference store, or inability to communicate with it
    • getScopeEnabledByScopeId

      public static Optional<Boolean> getScopeEnabledByScopeId(String scopeId)
      Returns the enabled status of the scope that associated with the given scope id.
      Parameters:
      scopeId - the id of scope which enabled status to get
      Returns:
      an Optional describing value of scope enabled status, or an empty Optional if there is not any value for the given scope id
      Throws:
      NumberFormatException - if the value from preferences cannot be parsed as an boolean
    • getScopeColor

      public static Optional<org.eclipse.swt.graphics.RGB> getScopeColor(String scopeColorPrefKey)
    • setScopeColor

      public static void setScopeColor(String scopeColorPrefKey, org.eclipse.swt.graphics.RGB rgb)
    • getScopeColorByScopeId

      public static Optional<org.eclipse.swt.graphics.RGB> getScopeColorByScopeId(String scopeId)
    • setScopeColorByScopeId

      public static void setScopeColorByScopeId(String scopeId, org.eclipse.swt.graphics.RGB color)
    • clearAll

      public static void clearAll()
      Clears all preferences.