99import java .util .Iterator ;
1010import java .util .List ;
1111import java .util .Properties ;
12+ import net .sf .j2s .ui .launching .J2SCyclicProjectUtils ;
1213
1314
1415public class CompositeResources extends Resource implements IClasspathContainer {
@@ -21,7 +22,7 @@ public class CompositeResources extends Resource implements IClasspathContainer
2122
2223 public File getAbsoluteFile () {
2324 if (getRelativePath ().startsWith ("/" )) {
24- return new File (getFolder (), ".." + getRelativePath ());
25+ return new File (getFolder (), getRelativePath ());
2526 } else {
2627 return super .getAbsoluteFile ();
2728 }
@@ -34,14 +35,14 @@ public String getName() {
3435
3536 public boolean exists () {
3637 if (getRelativePath ().startsWith ("/" )) {
37- return new File (getFolder (), ".." + getRelativePath ()).exists ();
38+ return new File (getFolder (), getRelativePath ()).exists ();
3839 } else {
3940 return super .exists ();
4041 }
4142 }
4243 public String getBinRelativePath () {
4344 if (getRelativePath ().startsWith ("/" )) {
44- return ".." + getRelativePath ().substring (0 , getRelativePath ().lastIndexOf ('/' ) + 1 );
45+ return getRelativePath ().substring (0 , getRelativePath ().lastIndexOf ('/' ) + 1 );
4546 } else {
4647 return "" ;
4748 //return binRelativePath;
@@ -115,7 +116,7 @@ private void addResourceByString(List resourcesList, String[] reses) {
115116 if (res .startsWith ("|" )) {
116117 res = res .substring (1 );
117118 Resource rr = null ;
118- if (res .endsWith (".z.js" )) {
119+ if (res .endsWith (".z.js" ) || res . endsWith ( ".j2x" ) ) {
119120 rr = new ContactedClasses ();
120121 } else if (res .endsWith (".css" )) {
121122 rr = new CSSResource ();
@@ -129,7 +130,7 @@ private void addResourceByString(List resourcesList, String[] reses) {
129130 rr .setParent (this );
130131 rr .setAbsolute (true );
131132 resourcesList .add (rr );
132- } else if (res .endsWith (".z.js" )) {
133+ } else if (res .endsWith (".z.js" ) || res . endsWith ( ".j2x" ) ) {
133134 ContactedClasses jz = new ContactedClasses ();
134135 jz .setFolder (this .getAbsoluteFolder ());
135136 jz .setRelativePath (res );
@@ -151,7 +152,7 @@ private void addResourceByString(List resourcesList, String[] reses) {
151152 resourcesList .add (css );
152153 } else if (res .endsWith ("/.j2s" )) {
153154 ProjectResources prj = new ProjectResources ();
154- prj .setFolder (this .getAbsoluteFolder ());
155+ prj .setFolder (this .getAbsoluteFolder (). getParentFile () );
155156 prj .setRelativePath (res );
156157 prj .setParent (this );
157158 resourcesList .add (prj );
@@ -240,10 +241,119 @@ public String toHTMLString() {
240241 }
241242 for (Iterator iter = resources .iterator (); iter .hasNext ();) {
242243 Resource res = (Resource ) iter .next ();
244+ if (!J2SCyclicProjectUtils .visit (res )) {
245+ continue ;
246+ }
243247 buf .append (res .toHTMLString ());
244248 }
245249 return buf .toString ();
246250 }
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+
247357 public int getType () {
248358 return VARIABLE ;
249359 }
0 commit comments