Skip to content

Commit 394483a

Browse files
author
jossonsmith
committed
Merge /trunk/ to [236]
Fix bug that J2SUnit runs twice in one Run/Debug process
1 parent d63eeb9 commit 394483a

File tree

4 files changed

+16
-64
lines changed

4 files changed

+16
-64
lines changed

src/net/sf/j2s/ui/launching/J2SApplicationLaunchShortcut.java

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -135,24 +135,7 @@ protected String getSelectionEmptyMessage() {
135135
protected void launch(IType type, String mode) {
136136
ILaunchConfiguration config = findLaunchConfiguration(type, getConfigurationType());
137137
if (config != null) {
138-
try {
139-
StringBuffer buffer= new StringBuffer(config.getName());
140-
buffer.append(DebugUIMessages.DebugUIPlugin_0); //$NON-NLS-1$
141-
ILaunchConfigurationWorkingCopy workingCopy= config.copy(buffer.toString());
142-
//workingCopy.setAttribute(ATTR_LAUNCHING_CONFIG_HANDLE, config.getMemento());
143-
//final ILaunch pendingLaunch= new PendingLaunch(workingCopy, mode, this);
144-
145-
DebugPlugin.getDefault().getLaunchManager().addLaunch(new Launch(config, mode, new ISourceLocator() {
146-
public Object getSourceElement(IStackFrame stackFrame) {
147-
// TODO Auto-generated method stub
148-
return null;
149-
}
150-
}));
151-
J2SLaunchingUtil.launchingJ2SApp(config);
152-
} catch (CoreException e) {
153-
e.printStackTrace();
154-
}
155-
//DebugUITools.launch(config, mode);
138+
DebugUITools.launch(config, mode);
156139
}
157140
}
158141

src/net/sf/j2s/ui/launching/J2SLaunchingUtil.java

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -31,23 +31,6 @@
3131
import org.eclipse.swt.widgets.Display;
3232

3333
public class J2SLaunchingUtil {
34-
// public static String readTemplate() {
35-
// try {
36-
// InputStream res = J2SLaunchingUtil.class
37-
// .getResourceAsStream("j2s.template.html");
38-
// ByteArrayOutputStream baos = new ByteArrayOutputStream();
39-
// byte[] buf = new byte[1024];
40-
// int read = 0;
41-
// while ((read = res.read(buf)) != -1) {
42-
// baos.write(buf, 0, read);
43-
// }
44-
// res.close();
45-
// return baos.toString();
46-
// } catch (IOException e) {
47-
// e.printStackTrace();
48-
// }
49-
// return null;
50-
// }
5134

5235
public static void writeMainHTML(File file, String html) {
5336
try {
@@ -253,9 +236,16 @@ private static String generateHTML(ILaunchConfiguration configuration,
253236
//buf.append(wrapTypeJS(mainType, relativePath));
254237

255238
buf.append("<script type=\"text/javascript\">\r\n");
239+
/*
256240
buf.append("ClazzLoader.j2slibClasspath (\"");
257241
buf.append(j2sLibPath);
258242
buf.append("\");\r\n");
243+
*/
244+
245+
buf.append("ClazzLoader.packageClasspath ([\"java\", \"swt\"], \"");
246+
buf.append(j2sLibPath);
247+
buf.append("\", true);\r\n");
248+
259249
buf.append("ClazzLoader.setPrimaryFolder (\"");
260250
buf.append(relativePath);
261251
buf.append("\");\r\n");

src/net/sf/j2s/ui/launching/J2SUnitLaunchShortcut.java

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -138,17 +138,6 @@ private void launch(String mode, JUnitLaunchDescription description) throws Laun
138138
ILaunchConfiguration config= findOrCreateLaunchConfiguration(mode, this, description);
139139

140140
if (config != null) {
141-
try {
142-
DebugPlugin.getDefault().getLaunchManager().addLaunch(new Launch(config, mode, new ISourceLocator() {
143-
public Object getSourceElement(IStackFrame stackFrame) {
144-
// TODO Auto-generated method stub
145-
return null;
146-
}
147-
}));
148-
J2SUnitLaunchingUtil.launchingJ2SUnit(config);
149-
} catch (CoreException e) {
150-
e.printStackTrace();
151-
}
152141
DebugUITools.launch(config, mode);
153142
}
154143
}

src/net/sf/j2s/ui/launching/J2SUnitLaunchingUtil.java

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -31,23 +31,6 @@
3131
import org.eclipse.swt.widgets.Display;
3232

3333
public class J2SUnitLaunchingUtil {
34-
// public static String readTemplate() {
35-
// try {
36-
// InputStream res = J2SLaunchingUtil.class
37-
// .getResourceAsStream("j2s.template.html");
38-
// ByteArrayOutputStream baos = new ByteArrayOutputStream();
39-
// byte[] buf = new byte[1024];
40-
// int read = 0;
41-
// while ((read = res.read(buf)) != -1) {
42-
// baos.write(buf, 0, read);
43-
// }
44-
// res.close();
45-
// return baos.toString();
46-
// } catch (IOException e) {
47-
// e.printStackTrace();
48-
// }
49-
// return null;
50-
// }
5134

5235
public static void writeMainHTML(File file, String html) {
5336
try {
@@ -252,19 +235,26 @@ private static String generateHTML(ILaunchConfiguration configuration,
252235
//buf.append(wrapTypeJS(mainType, relativePath));
253236

254237
buf.append("<script type=\"text/javascript\">\r\n");
238+
/*
255239
buf.append("ClazzLoader.j2slibClasspath (\"");
256240
buf.append(j2sLibPath);
257241
buf.append("\");\r\n");
242+
*/
243+
buf.append("ClazzLoader.packageClasspath ([\"java\", \"junit\"], \"");
244+
buf.append(j2sLibPath);
245+
buf.append("\", true);\r\n");
246+
258247
buf.append("ClazzLoader.setPrimaryFolder (\"");
259248
buf.append(relativePath);
260249
buf.append("\");\r\n");
261250

262251
//String args = configuration.getAttribute(IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, (String) null);
263-
buf.append("ClazzLoader.loadClass (\"junit.textui.TestRunner\");\r\n");
252+
buf.append("ClazzLoader.loadClass (\"junit.textui.TestRunner\", function () {\r\n");
264253
buf.append("ClazzLoader.loadClass (\"" + mainType + "\", function () {\r\n");
265254
//buf.append("" + mainType + ".main(" + ArgsUtil.wrapAsArgumentArray(args) + ");\r\n");
266255
buf.append("junit.textui.TestRunner.run (" + mainType + ");\r\n");
267256
buf.append("});\r\n");
257+
buf.append("});\r\n");
268258
buf.append("</script>\r\n");
269259

270260
buf.append(configuration.getAttribute(

0 commit comments

Comments
 (0)