1 11 package org.eclipse.update.core; 12 13 import java.util.ArrayList ; 14 import java.util.List ; 15 16 import org.eclipse.update.internal.core.Messages; 17 import org.eclipse.update.internal.core.UpdateCore; 18 19 36 public class SiteFeatureReference extends SiteFeatureReferenceModel implements ISiteFeatureReference { 37 38 private List categories; 39 40 43 public SiteFeatureReference() { 44 super(); 45 } 46 47 51 public SiteFeatureReference(ISiteFeatureReference ref) { 52 super(ref); 53 } 54 55 61 public ICategory[] getCategories() { 62 63 if (categories == null) { 64 categories = new ArrayList (); 65 String [] categoriesAsString = getCategoryNames(); 66 for (int i = 0; i < categoriesAsString.length; i++) { 67 ICategory siteCat = getSite().getCategory(categoriesAsString[i]); 68 if (siteCat != null) 69 categories.add(siteCat); 70 else { 71 String siteURL = getSite().getURL() != null ? getSite().getURL().toExternalForm() : null; 72 UpdateCore.warn("Category " + categoriesAsString[i] + " not found in Site:" + siteURL); } 74 } 75 } 76 77 if (categories.size() == 0) { 78 ICategory category = new Category(Messages.SiteCategory_other_label, Messages.SiteCategory_other_description); 81 categories.add(category); 82 } 83 84 ICategory[] result = new ICategory[0]; 85 86 if (!(categories == null || categories.isEmpty())) { 87 result = new ICategory[categories.size()]; 88 categories.toArray(result); 89 } 90 return result; 91 } 92 93 99 public void addCategory(ICategory category) { 100 this.addCategoryName(category.getName()); 101 } 102 103 } 104 | Popular Tags |