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

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

AEI2 0.97:

  • Finished toolmanager
File size: 21.6 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
[640]124 setSize(getWidth() + 150, getHeight());
[637]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()) {
[640]386 File exe = m.getExeFile();
387 if (exe != null && exe.exists()) {
[623]388 JMenuItem item = new JMenuItem();
389 final Vector<String> params = new Vector<String>();
[640]390 if (exe.getName().toLowerCase().endsWith(".jar")) {
391 File jre = null;
392 if (Settings.getPlatform() == Platform.WIN)
393 jre = new File(System.getProperties().getProperty(
394 "java.home"), "bin/javaw.exe");
395 else
396 jre = new File(System.getProperties().getProperty(
397 "java.home"), "bin/java");
398 params.add(jre.getPath());
399 params.add("-jar");
400 }
401 params.add(exe.getPath());
[623]402 final File wd = m.getWorkingDir();
403 Icon ico = null;
404 if (m.getIconFile() != null && m.getIconFile().exists()) {
405 ico = new ImageIcon(m.getIconFile().getPath());
406 } else {
[624]407 URL icon = AEInstaller2.class
408 .getResource("images/transparent.png");
[623]409 ico = new ImageIcon(icon);
410 }
411 item.setAction(new AbstractAction(m.getName(), ico) {
412 private static final long serialVersionUID = 1L;
413
414 @Override
415 public void actionPerformed(ActionEvent e) {
416 AppExecution.execute(params, wd);
417 }
418 });
419 toolsMenuItems.add(item);
420 toolsMenu.add(item);
421 }
422 }
423 }
424
[593]425 private void revertSelection() {
[631]426 tblMods.revertSelection();
[593]427 }
428
[602]429 @DoInBackground(progressMessage = "mandatoryFiles.title", cancelable = false, indeterminateProgress = false)
430 private void checkMandatoryFiles(final BackgroundEvent evt) {
[621]431 if (!Settings.getInstance().isOfflineMode()) {
432 TreeSet<Mod> mand = new TreeSet<Mod>();
433 for (Mod m : ModManager.getInstance().getMandatoryTools()) {
434 if (m.isNewerAvailable()) {
435 mand.add(m);
436 }
[604]437 }
[621]438 for (Mod m : ModManager.getInstance().getMandatoryMods()) {
439 if (m.isNewerAvailable()) {
440 mand.add(m);
441 }
[604]442 }
[621]443 if (mand.size() > 0) {
444 ModDownloader m = new ModDownloader(mand,
445 new ModDownloaderListener() {
446 @Override
447 public void updateStatus(ModDownloader source,
448 State state, int filesDown, int filesTotal,
449 int bytesDown, int bytesTotal,
450 int duration, int remaining, int speed) {
451 evt.setProgressEnd(filesTotal);
452 evt.setProgressValue(filesDown);
453 }
454 });
455 while (!m.isFinished()) {
456 try {
457 Thread.sleep(10);
458 } catch (InterruptedException e) {
459 e.printStackTrace();
460 }
[604]461 }
462 }
[621]463 evt.setProgressMessage(bundle
464 .getString("mandatoryToolsInstall.title"));
465 Installer
466 .installTools(ModManager.getInstance().getMandatoryTools());
[604]467 }
[602]468 }
469
[600]470 @DoInBackground(progressMessage = "installing.title", cancelable = false, indeterminateProgress = false)
[621]471 private void install(final BackgroundEvent evt) {
[600]472 TreeSet<Mod> mods = new TreeSet<Mod>();
[602]473 mods.addAll(ModManager.getInstance().getMandatoryMods());
[631]474 mods.addAll(tblMods.getSelectedMods());
[600]475
[605]476 boolean instReady = false;
[621]477 installDone = EInstallResult.DONE;
[605]478
479 while (!instReady) {
480 TreeSet<Mod> toDownload = new TreeSet<Mod>();
481 for (Mod m : mods) {
482 if (!m.isLocalAvailable())
483 toDownload.add(m);
484 }
[621]485 if (Settings.getInstance().isOfflineMode()) {
486 installDone = EInstallResult.OFFLINE;
487 break;
488 }
[605]489 if (toDownload.size() > 0) {
490 Downloader dl = new Downloader(toDownload);
[617]491 try {
492 dl.setVisible(true);
493 if (!dl.isFinished())
494 break;
495 } finally {
496 dl.dispose();
497 }
[605]498 }
499 HashMap<Mod, HashSet<Mod>> dependencies = ModManager.getInstance()
500 .checkDependencies(mods);
501 if (dependencies.size() > 0) {
502 System.out.println("Unmet dependencies: "
503 + dependencies.toString());
504 for (Mod m : dependencies.keySet()) {
505 for (Mod mDep : dependencies.get(m))
506 mods.add(mDep);
507 }
508 } else {
509 HashMap<Mod, HashSet<Mod>> conflicts = ModManager.getInstance()
[608]510 .checkIncompabitilites(mods);
[605]511 if (conflicts.size() > 0) {
[621]512 installDone = EInstallResult.INCOMPATIBLE;
[608]513 System.err.println("Incompatible mods: "
[605]514 + conflicts.toString());
515 break;
516 } else {
517 instReady = true;
518 }
519 }
[600]520 }
[618]521
[605]522 if (instReady) {
[623]523 TreeSet<Mod> actuallyMods = new TreeSet<Mod>();
524 TreeSet<Mod> actuallyTools = new TreeSet<Mod>();
525
526 for (Mod m : mods) {
527 if (m.isTool())
528 actuallyTools.add(m);
529 else
530 actuallyMods.add(m);
531 }
532
533 if (actuallyTools.size() > 0) {
534 Installer.installTools(actuallyTools);
535 }
536
537 Installer.install(actuallyMods, new InstallProgressListener() {
[605]538 @Override
539 public void installProgressUpdate(int done, int total,
540 String step) {
541 evt.setProgressEnd(total);
542 evt.setProgressValue(done);
543 evt.setProgressMessage(step);
544 }
545 });
[621]546 installDone = EInstallResult.DONE;
[605]547 }
[600]548 }
[618]549
[617]550 @SuppressWarnings("unused")
551 private void installDone() {
[637]552 ModManager.getInstance().updateInstalledMods();
553 revertSelection();
[621]554 switch (installDone) {
555 case DONE:
556 JOptionPane.showMessageDialog(this,
557 bundle.getString("installDone.text"),
558 bundle.getString("installDone.title"),
559 JOptionPane.INFORMATION_MESSAGE);
560 break;
561 case OFFLINE:
562 JOptionPane.showMessageDialog(this,
563 bundle.getString("offlineMode.text"),
564 bundle.getString("offlineMode.title"),
565 JOptionPane.WARNING_MESSAGE);
566 break;
567 case INCOMPATIBLE:
568 break;
569 }
[617]570 }
[600]571
[631]572 @Override
573 public void modSelectionChanged(ModTable source, Mod m) {
[639]574 lblTitleVal.setText("");
[592]575 lblSubmitterVal.setText("");
576 lblCreatorVal.setText("");
577 lblDescriptionVal.setText("");
[606]578 lblTypesVal.setText("");
579 lblPlatformVal.setText("");
[621]580 lblPackageNumberVal.setText("");
[638]581 lblVersionNumberVal.setText("");
[600]582 if (m != null) {
[639]583 lblTitleVal.setText(m.getName());
584 lblSubmitterVal.setText(m.getSubmitter());
[600]585 lblCreatorVal.setText(m.getCreator());
586 lblDescriptionVal.setText(m.getDescription());
[606]587
588 String types = "";
589 for (Type t : m.getTypes()) {
590 if (types.length() > 0)
591 types += ", ";
592 types += t.getName();
593 }
594 lblTypesVal.setText(types);
595 lblPlatformVal.setText(m.getPlatform().toString());
[621]596 lblPackageNumberVal.setText(m.getPackageNumberString());
[638]597 lblVersionNumberVal.setText(m.getVersion());
[591]598 }
599 }
600
[630]601 private void updateTableFilter() {
602 Object o = cmbModTypes.getSelectedItem();
603 Type t = null;
604 if (o instanceof Type)
605 t = (Type) o;
606 int downloadState = 0;
607 if (radOnline.isSelected())
608 downloadState = 1;
609 if (radLocal.isSelected())
610 downloadState = 2;
[631]611 tblMods.setFilter(t, downloadState);
[630]612 }
613
[591]614 @SuppressWarnings("unused")
[592]615 private void modTypeSelection() {
[630]616 updateTableFilter();
[591]617 }
[593]618
[630]619 @SuppressWarnings("unused")
620 private void showTypeSelection() {
621 updateTableFilter();
622 }
623
[593]624 @Override
[600]625 public void downloadSizeChanged(int newSize) {
626 lblDownloadSizeVal.setText(SizeFormatter.format(newSize, 2));
627 }
628
[616]629 @SuppressWarnings("unused")
630 private void checkInitialize() {
[600]631 if (!Installer.isEditionInitialized()) {
[621]632 if (!OniSplit.isOniSplitInstalled()) {
633 JOptionPane.showMessageDialog(this,
634 bundle.getString("noOniSplit.text"),
635 bundle.getString("noOniSplit.title"),
636 JOptionPane.ERROR_MESSAGE);
[600]637 exit();
[621]638 } else {
639 int res = JOptionPane
640 .showConfirmDialog(this,
641 bundle.getString("askInitialize.text"),
642 bundle.getString("askInitialize.title"),
643 JOptionPane.YES_NO_OPTION,
644 JOptionPane.QUESTION_MESSAGE);
645 if (res == JOptionPane.NO_OPTION) {
646 saveLocalData();
647 exit();
648 }
[600]649 }
650 }
651 }
[606]652
[616]653 @DoInBackground(progressMessage = "initializingEdition.title", cancelable = false, indeterminateProgress = false)
654 private void initialize(final BackgroundEvent evt) {
655 if (!Installer.isEditionInitialized()) {
656 Installer.initializeEdition(new InstallProgressListener() {
657 @Override
658 public void installProgressUpdate(int done, int total,
659 String step) {
660 evt.setProgressEnd(total);
661 evt.setProgressValue(done);
662 evt.setProgressMessage(step);
663 }
664 });
665 }
666 }
667
[605]668 private Vector<String> getBasicOniLaunchParams() {
669 Vector<String> params = new Vector<String>();
[618]670 File exe = null;
[605]671 switch (Settings.getPlatform()) {
672 case WIN:
[618]673 exe = new File(Paths.getEditionBasePath(), "Oni.exe");
674 if (exe.exists())
675 params.add(exe.getPath());
[605]676 break;
677 case MACOS:
[618]678 exe = new File(Paths.getEditionBasePath(),
679 "Oni.app/Contents/MacOS/Oni");
680 if (exe.exists())
681 params.add(exe.getPath());
[605]682 break;
683 case LINUX:
684 String wine = Settings.getWinePath();
[618]685 exe = new File(Paths.getEditionBasePath(), "Oni.exe");
686 if (exe.exists()) {
687 if (wine != null) {
688 params.add(wine);
689 params.add(exe.getPath());
690 }
[605]691 }
692 break;
693 default:
694 }
695 if (params.size() > 0) {
696 params.add("-debugfiles");
697 }
698 return params;
699 }
[600]700
[605]701 @SuppressWarnings("unused")
702 private void oniFull() {
703 Vector<String> params = getBasicOniLaunchParams();
704 if (params.size() > 0) {
[623]705 AppExecution.execute(params, Paths.getEditionBasePath());
[605]706 }
707 }
708
709 @SuppressWarnings("unused")
710 private void oniWin() {
711 Vector<String> params = getBasicOniLaunchParams();
712 if (params.size() > 0) {
713 params.add("-noswitch");
[623]714 AppExecution.execute(params, Paths.getEditionBasePath());
[605]715 }
716 }
717
[608]718 @SuppressWarnings("unused")
719 private void openEditionFolder() {
720 try {
721 Desktop.getDesktop().open(Paths.getEditionBasePath());
[639]722 } catch (Exception e) {
[608]723 e.printStackTrace();
724 }
725 }
726
[600]727 @Override
[593]728 public void handleAbout(ApplicationEvent event) {
729 event.setHandled(true);
730 showAbout();
731 }
732
733 @Override
734 public void handleOpenApplication(ApplicationEvent event) {
735 }
736
737 @Override
738 public void handleOpenFile(ApplicationEvent event) {
739 }
740
741 @Override
742 public void handlePreferences(ApplicationEvent event) {
743 showSettings();
744 }
745
746 @Override
747 public void handlePrintFile(ApplicationEvent event) {
748 }
749
750 @Override
751 public void handleQuit(ApplicationEvent event) {
[605]752 event.setHandled(true);
753 saveLocalData();
754 exit();
[593]755 }
756
757 @Override
758 public void handleReOpenApplication(ApplicationEvent event) {
759 }
[600]760
[592]761}
Note: See TracBrowser for help on using the repository browser.