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 708 by alloc, Thu Mar 21 09:39:55 2013 UTC vs.
Revision 720 by alloc, Thu Mar 21 11:33:53 2013 UTC

# Line 9 | Line 9 | import java.awt.event.ItemListener;
9   import java.awt.event.KeyAdapter;
10   import java.awt.event.KeyEvent;
11   import java.io.File;
12 + import java.io.FileNotFoundException;
13   import java.net.URL;
14   import java.util.Date;
15   import java.util.HashMap;
# Line 38 | Line 39 | import javax.swing.SwingUtilities;
39   import javax.swing.ToolTipManager;
40   import javax.swing.filechooser.FileFilter;
41  
42 + import net.oni2.SettingsManager;
43   import net.oni2.aeinstaller.AEInstaller2;
44   import net.oni2.aeinstaller.backend.ImageResizer;
45   import net.oni2.aeinstaller.backend.Paths;
44 import net.oni2.aeinstaller.backend.ToolLauncher;
46   import net.oni2.aeinstaller.backend.SizeFormatter;
47   import net.oni2.aeinstaller.backend.depot.DepotManager;
48   import net.oni2.aeinstaller.backend.oni.InstallProgressListener;
49   import net.oni2.aeinstaller.backend.oni.Installer;
50 + import net.oni2.aeinstaller.backend.oni.OniLauncher;
51   import net.oni2.aeinstaller.backend.oni.OniSplit;
52   import net.oni2.aeinstaller.backend.packages.Package;
53   import net.oni2.aeinstaller.backend.packages.PackageManager;
# Line 56 | Line 58 | import net.oni2.aeinstaller.backend.pack
58   import net.oni2.aeinstaller.gui.about.AboutDialog;
59   import net.oni2.aeinstaller.gui.corepackages.CorePackagesDialog;
60   import net.oni2.aeinstaller.gui.downloadwindow.Downloader;
59 import net.oni2.aeinstaller.gui.modtable.ModInstallSelectionListener;
61   import net.oni2.aeinstaller.gui.modtable.EApplyFilterTo;
62 + import net.oni2.aeinstaller.gui.modtable.ModInstallSelectionListener;
63   import net.oni2.aeinstaller.gui.modtable.ModSelectionListener;
64   import net.oni2.aeinstaller.gui.modtable.ModTable;
65   import net.oni2.aeinstaller.gui.modtable.ModTable.ETableContentType;
66   import net.oni2.aeinstaller.gui.packageinfobox.PackageInfoBox;
67   import net.oni2.aeinstaller.gui.settings.SettingsDialog;
68   import net.oni2.aeinstaller.gui.toolmanager.ToolManager;
69 < import net.oni2.applicationinvoker.AppExecution;
70 < import net.oni2.settingsmanager.Settings;
71 < import net.oni2.settingsmanager.Settings.Platform;
69 > import net.oni2.platformtools.PlatformInformation;
70 > import net.oni2.platformtools.PlatformInformation.Platform;
71 > import net.oni2.platformtools.applicationinvoker.ApplicationInvoker;
72 > import net.oni2.platformtools.applicationinvoker.ERuntimeNotInstalledException;
73  
74   import org.javabuilders.BuildResult;
75   import org.javabuilders.annotations.DoInBackground;
# Line 137 | Line 140 | public class MainWin extends JFrame impl
140                  tblMods.setVisible(false);
141                  scrollMods.setViewportView(tblMods);
142  
143 <                contents.setDividerLocation(Settings.getInstance().get("win_main_divloc", 550));
143 >                contents.setDividerLocation(SettingsManager.getInstance().get(
144 >                                "win_main_divloc", 550));
145                  contents.setResizeWeight(0.4);
146  
147 <                if (Settings.getPlatform() == Platform.MACOS) {
147 >                if (PlatformInformation.getPlatform() == Platform.MACOS) {
148                          mainMenu.setVisible(false);
149                  }
150  
# Line 164 | Line 168 | public class MainWin extends JFrame impl
168  
169                  tblMods.addModSelectionListener(this);
170                  tblMods.addDownloadSizeListener(this);
171 <                
172 <                setSize(Settings.getInstance().get("win_main_width", 950), Settings.getInstance().get("win_main_height", 600));
171 >
172 >                setSize(SettingsManager.getInstance().get("win_main_width", 950),
173 >                                SettingsManager.getInstance().get("win_main_height", 600));
174                  setLocationRelativeTo(null);
175          }
176  
# Line 189 | Line 194 | public class MainWin extends JFrame impl
194          }
195  
196          private void saveLocalData() {
197 <                Settings.getInstance().put("win_main_divloc", contents.getDividerLocation());
198 <                Settings.getInstance().put("win_main_width", getWidth());
199 <                Settings.getInstance().put("win_main_height", getHeight());
200 <                Settings.getInstance().serializeToFile(Paths.getSettingsFilename());
197 >                SettingsManager.getInstance().put("win_main_divloc",
198 >                                contents.getDividerLocation());
199 >                SettingsManager.getInstance().put("win_main_width", getWidth());
200 >                SettingsManager.getInstance().put("win_main_height", getHeight());
201 >                SettingsManager.getInstance().serializeToFile(
202 >                                Paths.getSettingsFilename());
203          }
204  
205          @DoInBackground(progressMessage = "updateDepot.title", cancelable = false, indeterminateProgress = false)
206          private void execDepotUpdate(final BackgroundEvent evt) {
207 <                if (!Settings.getInstance().isOfflineMode()
208 <                                && !Settings.getInstance().isNoCacheUpdateMode()) {
207 >                if (!SettingsManager.getInstance().isOfflineMode()
208 >                                && !SettingsManager.getInstance().isNoCacheUpdateMode()) {
209                          long start = new Date().getTime();
210  
211                          try {
# Line 221 | Line 228 | public class MainWin extends JFrame impl
228          @SuppressWarnings("unused")
229          private void checkUpdates(Object evtSource) {
230                  if ((evtSource != this)
231 <                                || Settings.getInstance().get("notifyupdates", true)) {
232 <                        if (Settings.getInstance().isOfflineMode()) {
231 >                                || SettingsManager.getInstance().get("notifyupdates", true)) {
232 >                        if (SettingsManager.getInstance().isOfflineMode()) {
233                                  if (evtSource != this) {
234                                          JOptionPane.showMessageDialog(
235                                                          this,
# Line 249 | Line 256 | public class MainWin extends JFrame impl
256                                  for (final Package m : mods) {
257                                          size += m.getZipSize();
258                                          JCheckBox check = new JCheckBox("Mod: " + m.getName()
259 <                                                        + " (" + SizeFormatter.format(m.getZipSize(), 1) + ")");
259 >                                                        + " (" + SizeFormatter.format(m.getZipSize(), 1)
260 >                                                        + ")");
261                                          check.setSelected(true);
262                                          check.addItemListener(new ItemListener() {
263                                                  @Override
# Line 273 | Line 281 | public class MainWin extends JFrame impl
281                                  for (final Package m : tools) {
282                                          size += m.getZipSize();
283                                          JCheckBox check = new JCheckBox("Tool: " + m.getName()
284 <                                                        + " (" + SizeFormatter.format(m.getZipSize(), 1) + ")");
284 >                                                        + " (" + SizeFormatter.format(m.getZipSize(), 1)
285 >                                                        + ")");
286                                          check.setSelected(true);
287                                          check.addItemListener(new ItemListener() {
288                                                  @Override
# Line 312 | Line 321 | public class MainWin extends JFrame impl
321                                          pan.add(packages, BorderLayout.CENTER);
322                                          JCheckBox checkFutureUpdates = new JCheckBox(
323                                                          bundle.getString("checkOnStartup.text"));
324 <                                        checkFutureUpdates.setSelected(Settings.getInstance().get(
325 <                                                        "notifyupdates", true));
324 >                                        checkFutureUpdates.setSelected(SettingsManager
325 >                                                        .getInstance().get("notifyupdates", true));
326                                          checkFutureUpdates.addItemListener(new ItemListener() {
327                                                  @Override
328                                                  public void itemStateChanged(ItemEvent evt) {
329 <                                                        Settings.getInstance().put("notifyupdates",
329 >                                                        SettingsManager.getInstance().put("notifyupdates",
330                                                                          evt.getStateChange() == ItemEvent.SELECTED);
331                                                  }
332                                          });
# Line 491 | Line 500 | public class MainWin extends JFrame impl
500                                          @Override
501                                          public void actionPerformed(ActionEvent evt) {
502                                                  try {
503 <                                                        ToolLauncher.launch(m);
504 <                                                } catch (Exception ex) {
505 <                                                        if (ex.getMessage().contains("JRE"))
503 >                                                        ApplicationInvoker.execute(m.getExeType(),
504 >                                                                        m.getWorkingDir(), m.getExeFile(), null);
505 >                                                } catch (ERuntimeNotInstalledException e) {
506 >                                                        JOptionPane.showMessageDialog(null,
507 >                                                                        bundle.getString("exeNotFound.text"),
508 >                                                                        bundle.getString("exeNotFound.title"),
509 >                                                                        JOptionPane.ERROR_MESSAGE);
510 >                                                        e.printStackTrace();
511 >                                                } catch (FileNotFoundException e) {
512 >                                                        if (e.getMessage().contains("JRE"))
513                                                                  JOptionPane.showMessageDialog(null,
514                                                                                  bundle.getString("jreNotFound.text"),
515                                                                                  bundle.getString("jreNotFound.title"),
516                                                                                  JOptionPane.ERROR_MESSAGE);
517 <                                                        if (ex.getMessage().contains(".NET"))
517 >                                                        if (e.getMessage().contains(".NET"))
518                                                                  JOptionPane.showMessageDialog(
519                                                                                  null,
520                                                                                  bundle.getString("dotNetNotFound.text"),
521                                                                                  bundle.getString("dotNetNotFound.title"),
522                                                                                  JOptionPane.ERROR_MESSAGE);
523 +                                                        if (e.getMessage().contains("Wine"))
524 +                                                                JOptionPane.showMessageDialog(null,
525 +                                                                                bundle.getString("wineNotFound.text"),
526 +                                                                                bundle.getString("wineNotFound.title"),
527 +                                                                                JOptionPane.ERROR_MESSAGE);
528 +                                                        e.printStackTrace();
529                                                  }
530                                          }
531                                  });
# Line 524 | Line 546 | public class MainWin extends JFrame impl
546  
547          @DoInBackground(progressMessage = "checkCorePackages.title", cancelable = false, indeterminateProgress = false)
548          private void checkCorePackages(final BackgroundEvent evt) {
549 <                if (!Settings.getInstance().isOfflineMode()) {
549 >                if (!SettingsManager.getInstance().isOfflineMode()) {
550                          for (Package m : PackageManager.getInstance().getCoreTools()) {
551                                  if (m.isNewerAvailable()) {
552                                          execCoreUpdates.add(m);
# Line 557 | Line 579 | public class MainWin extends JFrame impl
579                                  }
580                          }
581                          evt.setProgressMessage(bundle.getString("coreToolsInstall.title"));
582 <                        Installer.installTools(PackageManager.getInstance().getCoreTools(), false);
582 >                        Installer.installTools(PackageManager.getInstance().getCoreTools(),
583 >                                        false);
584                  }
585          }
586  
# Line 593 | Line 616 | public class MainWin extends JFrame impl
616                                          toDownload.add(m);
617                          }
618  
619 <                        if (toDownload.size() > 0 && Settings.getInstance().isOfflineMode()) {
619 >                        if (toDownload.size() > 0
620 >                                        && SettingsManager.getInstance().isOfflineMode()) {
621                                  installState = EInstallState.OFFLINE;
622                                  break;
623                          }
# Line 646 | Line 670 | public class MainWin extends JFrame impl
670                                          depsDownloadString = bundle
671                                                          .getString("installDependencies.none");
672  
673 <                                if (!Settings.getInstance()
674 <                                                .get("notifyDepsAfterInstall", false)) {
673 >                                if (!SettingsManager.getInstance().get(
674 >                                                "notifyDepsAfterInstall", false)) {
675                                          int res = JOptionPane.showConfirmDialog(this, String
676                                                          .format(bundle
677                                                                          .getString("installDependencies.text"),
# Line 735 | Line 759 | public class MainWin extends JFrame impl
759                          case DONE:
760                                  revertSelection();
761                                  if (installDeps.size() > 0
762 <                                                && Settings.getInstance().get("notifyDepsAfterInstall",
763 <                                                                false)) {
762 >                                                && SettingsManager.getInstance().get(
763 >                                                                "notifyDepsAfterInstall", false)) {
764                                          String installedDeps = "";
765                                          for (Package m : installDeps) {
766                                                  if (installedDeps.length() > 0)
# Line 834 | Line 858 | public class MainWin extends JFrame impl
858                  }
859          }
860  
861 <        private Vector<String> getBasicOniLaunchParams() {
862 <                Vector<String> params = new Vector<String>();
863 <                File exe = null;
864 <                switch (Settings.getPlatform()) {
865 <                        case WIN:
866 <                                exe = new File(Paths.getEditionBasePath(), "Oni.exe");
867 <                                if (exe.exists())
868 <                                        params.add(exe.getPath());
869 <                                break;
870 <                        case MACOS:
871 <                                exe = new File(Paths.getEditionBasePath(),
872 <                                                "Oni.app/Contents/MacOS/Oni");
873 <                                if (exe.exists())
874 <                                        params.add(exe.getPath());
875 <                                break;
852 <                        case LINUX:
853 <                                String wine = Settings.getWinePath();
854 <                                exe = new File(Paths.getEditionBasePath(), "Oni.exe");
855 <                                if (exe.exists()) {
856 <                                        if (wine != null) {
857 <                                                params.add(wine);
858 <                                                params.add(exe.getPath());
859 <                                        }
860 <                                }
861 <                                break;
862 <                        default:
861 >        private void oni(boolean windowed) {
862 >                try {
863 >                        OniLauncher.launch(windowed);
864 >                } catch (FileNotFoundException e) {
865 >                        JOptionPane.showMessageDialog(this,
866 >                                        bundle.getString("oniExeNotFound.text"),
867 >                                        bundle.getString("oniExeNotFound.title"),
868 >                                        JOptionPane.ERROR_MESSAGE);
869 >                        e.printStackTrace();
870 >                } catch (ERuntimeNotInstalledException e) {
871 >                        JOptionPane.showMessageDialog(this,
872 >                                        bundle.getString("wineNotFound.text"),
873 >                                        bundle.getString("wineNotFound.title"),
874 >                                        JOptionPane.ERROR_MESSAGE);
875 >                        e.printStackTrace();
876                  }
864                if (params.size() > 0) {
865                        params.add("-debugfiles");
866                }
867                return params;
877          }
878  
879          @SuppressWarnings("unused")
880          private void oniFull() {
881 <                Vector<String> params = getBasicOniLaunchParams();
873 <                if (params.size() > 0) {
874 <                        AppExecution.execute(params, Paths.getEditionBasePath());
875 <                }
881 >                oni(false);
882          }
883  
884          @SuppressWarnings("unused")
885          private void oniWin() {
886 <                Vector<String> params = getBasicOniLaunchParams();
881 <                if (params.size() > 0) {
882 <                        params.add("-noswitch");
883 <                        AppExecution.execute(params, Paths.getEditionBasePath());
884 <                }
886 >                oni(true);
887          }
888  
889          @SuppressWarnings("unused")

Diff Legend

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