/** * Called when the request for a type is not in the cache. It will resolve the request by * iterating the elements in the last selection, searching for the requested type. The result will * be cached and returned * * @param type the selected type * @return a not null list of the elements of the desired type or of one of its subclasses */ private ModelPartPair createCacheForModelType(Class<?> type) { ModelPartPair result = new ModelPartPair(); for (EditPart part : lastModelSelection.parts) { if (type.isInstance(part.getModel())) { result.add(part); } else if (!allowDishomogeneousSelection) { return new ModelPartPair(); } } return result; }
/** Clear the cache maps and reprocess the edit parts */ private void reinitializeMaps() { IStructuredSelection sSel = (IStructuredSelection) lastSelection; Iterator<?> elements = sSel.iterator(); lastModelSelection.clear(); cachedModelTypedRequest.clear(); lastEditPartSelection.clear(); cachedEditPartTypedRequest.clear(); while (elements.hasNext()) { Object obj = elements.next(); if (obj instanceof EditPart) { EditPart editPart = (EditPart) obj; lastModelSelection.add(editPart); lastEditPartSelection.add(editPart); } } }