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