Skip to content

Commit d421027

Browse files
author
zhourenjian
committed
Checkin Java2Script Desktop:
Split ShellManager into MaximizedTitle, TaskBar, NotificationCorner and QuickLaunch
1 parent d2481a3 commit d421027

23 files changed

+1726
-1229
lines changed

sources/net.sf.j2s.java.org.eclipse.swt/.j2s

Lines changed: 2 additions & 2 deletions
Large diffs are not rendered by default.

sources/net.sf.j2s.java.org.eclipse.swt/src/org/eclipse/swt/internal/ResizeHandler.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -71,16 +71,16 @@ public void updateMaximized() {
7171
int titleHeight = ((shell.getStyle() & SWT.TITLE) != 0) ? OS.getContainerHeight(tb) : 0;
7272
// FIXME: maximized size is not accurate
7373
//shell.setBounds(shell.computeTrim(0, 0, width + 4, height - titleHeight + 6));
74-
boolean isOptMaximized = false;
75-
/**
76-
* @j2sNative
77-
* isOptMaximized = window["ShellManager"] != null;
78-
*/ {}
79-
if (!isOptMaximized) {
80-
shell.setBounds(shell.computeTrim(0, 0, width, height - titleHeight));
81-
} else {
74+
// boolean isOptMaximized = false;
75+
// /**
76+
// * @j2sNative
77+
// * isOptMaximized = window["ShellManager"] != null;
78+
// */ {}
79+
// if (!isOptMaximized) {
80+
// shell.setBounds(shell.computeTrim(0, 0, width, height - titleHeight));
81+
// } else {
8282
shell.setBounds(shell.computeTrim(0, -titleHeight, width, height));
83-
}
83+
// }
8484
// shell.setBounds(0 - 4, 0 - 4, width - 2, height + 4);
8585
//shell.setBounds(shell.computeTrim(0, 0, width + 2, height - 18));
8686
}

sources/net.sf.j2s.java.org.eclipse.swt/src/org/eclipse/swt/internal/ResizeSystem.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
import org.eclipse.swt.SWT;
1515
import org.eclipse.swt.widgets.Decorations;
16+
import org.eclipse.swt.widgets.Display;
1617
import org.eclipse.swt.widgets.Monitor;
1718

1819
/**
@@ -113,10 +114,6 @@ public static void updateResize() {
113114
}
114115
}
115116

116-
/**
117-
* @j2sNative
118-
* $wt.widgets.ShellManager.layoutTasks();
119-
* $wt.widgets.ShellManager.layoutShortcuts();
120-
*/ {}
117+
Display.getDefault().updateLayout();
121118
}
122119
}

