Skip to content

Commit ff7bec7

Browse files
author
zhourenjian
committed
Fixing bug of CSS loading, Label#setImage and Shell#close
1 parent 0c996f4 commit ff7bec7

3 files changed

Lines changed: 29 additions & 24 deletions

File tree

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,9 +136,11 @@ $WTC$$.globalChecking = function () {
136136
/* private */
137137
$WTC$$.getCSSRuleID = function (clazzName) {
138138
var cssRuleID = null;
139-
if (clazzName.indexOf ("org.eclipse.swt.") == 0 || clazzName.indexOf ("$wt.")) {
139+
if (clazzName.indexOf ("org.eclipse.swt.") == 0 || clazzName.indexOf ("$wt.") == 0) {
140140
var idx = clazzName.indexOf ("wt.") + 3;
141141
cssRuleID = "swt." + clazzName.substring (idx);
142+
} else {
143+
cssRuleID = clazzName;
142144
}
143145
return cssRuleID.toLowerCase ().replace (/\./g, '-');
144146
};

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -523,7 +523,6 @@ public void setAlignment (int alignment) {
523523
*/
524524
public void setImage (Image image) {
525525
checkWidget ();
526-
if (image == null) return ;
527526
if ((style & SWT.SEPARATOR) != 0) return;
528527
if (image != null && image.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);
529528
//_setImage (this.image = image);

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

Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -493,36 +493,40 @@ int callWindowProc (int hwnd, int msg, int wParam, int lParam) {
493493
*/
494494
public void close () {
495495
checkWidget ();
496-
if (parent == null && (this.getStyle() & SWT.TOOL) == 0 && display.taskBar != null) {
497-
TaskBar taskBar = display.taskBar;
498-
taskBar.removeShellItem(this);
499-
taskBar.handleApproaching();
500-
taskBar.updateLayout();
501-
taskBar.setMinimized(false);
502-
taskBar.updateLastModified();
503-
}
504496
Shell nextShell = null;
505497
if (parent instanceof Shell) {
506498
nextShell = (Shell) parent;
507499
if (!nextShell.isVisible()) {
508500
nextShell = null;
509501
}
510502
}
503+
Display display = this.display;
511504
closeWidget ();
512-
if (nextShell == null || nextShell.isDisposed()) {
513-
nextShell = Display.getTopShell();
514-
}
515-
if (nextShell != null && !nextShell.isDisposed()) {
516-
nextShell.bringToTop();
517-
nextShell.forceFocus();
518-
} else
519-
/**
520-
* Return to default title
521-
* @j2sNative
522-
* if (window["document.title"] != null) {
523-
* document.title = window["document.title"];
524-
* }
525-
*/ {}
505+
if (isDisposed()) {
506+
if (parent == null && (this.getStyle() & SWT.TOOL) == 0
507+
&& display != null && display.taskBar != null) {
508+
TaskBar taskBar = display.taskBar;
509+
taskBar.removeShellItem(this);
510+
taskBar.handleApproaching();
511+
taskBar.updateLayout();
512+
taskBar.setMinimized(false);
513+
taskBar.updateLastModified();
514+
}
515+
if (nextShell == null || nextShell.isDisposed()) {
516+
nextShell = Display.getTopShell();
517+
}
518+
if (nextShell != null && !nextShell.isDisposed()) {
519+
nextShell.bringToTop();
520+
nextShell.forceFocus();
521+
} else
522+
/**
523+
* Return to default title
524+
* @j2sNative
525+
* if (window["document.title"] != null) {
526+
* document.title = window["document.title"];
527+
* }
528+
*/ {}
529+
}
526530
}
527531

528532
protected void createHandle () {

0 commit comments

Comments
 (0)