Try to fix some problems

This commit is contained in:
huanghongxun
2015-12-10 14:06:56 +08:00
parent 52c43bde06
commit e91d4c5477
20 changed files with 1920 additions and 1264 deletions

View File

@@ -25,7 +25,7 @@ import org.jackhuang.hellominecraft.logging.logger.Logger;
*/
public class HMCLog {
public static Logger logger = new Logger("HMC");
public static Logger logger = new Logger("Hello Minecraft!");
public static void log(String message) {
logger.info(message);

View File

@@ -17,6 +17,7 @@
*/
package org.jackhuang.hellominecraft.tasks;
import java.awt.EventQueue;
import java.util.ArrayList;
import java.util.LinkedList;
import javax.swing.SwingUtilities;
@@ -31,13 +32,13 @@ import org.jackhuang.hellominecraft.utils.SwingUtils;
* @author huangyuhui
*/
public class TaskWindow extends javax.swing.JDialog
implements ProgressProviderListener, Runnable, DoingDoneListener<Task> {
implements ProgressProviderListener, Runnable, DoingDoneListener<Task> {
private static final TaskWindow instance = new TaskWindow();
private static final TaskWindow INSTANCE = new TaskWindow();
private static TaskWindow inst() {
instance.clean();
return instance;
INSTANCE.clean();
return INSTANCE;
}
public static TaskWindowFactory getInstance() {
@@ -200,12 +201,13 @@ implements ProgressProviderListener, Runnable, DoingDoneListener<Task> {
private javax.swing.JScrollPane srlDownload;
// End of variables declaration//GEN-END:variables
ArrayList<Task> tasks = new ArrayList<>();
ArrayList<Integer> progresses = new ArrayList<>();
final ArrayList<Task> tasks = new ArrayList<>();
final ArrayList<Integer> progresses = new ArrayList<>();
@Override
public void setProgress(Task task, int progress, int max) {
SwingUtilities.invokeLater(() -> {
if (task == null) return;
int idx = tasks.indexOf(task);
if (idx == -1)
return;
@@ -229,7 +231,7 @@ implements ProgressProviderListener, Runnable, DoingDoneListener<Task> {
task.setProgressProviderListener(this);
SwingUtilities.invokeLater(() -> {
if (taskList == null)
if (taskList == null || task == null)
return;
tasks.add(task);
progresses.add(0);
@@ -245,7 +247,7 @@ implements ProgressProviderListener, Runnable, DoingDoneListener<Task> {
@Override
public void onDone(Task task) {
SwingUtilities.invokeLater(() -> {
if (taskList == null)
if (taskList == null || task == null)
return;
pgsTotal.setMaximum(taskList.taskCount());
pgsTotal.setValue(pgsTotal.getValue() + 1);
@@ -261,7 +263,7 @@ implements ProgressProviderListener, Runnable, DoingDoneListener<Task> {
@Override
public void onFailed(Task task) {
SwingUtilities.invokeLater(() -> {
if (taskList == null)
if (taskList == null || task == null)
return;
failReasons.add(task.getInfo() + ": " + (null == task.getFailReason() ? "No exception" : (StrUtils.isBlank(task.getFailReason().getLocalizedMessage()) ? task.getFailReason().getClass().getSimpleName() : task.getFailReason().getLocalizedMessage())));
pgsTotal.setMaximum(taskList.taskCount());
@@ -283,7 +285,7 @@ implements ProgressProviderListener, Runnable, DoingDoneListener<Task> {
@Override
public void setStatus(Task task, String sta) {
SwingUtilities.invokeLater(() -> {
if (taskList == null)
if (taskList == null || task == null)
return;
int idx = tasks.indexOf(task);
if (idx == -1)
@@ -295,6 +297,7 @@ implements ProgressProviderListener, Runnable, DoingDoneListener<Task> {
public static class TaskWindowFactory {
LinkedList<Task> ll = new LinkedList<>();
boolean flag;
public TaskWindowFactory addTask(Task t) {
ll.add(t);
@@ -302,14 +305,28 @@ implements ProgressProviderListener, Runnable, DoingDoneListener<Task> {
}
public boolean start() {
synchronized (instance) {
if (instance.isVisible())
return false;
TaskWindow tw = inst();
for (Task t : ll)
tw.addTask(t);
return tw.start();
}
Runnable r = () -> {
synchronized (INSTANCE) {
if (INSTANCE.isVisible()) {
flag = false;
return;
}
TaskWindow tw = inst();
for (Task t : ll)
tw.addTask(t);
flag = tw.start();
}
};
if (EventQueue.isDispatchThread())
r.run();
else
try {
EventQueue.invokeAndWait(r);
} catch (Exception e) {
HMCLog.err("Failed to invokeAndWait, the UI will work abnormally.", e);
r.run();
}
return flag;
}
}
}

View File

@@ -30,7 +30,6 @@ import java.util.Map;
import org.jackhuang.hellominecraft.HMCLog;
import org.jackhuang.hellominecraft.utils.system.IOUtils;
import rx.Observable;
import rx.subscriptions.Subscriptions;
/**
*
@@ -160,13 +159,12 @@ public final class NetUtils {
}
public static Observable<String> getRx(String url) {
return Observable.create(t1 -> {
return Observable.createWithEmptySubscription(t1 -> {
try {
t1.onNext(get(url));
} catch(Exception e) {
t1.onError(e);
}
return Subscriptions.empty();
});
}
}

View File

@@ -131,12 +131,15 @@ public class SwingUtils {
* Clear the JTable
*
* @param table JTable with DefaultTableModel.
*
* @return To make the code succinct
*/
public static void clearDefaultTable(JTable table) {
public static DefaultTableModel clearDefaultTable(JTable table) {
DefaultTableModel model = (DefaultTableModel) table.getModel();
while (model.getRowCount() > 0)
model.removeRow(0);
table.updateUI();
return model;
}
public static void appendLast(JTable table, Object... elements) {

View File

@@ -93,9 +93,10 @@ public final class Utils {
return new ImageIcon(i.getImage().getScaledInstance(x, y, Image.SCALE_SMOOTH));
}
public static ImageIcon searchBackgroundImage(ImageIcon background, String bgpath, int width, int height) {
public static ImageIcon searchBackgroundImage(ImageIcon init, String bgpath, int width, int height) {
Random r = new Random();
boolean loaded = false;
ImageIcon background = init;
// bgpath
if (StrUtils.isNotBlank(bgpath) && !loaded) {
@@ -142,6 +143,7 @@ public final class Utils {
}
}
if (background == null) return init;
return background;
}

File diff suppressed because it is too large Load Diff

View File

@@ -240,7 +240,7 @@ mainwindow.enter_script_name=\u8f93\u5165\u8981\u751f\u6210\u811a\u672c\u7684\u6
mainwindow.make_launch_succeed=\u542f\u52a8\u811a\u672c\u5df2\u751f\u6210\u5b8c\u6bd5:
mainwindow.no_version=\u672a\u627e\u5230\u4efb\u4f55\u7248\u672c\uff0c\u662f\u5426\u8fdb\u5165\u6e38\u620f\u4e0b\u8f7d\uff1f
launcher.about=<html>\u9ed8\u8ba4\u80cc\u666f\u56fe\u6765\u81eaLiberty Dome\u670d\u52a1\u5668\u3002<br/>\u5173\u4e8e\u4f5c\u8005\uff1a<br/>\n\u767e\u5ea6ID\uff1ahuanghongxun20<br/>\nmcbbs\uff1ahuanghongxun<br/>\n\u90ae\u7bb1\uff1ahuanghongxun2008@126.com<br/>\nMinecraft Forum ID: klkl6523<br/>\n\u6b22\u8fce\u63d0\u4ea4Bug\u54e6<br/>\nCopyright (c) 2013-2015 huangyuhui.<br/>\u514d\u8d23\u58f0\u660e\uff1aMinecraft\u8f6f\u4ef6\u7248\u6743\u5f52Mojang AB\u6240\u6709\uff0c\u6e38\u620f\u7531\u4e8e\u8bef\u64cd\u4f5c\u672c\u542f\u52a8\u5668\u800c\u4e22\u5931\u6570\u636e\u7684\u6982\u4e0d\u8d1f\u8d23\u3002<br/>\u672c\u542f\u52a8\u5668\u5728GPLv2\u534f\u8bae\u4e0b\u5f00\u6e90:http://github.com/huanghongxun/HMCL/</html>
launcher.about=<html>\u9ed8\u8ba4\u80cc\u666f\u56fe\u6765\u81eaLiberty Dome\u670d\u52a1\u5668\u3002<br/>\u5173\u4e8e\u4f5c\u8005\uff1a<br/>\n\u767e\u5ea6ID\uff1ahuanghongxun20<br/>\nmcbbs\uff1ahuanghongxun<br/>\n\u90ae\u7bb1\uff1ahuanghongxun2008@126.com<br/>\nMinecraft Forum ID: klkl6523<br/>\n\u6b22\u8fce\u63d0\u4ea4Bug\u54e6<br/>\nCopyright (c) 2013-2015 huangyuhui.<br/>\u514d\u8d23\u58f0\u660e\uff1aMinecraft\u8f6f\u4ef6\u7248\u6743\u5f52Mojang AB\u6240\u6709\uff0c\u6e38\u620f\u7531\u4e8e\u8bef\u64cd\u4f5c\u672c\u542f\u52a8\u5668\u800c\u4e22\u5931\u6570\u636e\u7684\u6982\u4e0d\u8d1f\u8d23\u3002<br/>\u672c\u542f\u52a8\u5668\u5728GPLv3\u534f\u8bae\u4e0b\u5f00\u6e90:http://github.com/huanghongxun/HMCL/<br/>\u672c\u8f6f\u4ef6\u4f7f\u7528\u4e86\u57fa\u4e8eApache License 2.0\u7684RxJava\u548cGson\u9879\u76ee\uff0c\u611f\u8c22\u8d21\u732e\u8005\u3002</html>
launcher.download_source=\u4e0b\u8f7d\u6e90
launcher.background_location=\u80cc\u666f\u5730\u5740
launcher.exit_failed=\u5f3a\u5236\u9000\u51fa\u5931\u8d25\uff0c\u53ef\u80fd\u662fForge 1.7.10\u53ca\u66f4\u9ad8\u7248\u672c\u5bfc\u81f4\u7684\uff0c\u65e0\u6cd5\u89e3\u51b3\u3002

View File

@@ -240,7 +240,7 @@ mainwindow.enter_script_name=Enter the script name.
mainwindow.make_launch_succeed=Finished script creation.
mainwindow.no_version=No version found. Switch to Game Downloads Tab?
launcher.about=<html>About Author<br/>\nEmail\uff1ahuanghongxun2008@126.com<br/>\nMinecraft Forum ID: klkl6523<br/>\nCopyright (c) 2013 huangyuhui<br/>Opened source under GPL v2 licence:http://github.com/huanghongxun/HMCL/</html>
launcher.about=<html>About Author<br/>\nEmail\uff1ahuanghongxun2008@126.com<br/>\nMinecraft Forum ID: klkl6523<br/>\nCopyright (c) 2013 huangyuhui<br/>Opened source under GPL v3 license:http://github.com/huanghongxun/HMCL/<br/>This software used project RxJava and Gson which is under Apache License 2.0, thanks contributors.</html>
launcher.download_source=Download Source
launcher.background_location=Background Location
launcher.exit_failed=Failed to shutdown.

View File

@@ -240,7 +240,7 @@ mainwindow.enter_script_name=\u8f38\u5165\u8981\u751f\u6210\u8173\u672c\u7684\u6
mainwindow.make_launch_succeed=\u555f\u52d5\u8173\u672c\u5df2\u751f\u6210\u5b8c\u7562:
mainwindow.no_version=\u672a\u627e\u5230\u4efb\u4f55\u7248\u672c\uff0c\u662f\u5426\u9032\u5165\u904a\u6232\u4e0b\u8f09\uff1f
launcher.about=<html>\u9ed8\u8a8d\u80cc\u666f\u5716\u4f86\u81eaLiberty Dome\u670d\u52d9\u5668\u3002 <br/>\u95dc\u65bc\u4f5c\u8005\uff1a<br/>\n\u767e\u5ea6ID\uff1ahuanghongxun20<br/>\nmcbbs\uff1ahuanghongxun<br/>\n\u90f5\u7bb1\uff1ahuanghongxun2008@126.com<br/>\nMinecraft Forum ID: klkl6523<br />\n\u6b61\u8fce\u63d0\u4ea4Bug\u54e6<br/>\nCopyright (c) 2013-2015 huangyuhui.<br/>\u514d\u8cac\u8072\u660e\uff1aMinecraft\u8edf\u4ef6\u7248\u6b0a\u6b78Mojang AB\u6240\u6709\uff0c\u904a\u6232\u7531\u65bc\u8aa4\u64cd\u4f5c\u672c\u555f\u52d5\u5668\u800c\u4e1f\u5931\u6578\u64da\u7684\u6982\u4e0d\u8ca0\u8cac\u3002 <br/>\u672c\u555f\u52d5\u5668\u5728GPLv2\u5354\u8b70\u4e0b\u958b\u6e90:http://github.com/huanghongxun/HMCL/</html>
launcher.about=<html>\u9ed8\u8a8d\u80cc\u666f\u5716\u4f86\u81eaLiberty Dome\u670d\u52d9\u5668\u3002 <br/>\u95dc\u65bc\u4f5c\u8005\uff1a<br/>\n\u767e\u5ea6ID\uff1ahuanghongxun20<br/>\nmcbbs\uff1ahuanghongxun<br/>\n\u90f5\u7bb1\uff1ahuanghongxun2008@126.com<br/>\nMinecraft Forum ID: klkl6523<br />\n\u6b61\u8fce\u63d0\u4ea4Bug\u54e6<br/>\nCopyright (c) 2013-2015 huangyuhui.<br/>\u514d\u8cac\u8072\u660e\uff1aMinecraft\u8edf\u4ef6\u7248\u6b0a\u6b78Mojang AB\u6240\u6709\uff0c\u904a\u6232\u7531\u65bc\u8aa4\u64cd\u4f5c\u672c\u555f\u52d5\u5668\u800c\u4e1f\u5931\u6578\u64da\u7684\u6982\u4e0d\u8ca0\u8cac\u3002 <br/>\u672c\u555f\u52d5\u5668\u5728GPLv3\u5354\u8b70\u4e0b\u958b\u6e90:http://github.com/huanghongxun/HMCL/<br/>\u672c\u8edf\u4ef6\u4f7f\u7528\u4e86\u57fa\u65bcApache License 2.0\u7684RxJava\u548cGson\u9805\u76ee\uff0c\u611f\u8b1d\u8ca2\u737b\u8005\u3002</html>
launcher.download_source=\u4e0b\u8f09\u6e90
launcher.background_location=\u80cc\u666f\u5730\u5740
launcher.exit_failed=\u5f37\u5236\u9000\u51fa\u5931\u6557\uff0c\u53ef\u80fd\u662fForge 1.7.10\u53ca\u66f4\u9ad8\u7248\u672c\u5c0e\u81f4\u7684\uff0c\u7121\u6cd5\u89e3\u6c7a\u3002

View File

@@ -237,7 +237,7 @@ mainwindow.enter_script_name=\u8f93\u5165\u8981\u751f\u6210\u811a\u672c\u7684\u6
mainwindow.make_launch_succeed=\u542f\u52a8\u811a\u672c\u5df2\u751f\u6210\u5b8c\u6bd5:
mainwindow.no_version=\u672a\u627e\u5230\u4efb\u4f55\u7248\u672c\uff0c\u662f\u5426\u8fdb\u5165\u6e38\u620f\u4e0b\u8f7d\uff1f
launcher.about=<html>\u9ed8\u8ba4\u80cc\u666f\u56fe\u6765\u81eaLiberty Dome\u670d\u52a1\u5668\u3002<br/>\u5173\u4e8e\u4f5c\u8005\uff1a<br/>\n\u767e\u5ea6ID\uff1ahuanghongxun20<br/>\nmcbbs\uff1ahuanghongxun<br/>\n\u90ae\u7bb1\uff1ahuanghongxun2008@126.com<br/>\nMinecraft Forum ID: klkl6523<br/>\n\u6b22\u8fce\u63d0\u4ea4Bug\u54e6<br/>\nCopyright (c) 2013-2015 huangyuhui.<br/>\u514d\u8d23\u58f0\u660e\uff1aMinecraft\u8f6f\u4ef6\u7248\u6743\u5f52Mojang AB\u6240\u6709\uff0c\u6e38\u620f\u7531\u4e8e\u8bef\u64cd\u4f5c\u672c\u542f\u52a8\u5668\u800c\u4e22\u5931\u6570\u636e\u7684\u6982\u4e0d\u8d1f\u8d23\u3002<br/>\u672c\u542f\u52a8\u5668\u5728GPLv2\u534f\u8bae\u4e0b\u5f00\u6e90:http://github.com/huanghongxun/HMCL/</html>
launcher.about=<html>\u9ed8\u8ba4\u80cc\u666f\u56fe\u6765\u81eaLiberty Dome\u670d\u52a1\u5668\u3002<br/>\u5173\u4e8e\u4f5c\u8005\uff1a<br/>\n\u767e\u5ea6ID\uff1ahuanghongxun20<br/>\nmcbbs\uff1ahuanghongxun<br/>\n\u90ae\u7bb1\uff1ahuanghongxun2008@126.com<br/>\nMinecraft Forum ID: klkl6523<br/>\n\u6b22\u8fce\u63d0\u4ea4Bug\u54e6<br/>\nCopyright (c) 2013-2015 huangyuhui.<br/>\u514d\u8d23\u58f0\u660e\uff1aMinecraft\u8f6f\u4ef6\u7248\u6743\u5f52Mojang AB\u6240\u6709\uff0c\u6e38\u620f\u7531\u4e8e\u8bef\u64cd\u4f5c\u672c\u542f\u52a8\u5668\u800c\u4e22\u5931\u6570\u636e\u7684\u6982\u4e0d\u8d1f\u8d23\u3002<br/>\u672c\u542f\u52a8\u5668\u5728GPLv3\u534f\u8bae\u4e0b\u5f00\u6e90:http://github.com/huanghongxun/HMCL/<br/>\u672c\u8f6f\u4ef6\u4f7f\u7528\u4e86\u57fa\u4e8eApache License 2.0\u7684RxJava\u548cGson\u9879\u76ee\uff0c\u611f\u8c22\u8d21\u732e\u8005\u3002</html>
launcher.download_source=\u4e0b\u8f7d\u6e90
launcher.background_location=\u80cc\u666f\u5730\u5740
launcher.exit_failed=\u5f3a\u5236\u9000\u51fa\u5931\u8d25\uff0c\u53ef\u80fd\u662fForge 1.7.10\u53ca\u66f4\u9ad8\u7248\u672c\u5bfc\u81f4\u7684\uff0c\u65e0\u6cd5\u89e3\u51b3\u3002