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