MCPcopy Create free account
hub / github.com/PCGen/pcgen / setCharacter

Method setCharacter

code/src/java/pcgen/gui2/tabs/InfoTabbedPane.java:143–175  ·  view source on GitHub ↗
(CharacterFacade character)

Source from the content-addressed store, hash-verified

141 }
142
143 @Override
144 public void setCharacter(CharacterFacade character)
145 {
146 modelService.cancelRestoreTasks();
147 if (!stateMap.containsKey(character))
148 {
149 //This is the first time this character has been added, so initialize the tab states.
150 for (int i = 0; i < getTabCount(); i++)
151 {
152 CharacterInfoTab tab = (CharacterInfoTab) getComponentAt(i);
153 ModelMap models = tab.createModels(character);
154 stateMap.put(character, tab, models);
155 }
156 String key = UIPropertyContext.C_PROP_INITIAL_TAB;
157 key = UIPropertyContext.createCharacterPropertyKey(character, key);
158 //defaults to the summary tab if prop doesn't exist
159 int startingTab = UIPropertyContext.getInstance().getInt(key, SUMMARY_TAB);
160 tabSelectionMap.put(character, startingTab);
161 }
162 if (currentCharacter != null)
163 {
164 Map<CharacterInfoTab, ModelMap> states = stateMap.getMapFor(currentCharacter);
165 modelService.storeModels(states);
166 //Save tabSelection for this character
167 tabSelectionMap.put(currentCharacter, getSelectedIndex());
168 }
169 currentCharacter = character;
170
171 Map<CharacterInfoTab, ModelMap> states = stateMap.getMapFor(character);
172 updateTabsForCharacter(character);
173 int selectedIndex = tabSelectionMap.get(character);
174 modelService.restoreModels(states, selectedIndex);
175 }
176
177 /**
178 * Update the displayed tabs to reflect the settings of the game mode of the

Callers

nothing calls this directly

Calls 12

createModelsMethod · 0.95
getInstanceMethod · 0.95
cancelRestoreTasksMethod · 0.80
getIntMethod · 0.80
containsKeyMethod · 0.65
putMethod · 0.65
storeModelsMethod · 0.65
getMethod · 0.65
restoreModelsMethod · 0.65
getMapForMethod · 0.45

Tested by

no test coverage detected