Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 137652 Details for
Bug 278346
[List] Javascript error when removing selected items
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Proposed patch with test case.
Bug-278344-278346.patch (text/plain), 4.43 KB, created by
Ivan Furnadjiev
on 2009-05-29 10:56:47 EDT
(
hide
)
Description:
Proposed patch with test case.
Filename:
MIME Type:
Creator:
Ivan Furnadjiev
Created:
2009-05-29 10:56:47 EDT
Size:
4.43 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.rap.rwt >Index: src/org/eclipse/swt/internal/widgets/ListModel.java >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.rap/runtime.rwt/org.eclipse.rap.rwt/src/org/eclipse/swt/internal/widgets/ListModel.java,v >retrieving revision 1.1 >diff -u -r1.1 ListModel.java >--- src/org/eclipse/swt/internal/widgets/ListModel.java 17 Mar 2009 10:45:47 -0000 1.1 >+++ src/org/eclipse/swt/internal/widgets/ListModel.java 29 May 2009 14:55:31 -0000 >@@ -45,7 +45,7 @@ > System.arraycopy( selection, 0, result, 0, selection.length ); > return result; > } >- >+ > public int getSelectionCount() { > return selection.length; > } >@@ -86,7 +86,7 @@ > } > } > } >- >+ > public void setSelection( final int start, final int end ) { > deselectAll(); > if( end >= 0 && start <= end && start <= getItemCount() - 1 ) { >@@ -106,7 +106,7 @@ > } > } > } >- >+ > public void setSelection( final String[] selection ) { > if( selection == null ) { > SWT.error( SWT.ERROR_NULL_ARGUMENT ); >@@ -161,10 +161,10 @@ > public void deselectAll() { > this.selection = EMPTY_SELECTION; > } >- >+ > //////////////////////////////// > // Methods to maintain the items >- >+ > public void add( final String string ) { > if( string == null ) { > SWT.error( SWT.ERROR_NULL_ARGUMENT ); >@@ -195,7 +195,7 @@ > remove( i ); > } > } >- >+ > public void remove( final int[] indices ) { > if( indices == null ) { > SWT.error( SWT.ERROR_NULL_ARGUMENT ); >@@ -237,7 +237,7 @@ > public void setItems( final String[] items ) { > if( items == null ) { > SWT.error( SWT.ERROR_NULL_ARGUMENT ); >- } >+ } > for( int i = 0; i < items.length; i++ ) { > if( items[ i ] == null ) { > SWT.error( SWT.ERROR_INVALID_ARGUMENT ); >@@ -264,8 +264,8 @@ > } > > ////////////////// >- // Helping methods >- >+ // Helping methods >+ > /* If the given index is contained in the selection, it will be removed. */ > private void removeFromSelection( final int index ) { > boolean found = false; >@@ -281,8 +281,17 @@ > found = true; > } > } >+ adjustSelectionIndices( index ); >+ } >+ >+ private void adjustSelectionIndices( final int removedIndex ) { >+ for( int i = 0; i < selection.length; i++ ) { >+ if( selection[ i ] >= removedIndex ) { >+ selection[ i ] = selection[ i ] - 1; >+ } >+ } > } >- >+ > private int indexOf( final String string ) { > return items.indexOf( string ); > } >#P org.eclipse.rap.rwt.test >Index: src/org/eclipse/swt/widgets/List_Test.java >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.rap/runtime.rwt.test/org.eclipse.rap.rwt.test/src/org/eclipse/swt/widgets/List_Test.java,v >retrieving revision 1.9 >diff -u -r1.9 List_Test.java >--- src/org/eclipse/swt/widgets/List_Test.java 6 Nov 2008 14:15:10 -0000 1.9 >+++ src/org/eclipse/swt/widgets/List_Test.java 29 May 2009 14:55:35 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2002, 2008 Innoopract Informationssysteme GmbH. >+ * Copyright (c) 2002, 2009 Innoopract Informationssysteme GmbH. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -757,6 +757,30 @@ > assertEquals( 0, list.getSelectionIndices()[ 0 ] ); > assertEquals( 1, list.getSelectionIndices()[ 1 ] ); > assertEquals( 2, list.getSelectionIndices()[ 2 ] ); >+ >+ // Ensure that no selection indices after remove all items one by one >+ list.removeAll(); >+ list.add( "item0" ); >+ list.add( "item1" ); >+ list.add( "item2" ); >+ list.select( new int[] { 0, 1, 2 } ); >+ String[] listSelection = list.getSelection(); >+ for( int i = 0; i < listSelection.length; i++ ) { >+ list.remove( listSelection[ i ] ); >+ } >+ assertEquals( 0, list.getSelectionCount() ); >+ >+ // Ensure that no selection indices after remove selected items one by one >+ list.removeAll(); >+ list.add( "item0" ); >+ list.add( "item1" ); >+ list.add( "item2" ); >+ list.select( new int[] { 0, 1 } ); >+ listSelection = list.getSelection(); >+ for( int i = 0; i < listSelection.length; i++ ) { >+ list.remove( listSelection[ i ] ); >+ } >+ assertEquals( 0, list.getSelectionCount() ); > } > > public void testSetItem() {
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 278346
:
137635
|
137652
|
137666