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