1 package net.suberic.pooka; 2 3 import java.util.*; 4 5 import net.suberic.util.*; 6 7 13 public class NetworkConnectionManager implements ItemCreator, ItemListChangeListener { 14 15 private ItemManager manager; 16 private LinkedList listenerList = new LinkedList(); 17 18 21 public NetworkConnectionManager() { 22 createConnectionList(); 23 } 24 25 28 33 public void itemListChanged(ItemListChangeEvent e) { 34 fireItemListChanged(e); 35 } 36 37 41 public java.util.Vector getConnectionList() { 42 return manager.getItems(); 43 } 44 45 49 public void addConnection(String connectionName) { 50 manager.addItem(connectionName); 51 } 52 53 56 public void addConnection(String [] connectionName) { 57 manager.addItem(connectionName); 58 } 59 60 63 public void removeConnection(String connectionName) { 64 manager.removeItem(connectionName); 65 } 66 67 70 public void removeConnection(String [] connectionNames) { 71 manager.removeItem(connectionNames); 72 } 73 74 77 public void removeConnection(NetworkConnection connection) { 78 manager.removeItem(connection); 79 } 80 81 84 public void removeConnection(NetworkConnection[] connections) { 85 manager.removeItem(connections); 86 } 87 88 92 public NetworkConnection getConnection(String connectionID) { 93 return (NetworkConnection) manager.getItem(connectionID); 94 } 95 96 100 public NetworkConnection getDefaultConnection() { 101 String defaultName = Pooka.getProperty("Connection._default", "_default"); 102 return (NetworkConnection) manager.getItem(defaultName); 103 } 104 105 108 public void addItemListChangeListener(ItemListChangeListener ilcl) { 109 if (! listenerList.contains(ilcl)) 110 listenerList.add(ilcl); 111 } 112 113 116 public void removeItemListChangeListener(ItemListChangeListener ilcl) { 117 listenerList.remove(ilcl); 118 } 119 120 123 public void fireItemListChanged(ItemListChangeEvent e) { 124 for (int i = 0; i < listenerList.size(); i++) 125 ((ItemListChangeListener)listenerList.get(i)).itemListChanged(e); 126 } 127 128 129 132 public Item createItem(VariableBundle sourceBundle, String resourceString, String itemID) { 133 NetworkConnection returnValue = new NetworkConnection(itemID); 134 returnValue.configure(); 135 return returnValue; 136 } 137 138 141 145 private void createConnectionList() { 146 manager = new ItemManager("Connection", Pooka.getResources(), this); 147 manager.addItemListChangeListener(this); 148 } 149 } 150 | Popular Tags |