fix bugs with Swing.
This commit is contained in:
@@ -62,11 +62,11 @@ dependencies {
|
||||
}
|
||||
|
||||
retrolambda {
|
||||
javaVersion = JavaVersion.VERSION_1_7
|
||||
javaVersion = JavaVersion.VERSION_1_6
|
||||
}
|
||||
|
||||
jar {
|
||||
jar.classifier = 'base'
|
||||
//jar.classifier = 'base'
|
||||
from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } }
|
||||
|
||||
manifest {
|
||||
@@ -117,7 +117,7 @@ task makeExecutable(dependsOn: jar) << {
|
||||
launch4j {
|
||||
launch4jCmd = 'D:\\Develop\\Java\\Launch4j\\launch4j.exe'
|
||||
supportUrl = 'http://www.mcbbs.net/thread-142335-1-1.html'
|
||||
jreMinVersion = '1.7.0'
|
||||
jreMinVersion = '1.6.0'
|
||||
|
||||
mainClassName = mainClass
|
||||
icon = new File(project.buildDir, '../icon.ico').absolutePath
|
||||
@@ -136,6 +136,6 @@ processResources {
|
||||
}
|
||||
}
|
||||
|
||||
build.dependsOn proguard
|
||||
//build.dependsOn proguard
|
||||
//makeExecutable.dependsOn proguard
|
||||
//build.dependsOn makeExecutable
|
||||
File diff suppressed because it is too large
Load Diff
@@ -16,6 +16,7 @@
|
||||
*/
|
||||
package org.jackhuang.hellominecraft.launcher.launch;
|
||||
|
||||
import com.google.gson.JsonSyntaxException;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
@@ -146,7 +147,7 @@ public class MinecraftLoader extends AbstractMinecraftLoader {
|
||||
// If the scale new format existent file is lower then 0.1, use the old format.
|
||||
if (cnt * 10 < tot) return assetsDir;
|
||||
}
|
||||
} catch (IOException e) {
|
||||
} catch (IOException | JsonSyntaxException e) {
|
||||
HMCLog.warn("Failed to create virutal assets.", e);
|
||||
}
|
||||
|
||||
|
||||
@@ -172,6 +172,7 @@ public final class Profile {
|
||||
}
|
||||
|
||||
public File getFolder(String folder) {
|
||||
if (getSelectedMinecraftVersion() == null) return new File(getCanonicalGameDirFile(), folder);
|
||||
return new File(getMinecraftProvider().getRunDirectory(getSelectedMinecraftVersion().id), folder);
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,6 @@ import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import org.jackhuang.hellominecraft.C;
|
||||
import org.jackhuang.hellominecraft.HMCLog;
|
||||
import org.jackhuang.hellominecraft.launcher.Main;
|
||||
@@ -77,6 +76,8 @@ public final class Settings {
|
||||
temp.add(new Java("Custom", null));
|
||||
if (OS.os() == OS.WINDOWS)
|
||||
temp.addAll(Java.queryAllJavaHomeInWindowsByReg());
|
||||
if (OS.os() == OS.OSX)
|
||||
temp.addAll(Java.queryAllJDKInMac());
|
||||
JAVA = Collections.unmodifiableList(temp);
|
||||
}
|
||||
|
||||
@@ -124,7 +125,6 @@ public final class Settings {
|
||||
}
|
||||
|
||||
public static void setVersion(Profile ver) {
|
||||
Objects.requireNonNull(ver);
|
||||
getVersions().put(ver.getName(), ver);
|
||||
}
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@ package org.jackhuang.hellominecraft.launcher.utils;
|
||||
import java.text.DateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import javax.swing.SwingUtilities;
|
||||
import org.jackhuang.hellominecraft.HMCLog;
|
||||
import org.jackhuang.hellominecraft.launcher.Main;
|
||||
@@ -60,7 +61,7 @@ public class CrashReporter implements Thread.UncaughtExceptionHandler {
|
||||
else System.out.println(text);
|
||||
SwingUtilities.invokeLater(() -> LogWindow.instance.showAsCrashWindow(UpdateChecker.OUT_DATED));
|
||||
if (!UpdateChecker.OUT_DATED)
|
||||
reportToServer(text);
|
||||
reportToServer(text, e);
|
||||
} catch (Throwable ex) {
|
||||
try {
|
||||
MessageBox.Show(e.getMessage() + "\n" + ex.getMessage(), "ERROR", MessageBox.ERROR_MESSAGE);
|
||||
@@ -71,7 +72,12 @@ public class CrashReporter implements Thread.UncaughtExceptionHandler {
|
||||
}
|
||||
}
|
||||
|
||||
void reportToServer(String text) {
|
||||
private static final HashSet<String> throwableSet = new HashSet<>();
|
||||
|
||||
void reportToServer(String text, Throwable t) {
|
||||
String s = StrUtils.getStackTrace(t);
|
||||
if (throwableSet.contains(s)) return;
|
||||
throwableSet.add(s);
|
||||
new Thread(() -> {
|
||||
HashMap<String, String> map = new HashMap<>();
|
||||
map.put("CrashReport", text);
|
||||
|
||||
@@ -72,6 +72,11 @@ public class BMCLAPIDownloadProvider implements IDownloadProvider {
|
||||
return "http://bmclapi2.bangbang93.com/assets/";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getParsedLibraryDownloadURL(String str) {
|
||||
return str.replace("http://files.minecraftforge.net/maven", "http://bmclapi2.bangbang93.com/maven");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAllowedToUseSelfURL() {
|
||||
return false;
|
||||
|
||||
@@ -41,6 +41,8 @@ public interface IDownloadProvider {
|
||||
String getVersionsListDownloadURL();
|
||||
|
||||
String getAssetsDownloadURL();
|
||||
|
||||
String getParsedLibraryDownloadURL(String str);
|
||||
|
||||
boolean isAllowedToUseSelfURL();
|
||||
}
|
||||
|
||||
@@ -77,4 +77,9 @@ public class MojangDownloadProvider implements IDownloadProvider {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getParsedLibraryDownloadURL(String str) {
|
||||
return str;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -24,10 +24,8 @@ import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Queue;
|
||||
import java.util.TreeMap;
|
||||
import org.jackhuang.hellominecraft.C;
|
||||
import org.jackhuang.hellominecraft.HMCLog;
|
||||
@@ -223,23 +221,26 @@ public final class MinecraftVersionManager extends IMinecraftProvider {
|
||||
|
||||
@Override
|
||||
public List<ModInfo> listMods() {
|
||||
if (profile.getSelectedMinecraftVersion() == null) return Arrays.asList();
|
||||
if (profile.getSelectedMinecraftVersion() == null) return new ArrayList<>();
|
||||
File modsFolder = new File(getRunDirectory(profile.getSelectedMinecraftVersion().id), "mods");
|
||||
ArrayList<ModInfo> mods = new ArrayList<>();
|
||||
Queue<File> queue = new LinkedList<>();
|
||||
queue.add(modsFolder);
|
||||
while (!queue.isEmpty()) {
|
||||
File dir = queue.poll();
|
||||
File[] fs = dir.listFiles();
|
||||
if (fs != null)
|
||||
for (File f : fs)
|
||||
if (ModInfo.isFileMod(f)) {
|
||||
ModInfo m = ModInfo.readModInfo(f);
|
||||
if (m != null)
|
||||
mods.add(m);
|
||||
} else if (f.isDirectory())
|
||||
queue.add(f);
|
||||
}
|
||||
File[] fs = modsFolder.listFiles();
|
||||
if (fs != null)
|
||||
for (File f : fs)
|
||||
if (ModInfo.isFileMod(f)) {
|
||||
ModInfo m = ModInfo.readModInfo(f);
|
||||
if (m != null)
|
||||
mods.add(m);
|
||||
} else if (f.isDirectory()) {
|
||||
File[] ss = f.listFiles();
|
||||
if (ss != null)
|
||||
for (File ff : ss)
|
||||
if (ModInfo.isFileMod(ff)) {
|
||||
ModInfo m = ModInfo.readModInfo(ff);
|
||||
if (m != null)
|
||||
mods.add(m);
|
||||
}
|
||||
}
|
||||
Collections.sort(mods);
|
||||
return mods;
|
||||
}
|
||||
@@ -255,7 +256,7 @@ public final class MinecraftVersionManager extends IMinecraftProvider {
|
||||
File ff = l.getFilePath(baseFolder);
|
||||
if (!ff.exists()) {
|
||||
String libURL = downloadType.getProvider().getLibraryDownloadURL() + "/";
|
||||
libURL = l.getDownloadURL(libURL, downloadType);
|
||||
libURL = downloadType.getProvider().getParsedLibraryDownloadURL(l.getDownloadURL(libURL, downloadType));
|
||||
if (libURL != null)
|
||||
downloadLibraries.add(new DownloadLibraryJob(l.name, libURL, ff));
|
||||
}
|
||||
|
||||
@@ -175,7 +175,6 @@ public class GameSettingsPanel extends javax.swing.JPanel implements DropTargetL
|
||||
ppmManage.add(itm);
|
||||
//</editor-fold>
|
||||
|
||||
lstExternalMods.getColumnModel().getSelectionModel().setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
|
||||
if (lstExternalMods.getColumnModel().getColumnCount() > 0) {
|
||||
lstExternalMods.getColumnModel().getColumn(0).setMinWidth(17);
|
||||
lstExternalMods.getColumnModel().getColumn(0).setPreferredWidth(17);
|
||||
@@ -1143,11 +1142,12 @@ btnRefreshLiteLoader.addActionListener(new java.awt.event.ActionListener() {
|
||||
String url;
|
||||
File filepath = IOUtils.tryGetCanonicalFile(IOUtils.currentDirWithSeparator() + "forge-installer.jar");
|
||||
if (v.installer != null) {
|
||||
url = v.installer;
|
||||
url = Settings.getInstance().getDownloadSource().getProvider().getParsedLibraryDownloadURL(v.installer);
|
||||
TaskWindow.getInstance()
|
||||
.addTask(new FileDownloadTask(url, filepath).setTag("forge"))
|
||||
.addTask(new ForgeInstaller(profile.getMinecraftProvider(), filepath, v))
|
||||
.start();
|
||||
refreshVersions();
|
||||
}
|
||||
}//GEN-LAST:event_btnDownloadForgeActionPerformed
|
||||
|
||||
@@ -1169,6 +1169,7 @@ btnRefreshLiteLoader.addActionListener(new java.awt.event.ActionListener() {
|
||||
.addTask(new FileDownloadTask(filepath).registerPreviousResult(task).setTag("optifine"))
|
||||
.addTask(new OptiFineInstaller(profile, v.selfVersion, filepath))
|
||||
.start();
|
||||
refreshVersions();
|
||||
}
|
||||
}//GEN-LAST:event_btnDownloadOptifineActionPerformed
|
||||
|
||||
@@ -1186,6 +1187,7 @@ btnRefreshLiteLoader.addActionListener(new java.awt.event.ActionListener() {
|
||||
TaskWindow.getInstance()
|
||||
.addTask(task).addTask(new LiteLoaderInstaller(profile, (LiteLoaderInstallerVersion) v).registerPreviousResult(task))
|
||||
.start();
|
||||
refreshVersions();
|
||||
}//GEN-LAST:event_btnInstallLiteLoaderActionPerformed
|
||||
|
||||
private void btnRefreshLiteLoaderActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnRefreshLiteLoaderActionPerformed
|
||||
@@ -1369,6 +1371,7 @@ btnRefreshLiteLoader.addActionListener(new java.awt.event.ActionListener() {
|
||||
try {
|
||||
if (!ModInfo.isFileMod(f) || mods == null) return false;
|
||||
File newf = profile.getFolder("mods");
|
||||
if(newf == null) return false;
|
||||
newf.mkdirs();
|
||||
newf = new File(newf, f.getName());
|
||||
FileUtils.copyFile(f, newf);
|
||||
@@ -1537,7 +1540,7 @@ btnRefreshLiteLoader.addActionListener(new java.awt.event.ActionListener() {
|
||||
if (mcVersion == null || profile == null) return;
|
||||
type.getList((value) -> {
|
||||
if (value != null)
|
||||
TaskWindow.getInstance().addTask(type.getDownloadTask(Settings.getInstance().getDownloadSource().getProvider())).start();
|
||||
SwingUtilities.invokeLater(() -> TaskWindow.getInstance().addTask(type.getDownloadTask(Settings.getInstance().getDownloadSource().getProvider())).start());
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1694,13 +1697,22 @@ btnRefreshLiteLoader.addActionListener(new java.awt.event.ActionListener() {
|
||||
// </editor-fold>
|
||||
// <editor-fold>
|
||||
List<ModInfo> mods;
|
||||
private final Object lockMod = new Object();
|
||||
|
||||
private void reloadMods() {
|
||||
mods = profile.getMinecraftProvider().listMods();
|
||||
SwingUtils.clearDefaultTable(lstExternalMods);
|
||||
DefaultTableModel model = (DefaultTableModel) lstExternalMods.getModel();
|
||||
for (ModInfo info : mods)
|
||||
model.addRow(new Object[]{info.isActive(), info.getFileName(), info.version});
|
||||
new Thread(() -> {
|
||||
synchronized (lockMod) {
|
||||
mods = profile.getMinecraftProvider().listMods();
|
||||
SwingUtilities.invokeLater(() -> {
|
||||
synchronized (lockMod) {
|
||||
SwingUtils.clearDefaultTable(lstExternalMods);
|
||||
DefaultTableModel model = (DefaultTableModel) lstExternalMods.getModel();
|
||||
for (ModInfo info : mods)
|
||||
model.addRow(new Object[]{info.isActive(), info.getFileName(), info.version});
|
||||
}
|
||||
});
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
|
||||
// </editor-fold>
|
||||
|
||||
@@ -4,7 +4,6 @@ import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import org.jackhuang.hellominecraft.logging.logger.Logger;
|
||||
import org.jackhuang.hellominecraft.utils.StrUtils;
|
||||
import org.jackhuang.mojang.authlib.properties.Property;
|
||||
@@ -30,7 +29,6 @@ public abstract class BaseUserAuthentication
|
||||
private UserType userType;
|
||||
|
||||
protected BaseUserAuthentication(AuthenticationService authenticationService) {
|
||||
Objects.requireNonNull(authenticationService);
|
||||
this.authenticationService = authenticationService;
|
||||
}
|
||||
|
||||
|
||||
@@ -9,10 +9,10 @@ import java.net.Proxy;
|
||||
import java.net.URL;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import org.jackhuang.hellominecraft.logging.logger.Logger;
|
||||
import org.jackhuang.hellominecraft.utils.system.IOUtils;
|
||||
import org.jackhuang.hellominecraft.utils.NetUtils;
|
||||
import org.jackhuang.hellominecraft.utils.Utils;
|
||||
|
||||
public abstract class HttpAuthenticationService extends BaseAuthenticationService {
|
||||
|
||||
@@ -20,7 +20,6 @@ public abstract class HttpAuthenticationService extends BaseAuthenticationServic
|
||||
private final Proxy proxy;
|
||||
|
||||
protected HttpAuthenticationService(Proxy proxy) {
|
||||
Objects.requireNonNull(proxy);
|
||||
this.proxy = proxy;
|
||||
}
|
||||
|
||||
@@ -29,7 +28,6 @@ public abstract class HttpAuthenticationService extends BaseAuthenticationServic
|
||||
}
|
||||
|
||||
protected HttpURLConnection createUrlConnection(URL url) throws IOException {
|
||||
Objects.requireNonNull(url);
|
||||
LOGGER.debug("Opening connection to " + url);
|
||||
HttpURLConnection connection = (HttpURLConnection) url.openConnection(this.proxy);
|
||||
connection.setConnectTimeout(15000);
|
||||
@@ -39,9 +37,9 @@ public abstract class HttpAuthenticationService extends BaseAuthenticationServic
|
||||
}
|
||||
|
||||
public String performPostRequest(URL url, String post, String contentType) throws IOException {
|
||||
Objects.requireNonNull(url);
|
||||
Objects.requireNonNull(post);
|
||||
Objects.requireNonNull(contentType);
|
||||
Utils.requireNonNull(url);
|
||||
Utils.requireNonNull(post);
|
||||
Utils.requireNonNull(contentType);
|
||||
HttpURLConnection connection = createUrlConnection(url);
|
||||
byte[] postAsBytes = post.getBytes("UTF-8");
|
||||
|
||||
@@ -90,7 +88,7 @@ public abstract class HttpAuthenticationService extends BaseAuthenticationServic
|
||||
|
||||
public String performGetRequest(URL url)
|
||||
throws IOException {
|
||||
Objects.requireNonNull(url);
|
||||
Utils.requireNonNull(url);
|
||||
HttpURLConnection connection = createUrlConnection(url);
|
||||
|
||||
LOGGER.debug("Reading data from " + url);
|
||||
|
||||
@@ -31,5 +31,5 @@ buildscript {
|
||||
}
|
||||
|
||||
retrolambda {
|
||||
javaVersion = JavaVersion.VERSION_1_7
|
||||
javaVersion = JavaVersion.VERSION_1_6
|
||||
}
|
||||
@@ -30,8 +30,6 @@
|
||||
<DimensionLayout dim="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="lblTotalProgress" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="pgsTotal" max="32767" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
@@ -44,14 +42,11 @@
|
||||
<DimensionLayout dim="1">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<Component id="srlDownload" pref="289" max="32767" attributes="0"/>
|
||||
<Component id="srlDownload" pref="291" max="32767" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="btnCancel" alignment="1" min="-2" pref="22" max="-2" attributes="0"/>
|
||||
<Group type="103" alignment="1" groupAlignment="3" attributes="0">
|
||||
<Component id="pgsTotal" alignment="3" min="-2" pref="22" max="-2" attributes="0"/>
|
||||
<Component id="lblTotalProgress" alignment="3" min="-2" pref="22" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<Component id="pgsTotal" alignment="1" min="-2" pref="22" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
</Group>
|
||||
@@ -69,13 +64,6 @@
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnCancelActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="lblTotalProgress">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
|
||||
<ResourceString bundle="org/jackhuang/hellominecraft/launcher/I18N.properties" key="taskwindow.total_progress" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JProgressBar" name="pgsTotal">
|
||||
<Properties>
|
||||
<Property name="stringPainted" type="boolean" value="true"/>
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
*/
|
||||
package org.jackhuang.hellominecraft.tasks;
|
||||
|
||||
import java.awt.EventQueue;
|
||||
import java.util.ArrayList;
|
||||
import javax.swing.SwingUtilities;
|
||||
import org.jackhuang.hellominecraft.C;
|
||||
@@ -52,6 +51,13 @@ public class TaskWindow extends javax.swing.JDialog
|
||||
initComponents();
|
||||
|
||||
setLocationRelativeTo(null);
|
||||
|
||||
if (lstDownload.getColumnModel().getColumnCount() > 1) {
|
||||
int i = 35;
|
||||
lstDownload.getColumnModel().getColumn(1).setMinWidth(i);
|
||||
lstDownload.getColumnModel().getColumn(1).setMaxWidth(i);
|
||||
lstDownload.getColumnModel().getColumn(1).setPreferredWidth(i);
|
||||
}
|
||||
|
||||
setModal(true);
|
||||
}
|
||||
@@ -96,7 +102,6 @@ public class TaskWindow extends javax.swing.JDialog
|
||||
private void initComponents() {
|
||||
|
||||
btnCancel = new javax.swing.JButton();
|
||||
lblTotalProgress = new javax.swing.JLabel();
|
||||
pgsTotal = new javax.swing.JProgressBar();
|
||||
srlDownload = new javax.swing.JScrollPane();
|
||||
lstDownload = new javax.swing.JTable();
|
||||
@@ -117,8 +122,6 @@ public class TaskWindow extends javax.swing.JDialog
|
||||
}
|
||||
});
|
||||
|
||||
lblTotalProgress.setText(bundle.getString("taskwindow.total_progress")); // NOI18N
|
||||
|
||||
pgsTotal.setStringPainted(true);
|
||||
|
||||
lstDownload.setModel(SwingUtils.makeDefaultTableModel(new String[]{C.i18n("taskwindow.file_name"), C.i18n("taskwindow.download_progress")}, new Class[]{String.class, String.class}, new boolean[]{false,false})
|
||||
@@ -133,8 +136,6 @@ public class TaskWindow extends javax.swing.JDialog
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addComponent(lblTotalProgress)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(pgsTotal, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(btnCancel)
|
||||
@@ -144,13 +145,11 @@ public class TaskWindow extends javax.swing.JDialog
|
||||
layout.setVerticalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addComponent(srlDownload, javax.swing.GroupLayout.DEFAULT_SIZE, 289, Short.MAX_VALUE)
|
||||
.addComponent(srlDownload, javax.swing.GroupLayout.DEFAULT_SIZE, 291, Short.MAX_VALUE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(btnCancel, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(pgsTotal, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(lblTotalProgress, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE)))
|
||||
.addComponent(pgsTotal, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addContainerGap())
|
||||
);
|
||||
|
||||
@@ -166,19 +165,18 @@ public class TaskWindow extends javax.swing.JDialog
|
||||
tasks.clear();
|
||||
|
||||
if (!this.failReasons.isEmpty()) {
|
||||
MessageBox.Show(StrUtils.parseParams("", failReasons.toArray(), "\n"), C.i18n("message.error"), MessageBox.ERROR_MESSAGE);
|
||||
SwingUtilities.invokeLater(() -> MessageBox.Show(StrUtils.parseParams("", failReasons.toArray(), "\n"), C.i18n("message.error"), MessageBox.ERROR_MESSAGE));
|
||||
failReasons.clear();
|
||||
}
|
||||
|
||||
if (!suc) {
|
||||
EventQueue.invokeLater(taskList::abort);
|
||||
SwingUtilities.invokeLater(taskList::abort);
|
||||
HMCLog.log("Tasks have been canceled by user.");
|
||||
}
|
||||
}//GEN-LAST:event_formWindowClosed
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
private javax.swing.JButton btnCancel;
|
||||
private javax.swing.JLabel lblTotalProgress;
|
||||
private javax.swing.JTable lstDownload;
|
||||
private javax.swing.JProgressBar pgsTotal;
|
||||
private javax.swing.JScrollPane srlDownload;
|
||||
@@ -197,7 +195,6 @@ public class TaskWindow extends javax.swing.JDialog
|
||||
SwingUtils.setValueAt(lstDownload, pgs + "%", idx, 1);
|
||||
progresses.set(idx, pgs);
|
||||
}
|
||||
if (task.isParallelExecuting()) return;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -228,7 +228,7 @@ public class FileDownloadTask extends Task implements PreviousResult<File>, Prev
|
||||
|
||||
@Override
|
||||
public String getInfo() {
|
||||
return C.i18n("download") + ": " + url + " " + filePath;
|
||||
return C.i18n("download") + ": " + url;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -21,6 +21,7 @@ import org.jackhuang.hellominecraft.utils.system.MessageBox;
|
||||
import org.jackhuang.hellominecraft.C;
|
||||
import org.jackhuang.hellominecraft.utils.functions.NonConsumer;
|
||||
import org.jackhuang.hellominecraft.HMCLog;
|
||||
import org.jackhuang.hellominecraft.utils.system.OS;
|
||||
|
||||
/**
|
||||
*
|
||||
|
||||
@@ -186,4 +186,8 @@ public final class Utils {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static void requireNonNull(Object o) {
|
||||
if (o == null) throw new NullPointerException("Oh dear, there is a problem...");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
*/
|
||||
package org.jackhuang.hellominecraft.utils.system;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -59,9 +60,30 @@ public class Java {
|
||||
return name.hashCode();
|
||||
}
|
||||
|
||||
/*
|
||||
-----------------------------------
|
||||
MAC OS X
|
||||
-----------------------------------
|
||||
*/
|
||||
public static List<Java> queryAllJDKInMac() {
|
||||
List<Java> ans = new ArrayList<>();
|
||||
if (new File("/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home").exists())
|
||||
ans.add(new Java("JRE", "/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home"));
|
||||
File f = new File("/Library/Java/JavaVirtualMachines/");
|
||||
if (f.exists())
|
||||
for (File a : f.listFiles())
|
||||
ans.add(new Java(a.getName(), new File(a, "Contents/Home").getAbsolutePath()));
|
||||
return ans;
|
||||
}
|
||||
|
||||
/*
|
||||
-----------------------------------
|
||||
WINDOWS
|
||||
-----------------------------------
|
||||
*/
|
||||
public static List<Java> queryAllJavaHomeInWindowsByReg() {
|
||||
List<Java> ans = new ArrayList<>();
|
||||
try {
|
||||
List<Java> ans = new ArrayList<>();
|
||||
List<String> javas = queryRegSubFolders("HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Runtime Environment");
|
||||
for (String java : javas) {
|
||||
int s = 0;
|
||||
@@ -82,21 +104,19 @@ public class Java {
|
||||
if (javahome != null)
|
||||
ans.add(new Java(java.substring("HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\".length()), javahome));
|
||||
}
|
||||
return ans;
|
||||
} catch (IOException | InterruptedException ex) {
|
||||
HMCLog.err("Faield to query java", ex);
|
||||
return null;
|
||||
}
|
||||
return ans;
|
||||
}
|
||||
|
||||
private static List<String> queryRegSubFolders(String location) throws IOException, InterruptedException {
|
||||
String[] cmd = new String[]{"cmd", "/c", "reg", "query", location};
|
||||
List<String> l = IOUtils.readProcessByInputStream(cmd);
|
||||
List<String> ans = new ArrayList<>();
|
||||
for (String line : l) {
|
||||
for (String line : l)
|
||||
if (line.startsWith(location) && !line.equals(location))
|
||||
ans.add(line);
|
||||
}
|
||||
return ans;
|
||||
}
|
||||
|
||||
@@ -104,20 +124,20 @@ public class Java {
|
||||
String[] cmd = new String[]{"cmd", "/c", "reg", "query", location, "/v", name};
|
||||
List<String> l = IOUtils.readProcessByInputStream(cmd);
|
||||
boolean last = false;
|
||||
for(String s : l) {
|
||||
if(s.trim().isEmpty()) continue;
|
||||
for (String s : l) {
|
||||
if (s.trim().isEmpty()) continue;
|
||||
if (last == true && s.trim().startsWith(name)) {
|
||||
int begins = s.indexOf(name);
|
||||
if(begins > 0) {
|
||||
if (begins > 0) {
|
||||
s = s.substring(begins + name.length());
|
||||
begins = s.indexOf("REG_SZ");
|
||||
if(begins > 0) {
|
||||
if (begins > 0) {
|
||||
s = s.substring(begins + "REG_SZ".length());
|
||||
return s.trim();
|
||||
}
|
||||
}
|
||||
}
|
||||
if(s.trim().equals(location)) last = true;
|
||||
if (s.trim().equals(location)) last = true;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ configure(install.repositories.mavenInstaller) {
|
||||
}
|
||||
|
||||
retrolambda {
|
||||
javaVersion = JavaVersion.VERSION_1_7
|
||||
javaVersion = JavaVersion.VERSION_1_6
|
||||
}
|
||||
|
||||
dependencies {
|
||||
|
||||
@@ -31,5 +31,5 @@ buildscript {
|
||||
}
|
||||
|
||||
retrolambda {
|
||||
javaVersion = JavaVersion.VERSION_1_7
|
||||
javaVersion = JavaVersion.VERSION_1_6
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user