You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pivot.apache.org by rw...@apache.org on 2012/10/01 21:24:24 UTC
svn commit: r1392533 -
/pivot/branches/2.0.x/tutorials/src/org/apache/pivot/tutorials/stocktracker/StockTrackerWindow.java
Author: rwhitcomb
Date: Mon Oct 1 19:24:24 2012
New Revision: 1392533
URL: http://svn.apache.org/viewvc?rev=1392533&view=rev
Log:
PIVOT-874: StockTracker: removing multiple symbols may remove unselected ones too
Applied patch from user, tested StockTracker application standalone.
Modified:
pivot/branches/2.0.x/tutorials/src/org/apache/pivot/tutorials/stocktracker/StockTrackerWindow.java
Modified: pivot/branches/2.0.x/tutorials/src/org/apache/pivot/tutorials/stocktracker/StockTrackerWindow.java
URL: http://svn.apache.org/viewvc/pivot/branches/2.0.x/tutorials/src/org/apache/pivot/tutorials/stocktracker/StockTrackerWindow.java?rev=1392533&r1=1392532&r2=1392533&view=diff
==============================================================================
--- pivot/branches/2.0.x/tutorials/src/org/apache/pivot/tutorials/stocktracker/StockTrackerWindow.java (original)
+++ pivot/branches/2.0.x/tutorials/src/org/apache/pivot/tutorials/stocktracker/StockTrackerWindow.java Mon Oct 1 19:24:24 2012
@@ -31,6 +31,7 @@ import org.apache.pivot.beans.BeanAdapte
import org.apache.pivot.beans.Bindable;
import org.apache.pivot.collections.ArrayList;
import org.apache.pivot.collections.List;
+import org.apache.pivot.collections.List.ItemIterator;
import org.apache.pivot.collections.Map;
import org.apache.pivot.collections.Sequence;
import org.apache.pivot.json.JSON;
@@ -103,9 +104,16 @@ public class StockTrackerWindow extends
@Override
public void perform(Component source) {
int selectedIndex = stocksTableView.getFirstSelectedIndex();
- int selectionLength = stocksTableView.getLastSelectedIndex() - selectedIndex + 1;
- stocksTableView.getTableData().remove(selectedIndex, selectionLength);
- symbols.remove(selectedIndex, selectionLength);
+ ArrayList<Span> spanList = new ArrayList<Span>(stocksTableView.getSelectedRanges());
+
+ // remove spans in reverse order to prevent IndexOutOfBoundsException
+ ItemIterator<Span> it = spanList.iterator();
+ it.toEnd();
+ while (it.hasPrevious()) {
+ Span span = it.previous();
+ stocksTableView.getTableData().remove(span.start, (int) span.getLength());
+ symbols.remove(span.start, (int) span.getLength());
+ }
if (selectedIndex >= symbols.getLength()) {
selectedIndex = symbols.getLength() - 1;