1 11 12 package org.eclipse.ui.internal.navigator; 13 14 import java.util.LinkedHashSet ; 15 16 import org.eclipse.ui.internal.navigator.extensions.NavigatorContentDescriptor; 17 18 22 public class ContributorTrackingSet extends LinkedHashSet { 23 24 25 private static final long serialVersionUID = 2516241537206281972L; 26 27 private NavigatorContentDescriptor contributor; 28 private NavigatorContentService contentService; 29 30 35 public ContributorTrackingSet(NavigatorContentService aContentService) { 36 contentService = aContentService; 37 } 38 39 45 public ContributorTrackingSet(NavigatorContentService aContentService, Object [] elements) { 46 47 for (int i = 0; i < elements.length; i++) 48 super.add(elements[i]); 49 50 contentService = aContentService; 51 } 52 53 56 public boolean add(Object o) { 57 if(contributor != null) 58 contentService.rememberContribution(contributor, o); 59 return super.add(o); 60 } 61 62 65 public boolean remove(Object o) { 66 contentService.rememberContribution(null, o); 67 return super.remove(o); 68 } 69 70 74 public NavigatorContentDescriptor getContributor() { 75 return contributor; 76 } 77 78 82 public void setContributor(NavigatorContentDescriptor newContributor) { 83 contributor = newContributor; 84 } 85 86 89 public void setContents(Object [] contents) { 90 super.clear(); 91 if(contents != null) 92 for (int i = 0; i < contents.length; i++) 93 super.add(contents[i]); 94 95 } 96 } 97 | Popular Tags |