X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=src%2Forg%2Fxwt%2FPlatform.java;h=8c4df6e69a93b1d1774ac791d9c8a7aaebdc52bb;hb=16ad8b9430571d806f2aeb18ec472a277ff69423;hp=5b1f0ac1879dc6dbfdd51090bedf549b645db52e;hpb=6a96430e10e27fc1de5754cb5add705f929dd109;p=org.ibex.core.git
diff --git a/src/org/xwt/Platform.java b/src/org/xwt/Platform.java
index 5b1f0ac..8c4df6e 100644
--- a/src/org/xwt/Platform.java
+++ b/src/org/xwt/Platform.java
@@ -1,10 +1,11 @@
-// Copyright 2003 Adam Megacz, see the COPYING file for licensing [GPL]
+// Copyright 2004 Adam Megacz, see the COPYING file for licensing [GPL]
package org.xwt;
import java.lang.reflect.*;
import java.net.*;
import java.io.*;
import java.util.*;
+import org.xwt.js.*;
import org.xwt.util.*;
/**
@@ -17,32 +18,21 @@ import org.xwt.util.*;
* it in the org.xwt.plat package, and add code to this file's static
* block to detect the new platform.
*/
-public class Platform {
+public abstract class Platform {
- // Static Data /////////////////////////////////////////////////////////////////////////////////////
-
- /**
- * set to true during the delivery of a KeyPressed:C-v/A-v or Press3; it is safe to use a
- * 'global' here, since message delivery is single-threaded and non-preemptable
- */
- static boolean clipboardReadEnabled = false;
-
- /** The appropriate Platform object for this JVM */
- static Platform platform = null;
+ public Platform() { platform = this; }
- /** true if proxy autodetection has already been run */
- static boolean alreadyDetectedProxy = false;
-
- /** the result of proxy autodetection */
- static org.xwt.HTTP.Proxy cachedProxyInfo = null;
+ // Static Data /////////////////////////////////////////////////////////////////////////////////////
- /** the current build */
- public static String build = "unknown";
+ static boolean clipboardReadEnabled = false; ///< true iff inside a C-v/A-v/Press3 trap handler
+ static Platform platform = null; ///< The appropriate Platform object for this JVM
+ static boolean alreadyDetectedProxy = false; ///< true if proxy autodetection has already been run
+ static org.xwt.HTTP.Proxy cachedProxyInfo = null; ///< the result of proxy autodetection
+ public static String build = "unknown"; ///< the current build
// VM Detection Logic /////////////////////////////////////////////////////////////////////
- /** do-nothing method that forces <clinit> to run */
- public static void forceLoad() { }
+ public static void forceLoad() { } ///< do-nothing method that forces <clinit> to run
// If you create a new subclass of Platform, you should add logic
// here to detect it. Do not reference your class directly -- use
@@ -57,94 +47,82 @@ public class Platform {
String os_version = System.getProperty("os.version", "");
String platform_class = null;
- if (os_name.startsWith("Darwin")) platform_class = "Darwin";
- else if (vendor.startsWith("Free Software Foundation")) {
+ if (vendor.startsWith("Free Software Foundation")) {
if (os_name.startsWith("Window")) platform_class = "Win32";
+ else if (os_name.startsWith("Linux")) platform_class = "Linux";
+ else if (os_name.startsWith("SunOS")) platform_class = "Solaris";
+ else if (os_name.startsWith("Solaris")) platform_class = "Solaris";
else platform_class = "X11";
- } else if (version.startsWith("1.1") && vendor.startsWith("Netscape")) platform_class = "Netscape";
- else if (version.startsWith("1.1") && vendor.startsWith("Microsoft")) platform_class = "Microsoft";
+ }
else if (!version.startsWith("1.0") && !version.startsWith("1.1")) platform_class = "Java2";
- /*
- // Disable 2d hardware acceleration on Jaguar
- if (os_name.equals("Mac OS X") && os_version.startsWith("10.2")) System.setProperty("com.apple.hwaccel", "false");
- */
-
- if (platform_class != null) {
- platform = (Platform)Class.forName("org.xwt.plat." + platform_class).newInstance();
- platform.init();
+ if (platform_class == null) {
+ Log.error(Platform.class, "Unable to detect JVM");
+ criticalAbort("Unable to detect JVM");
}
+ if (platform_class != null) Class.forName("org.xwt.plat." + platform_class).newInstance();
+
+ String term = Platform.getEnv("TERM");
+ Log.color = term != null && term.length() != 0 && !term.equals("cygwin");
+
try {
build = (String)Class.forName("org.xwt.Build").getField("build").get(null);
+ Log.diag(Platform.class, "XWT build: " + build);
} catch (ClassNotFoundException cnfe) {
+ Log.warn(Platform.class, "XWT build: unknown");
} catch (Exception e) {
- if (Log.on) Log.log(Platform.class, "exception while detecting build:");
- if (Log.on) Log.log(Platform.class, e);
- }
- if (Log.on) Log.log(Platform.class, "XWT build: " + build);
-
- if (Log.on) Log.log(Platform.class, "XWT VM detection: vendor = " + vendor);
- if (Log.on) Log.log(Platform.class, " version = " + version);
- if (Log.on) Log.log(Platform.class, " os = " + os_name + " [version " + os_version + "]");
-
- if (platform_class == null) {
- if (Log.on) Log.log(Platform.class, "Unable to detect JVM");
- new Platform().criticalAbort("Unable to detect JVM");
+ Log.info(Platform.class, "exception while detecting build:");
+ Log.info(Platform.class, e);
}
- if (Log.on) Log.log(Platform.class, " platform = " + platform.getDescriptiveName());
- if (Log.on) Log.log(Platform.class, " class = " + platform.getClass().getName());
+ Log.diag(Platform.class, "XWT VM detection: vendor = " + vendor);
+ Log.diag(Platform.class, " version = " + version);
+ Log.diag(Platform.class, " os = " + os_name + " [version " + os_version + "]");
+ Log.diag(Platform.class, " platform = " + platform.getDescriptiveName());
+ Log.diag(Platform.class, " class = " + platform.getClass().getName());
platform.postInit();
} catch (Exception e) {
- if (Log.on) Log.log(Platform.class, "Exception while trying to detect JVM");
- if (Log.on) Log.log(Platform.class, e);
- new Platform().criticalAbort("Unable to detect JVM");
+ Log.error(Platform.class, "Exception while trying to detect JVM");
+ Log.error(Platform.class, e);
+ criticalAbort("Unable to detect JVM");
}
}
- // Methods to be Overridden ////////////////////////////////////////////////////////////////////
+ // Methods to be Overridden ///////////////////////////////////////////////////////////////////
- /** a string describing the VM */
- protected String getDescriptiveName() { return "Generic Java 1.1 VM"; }
-
- /** this initializes the platform; code in here can invoke methods on Platform since Platform.platform has already been set */
- protected void init() { }
- protected void postInit() { }
-
- /** creates and returns a doublebuffer 'belonging' to owner; we need to associate PixelBuffers to surfaces
- * due to AWT 1.1 requirements (definately for Navigator, possibly also for MSJVM).
- */
- public static PixelBuffer createPixelBuffer(int w, int h, Surface s) { return platform._createPixelBuffer(w, h, s); }
+ protected Surface _createSurface(Box b, boolean framed) { return null; }
+ protected Picture _createPicture(JS r) { return null; }
protected PixelBuffer _createPixelBuffer(int w, int h, Surface owner) { return null; }
-
- /** creates and returns a picture */
- public static Picture createPicture(int[] data, int w, int h) { return platform._createPicture(data, w, h); }
- public static Picture createAlphaOnlyPicture(byte[] data, int w, int h) { return platform._createAlphaOnlyPicture(data, w, h); }
-
- protected Picture _createPicture(int[] b, int w, int h) { return null; }
- protected Picture _createAlphaOnlyPicture(byte[] b, int w, int h) {
- int[] b2 = new int[b.length];
- for(int i=0;i