Changeset 621 for AE/installer2/src
- Timestamp:
- Jan 15, 2013, 9:02:01 PM (12 years ago)
- Location:
- AE/installer2/src/net/oni2/aeinstaller
- Files:
-
- 1 added
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
AE/installer2/src/net/oni2/aeinstaller/AEInstaller.properties
r618 r621 1 1 appname=AE Installer 2 2 appversion=0.8 02 appversion=0.81 3 3 4 4 invalidPath.title=Wrong directory … … 7 7 dotNetMissing.title=.NET is not installed 8 8 dotNetMissing.text=.NET, which is required to use this tool, is not installed on this machine.<br>Please download and install it:<br>%1 9 10 offlineMode.title=Offline mode 11 offlineMode.text=Connection to the ModDepot could not be established.\nAEI will run in offline mode.\nUpdates or installation of mods not already downloaded will not be possible. -
AE/installer2/src/net/oni2/aeinstaller/AEInstaller2.java
r612 r621 177 177 } 178 178 179 boolean offline = !DepotManager.getInstance().checkConnection(); 180 if (offline) { 181 JOptionPane.showMessageDialog(null, 182 basicBundle.getString("offlineMode.text"), 183 basicBundle.getString("offlineMode.title"), 184 JOptionPane.INFORMATION_MESSAGE); 185 } 186 Settings.getInstance().setOfflineMode(offline); 187 179 188 SwingUtilities.invokeLater(new Runnable() { 180 189 public void run() { -
AE/installer2/src/net/oni2/aeinstaller/Images.properties
r608 r621 28 28 img.install=/net/oni2/aeinstaller/images/open_icon_library/run-build-install-root.png 29 29 img.folder=/net/oni2/aeinstaller/images/open_icon_library/folder-open-3.png 30 img.update=/net/oni2/aeinstaller/images/open_icon_library/system-software-update-2.png 30 31 31 32 img.ae=/net/oni2/aeinstaller/images/AElogo.png -
AE/installer2/src/net/oni2/aeinstaller/backend/Settings.java
r619 r621 65 65 66 66 private boolean printNamesNotInMap = false; 67 68 private boolean offlineMode = false; 67 69 68 70 /** … … 161 163 162 164 /** 165 * @return Is offline? 166 */ 167 public boolean isOfflineMode() { 168 return offlineMode; 169 } 170 171 /** 172 * @param offline 173 * Is offline? 174 */ 175 public void setOfflineMode(boolean offline) { 176 this.offlineMode = offline; 177 } 178 179 /** 163 180 * @return Mod Depot cache filename 164 181 */ -
AE/installer2/src/net/oni2/aeinstaller/backend/depot/DepotConfig.java
r604 r621 1 1 package net.oni2.aeinstaller.backend.depot; 2 3 import net.oni2.aeinstaller.backend.Settings; 2 4 3 5 /** … … 76 78 return 8000; 77 79 } 80 81 /** 82 * @return URL of Depot 83 */ 84 public static String getDepotUrl() { 85 return Settings.getInstance().get("depot_url", "http://mods.oni2.net/"); 86 } 87 88 /** 89 * @return URL of Depot API 90 */ 91 public static String getDepotApiUrl() { 92 return Settings.getInstance().get("depot_api_url", 93 "http://mods.oni2.net/?q=api/"); 94 } 78 95 } -
AE/installer2/src/net/oni2/aeinstaller/backend/depot/DepotManager.java
r605 r621 5 5 import java.io.FileOutputStream; 6 6 import java.io.IOException; 7 import java.io.UnsupportedEncodingException; 8 import java.net.UnknownHostException; 7 9 import java.util.HashMap; 8 10 import java.util.HashSet; … … 21 23 import net.oni2.aeinstaller.backend.network.DrupalJSONQuery; 22 24 25 import org.apache.http.HttpResponse; 26 import org.apache.http.client.methods.HttpGet; 27 import org.apache.http.client.methods.HttpRequestBase; 28 import org.apache.http.impl.client.DefaultHttpClient; 23 29 import org.json.JSONArray; 24 30 import org.json.JSONException; … … 221 227 222 228 /** 229 * @return Can we connect to the Depot? 230 */ 231 public boolean checkConnection() { 232 HttpRequestBase httpQuery = null; 233 234 try { 235 DefaultHttpClient httpclient = new DefaultHttpClient(); 236 httpQuery = new HttpGet(DepotConfig.getDepotUrl()); 237 238 HttpResponse response = httpclient.execute(httpQuery); 239 240 int code = response.getStatusLine().getStatusCode(); 241 242 return (code >= 200) && (code <= 299); 243 } catch (UnknownHostException e) { 244 } catch (UnsupportedEncodingException e) { 245 e.printStackTrace(); 246 } catch (IOException e) { 247 e.printStackTrace(); 248 } finally { 249 if (httpQuery != null) 250 httpQuery.releaseConnection(); 251 } 252 return false; 253 } 254 255 /** 223 256 * @return All TaxVocabs 224 257 */ -
AE/installer2/src/net/oni2/aeinstaller/backend/mods/ModManager.java
r608 r621 182 182 183 183 /** 184 * @return Mods which are already locally available 185 */ 186 public TreeSet<Mod> getLocalAvailableMods() { 187 TreeSet<Mod> res = new TreeSet<Mod>(); 188 for (Mod m : mods.values()) { 189 if (m.isLocalAvailable()) 190 res.add(m); 191 } 192 return res; 193 } 194 195 /** 196 * @return Mods which can be updated 197 */ 198 public TreeSet<Mod> getUpdatableMods() { 199 TreeSet<Mod> res = new TreeSet<Mod>(); 200 for (Mod m : getLocalAvailableMods()) { 201 if (m.isNewerAvailable()) 202 res.add(m); 203 } 204 return res; 205 } 206 207 /** 184 208 * @return Collection of tools valid on this platform and not mandatory 185 209 */ … … 199 223 for (Mod m : tools.values()) { 200 224 if (m.isValidOnPlatform() && m.isMandatoryMod()) 225 res.add(m); 226 } 227 return res; 228 } 229 230 /** 231 * @return Tools which are already locally available 232 */ 233 public TreeSet<Mod> getLocalAvailableTools() { 234 TreeSet<Mod> res = new TreeSet<Mod>(); 235 for (Mod m : tools.values()) { 236 if (m.isLocalAvailable()) 237 res.add(m); 238 } 239 return res; 240 } 241 242 /** 243 * @return Tools which can be updated 244 */ 245 public TreeSet<Mod> getUpdatableTools() { 246 TreeSet<Mod> res = new TreeSet<Mod>(); 247 for (Mod m : getLocalAvailableTools()) { 248 if (m.isNewerAvailable()) 201 249 res.add(m); 202 250 } -
AE/installer2/src/net/oni2/aeinstaller/backend/mods/download/ModDownload.java
r605 r621 80 80 unpacker = new Unpacker(zipFile, targetFolder, this); 81 81 } catch (IOException e) { 82 // TODO Auto-generated catch block83 82 e.printStackTrace(); 84 83 } -
AE/installer2/src/net/oni2/aeinstaller/backend/network/DrupalJSONQuery.java
r605 r621 9 9 import java.util.List; 10 10 11 import net.oni2.aeinstaller.backend. Settings;11 import net.oni2.aeinstaller.backend.depot.DepotConfig; 12 12 13 13 import org.apache.http.HttpEntity; … … 29 29 */ 30 30 public class DrupalJSONQuery { 31 32 private static String getDepotUrl() {33 return Settings.getInstance().get("depot_api_url",34 "http://mods.oni2.net/?q=api/");35 }36 31 37 32 /** … … 56 51 } 57 52 HttpEntity data = new UrlEncodedFormEntity(nvps); 58 return executeQuery( getDepotUrl() + resource + "/" + action53 return executeQuery(DepotConfig.getDepotApiUrl() + resource + "/" + action 59 54 + ".json", data); 60 55 } catch (UnsupportedEncodingException e) { … … 80 75 String refName) throws Exception { 81 76 return executeQuery( 82 getDepotUrl() + resource + "/" + Integer.toString(index) + "/"77 DepotConfig.getDepotApiUrl() + resource + "/" + Integer.toString(index) + "/" 83 78 + refName + ".json", null); 84 79 } … … 100 95 String parameters) throws Exception { 101 96 return executeQuery( 102 getDepotUrl() + resource + "/" + Integer.toString(index)97 DepotConfig.getDepotApiUrl() + resource + "/" + Integer.toString(index) 103 98 + ".json" + parameters, null); 104 99 } … … 126 121 if (pagesize >= 0) 127 122 pagesizeN = "&pagesize=" + Integer.toString(pagesize); 128 return executeQuery( getDepotUrl() + resource + ".json" + pageN123 return executeQuery(DepotConfig.getDepotApiUrl() + resource + ".json" + pageN 129 124 + pagesizeN, null); 130 125 } -
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.