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

(-)js/org/eclipse/swt/widgets/Table.js (+9 lines)
Lines 375-380 Link Here
375
        if( this._focusIndex !== -1 ) {
375
        if( this._focusIndex !== -1 ) {
376
          this.updateItem( this._focusIndex, false );
376
          this.updateItem( this._focusIndex, false );
377
        }
377
        }
378
        // This function is called from server-side and from within Table.js
379
        // org_eclipse_rap_rwt_EventUtil_suspend is used to distinguish the caller
380
        if( org_eclipse_rap_rwt_EventUtil_suspend ) {
381
          this._selectionStart = -1;
382
        } else {
383
          var req = org.eclipse.swt.Request.getInstance();
384
          var id = org.eclipse.swt.WidgetManager.getInstance().findIdByWidget( this );
385
          req.addParameter( id + ".focusIndex", value );
386
        }
378
      }
387
      }
379
    },
388
    },
380
    
389
    
(-)src/org/eclipse/swt/internal/widgets/tablekit/TableLCAUtil.java (-1 / +8 lines)
Lines 28-33 Link Here
28
28
29
  // Constants used by alignment
29
  // Constants used by alignment
30
  private static final Integer DEFAULT_ALIGNMENT = new Integer( SWT.LEFT );
30
  private static final Integer DEFAULT_ALIGNMENT = new Integer( SWT.LEFT );
31
  private static final Integer DEFAULT_FOCUS_INDEX = new Integer( -1 );
31
32
32
33
33
  ////////////////////////////
34
  ////////////////////////////
Lines 100-106 Link Here
100
  }
101
  }
101
  
102
  
102
  public static boolean hasFocusIndexChanged( final Table table ) {
103
  public static boolean hasFocusIndexChanged( final Table table ) {
103
    return false;
104
    ITableAdapter tableAdapter
105
      = ( ITableAdapter )table.getAdapter( ITableAdapter.class );
106
    int focusIndex = tableAdapter.getFocusIndex();
107
    return WidgetLCAUtil.hasChanged( table, 
108
                                     PROP_FOCUS_INDEX, 
109
                                     new Integer( focusIndex ), 
110
                                     DEFAULT_FOCUS_INDEX );
104
  }
111
  }
105
  
112
  
106
  //////////////////
113
  //////////////////
(-)src/org/eclipse/swt/internal/widgets/tablekit/TableLCA.java (-18 / +37 lines)
Lines 83-88 Link Here
83
  public void readData( final Widget widget ) {
83
  public void readData( final Widget widget ) {
84
    Table table = ( Table )widget;
84
    Table table = ( Table )widget;
85
    readTopIndex( table ); // topIndex MUST be read *before* processSetData
85
    readTopIndex( table ); // topIndex MUST be read *before* processSetData
86
    readFocusIndex( table );
86
    readSelection( table );
87
    readSelection( table );
87
    readSetData( table );
88
    readSetData( table );
88
    readWidgetSelected( table );
89
    readWidgetSelected( table );
Lines 115-120 Link Here
115
    TableLCAUtil.writeItemMetrics( table );
116
    TableLCAUtil.writeItemMetrics( table );
116
    writeItemCount( table );
117
    writeItemCount( table );
117
    writeTopIndex( table );
118
    writeTopIndex( table );
119
    writeFocusIndex( table );
118
    writeLinesVisible( table );
120
    writeLinesVisible( table );
119
    writeSelectionListener( table );
121
    writeSelectionListener( table );
120
    writeDefaultColumnWidth( table );
122
    writeDefaultColumnWidth( table );
Lines 169-175 Link Here
169
      table.setTopIndex( Integer.parseInt( value ) );
171
      table.setTopIndex( Integer.parseInt( value ) );
170
    }
172
    }
171
  }
173
  }
172
  
174
175
  private static void readFocusIndex( final Table table ) {
176
    String value = WidgetLCAUtil.readPropertyValue( table, "focusIndex" );
177
    if( value != null ) {
178
      ITableAdapter adapter
179
        = ( ITableAdapter )table.getAdapter( ITableAdapter.class );
180
      adapter.setFocusIndex( Integer.parseInt( value ) );
181
    }
182
  }
183
173
  private static void readSetData( final Table table ) {
184
  private static void readSetData( final Table table ) {
174
    if( WidgetLCAUtil.wasEventSent( table, JSConst.EVENT_SET_DATA ) ) {
185
    if( WidgetLCAUtil.wasEventSent( table, JSConst.EVENT_SET_DATA ) ) {
175
      HttpServletRequest request = ContextProvider.getRequest();
186
      HttpServletRequest request = ContextProvider.getRequest();
Lines 179-216 Link Here
179
      ITableAdapter tableAdapter = ( ITableAdapter )adapter;
190
      ITableAdapter tableAdapter = ( ITableAdapter )adapter;
180
      for( int i = 0; i < indices.length; i++ ) {
191
      for( int i = 0; i < indices.length; i++ ) {
181
        int index = Integer.parseInt( indices[ i ] );
192
        int index = Integer.parseInt( indices[ i ] );
182
        if (index >-1 && index < table.getItemCount()) {
193
        if( index > -1 && index < table.getItemCount() ) {
183
            tableAdapter.checkData( index );
194
          tableAdapter.checkData( index );
184
        }
195
        }
185
      }
196
      }
186
    }
197
    }
187
  }
198
  }