sources/net.sf.j2s.java.org.eclipse.swt/src/org/eclipse/swt/internal/xhtml/Element.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ public class Element {
1717
public CSSStyle style;
1818
public String id;
1919
public String innerHTML;
20-
public String innerText;
20+
public String innerText; // IE
21+
public String text; // Mozilla
2122

2223
public String value;
2324
public String type;

sources/net.sf.j2s.java.org.eclipse.swt/src/org/eclipse/swt/package.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -405,15 +405,20 @@ if (!isDebugging) {
405405

406406
var wPath = ClazzLoader.getClasspathFor ("org.eclipse.swt.widgets.*");
407407
ClazzLoader.jarClasspath (wPath + "Shell.z.js", [
408-
"$wt.widgets.Display",
408+
"$wt.widgets.DesktopListener",
409+
"$.DesktopItem",
410+
"$.TaskBar",
411+
"$.MaximizedTitle",
412+
"$.QuickLaunch",
413+
"$.NotificationCorner",
414+
"$.Display",
409415
"$.Widget",
410416
"$.Control",
411417
"$.ScrollBar",
412418
"$.Scrollable",
413419
"$.Composite",
414420
"$.Canvas",
415421
"$.Decorations",
416-
"$.ShellManager",
417422
"$.Shell",
418423
"$.Dialog"
419424
]);
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
*
3737
* Aug 3, 2008
3838
*/
39-
public class AboutJava2Script {
39+
public class About {
4040

4141
/**
4242
* Launch the application
@@ -107,7 +107,7 @@ private static void createContents(Shell aboutShell) {
107107
* @j2sNative
108108
* logoImage = new $wt.graphics.Image ($wt.widgets.Display.getCurrent (), this.getClass().getResourceAsStream ("images/j2s-logo.gif"));
109109
*/ {}
110-
//logo.setImage(SWTResourceManager.getImage(AboutJava2Script.class, "images/j2s-logo.gif"));
110+
//logo.setImage(SWTResourceManager.getImage(About.class, "images/j2s-logo.gif"));
111111
logo.setImage(logoImage);
112112

113113
logo.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));

sources/net.sf.j2s.java.org.eclipse.swt/src/org/eclipse/swt/widgets/Decorations.java

Lines changed: 76 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import org.eclipse.swt.internal.dnd.HTMLEventWrapper;
2626
import org.eclipse.swt.internal.dnd.ShellFrameDND;
2727
import org.eclipse.swt.internal.xhtml.CSSStyle;
28+
import org.eclipse.swt.internal.xhtml.Clazz;
2829
import org.eclipse.swt.internal.xhtml.Element;
2930
import org.eclipse.swt.internal.xhtml.HTMLEvent;
3031
import org.eclipse.swt.internal.xhtml.document;
@@ -751,12 +752,12 @@ void exportHTMLSource(boolean onlyContent) {
751752

752753
/**
753754
* @j2sNative
754-
* ClazzLoader.loadClass ("org.eclipse.swt.widgets.AboutJava2Script", (function (o) { return function () {
755-
* $wt.widgets.AboutJava2Script.openAbout (o);
755+
* ClazzLoader.loadClass ("org.eclipse.swt.widgets.About", (function (o) { return function () {
756+
* $wt.widgets.About.openAbout (o);
756757
* }; }) (this));
757758
* @j2sNativeSrc
758-
* ClazzLoader.loadClass ("org.eclipse.swt.widgets.AboutJava2Script", (function (o) { return function () {
759-
* $wt.widgets.AboutJava2Script.openAbout (o);
759+
* ClazzLoader.loadClass ("org.eclipse.swt.widgets.About", (function (o) { return function () {
760+
* $wt.widgets.About.openAbout (o);
760761
* }; }) (this));
761762
*/
762763
void openAboutJava2Script() {
@@ -801,12 +802,9 @@ public void dispose () {
801802
* }
802803
* }
803804
*/ {}
804-
/**
805-
* @j2sNative
806-
* if (window["ShellManager"] != null && (this.getStyle() & 4) == 0) { // SWT.TOOL
807-
* ShellManager.removeShellItem (this);
808-
* }
809-
*/ {}
805+
if ((this.getStyle() & SWT.TOOL) == 0 && display.taskBar != null) {
806+
display.taskBar.removeShellItem ((Shell) this);
807+
}
810808
super.dispose ();
811809
}
812810

@@ -1116,12 +1114,9 @@ public boolean getMinimized () {
11161114
if (OS.IsWindowVisible (handle)) return OS.IsIconic (handle);
11171115
return swFlags == OS.SW_SHOWMINNOACTIVE;
11181116
*/
1119-
/**
1120-
* @j2sNative
1121-
* if (window["ShellManager"] != null && this.parent == null) {
1122-
* return this.handle.style.display == "none";
1123-
* }
1124-
*/ {}
1117+
if (this.parent == null) {
1118+
return this.handle.style.display == "none";
1119+
}
11251120
return this.minimized; // TODO
11261121
}
11271122

@@ -1464,7 +1459,7 @@ public void setImage (Image image) {
14641459
// imgBackground.style.height = "100%";
14651460
// imgBackground.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\"" + this.image.url + "\", sizingMethod=\"image\")";
14661461
// handle.appendChild(imgBackground);
1467-
iconStyle.backgroundImage = "";
1462+
iconStyle.backgroundImage = "url(\"about:blank\")";
14681463
iconStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\"" + this.image.url + "\", sizingMethod=\"image\")";
14691464
} else {
14701465
if (OS.isIENeedPNGFix && iconStyle.filter != null) iconStyle.filter = "";
@@ -1685,7 +1680,7 @@ public void setMaximized (boolean maximized) {
16851680
* };
16861681
*/ { }
16871682
}
1688-
boolean toUpdateMax = false;
1683+
// boolean toUpdateMax = false;
16891684
if (contentHandle != null) {
16901685
if (oldBounds == null) {
16911686
oldBounds = getBounds();
@@ -1700,44 +1695,43 @@ public void setMaximized (boolean maximized) {
17001695
}
17011696
//int titleHeight = ((style & SWT.TITLE) != 0) ? 20 : 0;
17021697
int titleHeight = ((style & SWT.TITLE) != 0) ? OS.getContainerHeight(titleBar) : 0;
1703-
boolean isOptMaximized = false;
1704-
/**
1705-
* @j2sNative
1706-
* isOptMaximized = window["ShellManager"] != null;
1707-
*/ {}
1708-
1709-
1710-
if (!isOptMaximized) {
1711-
setBounds(computeTrim(0, 0, width, height - titleHeight));
1712-
} else {
1698+
// boolean isOptMaximized = false;
1699+
// /**
1700+
// * @j2sNative
1701+
// * isOptMaximized = window["ShellManager"] != null;
1702+
// */ {}
1703+
//
1704+
//
1705+
// if (!isOptMaximized) {
1706+
// setBounds(computeTrim(0, 0, width, height - titleHeight));
1707+
// } else {
17131708
Rectangle trim = computeTrim(0, -titleHeight, width, height);
17141709
setBounds(trim.x, trim.y, trim.width, trim.height);
1715-
toUpdateMax = true;
1716-
}
1710+
// toUpdateMax = true;
1711+
// }
17171712
}
17181713
ResizeSystem.register(this, SWT.MAX);
17191714
if (titleBar != null) {
17201715
OS.addCSSClass(titleBar, key);
17211716
}
1722-
if (window.currentTopZIndex == null) {
1723-
handle.style.zIndex = window.currentTopZIndex = "1000";
1724-
} else {
1725-
handle.style.zIndex = window.currentTopZIndex = ""
1726-
+ (Integer.parseInt(window.currentTopZIndex) + 1);
1717+
handle.style.zIndex = Display.getNextZIndex(true);
1718+
if (contentHandle != null) {
1719+
window.setTimeout(Clazz.makeFunction(new Runnable() {
1720+
1721+
@Override
1722+
public void run() {
1723+
Shell lastShell = Display.getTopMaximizedShell();
1724+
if (lastShell == null || lastShell.titleBar == null) return;
1725+
if (display.topBar != null) {
1726+
MaximizedTitle topBar = display.topBar;
1727+
topBar.handleApproaching();
1728+
topBar.updateLayout();
1729+
topBar.updateLastModified();
1730+
}
1731+
}
1732+
1733+
}), 250);
17271734
}
1728-
if (toUpdateMax)
1729-
/**
1730-
* @j2sNative
1731-
* window.setTimeout (function () {
1732-
* var lastShell = ShellManager.getTopMaximizedShell ();
1733-
* if (lastShell == null || lastShell.titleBar == null) return;
1734-
* if (ShellManager.topbarContainerEl != null) {
1735-
* ShellManager.topbarContainerEl.style.display = "block";
1736-
* }
1737-
* ShellManager.updateTopMaximized ();
1738-
* ShellManager.lastMMed = new Date().getTime();
1739-
* }, 250);
1740-
*/ {}
17411735
} else {
17421736
setBounds(oldBounds);
17431737
if (titleBar != null) {
@@ -1888,18 +1882,13 @@ public void setMinimized (boolean minimized) {
18881882
return;
18891883
}
18901884
}
1891-
/**
1892-
* @j2sNative
1893-
* if (window["ShellManager"] != null && this.parent == null && minimized) {
1894-
* this.handle.style.display = "none";
1895-
* if (ShellManager.sidebarEl != null) {
1896-
* ShellManager.sidebarEl.style.display = "block";
1897-
* }
1898-
* ShellManager.updateItems ();
1899-
* ShellManager.lastMMed = new Date().getTime();
1900-
* return;
1901-
* }
1902-
*/ {}
1885+
if (this.parent == null && minimized && display.taskBar != null) {
1886+
this.handle.style.display = "none";
1887+
display.taskBar.handleApproaching();
1888+
display.taskBar.updateLayout();
1889+
// lastMMed
1890+
return;
1891+
}
19031892
if (minimized && contentHandle != null) {
19041893
//handle.style.display = "none";
19051894
if (oldBounds == null) {
@@ -2086,12 +2075,9 @@ public void run() {
20862075
Decorations shell = Decorations.this;
20872076
ResizeSystem.unregister(shell, SWT.MIN);
20882077
setMinimized(true);
2089-
/**
2090-
* @j2sNative
2091-
* if (window["ShellManager"] != null) {
2092-
* ShellManager.returnTopMaximized (shell);
2093-
* }
2094-
*/ { }
2078+
if (display.topBar != null) {
2079+
display.topBar.returnTopMaximized((Shell) shell);
2080+
}
20952081
}
20962082
};
20972083
}
@@ -2105,12 +2091,9 @@ public void run() {
21052091
boolean cur = !getMaximized();
21062092
setMaximized(cur);
21072093
Decorations shell = Decorations.this;
2108-
/**
2109-
* @j2sNative
2110-
* if (window["ShellManager"] != null && !cur) {
2111-
* ShellManager.returnTopMaximized (shell);
2112-
* }
2113-
*/ { shell.bringToTop(); }
2094+
if (!cur && display.topBar != null) {
2095+
display.topBar.returnTopMaximized((Shell) shell);
2096+
}
21142097
display.timerExec(25, new Runnable() {
21152098
public void run() {
21162099
layout();
@@ -2128,12 +2111,9 @@ public void run() {
21282111
public void run() {
21292112
if (Decorations.this instanceof Shell) {
21302113
Shell shell = (Shell) Decorations.this;
2131-
/**
2132-
* @j2sNative
2133-
* if (window["ShellManager"] != null) {
2134-
* ShellManager.returnTopMaximized (shell);
2135-
* }
2136-
*/ { }
2114+
if (display.topBar != null) {
2115+
display.topBar.returnTopMaximized(shell);
2116+
}
21372117
shell.close();
21382118
}
21392119
}
@@ -2170,12 +2150,8 @@ public void run() {
21702150
}
21712151
};
21722152

2173-
if (window.currentTopZIndex == null) {
2174-
handle.style.zIndex = window.currentTopZIndex = "1000";
2175-
} else {
2176-
handle.style.zIndex = window.currentTopZIndex = ""
2177-
+ (Integer.parseInt(window.currentTopZIndex) + 2);
2178-
}
2153+
Display.getNextZIndex(true);
2154+
handle.style.zIndex = Display.getNextZIndex(true);
21792155
}
21802156

21812157
/**
@@ -2206,19 +2182,22 @@ public void setText (String string) {
22062182
}
22072183
}
22082184
shellTitle.appendChild(document.createTextNode(string));
2209-
/**
2210-
* @j2sNative
2211-
* if (window["ShellManager"] != null && this.parent == null
2212-
* && (this.getStyle() & 4) == 0) { // SWT.TOOL
2213-
* if (ShellManager.sidebarEl != null) {
2214-
* ShellManager.sidebarEl.style.display = "block";
2215-
* }
2216-
* window.setTimeout (function () {
2217-
* ShellManager.updateItems ();
2218-
* ShellManager.lastMMed = new Date().getTime();
2219-
* }, 50);
2220-
* }
2221-
*/ {}
2185+
2186+
if (this.parent == null && (this.getStyle() & SWT.TOOL) == 0
2187+
&& display.taskBar != null) {
2188+
display.taskBar.handleApproaching();
2189+
}
2190+
if (display.taskBar != null) {
2191+
window.setTimeout(Clazz.makeFunction(new Runnable() {
2192+
2193+
@Override
2194+
public void run() {
2195+
display.taskBar.updateLayout();
2196+
// lastMM
2197+
}
2198+
2199+
}), 50);
2200+
}
22222201
}
22232202
}
22242203

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package org.eclipse.swt.widgets;
2+
3+
public interface DesktopItem {
4+
5+
public void initialize();
6+
7+
public void bringToTop(String zIndex);
8+
9+
public void updateLayout();
10+
11+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package org.eclipse.swt.widgets;
2+
3+
import org.eclipse.swt.internal.xhtml.HTMLEvent;
4+
5+
public interface DesktopListener {
6+
7+
public boolean isApproaching(HTMLEvent e);
8+
9+
public boolean isLeaving(HTMLEvent e);
10+
11+
public void handleApproaching();
12+
13+
public void handleLeaving();
14+
15+
}

0 commit comments

Comments
 (0)