1 19 20 package org.netbeans.modules.websvc.registry.model; 21 22 import java.util.ArrayList ; 23 import java.util.HashSet ; 24 import java.util.Iterator ; 25 import java.util.List ; 26 import java.util.Set ; 27 import org.netbeans.modules.websvc.registry.model.WebServiceListModel; 28 import org.netbeans.modules.websvc.registry.util.Util; 29 30 34 public class WebServiceGroup { 35 36 Set listeners = new HashSet (); 37 String groupId = null; 38 String groupName = null; 39 40 Set webserviceIds = new HashSet (); 41 42 public WebServiceGroup() { 43 this(WebServiceListModel.getInstance().getUniqueWebServiceGroupId()); 44 } 45 46 public WebServiceGroup(String id) { 47 setId(id); 48 } 49 50 public void addWebServiceGroupListener(WebServiceGroupListener listener){ 51 listeners.add(listener); 52 } 53 54 public void removeWebServiceGroupListener(WebServiceGroupListener listener){ 55 listeners.remove(listener); 56 } 57 58 public void setId(String id){ 59 groupId = id; 60 } 61 62 public String getId(){ 63 return groupId; 64 } 65 66 public String getName() { 67 return groupName; 68 } 69 70 public void setName(String name) { 71 groupName = name; 72 } 73 74 public void add(String webServiceId) { 75 if (!webserviceIds.contains(webServiceId)) { 77 WebServiceData wsData = WebServiceListModel.getInstance().getWebService(webServiceId); 78 wsData.setGroupId(getId()); 79 webserviceIds.add(webServiceId); 80 Iterator iter = listeners.iterator(); 81 while(iter.hasNext()) { 82 WebServiceGroupEvent evt = new WebServiceGroupEvent(webServiceId); 83 ((WebServiceGroupListener)iter.next()).webServiceAdded(evt); 84 } 85 } 86 } 87 88 public void remove(String webServiceId){ 89 if (webserviceIds.contains(webServiceId)) { 91 webserviceIds.remove(webServiceId); 92 Iterator iter = listeners.iterator(); 93 while(iter.hasNext()) { 94 WebServiceGroupEvent evt = new WebServiceGroupEvent(webServiceId); 95 ((WebServiceGroupListener)iter.next()).webServiceRemoved(evt); 96 } 97 } 98 } 99 100 public void setWebServiceIds(Set ids){ 101 webserviceIds = ids; 102 Iterator iter = webserviceIds.iterator(); 103 while(iter.hasNext()) { 104 WebServiceData wsData = WebServiceListModel.getInstance().getWebService((String )iter.next()); 105 wsData.setGroupId(getId()); 106 } 107 } 108 109 public Set getWebServiceIds(){ 110 return webserviceIds; 111 } 112 113 } 114 | Popular Tags |