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

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

AEI2 0.99:

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