Allowing the initial status location and color to be set in case an error occurs before getdown.txt has been read (as is the case when the user rejects our certificate).
This commit is contained in:
@@ -6,13 +6,13 @@
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||
// provided that the following conditions are met:
|
||||
//
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
// conditions and the following disclaimer.
|
||||
// 2. Redistributions in binary form must reproduce the above copyright notice, this list of
|
||||
// conditions and the following disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
// INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
||||
// PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
|
||||
@@ -104,7 +104,7 @@ public class Application
|
||||
|
||||
/** Background image specifiers for {@link RotatingBackgrounds}. */
|
||||
public String[] rotatingBackgrounds;
|
||||
|
||||
|
||||
/** The error background image for {@link RotatingBackgrounds}. */
|
||||
public String errorBackground;
|
||||
|
||||
@@ -546,7 +546,7 @@ public class Application
|
||||
_jvmargs.add(jvmargs[ii]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Add the launch specific JVM arguments
|
||||
for (String arg : _baseJvmArgs) {
|
||||
_jvmargs.add(arg);
|
||||
@@ -1258,31 +1258,51 @@ public class Application
|
||||
protected Rectangle parseRect (HashMap<String,Object> cdata, String name, Rectangle def)
|
||||
{
|
||||
String value = (String)cdata.get(name);
|
||||
Rectangle rect = parseRect(value);
|
||||
if (rect == null) {
|
||||
log.warning("Ignoring invalid '" + name + "' config '" + value + "'.");
|
||||
} else {
|
||||
return rect;
|
||||
}
|
||||
return def;
|
||||
}
|
||||
|
||||
public static Rectangle parseRect (String value)
|
||||
{
|
||||
if (!StringUtil.isBlank(value)) {
|
||||
int[] v = StringUtil.parseIntArray(value);
|
||||
if (v != null && v.length == 4) {
|
||||
return new Rectangle(v[0], v[1], v[2], v[3]);
|
||||
} else {
|
||||
log.warning("Ignoring invalid '" + name + "' config '" + value + "'.");
|
||||
}
|
||||
}
|
||||
return def;
|
||||
return null;
|
||||
}
|
||||
|
||||
/** Used to parse color specifications from the config file. */
|
||||
protected Color parseColor (HashMap<String,Object> cdata, String name, Color def)
|
||||
{
|
||||
String value = (String)cdata.get(name);
|
||||
if (!StringUtil.isBlank(value)) {
|
||||
try {
|
||||
return new Color(Integer.parseInt(value, 16));
|
||||
} catch (Exception e) {
|
||||
log.warning("Ignoring invalid '" + name + "' config '" + value + "'.");
|
||||
}
|
||||
Color color = parseColor(value);
|
||||
if (color == null) {
|
||||
log.warning("Ignoring invalid '" + name + "' config '" + value + "'.");
|
||||
} else {
|
||||
return color;
|
||||
}
|
||||
return def;
|
||||
}
|
||||
|
||||
public static Color parseColor (String hexValue)
|
||||
{
|
||||
if (!StringUtil.isBlank(hexValue)) {
|
||||
try {
|
||||
return new Color(Integer.parseInt(hexValue, 16));
|
||||
} catch (NumberFormatException e) {
|
||||
log.warning("Ignoring invalid color", "hexValue", hexValue, "exception", e);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/** Parses a list of strings from the config file. */
|
||||
protected String[] parseList (HashMap<String,Object> cdata, String name)
|
||||
{
|
||||
@@ -1324,7 +1344,7 @@ public class Application
|
||||
|
||||
protected ArrayList<String> _jvmargs = new ArrayList<String>();
|
||||
protected ArrayList<String> _appargs = new ArrayList<String>();
|
||||
|
||||
|
||||
protected String[] _baseJvmArgs = new String[0];
|
||||
|
||||
protected Object[] _signers;
|
||||
|
||||
@@ -6,13 +6,13 @@
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||
// provided that the following conditions are met:
|
||||
//
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
// conditions and the following disclaimer.
|
||||
// 2. Redistributions in binary form must reproduce the above copyright notice, this list of
|
||||
// conditions and the following disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
// INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
||||
// PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
|
||||
@@ -23,8 +23,10 @@
|
||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
package com.threerings.getdown.launcher;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Container;
|
||||
import java.awt.Image;
|
||||
import java.awt.Rectangle;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
@@ -34,15 +36,12 @@ import java.net.URL;
|
||||
import javax.swing.JApplet;
|
||||
import javax.swing.JPanel;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.PrintStream;
|
||||
import java.util.Map;
|
||||
|
||||
import com.samskivert.util.RunAnywhere;
|
||||
import com.samskivert.util.StringUtil;
|
||||
|
||||
import com.threerings.getdown.data.Application;
|
||||
import com.threerings.getdown.util.ConfigUtil;
|
||||
|
||||
import static com.threerings.getdown.Log.log;
|
||||
@@ -111,7 +110,7 @@ public class GetdownApplet extends JApplet
|
||||
jvmargs = params.split(",");
|
||||
for (int ii = 0; ii < jvmargs.length; ii++) {
|
||||
jvmargs[ii] = "-D" + jvmargs[ii];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
@@ -141,9 +140,9 @@ public class GetdownApplet extends JApplet
|
||||
protected void exit (int exitCode) {
|
||||
_app.releaseLock();
|
||||
// Redirect to the URL in 'redirect_on_finish' if we completed successfully.
|
||||
// This allows us to use some javascript on that page to close Getdown's
|
||||
// This allows us to use some javascript on that page to close Getdown's
|
||||
// browser window. I'd prefer to use the javascript bridge from the applet
|
||||
// rather than redirecting, but calling JSObject.getWindow(this).call("close")
|
||||
// rather than redirecting, but calling JSObject.getWindow(this).call("close")
|
||||
// doesn't seem to do anything.
|
||||
if (getParameter("redirect_on_finish") != null && exitCode == 0) {
|
||||
URL dest;
|
||||
@@ -163,6 +162,17 @@ public class GetdownApplet extends JApplet
|
||||
}
|
||||
};
|
||||
|
||||
// configure the status/progress text in case something goes horribly wrong before we
|
||||
// get a chance to read getdown.txt (like when the user rejects write permissions)
|
||||
Rectangle statusBounds = Application.parseRect(getParameter("ui.status"));
|
||||
if (statusBounds != null) {
|
||||
_getdown._ifc.status = statusBounds;
|
||||
}
|
||||
Color statusColor = Application.parseColor(getParameter("ui.status_text"));
|
||||
if (statusColor != null) {
|
||||
_getdown._ifc.statusText = statusColor;
|
||||
}
|
||||
|
||||
// set up our user interface immediately
|
||||
_getdown.preInit();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user