Some more progress with autoupdate button

This commit is contained in:
friarsol
2020-02-17 21:51:18 -05:00
parent 599d75351c
commit 133f1656d8
4 changed files with 24 additions and 7 deletions

View File

@@ -23,6 +23,13 @@ public enum CSubmenuDownloaders implements ICDoc {
VSubmenuDownloaders.SINGLETON_INSTANCE.showLicensing(); VSubmenuDownloaders.SINGLETON_INSTANCE.showLicensing();
} }
}; };
private final UiCommand cmdCheckForUpdates = new UiCommand() {
@Override
public void run() {
new AutoUpdater(false).attemptToUpdate();
}
};
private final UiCommand cmdPicDownload = new UiCommand() { private final UiCommand cmdPicDownload = new UiCommand() {
@Override public void run() { @Override public void run() {
new GuiDownloader(new GuiDownloadPicturesLQ()).show(); new GuiDownloader(new GuiDownloadPicturesLQ()).show();
@@ -84,6 +91,7 @@ public enum CSubmenuDownloaders implements ICDoc {
@Override @Override
public void initialize() { public void initialize() {
final VSubmenuDownloaders view = VSubmenuDownloaders.SINGLETON_INSTANCE; final VSubmenuDownloaders view = VSubmenuDownloaders.SINGLETON_INSTANCE;
view.setCheckForUpdatesCommand(cmdCheckForUpdates);
view.setDownloadPicsCommand(cmdPicDownload); view.setDownloadPicsCommand(cmdPicDownload);
view.setDownloadPicsHQCommand(cmdPicDownloadHQ); view.setDownloadPicsHQCommand(cmdPicDownloadHQ);
view.setDownloadSetPicsCommand(cmdSetDownload); view.setDownloadSetPicsCommand(cmdSetDownload);

View File

@@ -55,6 +55,7 @@ public enum VSubmenuDownloaders implements IVSubmenu<CSubmenuDownloaders> {
private final JPanel pnlContent = new JPanel(new MigLayout("insets 0, gap 0, wrap, ay center")); private final JPanel pnlContent = new JPanel(new MigLayout("insets 0, gap 0, wrap, ay center"));
private final FScrollPane scrContent = new FScrollPane(pnlContent, false); private final FScrollPane scrContent = new FScrollPane(pnlContent, false);
private final FLabel btnCheckForUpdates = _makeButton(localizer.getMessage("btnCheckForUpdates"));
private final FLabel btnDownloadSetPics = _makeButton(localizer.getMessage("btnDownloadSetPics")); private final FLabel btnDownloadSetPics = _makeButton(localizer.getMessage("btnDownloadSetPics"));
private final FLabel btnDownloadPics = _makeButton(localizer.getMessage("btnDownloadPics")); private final FLabel btnDownloadPics = _makeButton(localizer.getMessage("btnDownloadPics"));
private final FLabel btnDownloadPicsHQ = _makeButton(localizer.getMessage("btnDownloadPicsHQ")); private final FLabel btnDownloadPicsHQ = _makeButton(localizer.getMessage("btnDownloadPicsHQ"));
@@ -80,6 +81,9 @@ public enum VSubmenuDownloaders implements IVSubmenu<CSubmenuDownloaders> {
if (javaRecentEnough()) { if (javaRecentEnough()) {
pnlContent.add(btnCheckForUpdates, constraintsBTN);
pnlContent.add(_makeLabel(localizer.getMessage("lblCheckForUpdates")), constraintsLBL);
pnlContent.add(btnDownloadPics, constraintsBTN); pnlContent.add(btnDownloadPics, constraintsBTN);
pnlContent.add(_makeLabel(localizer.getMessage("lblDownloadPics")), constraintsLBL); pnlContent.add(_makeLabel(localizer.getMessage("lblDownloadPics")), constraintsLBL);
@@ -162,6 +166,7 @@ public enum VSubmenuDownloaders implements IVSubmenu<CSubmenuDownloaders> {
return EMenuGroup.SETTINGS; return EMenuGroup.SETTINGS;
} }
public void setCheckForUpdatesCommand(UiCommand command) { btnCheckForUpdates.setCommand(command); }
public void setDownloadPicsCommand(UiCommand command) { btnDownloadPics.setCommand(command); } public void setDownloadPicsCommand(UiCommand command) { btnDownloadPics.setCommand(command); }
public void setDownloadPicsHQCommand(UiCommand command) { btnDownloadPicsHQ.setCommand(command); } public void setDownloadPicsHQCommand(UiCommand command) { btnDownloadPicsHQ.setCommand(command); }
public void setDownloadSetPicsCommand(UiCommand command) { btnDownloadSetPics.setCommand(command); } public void setDownloadSetPicsCommand(UiCommand command) { btnDownloadSetPics.setCommand(command); }

View File

@@ -182,6 +182,7 @@ KeyboardShortcuts=Keyboard Shortcuts
#VSubmenuAchievements.java #VSubmenuAchievements.java
lblAchievements=Achievements lblAchievements=Achievements
#VSubmenuDownloaders.java #VSubmenuDownloaders.java
btnCheckForUpdates=Check for Updates
btnDownloadSetPics=Download LQ Set Pictures btnDownloadSetPics=Download LQ Set Pictures
btnDownloadPicsHQ=Download HQ Card Pictures (Very Slow!) btnDownloadPicsHQ=Download HQ Card Pictures (Very Slow!)
btnDownloadPics=Download LQ Card Pictures btnDownloadPics=Download LQ Card Pictures
@@ -194,6 +195,7 @@ btnImportPictures=Import Data
btnHowToPlay=How To Play btnHowToPlay=How To Play
btnDownloadPrices=Download Card Prices btnDownloadPrices=Download Card Prices
btnLicensing=License Details btnLicensing=License Details
lblCheckForUpdates=Check Forge server to see if there's a more recent release
lblDownloadPics=Download default card picture for each card. lblDownloadPics=Download default card picture for each card.
lblDownloadPicsHQ=Download default card HQ picture for each card. lblDownloadPicsHQ=Download default card HQ picture for each card.
lblDownloadSetPics=Download all pictures of each card (one for each set the card appeared in) lblDownloadSetPics=Download all pictures of each card (one for each set the card appeared in)

View File

@@ -9,9 +9,11 @@ import forge.util.WaitCallback;
import forge.util.gui.SOptionPane; import forge.util.gui.SOptionPane;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import javax.swing.*;
import java.awt.*; import java.awt.*;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.lang.reflect.InvocationTargetException;
import java.net.*; import java.net.*;
import java.util.List; import java.util.List;
@@ -129,10 +131,10 @@ public class AutoUpdater {
final List<String> options = ImmutableList.of("Update Now", "Update Later"); final List<String> options = ImmutableList.of("Update Now", "Update Later");
if (SOptionPane.showOptionDialog(message, "New Version Available", null, options, 0) == 0) { if (SOptionPane.showOptionDialog(message, "New Version Available", null, options, 0) == 0) {
downloadFromForge(); return downloadFromForge();
} }
return true; return false;
} }
private boolean downloadFromBrowser() throws URISyntaxException, IOException { private boolean downloadFromBrowser() throws URISyntaxException, IOException {
@@ -157,15 +159,15 @@ public class AutoUpdater {
super.copyInputStream(in, outPath); super.copyInputStream(in, outPath);
packagePath = outPath; packagePath = outPath;
extractUpdate();
} }
}, this); }, this);
} }
}; };
if (!callback.invokeAndWait()) {
return false; SwingUtilities.invokeLater(callback);
} else {
return true; return false;
}
} }
private void extractUpdate() { private void extractUpdate() {