X Tutup
Skip to content

Commit bfa4139

Browse files
author
jossonsmith
committed
Commit a rough JFace test
1 parent ab9080f commit bfa4139

File tree

15 files changed

+637
-0
lines changed

15 files changed

+637
-0
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<classpath>
3+
<classpathentry kind="src" path="src"/>
4+
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
5+
<classpathentry sourcepath="S:/eclipse-3.1.1/swt-3.1.1/src.zip" kind="lib" path="S:/eclipse-3.1.1/eclipse/plugins/org.eclipse.swt.win32.win32.x86_3.1.1.jar"/>
6+
<classpathentry kind="lib" path="S:/eclipse-3.1.1/eclipse/plugins/org.eclipse.core.commands_3.1.0.jar"/>
7+
<classpathentry kind="lib" path="S:/eclipse-3.1.1/eclipse/plugins/org.eclipse.core.runtime_3.1.1.jar"/>
8+
<classpathentry kind="lib" path="S:/eclipse-3.1.1/eclipse/plugins/org.eclipse.jface_3.1.1.jar"/>
9+
<classpathentry kind="output" path="bin"/>
10+
</classpath>
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#Java2Script Configuration
2+
#Sat Jan 20 01:19:23 CST 2007
3+
j2s.resources.list=/net.sf.j2s.java.core/.j2s,/net.sf.j2s.java.org.eclipse.jface/.j2s,bin/com/ognize/jface/test/TitleAreaDialogTest.js,bin/com/ognize/jface/test/MyTitleAreaDialog.js,bin/com/ognize/jface/test/IWorld.js,bin/com/ognize/jface/test/AsyncWindowProxy.js,bin/com/ognize/jface/async/AsyncWindowRunnable.js,bin/com/ognize/jface/async/AsyncWindowProxy.js,bin/org/eclipse/jface/window/WindowProxy.js
4+
j2s.abandoned.resources.list=
5+
j2s.output.path=bin
6+
j2s.compiler.status=enable
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>net.sf.j2s.test.jface</name>
4+
<comment></comment>
5+
<projects>
6+
</projects>
7+
<buildSpec>
8+
<buildCommand>
9+
<name>org.eclipse.jdt.core.javabuilder</name>
10+
<arguments>
11+
</arguments>
12+
</buildCommand>
13+
<buildCommand>
14+
<name>org.eclipse.pde.ManifestBuilder</name>
15+
<arguments>
16+
</arguments>
17+
</buildCommand>
18+
<buildCommand>
19+
<name>org.eclipse.pde.SchemaBuilder</name>
20+
<arguments>
21+
</arguments>
22+
</buildCommand>
23+
<buildCommand>
24+
<name>net.sf.j2s.core.java2scriptbuilder</name>
25+
<arguments>
26+
</arguments>
27+
</buildCommand>
28+
</buildSpec>
29+
<natures>
30+
<nature>org.eclipse.pde.PluginNature</nature>
31+
<nature>org.eclipse.jdt.core.javanature</nature>
32+
</natures>
33+
</projectDescription>
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
source.. = src/
2+
output.. = bin/
3+
bin.includes = META-INF/,\
4+
.
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
2+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
3+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
4+
<head>
5+
<title>com.ognize.jface.test.TitleAreaDialogTest</title>
6+
<script type="text/javascript" src="../../plugins/net.sf.j2s.lib_1.0.0/j2slib/j2slib.z.js"></script>
7+
</head>
8+
<body>
9+
<script type="text/javascript">
10+
ClazzLoader.ignore (["org.eclipse.osgi.framework.log.FrameworkLogEntry", "org.eclipse.core.internal.runtime.FindSupport", "$.InternalPlatform", "java.io.File", "$.FileInputStream", "$.FilterInputStream", "$.InputStreamReader", "$.OutputStreamWriter", "java.net.URL", "java.text.MessageFormat", "java.security.AccessController", "java.security.PrivilegedAction", "org.eclipse.osgi.framework.adaptor.FrameworkAdaptor", "org.eclipse.osgi.framework.debug.Debug", "org.eclipse.core.internal.runtime.CompatibilityHelper"]);
11+
ClazzLoader.ignore ("$wt.widgets.Menu", "$.MenuItem", "$.Tray", "$.TrayItem",
12+
"$wt.browser.CloseWindowListener", "$.LocationListener", "$.OpenWindowListener", "$.ProgressListener", "$.StatusTextListener", "$.TitleListener", "$.VisibilityWindowListener");
13+
ClazzLoader.jarClasspath ("bin/org/eclipse/jface/window/WindowProxy.js", "org.eclipse.jface.window.WindowProxy");
14+
ClazzLoader.packageClasspath ("net.sf.j2s.ajax", "../net.sf.j2s.java.core/bin/");
15+
ClazzLoader.packageClasspath ("java", "../net.sf.j2s.java.core/bin/", true);
16+
ClazzLoader.packageClasspath ("org.eclipse.swt", "../net.sf.j2s.java.org.eclipse.swt/bin/", true);
17+
ClazzLoader.setPrimaryFolder ("bin");
18+
ClazzLoader.packageClasspath (["com.ognize.jface.async", "$.test", "org.eclipse.jface.window"], "bin/");
19+
ClazzLoader.packageClasspath (["java.lang.reflect", "java.lang", "$.util", "$.io"], "../net.sf.j2s.java.core/bin/");
20+
ClazzLoader.packageClasspath (["org.eclipse.jface.bindings", "$.util", "$.contexts", "$.dialogs", "$.viewers", "$.commands", "org.eclipse.jface.bindings.keys.formatting", "org.eclipse.jface.action", "$.preference", "$.window", "$.operation", "$.wizard", "org.eclipse.jface.bindings.keys", "org.eclipse.jface.resource", "org.eclipse.jface.viewers.deferred"], "../net.sf.j2s.java.org.eclipse.jface/bin/");
21+
ClazzLoader.packageClasspath (["org.eclipse.core.commands.contexts", "$.common", "$.operations", "org.eclipse.core.commands", "org.eclipse.core.internal.commands.util", "$.operations"], "../net.sf.j2s.java.org.eclipse.core.commands/bin/");
22+
ClazzLoader.packageClasspath (["org.eclipse.core.internal.registry", "org.eclipse.core.runtime.preferences", "$.content", "org.eclipse.core.internal.content", "$.preferences", "$.runtime", "$.boot", "$.jobs", "org.eclipse.core.runtime.dynamichelpers", "org.osgi.service.prefs", "org.eclipse.core.runtime", "org.eclipse.core.runtime.jobs"], "../net.sf.j2s.java.org.eclipse.core.runtime/bin/");
23+
ClazzLoader.packageClasspath (["org.eclipse.osgi.service.datalocation", "org.eclipse.osgi.framework.internal.protocol.bundleresource", "org.osgi.service.permissionadmin", "org.eclipse.osgi.framework.internal.protocol", "org.eclipse.osgi.internal.profile", "$.resolver", "org.eclipse.osgi.framework.log", "org.osgi.framework", "org.eclipse.core.runtime.internal.stats", "org.eclipse.osgi.service.resolver", "org.eclipse.osgi.event", "org.osgi.service.url", "org.eclipse.osgi.framework.internal.core", "org.eclipse.osgi.service.pluginconversion", "org.eclipse.osgi.framework.adaptor", "org.eclipse.osgi.framework.internal.protocol.reference", "org.eclipse.osgi.framework.adaptor.core", "org.eclipse.core.runtime.adaptor", "org.eclipse.osgi.service.urlconversion", "org.eclipse.osgi.framework.internal.reliablefile", "org.osgi.service.startlevel", "org.eclipse.osgi.framework.launcher", "org.eclipse.osgi.service.runnable", "org.eclipse.osgi.framework.util", "org.eclipse.osgi.internal.module", "org.eclipse.osgi.util", "org.eclipse.osgi.service.debug", "org.eclipse.osgi.framework.console", "org.eclipse.osgi.framework.internal.defaultadaptor", "org.eclipse.osgi.service.environment", "org.osgi.service.packageadmin", "org.eclipse.osgi.framework.internal.protocol.bundleentry", "org.eclipse.osgi.service.localization", "org.eclipse.osgi.framework.debug", "org.eclipse.core.runtime.internal.adaptor", "org.eclipse.osgi.framework.eventmgr", "org.osgi.util.tracker", "org.osgi.service.condpermadmin"], "../net.sf.j2s.java.org.eclipse.osgi/bin/");
24+
ClazzLoader.loadClass ("com.ognize.jface.test.TitleAreaDialogTest", function () {
25+
com.ognize.jface.test.TitleAreaDialogTest.main([]);
26+
});
27+
</script>
28+
</body>
29+
</html>
2.86 KB
Loading
2.86 KB
Loading
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
This is a rough test for Eclipse JFace. Before everything
2+
is OK, you may need to do the following things:
3+
1. update .classpath with correct classpath
4+
2. open com.ognize.jface.test.TitleAreaDialog.html directly
5+
(without Run/Debug)
Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
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 com.ognize.jface.async;
15+
16+
import org.eclipse.jface.window.Window;
17+
import org.eclipse.jface.window.WindowProxy;
18+
import org.eclipse.swt.events.DisposeEvent;
19+
import org.eclipse.swt.events.DisposeListener;
20+
import org.eclipse.swt.widgets.Display;
21+
import org.eclipse.swt.widgets.Shell;
22+
23+
/**
24+
* @author josson smith
25+
*
26+
* 2006-4-29
27+
*/
28+
public class AsyncWindowProxy {
29+
protected Window window;
30+
31+
public AsyncWindowProxy(Window window) {
32+
super();
33+
this.window = window;
34+
}
35+
36+
public static void open(Window window, AsyncWindowRunnable runnable) {
37+
new AsyncWindowProxy(window).open(runnable);
38+
}
39+
40+
/**
41+
* @j2sNative
42+
runnable.setWindow (this.window);
43+
this.window.open ();
44+
(function (innerThis, finalVars) {
45+
if (!Clazz.isClassDefined ("com.ognize.jface.async.AsyncWindowProxy$1")) {
46+
Clazz.pu$h ();
47+
cla$$ = com.ognize.jface.async.AsyncWindowProxy$1 = function () {
48+
Clazz.prepareCallback (this, arguments);
49+
Clazz.instantialize (this, arguments);
50+
};
51+
Clazz.decorateAsType (cla$$, "com.ognize.jface.async.AsyncWindowProxy$1", null, Runnable);
52+
Clazz.defineMethod (cla$$, "run",
53+
function () {
54+
if (this.callbacks["com.ognize.jface.async.AsyncWindowProxy"].window.getShell () == null) {
55+
this.callbacks["com.ognize.jface.async.AsyncWindowProxy"].getActiveDisplay ().timerExec (10, this);
56+
return ;
57+
}
58+
var $hell = this.callbacks["com.ognize.jface.async.AsyncWindowProxy"].window.getShell ();
59+
$hell.addDisposeListener ((function (innerThis, finalVars) {
60+
if (!Clazz.isClassDefined ("com.ognize.jface.async.AsyncWindowProxy$1$2")) {
61+
Clazz.pu$h ();
62+
cla$$ = com.ognize.jface.async.AsyncWindowProxy$1$2 = function () {
63+
Clazz.prepareCallback (this, arguments);
64+
Clazz.instantialize (this, arguments);
65+
};
66+
Clazz.decorateAsType (cla$$, "com.ognize.jface.async.AsyncWindowProxy$1$2", null, $wt.events.DisposeListener);
67+
Clazz.defineMethod (cla$$, "widgetDisposed",
68+
function (e) {
69+
//this.$finals.runnable.run ();
70+
this.callbacks["com.ognize.jface.async.AsyncWindowProxy"].getActiveDisplay ().timerExec (5, this.$finals.runnable);
71+
}, "$wt.events.DisposeEvent");
72+
cla$$ = Clazz.p0p ();
73+
}
74+
return Clazz.innerTypeInstance (com.ognize.jface.async.AsyncWindowProxy$1$2, innerThis, finalVars);
75+
}) (this, Clazz.cloneFinals ("runnable", this.$finals.runnable)));
76+
$hell.getDisplay ().readAndDispatch ();
77+
});
78+
cla$$ = Clazz.p0p ();
79+
}
80+
return Clazz.innerTypeInstance (com.ognize.jface.async.AsyncWindowProxy$1, innerThis, finalVars);
81+
}) (this, Clazz.cloneFinals ("runnable", runnable)).run ();
82+
*/
83+
public void open(final AsyncWindowRunnable runnable) {
84+
runnable.setWindow(window);
85+
new Thread(new Runnable() {
86+
public void run() {
87+
while (window.getShell() == null) {
88+
try {
89+
Thread.sleep(10);
90+
} catch (InterruptedException e) {
91+
e.printStackTrace();
92+
}
93+
}
94+
getActiveDisplay().syncExec(new Runnable() {
95+
public void run() {
96+
window.getShell().addDisposeListener(new DisposeListener() {
97+
public synchronized void widgetDisposed(DisposeEvent e) {
98+
runnable.run();
99+
}
100+
});
101+
}
102+
});
103+
}
104+
}).start();
105+
window.open();
106+
}
107+
108+
/*
109+
public void open(final AsyncWindowRunnable runnable) {
110+
runnable.setWindow(window);
111+
window.open();
112+
new Runnable() {
113+
public void run() {
114+
if (window.getShell() == null) {
115+
getActiveDisplay().timerExec(10, this);
116+
return ;
117+
}
118+
window.getShell().addDisposeListener(new DisposeListener() {
119+
public synchronized void widgetDisposed(DisposeEvent e) {
120+
//runnable.run();
121+
getActiveDisplay().timerExec(5, runnable);
122+
}
123+
});
124+
}
125+
}.run();
126+
}
127+
*/
128+
129+
Display getActiveDisplay() {
130+
Display display = null;
131+
Shell shell = window.getShell();
132+
if (shell == null) {
133+
shell = WindowProxy.getParentShell(window);
134+
}
135+
if (shell != null) {
136+
display = shell.getDisplay();
137+
}
138+
if (display == null) {
139+
display = Display.getCurrent();
140+
}
141+
if (display == null) {
142+
display = Display.getDefault();
143+
}
144+
return display;
145+
}
146+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
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 com.ognize.jface.async;
15+
16+
import org.eclipse.jface.window.Window;
17+
18+
/**
19+
* @author josson smith
20+
*
21+
* 2006-4-29
22+
*/
23+
public abstract class AsyncWindowRunnable implements Runnable {
24+
private Window window;
25+
26+
protected void setWindow(Window window) {
27+
this.window = window;
28+
}
29+
30+
public Window getWindow() {
31+
return window;
32+
}
33+
34+
public int getReturnCode() {
35+
return window.getReturnCode();
36+
}
37+
}

0 commit comments

Comments
 (0)
X Tutup