public void update(final ArrayList<Series> psSeriesList) { // Clear the existing information; anything that is saveable will // still be in the general memory, though. Spawn generation off // to a swingWorker, rather than doing this in the immediate // thread. collectionListIndex.clear(); psList.clear(); for (PSCollection psc : psCollectionList) psc.flush(); psCollectionList.clear(); for (PSThumbnailPanel pstp : psList) pstp.flush(); psList.clear(); SwingWorker sw = new SwingWorker<Boolean, Void>() { public Boolean doInBackground() { for (Series s : psSeriesList) { List<AssociatedData> ls = s.getAssociatedData(); // Sort the associated data based on any order indicies... Collections.sort( ls, new Comparator<AssociatedData>() { public int compare(AssociatedData a1, AssociatedData a2) { Integer orderIndex1 = a1.getOrderIndex(); Integer orderIndex2 = a2.getOrderIndex(); if ((orderIndex1 == null) && (orderIndex2 == null)) return 0; if ((orderIndex1 != null) && (orderIndex2 == null)) return 1; if ((orderIndex1 == null) && (orderIndex2 != null)) return -1; return orderIndex1.intValue() - orderIndex2.intValue(); } public boolean equals(Object o) { return false; } }); for (AssociatedData a : ls) { // Retrieve only the presentation states; link the // thumbnails to the associatedData objects used to // generate the associablePresentationState. if (AssociatedData.AssocDataType.PRESENTATION_STATE .getTypeNumber() .equals(a.getType())) { AssociablePresentationState aps = new AssociablePresentationState(a); addPresentationState(aps.getPresentationState()).setAssociatedData(a); } } } return Boolean.TRUE; } }; sw.execute(); }
public void updateGrouping(GroupByType groupBy) { this.groupBy = groupBy; ArrayList<PSCollection> originalCollection = (ArrayList<PSCollection>) psCollectionList.clone(); collectionListIndex.clear(); psCollectionList.clear(); for (PSCollection psc : originalCollection) { ArrayList<PSThumbnailPanel> thumbnails = psc.getThumbnails(); for (PSThumbnailPanel pstp : thumbnails) { PresentationState ps = pstp.getPresentationState(); findPSCollection(ps).addPSThumbnailPanel(pstp); } } fireTableDataChanged(); }