Package com.atlauncher.workers

Examples of com.atlauncher.workers.InstanceInstaller


                subProgressBar.setVisible(false);

                dialog.add(topPanel, BorderLayout.CENTER);
                dialog.add(bottomPanel, BorderLayout.SOUTH);

                final InstanceInstaller instanceInstaller = new InstanceInstaller((isServer ? "" : instanceNameField
                        .getText()), pack, version, isReinstall, isServer) {

                    protected void done() {
                        Boolean success = false;
                        int type;
                        String text;
                        String title;
                        if (isCancelled()) {
                            type = JOptionPane.ERROR_MESSAGE;
                            text = pack.getName() + " " + version.getVersion() + " " + Language.INSTANCE.localize
                                    ("common.wasnt") + " " + ((isReinstall) ? Language.INSTANCE.localize("common" + "" +
                                    ".reinstalled") : Language.INSTANCE.localize("common.installed")) +
                                    "<br/><br/>" + Language.INSTANCE.localize("instance" + ".checkerrorlogs");
                            title = pack.getName() + " " + version.getVersion() + " " + Language.INSTANCE.localize
                                    ("common.not") + " " + ((isReinstall) ? Language.INSTANCE.localize("common" + "" +
                                    ".reinstalled") : Language.INSTANCE.localize("common.installed"));
                            if (isReinstall) {
                                if (shouldCoruptInstance()) {
                                    App.settings.setInstanceUnplayable(instance);
                                }
                            }
                        } else {
                            try {
                                success = get();
                            } catch (InterruptedException e) {
                                App.settings.logStackTrace(e);
                            } catch (ExecutionException e) {
                                App.settings.logStackTrace(e);
                            }
                            if (success) {
                                type = JOptionPane.INFORMATION_MESSAGE;
                                text = pack.getName() + " " + version.getVersion() + " " + Language.INSTANCE.localize
                                        ("common.hasbeen") + " " + ((isReinstall) ? Language.INSTANCE.localize
                                        ("common.reinstalled") : Language.INSTANCE.localize("common.installed")) +
                                        "<br/><br/>" + ((isServer) ? Language.INSTANCE.localizeWithReplace("instance"
                                        + ".finditserver", "<br/><br/>" + this.getRootDirectory().getAbsolutePath())
                                        : Language.INSTANCE.localize("instance.findit"));
                                title = pack.getName() + " " + version.getVersion() + " " + Language.INSTANCE
                                        .localize("common.installed");
                                if (isReinstall) {
                                    instance.setVersion(version.getVersion());
                                    instance.setMinecraftVersion(version.getMinecraftVersion().getVersion());
                                    instance.setModsInstalled(this.getModsInstalled());
                                    instance.setJarOrder(this.getJarOrder());
                                    instance.setMemory(this.getMemory());
                                    instance.setPermgen(this.getPermGen());
                                    instance.setIsNewLaunchMethod(!this.isLegacy());
                                    instance.setLibrariesNeeded(this.getLibrariesNeeded());
                                    instance.setMinecraftArguments(this.getMinecraftArguments());
                                    instance.setExtraArguments(this.getExtraArguments());
                                    instance.setMainClass(this.getMainClass());
                                    instance.setAssets(version.getMinecraftVersion().getMojangVersion().getAssets());
                                    if (version.isDev()) {
                                        instance.setDevVersion();
                                        if (version.getHash() != null) {
                                            instance.setHash(version.getHash());
                                        }
                                    } else {
                                        instance.setNotDevVersion();
                                    }
                                    if (!instance.isPlayable()) {
                                        instance.setPlayable();
                                    }
                                } else if (isServer) {

                                } else {
                                    Instance newInstance = new Instance(instanceNameField.getText(), pack.getName(),
                                            pack, installForMe.isSelected(), version.getVersion(),
                                            version.getMinecraftVersion().getVersion(), this.getMemory(),
                                            this.getPermGen(), this.getModsInstalled(), this.getJarOrder(),
                                            this.getLibrariesNeeded(), this.getExtraArguments(),
                                            this.getMinecraftArguments(), this.getMainClass(),
                                            version.getMinecraftVersion().getMojangVersion().getAssets(),
                                            version.isDev(), !version.getMinecraftVersion().isLegacy());

                                    if (version.isDev() && (version.getHash() != null)) {
                                        newInstance.setHash(version.getHash());
                                    }

                                    App.settings.getInstances().add(newInstance);

                                }
                                App.settings.saveInstances();
                                App.settings.reloadInstancesPanel();
                                if (pack.isLoggingEnabled() && App.settings.enableLogs() && !version.isDev()) {
                                    if (isServer) {
                                        pack.addServerInstall(version.getVersion());
                                    } else if (isUpdate) {
                                        pack.addUpdate(version.getVersion());
                                    } else {
                                        pack.addInstall(version.getVersion());
                                    }
                                }
                            } else {
                                if (isReinstall) {
                                    type = JOptionPane.ERROR_MESSAGE;
                                    text = pack.getName() + " " + version.getVersion() + " " + Language.INSTANCE
                                            .localize("common.wasnt") + " " + Language.INSTANCE.localize("common" + "" +
                                            ".reinstalled") + "<br/><br/>" + (this.shouldCoruptInstance() ? Language
                                            .INSTANCE.localize("instance.nolongerplayable") : "") + "<br/><br/>" +
                                            Language.INSTANCE.localize("instance.checkerrorlogs") + "!";
                                    title = pack.getName() + " " + version.getVersion() + " " + Language.INSTANCE
                                            .localize("common.not") + " " + Language.INSTANCE.localize("common" + "" +
                                            ".reinstalled");
                                    if (this.shouldCoruptInstance()) {
                                        App.settings.setInstanceUnplayable(instance);
                                    }
                                } else {
                                    // Install failed so delete the folder and clear Temp Dir
                                    Utils.delete(this.getRootDirectory());
                                    type = JOptionPane.ERROR_MESSAGE;
                                    text = pack.getName() + " " + version.getVersion() + " " + Language.INSTANCE
                                            .localize("common.wasnt") + " " + Language.INSTANCE.localize("common" + "" +
                                            ".installed") + "<br/><br/>" + Language.INSTANCE.localize("instance" + "" +
                                            ".checkerrorlogs") + "!";
                                    title = pack.getName() + " " + version.getVersion() + " " + Language.INSTANCE
                                            .localize("common.not") + " " + Language.INSTANCE.localize("common" + "" +
                                            ".installed");
                                }
                            }
                        }

                        dialog.dispose();

                        Utils.cleanTempDirectory();

                        JOptionPane.showMessageDialog(App.settings.getParent(), "<html><p align=\"center\">" + text +
                                "</p></html>", title, type);
                    }

                };
                instanceInstaller.addPropertyChangeListener(new PropertyChangeListener() {

                    public void propertyChange(PropertyChangeEvent evt) {
                        if ("progress" == evt.getPropertyName()) {
                            if (progressBar.isIndeterminate()) {
                                progressBar.setIndeterminate(false);
                            }
                            int progress = (Integer) evt.getNewValue();
                            if (progress > 100) {
                                progress = 100;
                            }
                            progressBar.setValue(progress);
                        } else if ("subprogress" == evt.getPropertyName()) {
                            if (!subProgressBar.isVisible()) {
                                subProgressBar.setVisible(true);
                            }
                            if (subProgressBar.isIndeterminate()) {
                                subProgressBar.setIndeterminate(false);
                            }
                            int progress;
                            String paint = null;
                            if (evt.getNewValue() instanceof Integer) {
                                progress = (Integer) evt.getNewValue();
                            } else {
                                String[] parts = (String[]) evt.getNewValue();
                                progress = Integer.parseInt(parts[0]);
                                paint = parts[1];
                            }
                            if (progress >= 100) {
                                progress = 100;
                            }
                            if (progress < 0) {
                                if (subProgressBar.isStringPainted()) {
                                    subProgressBar.setStringPainted(false);
                                }
                                subProgressBar.setVisible(false);
                            } else {
                                if (!subProgressBar.isStringPainted()) {
                                    subProgressBar.setStringPainted(true);
                                }
                                if (paint != null) {
                                    subProgressBar.setString(paint);
                                }
                            }
                            subProgressBar.setValue(progress);
                        } else if ("subprogressint" == evt.getPropertyName()) {
                            if (subProgressBar.isStringPainted()) {
                                subProgressBar.setStringPainted(false);
                            }
                            if (!subProgressBar.isVisible()) {
                                subProgressBar.setVisible(true);
                            }
                            if (!subProgressBar.isIndeterminate()) {
                                subProgressBar.setIndeterminate(true);
                            }
                        } else if ("doing" == evt.getPropertyName()) {
                            String doingText = (String) evt.getNewValue();
                            doing.setText(doingText);
                        }

                    }
                });
                dialog.addWindowListener(new WindowAdapter() {
                    public void windowClosing(WindowEvent e) {
                        instanceInstaller.cancel(true);
                    }
                });
                if (isReinstall) {
                    instanceInstaller.setInstance(instance);
                }
                instanceInstaller.execute();
                dispose();
                dialog.setVisible(true);

            }
        });
View Full Code Here

TOP

Related Classes of com.atlauncher.workers.InstanceInstaller

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.