Thread: [Javanetsim-cvs] javaNetSim/guiUI GuiNode.java, 1.6, 1.7 GuiPC.java, 1.6, 1.7 MainScreen.java, 1.83
Status: Beta
Brought to you by:
darkkey
From: Alexander B. <da...@us...> - 2008-09-09 09:16:16
|
Update of /cvsroot/javanetsim/javaNetSim/guiUI In directory sc8-pr-cvs17.sourceforge.net:/tmp/cvs-serv6886/guiUI Modified Files: GuiNode.java GuiPC.java MainScreen.java Log Message: Index: MainScreen.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/guiUI/MainScreen.java,v retrieving revision 1.83 retrieving revision 1.84 diff -C2 -d -r1.83 -r1.84 *** MainScreen.java 26 Dec 2007 17:43:15 -0000 1.83 --- MainScreen.java 9 Sep 2008 09:16:10 -0000 1.84 *************** *** 136,141 **** private static final String HTM_PREFIX = "htm"; ! ! //File used to save simulation --- 136,142 ---- private static final String HTM_PREFIX = "htm"; ! ! ! private int Rcnt=0, SWcnt=0, PCcnt=0, PRINTcnt=0, HUBcnt=0; //File used to save simulation *************** *** 684,688 **** public void addPC(Point inPoint){ ! String result = JOptionPane.showInputDialog(this,"Please enter a PC name:","Create New PC", JOptionPane.PLAIN_MESSAGE); if(result != null){ --- 685,689 ---- public void addPC(Point inPoint){ ! String result = JOptionPane.showInputDialog(this,"Please enter a name for a new PC:", "PC" + PCcnt); if(result != null){ *************** *** 695,701 **** Sim.addPC(result, true); ! Sim.getNode(result).addNetworkInterface(core.NetworkInterface.getIntName(core.NetworkInterface.Ethernet10T) + "0", core.NetworkInterface.Ethernet10T, true); ! Sim.getNode(result).addNetworkInterface(core.NetworkInterface.getIntName(core.NetworkInterface.Console) + "0", core.NetworkInterface.Console, false); --- 696,704 ---- Sim.addPC(result, true); + + PCcnt++; ! Sim.getNode(result).addNetworkInterface(core.NetworkInterface.getIntName(core.NetworkInterface.Ethernet10T) + "0", core.NetworkInterface.Ethernet10T, true); ! Sim.getNode(result).addNetworkInterface(core.NetworkInterface.getIntName(core.NetworkInterface.Console) + "0", core.NetworkInterface.Console, false); *************** *** 747,751 **** public void addPrinter(Point inPoint){ ! String result = JOptionPane.showInputDialog(this,"Please enter a Printer name:","Create New Printer", JOptionPane.PLAIN_MESSAGE); if(result != null){ --- 750,754 ---- public void addPrinter(Point inPoint){ ! String result = JOptionPane.showInputDialog(this, "Please enter a name for new Printer:", "Printer" + PRINTcnt); if(result != null){ *************** *** 839,845 **** public void addRouter(Point inPoint){ ! String result = JOptionPane.showInputDialog(this,"Please enter a Router name:","Create New Router", JOptionPane.PLAIN_MESSAGE); ! String[] choices = {"Simple router with 2 Ethernet-TX ports.", "Router with 3 Ethernet-TX ports", "Router with 2 Ethernet-TX ports and 1 Ethernet-FX port.", --- 842,850 ---- public void addRouter(Point inPoint){ ! String result = JOptionPane.showInputDialog(this,"Please enter a name for new Router:", "R" + Rcnt); ! ! if(result != null){ ! String[] choices = {"Simple router with 2 Ethernet-TX ports.", "Router with 3 Ethernet-TX ports", "Router with 2 Ethernet-TX ports and 1 Ethernet-FX port.", *************** *** 848,856 **** }; ! String choice = (String)JOptionPane.showInputDialog(this,"Please choose Switch type", "Create New Switch", JOptionPane.PLAIN_MESSAGE, null, choices,choices[0]); ! if(result != null && choice !=null){ result = result.trim(); --- 853,861 ---- }; ! String choice = (String)JOptionPane.showInputDialog(this,"Please choose router type", "Create New Router", JOptionPane.PLAIN_MESSAGE, null, choices,choices[0]); ! if(choice !=null){ result = result.trim(); *************** *** 861,864 **** --- 866,872 ---- Sim.addRouter(result, true); + + Rcnt++; + Sim.getNode(result).addNetworkInterface(NetworkInterface.getIntName(NetworkInterface.Console) + "0", NetworkInterface.Console, false); *************** *** 920,923 **** --- 928,933 ---- } + + } this.setAllHighlightsOff(); *************** *** 927,931 **** } ! /** --- 937,944 ---- } ! public void showRIPDialog(String inNodeName){ ! new RIPProperties(this,Sim,Sandbox,inNodeName); ! ! } /** *************** *** 941,945 **** public void addHub(Point inPoint){ ! String result = JOptionPane.showInputDialog(this,"Please enter a Hub name:","Create New Hub", JOptionPane.PLAIN_MESSAGE); String[] choises = {"5-ports simple hub.", --- 954,960 ---- public void addHub(Point inPoint){ ! String result = JOptionPane.showInputDialog(this,"Please enter a name for new Hub:","H" + HUBcnt); ! ! if(result != null){ String[] choises = {"5-ports simple hub.", *************** *** 951,955 **** choises,choises[0]); ! if(result != null && choice != null){ result = result.trim(); --- 966,970 ---- choises,choises[0]); ! if(choice != null){ result = result.trim(); *************** *** 960,963 **** --- 975,980 ---- int portCount = 5; + HUBcnt++; + if(choice.contains(choises[1])) portCount = 8; *************** *** 999,1002 **** --- 1016,1021 ---- } + + } this.setAllHighlightsOff(); *************** *** 1134,1140 **** public void addSwitch(Point inPoint){ ! String result = JOptionPane.showInputDialog(this,"Please enter a Switch name:","Create New Switch", JOptionPane.PLAIN_MESSAGE); ! String[] choices = {"5 Ethernet-TX ports simple switch.", "8 Ethernet-TX ports switch.", "12 Ethernet-TX ports switch.", --- 1153,1161 ---- public void addSwitch(Point inPoint){ ! String result = JOptionPane.showInputDialog(this,"Please enter a name for new Switch:", "SW"+SWcnt); ! ! if(result != null){ ! String[] choices = {"5 Ethernet-TX ports simple switch.", "8 Ethernet-TX ports switch.", "12 Ethernet-TX ports switch.", *************** *** 1146,1155 **** }; ! String choice = (String)JOptionPane.showInputDialog(this,"Please choose Switch type", "Create New Switch", JOptionPane.PLAIN_MESSAGE, null, choices,choices[0]); ! if(result != null && choice != null){ result = result.trim(); --- 1167,1176 ---- }; ! String choice = (String)JOptionPane.showInputDialog(this,"Please choose switch type", "Create New Switch", JOptionPane.PLAIN_MESSAGE, null, choices,choices[0]); ! if(choice != null){ result = result.trim(); *************** *** 1160,1163 **** --- 1181,1186 ---- int tx=0, fx=0; + SWcnt++; + if(choice.contains(choices[0])){ tx = 5; fx = 0; *************** *** 1221,1224 **** --- 1244,1249 ---- } + + } this.setAllHighlightsOff(); *************** *** 1357,1361 **** String strSecondNodeInterface = dlgLink.getSecondSelectedInterface(); ! String strLinkName = inNode1 + "-" + Sim.getNode(inNode1).getIntSType(strFirstNodeInterface) + "-" + inNode2; if( Sim.getNode(inNode1).getIntType(strFirstNodeInterface) == Sim.getNode(inNode2).getIntType(strSecondNodeInterface)){ --- 1382,1388 ---- String strSecondNodeInterface = dlgLink.getSecondSelectedInterface(); ! //String strLinkName = inNode1 + "-" + Sim.getNode(inNode1).getIntSType(strFirstNodeInterface) + "-" + inNode2; ! ! String strLinkName = inNode1 + "(" + strFirstNodeInterface + ") - " + inNode2 + "(" + strSecondNodeInterface + ")"; if( Sim.getNode(inNode1).getIntType(strFirstNodeInterface) == Sim.getNode(inNode2).getIntType(strSecondNodeInterface)){ *************** *** 2345,2358 **** printLayerInfo(false); ! JFileChooser chooser = new JFileChooser(); chooser.setDialogTitle("Open File ..."); ! chooser.setMultiSelectionEnabled(false); ! chooser.setAcceptAllFileFilterUsed(false); ! chooser.addChoosableFileFilter(new JNSTFilter()); int returnVal = chooser.showOpenDialog(this); ! if(returnVal == JFileChooser.APPROVE_OPTION){ try { --- 2372,2385 ---- printLayerInfo(false); ! JFileChooser chooser = new JFileChooser(); chooser.setDialogTitle("Open File ..."); ! chooser.setMultiSelectionEnabled(false); ! chooser.setAcceptAllFileFilterUsed(false); ! chooser.addChoosableFileFilter(new JNSTFilter()); int returnVal = chooser.showOpenDialog(this); ! if(returnVal == JFileChooser.APPROVE_OPTION){ try { *************** *** 2525,2528 **** --- 2552,2556 ---- GuiHub tempHub = new GuiHub(strNodeName,this); tempHub.setNodeLocation(pnt); + tempHub.setEnabled(false); Sandbox.add(tempHub); Sandbox.setLayer((Component) tempHub,3,0); *************** *** 2531,2534 **** --- 2559,2563 ---- GuiSwitch tempSwitch = new GuiSwitch(strNodeName,this); tempSwitch.setNodeLocation(pnt); + tempSwitch.setEnabled(false); Sandbox.add(tempSwitch); Sandbox.setLayer(tempSwitch,3,0); *************** *** 2537,2540 **** --- 2566,2570 ---- GuiCSUDSU tempCSUDSU = new GuiCSUDSU(strNodeName,this); tempCSUDSU.setNodeLocation(pnt); + tempCSUDSU.setEnabled(false); Sandbox.add(tempCSUDSU); Sandbox.setLayer(tempCSUDSU,3,0); *************** *** 2543,2546 **** --- 2573,2577 ---- GuiPC tempPC = new GuiPC(strNodeName,this); tempPC.setNodeLocation(pnt); + tempPC.setEnabled(false); Sandbox.add(tempPC); Sandbox.setLayer(tempPC,3,0); *************** *** 2549,2552 **** --- 2580,2584 ---- GuiRouter tempRouter = new GuiRouter(strNodeName,this); tempRouter.setNodeLocation(pnt); + tempRouter.setEnabled(false); Sandbox.add(tempRouter); Sandbox.setLayer(tempRouter,3,0); *************** *** 2555,2558 **** --- 2587,2591 ---- GuiExternalProxy tempRouter = new GuiExternalProxy(strNodeName,this); tempRouter.setNodeLocation(pnt); + tempRouter.setEnabled(false); Sandbox.add(tempRouter); Sandbox.setLayer(tempRouter,3,0); *************** *** 2594,2597 **** --- 2627,2631 ---- String nodeName = (String) DevicesTurnedOn.get(i); Sim.getNode(nodeName).turnOn(); + ((GuiNode)GUInodeTable.get(nodeName)).setEnabled(true); } *************** *** 2622,2632 **** ! public void Import(){ ! printLayerInfo(false); JFileChooser chooser = new JFileChooser(); ! chooser.setDialogTitle("Import simulation from previous versions ..."); chooser.setMultiSelectionEnabled(false); --- 2656,2666 ---- ! public void Import(){ ! printLayerInfo(false); JFileChooser chooser = new JFileChooser(); ! chooser.setDialogTitle("Import simulation from previous versions ..."); chooser.setMultiSelectionEnabled(false); *************** *** 2645,2648 **** --- 2679,2683 ---- File inFile = chooser.getSelectedFile(); + Vector DevicesTurnedOn = new Vector(); //System.out.println(inFile.getPath()); *************** *** 2740,2743 **** --- 2775,2780 ---- tempHub.setNodeLocation(pnt); + + tempHub.setEnabled(true); Sandbox.add(tempHub); *************** *** 2760,2763 **** --- 2797,2802 ---- tempSwitch.setNodeLocation(pnt); + + tempSwitch.setEnabled(true); Sandbox.add(tempSwitch); *************** *** 2776,2779 **** --- 2815,2820 ---- GuiPC tempPC = new GuiPC(strNodeName,this); + + tempPC.setEnabled(true); tempPC.setNodeLocation(pnt); *************** *** 2799,2802 **** --- 2840,2845 ---- tempRouter.setNodeLocation(pnt); + + tempRouter.setEnabled(true); Sandbox.add(tempRouter); *************** *** 2873,2878 **** } - try{ Route_entry r; --- 2916,2921 ---- } + try{ Route_entry r; *************** *** 2889,2892 **** --- 2932,2938 ---- Sim.addRoute(strNodeName, r); } + + + Sim.execCmd(strNodeName, "write mem"); }catch(Exception e){ *************** *** 4041,4051 **** } ! public void TurnDevice(String inNodeName){ try{ if(Sim.getNode(inNodeName).On == true){ Sim.getNode(inNodeName).turnOff(); }else{ Sim.getNode(inNodeName).turnOn(); ! } }catch(Exception e){ } --- 4087,4098 ---- } ! public void TurnDevice(GuiNode node, String inNodeName){ try{ if(Sim.getNode(inNodeName).On == true){ Sim.getNode(inNodeName).turnOff(); + node.setEnabled(false); }else{ Sim.getNode(inNodeName).turnOn(); ! node.setEnabled(true); } }catch(Exception e){ } *************** *** 4055,4061 **** try{ if(Sim.getNode(inNodeName).On == true){ ! return "Turn On"; }else{ ! return "Turn Off"; } }catch(Exception e){ --- 4102,4108 ---- try{ if(Sim.getNode(inNodeName).On == true){ ! return "Turn Off"; }else{ ! return "Turn On"; } }catch(Exception e){ Index: GuiNode.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/guiUI/GuiNode.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** GuiNode.java 10 Nov 2007 13:25:39 -0000 1.6 --- GuiNode.java 9 Sep 2008 09:16:10 -0000 1.7 *************** *** 109,112 **** --- 109,113 ---- protected JLabel lblNodeName = new JLabel(); + protected GuiNode selfLink = this; *************** *** 248,254 **** lblIcon.setIcon(nodeIcon); ! lblIcon.setHorizontalAlignment((JLabel.CENTER)); ! ! //Set the layout of this jPanel --- 249,253 ---- lblIcon.setIcon(nodeIcon); ! lblIcon.setHorizontalAlignment((JLabel.CENTER)); //Set the layout of this jPanel *************** *** 352,356 **** ! GuiNodePopMenu.add(mnuDelete); GuiNodePopMenu.add(mnuTurn); GuiNodePopMenu.add(mnuBreakLink); --- 351,355 ---- ! GuiNodePopMenu.add(mnuDelete); GuiNodePopMenu.add(mnuTurn); GuiNodePopMenu.add(mnuBreakLink); *************** *** 358,361 **** --- 357,362 ---- GuiNodePopMenu.add(mnuInt); + + mnuTurn.setText(controller.DeviceState(lblNodeName.getText())); mnuTurn.addActionListener(new ActionListener(){ *************** *** 363,373 **** public void actionPerformed(ActionEvent e){ //controller.showLinkDialog(lblNodeName.getText()); ! controller.TurnDevice(lblNodeName.getText()); mnuTurn.setText(controller.DeviceState(lblNodeName.getText())); - } ! }); } /** --- 364,379 ---- public void actionPerformed(ActionEvent e){ //controller.showLinkDialog(lblNodeName.getText()); ! controller.TurnDevice(selfLink, lblNodeName.getText()); mnuTurn.setText(controller.DeviceState(lblNodeName.getText())); } ! }); ! } + public void setEnabled(boolean e){ + lblIcon.setEnabled(e); + mnuTurn.setText(controller.DeviceState(lblNodeName.getText())); + } + /** Index: GuiPC.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/guiUI/GuiPC.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** GuiPC.java 26 Dec 2007 17:43:15 -0000 1.6 --- GuiPC.java 9 Sep 2008 09:16:10 -0000 1.7 *************** *** 104,108 **** private JMenuItem mnuDNSListen = new JMenuItem("Start DNS server"); private JMenuItem mnuDNSSend = new JMenuItem("Send request to DNS server"); ! private JMenuItem mnuDNSEdit = new JMenuItem("Edit DNS-table"); --- 104,109 ---- private JMenuItem mnuDNSListen = new JMenuItem("Start DNS server"); private JMenuItem mnuDNSSend = new JMenuItem("Send request to DNS server"); ! private JMenuItem mnuDNSEdit = new JMenuItem("Edit DNS-table"); ! private JMenuItem mnuRIPcfg = new JMenuItem("Configure RIP..."); *************** *** 195,204 **** }); mnuAppLayer.addSeparator(); mnuAppLayer.add(mnuEchoListen); ! mnuAppLayer.add(mnuEchoSend); mnuAppLayer.addSeparator(); mnuAppLayer.add(mnuEchotcpListen); ! mnuAppLayer.add(mnuEchotcpSend); mnuAppLayer.addSeparator(); mnuAppLayer.add(mnuSNMPManager); --- 196,211 ---- }); + mnuRIPcfg.addActionListener(new ActionListener(){ + public void actionPerformed(ActionEvent e){ + controller.showRIPDialog(lblNodeName.getText()); + } + }); + mnuAppLayer.addSeparator(); mnuAppLayer.add(mnuEchoListen); ! mnuAppLayer.add(mnuEchoSend); mnuAppLayer.addSeparator(); mnuAppLayer.add(mnuEchotcpListen); ! mnuAppLayer.add(mnuEchotcpSend); mnuAppLayer.addSeparator(); mnuAppLayer.add(mnuSNMPManager); *************** *** 206,210 **** mnuAppLayer.add(mnuTelnetListen); mnuAppLayer.add(mnuTelnetNoListen); ! mnuAppLayer.add(mnuTelnetConnect); mnuAppLayer.add(mnuPosixTelnet); mnuAppLayer.addSeparator(); --- 213,217 ---- mnuAppLayer.add(mnuTelnetListen); mnuAppLayer.add(mnuTelnetNoListen); ! mnuAppLayer.add(mnuTelnetConnect); mnuAppLayer.add(mnuPosixTelnet); mnuAppLayer.addSeparator(); *************** *** 214,217 **** --- 221,226 ---- mnuAppLayer.add(mnuDNSSend); mnuAppLayer.add(mnuDNSEdit); + mnuAppLayer.addSeparator(); + mnuAppLayer.add(mnuRIPcfg); } |