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 286306
Collapse All | Expand All

(-)src/org/eclipse/swt/internal/widgets/toolitemkit/PushToolItemLCA.java (-1 / +1 lines)
Lines 49-55 Link Here
49
    Object[] args = new Object[]{
49
    Object[] args = new Object[]{
50
      WidgetUtil.getId( toolItem ),
50
      WidgetUtil.getId( toolItem ),
51
      toolBar,
51
      toolBar,
52
      new Integer( toolBar.indexOf( toolItem ) ),
52
      ToolItemLCAUtil.getClientSideIndex( toolItem ),
53
      Boolean.valueOf( ( toolBar.getStyle() & SWT.FLAT ) != 0 )
53
      Boolean.valueOf( ( toolBar.getStyle() & SWT.FLAT ) != 0 )
54
    };
54
    };
55
    writer.callStatic( CREATE_PUSH, args );
55
    writer.callStatic( CREATE_PUSH, args );
(-)src/org/eclipse/swt/internal/widgets/toolitemkit/SeparatorToolItemLCA.java (-1 / +1 lines)
Lines 46-52 Link Here
46
    Object[] args = new Object[]{
46
    Object[] args = new Object[]{
47
      WidgetUtil.getId( toolItem ),
47
      WidgetUtil.getId( toolItem ),
48
      toolBar,
48
      toolBar,
49
      new Integer( toolBar.indexOf( toolItem ) ),
49
      ToolItemLCAUtil.getClientSideIndex( toolItem ),
50
      Boolean.valueOf( ( toolBar.getStyle() & SWT.FLAT  ) != 0 )
50
      Boolean.valueOf( ( toolBar.getStyle() & SWT.FLAT  ) != 0 )
51
    };
51
    };
52
    writer.callStatic( CREATE_SEPARATOR, args );    
52
    writer.callStatic( CREATE_SEPARATOR, args );    
(-)src/org/eclipse/swt/internal/widgets/toolitemkit/RadioToolItemLCA.java (-1 / +1 lines)
Lines 65-71 Link Here
65
    Object[] args = new Object[] {
65
    Object[] args = new Object[] {
66
      WidgetUtil.getId( toolItem ),
66
      WidgetUtil.getId( toolItem ),
67
      toolItem.getParent(),
67
      toolItem.getParent(),
68
      new Integer( itemIndex ),
68
      ToolItemLCAUtil.getClientSideIndex( toolItem ),
69
      toolItem.getSelection() ? "true" : null,
69
      toolItem.getSelection() ? "true" : null,
70
      neighbour
70
      neighbour
71
    };
71
    };
(-)src/org/eclipse/swt/internal/widgets/toolitemkit/DropDownToolItemLCA.java (-1 / +1 lines)
Lines 74-80 Link Here
74
    Object[] args = new Object[] {
74
    Object[] args = new Object[] {
75
      WidgetUtil.getId( toolItem ),
75
      WidgetUtil.getId( toolItem ),
76
      toolBar,
76
      toolBar,
77
      new Integer( toolBar.indexOf( toolItem ) ),
77
      ToolItemLCAUtil.getClientSideIndex( toolItem ),
78
      Boolean.valueOf( ( toolBar.getStyle() & SWT.FLAT ) != 0 )
78
      Boolean.valueOf( ( toolBar.getStyle() & SWT.FLAT ) != 0 )
79
    };
79
    };
80
    writer.callStatic( CREATE_DROP_DOWN, args );
80
    writer.callStatic( CREATE_DROP_DOWN, args );
(-)src/org/eclipse/swt/internal/widgets/toolitemkit/CheckToolItemLCA.java (-1 / +1 lines)
Lines 57-63 Link Here
57
    Object[] args = new Object[] {
57
    Object[] args = new Object[] {
58
      WidgetUtil.getId( toolItem ),
58
      WidgetUtil.getId( toolItem ),
59
      toolBar,
59
      toolBar,
60
      new Integer( toolBar.indexOf( toolItem ) )
60
      ToolItemLCAUtil.getClientSideIndex( toolItem )
61
    };
61
    };
62
    writer.callStatic( CREATE_CHECK, args );
62
    writer.callStatic( CREATE_CHECK, args );
63
    writer.set( "checked", toolItem.getSelection() );
63
    writer.set( "checked", toolItem.getSelection() );
