Asynchronously load the sources required for a character and then load the character. @param pcgFile The character to be loaded.
(final File pcgFile)
| 1151 | * @param pcgFile The character to be loaded. |
| 1152 | */ |
| 1153 | private void loadSourcesThenCharacter(final File pcgFile) |
| 1154 | { |
| 1155 | new Thread(() -> { |
| 1156 | try |
| 1157 | { |
| 1158 | sourceLoader.join(); |
| 1159 | SwingUtilities.invokeAndWait(() -> { |
| 1160 | final String msg = |
| 1161 | LanguageBundle.getFormattedString("in_loadPcLoadingFile", pcgFile.getName()); |
| 1162 | statusBar.startShowingProgress(msg, false); |
| 1163 | statusBar.getProgressBar().getModel().setRangeProperties(0, 1, 0, 2, false); |
| 1164 | statusBar.getProgressBar().setString(LanguageBundle.getString("in_loadPcOpening")); |
| 1165 | }); |
| 1166 | SwingUtilities.invokeLater(() -> { |
| 1167 | try |
| 1168 | { |
| 1169 | CharacterManager.openCharacter(pcgFile, PCGenFrame.this, currentDataSetRef.get()); |
| 1170 | statusBar.getProgressBar().getModel().setRangeProperties(1, 1, 0, 2, false); |
| 1171 | } |
| 1172 | catch (Exception e) |
| 1173 | { |
| 1174 | Logging.errorPrint("Error loading character: " + pcgFile.getName(), e); |
| 1175 | } |
| 1176 | finally |
| 1177 | { |
| 1178 | statusBar.endShowingProgress(); |
| 1179 | } |
| 1180 | }); |
| 1181 | } |
| 1182 | catch (InterruptedException ex) |
| 1183 | { |
| 1184 | //Do nothing |
| 1185 | } |
| 1186 | catch (InvocationTargetException e1) |
| 1187 | { |
| 1188 | Logging.errorPrint("Error showing progress bar.", e1); |
| 1189 | } |
| 1190 | }).start(); |
| 1191 | } |
| 1192 | |
| 1193 | public void loadPartyFromFile(final File pcpFile) |
| 1194 | { |
no test coverage detected