Search in sources :

Example 1 with Version

use of com.sk89q.skmcl.application.Version 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 2 with Version

use of com.sk89q.skmcl.application.Version in project SKMCLauncher by SKCraft.

the class Minecraft method getInstalled.

@Override
public List<Version> getInstalled() {
    List<Version> versions = new ArrayList<Version>();
    File dir = new File(profile.getContentDir(), "versions");
    if (dir.exists()) {
        for (File d : dir.listFiles(new VersionFoldersFilter())) {
            versions.add(new Version(d.getName()));
        }
    }
    return versions;
}
Also used : Version(com.sk89q.skmcl.application.Version) ArrayList(java.util.ArrayList) File(java.io.File)

Aggregations

Version (com.sk89q.skmcl.application.Version)2 LauncherException (com.sk89q.skmcl.LauncherException)1 ActionEvent (java.awt.event.ActionEvent)1 ActionListener (java.awt.event.ActionListener)1 File (java.io.File)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1