Skip to content

Commit 959b970

Browse files
author
jossonsmith
committed
ProgressBar improved with help of asynchronous JUnit tests.
1 parent 52cf4a6 commit 959b970

1 file changed

Lines changed: 26 additions & 5 deletions

File tree

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

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

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,16 @@ static int checkStyle (int style) {
132132
return checkBits (style, SWT.HORIZONTAL, SWT.VERTICAL, 0, 0, 0, 0);
133133
}
134134

135+
/* (non-Javadoc)
136+
* @see org.eclipse.swt.widgets.Control#getBorderWidth()
137+
*/
138+
public int getBorderWidth() {
139+
/*if ((style & SWT.BORDER) != 0) {
140+
return 2;
141+
}*/
142+
return 1;
143+
}
144+
135145
public Point computeSize (int wHint, int hHint, boolean changed) {
136146
checkWidget ();
137147
int border = getBorderWidth ();
@@ -166,8 +176,11 @@ void createHandle () {
166176
maximum = 100;
167177
handle = document.createElement ("DIV");
168178
handle.className = "progress-bar-default";
169-
if (parent != null && parent.handle != null) {
170-
parent.handle.appendChild(handle);
179+
if (parent != null) {
180+
Element parentHandle = parent.containerHandle();
181+
if (parentHandle!= null) {
182+
parentHandle.appendChild(handle);
183+
}
171184
}
172185

173186
innerHandle = document.createElement("DIV");
@@ -300,8 +313,9 @@ public void setMaximum (int value) {
300313
OS.SendMessage (handle, OS.PBM_SETRANGE32, minimum, value);
301314
}
302315
*/
303-
if (0 <= minimum && minimum < value) {
316+
if (0 <= minimum && minimum < value && maximum != value) {
304317
maximum = value;
318+
setSelection(selection);
305319
}
306320
}
307321

@@ -326,8 +340,9 @@ public void setMinimum (int value) {
326340
OS.SendMessage (handle, OS.PBM_SETRANGE32, value, maximum);
327341
}
328342
*/
329-
if (0 <= value && value < maximum) {
343+
if (0 <= value && value < maximum && minimum != value) {
330344
minimum = value;
345+
setSelection(selection);
331346
}
332347
}
333348

@@ -346,7 +361,13 @@ public void setMinimum (int value) {
346361
public void setSelection (int value) {
347362
checkWidget ();
348363
// OS.SendMessage (handle, OS.PBM_SETPOS, value, 0);
349-
selection = value;
364+
if (value < minimum) {
365+
selection = minimum;
366+
} else if (value > maximum) {
367+
selection = maximum;
368+
} else {
369+
selection = value;
370+
}
350371
if ((style & SWT.HORIZONTAL) != 0) {
351372
innerHandle.style.width = Math.round(getSize().x * selection / maximum) + "px";
352373
} else {

0 commit comments

Comments
 (0)