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 606 by alloc, Mon Jan 14 12:34:55 2013 UTC vs.
Revision 608 by alloc, Mon Jan 14 17:49:25 2013 UTC

# Line 1 | Line 1
1   package net.oni2.aeinstaller.gui;
2  
3 + import java.awt.Desktop;
4 + import java.awt.event.ActionEvent;
5 + import java.awt.event.ActionListener;
6 + import java.awt.event.MouseAdapter;
7 + import java.awt.event.MouseEvent;
8   import java.io.File;
9   import java.io.IOException;
10   import java.util.ArrayList;
# Line 18 | Line 23 | import javax.swing.JFileChooser;
23   import javax.swing.JFrame;
24   import javax.swing.JLabel;
25   import javax.swing.JMenu;
26 + import javax.swing.JMenuItem;
27   import javax.swing.JOptionPane;
28 + import javax.swing.JPopupMenu;
29   import javax.swing.JSplitPane;
30   import javax.swing.JTable;
31   import javax.swing.ListSelectionModel;
# Line 123 | Line 130 | public class MainWin extends JFrame impl
130                  tblMods.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
131                  tblMods.getSelectionModel().addListSelectionListener(
132                                  new ListSelectionListener() {
126
133                                          @Override
134                                          public void valueChanged(ListSelectionEvent e) {
135                                                  int viewRow = tblMods.getSelectedRow();
# Line 137 | Line 143 | public class MainWin extends JFrame impl
143                                                  }
144                                          }
145                                  });
146 +                tblMods.addMouseListener(new MouseAdapter() {
147 +                        private void common(MouseEvent e) {
148 +                                int r = tblMods.rowAtPoint(e.getPoint());
149 +                                if (r >= 0 && r < tblMods.getRowCount())
150 +                                        tblMods.setRowSelectionInterval(r, r);
151 +                                else
152 +                                        tblMods.clearSelection();
153 +
154 +                                int rowindex = tblMods.getSelectedRow();
155 +                                if (rowindex >= 0) {
156 +                                        if (e.isPopupTrigger()
157 +                                                        && e.getComponent() instanceof JTable) {
158 +                                                int modelRow = tblMods.convertRowIndexToModel(rowindex);
159 +                                                final Mod mod = (Mod) model.getValueAt(modelRow, -1);
160 +
161 +                                                if (mod.isLocalAvailable()) {
162 +                                                        JPopupMenu popup = new JPopupMenu();
163 +                                                        JMenuItem openModFolder = new JMenuItem(bundle
164 +                                                                        .getString("openModFolder.text"));
165 +                                                        openModFolder
166 +                                                                        .addActionListener(new ActionListener() {
167 +                                                                                @Override
168 +                                                                                public void actionPerformed(
169 +                                                                                                ActionEvent arg0) {
170 +                                                                                        try {
171 +                                                                                                Desktop.getDesktop().open(
172 +                                                                                                                mod.getLocalPath());
173 +                                                                                        } catch (IOException e) {
174 +                                                                                                e.printStackTrace();
175 +                                                                                        }
176 +                                                                                }
177 +                                                                        });
178 +                                                        popup.add(openModFolder);
179 +                                                        popup.show(e.getComponent(), e.getX(), e.getY());
180 +                                                }
181 +                                        }
182 +                                }
183 +                        }
184  
185 +                        @Override
186 +                        public void mousePressed(MouseEvent e) {
187 +                                common(e);
188 +                        }
189 +
190 +                        @Override
191 +                        public void mouseReleased(MouseEvent e) {
192 +                                common(e);
193 +                        }
194 +                });
195                  // To get checkbox-cells with background of row
196                  ((JComponent) tblMods.getDefaultRenderer(Boolean.class))
197                                  .setOpaque(true);
# Line 162 | Line 216 | public class MainWin extends JFrame impl
216          }
217  
218          private void exit() {
165                setVisible(false);
219                  dispose();
220 +                System.exit(0);
221          }
222  
223          private void saveLocalData() {
# Line 198 | Line 252 | public class MainWin extends JFrame impl
252          @SuppressWarnings("unused")
253          private void checkUpdates() {
254                  if (Settings.getInstance().get("notifyupdates", true)) {
255 +                        // TODO
256                  }
257          }
258  
# Line 364 | Line 419 | public class MainWin extends JFrame impl
419                                  }
420                          } else {
421                                  HashMap<Mod, HashSet<Mod>> conflicts = ModManager.getInstance()
422 <                                                .checkConflicts(mods);
422 >                                                .checkIncompabitilites(mods);
423                                  if (conflicts.size() > 0) {
424 <                                        System.err.println("Conflicting mods: "
424 >                                        System.err.println("Incompatible mods: "
425                                                          + conflicts.toString());
426                                          break;
427                                  } else {
# Line 376 | Line 431 | public class MainWin extends JFrame impl
431                  }
432  
433                  if (instReady) {
434 +                        System.out.println("Install mods: " + mods.toString());
435 +
436                          Installer.install(mods, new InstallProgressListener() {
437                                  @Override
438                                  public void installProgressUpdate(int done, int total,
# Line 461 | Line 518 | public class MainWin extends JFrame impl
518                                                  .getPath());
519                                  break;
520                          case MACOS:
521 <                                params.add(new File(Paths.getEditionBasePath(), "Oni")
522 <                                                .getPath());
521 >                                params.add(new File(Paths.getEditionBasePath(),
522 >                                                "Oni.app/Contents/MacOS/Oni").getPath());
523                                  break;
524                          case LINUX:
525                                  String wine = Settings.getWinePath();
# Line 511 | Line 568 | public class MainWin extends JFrame impl
568                  }
569          }
570  
571 +        @SuppressWarnings("unused")
572 +        private void openEditionFolder() {
573 +                try {
574 +                        Desktop.getDesktop().open(Paths.getEditionBasePath());
575 +                } catch (IOException e) {
576 +                        e.printStackTrace();
577 +                }
578 +        }
579 +
580          @Override
581          public void handleAbout(ApplicationEvent event) {
582                  event.setHandled(true);

Diff Legend

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