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 |
if (version==null || version.length()==0) |
114 |
{ |
115 |
if (f.getName().toLowerCase().contains(platformName.toLowerCase())) |
116 |
platformName = f.getName(); |
117 |
else |
118 |
platformName = platformName + " " + f.getName(); |
119 |
} |
120 |
else |
121 |
{ |
122 |
version = removeBuildVersion(version); |
123 |
platformName = platformName + " " + version; |
124 |
} |
125 |
} catch (IOException ex) { |
126 |
//Exceptions.printStackTrace(ex); |
127 |
} |
128 |
finally |
129 |
{ |
130 |
if (rimJar!=null) |
131 |
try { |
132 |
rimJar.close(); |
133 |
} catch (IOException ex) { |
134 |
} |
135 |
} |
136 |
|
95 |
ArrayList<CLDCPlatformDescriptor.Device> devices = new ArrayList<CLDCPlatformDescriptor.Device>(); |
137 |
ArrayList<CLDCPlatformDescriptor.Device> devices = new ArrayList<CLDCPlatformDescriptor.Device>(); |
96 |
ArrayList<CLDCPlatformDescriptor.Profile> profiles = new ArrayList<CLDCPlatformDescriptor.Profile>(); |
138 |
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 |
139 |
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++) { |
145 |
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))); |
146 |
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 |
} |
147 |
} |
106 |
return new CLDCPlatformDescriptor(BB_PLATFORM_NAME, f.getAbsolutePath(), "CUSTOM", null, docs.getAbsolutePath(), |
148 |
|
107 |
"\"{platformhome}{/}bin{/}preverify\" {classpath|-classpath \"{classpath}\"} -d \"{destdir}\" \"{srcdir}\"", //NOI18N |
149 |
///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 |
150 |
if (System.getProperty("os.name").toLowerCase().startsWith("windows")) |
109 |
"cmd /C \"cd /D {platformhome}{/}bin&jdwp\"", devices); //NOI18N |
151 |
{ |
|
|
152 |
return new CLDCPlatformDescriptor(platformName, f.getAbsolutePath(), "CUSTOM", null, docs.getAbsolutePath(), |
153 |
"\"{platformhome}{/}bin{/}preverify\" {classpath|-classpath \"{classpath}\"} -d \"{destdir}\" \"{srcdir}\"", //NOI18N |
154 |
"cmd /C \"cd /D {platformhome}{/}simulator&{device}\"", //NOI18N |
155 |
"cmd /C \"cd /D {platformhome}{/}bin&jdwp\"", devices); //NOI18N |
156 |
} |
157 |
else |
158 |
{ |
159 |
String sh = findFile("sh", "/bin", "/usr/bin", "/usr/local/bin", System.getProperty("user.home") + File.separator + "bin"); |
160 |
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"); |
161 |
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"); |
162 |
|
163 |
return new CLDCPlatformDescriptor(platformName, f.getAbsolutePath(), "CUSTOM", null, docs.getAbsolutePath(), |
164 |
sh + " -c '" + wine + " \"{platformhome}{/}bin{/}preverify.exe\" {classpath|-classpath \"`" + winepath + " -w \"{classpath}\"`\"} -d \"`" + winepath + " -w \"{destdir}\"`\" \"`" + winepath + " -w \"{srcdir}\"`\"'", //NOI18N |
165 |
sh + " -c 'cd \"{platformhome}{/}simulator{/}\" && " + wine + " cmd /C \"{device}.bat\"'", //NOI18N |
166 |
sh + " -c 'cd \"{platformhome}{/}bin{/}\" && " + wine + " cmd /C \"jdwp.bat\"'", devices); //NOI18N |
167 |
|
168 |
} |
110 |
} catch (IOException ioe) { |
169 |
} catch (IOException ioe) { |
111 |
ErrorManager.getDefault().notify(ioe); |
170 |
ErrorManager.getDefault().notify(ioe); |
112 |
return null; |
171 |
return null; |
Lines 114-118
Link Here
|
114 |
if (br != null) try {br.close();} catch (IOException ioe) {} |
173 |
if (br != null) try {br.close();} catch (IOException ioe) {} |
115 |
} |
174 |
} |
116 |
} |
175 |
} |
|
|
176 |
|
177 |
|
178 |
private String findFile(String file, String ... paths) { |
179 |
for(String path:paths) |
180 |
{ |
181 |
File f = new File(path + File.separator + file); |
182 |
if (f.exists() && f.canRead()) |
183 |
{ |
184 |
return f.getAbsolutePath(); |
185 |
} |
186 |
} |
187 |
return paths[0] + File.separator + file; |
188 |
} |
189 |
|
190 |
private String removeBuildVersion(String version) { |
191 |
if (version.split("\\.").length>3) |
192 |
{ |
193 |
return version.substring(0,version.lastIndexOf(".")); |
194 |
} |
195 |
return version; |
196 |
} |
117 |
|
197 |
|
118 |
} |
198 |
} |