(-)src/org/eclipse/swt/internal/widgets/toolitemkit/ToolItemLCAUtil.java (-2 / +18 lines)
Lines 21-28 Link Here
21
import org.eclipse.swt.graphics.Rectangle;
21
import org.eclipse.swt.graphics.Rectangle;
22
import org.eclipse.swt.internal.graphics.ResourceFactory;
22
import org.eclipse.swt.internal.graphics.ResourceFactory;
23
import org.eclipse.swt.internal.widgets.*;
23
import org.eclipse.swt.internal.widgets.*;
24
import org.eclipse.swt.widgets.ToolItem;
24
import org.eclipse.swt.widgets.*;
25
import org.eclipse.swt.widgets.Widget;
26
25
27
26
28
final class ToolItemLCAUtil {
27
final class ToolItemLCAUtil {
Lines 124-129 Link Here
124
    return bounds;
123
    return bounds;
125
  }
124
  }
126
125
126
  // TODO [bm]: workaround for bug 286306
127
  //            we need to count the DROP_DOWN twice as it consists of two
128
  //            widgets on the client-side. This needs to be removed once we
129
  //            a proper DROP_DOWN ToolItem in place
130
  static Integer getClientSideIndex( final ToolItem toolItem ) {
131
    ToolBar toolBar = toolItem.getParent();
132
    int result = 0;
133
    int toolItemIndex = toolBar.indexOf( toolItem );
134
    for( int i = 0; i < toolItemIndex; i++ ) {
135
      result++;
136
      if( ( toolBar.getItem( i ).getStyle() & SWT.DROP_DOWN ) != 0 ) {
137
        result++;
138
      }
139
    }
140
    return new Integer( result );
141
  }
142
  
127
  ////////
143
  ////////
128
  // Image
144
  // Image
129
145
(-)src/org/eclipse/swt/internal/widgets/toolitemkit/ToolItemLCA_Test.java (+45 lines)
Lines 339-344 Link Here
339
    assertEquals( expected, Fixture.getAllMarkup() );
339
    assertEquals( expected, Fixture.getAllMarkup() );
340
  }
340
  }
341
341
342
  // TODO [bm]: test for workaround for bug 286306
343
  //            we need to count the DROP_DOWN twice for a proper index
344
  //            as it consists of two
345
  //            widgets on the client-side. This needs to be removed once we
346
  //            a single-widget DROP_DOWN ToolItem in place
347
  public void testIndexOnInitializeWithDropDown() throws Exception {
348
    Fixture.fakeResponseWriter();
349
    Display display = new Display();
350
    Shell shell = new Shell( display, SWT.NONE );
351
    ToolBar tb = new ToolBar( shell, SWT.NONE );
352
    final ToolItem item1 = new ToolItem( tb, SWT.DROP_DOWN );
353
    final ToolItem item2 = new ToolItem( tb, SWT.PUSH );
354
    final ToolItem item3 = new ToolItem( tb, SWT.DROP_DOWN );
355
    final ToolItem item4 = new ToolItem( tb, SWT.PUSH );
356
    shell.open();
357
    ToolItemLCA itemLCA = new ToolItemLCA();
358
    itemLCA.renderInitialization( item1 );
359
    itemLCA.renderInitialization( item2 );
360
    itemLCA.renderInitialization( item3 );
361
    itemLCA.renderInitialization( item4 );
362
    String parent = "wm.findWidgetById( \"" + WidgetUtil.getId( tb )+ "\" )";
363
    String expected1 = "org.eclipse.swt.ToolItemUtil.createDropDown( \""
364
                      + WidgetUtil.getId( item1 )
365
                      + "\", "
366
                      + parent
367
                      + ", 0, false );";
368
    String expected2 = "org.eclipse.swt.ToolItemUtil.createPush( \""
369
                       + WidgetUtil.getId( item2 )
370
                       + "\", "
371
                       + parent
372
                       + ", 2, false );";
373
    String expected3 = "org.eclipse.swt.ToolItemUtil.createDropDown( \""
374
                       + WidgetUtil.getId( item3 )
375
                       + "\", "
376
                       + parent
377
                       + ", 3, false );";
378
    String expected4 = "org.eclipse.swt.ToolItemUtil.createPush( \""
379
                       + WidgetUtil.getId( item4 )
380
                       + "\", "
381
                       + parent
382
                       + ", 5, false );";
383
    assertEquals( expected1 + expected2 + expected3 + expected4,
384
                  Fixture.getAllMarkup() );
385
  }
386
342
  protected void setUp() throws Exception {
387
  protected void setUp() throws Exception {
343
    RWTFixture.setUp();
388
    RWTFixture.setUp();
344
    Fixture.fakeResponseWriter();
389
    Fixture.fakeResponseWriter();

Return to bug 286306