Revision: 2340
http://sourceforge.net/p/swingme/code/2340
Author: yuranet
Date: 2015-03-14 17:18:32 +0000 (Sat, 14 Mar 2015)
Log Message:
-----------
IO works even when there is no UI
Modified Paths:
--------------
me4se/src/javax/microedition/io/Connector.java
me4se/src/javax/microedition/lcdui/Canvas.java
me4se/src/javax/microedition/lcdui/CommandList.java
me4se/src/javax/microedition/lcdui/Display.java
me4se/src/javax/microedition/lcdui/Displayable.java
me4se/src/javax/microedition/lcdui/ScmDeviceComponent.java
me4se/src/javax/microedition/lcdui/ScmDisplayable.java
me4se/src/javax/microedition/lcdui/ScmIcon.java
me4se/src/javax/microedition/lcdui/StringItem.java
me4se/src/javax/microedition/media/Manager.java
me4se/src/javax/microedition/midlet/ApplicationManager.java
me4se/src/javax/microedition/midlet/MIDlet.java
me4se/src/org/me4se/impl/lcdui/FontInfo.java
me4se/src/org/me4se/impl/skins/Skin.java
me4se/src/org/me4se/psi/comm/gcf/comm/CommConnectionImpl.java
me4se/src/org/me4se/psi/j2se/rms/RecordStoreInitializer.java
me4se/src/org/me4se/psi/java1/gcf/http/HttpConnectionImpl.java
me4se/src/org/me4se/psi/java1/gcf/socket/SocketConnectionImpl.java
Modified: me4se/src/javax/microedition/io/Connector.java
===================================================================
--- me4se/src/javax/microedition/io/Connector.java 2015-03-14 12:44:18 UTC (rev 2339)
+++ me4se/src/javax/microedition/io/Connector.java 2015-03-14 17:18:32 UTC (rev 2340)
@@ -89,7 +89,7 @@
try {
// System.out.println("try to load " + name);
- ConnectionImpl connection = (ConnectionImpl) ApplicationManager.getInstance().instantiate(name);
+ ConnectionImpl connection = (ConnectionImpl) ApplicationManager.instantiate(name);
// System.out.println("loaded.");
Modified: me4se/src/javax/microedition/lcdui/Canvas.java
===================================================================
--- me4se/src/javax/microedition/lcdui/Canvas.java 2015-03-14 12:44:18 UTC (rev 2339)
+++ me4se/src/javax/microedition/lcdui/Canvas.java 2015-03-14 17:18:32 UTC (rev 2340)
@@ -144,7 +144,7 @@
public static final int KEY_STAR = '*';
ScmCanvas component = new ScmCanvas(this);
- boolean hasPointerEvents = !"false".equalsIgnoreCase(ApplicationManager.getInstance().getProperty("touch_screen"));;
+ boolean hasPointerEvents = !"false".equalsIgnoreCase(ApplicationManager.getProperty("touch_screen"));;
/**
* @ME4SE INTERNAL
Modified: me4se/src/javax/microedition/lcdui/CommandList.java
===================================================================
--- me4se/src/javax/microedition/lcdui/CommandList.java 2015-03-14 12:44:18 UTC (rev 2339)
+++ me4se/src/javax/microedition/lcdui/CommandList.java 2015-03-14 17:18:32 UTC (rev 2340)
@@ -7,14 +7,13 @@
class CommandList extends List implements CommandListener {
private Displayable owner;
- ApplicationManager manager = ApplicationManager.getInstance();
- private Command cancel = new Command(manager.getProperty("cancel.command.label", "Cancel"), Command.CANCEL, 0);
+ private Command cancel = new Command(ApplicationManager.getProperty("cancel.command.label", "Cancel"), Command.CANCEL, 0);
protected CommandList(Displayable d) {
super("Select", Choice.IMPLICIT);
- String t = manager.getProperty("options.menu.title");
+ String t = ApplicationManager.getProperty("options.menu.title");
if (t != null)
setTitle(t);
Modified: me4se/src/javax/microedition/lcdui/Display.java
===================================================================
--- me4se/src/javax/microedition/lcdui/Display.java 2015-03-14 12:44:18 UTC (rev 2339)
+++ me4se/src/javax/microedition/lcdui/Display.java 2015-03-14 17:18:32 UTC (rev 2340)
@@ -216,8 +216,8 @@
if (manager.currentlyShown instanceof Canvas)
((Canvas) manager.currentlyShown).hideNotify();
- d.container.setX(manager.getIntProperty("screen.x", 0));
- d.container.setY(manager.getIntProperty("screen.y", 0));
+ d.container.setX(ApplicationManager.getIntProperty("screen.x", 0));
+ d.container.setY(ApplicationManager.getIntProperty("screen.y", 0));
if (d instanceof Alert) {
Alert alert = (Alert) d;
@@ -298,22 +298,22 @@
public int getColor(int type) {
switch (type) {
case COLOR_BACKGROUND:
- return ApplicationManager.getInstance().getIntProperty("item.background",
+ return ApplicationManager.getIntProperty("item.background",
0x0ffffff);
case COLOR_FOREGROUND:
- return ApplicationManager.getInstance().getIntProperty("item.foreground",
+ return ApplicationManager.getIntProperty("item.foreground",
0);
case COLOR_HIGHLIGHTED_BACKGROUND:
- return ApplicationManager.getInstance().getIntProperty(
+ return ApplicationManager.getIntProperty(
"item.focus.background", 0x00000ff);
case COLOR_HIGHLIGHTED_FOREGROUND:
- return ApplicationManager.getInstance().getIntProperty(
+ return ApplicationManager.getIntProperty(
"item.focus.foreground", 0);
case COLOR_BORDER:
- return ApplicationManager.getInstance().getIntProperty("item.border",
+ return ApplicationManager.getIntProperty("item.border",
0x0ffffff);
case COLOR_HIGHLIGHTED_BORDER:
- return ApplicationManager.getInstance().getIntProperty(
+ return ApplicationManager.getIntProperty(
"item.focus.border", 0x08888ff);
}
return 0x08888ff;
Modified: me4se/src/javax/microedition/lcdui/Displayable.java
===================================================================
--- me4se/src/javax/microedition/lcdui/Displayable.java 2015-03-14 12:44:18 UTC (rev 2339)
+++ me4se/src/javax/microedition/lcdui/Displayable.java 2015-03-14 17:18:32 UTC (rev 2340)
@@ -114,7 +114,7 @@
}
if (selectButtonRequired
- && ApplicationManager.getInstance().getProperty("command.menu.select",
+ && ApplicationManager.getProperty("command.menu.select",
"").toUpperCase().startsWith("SOFT")) {
v.insertElementAt(new CmdInfo(ScmDisplayable.ITEM_SELECT_COMMAND, null),
0);
Modified: me4se/src/javax/microedition/lcdui/ScmDeviceComponent.java
===================================================================
--- me4se/src/javax/microedition/lcdui/ScmDeviceComponent.java 2015-03-14 12:44:18 UTC (rev 2339)
+++ me4se/src/javax/microedition/lcdui/ScmDeviceComponent.java 2015-03-14 17:18:32 UTC (rev 2340)
@@ -48,7 +48,7 @@
setFocusable(focusable);
- String props = (ApplicationManager.getInstance().getProperty(type));
+ String props = ApplicationManager.getProperty(type);
if (props != null) {
// System.out.println("props: "+props);
location = Csv.decode(props);
Modified: me4se/src/javax/microedition/lcdui/ScmDisplayable.java
===================================================================
--- me4se/src/javax/microedition/lcdui/ScmDisplayable.java 2015-03-14 12:44:18 UTC (rev 2339)
+++ me4se/src/javax/microedition/lcdui/ScmDisplayable.java 2015-03-14 17:18:32 UTC (rev 2340)
@@ -18,7 +18,7 @@
static String[] TYPES = { "null", "SCREEN", "BACK", "CANCEL", "OK", "HELP", "STOP", "EXIT", "ITEM" };
- static final Command OPTIONS_COMMAND = new Command(ApplicationManager.getInstance().getProperty(
+ static final Command OPTIONS_COMMAND = new Command(ApplicationManager.getProperty(
"options.command.label", "Menu"), Command.SCREEN, 0);
/**
@@ -113,11 +113,11 @@
}
int cnt;
- if (manager.getProperty("skin") == null)
+ if (ApplicationManager.getProperty("skin") == null)
cnt = 2;
else {
cnt = 0;
- while (manager.getProperty("softbutton." + (cnt)) != null) {
+ while (ApplicationManager.getProperty("softbutton." + (cnt)) != null) {
cnt++;
}
}
@@ -168,7 +168,7 @@
shutdownTrigger = "POWER".equals(key);
- String timeout = manager.getProperty("me4se.timeout");
+ String timeout = ApplicationManager.getProperty("me4se.timeout");
if (timeout != null && !timeout.equals("")) {
if (manager.firstKeyPress == 0) {
manager.firstKeyPress = System.currentTimeMillis();
@@ -176,7 +176,7 @@
if (manager.timeoutImage == null) {
try {
- manager.timeoutImage = manager.getImage(manager.getProperty("me4se.timeout-image", "/timeout.png"));
+ manager.timeoutImage = manager.getImage(ApplicationManager.getProperty("me4se.timeout-image", "/timeout.png"));
} catch (IOException e) {
throw new RuntimeException(e);
}
@@ -252,7 +252,7 @@
CmdInfo ci = (CmdInfo) commands.elementAt(i);
Command cmd = ci.command;
- String desired[] = ApplicationManager.split(ApplicationManager.getInstance().getProperty(
+ String desired[] = ApplicationManager.split(ApplicationManager.getProperty(
"command.keys." + cmd.getTypeName()));
for (int j = 0; j < desired.length; j++) {
@@ -295,7 +295,7 @@
CmdInfo ci = (CmdInfo) remaining.elementAt(i);
Command cmd = ci.command;
- String[] desired = ApplicationManager.split(ApplicationManager.getInstance().getProperty(
+ String[] desired = ApplicationManager.split(ApplicationManager.getProperty(
cmd == OPTIONS_COMMAND ? "command.menu.activate" : ("command.keys." + cmd.getTypeName())));
if (cmd == OPTIONS_COMMAND && desired.length == 0) {
@@ -352,26 +352,24 @@
public void doLayout() {
- ApplicationManager manager = ApplicationManager.getInstance();
-
int x = 0;
int y = 0;
int w = manager.screenWidth;
int h = manager.screenHeight;
- x = manager.getIntProperty("screenPaintableRegion.x", x);
- y = manager.getIntProperty("screenPaintableRegion.y", y);
- w = manager.getIntProperty("screenPaintableRegion.width", w);
- h = manager.getIntProperty("screenPaintableRegion.height", h);
+ x = ApplicationManager.getIntProperty("screenPaintableRegion.x", x);
+ y = ApplicationManager.getIntProperty("screenPaintableRegion.y", y);
+ w = ApplicationManager.getIntProperty("screenPaintableRegion.width", w);
+ h = ApplicationManager.getIntProperty("screenPaintableRegion.height", h);
if (fullScreen) {
- x = manager.getIntProperty("canvasPaintableRegion.x", x);
- y = manager.getIntProperty("canvasPaintableRegion.y", y);
- w = manager.getIntProperty("canvasPaintableRegion.width", w);
- h = manager.getIntProperty("canvasPaintableRegion.height", h);
+ x = ApplicationManager.getIntProperty("canvasPaintableRegion.x", x);
+ y = ApplicationManager.getIntProperty("canvasPaintableRegion.y", y);
+ w = ApplicationManager.getIntProperty("canvasPaintableRegion.width", w);
+ h = ApplicationManager.getIntProperty("canvasPaintableRegion.height", h);
}
- if (manager.getProperty("skin") == null && h == manager.screenHeight && softButtons!=null && softButtons.length > 0
+ if (ApplicationManager.getProperty("skin") == null && h == manager.screenHeight && softButtons!=null && softButtons.length > 0
&& softButtons[0] != null) {
h -= softButtons[0].getHeight();
}
Modified: me4se/src/javax/microedition/lcdui/ScmIcon.java
===================================================================
--- me4se/src/javax/microedition/lcdui/ScmIcon.java 2015-03-14 12:44:18 UTC (rev 2339)
+++ me4se/src/javax/microedition/lcdui/ScmIcon.java 2015-03-14 17:18:32 UTC (rev 2340)
@@ -39,14 +39,14 @@
for (Enumeration e = manager.properties.keys(); e.hasMoreElements();) {
String key = (String) e.nextElement();
if (key.toLowerCase().startsWith(seek)) {
- String value = manager.getProperty(key).trim();
+ String value = ApplicationManager.getProperty(key).trim();
String state = key.substring(seek.length());
// System.out.println("item state '" + state + "' for " + name + " is " + value);
if (!value.equals("")) {
BufferedImage image;
try {
- image = manager.getImage(ApplicationManager.concatPath(manager.getProperty("skin"), value));
+ image = manager.getImage(ApplicationManager.concatPath(ApplicationManager.getProperty("skin"), value));
int w = image.getWidth();
int h = image.getHeight();
if(w > getWidth()) setWidth(w);
@@ -83,7 +83,7 @@
}
public static ScmIcon create(String name) {
- String propStr = ApplicationManager.getInstance().getProperty(name);
+ String propStr = ApplicationManager.getProperty(name);
// System.out.println("creating icon '" + name + "'; entry found: " + propStr);
return (propStr == null) ? null : new ScmIcon(name, propStr);
}
Modified: me4se/src/javax/microedition/lcdui/StringItem.java
===================================================================
--- me4se/src/javax/microedition/lcdui/StringItem.java 2015-03-14 12:44:18 UTC (rev 2339)
+++ me4se/src/javax/microedition/lcdui/StringItem.java 2015-03-14 17:18:32 UTC (rev 2340)
@@ -55,8 +55,8 @@
}
if (text != null && text.length() > 0) {
- WordWrap ww = new WordWrap(FontInfo.getFontInfo(type).font, text, ApplicationManager.getInstance()
- .getIntProperty("screenPaintableRegion.width", ApplicationManager.getInstance().screenWidth));
+ WordWrap ww = new WordWrap(FontInfo.getFontInfo(type).font, text,
+ ApplicationManager.getIntProperty("screenPaintableRegion.width", ApplicationManager.getInstance().screenWidth));
int p0 = 0;
Modified: me4se/src/javax/microedition/media/Manager.java
===================================================================
--- me4se/src/javax/microedition/media/Manager.java 2015-03-14 12:44:18 UTC (rev 2339)
+++ me4se/src/javax/microedition/media/Manager.java 2015-03-14 17:18:32 UTC (rev 2340)
@@ -105,7 +105,7 @@
try {
- BasicMMPlayer player = (BasicMMPlayer) ApplicationManager.getInstance().instantiate(className);
+ BasicMMPlayer player = (BasicMMPlayer) ApplicationManager.instantiate(className);
player.setSource((BasicMMDataSource) source);
return player;
}
Modified: me4se/src/javax/microedition/midlet/ApplicationManager.java
===================================================================
--- me4se/src/javax/microedition/midlet/ApplicationManager.java 2015-03-14 12:44:18 UTC (rev 2339)
+++ me4se/src/javax/microedition/midlet/ApplicationManager.java 2015-03-14 17:18:32 UTC (rev 2340)
@@ -344,7 +344,7 @@
* @return
*/
- public Object instantiate(String name) throws ClassNotFoundException {
+ public static Object instantiate(String name) throws ClassNotFoundException {
String implementation = getProperty("me4se.implementation");
@@ -483,12 +483,16 @@
}
}
- public String getProperty(String name) {
- String result = properties.getProperty(name.toLowerCase());
+ public static String getProperty(String name) {
+ // if we dont have a ApplicationManager, no point in making it, as properties will be empty.
+ ApplicationManager am = isInitialized() ? getInstance() : null;
+
+ String result = am == null ? null : am.properties.getProperty(name.toLowerCase());
+
if (result == null) {
- if (applet != null) {
- result = applet.getParameter(name);
+ if (am !=null && am.applet != null) {
+ result = am.applet.getParameter(name);
}
else {
try {
@@ -497,11 +501,10 @@
catch(Throwable th) { }
}
}
-
return result;
}
- public String getProperty(String name, String dflt) {
+ public static String getProperty(String name, String dflt) {
String result = getProperty(name);
return result != null ? result : dflt;
}
@@ -877,10 +880,9 @@
}
}
- public int getIntProperty(String name, int dflt) {
+ public static int getIntProperty(String name, int dflt) {
try {
- return Integer.decode(
- (String) ApplicationManager.manager.getProperty(name)).intValue();
+ return Integer.decode(getProperty(name)).intValue();
} catch (Exception e) {
return dflt;
}
Modified: me4se/src/javax/microedition/midlet/MIDlet.java
===================================================================
--- me4se/src/javax/microedition/midlet/MIDlet.java 2015-03-14 12:44:18 UTC (rev 2339)
+++ me4se/src/javax/microedition/midlet/MIDlet.java 2015-03-14 17:18:32 UTC (rev 2340)
@@ -88,7 +88,7 @@
String result = ApplicationManager.getInstance().jadFile.getValue(key);
if (result == null) {
- result = ApplicationManager.getInstance().getProperty(key);
+ result = ApplicationManager.getProperty(key);
}
// System.out.println("getAppProperty("+key+")='"+result+"'");
Modified: me4se/src/org/me4se/impl/lcdui/FontInfo.java
===================================================================
--- me4se/src/org/me4se/impl/lcdui/FontInfo.java 2015-03-14 12:44:18 UTC (rev 2339)
+++ me4se/src/org/me4se/impl/lcdui/FontInfo.java 2015-03-14 17:18:32 UTC (rev 2340)
@@ -67,7 +67,7 @@
? type
: (property.equals("font") ? "font." + type : type + "." + property);
- String v = ApplicationManager.getInstance().getProperty(fullName);
+ String v = ApplicationManager.getProperty(fullName);
//System.out.println("property: '"+fullName+ (v == null ? "' not found " : "' found: '"+v+"'"));
@@ -203,7 +203,7 @@
int height;
- if ("ME4SE-iPhoneEmulator".equals(ApplicationManager.getInstance().getProperty("microedition.platform"))) {
+ if ("ME4SE-iPhoneEmulator".equals(ApplicationManager.getProperty("microedition.platform"))) {
if (font != null) {
height = font.height;
}
Modified: me4se/src/org/me4se/impl/skins/Skin.java
===================================================================
--- me4se/src/org/me4se/impl/skins/Skin.java 2015-03-14 12:44:18 UTC (rev 2339)
+++ me4se/src/org/me4se/impl/skins/Skin.java 2015-03-14 17:18:32 UTC (rev 2340)
@@ -154,7 +154,7 @@
}
public int getInt(String name, int dflt) {
- return ApplicationManager.getInstance().getIntProperty(name, dflt);
+ return ApplicationManager.getIntProperty(name, dflt);
}
public String getName(String name) {
@@ -175,7 +175,7 @@
public Skin() {
ApplicationManager manager = ApplicationManager.getInstance();
// setBackground(Color.white);
- skinUrl = manager.getProperty("skin");
+ skinUrl = ApplicationManager.getProperty("skin");
try {
BufferedReader reader =
@@ -244,7 +244,7 @@
e.hasMoreElements();
) {
String key = (String) e.nextElement();
- String value = (String) manager.getProperty(key);
+ String value = ApplicationManager.getProperty(key);
try {
Modified: me4se/src/org/me4se/psi/comm/gcf/comm/CommConnectionImpl.java
===================================================================
--- me4se/src/org/me4se/psi/comm/gcf/comm/CommConnectionImpl.java 2015-03-14 12:44:18 UTC (rev 2339)
+++ me4se/src/org/me4se/psi/comm/gcf/comm/CommConnectionImpl.java 2015-03-14 17:18:32 UTC (rev 2340)
@@ -54,7 +54,7 @@
*/
public void open(String url, int mode, boolean timeouts) throws IOException {
- String useCommPortsString = ApplicationManager.getInstance().getProperty("me4se.comm.enable");
+ String useCommPortsString = ApplicationManager.getProperty("me4se.comm.enable");
if (useCommPortsString != null) {
Hashtable ht = new Hashtable();
Modified: me4se/src/org/me4se/psi/j2se/rms/RecordStoreInitializer.java
===================================================================
--- me4se/src/org/me4se/psi/j2se/rms/RecordStoreInitializer.java 2015-03-14 12:44:18 UTC (rev 2339)
+++ me4se/src/org/me4se/psi/j2se/rms/RecordStoreInitializer.java 2015-03-14 17:18:32 UTC (rev 2340)
@@ -29,7 +29,7 @@
}
else {
- RecordStoreImpl.rmsDir = new File(am.getProperty("rms.home", ".rms"));
+ RecordStoreImpl.rmsDir = new File(ApplicationManager.getProperty("rms.home", ".rms"));
boolean hasRms;
try {
Modified: me4se/src/org/me4se/psi/java1/gcf/http/HttpConnectionImpl.java
===================================================================
--- me4se/src/org/me4se/psi/java1/gcf/http/HttpConnectionImpl.java 2015-03-14 12:44:18 UTC (rev 2339)
+++ me4se/src/org/me4se/psi/java1/gcf/http/HttpConnectionImpl.java 2015-03-14 17:18:32 UTC (rev 2340)
@@ -108,7 +108,7 @@
Log.log(Log.IO, "entering http open '" + url + "' mode: " + mode);
this.url = new URL(url);
- proxy = url.startsWith("https") ? null : ApplicationManager.getInstance().getProperty("me4se.httpproxy");
+ proxy = url.startsWith("https") ? null : ApplicationManager.getProperty("me4se.httpproxy");
Log.log(Log.IO, "using proxy: " + proxy);
@@ -120,8 +120,8 @@
con.setDoOutput(doOutput);
con.setDoInput(true);
// con.setRequestProperty("connection", "close");
- con.setRequestProperty("User-Agent", ApplicationManager.getInstance().getProperty("me4se.useragent",
- ApplicationManager.getInstance().getProperty("microedition.platform", "MobileRunner-J2ME")));
+ con.setRequestProperty("User-Agent", ApplicationManager.getProperty("me4se.useragent",
+ ApplicationManager.getProperty("microedition.platform", "MobileRunner-J2ME")));
if (proxy != null) {
con.setRequestProperty("me4se-target-url", url);
}
Modified: me4se/src/org/me4se/psi/java1/gcf/socket/SocketConnectionImpl.java
===================================================================
--- me4se/src/org/me4se/psi/java1/gcf/socket/SocketConnectionImpl.java 2015-03-14 12:44:18 UTC (rev 2339)
+++ me4se/src/org/me4se/psi/java1/gcf/socket/SocketConnectionImpl.java 2015-03-14 17:18:32 UTC (rev 2340)
@@ -26,7 +26,7 @@
throw new IOException("socket blocked by no.socket file");
}
- String proxy = ApplicationManager.getInstance().getProperty("me4se.socketproxy");
+ String proxy = ApplicationManager.getProperty("me4se.socketproxy");
// System.out.println("Connecting to: "+url);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|