Changeset 621 for AE/installer2/src/net/oni2/aeinstaller/gui
- Timestamp:
- Jan 15, 2013, 9:02:01 PM (12 years ago)
- Location:
- AE/installer2/src/net/oni2/aeinstaller/gui
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
AE/installer2/src/net/oni2/aeinstaller/gui/MainWin.java
r619 r621 52 52 import net.oni2.aeinstaller.backend.oni.InstallProgressListener; 53 53 import net.oni2.aeinstaller.backend.oni.Installer; 54 import net.oni2.aeinstaller.backend.oni.OniSplit; 54 55 import net.oni2.aeinstaller.gui.about.AboutDialog; 55 56 import net.oni2.aeinstaller.gui.downloadwindow.Downloader; … … 92 93 private JLabel lblTypesVal; 93 94 private JLabel lblPlatformVal; 95 private JLabel lblPackageNumberVal; 94 96 private HTMLLinkLabel lblDescriptionVal; 95 97 96 98 private JButton btnInstall; 99 100 private TreeSet<Mod> execUpdates = null; 101 102 private enum EInstallResult { 103 DONE, 104 OFFLINE, 105 INCOMPATIBLE 106 }; 107 108 private EInstallResult installDone = EInstallResult.DONE; 97 109 98 110 /** … … 228 240 @DoInBackground(progressMessage = "updateDepot.title", cancelable = false, indeterminateProgress = false) 229 241 private void execDepotUpdate(final BackgroundEvent evt) { 230 try { 231 DepotManager.getInstance().updateInformation(false, 232 new DepotCacheUpdateProgressListener() { 233 234 @Override 235 public void cacheUpdateProgress(String stepName, 236 int current, int total) { 237 evt.setProgressEnd(total); 238 evt.setProgressValue(current); 239 evt.setProgressMessage(stepName); 240 } 241 }); 242 ModManager.getInstance().init(); 243 initTable(); 244 initModTypeBox(); 245 246 tblMods.setVisible(true); 247 } catch (Exception e) { 248 e.printStackTrace(); 249 } 250 } 251 252 @SuppressWarnings("unused") 253 private void checkUpdates() { 254 if (Settings.getInstance().get("notifyupdates", true)) { 242 if (!Settings.getInstance().isOfflineMode()) { 243 try { 244 DepotManager.getInstance().updateInformation(false, 245 new DepotCacheUpdateProgressListener() { 246 247 @Override 248 public void cacheUpdateProgress(String stepName, 249 int current, int total) { 250 evt.setProgressEnd(total); 251 evt.setProgressValue(current); 252 evt.setProgressMessage(stepName); 253 } 254 }); 255 } catch (Exception e) { 256 e.printStackTrace(); 257 } 258 } 259 ModManager.getInstance().init(); 260 initTable(); 261 initModTypeBox(); 262 263 tblMods.setVisible(true); 264 } 265 266 @SuppressWarnings("unused") 267 private void checkUpdates(Object evtSource) { 268 if ((evtSource != this) 269 || Settings.getInstance().get("notifyupdates", true)) { 270 if (Settings.getInstance().isOfflineMode()) { 271 if (evtSource != this) { 272 JOptionPane.showMessageDialog(this, 273 bundle.getString("offlineMode.text"), 274 bundle.getString("offlineMode.title"), 275 JOptionPane.WARNING_MESSAGE); 276 } 277 } else { 278 TreeSet<Mod> mods = ModManager.getInstance().getUpdatableMods(); 279 TreeSet<Mod> tools = ModManager.getInstance() 280 .getUpdatableTools(); 281 int size = 0; 282 String strMods = ""; 283 for (Mod m : mods) { 284 size += m.getZipSize(); 285 if (strMods.length() > 0) 286 strMods += "<br>"; 287 strMods += " - " + m.getName(); 288 } 289 String strTools = ""; 290 for (Mod m : tools) { 291 size += m.getZipSize(); 292 if (strTools.length() > 0) 293 strTools += "<br>"; 294 strTools += " - " + m.getName(); 295 } 296 String message = "<html>"; 297 message += String.format( 298 bundle.getString("updatesAvailable.text"), strMods, 299 strTools, SizeFormatter.format(size, 3)); 300 message += "</html>"; 301 int res = JOptionPane 302 .showConfirmDialog(this, message, 303 bundle.getString("updatesAvailable.title"), 304 JOptionPane.YES_NO_OPTION, 305 JOptionPane.QUESTION_MESSAGE); 306 if (res == JOptionPane.YES_OPTION) { 307 execUpdates = new TreeSet<Mod>(); 308 execUpdates.addAll(mods); 309 execUpdates.addAll(tools); 310 } 311 } 312 } 313 } 314 315 @DoInBackground(progressMessage = "doUpdate.title", cancelable = false, indeterminateProgress = false) 316 private void doUpdate(final BackgroundEvent evt) { 317 if (execUpdates != null) { 255 318 // TODO 256 } 319 System.out.println("Update: " + execUpdates.toString()); 320 // TODO: install new tools if previously installed 321 } 322 execUpdates = null; 257 323 } 258 324 … … 351 417 @DoInBackground(progressMessage = "mandatoryFiles.title", cancelable = false, indeterminateProgress = false) 352 418 private void checkMandatoryFiles(final BackgroundEvent evt) { 353 TreeSet<Mod> mand = new TreeSet<Mod>(); 354 for (Mod m : ModManager.getInstance().getMandatoryTools()) { 355 if (m.isNewerAvailable()) { 356 mand.add(m); 357 } 358 } 359 for (Mod m : ModManager.getInstance().getMandatoryMods()) { 360 if (m.isNewerAvailable()) { 361 mand.add(m); 362 } 363 } 364 if (mand.size() > 0) { 365 ModDownloader m = new ModDownloader(mand, 366 new ModDownloaderListener() { 367 @Override 368 public void updateStatus(ModDownloader source, 369 State state, int filesDown, int filesTotal, 370 int bytesDown, int bytesTotal, int duration, 371 int remaining, int speed) { 372 evt.setProgressEnd(filesTotal); 373 evt.setProgressValue(filesDown); 374 } 375 }); 376 while (!m.isFinished()) { 377 try { 378 Thread.sleep(10); 379 } catch (InterruptedException e) { 380 e.printStackTrace(); 381 } 382 } 383 } 384 evt.setProgressMessage(bundle.getString("mandatoryToolsInstall.title")); 385 Installer.installTools(ModManager.getInstance().getMandatoryTools()); 419 if (!Settings.getInstance().isOfflineMode()) { 420 TreeSet<Mod> mand = new TreeSet<Mod>(); 421 for (Mod m : ModManager.getInstance().getMandatoryTools()) { 422 if (m.isNewerAvailable()) { 423 mand.add(m); 424 } 425 } 426 for (Mod m : ModManager.getInstance().getMandatoryMods()) { 427 if (m.isNewerAvailable()) { 428 mand.add(m); 429 } 430 } 431 if (mand.size() > 0) { 432 ModDownloader m = new ModDownloader(mand, 433 new ModDownloaderListener() { 434 @Override 435 public void updateStatus(ModDownloader source, 436 State state, int filesDown, int filesTotal, 437 int bytesDown, int bytesTotal, 438 int duration, int remaining, int speed) { 439 evt.setProgressEnd(filesTotal); 440 evt.setProgressValue(filesDown); 441 } 442 }); 443 while (!m.isFinished()) { 444 try { 445 Thread.sleep(10); 446 } catch (InterruptedException e) { 447 e.printStackTrace(); 448 } 449 } 450 } 451 evt.setProgressMessage(bundle 452 .getString("mandatoryToolsInstall.title")); 453 Installer 454 .installTools(ModManager.getInstance().getMandatoryTools()); 455 } 386 456 } 387 457 388 458 @DoInBackground(progressMessage = "installing.title", cancelable = false, indeterminateProgress = false) 389 private booleaninstall(final BackgroundEvent evt) {459 private void install(final BackgroundEvent evt) { 390 460 TreeSet<Mod> mods = new TreeSet<Mod>(); 391 461 mods.addAll(ModManager.getInstance().getMandatoryMods()); … … 393 463 394 464 boolean instReady = false; 465 installDone = EInstallResult.DONE; 395 466 396 467 while (!instReady) { 397 System.out.println("Checking downloads:");398 468 TreeSet<Mod> toDownload = new TreeSet<Mod>(); 399 469 for (Mod m : mods) { … … 401 471 toDownload.add(m); 402 472 } 473 if (Settings.getInstance().isOfflineMode()) { 474 installDone = EInstallResult.OFFLINE; 475 break; 476 } 403 477 if (toDownload.size() > 0) { 404 System.out.println("Download files: " + toDownload.toString());405 478 Downloader dl = new Downloader(toDownload); 406 479 try { … … 425 498 .checkIncompabitilites(mods); 426 499 if (conflicts.size() > 0) { 500 installDone = EInstallResult.INCOMPATIBLE; 427 501 System.err.println("Incompatible mods: " 428 502 + conflicts.toString()); … … 435 509 436 510 if (instReady) { 437 System.out.println("Install mods: " + mods.toString());438 439 511 Installer.install(mods, new InstallProgressListener() { 440 512 @Override … … 446 518 } 447 519 }); 448 return true; 449 } 450 return false; 520 installDone = EInstallResult.DONE; 521 } 451 522 } 452 523 453 524 @SuppressWarnings("unused") 454 525 private void installDone() { 455 JOptionPane.showMessageDialog(this, 456 bundle.getString("installDone.text"), 457 bundle.getString("installDone.title"), 458 JOptionPane.INFORMATION_MESSAGE); 526 switch (installDone) { 527 case DONE: 528 JOptionPane.showMessageDialog(this, 529 bundle.getString("installDone.text"), 530 bundle.getString("installDone.title"), 531 JOptionPane.INFORMATION_MESSAGE); 532 break; 533 case OFFLINE: 534 JOptionPane.showMessageDialog(this, 535 bundle.getString("offlineMode.text"), 536 bundle.getString("offlineMode.title"), 537 JOptionPane.WARNING_MESSAGE); 538 break; 539 case INCOMPATIBLE: 540 break; 541 } 459 542 } 460 543 … … 465 548 lblTypesVal.setText(""); 466 549 lblPlatformVal.setText(""); 550 lblPackageNumberVal.setText(""); 467 551 if (m != null) { 468 552 lblSubmitterVal.setText(m.getName()); … … 478 562 lblTypesVal.setText(types); 479 563 lblPlatformVal.setText(m.getPlatform().toString()); 480 }481 // TODO564 lblPackageNumberVal.setText(m.getPackageNumberString()); 565 } 482 566 } 483 567 … … 499 583 private void checkInitialize() { 500 584 if (!Installer.isEditionInitialized()) { 501 int res = JOptionPane.showConfirmDialog(this, 502 bundle.getString("askInitialize.text"), 503 bundle.getString("askInitialize.title"), 504 JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE); 505 if (res == JOptionPane.NO_OPTION) { 506 saveLocalData(); 585 if (!OniSplit.isOniSplitInstalled()) { 586 JOptionPane.showMessageDialog(this, 587 bundle.getString("noOniSplit.text"), 588 bundle.getString("noOniSplit.title"), 589 JOptionPane.ERROR_MESSAGE); 507 590 exit(); 591 } else { 592 int res = JOptionPane 593 .showConfirmDialog(this, 594 bundle.getString("askInitialize.text"), 595 bundle.getString("askInitialize.title"), 596 JOptionPane.YES_NO_OPTION, 597 JOptionPane.QUESTION_MESSAGE); 598 if (res == JOptionPane.NO_OPTION) { 599 saveLocalData(); 600 exit(); 601 } 508 602 } 509 603 } -
AE/installer2/src/net/oni2/aeinstaller/gui/MainWin.properties
r612 r621 26 26 menu.tools=&Manage Tools 27 27 menu.toolsTooltip=Install/Remove Tools 28 menu.update=&Check for updates 29 menu.updateTooltip=Check for updates to already downloaded packages on the Depot 28 30 29 31 btnRevertSelection.text=Revert selection … … 40 42 lblTypes.text=Types: 41 43 lblPlatform.text=Platform: 44 lblPackageNumber.text=Package number: 42 45 lblFiles.text=Number of files: 43 46 lblDescription.text=Description: … … 48 51 installDone.text=You can now play AE Oni. 49 52 53 offlineMode.title=Offline mode 54 offlineMode.text=AEI is running in offline mode.\nNo updates or downloads of new mods are possible.\nPlease restart AEI when you have internet connection to update or download new packages. 50 55 updatesAvailable.title=Updates available 51 updatesAvailable.text= Some mods have newer versions available.56 updatesAvailable.text=The following mods and tools have newer versions on the Depot.<br>Mods:<br>%s<br>Tools:<br>%s<br><br>Size of files to download is %s.<br>Update now? 52 57 58 noOniSplit.title=OniSplit not available 59 noOniSplit.text=The Edition is not yet initialized and OniSplit is missing (offline mode?).\nCan not resume from here, exiting! 53 60 askInitialize.title=Initialize Edition 54 61 askInitialize.text=The Edition is not yet initialized.\nIf you do not initialize now the installer will exit.\nInitialize Edition core now? … … 59 66 mandatoryToolsInstall.title=Installing mandatory tools 60 67 68 doUpdate.title=Updating packages 69 -
AE/installer2/src/net/oni2/aeinstaller/gui/MainWin.yml
r617 r621 6 6 locationRelativeTo: null 7 7 defaultCloseOperation: doNothingOnClose 8 onWindowOpened: [execDepotUpdate,checkMandatoryFiles,checkInitialize,initialize,checkUpdates, focus]8 onWindowOpened: [execDepotUpdate,checkMandatoryFiles,checkInitialize,initialize,checkUpdates,doUpdate] 9 9 onWindowClosing: [saveLocalData,exit] 10 10 iconImage: img.ae … … 20 20 - Action(name=reglobalize, text=menu.reglobalize, toolTipText=menu.reglobalizeTooltip, icon=img.refresh, onAction=[reglobalize]) 21 21 - Action(name=tools, text=menu.tools, toolTipText=menu.toolsTooltip, icon=img.tools, onAction=[tools]) 22 - Action(name=update, text=menu.update, toolTipText=menu.updateTooltip, icon=img.update, onAction=[checkUpdates,doUpdate]) 22 23 - JMenuBar: 23 24 - JMenu(name=mainMenu, text=menu.main): … … 37 38 - JSeparator() 38 39 - JMenuItem(action=tools) 40 - JSeparator() 41 - JMenuItem(action=update) 39 42 - JToolBar(name=toolbar, floatable=false, orientation=0): 40 43 - JButton(action=exitAction, hideActionText=true) … … 67 70 - JLabel(name=lblPlatform, text=lblPlatform.text) 68 71 - JLabel(name=lblPlatformVal) 72 - JLabel(name=lblPackageNumber, text=lblPackageNumber.text) 73 - JLabel(name=lblPackageNumberVal) 69 74 - JLabel(name=lblDescription, text=lblDescription.text) 70 75 - JScrollPane(name=scrollDescription, vScrollBar=always, hScrollBar=asNeeded): … … 72 77 - MigLayout: | 73 78 [min] [grow] 74 >lblSubmitter lblSubmitterVal [min] 75 >lblCreator lblCreatorVal [min] 76 >lblTypes lblTypesVal [min] 77 >lblPlatform lblPlatformVal [min] 78 >^lblDescription scrollDescription [grow] 79 >lblSubmitter lblSubmitterVal [min] 80 >lblCreator lblCreatorVal [min] 81 >lblTypes lblTypesVal [min] 82 >lblPlatform lblPlatformVal [min] 83 >lblPackageNumber lblPackageNumberVal [min] 84 >^lblDescription scrollDescription [grow] 79 85 - MigLayout: 80 86 layoutConstraints: wrap 1
Note:
See TracChangeset
for help on using the changeset viewer.