source: AE/installer2/src/net/oni2/aeinstaller/gui/MainWin.java@ 629

Last change on this file since 629 was 629, checked in by alloc, 12 years ago

AEI2 0.88:

  • Localization files moved to common localization package
File size: 23.0 KB
Line 
1package net.oni2.aeinstaller.gui;
2
3import java.awt.BorderLayout;
4import java.awt.Desktop;
5import java.awt.event.ActionEvent;
6import java.awt.event.ActionListener;
7import java.awt.event.ItemEvent;
8import java.awt.event.ItemListener;
9import java.awt.event.MouseAdapter;
10import java.awt.event.MouseEvent;
11import java.io.File;
12import java.io.IOException;
13import java.net.URL;
14import java.util.ArrayList;
15import java.util.HashMap;
16import java.util.HashSet;
17import java.util.List;
18import java.util.ResourceBundle;
19import java.util.TreeMap;
20import java.util.TreeSet;
21import java.util.Vector;
22
23import javax.swing.AbstractAction;
24import javax.swing.Icon;
25import javax.swing.ImageIcon;
26import javax.swing.JButton;
27import javax.swing.JCheckBox;
28import javax.swing.JComboBox;
29import javax.swing.JComponent;
30import javax.swing.JFileChooser;
31import javax.swing.JFrame;
32import javax.swing.JLabel;
33import javax.swing.JMenu;
34import javax.swing.JMenuItem;
35import javax.swing.JOptionPane;
36import javax.swing.JPanel;
37import javax.swing.JPopupMenu;
38import javax.swing.JSplitPane;
39import javax.swing.JTable;
40import javax.swing.ListSelectionModel;
41import javax.swing.RowSorter;
42import javax.swing.SortOrder;
43import javax.swing.SwingUtilities;
44import javax.swing.event.ListSelectionEvent;
45import javax.swing.event.ListSelectionListener;
46import javax.swing.filechooser.FileFilter;
47import javax.swing.table.TableRowSorter;
48
49import net.oni2.aeinstaller.AEInstaller2;
50import net.oni2.aeinstaller.backend.AppExecution;
51import net.oni2.aeinstaller.backend.Paths;
52import net.oni2.aeinstaller.backend.Settings;
53import net.oni2.aeinstaller.backend.Settings.Platform;
54import net.oni2.aeinstaller.backend.SizeFormatter;
55import net.oni2.aeinstaller.backend.depot.DepotCacheUpdateProgressListener;
56import net.oni2.aeinstaller.backend.depot.DepotManager;
57import net.oni2.aeinstaller.backend.mods.Mod;
58import net.oni2.aeinstaller.backend.mods.ModManager;
59import net.oni2.aeinstaller.backend.mods.Type;
60import net.oni2.aeinstaller.backend.mods.download.ModDownloader;
61import net.oni2.aeinstaller.backend.mods.download.ModDownloader.State;
62import net.oni2.aeinstaller.backend.mods.download.ModDownloaderListener;
63import net.oni2.aeinstaller.backend.oni.InstallProgressListener;
64import net.oni2.aeinstaller.backend.oni.Installer;
65import net.oni2.aeinstaller.backend.oni.OniSplit;
66import net.oni2.aeinstaller.gui.about.AboutDialog;
67import net.oni2.aeinstaller.gui.downloadwindow.Downloader;
68import net.oni2.aeinstaller.gui.modtable.DownloadSizeListener;
69import net.oni2.aeinstaller.gui.modtable.ModTableFilter;
70import net.oni2.aeinstaller.gui.modtable.ModTableModel;
71import net.oni2.aeinstaller.gui.settings.SettingsDialog;
72import net.oni2.aeinstaller.gui.toolmanager.ToolManager;
73
74import org.javabuilders.BuildResult;
75import org.javabuilders.annotations.DoInBackground;
76import org.javabuilders.event.BackgroundEvent;
77import org.javabuilders.swing.SwingJavaBuilder;
78import org.simplericity.macify.eawt.ApplicationEvent;
79import org.simplericity.macify.eawt.ApplicationListener;
80
81/**
82 * @author Christian Illy
83 */
84public class MainWin extends JFrame implements ApplicationListener,
85 DownloadSizeListener {
86 private static final long serialVersionUID = -4027395051382659650L;
87
88 private ResourceBundle bundle = ResourceBundle
89 .getBundle("net.oni2.aeinstaller.localization."
90 + getClass().getSimpleName());
91 @SuppressWarnings("unused")
92 private BuildResult result = SwingJavaBuilder.build(this, bundle);
93
94 private JMenu mainMenu;
95 private JMenu toolsMenu;
96 private TreeSet<JMenuItem> toolsMenuItems = new TreeSet<JMenuItem>();
97
98 private JSplitPane contents;
99
100 private JComboBox cmbModTypes;
101 private JTable tblMods;
102 private ModTableModel model;
103 private TableRowSorter<ModTableModel> sorter;
104 private JLabel lblDownloadSizeVal;
105
106 private JLabel lblSubmitterVal;
107 private JLabel lblCreatorVal;
108 private JLabel lblTypesVal;
109 private JLabel lblPlatformVal;
110 private JLabel lblPackageNumberVal;
111 private HTMLLinkLabel lblDescriptionVal;
112
113 private JButton btnInstall;
114
115 private TreeSet<Mod> execUpdates = null;
116
117 private enum EInstallResult {
118 DONE,
119 OFFLINE,
120 INCOMPATIBLE
121 };
122
123 private EInstallResult installDone = EInstallResult.DONE;
124
125 /**
126 * Constructor of main window.
127 */
128 public MainWin() {
129 this.setTitle(SwingJavaBuilder.getConfig().getResource("appname")
130 + " - v"
131 + SwingJavaBuilder.getConfig().getResource("appversion"));
132
133 contents.setDividerLocation(400);
134
135 if (Settings.getPlatform() == Platform.MACOS) {
136 mainMenu.setVisible(false);
137 }
138
139 getRootPane().setDefaultButton(btnInstall);
140 lblDownloadSizeVal.setText(SizeFormatter.format(0, 2));
141 }
142
143 private void initModTypeBox() {
144 cmbModTypes.removeAllItems();
145
146 TreeMap<String, Type> types = new TreeMap<String, Type>();
147 for (Type t : ModManager.getInstance().getTypesWithContent()) {
148 types.put(t.getName(), t);
149 }
150 for (Type t : types.values()) {
151 cmbModTypes.addItem(t);
152 }
153 cmbModTypes.setSelectedIndex(0);
154 }
155
156 private void initTable() {
157 tblMods.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
158 tblMods.getSelectionModel().addListSelectionListener(
159 new ListSelectionListener() {
160 @Override
161 public void valueChanged(ListSelectionEvent e) {
162 int viewRow = tblMods.getSelectedRow();
163 if (viewRow < 0) {
164 modSelection(null);
165 } else {
166 int modelRow = tblMods
167 .convertRowIndexToModel(viewRow);
168 Mod mod = (Mod) model.getValueAt(modelRow, -1);
169 modSelection(mod);
170 }
171 }
172 });
173 tblMods.addMouseListener(new MouseAdapter() {
174 private void common(MouseEvent e) {
175 int r = tblMods.rowAtPoint(e.getPoint());
176 if (r >= 0 && r < tblMods.getRowCount())
177 tblMods.setRowSelectionInterval(r, r);
178 else
179 tblMods.clearSelection();
180
181 int rowindex = tblMods.getSelectedRow();
182 if (rowindex >= 0) {
183 if (e.isPopupTrigger()
184 && e.getComponent() instanceof JTable) {
185 int modelRow = tblMods.convertRowIndexToModel(rowindex);
186 final Mod mod = (Mod) model.getValueAt(modelRow, -1);
187
188 if (mod.isLocalAvailable()) {
189 JPopupMenu popup = new JPopupMenu();
190 JMenuItem openModFolder = new JMenuItem(bundle
191 .getString("openModFolder.text"));
192 openModFolder
193 .addActionListener(new ActionListener() {
194 @Override
195 public void actionPerformed(
196 ActionEvent arg0) {
197 try {
198 Desktop.getDesktop().open(
199 mod.getLocalPath());
200 } catch (IOException e) {
201 e.printStackTrace();
202 }
203 }
204 });
205 popup.add(openModFolder);
206 popup.show(e.getComponent(), e.getX(), e.getY());
207 }
208 }
209 }
210 }
211
212 @Override
213 public void mousePressed(MouseEvent e) {
214 common(e);
215 }
216
217 @Override
218 public void mouseReleased(MouseEvent e) {
219 common(e);
220 }
221 });
222 // To get checkbox-cells with background of row
223 ((JComponent) tblMods.getDefaultRenderer(Boolean.class))
224 .setOpaque(true);
225
226 model = new ModTableModel();
227 model.addDownloadSizeListener(this);
228
229 tblMods.setModel(model);
230
231 sorter = new TableRowSorter<ModTableModel>(model);
232 tblMods.setRowSorter(sorter);
233
234 sorter.setRowFilter(new ModTableFilter(null));
235
236 List<RowSorter.SortKey> sortKeys = new ArrayList<RowSorter.SortKey>();
237 sortKeys.add(new RowSorter.SortKey(1, SortOrder.ASCENDING));
238 sorter.setSortKeys(sortKeys);
239
240 for (int i = 0; i < model.getColumnCount(); i++) {
241 model.setColumnConstraints(i, tblMods.getColumnModel().getColumn(i));
242 }
243 }
244
245 private void exit() {
246 dispose();
247 System.exit(0);
248 }
249
250 private void saveLocalData() {
251 Settings.getInstance().serializeToFile();
252 DepotManager.getInstance().saveToFile(Settings.getDepotCacheFilename());
253 }
254
255 @DoInBackground(progressMessage = "updateDepot.title", cancelable = false, indeterminateProgress = false)
256 private void execDepotUpdate(final BackgroundEvent evt) {
257 if (!Settings.getInstance().isOfflineMode()) {
258 try {
259 DepotManager.getInstance().updateInformation(false,
260 new DepotCacheUpdateProgressListener() {
261
262 @Override
263 public void cacheUpdateProgress(String stepName,
264 int current, int total) {
265 evt.setProgressEnd(total);
266 evt.setProgressValue(current);
267 evt.setProgressMessage(stepName);
268 }
269 });
270 } catch (Exception e) {
271 e.printStackTrace();
272 }
273 }
274 ModManager.getInstance().init();
275 initTable();
276 initModTypeBox();
277
278 tblMods.setVisible(true);
279 }
280
281 @SuppressWarnings("unused")
282 private void checkUpdates(Object evtSource) {
283 if ((evtSource != this)
284 || Settings.getInstance().get("notifyupdates", true)) {
285 if (Settings.getInstance().isOfflineMode()) {
286 if (evtSource != this) {
287 JOptionPane.showMessageDialog(this,
288 bundle.getString("offlineMode.text"),
289 bundle.getString("offlineMode.title"),
290 JOptionPane.WARNING_MESSAGE);
291 }
292 } else {
293 TreeSet<Mod> mods = ModManager.getInstance().getUpdatableMods();
294 TreeSet<Mod> tools = ModManager.getInstance()
295 .getUpdatableTools();
296 int size = 0;
297 String strMods = "";
298 for (Mod m : mods) {
299 size += m.getZipSize();
300 if (strMods.length() > 0)
301 strMods += "<br>";
302 strMods += " - " + m.getName();
303 }
304 String strTools = "";
305 for (Mod m : tools) {
306 size += m.getZipSize();
307 if (strTools.length() > 0)
308 strTools += "<br>";
309 strTools += " - " + m.getName();
310 }
311 if (size > 0) {
312 // Build info dialog content
313 String message = "<html>";
314 message += String.format(
315 bundle.getString("updatesAvailable.text"), strMods,
316 strTools, SizeFormatter.format(size, 3));
317 message += "</html>";
318
319 JPanel pan = new JPanel();
320 pan.setLayout(new BorderLayout(0, 20));
321 JLabel lab = new JLabel(message);
322 pan.add(lab, BorderLayout.CENTER);
323 JCheckBox checkFutureUpdates = new JCheckBox(
324 bundle.getString("checkOnStartup.text"));
325 checkFutureUpdates.setSelected(Settings.getInstance().get(
326 "notifyupdates", true));
327 checkFutureUpdates.addItemListener(new ItemListener() {
328 @Override
329 public void itemStateChanged(ItemEvent evt) {
330 Settings.getInstance().put("notifyupdates",
331 evt.getStateChange() == ItemEvent.SELECTED);
332 }
333 });
334 pan.add(checkFutureUpdates, BorderLayout.SOUTH);
335
336 // Show dialog
337 int res = JOptionPane.showConfirmDialog(this, pan,
338 bundle.getString("updatesAvailable.title"),
339 JOptionPane.YES_NO_OPTION,
340 JOptionPane.QUESTION_MESSAGE);
341 if (res == JOptionPane.YES_OPTION) {
342 execUpdates = new TreeSet<Mod>();
343 execUpdates.addAll(mods);
344 execUpdates.addAll(tools);
345 }
346 }
347 }
348 }
349 }
350
351 @SuppressWarnings("unused")
352 private void doUpdate() {
353 if (execUpdates != null) {
354 Downloader dl = new Downloader(execUpdates);
355 try {
356 dl.setVisible(true);
357 if (dl.isFinished()) {
358 TreeSet<Integer> installed = Installer.getInstalledTools();
359 TreeSet<Mod> tools = new TreeSet<Mod>();
360 for (Mod m : execUpdates)
361 if (m.isTool()
362 && installed.contains(m.getPackageNumber()))
363 tools.add(m);
364 if (tools.size() > 0) {
365 Installer.installTools(tools);
366 }
367 }
368 } finally {
369 dl.dispose();
370 }
371 }
372 execUpdates = null;
373 }
374
375 @SuppressWarnings("unused")
376 private void focus() {
377 SwingUtilities.invokeLater(new Runnable() {
378
379 @Override
380 public void run() {
381 toFront();
382 repaint();
383 }
384 });
385
386 }
387
388 private void showSettings() {
389 new SettingsDialog().setVisible(true);
390 }
391
392 private void showAbout() {
393 new AboutDialog().setVisible(true);
394 }
395
396 private JFileChooser getConfigOpenSaveDialog(boolean save) {
397 JFileChooser fc = new JFileChooser();
398 fc.setCurrentDirectory(Paths.getEditionBasePath());
399 if (save)
400 fc.setDialogType(JFileChooser.SAVE_DIALOG);
401 else
402 fc.setDialogType(JFileChooser.OPEN_DIALOG);
403 fc.setFileSelectionMode(JFileChooser.FILES_ONLY);
404 fc.setFileFilter(new FileFilter() {
405 @Override
406 public String getDescription() {
407 return "XML files";
408 }
409
410 @Override
411 public boolean accept(File arg0) {
412 return (arg0.isDirectory())
413 || (arg0.getName().toLowerCase().endsWith(".xml"));
414 }
415 });
416 fc.setMultiSelectionEnabled(false);
417 return fc;
418 }
419
420 @SuppressWarnings("unused")
421 private void loadConfig() {
422 JFileChooser fc = getConfigOpenSaveDialog(false);
423 int res = fc.showOpenDialog(this);
424 if (res == JFileChooser.APPROVE_OPTION) {
425 if (fc.getSelectedFile().exists())
426 model.reloadSelection(fc.getSelectedFile());
427 }
428 }
429
430 @SuppressWarnings("unused")
431 private void saveConfig() {
432 JFileChooser fc = getConfigOpenSaveDialog(true);
433 int res = fc.showSaveDialog(this);
434 if (res == JFileChooser.APPROVE_OPTION) {
435 File f = fc.getSelectedFile();
436 if (!f.getName().endsWith(".xml"))
437 f = new File(f.getParentFile(), f.getName() + ".xml");
438 ModManager.getInstance().saveModSelection(f,
439 model.getSelectedMods());
440 }
441 }
442
443 @DoInBackground(progressMessage = "initializingEdition.title", cancelable = false, indeterminateProgress = false)
444 private void reglobalize(final BackgroundEvent evt) {
445 Installer.initializeEdition(new InstallProgressListener() {
446 @Override
447 public void installProgressUpdate(int done, int total, String step) {
448 evt.setProgressEnd(total);
449 evt.setProgressValue(done);
450 evt.setProgressMessage(step);
451 }
452 });
453 }
454
455 @SuppressWarnings("unused")
456 private void tools() {
457 new ToolManager().setVisible(true);
458 }
459
460 @SuppressWarnings("unused")
461 private void refreshToolsMenu() {
462 for (JMenuItem i : toolsMenuItems) {
463 toolsMenu.remove(i);
464 }
465 toolsMenuItems.clear();
466 for (Mod m : ModManager.getInstance().getInstalledTools()) {
467 if (m.getExeFile() != null && m.getExeFile().exists()) {
468 JMenuItem item = new JMenuItem();
469 final Vector<String> params = new Vector<String>();
470 params.add(m.getExeFile().getPath());
471 final File wd = m.getWorkingDir();
472 Icon ico = null;
473 if (m.getIconFile() != null && m.getIconFile().exists()) {
474 ico = new ImageIcon(m.getIconFile().getPath());
475 } else {
476 URL icon = AEInstaller2.class
477 .getResource("images/transparent.png");
478 ico = new ImageIcon(icon);
479 }
480 item.setAction(new AbstractAction(m.getName(), ico) {
481 private static final long serialVersionUID = 1L;
482
483 @Override
484 public void actionPerformed(ActionEvent e) {
485 AppExecution.execute(params, wd);
486 }
487 });
488 toolsMenuItems.add(item);
489 toolsMenu.add(item);
490 }
491 }
492 }
493
494 @SuppressWarnings("unused")
495 private void revertSelection() {
496 model.revertSelection();
497 }
498
499 @DoInBackground(progressMessage = "mandatoryFiles.title", cancelable = false, indeterminateProgress = false)
500 private void checkMandatoryFiles(final BackgroundEvent evt) {
501 if (!Settings.getInstance().isOfflineMode()) {
502 TreeSet<Mod> mand = new TreeSet<Mod>();
503 for (Mod m : ModManager.getInstance().getMandatoryTools()) {
504 if (m.isNewerAvailable()) {
505 mand.add(m);
506 }
507 }
508 for (Mod m : ModManager.getInstance().getMandatoryMods()) {
509 if (m.isNewerAvailable()) {
510 mand.add(m);
511 }
512 }
513 if (mand.size() > 0) {
514 ModDownloader m = new ModDownloader(mand,
515 new ModDownloaderListener() {
516 @Override
517 public void updateStatus(ModDownloader source,
518 State state, int filesDown, int filesTotal,
519 int bytesDown, int bytesTotal,
520 int duration, int remaining, int speed) {
521 evt.setProgressEnd(filesTotal);
522 evt.setProgressValue(filesDown);
523 }
524 });
525 while (!m.isFinished()) {
526 try {
527 Thread.sleep(10);
528 } catch (InterruptedException e) {
529 e.printStackTrace();
530 }
531 }
532 }
533 evt.setProgressMessage(bundle
534 .getString("mandatoryToolsInstall.title"));
535 Installer
536 .installTools(ModManager.getInstance().getMandatoryTools());
537 }
538 }
539
540 @DoInBackground(progressMessage = "installing.title", cancelable = false, indeterminateProgress = false)
541 private void install(final BackgroundEvent evt) {
542 TreeSet<Mod> mods = new TreeSet<Mod>();
543 mods.addAll(ModManager.getInstance().getMandatoryMods());
544 mods.addAll(model.getSelectedMods());
545
546 boolean instReady = false;
547 installDone = EInstallResult.DONE;
548
549 while (!instReady) {
550 TreeSet<Mod> toDownload = new TreeSet<Mod>();
551 for (Mod m : mods) {
552 if (!m.isLocalAvailable())
553 toDownload.add(m);
554 }
555 if (Settings.getInstance().isOfflineMode()) {
556 installDone = EInstallResult.OFFLINE;
557 break;
558 }
559 if (toDownload.size() > 0) {
560 Downloader dl = new Downloader(toDownload);
561 try {
562 dl.setVisible(true);
563 if (!dl.isFinished())
564 break;
565 } finally {
566 dl.dispose();
567 }
568 }
569 HashMap<Mod, HashSet<Mod>> dependencies = ModManager.getInstance()
570 .checkDependencies(mods);
571 if (dependencies.size() > 0) {
572 System.out.println("Unmet dependencies: "
573 + dependencies.toString());
574 for (Mod m : dependencies.keySet()) {
575 for (Mod mDep : dependencies.get(m))
576 mods.add(mDep);
577 }
578 } else {
579 HashMap<Mod, HashSet<Mod>> conflicts = ModManager.getInstance()
580 .checkIncompabitilites(mods);
581 if (conflicts.size() > 0) {
582 installDone = EInstallResult.INCOMPATIBLE;
583 System.err.println("Incompatible mods: "
584 + conflicts.toString());
585 break;
586 } else {
587 instReady = true;
588 }
589 }
590 }
591
592 if (instReady) {
593 TreeSet<Mod> actuallyMods = new TreeSet<Mod>();
594 TreeSet<Mod> actuallyTools = new TreeSet<Mod>();
595
596 for (Mod m : mods) {
597 if (m.isTool())
598 actuallyTools.add(m);
599 else
600 actuallyMods.add(m);
601 }
602
603 if (actuallyTools.size() > 0) {
604 Installer.installTools(actuallyTools);
605 }
606
607 Installer.install(actuallyMods, new InstallProgressListener() {
608 @Override
609 public void installProgressUpdate(int done, int total,
610 String step) {
611 evt.setProgressEnd(total);
612 evt.setProgressValue(done);
613 evt.setProgressMessage(step);
614 }
615 });
616 installDone = EInstallResult.DONE;
617 }
618 }
619
620 @SuppressWarnings("unused")
621 private void installDone() {
622 switch (installDone) {
623 case DONE:
624 JOptionPane.showMessageDialog(this,
625 bundle.getString("installDone.text"),
626 bundle.getString("installDone.title"),
627 JOptionPane.INFORMATION_MESSAGE);
628 break;
629 case OFFLINE:
630 JOptionPane.showMessageDialog(this,
631 bundle.getString("offlineMode.text"),
632 bundle.getString("offlineMode.title"),
633 JOptionPane.WARNING_MESSAGE);
634 break;
635 case INCOMPATIBLE:
636 break;
637 }
638 }
639
640 private void modSelection(Mod m) {
641 lblSubmitterVal.setText("");
642 lblCreatorVal.setText("");
643 lblDescriptionVal.setText("");
644 lblTypesVal.setText("");
645 lblPlatformVal.setText("");
646 lblPackageNumberVal.setText("");
647 if (m != null) {
648 lblSubmitterVal.setText(m.getName());
649 lblCreatorVal.setText(m.getCreator());
650 lblDescriptionVal.setText(m.getDescription());
651
652 String types = "";
653 for (Type t : m.getTypes()) {
654 if (types.length() > 0)
655 types += ", ";
656 types += t.getName();
657 }
658 lblTypesVal.setText(types);
659 lblPlatformVal.setText(m.getPlatform().toString());
660 lblPackageNumberVal.setText(m.getPackageNumberString());
661 }
662 }
663
664 @SuppressWarnings("unused")
665 private void modTypeSelection() {
666 Type t = (Type) cmbModTypes.getSelectedItem();
667 if (t != null)
668 sorter.setRowFilter(new ModTableFilter(t));
669 else
670 sorter.setRowFilter(new ModTableFilter(null));
671 }
672
673 @Override
674 public void downloadSizeChanged(int newSize) {
675 lblDownloadSizeVal.setText(SizeFormatter.format(newSize, 2));
676 }
677
678 @SuppressWarnings("unused")
679 private void checkInitialize() {
680 if (!Installer.isEditionInitialized()) {
681 if (!OniSplit.isOniSplitInstalled()) {
682 JOptionPane.showMessageDialog(this,
683 bundle.getString("noOniSplit.text"),
684 bundle.getString("noOniSplit.title"),
685 JOptionPane.ERROR_MESSAGE);
686 exit();
687 } else {
688 int res = JOptionPane
689 .showConfirmDialog(this,
690 bundle.getString("askInitialize.text"),
691 bundle.getString("askInitialize.title"),
692 JOptionPane.YES_NO_OPTION,
693 JOptionPane.QUESTION_MESSAGE);
694 if (res == JOptionPane.NO_OPTION) {
695 saveLocalData();
696 exit();
697 }
698 }
699 }
700 }
701
702 @DoInBackground(progressMessage = "initializingEdition.title", cancelable = false, indeterminateProgress = false)
703 private void initialize(final BackgroundEvent evt) {
704 if (!Installer.isEditionInitialized()) {
705 Installer.initializeEdition(new InstallProgressListener() {
706 @Override
707 public void installProgressUpdate(int done, int total,
708 String step) {
709 evt.setProgressEnd(total);
710 evt.setProgressValue(done);
711 evt.setProgressMessage(step);
712 }
713 });
714 }
715 }
716
717 private Vector<String> getBasicOniLaunchParams() {
718 Vector<String> params = new Vector<String>();
719 File exe = null;
720 switch (Settings.getPlatform()) {
721 case WIN:
722 exe = new File(Paths.getEditionBasePath(), "Oni.exe");
723 if (exe.exists())
724 params.add(exe.getPath());
725 break;
726 case MACOS:
727 exe = new File(Paths.getEditionBasePath(),
728 "Oni.app/Contents/MacOS/Oni");
729 if (exe.exists())
730 params.add(exe.getPath());
731 break;
732 case LINUX:
733 String wine = Settings.getWinePath();
734 exe = new File(Paths.getEditionBasePath(), "Oni.exe");
735 if (exe.exists()) {
736 if (wine != null) {
737 params.add(wine);
738 params.add(exe.getPath());
739 }
740 }
741 break;
742 default:
743 }
744 if (params.size() > 0) {
745 params.add("-debugfiles");
746 }
747 return params;
748 }
749
750 @SuppressWarnings("unused")
751 private void oniFull() {
752 Vector<String> params = getBasicOniLaunchParams();
753 if (params.size() > 0) {
754 AppExecution.execute(params, Paths.getEditionBasePath());
755 }
756 }
757
758 @SuppressWarnings("unused")
759 private void oniWin() {
760 Vector<String> params = getBasicOniLaunchParams();
761 if (params.size() > 0) {
762 params.add("-noswitch");
763 AppExecution.execute(params, Paths.getEditionBasePath());
764 }
765 }
766
767 @SuppressWarnings("unused")
768 private void openEditionFolder() {
769 try {
770 Desktop.getDesktop().open(Paths.getEditionBasePath());
771 } catch (IOException e) {
772 e.printStackTrace();
773 }
774 }
775
776 @Override
777 public void handleAbout(ApplicationEvent event) {
778 event.setHandled(true);
779 showAbout();
780 }
781
782 @Override
783 public void handleOpenApplication(ApplicationEvent event) {
784 }
785
786 @Override
787 public void handleOpenFile(ApplicationEvent event) {
788 }
789
790 @Override
791 public void handlePreferences(ApplicationEvent event) {
792 showSettings();
793 }
794
795 @Override
796 public void handlePrintFile(ApplicationEvent event) {
797 }
798
799 @Override
800 public void handleQuit(ApplicationEvent event) {
801 event.setHandled(true);
802 saveLocalData();
803 exit();
804 }
805
806 @Override
807 public void handleReOpenApplication(ApplicationEvent event) {
808 }
809
810}
Note: See TracBrowser for help on using the repository browser.