[Javanetsim-cvs] javaNetSim/guiUI MainScreen.java, 1.72, 1.73 MenuBar.java, 1.16, 1.17
Status: Beta
Brought to you by:
darkkey
From: Alexander B. <da...@us...> - 2007-10-19 08:52:42
|
Update of /cvsroot/javanetsim/javaNetSim/guiUI In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv11211/guiUI Modified Files: MainScreen.java MenuBar.java Log Message: New save file format; import. Index: MainScreen.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/guiUI/MainScreen.java,v retrieving revision 1.72 retrieving revision 1.73 diff -C2 -d -r1.72 -r1.73 *** MainScreen.java 15 Oct 2007 18:25:54 -0000 1.72 --- MainScreen.java 19 Oct 2007 08:52:27 -0000 1.73 *************** *** 129,135 **** //Prefix for file extension ! private static final String GUI_PREFIX = "jfst"; ! private static final String SIM_PREFIX = "jfst"; private static final String HTM_PREFIX = "htm"; --- 129,135 ---- //Prefix for file extension ! private static final String OLD_PREFIX = "jfst"; ! private static final String SIM_PREFIX = "jnst"; private static final String HTM_PREFIX = "htm"; *************** *** 197,202 **** //The File chooser class - private JFileChooser chooser = new JFileChooser(); - private JScrollPane scroller = new JScrollPane(); --- 197,200 ---- *************** *** 689,693 **** try { ! Sim.addPC(result); GuiPC tempPC = new GuiPC(result,this); --- 687,691 ---- try { ! Sim.addPC(result, true); GuiPC tempPC = new GuiPC(result,this); *************** *** 781,785 **** try { ! Sim.addRouter(result); GuiRouter tempRouter = new GuiRouter(result,this); --- 779,783 ---- try { ! Sim.addRouter(result, true); GuiRouter tempRouter = new GuiRouter(result,this); *************** *** 845,849 **** try { ! Sim.addHub(result); GuiHub tempHub = new GuiHub(result,this); --- 843,847 ---- try { ! Sim.addHub(result, true); GuiHub tempHub = new GuiHub(result,this); *************** *** 897,901 **** try { ! Sim.addCSUDSU(result); GuiCSUDSU tempCSUDSU = new GuiCSUDSU(result,this); --- 895,899 ---- try { ! Sim.addCSUDSU(result, true); GuiCSUDSU tempCSUDSU = new GuiCSUDSU(result,this); *************** *** 958,962 **** try { ! Sim.addExternalNAT(result); GuiExternalProxy tempEN = new GuiExternalProxy(result,this); --- 956,960 ---- try { ! Sim.addExternalNAT(result, true); GuiExternalProxy tempEN = new GuiExternalProxy(result,this); *************** *** 1020,1024 **** try { ! Sim.addSwitch(result); GuiSwitch tempSwitch = new GuiSwitch(result,this); --- 1018,1022 ---- try { ! Sim.addSwitch(result, true); GuiSwitch tempSwitch = new GuiSwitch(result,this); *************** *** 1927,2032 **** - /** - - * Currently not implements but will eventually save the Simulation and GUI Nodes. - - * - - */ - public void Save(){ - if(simSaveFile!=null) SaveAs(simSaveFile.getPath()); - else SaveAs(null); - } - - - /** - - * Currently not implements but will eventually save the Simulation and GUI Nodes. - - * - - */ - - public void SaveAs(String saveas){ chooser.setDialogTitle("Save As ..."); - chooser.setAcceptAllFileFilterUsed(false); ! ! chooser.addChoosableFileFilter(new GraphicFilter()); ! ! int returnVal; - - if(saveas == null){ - returnVal = chooser.showSaveDialog(this); - }else{ - returnVal = JFileChooser.APPROVE_OPTION; - } - if(returnVal == JFileChooser.APPROVE_OPTION){ - //Get Selected file for saving GUI information - File tempFile = chooser.getSelectedFile(); ! ! ! ! ! //TODO Test if prefix isnt already added!!!!! ! ! ! ! //Set the Sim save file ! ! if(saveas == null){ ! if(tempFile.getPath().contains("."+SIM_PREFIX)) simSaveFile = new File(tempFile.getPath()); - else simSaveFile = new File(tempFile.getPath()+"."+SIM_PREFIX); - } - - - //TODO Remove me!!! - - //System.out.println(simSaveFile.getPath()); - - - //Save Simulation. - try{ ! Enumeration enum1 = GUInodeTable.keys(); ! String strSave = ""; - - while(enum1.hasMoreElements()){ String key = (String)enum1.nextElement(); - GuiNode tempNode = (GuiNode)GUInodeTable.get(key); - String lnk; --- 1925,1970 ---- public void Save(){ if(simSaveFile!=null) SaveAs(simSaveFile.getPath()); else SaveAs(null); } public void SaveAs(String saveas){ + JFileChooser chooser = new JFileChooser(); + chooser.setDialogTitle("Save As ..."); chooser.setAcceptAllFileFilterUsed(false); ! chooser.addChoosableFileFilter(new JNSTFilter()); int returnVal; if(saveas == null){ returnVal = chooser.showSaveDialog(this); }else{ returnVal = JFileChooser.APPROVE_OPTION; } if(returnVal == JFileChooser.APPROVE_OPTION){ //Get Selected file for saving GUI information File tempFile = chooser.getSelectedFile(); ! if(saveas == null){ if(tempFile.getPath().contains("."+SIM_PREFIX)) simSaveFile = new File(tempFile.getPath()); else simSaveFile = new File(tempFile.getPath()+"."+SIM_PREFIX); } //Save Simulation. try{ ! Enumeration enum1 = GUInodeTable.keys(); String strSave = ""; while(enum1.hasMoreElements()){ String key = (String)enum1.nextElement(); GuiNode tempNode = (GuiNode)GUInodeTable.get(key); String lnk; *************** *** 2034,2054 **** Object nics[] = Sim.getAllInterfaces(key); - - - Arrays.sort(nics); - - String strType = tempNode.getClass().toString(); - strType = strType.replaceFirst("class guiUI\\.",""); - - Point pnt1 = tempNode.getLocation(); - - strSave = strSave + key + "\n" --- 1972,1982 ---- *************** *** 2056,2131 **** + pnt1.x + "," + pnt1.y + "\n" + nics.length + "\n"; - - for (int i = 0; i < nics.length; i++) { String linkName = Sim.getLinkName(key, nics[i].toString()); ! strSave = strSave + nics[i] + "|" + linkName; ! ! if(tempNode instanceof NetworkLayerDevice){ ! ! String lP = "100.00"; ! ! try{ ! lnk = Sim.getLinkName(key, nics[i].toString()); ! lP = Double.valueOf(Sim.GetLinkProb(lnk)).toString(); ! }catch(Exception e){} ! ! ! strSave = strSave + "|" + Sim.getIpAddressForInterface(key,nics[i].toString()) ! ! + "|" + Sim.getSubnetMask(key,nics[i].toString()) ! ! + "|" + Sim.getDefaultGateway(key) + "|" + Sim.getMacAddressForInterface(key, nics[i].toString()) ! + "|" + lP; ! ! }else{ ! ! strSave = strSave + "|||"; ! } - - strSave = strSave + "\n"; - ! } ! try{ ! String routes[] = Sim.getRouteTableEntries(key); ! strSave = strSave + (routes.length-1) + "\n"; ! ! Route_entry r; ! ! for(int i=0; i<routes.length-1; i++){ ! ! r = Sim.getRouteEntry(key, routes[i]); ! ! strSave = strSave + routes[i] + "|" + r.gateway + "|" + r.genMask + "|" + r.Type + "|" + r.iFace + "\n"; ! ! } ! ! }catch(Exception e){ ! strSave = strSave + "0\n"; ! } } catch (Exception e) { //This should never happen - e.printStackTrace(); - } - - - - - - } --- 1984,2058 ---- + pnt1.x + "," + pnt1.y + "\n" + + + Sim.getNode(key).On + "\n" + nics.length + "\n"; for (int i = 0; i < nics.length; i++) { String linkName = Sim.getLinkName(key, nics[i].toString()); + int type = Sim.getNode(key).getIntType(nics[i].toString()); ! strSave = strSave + nics[i] + "|" + type + "|" + linkName; ! ! String lP = "100.00"; ! try{ ! lnk = Sim.getLinkName(key, nics[i].toString()); ! lP = Double.valueOf(Sim.GetLinkProb(lnk)).toString(); ! }catch(Exception e){} ! ! strSave += "|" + lP; ! ! switch(type){ ! case core.NetworkInterface.Ethernet10T: ! if((Sim.getNode(key).getNIC(nics[i].toString())) instanceof core.NetworkInterfacePort ){ ! strSave += "|#"; ! }else{ ! strSave += "|" + Sim.getMacAddressForInterface(key, nics[i].toString()); ! } ! break; ! case core.NetworkInterface.Console: ! break; ! case core.NetworkInterface.WAN: ! strSave += "|" + ! ((core.WANNetworkInterface)Sim.getNode(key).getNIC(nics[i].toString())).getConnType() ! + "|" + ! ((core.WANNetworkInterface)Sim.getNode(key).getNIC(nics[i].toString())).getServer() ! + "|" + ! ((core.WANNetworkInterface)Sim.getNode(key).getNIC(nics[i].toString())).getConnHost() ! + "|" + ! ((core.WANNetworkInterface)Sim.getNode(key).getNIC(nics[i].toString())).getConnPort() ! + "|" + ! ((core.WANNetworkInterface)Sim.getNode(key).getNIC(nics[i].toString())).getConnService(); ! break; ! case core.NetworkInterface.Serial: ! strSave += "|" + ! ((core.SerialNetworkInterface)Sim.getNode(key).getNIC(nics[i].toString())).getClockRate(); ! break; } ! strSave += "\n"; } + strSave += "#config\n"; ! if(Sim.getNode(key) instanceof core.NetworkLayerDevice){ ! Iterator<String> cnf = ((core.NetworkLayerDevice)Sim.getNode(key)).getConfig().getConfig(core.DeviceConfig.STARTUP_CONFIG).iterator(); ! while(cnf.hasNext()){ ! strSave += cnf.next() + "\n"; ! } ! } ! ! strSave += "#endconfig\n"; ! ! strSave += "#data\n"; + strSave += "#enddata\n"; + } catch (Exception e) { //This should never happen e.printStackTrace(); } } *************** *** 2152,2182 **** } - - - //FileOutputStream out = new FileOutputStream(simSaveFile); - - //ObjectOutputStream objStream = new ObjectOutputStream(out); - - - - //objStream.writeBytes("\n"); - - - - - - //objStream.flush(); - - - System.out.println("Writing Simulation file"); ! ! ! ! ! ! ! System.out.println("Simulation was saved succesfully."); System.out.println("File "+ simSaveFile.getName() + " has been saved to " + simSaveFile.getAbsolutePath()); --- 2079,2085 ---- } System.out.println("Writing Simulation file"); ! System.out.println("Simulation was saved succesfully."); System.out.println("File "+ simSaveFile.getName() + " has been saved to " + simSaveFile.getAbsolutePath()); *************** *** 2205,2208 **** --- 2108,2113 ---- public void save_html_rep(String saveas){ + JFileChooser chooser = new JFileChooser(); + chooser.setDialogTitle("Save HTML report..."); chooser.setAcceptAllFileFilterUsed(false); *************** *** 2267,2279 **** printLayerInfo(false); chooser.setDialogTitle("Open File ..."); ! //chooser.setMultiSelectionEnabled(true); ! //chooser.setAcceptAllFileFilterUsed(false); //TODO this needs to be false ! ! chooser.addChoosableFileFilter(new GraphicFilter()); int returnVal = chooser.showOpenDialog(this); --- 2172,2408 ---- 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 { ! File inFile = chooser.getSelectedFile(); ! File simFile; ! if(inFile.getPath().contains("."+SIM_PREFIX)) simFile = new File(inFile.getPath()); ! else simFile = new File(inFile.getPath()+"."+SIM_PREFIX); ! ! this.refreshMainScreen(); ! ! ! BufferedReader input = null; ! ! try { ! ! input = new BufferedReader( new FileReader(simFile) ); ! String line = null; //not declared within while loop ! ! Vector DevicesTurnedOn = new Vector(); ! Hashtable links = new Hashtable(); ! ! while (( line = input.readLine()) != null){ ! ! String strNodeName; ! String strClassName; ! String coords; ! int intCount; ! int x; ! int y; ! int j; ! int deviceType = 0; ! boolean on = false; ! ! ! strNodeName = line; ! strClassName = input.readLine().trim(); ! coords = input.readLine(); ! on = Boolean.valueOf(input.readLine().trim()); ! intCount = Integer.valueOf(input.readLine()).intValue(); ! ! if(on) DevicesTurnedOn.add(strNodeName); ! ! String xy[] = coords.split(","); ! ! x = Integer.valueOf(xy[0]).intValue(); ! y = Integer.valueOf(xy[1]).intValue(); ! ! Point pnt = new Point(x,y); ! ! if(strClassName.contains("GuiHub")){ ! deviceType = 1; ! Sim.addHub(strNodeName, false); ! GuiHub tempHub = new GuiHub(strNodeName,this); ! tempHub.setNodeLocation(pnt); ! Sandbox.add(tempHub); ! Sandbox.setLayer((Component) tempHub,3,0); ! GUInodeTable.put(strNodeName,tempHub); ! }else if(strClassName.contains("GuiSwitch")){ ! deviceType = 1; ! Sim.addSwitch(strNodeName, false); ! GuiSwitch tempSwitch = new GuiSwitch(strNodeName,this); ! tempSwitch.setNodeLocation(pnt); ! Sandbox.add(tempSwitch); ! Sandbox.setLayer(tempSwitch,3,0); ! GUInodeTable.put(strNodeName,tempSwitch); ! }else if(strClassName.contains("GuiCSUDSU")){ ! deviceType = 1; ! Sim.addCSUDSU(strNodeName, false); ! GuiCSUDSU tempCSUDSU = new GuiCSUDSU(strNodeName,this); ! tempCSUDSU.setNodeLocation(pnt); ! Sandbox.add(tempCSUDSU); ! Sandbox.setLayer(tempCSUDSU,3,0); ! GUInodeTable.put(strNodeName,tempCSUDSU); ! }else if(strClassName.contains("GuiPC")){ ! deviceType = 2; ! Sim.addPC(strNodeName, false); ! GuiPC tempPC = new GuiPC(strNodeName,this); ! tempPC.setNodeLocation(pnt); ! Sandbox.add(tempPC); ! Sandbox.setLayer(tempPC,3,0); ! GUInodeTable.put(strNodeName,tempPC); ! }else if(strClassName.contains("GuiRouter")){ ! deviceType = 2; ! Sim.addRouter(strNodeName, false); ! GuiRouter tempRouter = new GuiRouter(strNodeName,this); ! tempRouter.setNodeLocation(pnt); ! Sandbox.add(tempRouter); ! Sandbox.setLayer(tempRouter,3,0); ! GUInodeTable.put(strNodeName,tempRouter); ! }else if(strClassName.contains("GuiExternalProxy")){ ! deviceType = 2; ! Sim.addExternalNAT(strNodeName, false); ! GuiExternalProxy tempRouter = new GuiExternalProxy(strNodeName,this); ! tempRouter.setNodeLocation(pnt); ! Sandbox.add(tempRouter); ! Sandbox.setLayer(tempRouter,3,0); ! GUInodeTable.put(strNodeName,tempRouter); ! } ! ! ! String sieve = "100.00"; ! ! for(j = 1; j<=intCount; j++){ ! ! line = input.readLine(); ! ! String iface[] = line.split("\\|"); ! ! int LinkType = Integer.valueOf(iface[1]); ! ! String strLinkName = iface[2]; ! ! sieve = iface[3]; ! ! switch(LinkType){ ! case core.NetworkInterface.Ethernet10T: ! if(!iface[4].contains("#")) ! try{ ! //FIXME!!!!!!! ! Sim.setMACAddress(strNodeName,iface[0], iface[4]); ! }catch(Exception e){ } ! break; ! case core.NetworkInterface.Serial: ! ((core.SerialNetworkInterface)Sim.getNode(strNodeName).getNIC(iface[0])).setClockRate(Integer.valueOf(iface[4])); ! break; ! } ! ! if(!strLinkName.contains("null")){ ! ! if(((String)links.get(strLinkName)) == null){ ! ! links.put(strLinkName, strNodeName + "|" + iface[0] + "|" + sieve); ! ! }else{ ! ! String ln[] = ((String) links.get(strLinkName)).split("\\|"); ! ! switch(LinkType){ ! case core.NetworkInterface.Ethernet10T: ! Sim.addEthernetLink(strLinkName, ln[0], ln[1], strNodeName, iface[0], ln[2]); ! this.createLink(strLinkName, ln[0], strNodeName, core.NetworkInterface.Ethernet10T); ! break; ! case core.NetworkInterface.Console: ! Sim.addConsoleLink(strLinkName, ln[0], ln[1], strNodeName, iface[0]); ! this.createLink(strLinkName, ln[0], strNodeName, core.NetworkInterface.Console); ! break; ! case core.NetworkInterface.Serial: ! Sim.addSerialLink(strLinkName, ln[0], ln[1], strNodeName, iface[0]); ! this.createLink(strLinkName, ln[0], strNodeName, core.NetworkInterface.Serial); ! break; ! } ! } ! ! } ! ! } ! ! line = input.readLine(); ! if(line.contains("#config")){ ! line = input.readLine(); ! while(!line.contains("#endconfig")){ ! ((core.NetworkLayerDevice)Sim.getNode(strNodeName)).getConfig().add(line,core.DeviceConfig.STARTUP_CONFIG); ! line = input.readLine(); ! } ! } ! ! line = input.readLine(); ! if(line.contains("#data")){ ! line = input.readLine(); ! while(!line.contains("#enddata")){ ! line = input.readLine(); ! if(line == null) break; ! } ! } ! ! /// ! ! }//while ! ! for(int i =0; i<DevicesTurnedOn.size() ;i++){ ! String nodeName = (String) DevicesTurnedOn.get(i); ! Sim.getNode(nodeName).turnOn(); ! } ! ! this.refreshNodeInformationTab(); ! simSaveFile = simFile; ! ! ! }finally { ! try { ! if (input!= null) { ! //flush and close both "input" and its underlying FileReader ! input.close(); ! } ! } catch (IOException ex) { ! ex.printStackTrace(); ! } ! } ! ! } catch (FileNotFoundException e) { ! e.printStackTrace(); ! } catch (IOException e){ ! e.printStackTrace(); ! } catch (Exception e){ ! e.printStackTrace(); ! } ! } ! } ! ! ! public void Import(){ ! ! printLayerInfo(false); ! ! JFileChooser chooser = new JFileChooser(); ! ! chooser.setDialogTitle("Import simulation from previous versions ..."); ! ! chooser.setMultiSelectionEnabled(false); ! ! chooser.setAcceptAllFileFilterUsed(false); ! ! chooser.addChoosableFileFilter(new JFSTFilter()); int returnVal = chooser.showOpenDialog(this); *************** *** 2291,2297 **** File simFile; ! if(inFile.getPath().contains("."+SIM_PREFIX)) simFile = new File(inFile.getPath()); ! else simFile = new File(inFile.getPath()+"."+SIM_PREFIX); --- 2420,2426 ---- File simFile; ! if(inFile.getPath().contains("."+OLD_PREFIX)) simFile = new File(inFile.getPath()); ! else simFile = new File(inFile.getPath()+"."+OLD_PREFIX); *************** *** 2372,2376 **** deviceType = 1; ! Sim.addHub(strNodeName); GuiHub tempHub = new GuiHub(strNodeName,this); --- 2501,2505 ---- deviceType = 1; ! Sim.addHub(strNodeName, true); GuiHub tempHub = new GuiHub(strNodeName,this); *************** *** 2389,2393 **** deviceType = 1; ! Sim.addSwitch(strNodeName); GuiSwitch tempSwitch = new GuiSwitch(strNodeName,this); --- 2518,2522 ---- deviceType = 1; ! Sim.addSwitch(strNodeName, true); GuiSwitch tempSwitch = new GuiSwitch(strNodeName,this); *************** *** 2405,2409 **** deviceType = 1; ! Sim.addCSUDSU(strNodeName); GuiCSUDSU tempCSUDSU = new GuiCSUDSU(strNodeName,this); --- 2534,2538 ---- deviceType = 1; ! Sim.addCSUDSU(strNodeName, true); GuiCSUDSU tempCSUDSU = new GuiCSUDSU(strNodeName,this); *************** *** 2422,2426 **** deviceType = 2; ! Sim.addPC(strNodeName); GuiPC tempPC = new GuiPC(strNodeName,this); --- 2551,2555 ---- deviceType = 2; ! Sim.addPC(strNodeName, true); GuiPC tempPC = new GuiPC(strNodeName,this); *************** *** 2438,2442 **** deviceType = 2; ! Sim.addRouter(strNodeName); GuiRouter tempRouter = new GuiRouter(strNodeName,this); --- 2567,2571 ---- deviceType = 2; ! Sim.addRouter(strNodeName, true); GuiRouter tempRouter = new GuiRouter(strNodeName,this); *************** *** 2454,2458 **** deviceType = 2; ! Sim.addExternalNAT(strNodeName); GuiExternalProxy tempRouter = new GuiExternalProxy(strNodeName,this); --- 2583,2587 ---- deviceType = 2; ! Sim.addExternalNAT(strNodeName, true); GuiExternalProxy tempRouter = new GuiExternalProxy(strNodeName,this); *************** *** 2599,2603 **** //save the file for later use with the saveSim method ! simSaveFile = simFile; --- 2728,2732 ---- //save the file for later use with the saveSim method ! //simSaveFile = simFile; *************** *** 2627,2633 **** } - - - /** --- 2756,2759 ---- *************** *** 3089,3128 **** ! class GraphicFilter extends FileFilter{ ! ! ! ! /** ! ! * This method returns the Description that is in the File choosers Dialog ! ! */ ! public String getDescription(){ ! ! return "Simulation File (*."+GUI_PREFIX+")"; ! } - - - - /** - - * This method returns true or false if a file has the prefix - - */ - public boolean accept(File f) { ! ! if(f.isDirectory() || f.getName().endsWith(GUI_PREFIX)){ ! return true; - } return false; ! ! } --- 3215,3241 ---- ! class JFSTFilter extends FileFilter{ public String getDescription(){ ! return "Old Simulation File (*."+OLD_PREFIX+")"; } public boolean accept(File f) { ! if(f.isDirectory() || f.getName().endsWith(OLD_PREFIX)){ return true; } return false; + } + } + + class JNSTFilter extends FileFilter{ + public String getDescription(){ + return "Simulation File (*."+SIM_PREFIX+")"; + } ! public boolean accept(File f) { ! if(f.isDirectory() || f.getName().endsWith(SIM_PREFIX)){ ! return true; ! } ! return false; } Index: MenuBar.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/guiUI/MenuBar.java,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** MenuBar.java 15 Oct 2007 18:25:54 -0000 1.16 --- MenuBar.java 19 Oct 2007 08:52:27 -0000 1.17 *************** *** 25,30 **** --- 25,35 ---- private JMenuItem mnuOpen = new JMenuItem("Open ..."); //Open a old simulation + private JMenuItem mnuSave = new JMenuItem("Save ..."); //Save a simulation private JMenuItem mnuSaveAs = new JMenuItem("Save As..."); //Save a simulation + //HTML report generator menu + + private JMenuItem mnuImport = new JMenuItem("Import ..."); //Open a old simulation + private JMenuItem mnuGenRep = new JMenuItem("Export to HTML ..."); private JMenuItem mnuExit = new JMenuItem("Exit"); //Exit appliction //private JMenuItem mnuClose = new JMenuItem("Close"); //Close *************** *** 48,54 **** private JCheckBoxMenuItem mnuMsgApplication = new JCheckBoxMenuItem("Application Layer",true); ! //HTML report generator menu ! private JMenuItem mnuGenRep = new JMenuItem("Generate HTML report..."); ! //Add submenu private JMenu mnuAdd = new JMenu("Add"); //For Adding objects to simulation private JMenuItem mnuPC = new JMenuItem("PC ..."); --- 53,57 ---- private JCheckBoxMenuItem mnuMsgApplication = new JCheckBoxMenuItem("Application Layer",true); ! //Add submenu private JMenu mnuAdd = new JMenu("Add"); //For Adding objects to simulation private JMenuItem mnuPC = new JMenuItem("PC ..."); *************** *** 59,73 **** private JMenuItem mnuExternalNAT = new JMenuItem("Socks Proxy..."); - //Tools submenu - private JMenu mnuTools = new JMenu("Tools"); - private JMenuItem mnuSetTCPIPProperties = new JMenuItem("Set TCP/IP Properties ..."); - - /* - private JMenu mnuScenario = new JMenu("Scenario's"); - private JMenuItem mnuTest1 = new JMenuItem("Test 1"); - private JMenuItem mnuTest2 = new JMenuItem("Test 2"); - private JMenuItem mnuTest3 = new JMenuItem("Test 3"); - private JMenuItem mnuTest4 = new JMenuItem("Test 4"); - */ //help menu private JMenu mnuHelp = new JMenu("Help"); --- 62,65 ---- *************** *** 119,128 **** mnuFile.add(mnuNew); mnuFile.add(mnuOpen); mnuFile.add(mnuSave); mnuFile.add(mnuSaveAs); mnuFile.add(mnuExit); //Add items to simulation menu ! mnuSimulation.add(mnuGenRep); mnuSimulation.add(mnuAdd); mnuAdd.add(mnuPC); --- 111,125 ---- mnuFile.add(mnuNew); mnuFile.add(mnuOpen); + mnuFile.add(mnuSave); mnuFile.add(mnuSaveAs); + mnuFile.addSeparator(); + mnuFile.add(mnuImport); + mnuFile.add(mnuGenRep); + mnuFile.addSeparator(); mnuFile.add(mnuExit); //Add items to simulation menu ! mnuSimulation.add(mnuAdd); mnuAdd.add(mnuPC); *************** *** 133,138 **** mnuAdd.add(mnuExternalNAT); - mnuSimulation.add(mnuTools); - mnuTools.add(mnuSetTCPIPProperties); //mnuSimulation.add(mnuScenario); --- 130,133 ---- *************** *** 178,191 **** //mnuSwitch.setMnemonic('S'); - mnuTools.setMnemonic('T'); - mnuSetTCPIPProperties.setMnemonic('I'); - - /*mnuScenario.setMnemonic('S'); - mnuTest1.setMnemonic('1'); - mnuTest2.setMnemonic('2'); - mnuTest3.setMnemonic('3'); - mnuTest4.setMnemonic('4'); - */ - mnuEnvironment.setMnemonic('E'); mnuClearConsole.setMnemonic('C'); --- 173,176 ---- *************** *** 337,340 **** --- 322,332 ---- } }); + + //Add action listener to Save menu item + mnuImport.addActionListener(new ActionListener(){ + public void actionPerformed(ActionEvent e){ + controller.Import(); + } + }); //Add action listener to New menu item *************** *** 346,355 **** }); - mnuSetTCPIPProperties.addActionListener(new ActionListener(){ - public void actionPerformed(ActionEvent e){ - controller.setTCPIPProperties(null); - } - }); - mnuAbout.addActionListener(new ActionListener() { --- 338,341 ---- |