1 11 package org.eclipse.ui.internal.views.properties.tabbed.view; 12 13 import java.util.ArrayList ; 14 import java.util.HashMap ; 15 import java.util.List ; 16 import java.util.Map ; 17 18 import org.eclipse.ui.views.properties.tabbed.ITabbedPropertySheetPageContributor; 19 20 21 27 public class TabbedPropertyRegistryFactory { 28 29 class CacheData { 30 TabbedPropertyRegistry registry; 31 List references; 32 } 33 34 37 private static TabbedPropertyRegistryFactory INSTANCE = 38 new TabbedPropertyRegistryFactory(); 39 40 43 public static TabbedPropertyRegistryFactory getInstance() { 44 return INSTANCE; 45 } 46 47 50 private TabbedPropertyRegistryFactory() { 51 super(); 52 idToCacheData = new HashMap (); 53 } 54 55 protected Map idToCacheData; 57 60 public TabbedPropertyRegistry createRegistry(ITabbedPropertySheetPageContributor target) { 61 64 String key = target.getContributorId(); 65 CacheData data = (CacheData) idToCacheData.get(key); 66 if (data == null) { 67 data = new CacheData(); 68 data.registry = 69 new TabbedPropertyRegistry(key); 70 data.references = new ArrayList (5); 71 idToCacheData.put(key, data); 72 } 73 data.references.add(target); 74 return data.registry; 76 } 77 78 83 public void disposeRegistry(ITabbedPropertySheetPageContributor target) { 84 87 String key = target.getContributorId(); 88 CacheData data = (CacheData) idToCacheData.get(key); 89 if (data != null) { 90 data.references.remove(target); 91 if (data.references.isEmpty()) { 92 idToCacheData.remove(key); 93 } 94 } 95 } 96 } 97 | Popular Tags |