188
199
189
  private void readWidgetSelected( final Table table ) {
200
  private static void readWidgetSelected( final Table table ) {
190
    if( WidgetLCAUtil.wasEventSent( table, JSConst.EVENT_WIDGET_SELECTED ) ) {
201
    if( WidgetLCAUtil.wasEventSent( table, JSConst.EVENT_WIDGET_SELECTED ) ) {
191
      // TODO [rh] do something about when index points to unresolved item! 
202
      // TODO [rh] do something reasonable when index points to unresolved item 
192
      final int widgetSelectedIndex = getWidgetSelectedIndex();
203
      int index = getWidgetSelectedIndex();
193
      // Bugfix: check if index is valid before firing event to avoid problems with fast scrolling
204
      // Bugfix: check if index is valid before firing event to avoid problems 
194
      if (widgetSelectedIndex > -1 && widgetSelectedIndex < table.getItemCount()) {
205
      //         with fast scrolling
195
          TableItem item = table.getItem( widgetSelectedIndex );
206
      if ( index > -1 && index < table.getItemCount() ) {
207
          TableItem item = table.getItem( index );
196
          int detail = getWidgetSelectedDetail();
208
          int detail = getWidgetSelectedDetail();
197
          int id = SelectionEvent.WIDGET_SELECTED;
209
          int id = SelectionEvent.WIDGET_SELECTED;
198
          SelectionEvent event = new SelectionEvent( table,
210
          Rectangle bounds = new Rectangle( 0, 0, 0, 0 );
199
                  item,
211
          SelectionEvent event
200
                  id,
212
            = new SelectionEvent( table, item, id, bounds, "", true, detail );
201
                  new Rectangle( 0, 0, 0, 0 ),
202
                  "",
203
                  true,
204
                  detail );
205
          event.processEvent();
213
          event.processEvent();
206
      }
214
      }
207
    }
215
    }
208
  }
216
  }
209
217
210
  private void readWidgetDefaultSelected( final Table table ) {
218
  private static void readWidgetDefaultSelected( final Table table ) {
211
    String defaultSelectedParam = JSConst.EVENT_WIDGET_DEFAULT_SELECTED;
219
    String defaultSelectedParam = JSConst.EVENT_WIDGET_DEFAULT_SELECTED;
212
    if( WidgetLCAUtil.wasEventSent( table, defaultSelectedParam ) ) {
220
    if( WidgetLCAUtil.wasEventSent( table, defaultSelectedParam ) ) {
213
      // TODO [rh] do something about when index points to unresolved item! 
221
      // TODO [rh] do something reasonable when index points to unresolved item 
214
      TableItem item = table.getItem( getWidgetSelectedIndex() );
222
      TableItem item = table.getItem( getWidgetSelectedIndex() );
215
      int id = SelectionEvent.WIDGET_DEFAULT_SELECTED;
223
      int id = SelectionEvent.WIDGET_DEFAULT_SELECTED;
216
      SelectionEvent event = new SelectionEvent( table, item, id );
224
      SelectionEvent event = new SelectionEvent( table, item, id );
Lines 269-274 Link Here
269
    writer.set( PROP_TOP_INDEX, "topIndex", newValue, DEFAULT_TOP_INDEX );
277
    writer.set( PROP_TOP_INDEX, "topIndex", newValue, DEFAULT_TOP_INDEX );
270
  }
278
  }
271
279
280
  private static void writeFocusIndex( final Table table ) throws IOException {
281
    if( TableLCAUtil.hasFocusIndexChanged( table ) ) {
282
      ITableAdapter adapter
283
        = ( ITableAdapter )table.getAdapter( ITableAdapter.class );
284
      if( adapter.getFocusIndex() == -1 ) {
285
        JSWriter writer = JSWriter.getWriterFor( table );
286
        writer.set( "focusIndex", new Object[] { new Integer( -1 ) } );
287
      }
288
    }
289
  }
290
272
  private static void writeLinesVisible( final Table table ) throws IOException 
291
  private static void writeLinesVisible( final Table table ) throws IOException 
273
  {
292
  {
274
    JSWriter writer = JSWriter.getWriterFor( table );
293
    JSWriter writer = JSWriter.getWriterFor( table );
(-)src/org/eclipse/swt/internal/widgets/tableitemkit/TableItemLCA.java (-1 / +1 lines)
Lines 269-275 Link Here
269
  }
269
  }
270
270
271
  // TODO [rh] check if necessary to honor focusIndex == -1, would mean to
271
  // TODO [rh] check if necessary to honor focusIndex == -1, would mean to
272
  //      call jsTable.setFocusedItem( null ) in TableLCA
272
  //      call jsTable.setFocusIndex( -1 ) in TableLCA
273
  private static void writeFocused( final TableItem item ) throws IOException
273
  private static void writeFocused( final TableItem item ) throws IOException
274
  {
274
  {
275
    if(    TableLCAUtil.hasFocusIndexChanged( item.getParent() )
275
    if(    TableLCAUtil.hasFocusIndexChanged( item.getParent() )

Return to bug 235583