ViewVC Help
View File | Revision Log | View Changeset | Root Listing
root/Oni2/java/installer2/src/net/oni2/aeinstaller/gui/MainWin.java
(Generate patch)

Comparing AE/installer2/src/net/oni2/aeinstaller/gui/MainWin.java (file contents):
Revision 647 by alloc, Thu Jan 24 02:18:40 2013 UTC vs.
Revision 648 by alloc, Fri Jan 25 12:15:31 2013 UTC

# Line 43 | Line 43 | import net.oni2.aeinstaller.backend.Sett
43   import net.oni2.aeinstaller.backend.Settings.Platform;
44   import net.oni2.aeinstaller.backend.SizeFormatter;
45   import net.oni2.aeinstaller.backend.depot.DepotManager;
46 < import net.oni2.aeinstaller.backend.mods.Mod;
47 < import net.oni2.aeinstaller.backend.mods.ModManager;
48 < import net.oni2.aeinstaller.backend.mods.Type;
49 < import net.oni2.aeinstaller.backend.mods.download.ModDownloader;
50 < import net.oni2.aeinstaller.backend.mods.download.ModDownloader.State;
51 < import net.oni2.aeinstaller.backend.mods.download.ModDownloaderListener;
46 > import net.oni2.aeinstaller.backend.packages.Package;
47 > import net.oni2.aeinstaller.backend.packages.PackageManager;
48 > import net.oni2.aeinstaller.backend.packages.Type;
49   import net.oni2.aeinstaller.backend.oni.InstallProgressListener;
50   import net.oni2.aeinstaller.backend.oni.Installer;
51   import net.oni2.aeinstaller.backend.oni.OniSplit;
52 + import net.oni2.aeinstaller.backend.packages.download.ModDownloader;
53 + import net.oni2.aeinstaller.backend.packages.download.ModDownloaderListener;
54 + import net.oni2.aeinstaller.backend.packages.download.ModDownloader.State;
55   import net.oni2.aeinstaller.gui.about.AboutDialog;
56 + import net.oni2.aeinstaller.gui.corepackages.CorePackagesDialog;
57   import net.oni2.aeinstaller.gui.downloadwindow.Downloader;
57 import net.oni2.aeinstaller.gui.mandatorypackages.MandatoryPackagesDialog;
58   import net.oni2.aeinstaller.gui.modtable.DownloadSizeListener;
59   import net.oni2.aeinstaller.gui.modtable.ModSelectionListener;
60   import net.oni2.aeinstaller.gui.modtable.ModTable;
# Line 104 | Line 104 | public class MainWin extends JFrame impl
104  
105          private JButton btnInstall;
106  
107 <        private TreeSet<Mod> execMandatoryUpdates = new TreeSet<Mod>();
108 <        private TreeSet<Mod> execUpdates = null;
107 >        private TreeSet<Package> execCoreUpdates = new TreeSet<Package>();
108 >        private TreeSet<Package> execUpdates = null;
109  
110          private enum EInstallState {
111                  DONE,
# Line 117 | Line 117 | public class MainWin extends JFrame impl
117          };
118  
119          private EInstallState installState = EInstallState.DONE;
120 <        private TreeSet<Mod> installMods = null;
121 <        private TreeSet<Mod> installDeps = null;
120 >        private TreeSet<Package> installMods = null;
121 >        private TreeSet<Package> installDeps = null;
122  
123          /**
124           * Constructor of main window.
# Line 152 | Line 152 | public class MainWin extends JFrame impl
152                  cmbModTypes.removeAllItems();
153  
154                  TreeMap<String, Type> types = new TreeMap<String, Type>();
155 <                for (Type t : ModManager.getInstance().getTypesWithContent()) {
155 >                for (Type t : PackageManager.getInstance().getTypesWithContent()) {
156                          types.put(t.getName(), t);
157                  }
158                  cmbModTypes.addItem("-All-");
# Line 186 | Line 186 | public class MainWin extends JFrame impl
186                                          + " msec");
187                  }
188  
189 <                ModManager.getInstance().init();
189 >                PackageManager.getInstance().init();
190                  tblMods.reloadData();
191                  initModTypeBox();
192  
# Line 205 | Line 205 | public class MainWin extends JFrame impl
205                                                          JOptionPane.WARNING_MESSAGE);
206                                  }
207                          } else {
208 <                                TreeSet<Mod> mods = ModManager.getInstance().getUpdatableMods();
209 <                                TreeSet<Mod> tools = ModManager.getInstance()
208 >                                TreeSet<Package> mods = PackageManager.getInstance().getUpdatableMods();
209 >                                TreeSet<Package> tools = PackageManager.getInstance()
210                                                  .getUpdatableTools();
211                                  int size = 0;
212                                  JPanel panPackages = new JPanel(new GridLayout(0, 1));
213 <                                execUpdates = new TreeSet<Mod>();
213 >                                execUpdates = new TreeSet<Package>();
214                                  execUpdates.addAll(mods);
215                                  execUpdates.addAll(tools);
216 <                                for (final Mod m : mods) {
216 >                                for (final Package m : mods) {
217                                          size += m.getZipSize();
218                                          JCheckBox check = new JCheckBox("Mod: " + m.getName());
219                                          check.setSelected(true);
# Line 228 | Line 228 | public class MainWin extends JFrame impl
228                                          });
229                                          panPackages.add(check);
230                                  }
231 <                                for (final Mod m : tools) {
231 >                                for (final Package m : tools) {
232                                          size += m.getZipSize();
233                                          JCheckBox check = new JCheckBox("Tool: " + m.getName());
234                                          check.setSelected(true);
# Line 284 | Line 284 | public class MainWin extends JFrame impl
284                                  dl.setVisible(true);
285                                  if (dl.isFinished()) {
286                                          TreeSet<Integer> installed = Installer.getInstalledTools();
287 <                                        TreeSet<Mod> tools = new TreeSet<Mod>();
288 <                                        for (Mod m : execUpdates)
287 >                                        TreeSet<Package> tools = new TreeSet<Package>();
288 >                                        for (Package m : execUpdates)
289                                                  if (m.isTool()
290                                                                  && installed.contains(m.getPackageNumber()))
291                                                          tools.add(m);
# Line 314 | Line 314 | public class MainWin extends JFrame impl
314          }
315  
316          @SuppressWarnings("unused")
317 <        private void showMandatoryPackagesDialog() {
318 <                new MandatoryPackagesDialog().setVisible(true);
317 >        private void showCorePackagesDialog() {
318 >                new CorePackagesDialog().setVisible(true);
319          }
320  
321          private void showSettings() {
# Line 368 | Line 368 | public class MainWin extends JFrame impl
368                          File f = fc.getSelectedFile();
369                          if (!f.getName().endsWith(".xml"))
370                                  f = new File(f.getParentFile(), f.getName() + ".xml");
371 <                        ModManager.getInstance().saveModSelection(f,
371 >                        PackageManager.getInstance().saveModSelection(f,
372                                          tblMods.getSelectedMods());
373                  }
374          }
# Line 396 | Line 396 | public class MainWin extends JFrame impl
396                          toolsMenu.remove(i);
397                  }
398                  toolsMenuItems.clear();
399 <                for (Mod m : ModManager.getInstance().getInstalledTools()) {
399 >                for (Package m : PackageManager.getInstance().getInstalledTools()) {
400                          File exe = m.getExeFile();
401                          if (exe != null && exe.exists()) {
402                                  JMenuItem item = new JMenuItem();
# Line 440 | Line 440 | public class MainWin extends JFrame impl
440                  tblMods.revertSelection();
441          }
442  
443 <        @DoInBackground(progressMessage = "mandatoryFiles.title", cancelable = false, indeterminateProgress = false)
444 <        private void checkMandatoryFiles(final BackgroundEvent evt) {
443 >        @DoInBackground(progressMessage = "checkCorePackages.title", cancelable = false, indeterminateProgress = false)
444 >        private void checkCorePackages(final BackgroundEvent evt) {
445                  if (!Settings.getInstance().isOfflineMode()) {
446 <                        for (Mod m : ModManager.getInstance().getMandatoryTools()) {
446 >                        for (Package m : PackageManager.getInstance().getCoreTools()) {
447                                  if (m.isNewerAvailable()) {
448 <                                        execMandatoryUpdates.add(m);
448 >                                        execCoreUpdates.add(m);
449                                  }
450                          }
451 <                        for (Mod m : ModManager.getInstance().getMandatoryMods()) {
451 >                        for (Package m : PackageManager.getInstance().getCoreMods()) {
452                                  if (m.isNewerAvailable()) {
453 <                                        execMandatoryUpdates.add(m);
453 >                                        execCoreUpdates.add(m);
454                                  }
455                          }
456 <                        if (execMandatoryUpdates.size() > 0) {
457 <                                ModDownloader m = new ModDownloader(execMandatoryUpdates,
456 >                        if (execCoreUpdates.size() > 0) {
457 >                                ModDownloader m = new ModDownloader(execCoreUpdates,
458                                                  new ModDownloaderListener() {
459                                                          @Override
460                                                          public void updateStatus(ModDownloader source,
461 <                                                                        Mod currentDownload, State state,
461 >                                                                        Package currentDownload, State state,
462                                                                          int filesDown, int filesTotal,
463                                                                          int bytesDown, int bytesTotal,
464                                                                          int duration, int remaining, int speed) {
# Line 475 | Line 475 | public class MainWin extends JFrame impl
475                                  }
476                          }
477                          evt.setProgressMessage(bundle
478 <                                        .getString("mandatoryToolsInstall.title"));
478 >                                        .getString("coreToolsInstall.title"));
479                          Installer
480 <                                        .installTools(ModManager.getInstance().getMandatoryTools());
480 >                                        .installTools(PackageManager.getInstance().getCoreTools());
481                  }
482          }
483  
484          @SuppressWarnings("unused")
485 <        private void infoMandatoryFiles() {
486 <                if (execMandatoryUpdates.size() > 0) {
485 >        private void infoCorePackages() {
486 >                if (execCoreUpdates.size() > 0) {
487                          String packages = "";
488 <                        for (Mod m : execMandatoryUpdates) {
488 >                        for (Package m : execCoreUpdates) {
489                                  packages += String.format("\n - %s (%s)", m.getName(),
490                                                  m.getVersion());
491                          }
492                          JOptionPane.showMessageDialog(this, String.format(
493 <                                        bundle.getString("mandatoryFilesUpdated.text"), packages),
494 <                                        bundle.getString("mandatoryFilesUpdated.title"),
493 >                                        bundle.getString("corePackagesUpdated.text"), packages),
494 >                                        bundle.getString("corePackagesUpdated.title"),
495                                          JOptionPane.INFORMATION_MESSAGE);
496                  }
497          }
498  
499          @SuppressWarnings("unused")
500          private void install() {
501 <                TreeSet<Mod> mods = new TreeSet<Mod>();
502 <                mods.addAll(ModManager.getInstance().getMandatoryMods());
501 >                TreeSet<Package> mods = new TreeSet<Package>();
502 >                mods.addAll(PackageManager.getInstance().getCoreMods());
503                  mods.addAll(tblMods.getSelectedMods());
504  
505 <                installDeps = new TreeSet<Mod>();
505 >                installDeps = new TreeSet<Package>();
506  
507                  installState = EInstallState.CHECKING;
508  
509                  while (installState == EInstallState.CHECKING) {
510 <                        TreeSet<Mod> toDownload = new TreeSet<Mod>();
511 <                        for (Mod m : mods) {
510 >                        TreeSet<Package> toDownload = new TreeSet<Package>();
511 >                        for (Package m : mods) {
512                                  if (!m.isLocalAvailable())
513                                          toDownload.add(m);
514                          }
# Line 528 | Line 528 | public class MainWin extends JFrame impl
528                                          dl.dispose();
529                                  }
530                          }
531 <                        HashMap<Mod, HashSet<Mod>> dependencies = ModManager.getInstance()
531 >                        HashMap<Package, HashSet<Package>> dependencies = PackageManager.getInstance()
532                                          .checkDependencies(mods);
533                          if (dependencies.size() > 0) {
534 <                                for (HashSet<Mod> hm : dependencies.values()) {
534 >                                for (HashSet<Package> hm : dependencies.values()) {
535                                          installDeps.addAll(hm);
536                                        for (Mod mDep : hm) {
537                                                if (!mods.contains(mDep))
538                                                        mods.add(mDep);
539                                        }
536                                  }
537  
538                                  if (!Settings.getInstance()
# Line 544 | Line 540 | public class MainWin extends JFrame impl
540                                          int size = 0;
541                                          String depsLocalString = "";
542                                          String depsDownloadString = "";
543 <                                        for (Mod m : dependencies.keySet()) {
544 <                                                for (Mod mDep : dependencies.get(m)) {
543 >                                        for (Package m : dependencies.keySet()) {
544 >                                                for (Package mDep : dependencies.get(m)) {
545                                                          if (!mods.contains(mDep)) {
546                                                                  mods.add(mDep);
547                                                                  if (!mDep.isLocalAvailable()) {
# Line 583 | Line 579 | public class MainWin extends JFrame impl
579                                          }
580                                  }
581                          } else {
582 <                                HashMap<Mod, HashSet<Mod>> incompatibilities = ModManager
582 >                                HashMap<Package, HashSet<Package>> incompatibilities = PackageManager
583                                                  .getInstance().checkIncompabitilites(mods);
584                                  if (incompatibilities.size() > 0) {
585                                          installState = EInstallState.INCOMPATIBLE;
586  
587                                          String incompatString = "";
588 <                                        for (Mod m : incompatibilities.keySet()) {
588 >                                        for (Package m : incompatibilities.keySet()) {
589                                                  if (incompatString.length() > 0)
590                                                          incompatString += "\n";
591                                                  incompatString += m.getName() + ": ";
592                                                  String confMods = "";
593 <                                                for (Mod mConf : incompatibilities.get(m)) {
593 >                                                for (Package mConf : incompatibilities.get(m)) {
594                                                          if (confMods.length() > 0)
595                                                                  confMods += ", ";
596                                                          confMods += mConf.getName();
# Line 615 | Line 611 | public class MainWin extends JFrame impl
611                  }
612  
613                  if (installState == EInstallState.READY) {
614 <                        installMods = new TreeSet<Mod>();
615 <                        TreeSet<Mod> actuallyTools = new TreeSet<Mod>();
614 >                        installMods = new TreeSet<Package>();
615 >                        TreeSet<Package> actuallyTools = new TreeSet<Package>();
616  
617 <                        for (Mod m : mods) {
617 >                        for (Package m : mods) {
618                                  if (m.isTool())
619                                          actuallyTools.add(m);
620                                  else
# Line 651 | Line 647 | public class MainWin extends JFrame impl
647  
648          @SuppressWarnings("unused")
649          private void installDone() {
650 <                ModManager.getInstance().updateInstalledMods();
650 >                PackageManager.getInstance().updateInstalledMods();
651                  switch (installState) {
652                          case DONE:
653                                  revertSelection();
# Line 659 | Line 655 | public class MainWin extends JFrame impl
655                                                  && Settings.getInstance().get("notifyDepsAfterInstall",
656                                                                  false)) {
657                                          String installedDeps = "";
658 <                                        for (Mod m : installDeps) {
658 >                                        for (Package m : installDeps) {
659                                                  if (installedDeps.length() > 0)
660                                                          installedDeps += "\n";
661                                                  installedDeps += " - " + m.getName();
# Line 689 | Line 685 | public class MainWin extends JFrame impl
685          }
686  
687          @Override
688 <        public void modSelectionChanged(ModTable source, Mod m) {
688 >        public void modSelectionChanged(ModTable source, Package m) {
689                  lblTitleVal.setText("");
690                  lblCreatorVal.setText("");
691                  lblDescriptionVal.setText("");

Diff Legend

Removed lines
+ Added lines
< Changed lines (old)
> Changed lines (new)