This interface must be implemented by all tabs that display character information: summary tab, classes tab, abilities tab, inventory tab, etc.... The goal of this class is to create a separation of UI models and the UI components that use them. By doing this, knowledge of the CharacterFacade can be
| 55 | * that would occur to any state would be in a call to {@code storeModels}. |
| 56 | */ |
| 57 | public interface CharacterInfoTab |
| 58 | { |
| 59 | |
| 60 | /** |
| 61 | * This gives the CharacterInfoTab a chance to store the models that it will |
| 62 | * use for a given character into a Hashtable. This returned Hashtable will |
| 63 | * be used as arguments in storeModels(Hashtable) and |
| 64 | * restoreModels(Hashtable). |
| 65 | * <p> |
| 66 | * Note: Character tabs implementing this method should <b>NOT</b> make any |
| 67 | * changes to its UI components, this method is purely meant to create |
| 68 | * models and making changes to the UI components could produce undesirable |
| 69 | * side effects. |
| 70 | * |
| 71 | * @param character the character that this state is for. |
| 72 | * @return a ModelMap containing the UI models created for this character |
| 73 | */ |
| 74 | public ModelMap createModels(CharacterFacade character); |
| 75 | |
| 76 | /** |
| 77 | * This restores this character tab to a state that contains the models for |
| 78 | * some given character. The models in question were created during the call |
| 79 | * to {@code createModels(CharacterFacade)} When this is called the tab |
| 80 | * should attach the models contained within this state to the UI components |
| 81 | * of this tab. |
| 82 | * |
| 83 | * @param models a ModelMap containing the models for this character |
| 84 | */ |
| 85 | public void restoreModels(ModelMap models); |
| 86 | |
| 87 | /** |
| 88 | * This is called to save any character specific info that might have |
| 89 | * changed since {@code restoreModels} was called. Implementors might |
| 90 | * also use this method to detach non swappable models from the UI |
| 91 | * components, i.e. listeners. |
| 92 | * |
| 93 | * @param models a ModelMap that contains the models for some character |
| 94 | */ |
| 95 | public void storeModels(ModelMap models); |
| 96 | |
| 97 | /** |
| 98 | * This returns an Action that will be used by the InfoTabbedPane to render |
| 99 | * the tab's title. Any changes in the Action's properties will be |
| 100 | * immediately rendered onto the tab's title space. |
| 101 | * |
| 102 | * @return an Action for the tab title |
| 103 | */ |
| 104 | public TabTitle getTabTitle(); |
| 105 | |
| 106 | public static class ModelMap |
| 107 | { |
| 108 | |
| 109 | private final HashMap<Object, Object> classMap = new HashMap<>(); |
| 110 | |
| 111 | public <T> T get(Class<T> key) |
| 112 | { |
| 113 | return (T) classMap.get(key); |
| 114 | } |
no outgoing calls
no test coverage detected