(String path)
| 1243 | |
| 1244 | |
| 1245 | private void openContribBundle(String path) { |
| 1246 | EventQueue.invokeLater(() -> { |
| 1247 | Editor editor = getActiveEditor(); |
| 1248 | if (editor == null) { |
| 1249 | // Shouldn't really happen, but if it's still null, it's a no-go |
| 1250 | Messages.showWarning("Failure is the only option", |
| 1251 | "Please open an Editor window before installing an extension."); |
| 1252 | } else { |
| 1253 | File contribFile = new File(path); |
| 1254 | String baseName = contribFile.getName(); |
| 1255 | baseName = baseName.substring(0, baseName.length() - CONTRIB_BUNDLE_EXT.length()); |
| 1256 | int result = |
| 1257 | Messages.showYesNoQuestion(editor, "How to Handle " + CONTRIB_BUNDLE_EXT, |
| 1258 | "Install " + baseName + "?", |
| 1259 | "Libraries, Modes, and Tools should<br>" + |
| 1260 | "only be installed from trusted sources."); |
| 1261 | |
| 1262 | if (result == JOptionPane.YES_OPTION) { |
| 1263 | editor.statusNotice("Installing " + baseName + "..."); |
| 1264 | editor.startIndeterminate(); |
| 1265 | |
| 1266 | new Thread(() -> { |
| 1267 | try { |
| 1268 | // do the work of the actual install |
| 1269 | LocalContribution contrib = |
| 1270 | AvailableContribution.install(this, new File(path)); |
| 1271 | |
| 1272 | EventQueue.invokeLater(() -> { |
| 1273 | editor.stopIndeterminate(); |
| 1274 | |
| 1275 | if (contrib != null) { |
| 1276 | editor.statusEmpty(); |
| 1277 | } else { |
| 1278 | editor.statusError("Could not install " + path); |
| 1279 | } |
| 1280 | }); |
| 1281 | } catch (IOException e) { |
| 1282 | EventQueue.invokeLater(() -> |
| 1283 | Messages.showWarning("Exception During Installation", |
| 1284 | "Could not install contrib from " + path, e)); |
| 1285 | } |
| 1286 | }).start(); |
| 1287 | } |
| 1288 | } |
| 1289 | }); |
| 1290 | } |
| 1291 | |
| 1292 | |
| 1293 | /** |
no test coverage detected