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 379234 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/swt/internal/widgets/UntypedEventAdapter.java (-2 / +31 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2002, 2011 Innoopract Informationssysteme GmbH and others.
2
 * Copyright (c) 2002, 2012 Innoopract Informationssysteme GmbH and others.
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 27-32 Link Here
27
             SelectionListener,
27
             SelectionListener,
28
             FocusListener,
28
             FocusListener,
29
             TreeListener,
29
             TreeListener,
30
             ExpandListener,
30
             ShellListener,
31
             ShellListener,
31
             MenuListener,
32
             MenuListener,
32
             ModifyListener,
33
             ModifyListener,
Lines 114-119 Link Here
114
    dispatchEvent( event );
115
    dispatchEvent( event );
115
  }
116
  }
116
117
118
  public void itemCollapsed( ExpandEvent typedEvent ) {
119
    Event event = createEvent( SWT.Collapse, typedEvent.getSource() );
120
    copyFields( typedEvent, event );
121
    dispatchEvent( event );
122
  }
123
124
  public void itemExpanded( ExpandEvent typedEvent ) {
125
    Event event = createEvent( SWT.Expand, typedEvent.getSource() );
126
    copyFields( typedEvent, event );
127
    dispatchEvent( event );
128
  }
129
117
  public void shellActivated( ShellEvent typedEvent ) {
130
  public void shellActivated( ShellEvent typedEvent ) {
118
    Event event = createEvent( SWT.Activate, typedEvent.getSource() );
131
    Event event = createEvent( SWT.Activate, typedEvent.getSource() );
119
    copyFields( typedEvent, event );
132
    copyFields( typedEvent, event );
Lines 272-278 Link Here
272
      break;
285
      break;
273
      case SWT.Expand:
286
      case SWT.Expand:
274
      case SWT.Collapse:
287
      case SWT.Collapse:
275
        TreeEvent.addListener( widget, ( TreeListener )this );
288
        if( widget instanceof Tree ) {
289
          TreeEvent.addListener( widget, ( TreeListener )this );
290
        } else {
291
          ExpandEvent.addListener( widget, ( ExpandListener )this );
292
        }
276
      break;
293
      break;
277
      case SWT.Activate:
294
      case SWT.Activate:
278
      case SWT.Deactivate:
295
      case SWT.Deactivate:
Lines 692-697 Link Here
692
    to.text = from.text;
709
    to.text = from.text;
693
  }
710
  }
694
711
712
  private static void copyFields( ExpandEvent from, Event to ) {
713
    copyFields( ( TypedEvent )from, to );
714
    to.detail = from.detail;
715
    to.doit = from.doit;
716
    to.x = from.x;
717
    to.y = from.y;
718
    to.height = from.height;
719
    to.width = from.width;
720
    to.item = from.item;
721
    to.text = from.text;
722
  }
723
695
  private static void copyFields( VerifyEvent from, Event to ) {
724
  private static void copyFields( VerifyEvent from, Event to ) {
696
    copyFields( ( TypedEvent )from, to );
725
    copyFields( ( TypedEvent )from, to );
697
    to.start = from.start;
726
    to.start = from.start;
(-)src/org/eclipse/swt/internal/widgets/UntypedEventAdapter_Test.java (-5 / +13 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2002, 2011 Innoopract Informationssysteme GmbH and others.
2
 * Copyright (c) 2002, 2012 Innoopract Informationssysteme GmbH and others.
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 35-44 Link Here
35
  private static final String EVENT_FIRED = "fired|";
35
  private static final String EVENT_FIRED = "fired|";
36
  private static int eventType;
36
  private static int eventType;
37
  private static String log;
37
  private static String log;
38
  
38
39
  private Display display;
39
  private Display display;
40
  private Control widget;
40
  private Control widget;
41
41
42
  @Override
42
  protected void setUp() throws Exception {
43
  protected void setUp() throws Exception {
43
    Fixture.setUp();
44
    Fixture.setUp();
44
    eventType = 0;
45
    eventType = 0;
Lines 47-52 Link Here
47
    widget = new Shell( display );
48
    widget = new Shell( display );
48
  }
49
  }
49
50
51
  @Override
50
  protected void tearDown() throws Exception {
52
  protected void tearDown() throws Exception {
51
    Fixture.tearDown();
53
    Fixture.tearDown();
52
  }
54
  }
Lines 85-90 Link Here
85
    adapter.addListener( SWT.Collapse, listener );
87
    adapter.addListener( SWT.Collapse, listener );
86
    adapter.treeCollapsed( new TreeEvent( widget, null, 0 ) );
88
    adapter.treeCollapsed( new TreeEvent( widget, null, 0 ) );
87
    assertEquals( SWT.Collapse, eventType );
89
    assertEquals( SWT.Collapse, eventType );
90
    adapter.addListener( SWT.Expand, listener );
91
    adapter.itemExpanded( new ExpandEvent( widget, null, 0 ) );
92
    assertEquals( SWT.Expand, eventType );
93
    adapter.addListener( SWT.Collapse, listener );
94
    adapter.itemCollapsed( new ExpandEvent( widget, null, 0 ) );
95
    assertEquals( SWT.Collapse, eventType );
88
    adapter.addListener( SWT.Activate, listener );
96
    adapter.addListener( SWT.Activate, listener );
89
    adapter.shellActivated( new ShellEvent( widget, 0 ) );
97
    adapter.shellActivated( new ShellEvent( widget, 0 ) );
90
    assertEquals( SWT.Activate, eventType );
98
    assertEquals( SWT.Activate, eventType );
Lines 262-274 Link Here
262
    assertNull( eventLog[ 0 ] );
270
    assertNull( eventLog[ 0 ] );
263
    widget.removeListener( 505, listener );
271
    widget.removeListener( 505, listener );
264
  }
272
  }
265
  
273
266
  public void testIsSerializable() throws Exception {
274
  public void testIsSerializable() throws Exception {
267
    UntypedEventAdapter adapter = new UntypedEventAdapter();
275
    UntypedEventAdapter adapter = new UntypedEventAdapter();
268
    adapter.addListener( SWT.Move, new SerializableListener() );
276
    adapter.addListener( SWT.Move, new SerializableListener() );
269
    
277
270
    UntypedEventAdapter deserializeAdapter = Fixture.serializeAndDeserialize( adapter );
278
    UntypedEventAdapter deserializeAdapter = Fixture.serializeAndDeserialize( adapter );
271
    
279
272
    Listener[] listeners = deserializeAdapter.getListeners( SWT.Move );
280
    Listener[] listeners = deserializeAdapter.getListeners( SWT.Move );
273
    assertEquals( 1, listeners.length );
281
    assertEquals( 1, listeners.length );
274
    assertEquals( SerializableListener.class, listeners[ 0 ].getClass() );
282
    assertEquals( SerializableListener.class, listeners[ 0 ].getClass() );

Return to bug 379234