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

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

AEI2 0.96:

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