|
1 | 1 | package net.sf.j2s.ui.classpath; |
2 | 2 |
|
3 | 3 | import java.io.File; |
| 4 | +import java.io.FileFilter; |
4 | 5 | import java.io.FileInputStream; |
5 | 6 | import java.io.FileNotFoundException; |
6 | 7 | import java.io.IOException; |
@@ -257,6 +258,25 @@ public String toJ2XString() { |
257 | 258 | if (resources == null) { |
258 | 259 | this.load(); |
259 | 260 | } |
| 261 | + if (this instanceof ProjectResources) { |
| 262 | + ProjectResources pr = (ProjectResources) this; |
| 263 | + File binFolder = new File(pr.getAbsoluteFolder(), this.binRelativePath); |
| 264 | + File[] files = binFolder.listFiles(new FileFilter() { |
| 265 | + public boolean accept(File pathname) { |
| 266 | + if (pathname.isFile() && pathname.getName().endsWith(".j2x")) { |
| 267 | + return true; |
| 268 | + } |
| 269 | + return false; |
| 270 | + } |
| 271 | + }); |
| 272 | + if (files != null && files.length != 0) { |
| 273 | + for (int i = 0; i < files.length; i++) { |
| 274 | + buf.append(files[i].getAbsolutePath()); |
| 275 | + buf.append(','); |
| 276 | + } |
| 277 | + return buf.toString(); |
| 278 | + } |
| 279 | + } |
260 | 280 | for (Iterator iter = resources.iterator(); iter.hasNext();) { |
261 | 281 | Resource res = (Resource) iter.next(); |
262 | 282 | if (!J2SCyclicProjectUtils.visit(res)) { |
@@ -290,6 +310,33 @@ public String existedClassesString() { |
290 | 310 | if (resources == null) { |
291 | 311 | this.load(); |
292 | 312 | } |
| 313 | + if (this instanceof ProjectResources) { |
| 314 | + ProjectResources pr = (ProjectResources) this; |
| 315 | + File binFolder = new File(pr.getAbsoluteFolder(), this.binRelativePath); |
| 316 | + File[] files = binFolder.listFiles(new FileFilter() { |
| 317 | + public boolean accept(File pathname) { |
| 318 | + if (pathname.isFile() && pathname.getName().endsWith(".j2x")) { |
| 319 | + return true; |
| 320 | + } |
| 321 | + return false; |
| 322 | + } |
| 323 | + }); |
| 324 | + if (files != null && files.length != 0) { // should always one *.j2x file |
| 325 | + Properties prop = new Properties(); |
| 326 | + try { |
| 327 | + prop.load(new FileInputStream(files[0])); |
| 328 | + } catch (FileNotFoundException e) { |
| 329 | + e.printStackTrace(); |
| 330 | + } catch (IOException e) { |
| 331 | + e.printStackTrace(); |
| 332 | + } |
| 333 | + String pkg = prop.getProperty("package.prefix"); |
| 334 | + File pkgFile = new File(files[0].getParentFile(), pkg.replace('.', '/') + "/package.js"); |
| 335 | + if (pkgFile.exists()) { |
| 336 | + return buf.toString(); |
| 337 | + } |
| 338 | + } |
| 339 | + } |
293 | 340 | buf.append('['); |
294 | 341 | try { |
295 | 342 | buf.append(new File(getAbsoluteFolder(), binRelativePath).getCanonicalPath()); |
|
0 commit comments