Skip to content

Commit bc2e49c

Browse files
author
jossonsmith
committed
Merge with /trunk
1 parent 33739eb commit bc2e49c

20 files changed

+1329
-52
lines changed

icons/z-logo-u.gif

1020 Bytes
Loading

plugin.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@
9696
</shortcut>
9797
<shortcut
9898
label="Java2Script Unit Test"
99-
icon="icons/z-logo.gif"
99+
icon="icons/z-logo-u.gif"
100100
modes="run, debug"
101101
class="net.sf.j2s.ui.launching.J2SUnitLaunchShortcut"
102102
id="net.sf.j2s.debug.ui.localJ2SJUnitShortcut">
@@ -201,7 +201,7 @@
201201
icon="icons/z-logo.gif"
202202
id="net.sf.j2s.ui.launching.launchConfigurationTypeImage.j2sApplication"/>
203203
<launchConfigurationTypeImage
204-
icon="icons/z-logo.gif"
204+
icon="icons/z-logo-u.gif"
205205
configTypeID="net.sf.j2s.ui.launching.j2sUnit"
206206
id="net.sf.j2s.ui.launching.launchConfigurationTypeImage.j2sUnit"/>
207207
</extension>

src/net/sf/j2s/ui/classpath/CompositeResources.java

Lines changed: 116 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import java.util.Iterator;
1010
import java.util.List;
1111
import java.util.Properties;
12+
import net.sf.j2s.ui.launching.J2SCyclicProjectUtils;
1213

1314

1415
public 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
}

src/net/sf/j2s/ui/classpath/ContactedClasses.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
package net.sf.j2s.ui.classpath;
22

33
import java.io.File;
4+
import java.io.IOException;
45
import java.util.ArrayList;
56
import java.util.Iterator;
67
import java.util.List;
78
import java.util.Properties;
9+
import net.sf.j2s.ui.launching.J2SCyclicProjectUtils;
810

911

1012
public class ContactedClasses extends Resource implements IExternalResource, IClasspathContainer {
@@ -124,6 +126,9 @@ public void setBinRelativePath(String binRelativePath) {
124126
}
125127

126128
public String toHTMLString() {
129+
if (getRelativePath() != null && getRelativePath().endsWith(".j2x")) {
130+
return "";
131+
}
127132
Resource p = this.getParent();
128133
if (p != null) {
129134
if (p instanceof ContactedClasses) {
@@ -139,6 +144,9 @@ public String toHTMLString() {
139144
}
140145
for (Iterator iter = externalList.iterator(); iter.hasNext();) {
141146
Resource res = (Resource) iter.next();
147+
if (!J2SCyclicProjectUtils.visit(res)) {
148+
continue;
149+
}
142150
buf.append(res.toHTMLString());
143151
}
144152
buf.append("<script type=\"text/javascript\" src=\"");
@@ -175,6 +183,18 @@ public String toHTMLString() {
175183
buf.append("\"></script>\r\n");
176184
return buf.toString();
177185
}
186+
187+
public String toJ2XString() {
188+
if (getName().endsWith(".j2x")) {
189+
try {
190+
return getAbsoluteFile().getCanonicalPath();
191+
} catch (IOException e) {
192+
e.printStackTrace();
193+
}
194+
}
195+
return "";
196+
}
197+
178198
public int getType() {
179199
return CONTAINER;
180200
}

src/net/sf/j2s/ui/classpath/ProjectResources.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
public class ProjectResources extends CompositeResources {
88

99
public File getAbsoluteFile() {
10-
return new File(getFolder(), ".." + getRelativePath());
10+
return new File(getFolder(), getRelativePath());
1111
}
1212

1313
public String getName() {
@@ -16,10 +16,10 @@ public String getName() {
1616
}
1717

1818
public boolean exists() {
19-
return new File(getFolder(), ".." + getRelativePath()).exists();
19+
return new File(getFolder(), getRelativePath()).exists();
2020
}
2121
public String getBinRelativePath() {
22-
return ".." + getRelativePath().substring(0, getRelativePath().lastIndexOf('/') + 1);
22+
return getRelativePath().substring(0, getRelativePath().lastIndexOf('/') + 1);
2323
//return super.getBinRelativePath();
2424
}
2525
public String toHTMLString() {
@@ -36,6 +36,7 @@ public String toHTMLString() {
3636
// return buf.toString();
3737
return super.toHTMLString();
3838
}
39+
3940
public int getType() {
4041
return PROJECT;
4142
}

src/net/sf/j2s/ui/classpath/UnitClass.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ public boolean exists() {
3636
}
3737
public String toHTMLString() {
3838
String bin = "";
39+
// Class unit *.js is loaded by Clazz.load from now on.
40+
if (true) return bin;
3941
if (this.getParent() != null
4042
&& (this.getParent() instanceof CompositeResources)) {
4143
CompositeResources cc = (CompositeResources) this.getParent();
@@ -46,6 +48,7 @@ public String toHTMLString() {
4648
}
4749
return J2SLaunchingUtil.wrapTypeJS(getClassName(), bin + getBinRelativePath());
4850
}
51+
4952
public int getType() {
5053
return ARCHIVE;
5154
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/*******************************************************************************
2+
* Java2Script Pacemaker (http://j2s.sourceforge.net)
3+
*
4+
* Copyright (c) 2006 ognize.com and others.
5+
* All rights reserved. This program and the accompanying materials
6+
* are made available under the terms of the Eclipse Public License v1.0
7+
* which accompanies this distribution, and is available at
8+
* http://www.eclipse.org/legal/epl-v10.html
9+
*
10+
* Contributors:
11+
* ognize.com - initial API and implementation
12+
*******************************************************************************/
13+
14+
package net.sf.j2s.ui.launching;
15+
16+
import java.util.HashSet;
17+
import java.util.Set;
18+
19+
/**
20+
* @author josson smith
21+
*
22+
* 2006-8-12
23+
*/
24+
public class J2SCyclicProjectUtils {
25+
26+
private static Set tracks = new HashSet();
27+
28+
public static void emptyTracks() {
29+
tracks.clear();
30+
}
31+
32+
public static boolean visit(Object obj) {
33+
if (tracks.contains(obj)) {
34+
return false;
35+
}
36+
tracks.add(obj);
37+
return true;
38+
}
39+
}

0 commit comments

Comments
 (0)