9
9
import java .util .Iterator ;
10
10
import java .util .List ;
11
11
import java .util .Properties ;
12
+ import net .sf .j2s .ui .launching .J2SCyclicProjectUtils ;
12
13
13
14
14
15
public class CompositeResources extends Resource implements IClasspathContainer {
@@ -21,7 +22,7 @@ public class CompositeResources extends Resource implements IClasspathContainer
21
22
22
23
public File getAbsoluteFile () {
23
24
if (getRelativePath ().startsWith ("/" )) {
24
- return new File (getFolder (), ".." + getRelativePath ());
25
+ return new File (getFolder (), getRelativePath ());
25
26
} else {
26
27
return super .getAbsoluteFile ();
27
28
}
@@ -34,14 +35,14 @@ public String getName() {
34
35
35
36
public boolean exists () {
36
37
if (getRelativePath ().startsWith ("/" )) {
37
- return new File (getFolder (), ".." + getRelativePath ()).exists ();
38
+ return new File (getFolder (), getRelativePath ()).exists ();
38
39
} else {
39
40
return super .exists ();
40
41
}
41
42
}
42
43
public String getBinRelativePath () {
43
44
if (getRelativePath ().startsWith ("/" )) {
44
- return ".." + getRelativePath ().substring (0 , getRelativePath ().lastIndexOf ('/' ) + 1 );
45
+ return getRelativePath ().substring (0 , getRelativePath ().lastIndexOf ('/' ) + 1 );
45
46
} else {
46
47
return "" ;
47
48
//return binRelativePath;
@@ -115,7 +116,7 @@ private void addResourceByString(List resourcesList, String[] reses) {
115
116
if (res .startsWith ("|" )) {
116
117
res = res .substring (1 );
117
118
Resource rr = null ;
118
- if (res .endsWith (".z.js" )) {
119
+ if (res .endsWith (".z.js" ) || res . endsWith ( ".j2x" ) ) {
119
120
rr = new ContactedClasses ();
120
121
} else if (res .endsWith (".css" )) {
121
122
rr = new CSSResource ();
@@ -129,7 +130,7 @@ private void addResourceByString(List resourcesList, String[] reses) {
129
130
rr .setParent (this );
130
131
rr .setAbsolute (true );
131
132
resourcesList .add (rr );
132
- } else if (res .endsWith (".z.js" )) {
133
+ } else if (res .endsWith (".z.js" ) || res . endsWith ( ".j2x" ) ) {
133
134
ContactedClasses jz = new ContactedClasses ();
134
135
jz .setFolder (this .getAbsoluteFolder ());
135
136
jz .setRelativePath (res );
@@ -151,7 +152,7 @@ private void addResourceByString(List resourcesList, String[] reses) {
151
152
resourcesList .add (css );
152
153
} else if (res .endsWith ("/.j2s" )) {
153
154
ProjectResources prj = new ProjectResources ();
154
- prj .setFolder (this .getAbsoluteFolder ());
155
+ prj .setFolder (this .getAbsoluteFolder (). getParentFile () );
155
156
prj .setRelativePath (res );
156
157
prj .setParent (this );
157
158
resourcesList .add (prj );
@@ -240,10 +241,119 @@ public String toHTMLString() {
240
241
}
241
242
for (Iterator iter = resources .iterator (); iter .hasNext ();) {
242
243
Resource res = (Resource ) iter .next ();
244
+ if (!J2SCyclicProjectUtils .visit (res )) {
245
+ continue ;
246
+ }
243
247
buf .append (res .toHTMLString ());
244
248
}
245
249
return buf .toString ();
246
250
}
251
+
252
+ public String toJ2XString () {
253
+ StringBuffer buf = new StringBuffer ();
254
+ if (!J2SCyclicProjectUtils .visit (this )) {
255
+ return buf .toString ();
256
+ }
257
+ if (resources == null ) {
258
+ this .load ();
259
+ }
260
+ for (Iterator iter = resources .iterator (); iter .hasNext ();) {
261
+ Resource res = (Resource ) iter .next ();
262
+ if (!J2SCyclicProjectUtils .visit (res )) {
263
+ continue ;
264
+ }
265
+ if (res instanceof CompositeResources ) {
266
+ CompositeResources c = (CompositeResources ) res ;
267
+ buf .append (c .toJ2XString ());
268
+ buf .append (',' );
269
+ }
270
+ }
271
+ for (Iterator iter = resources .iterator (); iter .hasNext ();) {
272
+ Resource res = (Resource ) iter .next ();
273
+ if (!J2SCyclicProjectUtils .visit (res )) {
274
+ continue ;
275
+ }
276
+ if (res instanceof ContactedClasses ) {
277
+ ContactedClasses unit = (ContactedClasses ) res ;
278
+ buf .append (unit .getAbsoluteFile ().getAbsolutePath ());
279
+ buf .append (',' );
280
+ }
281
+ }
282
+ return buf .toString ();
283
+ }
284
+
285
+ public String existedClassesString () {
286
+ StringBuffer buf = new StringBuffer ();
287
+ if (!J2SCyclicProjectUtils .visit (this )) {
288
+ return buf .toString ();
289
+ }
290
+ if (resources == null ) {
291
+ this .load ();
292
+ }
293
+ buf .append ('[' );
294
+ try {
295
+ buf .append (new File (getAbsoluteFolder (), binRelativePath ).getCanonicalPath ());
296
+ } catch (IOException e ) {
297
+ // TODO Auto-generated catch block
298
+ e .printStackTrace ();
299
+ }
300
+ buf .append (']' );
301
+ buf .append (',' );
302
+ for (Iterator iter = resources .iterator (); iter .hasNext ();) {
303
+ Resource res = (Resource ) iter .next ();
304
+ if (res instanceof UnitClass ) {
305
+ if (!J2SCyclicProjectUtils .visit (res )) {
306
+ continue ;
307
+ }
308
+ UnitClass unit = (UnitClass ) res ;
309
+ buf .append (unit .getClassName ());
310
+ buf .append (',' );
311
+ }
312
+ }
313
+ for (Iterator iter = resources .iterator (); iter .hasNext ();) {
314
+ Resource res = (Resource ) iter .next ();
315
+ if (res instanceof CompositeResources ) {
316
+ CompositeResources c = (CompositeResources ) res ;
317
+ buf .append (c .existedClassesString ());
318
+ buf .append (',' );
319
+ }
320
+ }
321
+ return buf .toString ();
322
+ }
323
+
324
+ public String ignoredClassesString () {
325
+ StringBuffer buf = new StringBuffer ();
326
+ if (!J2SCyclicProjectUtils .visit (this )) {
327
+ return buf .toString ();
328
+ }
329
+ if (resources == null ) {
330
+ this .load ();
331
+ }
332
+ for (Iterator iter = resources .iterator (); iter .hasNext ();) {
333
+ Resource res = (Resource ) iter .next ();
334
+ if (!J2SCyclicProjectUtils .visit (res )) {
335
+ continue ;
336
+ }
337
+ if (res instanceof CompositeResources ) {
338
+ CompositeResources c = (CompositeResources ) res ;
339
+ buf .append (c .ignoredClassesString ());
340
+ buf .append (',' );
341
+ }
342
+ }
343
+ for (Iterator iter = abandonedResources .iterator (); iter .hasNext ();) {
344
+ Resource res = (Resource ) iter .next ();
345
+ if (!J2SCyclicProjectUtils .visit (res )) {
346
+ continue ;
347
+ }
348
+ if (res instanceof UnitClass ) {
349
+ UnitClass unit = (UnitClass ) res ;
350
+ buf .append (unit .getClassName ());
351
+ buf .append (',' );
352
+ }
353
+ }
354
+ return buf .toString ();
355
+ }
356
+
247
357
public int getType () {
248
358
return VARIABLE ;
249
359
}
0 commit comments