Exemplo n.º 1
0
 public void switchToProtocol(Protocol p) {
   if (p == null) {
     _currentProtocol = null;
     _clientTab.changeFamilly(null);
     _serverTab.changeFamilly(null);
   } else {
     _currentProtocol = p;
     _clientTab.changeFamilly(p.getClientPacketsFamilly());
     _serverTab.changeFamilly(p.getServerPacketsFamilly());
   }
 }
Exemplo n.º 2
0
 public void loadProtocols() {
   _protocolMenu.removeAll();
   for (Protocol proto : ProtocolManager.getInstance().getProtocols()) {
     JMenuItem protoButton = new JMenuItem(proto.getName() + " (" + proto.getPort() + ")");
     protoButton.setActionCommand("p:" + proto.getName());
     protoButton.addActionListener(_pel);
     _protocolMenu.add(protoButton);
   }
   JMenuItem newProtoButton = new JMenuItem("New Protocol...");
   newProtoButton.setActionCommand("new");
   newProtoButton.addActionListener(_pel);
   _protocolMenu.addSeparator();
   _protocolMenu.add(newProtoButton);
   if (!ProtocolManager.getInstance().getProtocols().isEmpty())
     switchToProtocol(ProtocolManager.getInstance().getProtocols().iterator().next());
   else switchToProtocol(null);
 }
Exemplo n.º 3
0
 public void actionPerformed(ActionEvent e) {
   String cmd = e.getActionCommand();
   System.out.println(cmd);
   if (cmd.startsWith("p:")) {
     String pName = cmd.substring(2);
     _pEditor.switchToProtocol(ProtocolManager.getInstance().getProtocolByName(pName));
   } else if (cmd.equals("new")) {
     // dialog
   } else if (cmd.equals("properties")) {
     // dialog
   } else if (cmd.equals("save")) {
     Protocol currentProtocol = _pEditor.getCurrentProtocol();
     if (currentProtocol != null) currentProtocol.saveProtocol();
   } else if (cmd.equals("reload")) {
     ProtocolManager.getInstance().loadProtocols();
     _pEditor.loadProtocols();
   }
 }