public void loadProtocols() { _protocolsByPort.clear(); _protocolsByName.clear(); File dir = new File(_protocolsDir); if (!dir.isDirectory()) { PacketSamurai.getUserInterface().log("Invalid Protocols directory (" + _protocolsDir + ")"); return; } File[] files = dir.listFiles( new FilenameFilter() { public boolean accept(File dir, String name) { if (name.endsWith(".xml")) return true; return false; } }); for (File f : files) { Protocol p = new Protocol(_protocolsDir + "/" + f.getName()); if (p.isLoaded()) { PacketSamurai.getUserInterface() .log("Loaded protocol [" + p.getName() + "] from (" + f.getName() + ")"); Set<Protocol> protocols = _protocolsByPort.get(p.getPort()); if (protocols == null) { protocols = new FastSet<Protocol>(); _protocolsByPort.put(p.getPort(), protocols); } protocols.add(p); if (_protocolsByName.put(p.getName(), p) != null) { PacketSamurai.getUserInterface() .log( "ProtocolManager : Warning : there is more than one protocol for the name " + p.getName() + " only the last one will be available through getProtocolByName."); } } } }
private void selectPortNumber() { // Go and get default port number according to the selected protocol Protocol protocol = (Protocol) protocolList.getSelectedItem(); if (protocol.toString().equals("FILE")) { enableFields(false); this.isPortTextFieldDirty = false; return; } else { enableFields(true); } // if user types in a port number // or empties port number field // then do not set protocol's default port number if (isPortTextFieldDirty() && portTextField.isEditValid()) { return; } portTextField.setValue(protocol.getPort()); }