Lines 50-55
Link Here
|
50 |
import java.io.FileReader; |
50 |
import java.io.FileReader; |
51 |
import java.io.IOException; |
51 |
import java.io.IOException; |
52 |
import java.util.ArrayList; |
52 |
import java.util.ArrayList; |
|
|
53 |
import java.util.jar.JarFile; |
53 |
import org.netbeans.spi.mobility.cldcplatform.CLDCPlatformDescriptor; |
54 |
import org.netbeans.spi.mobility.cldcplatform.CLDCPlatformDescriptor; |
54 |
import org.netbeans.spi.mobility.cldcplatform.CustomCLDCPlatformConfigurator; |
55 |
import org.netbeans.spi.mobility.cldcplatform.CustomCLDCPlatformConfigurator; |
55 |
import org.openide.ErrorManager; |
56 |
import org.openide.ErrorManager; |
Lines 66-75
Link Here
|
66 |
} |
67 |
} |
67 |
|
68 |
|
68 |
private static final String keyFiles[] = new String[] { |
69 |
private static final String keyFiles[] = new String[] { |
69 |
"simulator/handhelds.manifest.txt", "bin/rapc.exe", //NOI18N |
70 |
"bin/rapc.exe", //NOI18N |
70 |
"bin/preverify.exe", "bin/JavaLoader.exe", "lib/net_rim_api.jar"}; //NOI18N |
71 |
"bin/preverify.exe", "bin/JavaLoader.exe", "lib/net_rim_api.jar"}; //NOI18N |
71 |
|
72 |
//"simulator/handhelds.manifest.txt", |
72 |
private static final String BB_PLATFORM_NAME = "BlackBerry Device Simulator 2.3"; //NOI18N |
|
|
73 |
|
73 |
|
74 |
private static final String CLASSPATH= "${platform.home}/lib/net_rim_api.jar"; //NOI18N |
74 |
private static final String CLASSPATH= "${platform.home}/lib/net_rim_api.jar"; //NOI18N |
75 |
|
75 |
|
Lines 88-97
Link Here
|
88 |
if (!isPossiblePlatform(f)) return null; |
88 |
if (!isPossiblePlatform(f)) return null; |
89 |
f = FileUtil.normalizeFile(f); |
89 |
f = FileUtil.normalizeFile(f); |
90 |
File docs = FileUtil.normalizeFile(new File(f, "docs/api")); //NOI18N |
90 |
File docs = FileUtil.normalizeFile(new File(f, "docs/api")); //NOI18N |
|
|
91 |
String platformName = "BlackBerry JDE"; //NOI18N |
92 |
|
91 |
BufferedReader br = null; |
93 |
BufferedReader br = null; |
92 |
try { |
94 |
try { |
93 |
br = new BufferedReader(new FileReader(new File(f, "simulator/handhelds.manifest.txt"))); //NOI18N |
95 |
File manifest = new File(f, "simulator/handhelds.manifest.txt"); //NOI18N |
94 |
String devNames[] = br.readLine().split(" ");//NOI18N |
96 |
String devNames[] = null; |
|
|
97 |
if (manifest.exists()) |
98 |
{ |
99 |
br = new BufferedReader(new FileReader(manifest)); |
100 |
devNames = br.readLine().split(" ");//NOI18N |
101 |
} |
102 |
else |
103 |
{ |
104 |
devNames = new String[]{"BlackBerry Device"};//NOI18N |
105 |
platformName = "BlackBerry JDE Component Package"; |
106 |
} |
107 |
|
108 |
File rim = new File(f, "lib/net_rim_api.jar"); |
109 |
JarFile rimJar=null; |
110 |
try { |
111 |
rimJar = new JarFile(rim); |
112 |
String version = rimJar.getManifest().getMainAttributes().getValue("MIDlet-Version"); |
113 |
version = removeBuildVersion(version); |
114 |
platformName = platformName + " " + version; |
115 |
} catch (IOException ex) { |
116 |
//Exceptions.printStackTrace(ex); |
117 |
} |
118 |
finally |
119 |
{ |
120 |
if (rimJar!=null) |
121 |
try { |
122 |
rimJar.close(); |
123 |
} catch (IOException ex) { |
124 |
} |
125 |
} |
126 |
|
95 |
ArrayList<CLDCPlatformDescriptor.Device> devices = new ArrayList<CLDCPlatformDescriptor.Device>(); |
127 |
ArrayList<CLDCPlatformDescriptor.Device> devices = new ArrayList<CLDCPlatformDescriptor.Device>(); |
96 |
ArrayList<CLDCPlatformDescriptor.Profile> profiles = new ArrayList<CLDCPlatformDescriptor.Profile>(); |
128 |
ArrayList<CLDCPlatformDescriptor.Profile> profiles = new ArrayList<CLDCPlatformDescriptor.Profile>(); |
97 |
profiles.add(new CLDCPlatformDescriptor.Profile("CLDC", "1.1", "Connected Limited Device Configuration", CLDCPlatformDescriptor.ProfileType.Configuration, null, CLASSPATH, true)); //NOI18N |
129 |
profiles.add(new CLDCPlatformDescriptor.Profile("CLDC", "1.1", "Connected Limited Device Configuration", CLDCPlatformDescriptor.ProfileType.Configuration, null, CLASSPATH, true)); //NOI18N |
Lines 103-112
Link Here
|
103 |
for (int i=0; i<devNames.length; i++) { |
135 |
for (int i=0; i<devNames.length; i++) { |
104 |
devices.add(new CLDCPlatformDescriptor.Device(devNames[i], devNames[i], null, profiles, new CLDCPlatformDescriptor.Screen(240, devNames[i].charAt(1) == '1' ? 260 : 160, 16, true, false))); |
136 |
devices.add(new CLDCPlatformDescriptor.Device(devNames[i], devNames[i], null, profiles, new CLDCPlatformDescriptor.Screen(240, devNames[i].charAt(1) == '1' ? 260 : 160, 16, true, false))); |
105 |
} |
137 |
} |
106 |
return new CLDCPlatformDescriptor(BB_PLATFORM_NAME, f.getAbsolutePath(), "CUSTOM", null, docs.getAbsolutePath(), |
138 |
|
107 |
"\"{platformhome}{/}bin{/}preverify\" {classpath|-classpath \"{classpath}\"} -d \"{destdir}\" \"{srcdir}\"", //NOI18N |
139 |
///bin/sh wine "{platformhome}{/}bin{/}preverify.exe" {classpath|-classpath "`" + winepath + " -w {classpath}`"} -d "`" + winepath + " -w {destdir}`" "`" + winepath + " -w {srcdir}`" |
108 |
"cmd /C \"cd /D {platformhome}{/}simulator&{device}\"", //NOI18N |
140 |
if (System.getProperty("os.name").toLowerCase().startsWith("windows")) |
109 |
"cmd /C \"cd /D {platformhome}{/}bin&jdwp\"", devices); //NOI18N |
141 |
{ |
|
|
142 |
return new CLDCPlatformDescriptor(platformName, f.getAbsolutePath(), "CUSTOM", null, docs.getAbsolutePath(), |
143 |
"\"{platformhome}{/}bin{/}preverify\" {classpath|-classpath \"{classpath}\"} -d \"{destdir}\" \"{srcdir}\"", //NOI18N |
144 |
"cmd /C \"cd /D {platformhome}{/}simulator&{device}\"", //NOI18N |
145 |
"cmd /C \"cd /D {platformhome}{/}bin&jdwp\"", devices); //NOI18N |
146 |
} |
147 |
else |
148 |
{ |
149 |
String sh = findFile("sh", "/bin", "/usr/bin", "/usr/local/bin", System.getProperty("user.home") + File.separator + "bin"); |
150 |
String wine = findFile("wine", "/usr/bin","/bin", "/usr/local/bin", System.getProperty("user.home") + File.separator + "bin", System.getProperty("user.home") + File.separator + "wine" + File.separator + "bin", "/usr/local/wine/bin", "/opt/wine/bin", "/usr/sfw/bin", "/opt/sfw/bin"); |
151 |
String winepath = findFile("winepath", "/usr/bin","/bin", "/usr/local/bin", System.getProperty("user.home") + File.separator + "bin", System.getProperty("user.home") + File.separator + "wine" + File.separator + "bin", "/usr/local/wine/bin", "/opt/wine/bin", "/usr/sfw/bin", "/opt/sfw/bin"); |
152 |
|
153 |
return new CLDCPlatformDescriptor(platformName, f.getAbsolutePath(), "CUSTOM", null, docs.getAbsolutePath(), |
154 |
sh + " -c '" + wine + " \"{platformhome}{/}bin{/}preverify.exe\" {classpath|-classpath \"`" + winepath + " -w \"{classpath}\"`\"} -d \"`" + winepath + " -w \"{destdir}\"`\" \"`" + winepath + " -w \"{srcdir}\"`\"'", //NOI18N |
155 |
sh + " -c 'cd \"{platformhome}{/}simulator{/}\" && " + wine + " cmd /C \"{device}.bat\"'", //NOI18N |
156 |
sh + " -c 'cd \"{platformhome}{/}bin{/}\" && " + wine + " cmd /C \"jdwp.bat\"'", devices); //NOI18N |
157 |
|
158 |
} |
110 |
} catch (IOException ioe) { |
159 |
} catch (IOException ioe) { |
111 |
ErrorManager.getDefault().notify(ioe); |
160 |
ErrorManager.getDefault().notify(ioe); |
112 |
return null; |
161 |
return null; |
Lines 114-118
Link Here
|
114 |
if (br != null) try {br.close();} catch (IOException ioe) {} |
163 |
if (br != null) try {br.close();} catch (IOException ioe) {} |
115 |
} |
164 |
} |
116 |
} |
165 |
} |
|
|
166 |
|
167 |
|
168 |
private String findFile(String file, String ... paths) { |
169 |
for(String path:paths) |
170 |
{ |
171 |
File f = new File(path + File.separator + file); |
172 |
if (f.exists() && f.canRead()) |
173 |
{ |
174 |
return f.getAbsolutePath(); |
175 |
} |
176 |
} |
177 |
return paths[0] + File.separator + file; |
178 |
} |
179 |
|
180 |
private String removeBuildVersion(String version) { |
181 |
if (version.split("\\.").length>3) |
182 |
{ |
183 |
return version.substring(0,version.lastIndexOf(".")); |
184 |
} |
185 |
return version; |
186 |
} |
117 |
|
187 |
|
118 |
} |
188 |
} |