| 1 | [[BackLinksMenu]] |
| 2 | |
| 3 | [[TicketQuery(summary=PLUGIN_SUPPORT_LIB_CONFIGURING_R1, format=table, col=summary|owner|status|type|component|priority|effort|importance, rows=description|analysis_owners|analysis_reviewers|analysis_score|design_owners|design_reviewers|design_score|implementation_owners|implementation_reviewers|implementation_score|test_owners|test_reviewers|test_score|)]] |
| 4 | |
| 5 | = Analysis = |
| 6 | |
| 7 | == Overview == |
| 8 | The goal of this task is to provide ability to load and save configuration settings that are not defined by skins. For example, bug reporting requires user's e-mail address to be persisted. |
| 9 | |
| 10 | == Task requirements == |
| 11 | * Configuration settings are stored as pairs (key, value). |
| 12 | * Loading and saving configuration settings should be easy and made in uniform way: |
| 13 | * get : key -> value - reads the value from configuration file. |
| 14 | * set : key, value - updates the value so any part of Sophie that depends on it is updated. |
| 15 | |
| 16 | * Convention for configuration files: |
| 17 | * Configuration files can be stored in {{{distrib/conf/}}} directory of the corresponding plugin. |
| 18 | * Their names should be unique for the application. |
| 19 | * Use the name of the corresponding Sophie module, for example: |
| 20 | * {{{distrib/conf/org.sophie2.main.layout.mydoggy.conf}}} |
| 21 | * {{{distrib/conf/org.sophie2.main.layout.mydoggy/some_name}}} |
| 22 | * Configuration files are saved in XML format. |
| 23 | * Keys should be unique in a given configuration file, but there's no need to be globally unique, since the file names are unique. |
| 24 | |
| 25 | * Make at least one of the following settings to be persisted in configuration files: |
| 26 | * User's e-mail address in the bug report form. |
| 27 | * Main window's size, location and state (maximized/normal). |
| 28 | * Current skin - default or alternative. |
| 29 | |
| 30 | == Task result == |
| 31 | * Source code. |
| 32 | |
| 33 | == Implementation idea == |
| 34 | * Create a singleton class {{{ConfigurationManager}}} (or something else) that has the described {{{get}}} and {{{set}}} methods. |
| 35 | |
| 36 | * Create a class {{{Configuration}}} that represents a single configuration file. |
| 37 | * Use list of {{{ListEntry}}}s that stores all key-value pairs in that file. |
| 38 | |
| 39 | * Create a generic class {{{ConfigKey}}} that encapsulates all of the information about a key: |
| 40 | * key name |
| 41 | * configuration file |
| 42 | * default value (if the key is not present in the file) |
| 43 | * schema (for the persistence) |
| 44 | |
| 45 | * {{{ConfigKey}}}s should be defined as constants in the code, for example: |
| 46 | * {{{public static final ConfigKey USER_EMAIL = ...;}}} |
| 47 | * {{{email = ConfigurationManager.get().get(USER_EMAIL);}}} |
| 48 | |
| 49 | == Related == |
| 50 | * [wiki:GROUP_PLUGINS_R0] (encompasses PLUGIN_SUPPORT_LIB_CONFIGURING_R0) |
| 51 | * [wiki:APP_PLUGIN_MANAGER_CONFIGURE_R0] |
| 52 | |
| 53 | == How to demo == |
| 54 | * Open Sophie. |
| 55 | * Maximize the main window. |
| 56 | * Open the bug report form (in Help menu) and enter a valid e-mail address. |
| 57 | * Close the form. |
| 58 | * Restart Sophie. |
| 59 | * Show that the main window is maximized. |
| 60 | * Open the bug report and show the saved e-mail address. |
| 61 | |
| 62 | = Design = |
| 63 | ^(Describe your design here.)^ |
| 64 | |
| 65 | = Implementation = |
| 66 | ^(Describe and link the implementation results here (from the wiki or the repository).)^ |
| 67 | |
| 68 | = Testing = |
| 69 | ^(Place the testing results here.)^ |
| 70 | |
| 71 | = Comments = |
| 72 | ^(Write comments for this or later revisions here.) |