Search in sources :

Example 1 with LauncherException

use of com.sk89q.skmcl.LauncherException in project SKMCLauncher by SKCraft.

the class LaunchWorker method update.

private void update(Instance instance, WorkUnit workUnit) throws LauncherException, InterruptedException {
    try {
        AbstractWorker<?> updater = instance.getUpdater();
        updater.addObserver(workUnit);
        updater.call();
    } catch (InterruptedException e) {
        throw e;
    } catch (Exception e) {
        throw new LauncherException(e, _("updater.updateFailed"));
    }
}
Also used : LauncherException(com.sk89q.skmcl.LauncherException) IOException(java.io.IOException) LauncherException(com.sk89q.skmcl.LauncherException)

Example 2 with LauncherException

use of com.sk89q.skmcl.LauncherException in project SKMCLauncher by SKCraft.

the class VersionListDialog method initComponents.

private void initComponents() {
    JPanel mainPanel = new JPanel();
    versionsList = new JList();
    JScrollPane versionsScroll = new JScrollPane(versionsList);
    LinedBoxPanel buttonsPanel = new LinedBoxPanel(true).fullyPadded();
    JButton cancelButton = new JButton(_("button.cancel"));
    JButton selectButton = new JButton(_("button.select"));
    mainPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
    mainPanel.setLayout(new BorderLayout());
    mainPanel.add(versionsScroll, BorderLayout.CENTER);
    buttonsPanel.addGlue();
    buttonsPanel.addElement(selectButton);
    buttonsPanel.addElement(cancelButton);
    add(mainPanel, BorderLayout.CENTER);
    add(buttonsPanel, BorderLayout.SOUTH);
    cancelButton.addActionListener(ActionListeners.dispose(this));
    selectButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            Object selected = versionsList.getSelectedValue();
            if (selected != null && selected instanceof Version) {
                version = (Version) selected;
            }
            dispose();
        }
    });
    getRootPane().setDefaultButton(selectButton);
    versionsList.addMouseListener(new DoubleClickToButtonAdapter(selectButton));
    ListenableFuture<?> future = executor.submit(new AbstractWorker<Object>() {

        @Override
        protected void run() throws Exception {
            try {
                setVersions(application.getAvailable());
            } catch (IOException e) {
                dispose();
                throw new LauncherException(e, _("versionList.failedFetchError"));
            } catch (InterruptedException e) {
                dispose();
            }
        }

        @Override
        public String getLocalizedTitle() {
            return _("selectVersions.fetchingVersionsTitle");
        }

        @Override
        public boolean shouldConfirmInterrupt() {
            return false;
        }
    });
    SwingHelper.addErrorDialogCallback(future, this);
}
Also used : LauncherException(com.sk89q.skmcl.LauncherException) ActionEvent(java.awt.event.ActionEvent) IOException(java.io.IOException) IOException(java.io.IOException) LauncherException(com.sk89q.skmcl.LauncherException) ActionListener(java.awt.event.ActionListener) Version(com.sk89q.skmcl.application.Version)

Example 3 with LauncherException

use of com.sk89q.skmcl.LauncherException in project SKMCLauncher by SKCraft.

the class LaunchWorker method call.

@Override
public LaunchedProcess call() throws LauncherException, InterruptedException {
    WorkUnit step1 = split(0.1), step2 = split(0.8), step3 = split(0.1);
    // First resolve the version (i.e. latest -> which version is "latest"?)
    setLocalizedTitle(_("launch.launchingTitle", profile.toString()));
    step1.push(0, _("launch.checkingVersion"));
    Instance instance = getInstance();
    Persistence.commitAndForget(profile);
    // Then attempt to launch
    // But an update MAY be required
    step2.push(0, _("launch.launching"));
    try {
        return launch(instance);
    } catch (UpdateRequiredException e) {
    // Update required, so we're going to go to the update step
    } catch (IOException e) {
        throw new LauncherException(e, _("launch.launchFailed"));
    }
    if (!offline) {
        setLocalizedTitle(_("launch.updatingTitle", profile.toString()));
        step2.push(0, _("launch.updating"));
        update(instance, step2);
    } else {
        throw new LauncherException("Can't update if offline", _("launch.onlineModeRequired"));
    }
    // Update's done, so let's try launching one more time
    setLocalizedTitle(_("launch.launchingTitle", profile.toString()));
    step3.push(0, _("launch.launching"));
    try {
        return launch(instance);
    } catch (UpdateRequiredException e) {
        // but perhaps something failed
        throw new LauncherException(e, _("updater.launchFailed"));
    } catch (IOException e) {
        throw new LauncherException(e, _("updater.launchFailed"));
    }
}
Also used : LauncherException(com.sk89q.skmcl.LauncherException) WorkUnit(com.sk89q.skmcl.concurrent.WorkUnit) IOException(java.io.IOException)

Aggregations

LauncherException (com.sk89q.skmcl.LauncherException)3 IOException (java.io.IOException)3 Version (com.sk89q.skmcl.application.Version)1 WorkUnit (com.sk89q.skmcl.concurrent.WorkUnit)1 ActionEvent (java.awt.event.ActionEvent)1 ActionListener (java.awt.event.ActionListener)1