Skip to content

Commit 2c9285b

Browse files
author
zhourenjian
committed
1. Fixed bug on Link's border width
2. Support ALAA embedding Java2Script's SWT applications inside other webpage, like blogs 3. Remove unnecessary "@OverRide" for Java 1.4 4. Modify "Display.dispose()" so one SWT application exiting won't close other SWT applications. 5. Improve user experience on notification corner.
1 parent 1f08dec commit 2c9285b

File tree

13 files changed

+273
-88
lines changed

13 files changed

+273
-88
lines changed

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,13 @@ public void widgetDisposed(DisposeEvent e) {
7777
ResizeSystem.unregister((Shell) e.widget, SWT.CENTER);
7878
}
7979
});
80+
Display disp = aboutShell.display;
8081
while (!aboutShell.isDisposed()) {
81-
if (!objShell.display.readAndDispatch())
82-
objShell.display.sleep();
82+
if (!aboutShell.display.readAndDispatch())
83+
aboutShell.display.sleep();
84+
}
85+
if (objShell == null) {
86+
disp.dispose();
8387
}
8488
} catch (Exception e) {
8589
e.printStackTrace();

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ body:nth-of-type(1) .button-arrow-chrome {
106106
.button-input-wrapper INPUT {
107107
position:relative;
108108
top:-6px;
109+
margin:3px;
109110
margin-left:0;
110111
/*margin-right:0;*/
111112
padding-left:0;

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1718,7 +1718,6 @@ public void setMaximized (boolean maximized) {
17181718
if (contentHandle != null) {
17191719
window.setTimeout(Clazz.makeFunction(new Runnable() {
17201720

1721-
@Override
17221721
public void run() {
17231722
Shell lastShell = Display.getTopMaximizedShell();
17241723
if (lastShell == null || lastShell.titleBar == null) return;
@@ -2198,7 +2197,6 @@ public void setText (String string) {
21982197
if (display.taskBar != null) {
21992198
window.setTimeout(Clazz.makeFunction(new Runnable() {
22002199

2201-
@Override
22022200
public void run() {
22032201
display.taskBar.updateLayout();
22042202
// lastMM

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

Lines changed: 123 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,8 @@ public class Display extends Device {
386386

387387
DesktopItem[] desktopItems;
388388

389+
static String bodyOverflow, htmlOverflow;
390+
389391
static int AUTO_HIDE_DELAY = 2000;
390392

391393
/* Private SWT Window Messages */
@@ -404,6 +406,7 @@ public class Display extends Device {
404406

405407
/* Package Name */
406408
static final String PACKAGE_PREFIX = "org.eclipse.swt.widgets."; //$NON-NLS-1$
409+
private RunnableCompatibility mouseMoveListener;
407410
/*
408411
* This code is intentionally commented. In order
409412
* to support CLDC, .class cannot be used because
@@ -941,6 +944,14 @@ protected void destroy () {
941944
void destroyDisplay () {
942945
}
943946

947+
public void dispose() {
948+
Shell[] shells = getShells();
949+
if (shells == null || shells.length == 0) {
950+
super.dispose();
951+
}
952+
//super.dispose();
953+
}
954+
944955
/**
945956
* Causes the <code>run()</code> method of the runnable to
946957
* be invoked by the user-interface thread just before the
@@ -1767,6 +1778,10 @@ Shell getModalDialogShell () {
17671778
Monitor monitor = new Monitor();
17681779
monitor.handle = document.body;
17691780
monitor.clientWidth = document.body.clientWidth;
1781+
int parentWidth = OS.getContainerWidth(document.body.parentNode);
1782+
if (parentWidth > monitor.clientWidth) {
1783+
monitor.clientWidth = parentWidth;
1784+
}
17701785
monitor.width = window.screen.availWidth;
17711786
monitor.clientHeight = OS.getFixedBodyClientHeight(); //document.body.clientHeight;
17721787
monitor.height = window.screen.availHeight;
@@ -2261,13 +2276,20 @@ public Tray getSystemTray () {
22612276
if (tray != null) return tray;
22622277
for (int i = 0; i < Displays.length; i++) {
22632278
Display disp = Displays[i];
2264-
if (disp != null) {
2265-
if (disp.tray != null) {
2266-
return disp.tray;
2279+
if (disp != null && disp.tray != null && !disp.tray.isDisposed()) {
2280+
tray = disp.tray;
2281+
if (disp.trayCorner != null) {
2282+
disp.trayCorner.tray = tray;
22672283
}
2284+
return tray;
22682285
}
22692286
}
2270-
return tray = new Tray (this, SWT.NONE);
2287+
tray = new Tray (this, SWT.NONE);
2288+
if (trayCorner != null) {
2289+
trayCorner.tray = tray;
2290+
trayCorner.initialize();
2291+
}
2292+
return tray;
22712293
}
22722294

22732295
/**
@@ -2445,7 +2467,8 @@ protected void init () {
24452467
void initializeDekstop() {
24462468
for (int i = 0; i < Displays.length; i++) {
24472469
Display disp = Displays[i];
2448-
if (disp != this && disp != null && !disp.isDisposed()) {
2470+
if (disp != this && disp != null && !disp.isDisposed()
2471+
&& disp.taskBar != null && disp.topBar != null) {
24492472
taskBar = disp.taskBar;
24502473
topBar = disp.topBar;
24512474
shortcutBar = disp.shortcutBar;
@@ -2454,22 +2477,33 @@ void initializeDekstop() {
24542477
return;
24552478
}
24562479
}
2457-
24582480
if (desktopItems != null) return;
24592481

2482+
taskBar = new TaskBar(this);
2483+
topBar = new MaximizedTitle(this);
2484+
if (QuickLaunch.defaultQuickLaunch != null) {
2485+
shortcutBar = QuickLaunch.defaultQuickLaunch;
2486+
} else {
2487+
shortcutBar = new QuickLaunch(this);
2488+
}
2489+
if (NotificationCorner.defaultNotificationCorner != null) {
2490+
trayCorner = NotificationCorner.defaultNotificationCorner;
2491+
} else {
2492+
trayCorner = new NotificationCorner(this);
2493+
}
2494+
24602495
desktopItems = new DesktopItem[] {
2461-
taskBar = new TaskBar(this),
2462-
topBar = new MaximizedTitle(this),
2463-
shortcutBar = new QuickLaunch(this),
2464-
trayCorner = new NotificationCorner(this)
2496+
taskBar,
2497+
topBar,
2498+
shortcutBar,
2499+
trayCorner
24652500
};
24662501
for (int i = 0; i < desktopItems.length; i++) {
24672502
desktopItems[i].initialize();
24682503
}
24692504

2470-
RunnableCompatibility listener = new RunnableCompatibility(){
2505+
mouseMoveListener = new RunnableCompatibility(){
24712506

2472-
@Override
24732507
public void run() {
24742508
HTMLEvent e = (HTMLEvent) getEvent();
24752509
for (int i = 0; i < desktopItems.length; i++) {
@@ -2483,15 +2517,14 @@ public void run() {
24832517
}
24842518

24852519
};
2486-
24872520
/**
24882521
* @j2sNative
24892522
if (document.addEventListener) {
2490-
document.addEventListener ("mousemove", listener, false);
2523+
document.addEventListener ("mousemove", this.mouseMoveListener, false);
24912524
} else if (document.attachEvent) {
2492-
document.attachEvent ("onmousemove", listener);
2525+
document.attachEvent ("onmousemove", this.mouseMoveListener);
24932526
}
2494-
*/ { listener.run(); }
2527+
*/ { mouseMoveListener.run(); }
24952528

24962529
}
24972530

@@ -3333,7 +3366,16 @@ protected void release () {
33333366
Shell shell = shells [i];
33343367
if (!shell.isDisposed ()) shell.dispose ();
33353368
}
3336-
if (tray != null) tray.dispose ();
3369+
int trayRefs = 1;
3370+
for (int i = 0; i < Displays.length; i++) {
3371+
Display disp = Displays[i];
3372+
if (disp != this && disp != null && !disp.isDisposed()) {
3373+
if (disp.tray != null) {
3374+
trayRefs++;
3375+
}
3376+
}
3377+
}
3378+
if (tray != null && trayRefs < 2) tray.dispose ();
33373379
tray = null;
33383380
/*
33393381
* Don't loop this "while"!
@@ -3363,6 +3405,24 @@ protected void release () {
33633405
releaseDesktop ();
33643406
releaseDisplay ();
33653407
super.release ();
3408+
3409+
if (NotificationCorner.defaultNotificationCorner != null) {
3410+
new Display().getSystemTray();
3411+
NotificationCorner corner = NotificationCorner.defaultNotificationCorner;
3412+
document.body.removeChild(corner.handle);
3413+
document.body.appendChild(corner.handle);
3414+
}
3415+
if (NotificationCorner.defaultNotificationCorner == null
3416+
&& QuickLaunch.defaultQuickLaunch == null) {
3417+
if (htmlOverflow != null) {
3418+
document.body.parentNode.style.overflow = htmlOverflow;
3419+
htmlOverflow = null;
3420+
}
3421+
if (bodyOverflow != null) {
3422+
document.body.style.overflow = bodyOverflow;
3423+
bodyOverflow = null;
3424+
}
3425+
}
33663426
}
33673427

33683428
void releaseDesktop () {
@@ -3375,17 +3435,51 @@ void releaseDesktop () {
33753435
}
33763436
}
33773437
if (existed) {
3438+
existed = false;
3439+
for (int i = 0; i < Displays.length; i++) {
3440+
Display disp = Displays[i];
3441+
if (disp != this && disp != null && !disp.isDisposed()
3442+
&& disp.tray != null && !disp.tray.isDisposed()) {
3443+
existed = true;
3444+
break;
3445+
}
3446+
}
3447+
if (!existed && trayCorner.handle != null) {
3448+
trayCorner.handle.style.display = "none";
3449+
}
33783450
return;
33793451
}
33803452

3453+
int trayRefs = 1;
3454+
for (int i = 0; i < Displays.length; i++) {
3455+
Display disp = Displays[i];
3456+
if (disp != this && disp != null && !disp.isDisposed()) {
3457+
if (disp.tray != null) {
3458+
trayRefs++;
3459+
}
3460+
}
3461+
}
3462+
33813463
for (int i = 0; i < desktopItems.length; i++) {
3464+
if (trayRefs > 1 && desktopItems[i] == trayCorner) {
3465+
continue;
3466+
}
33823467
desktopItems[i].releaseWidget();
33833468
}
33843469
desktopItems = null;
33853470
trayCorner = null;
33863471
taskBar = null;
33873472
shortcutBar = null;
33883473
topBar = null;
3474+
3475+
/**
3476+
* @j2sNative
3477+
if (document.removeEventListener) {
3478+
document.removeEventListener ("mousemove", this.mouseMoveListener, false);
3479+
} else if (document.detachEvent) {
3480+
document.detachEvent ("onmousemove", this.mouseMoveListener);
3481+
}
3482+
*/ { mouseMoveListener.run(); }
33893483
}
33903484

33913485
void releaseDisplay () {
@@ -3655,14 +3749,21 @@ void removeBar (Menu menu) {
36553749
Control removeControl (Object handle) {
36563750
if (handle == null) return null;
36573751
Control control = null;
3658-
int index = 0;
3752+
int index = -1;
36593753
/*
36603754
if (USE_PROPERTY) {
36613755
index = OS.RemoveProp (handle, SWT_OBJECT_INDEX) - 1;
36623756
} else {
36633757
index = OS.GetWindowLong (handle, OS.GWL_USERDATA) - 1;
36643758
}
36653759
*/
3760+
for (int i = 0; i < controlTable.length; i++) {
3761+
Control ctrl = controlTable [i];
3762+
if (ctrl != null && ctrl.handle == handle) {
3763+
index = i;
3764+
break;
3765+
}
3766+
}
36663767
if (0 <= index && index < controlTable.length) {
36673768
control = controlTable [index];
36683769
controlTable [index] = null;
@@ -4393,14 +4494,12 @@ static Tray getTray() {
43934494
if (Default != null) {
43944495
tray = Default.tray;
43954496
}
4396-
if (tray != null) {
4497+
if (tray == null || tray.isDisposed()) {
43974498
for (int i = 0; i < Displays.length; i++){
43984499
Display disp = Displays[i];
4399-
if (disp != null) {
4400-
if (disp.tray != null){
4401-
tray = disp.tray;
4402-
break;
4403-
}
4500+
if (disp != null && disp.tray != null && !disp.tray.isDisposed()){
4501+
tray = disp.tray;
4502+
break;
44044503
}
44054504
}
44064505
}

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -397,9 +397,11 @@ public void getFocus (AccessibleControlEvent e) {
397397
/* (non-Javadoc)
398398
* @see org.eclipse.swt.widgets.Control#getBorderWidth()
399399
*/
400+
/*
400401
public int getBorderWidth() {
401402
return 2;
402403
}
404+
*/
403405

404406
String getNameText () {
405407
return getText ();

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

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ void hide() {
117117
}
118118

119119
}
120-
@Override
120+
121121
public void handleApproaching() {
122122
Element topbar = handle;
123123
if (topbar == null) return;
@@ -129,7 +129,7 @@ public void handleApproaching() {
129129
}
130130
}
131131
}
132-
@Override
132+
133133
public void handleLeaving() {
134134
Element topbar = handle;
135135
if (topbar == null) return;
@@ -138,12 +138,12 @@ public void handleLeaving() {
138138
returnTopMaximized (null);
139139
}
140140
}
141-
@Override
141+
142142
public boolean isApproaching(HTMLEvent e) {
143143
mouseAlreadyMoved = true;
144144
return (e.clientY <= 8 && !e.ctrlKey) && isAround (e.clientX, e.clientY);
145145
}
146-
@Override
146+
147147
public boolean isLeaving(HTMLEvent e) {
148148
mouseAlreadyMoved = true;
149149
long now = new Date().getTime();
@@ -153,7 +153,6 @@ public boolean isLeaving(HTMLEvent e) {
153153
return !isAround (e.clientX, e.clientY) || e.ctrlKey || e.clientY > 12 + ((topShell.titleBar != null) ? OS.getContainerHeight (topShell.titleBar) : 20);
154154
}
155155

156-
@Override
157156
public void bringToTop(String index) {
158157
// TODO Auto-generated method stub
159158

@@ -163,7 +162,6 @@ public boolean isVisible() {
163162
return handle.style.display != "none";
164163
}
165164

166-
@Override
167165
public void releaseWidget() {
168166
if (handle != null) {
169167
OS.destroyHandle(handle);

0 commit comments

Comments
 (0)