[Javanetsim-cvs] javaNetSim/guiUI MainScreen.java,1.15,1.16 MenuBar.java,1.1.1.1,1.2 NetworkLayerDev
Status: Beta
Brought to you by:
darkkey
From: Alexander B. <da...@us...> - 2005-12-03 11:28:54
|
Update of /cvsroot/javanetsim/javaNetSim/guiUI In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19223/guiUI Modified Files: MainScreen.java MenuBar.java NetworkLayerDevice.java Log Message: Filters for messages... + Print routes table menu element. Index: NetworkLayerDevice.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/guiUI/NetworkLayerDevice.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** NetworkLayerDevice.java 19 Nov 2005 16:16:32 -0000 1.3 --- NetworkLayerDevice.java 3 Dec 2005 11:28:46 -0000 1.4 *************** *** 55,58 **** --- 55,59 ---- private JMenuItem mnuArpRemove = new JMenuItem("Remove entry from ARP table..."); private JMenuItem mnuRunCmd = new JMenuItem("Run low-level command..."); + private JMenuItem mnuPR = new JMenuItem("Print route table"); private JMenuItem mnuArp = new JMenuItem("Print ARP Table"); private JMenuItem mnuLink = new JMenuItem("Links properties"); *************** *** 112,115 **** --- 113,121 ---- } }); + mnuPR.addActionListener(new ActionListener(){ + public void actionPerformed(ActionEvent e){ + controller.PrintRouteTable(lblNodeName.getText()); + } + }); mnuLink.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e){ *************** *** 126,129 **** --- 132,136 ---- mnuARPMenu.add(mnuArp); GuiNodePopMenu.add(mnuRunCmd); + GuiNodePopMenu.add(mnuPR); GuiNodePopMenu.add(mnuBreakLink); GuiNodePopMenu.add(mnuLink); Index: MainScreen.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/guiUI/MainScreen.java,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** MainScreen.java 1 Dec 2005 19:51:53 -0000 1.15 --- MainScreen.java 3 Dec 2005 11:28:46 -0000 1.16 *************** *** 176,180 **** private JPanel pContentPane = (JPanel)getContentPane(); ! //Toolbar --- 176,181 ---- private JPanel pContentPane = (JPanel)getContentPane(); ! //filters ! private boolean[] filters = new boolean[8]; //Toolbar *************** *** 252,256 **** public MainScreen() { ! Sim = new Simulation(core.ProtocolStack.TCP_IP); buildGUI(); --- 253,260 ---- public MainScreen() { ! Sim = new Simulation(core.ProtocolStack.TCP_IP); ! ! for(int i= 0; i<=7; i++) ! filters[i] =true; buildGUI(); *************** *** 386,390 **** --- 390,415 ---- } + + /* + * This method set value of filter. + * @author Key + * @param filter index + * @param filter value + * + */ + public void setFilter(int i, boolean value){ + filters[i] = value; + } + /* + * This method get value of filter. + * @author Key + * @param filter index + * @returns filter value + * + */ + public boolean getFilter(int i){ + return filters[i]; + } /** *************** *** 1048,1052 **** String recording[] = (String[])it.next(); ! pnlConsole.append(pad(recording[1],15,' ')+pad(recording[2],25,' ')+pad(recording[3],15,' ')+pad(recording[4],10,' ')+recording[5]+ "\n"); } --- 1073,1081 ---- String recording[] = (String[])it.next(); ! //Very UGLY but works. ;) ! if(!(((String)recording[4]).contains("Network") && !filters[2]) && !(((String)recording[4]).contains("Link") && !filters[0]) && !(((String)recording[4]).contains("Transport") && !filters[3]) && !(((String)recording[4]).contains("Application") && !filters[4])){ ! // && !(((String)recording[4]).contains("ARP") && !filters[1]) ! pnlConsole.append(pad(recording[1],15,' ')+pad(recording[2],25,' ')+pad(recording[3],15,' ')+pad(recording[4],10,' ')+recording[5]+ "\n"); ! } } *************** *** 2988,2991 **** --- 3017,3040 ---- } + + /** + * Print routes table on throws node + * @author Key + * @param String inNodeName Name of node to run command on + */ + + public void PrintRouteTable(String inNodeName){ + String routes[] = Sim.getRouteTableEntries(inNodeName); + + this.addToConsole("IP routing table:\n" + "Destination" + "\t" + "Gateway" + "\t" + "Genmask" + "\t" + "Type" + "\t" + "Iface\n"); + + for(int i=0; i<routes.length - 1; i++){ + + Route_entry r = Sim.getRouteEntry(inNodeName, routes[i]); + + this.addToConsole(routes[i] + "\t" + r.gateway + "\t" + r.genMask + "\t" + r.Type + "\t" + r.iFace + "\n"); + + } + } /** Index: MenuBar.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/guiUI/MenuBar.java,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** MenuBar.java 8 Nov 2005 04:04:28 -0000 1.1.1.1 --- MenuBar.java 3 Dec 2005 11:28:46 -0000 1.2 *************** *** 33,37 **** private JMenuItem mnuClearConsole = new JMenuItem("Clear Console"); private JMenuItem mnuClearNodeInformation = new JMenuItem("Clear Node Information"); ! //Add submenu private JMenu mnuAdd = new JMenu("Add"); //For Adding objects to simulation --- 33,46 ---- private JMenuItem mnuClearConsole = new JMenuItem("Clear Console"); private JMenuItem mnuClearNodeInformation = new JMenuItem("Clear Node Information"); ! private JMenu mnuFilters = new JMenu("Show simulation messages for:"); ! ! //Filters menu ! private JCheckBoxMenuItem mnuMsgLinkLayer = new JCheckBoxMenuItem("Link and DataLink Layers",true); ! private JCheckBoxMenuItem mnuMsgARP = new JCheckBoxMenuItem("ARP",true); ! private JCheckBoxMenuItem mnuMsgNetwork = new JCheckBoxMenuItem("Network Layer",true); ! private JCheckBoxMenuItem mnuMsgTransport = new JCheckBoxMenuItem("Transport Layer",true); ! private JCheckBoxMenuItem mnuMsgApplication = new JCheckBoxMenuItem("Application Layer",true); ! ! //Add submenu private JMenu mnuAdd = new JMenu("Add"); //For Adding objects to simulation *************** *** 99,102 **** --- 108,118 ---- mnuEnvironment.add(mnuClearConsole); mnuEnvironment.add(mnuClearNodeInformation); + mnuEnvironment.add(mnuFilters); + + mnuFilters.add(mnuMsgLinkLayer); + //mnuFilters.add(mnuMsgARP); + mnuFilters.add(mnuMsgNetwork); + mnuFilters.add(mnuMsgTransport); + mnuFilters.add(mnuMsgApplication); //Add items to help *************** *** 163,167 **** --- 179,213 ---- } }); + + mnuMsgLinkLayer.addActionListener(new ActionListener(){ + public void actionPerformed(ActionEvent e){ + controller.setFilter(0,!controller.getFilter(0)); + } + }); + + mnuMsgARP.addActionListener(new ActionListener(){ + public void actionPerformed(ActionEvent e){ + controller.setFilter(1,!controller.getFilter(1)); + } + }); + + mnuMsgNetwork.addActionListener(new ActionListener(){ + public void actionPerformed(ActionEvent e){ + controller.setFilter(2,!controller.getFilter(2)); + } + }); + mnuMsgTransport.addActionListener(new ActionListener(){ + public void actionPerformed(ActionEvent e){ + controller.setFilter(3,!controller.getFilter(3)); + } + }); + + mnuMsgApplication.addActionListener(new ActionListener(){ + public void actionPerformed(ActionEvent e){ + controller.setFilter(4,!controller.getFilter(4)); + } + }); + //Add action listener to new switch /* |