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 622 by alloc, Wed Jan 16 07:35:08 2013 UTC vs.
Revision 623 by alloc, Wed Jan 16 10:25:00 2013 UTC

# Line 7 | Line 7 | import java.awt.event.MouseAdapter;
7   import java.awt.event.MouseEvent;
8   import java.io.File;
9   import java.io.IOException;
10 + import java.net.URL;
11   import java.util.ArrayList;
12   import java.util.HashMap;
13   import java.util.HashSet;
# Line 16 | Line 17 | import java.util.TreeMap;
17   import java.util.TreeSet;
18   import java.util.Vector;
19  
20 + import javax.swing.AbstractAction;
21 + import javax.swing.Icon;
22 + import javax.swing.ImageIcon;
23   import javax.swing.JButton;
24   import javax.swing.JComboBox;
25   import javax.swing.JComponent;
# Line 37 | Line 41 | import javax.swing.event.ListSelectionLi
41   import javax.swing.filechooser.FileFilter;
42   import javax.swing.table.TableRowSorter;
43  
44 + import net.oni2.aeinstaller.AEInstaller2;
45 + import net.oni2.aeinstaller.backend.AppExecution;
46   import net.oni2.aeinstaller.backend.Paths;
47   import net.oni2.aeinstaller.backend.Settings;
48   import net.oni2.aeinstaller.backend.Settings.Platform;
# Line 79 | Line 85 | public class MainWin extends JFrame impl
85          private BuildResult result = SwingJavaBuilder.build(this, bundle);
86  
87          private JMenu mainMenu;
88 +        private JMenu toolsMenu;
89 +        private TreeSet<JMenuItem> toolsMenuItems = new TreeSet<JMenuItem>();
90  
91          private JSplitPane contents;
92  
# Line 411 | Line 419 | public class MainWin extends JFrame impl
419          }
420  
421          @SuppressWarnings("unused")
422 +        private void refreshToolsMenu() {
423 +                for (JMenuItem i : toolsMenuItems) {
424 +                        toolsMenu.remove(i);
425 +                }
426 +                toolsMenuItems.clear();
427 +                for (Mod m : ModManager.getInstance().getInstalledTools()) {
428 +                        if (m.getExeFile() != null && m.getExeFile().exists()) {
429 +                                JMenuItem item = new JMenuItem();
430 +                                final Vector<String> params = new Vector<String>();
431 +                                params.add(m.getExeFile().getPath());
432 +                                final File wd = m.getWorkingDir();
433 +                                Icon ico = null;
434 +                                if (m.getIconFile() != null && m.getIconFile().exists()) {
435 +                                        ico = new ImageIcon(m.getIconFile().getPath());
436 +                                } else {
437 +                                        URL icon = AEInstaller2.class.getResource("images/transparent.png");
438 +                                        ico = new ImageIcon(icon);
439 +                                }
440 +                                item.setAction(new AbstractAction(m.getName(), ico) {
441 +                                        private static final long serialVersionUID = 1L;
442 +
443 +                                        @Override
444 +                                        public void actionPerformed(ActionEvent e) {
445 +                                                AppExecution.execute(params, wd);
446 +                                        }
447 +                                });
448 +                                toolsMenuItems.add(item);
449 +                                toolsMenu.add(item);
450 +                        }
451 +                }
452 +        }
453 +
454 +        @SuppressWarnings("unused")
455          private void revertSelection() {
456                  model.revertSelection();
457          }
# Line 509 | Line 550 | public class MainWin extends JFrame impl
550                  }
551  
552                  if (instReady) {
553 <                        Installer.install(mods, new InstallProgressListener() {
553 >                        TreeSet<Mod> actuallyMods = new TreeSet<Mod>();
554 >                        TreeSet<Mod> actuallyTools = new TreeSet<Mod>();
555 >
556 >                        for (Mod m : mods) {
557 >                                if (m.isTool())
558 >                                        actuallyTools.add(m);
559 >                                else
560 >                                        actuallyMods.add(m);
561 >                        }
562 >
563 >                        if (actuallyTools.size() > 0) {
564 >                                Installer.installTools(actuallyTools);
565 >                        }
566 >
567 >                        Installer.install(actuallyMods, new InstallProgressListener() {
568                                  @Override
569                                  public void installProgressUpdate(int done, int total,
570                                                  String step) {
# Line 656 | Line 711 | public class MainWin extends JFrame impl
711          private void oniFull() {
712                  Vector<String> params = getBasicOniLaunchParams();
713                  if (params.size() > 0) {
714 <                        try {
660 <                                ProcessBuilder pb = new ProcessBuilder(params);
661 <                                pb.directory(Paths.getEditionBasePath());
662 <                                pb.start();
663 <                        } catch (IOException e) {
664 <                                e.printStackTrace();
665 <                        }
714 >                        AppExecution.execute(params, Paths.getEditionBasePath());
715                  }
716          }
717  
# Line 671 | Line 720 | public class MainWin extends JFrame impl
720                  Vector<String> params = getBasicOniLaunchParams();
721                  if (params.size() > 0) {
722                          params.add("-noswitch");
723 <                        try {
675 <                                ProcessBuilder pb = new ProcessBuilder(params);
676 <                                pb.directory(Paths.getEditionBasePath());
677 <                                pb.start();
678 <                        } catch (IOException e) {
679 <                                e.printStackTrace();
680 <                        }
723 >                        AppExecution.execute(params, Paths.getEditionBasePath());
724                  }
725          }
726  

Diff Legend

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