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);
}
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;
}
Aggregations