Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 345597
Collapse All | Expand All

(-)src/org/eclipse/rwt/internal/lifecycle/JSConst.java (+1 lines)
Lines 158-163 Link Here
158
  public static final String QX_FIELD_FONT = "font";
158
  public static final String QX_FIELD_FONT = "font";
159
  public static final String QX_FIELD_COLOR = "textColor";
159
  public static final String QX_FIELD_COLOR = "textColor";
160
  public static final String QX_FIELD_BG_COLOR = "backgroundColor";
160
  public static final String QX_FIELD_BG_COLOR = "backgroundColor";
161
  public static final String QX_FIELD_BG_GRADIENT = "backgroundGradient";
161
  public static final String QX_FIELD_ORIENTATION = "orientation";
162
  public static final String QX_FIELD_ORIENTATION = "orientation";
162
  public static final String QX_FIELD_CAPTION = "caption";
163
  public static final String QX_FIELD_CAPTION = "caption";
163
  public static final String QX_FIELD_ENABLED = "enabled";
164
  public static final String QX_FIELD_ENABLED = "enabled";
(-)src/org/eclipse/rwt/lifecycle/WidgetLCAUtil.java (-5 / +5 lines)
Lines 690-698 Link Here
690
   * @throws IOException
690
   * @throws IOException
691
   * @see {@link #preserveBackground(Widget, Color, boolean)}
691
   * @see {@link #preserveBackground(Widget, Color, boolean)}
692
   */
692
   */
693
  public static void writeBackground( final Widget widget,
693
  public static void writeBackground( Widget widget, Color background, boolean transparency )
694
                                      final Color background,
695
                                      final boolean transparency )
696
    throws IOException
694
    throws IOException
697
  {
695
  {
698
    JSWriter writer = JSWriter.getWriterFor( widget );
696
    JSWriter writer = JSWriter.getWriterFor( widget );
Lines 701-715 Link Here
701
                                                Boolean.valueOf( transparency ),
699
                                                Boolean.valueOf( transparency ),
702
                                                Boolean.FALSE );
700
                                                Boolean.FALSE );
703
    if( !changed && !transparency ) {
701
    if( !changed && !transparency ) {
704
      changed
702
      changed = WidgetLCAUtil.hasChanged( widget, PROP_BACKGROUND, background, null );
705
        = WidgetLCAUtil.hasChanged( widget, PROP_BACKGROUND, background, null );
706
    }
703
    }
707
    if( changed ) {
704
    if( changed ) {
708
      if( transparency ) {
705
      if( transparency ) {
706
        writer.set( JSConst.QX_FIELD_BG_GRADIENT, ( Object )null );
709
        writer.set( JSConst.QX_FIELD_BG_COLOR, ( Object )null );
707
        writer.set( JSConst.QX_FIELD_BG_COLOR, ( Object )null );
710
      } else if( background != null ) {
708
      } else if( background != null ) {
709
        writer.set( JSConst.QX_FIELD_BG_GRADIENT, ( Object )null );
711
        writer.set( JSConst.QX_FIELD_BG_COLOR, background );
710
        writer.set( JSConst.QX_FIELD_BG_COLOR, background );
712
      } else {
711
      } else {
712
        writer.reset( JSConst.QX_FIELD_BG_GRADIENT );
713
        writer.reset( JSConst.QX_FIELD_BG_COLOR );
713
        writer.reset( JSConst.QX_FIELD_BG_COLOR );
714
      }
714
      }
715
    }
715
    }
(-)src/org/eclipse/rwt/lifecycle/WidgetLCAUtil_Test.java (-41 / +52 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2002, 2010 Innoopract Informationssysteme GmbH.
2
 * Copyright (c) 2002, 2011 Innoopract Informationssysteme GmbH.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 31-40 Link Here
31
31
32
32
33
public class WidgetLCAUtil_Test extends TestCase {
33
public class WidgetLCAUtil_Test extends TestCase {
34
  
35
  private Display display;
36
  private Shell shell;
37
38
  protected void setUp() throws Exception {
39
    Fixture.setUp();
40
    display = new Display();
41
    shell = new Shell( display , SWT.NONE );
42
  }
43
  
44
  protected void tearDown() throws Exception {
45
    Fixture.tearDown();
46
  }
34
47
35
  public void testHasChanged() {
48
  public void testHasChanged() {
36
    Display display = new Display();
37
    Shell shell = new Shell( display , SWT.NONE );
38
    Text text = new Text( shell, SWT.NONE );
49
    Text text = new Text( shell, SWT.NONE );
39
    // test initial behaviour, text is same as default value -> no 'change'
50
    // test initial behaviour, text is same as default value -> no 'change'
40
    text.setText( "" );
51
    text.setText( "" );
Lines 60-67 Link Here
60
  }
71
  }
61
72
62
  public void testHasChangedWidthArrays() {
73
  public void testHasChangedWidthArrays() {
63
    Display display = new Display();
64
    Shell shell = new Shell( display , SWT.NONE );
65
    List list = new List( shell, SWT.MULTI );
74
    List list = new List( shell, SWT.MULTI );
66
75
67
    boolean hasChanged;
76
    boolean hasChanged;
Lines 205-212 Link Here
205
  }
214
  }
206
215
207
  public void testFontBold() throws IOException {
216
  public void testFontBold() throws IOException {
208
    Display display = new Display();
209
    Composite shell = new Shell( display, SWT.NONE );
210
    Label label = new Label( shell, SWT.NONE );
217
    Label label = new Label( shell, SWT.NONE );
211
218
212
    Fixture.fakeResponseWriter();
219
    Fixture.fakeResponseWriter();
Lines 225-232 Link Here
225
  }
232
  }
226
233
227
  public void testFontItalic() throws IOException {
234
  public void testFontItalic() throws IOException {
228
    Display display = new Display();
229
    Composite shell = new Shell( display, SWT.NONE );
230
    Label label = new Label( shell, SWT.NONE );
235
    Label label = new Label( shell, SWT.NONE );
231
236
232
    Fixture.fakeResponseWriter();
237
    Fixture.fakeResponseWriter();
Lines 245-252 Link Here
245
  }
250
  }
246
251
247
  public void testFontSize() throws IOException {
252
  public void testFontSize() throws IOException {
248
    Display display = new Display();
249
    Composite shell = new Shell( display, SWT.NONE );
250
    Label label = new Label( shell, SWT.NONE );
253
    Label label = new Label( shell, SWT.NONE );
251
    Fixture.fakeResponseWriter();
254
    Fixture.fakeResponseWriter();
252
    Fixture.markInitialized( display );
255
    Fixture.markInitialized( display );
Lines 259-266 Link Here
259
  }
262
  }
260
263
261
  public void testFontReset() throws IOException {
264
  public void testFontReset() throws IOException {
262
    Display display = new Display();
263
    Composite shell = new Shell( display, SWT.NONE );
264
    Label label = new Label( shell, SWT.NONE );
265
    Label label = new Label( shell, SWT.NONE );
265
    Fixture.fakeResponseWriter();
266
    Fixture.fakeResponseWriter();
266
    Font font = Graphics.getFont( "Arial", 12, SWT.BOLD );
267
    Font font = Graphics.getFont( "Arial", 12, SWT.BOLD );
Lines 272-279 Link Here
272
  }
273
  }
273
274
274
  public void testForegroundReset() throws IOException {
275
  public void testForegroundReset() throws IOException {
275
    Display display = new Display();
276
    Composite shell = new Shell( display, SWT.NONE );
277
    Label label = new Label( shell, SWT.NONE );
276
    Label label = new Label( shell, SWT.NONE );
278
    Fixture.fakeResponseWriter();
277
    Fixture.fakeResponseWriter();
279
    Color red = Graphics.getColor( 255, 0, 0 );
278
    Color red = Graphics.getColor( 255, 0, 0 );
Lines 285-292 Link Here
285
  }
284
  }
286
285
287
  public void testWriteImage() throws IOException {
286
  public void testWriteImage() throws IOException {
288
    Display display = new Display();
289
    Composite shell = new Shell( display , SWT.NONE );
290
    Label item = new Label( shell, SWT.NONE );
287
    Label item = new Label( shell, SWT.NONE );
291
288
292
    // for an un-initialized control: no image -> no markup
289
    // for an un-initialized control: no image -> no markup
Lines 320-327 Link Here
320
  }
317
  }
321
318
322
  public void testWriteVariant() throws IOException {
319
  public void testWriteVariant() throws IOException {
323
    Display display = new Display();
324
    Composite shell = new Shell( display , SWT.NONE );
325
    Label label = new Label( shell, SWT.NONE );
320
    Label label = new Label( shell, SWT.NONE );
326
321
327
    Fixture.fakeResponseWriter();
322
    Fixture.fakeResponseWriter();
Lines 337-344 Link Here
337
  }
332
  }
338
333
339
  public void testWriteCustomVariant() throws IOException {
334
  public void testWriteCustomVariant() throws IOException {
340
    Display display = new Display();
341
    Composite shell = new Shell( display , SWT.NONE );
342
    Control control = new Label( shell, SWT.NONE );
335
    Control control = new Label( shell, SWT.NONE );
343
336
344
    Fixture.fakeResponseWriter();
337
    Fixture.fakeResponseWriter();
Lines 371-378 Link Here
371
  }
364
  }
372
365
373
  public void testWriteBackground() throws Exception {
366
  public void testWriteBackground() throws Exception {
374
    Display display = new Display();
375
    Composite shell = new Shell( display , SWT.NONE );
376
    Control control = new Label( shell, SWT.NONE );
367
    Control control = new Label( shell, SWT.NONE );
377
    Color red = display.getSystemColor( SWT.COLOR_RED );
368
    Color red = display.getSystemColor( SWT.COLOR_RED );
378
369
Lines 422-430 Link Here
422
    assertEquals( "", Fixture.getAllMarkup() );
413
    assertEquals( "", Fixture.getAllMarkup() );
423
  }
414
  }
424
415
416
  public void testWriteBackground_Transparency_RemoveBackgroundGradient() throws IOException {
417
    Control control = new Label( shell, SWT.NONE );
418
    Fixture.markInitialized( control );
419
420
    Fixture.fakeResponseWriter();
421
    WidgetLCAUtil.preserveBackground( control, null, false );
422
    WidgetLCAUtil.writeBackground( control, null, true );
423
    
424
    String expected = "w.setBackgroundGradient( null );w.setBackgroundColor( null );";
425
    assertTrue( Fixture.getAllMarkup().indexOf( expected ) != -1 );
426
  }
427
428
  public void testWriteBackground_ResetBackgroundGradient() throws IOException {
429
    Control control = new Label( shell, SWT.NONE );
430
    Fixture.markInitialized( control );
431
    Color red = display.getSystemColor( SWT.COLOR_RED );
432
433
    Fixture.fakeResponseWriter();
434
    WidgetLCAUtil.preserveBackground( control, red, false );
435
    WidgetLCAUtil.writeBackground( control, null, false );
436
437
    String expected = "w.resetBackgroundGradient();w.resetBackgroundColor();";
438
    assertTrue( Fixture.getAllMarkup().indexOf( expected ) != -1 );
439
  }
440
441
  public void testWriteBackground_RemoveBackgroundGradient() throws IOException {
442
    Control control = new Label( shell, SWT.NONE );
443
    Fixture.markInitialized( control );
444
    Color red = display.getSystemColor( SWT.COLOR_RED );
445
446
    Fixture.fakeResponseWriter();
447
    WidgetLCAUtil.preserveBackground( control, null, false );
448
    WidgetLCAUtil.writeBackground( control, red );
449
    
450
    String expected = "w.setBackgroundGradient( null );w.setBackgroundColor( \"#ff0000\" );";
451
    assertTrue( Fixture.getAllMarkup().indexOf( expected ) != -1 );
452
  }
453
425
  public void testWriteMenu() throws IOException {
454
  public void testWriteMenu() throws IOException {
426
    Display display = new Display();
427
    Composite shell = new Shell( display , SWT.NONE );
428
    Label label = new Label( shell, SWT.NONE );
455
    Label label = new Label( shell, SWT.NONE );
429
456
430
    // for an un-initialized control: no menu -> no markup
457
    // for an un-initialized control: no menu -> no markup
Lines 456-463 Link Here
456
  }
483
  }
457
484
458
  public void testWriteStyleFlag() throws IOException {
485
  public void testWriteStyleFlag() throws IOException {
459
    Display display = new Display();
460
    Composite shell = new Shell( display , SWT.NONE );
461
    Control control = new Label( shell, SWT.NONE );
486
    Control control = new Label( shell, SWT.NONE );
462
    Control borderControl = new Label( shell, SWT.BORDER );
487
    Control borderControl = new Label( shell, SWT.BORDER );
463
488
Lines 472-479 Link Here
472
  }
497
  }
473
498
474
  public void testWriteBackgroundGradient() throws IOException {
499
  public void testWriteBackgroundGradient() throws IOException {
475
    Display display = new Display();
476
    Shell shell = new Shell( display , SWT.NONE );
477
    Control control = new Composite( shell, SWT.NONE );
500
    Control control = new Composite( shell, SWT.NONE );
478
501
479
    Fixture.fakeResponseWriter();
502
    Fixture.fakeResponseWriter();
Lines 527-534 Link Here
527
  }
550
  }
528
551
529
  public void testWriteBackgroundGradient_Horizontal() throws IOException {
552
  public void testWriteBackgroundGradient_Horizontal() throws IOException {
530
    Display display = new Display();
531
    Shell shell = new Shell( display , SWT.NONE );
532
    Control control = new Composite( shell, SWT.NONE );
553
    Control control = new Composite( shell, SWT.NONE );
533
554
534
    Fixture.fakeResponseWriter();
555
    Fixture.fakeResponseWriter();
Lines 552-559 Link Here
552
  }
573
  }
553
574
554
  public void testWriteRoundedBorder() throws IOException {
575
  public void testWriteRoundedBorder() throws IOException {
555
    Display display = new Display();
556
    Shell shell = new Shell( display , SWT.NONE );
557
    Widget widget = new Composite( shell, SWT.NONE );
576
    Widget widget = new Composite( shell, SWT.NONE );
558
577
559
    CompositeLCA lca = new CompositeLCA();
578
    CompositeLCA lca = new CompositeLCA();
Lines 593-604 Link Here
593
      + "( wm.findWidgetById( \"w2\" ), 4, \"#00ff00\", 5, 4, 7, 8 );";
612
      + "( wm.findWidgetById( \"w2\" ), 4, \"#00ff00\", 5, 4, 7, 8 );";
594
    assertEquals( expected, Fixture.getAllMarkup() );
613
    assertEquals( expected, Fixture.getAllMarkup() );
595
  }
614
  }
596
597
  protected void setUp() throws Exception {
598
    Fixture.setUp();
599
  }
600
601
  protected void tearDown() throws Exception {
602
    Fixture.tearDown();
603
  }
604
}
615
}

Return to bug 345597