[Javanetsim-cvs] javaNetSim/guiUI GuiMultilayerSwitch.java, 1.1, 1.2 GuiNode.java, 1.9, 1.10
Status: Beta
Brought to you by:
darkkey
From: QweR <qw...@us...> - 2008-10-22 22:17:07
|
Update of /cvsroot/javanetsim/javaNetSim/guiUI In directory fdv4jf1.ch3.sourceforge.com:/tmp/cvs-serv10964/guiUI Modified Files: GuiMultilayerSwitch.java GuiNode.java Log Message: cosmetic changes Index: GuiNode.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/guiUI/GuiNode.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** GuiNode.java 13 Oct 2008 19:49:15 -0000 1.9 --- GuiNode.java 22 Oct 2008 21:33:00 -0000 1.10 *************** *** 129,133 **** private JMenuItem mnuTurn = new JMenuItem("Turn Off"); ! private JMenu mnuBreakLink = new JMenu("Disconnect link:"); private JMenuItem mnuLink = new JMenuItem("Links properties"); --- 129,133 ---- private JMenuItem mnuTurn = new JMenuItem("Turn Off"); ! private JMenu mnuBreakLink = new JMenu("Disconnect link"); private JMenuItem mnuLink = new JMenuItem("Links properties"); *************** *** 298,301 **** --- 298,306 ---- } }); + mnuBreakLink.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + updateConnectedLinkMenu(); + } + }); } *************** *** 312,316 **** for (int i = 0; i < ints.length; i++) { int int_type = Simulation.Sim.getNode(this.strNodeName).getIntType((String)ints[i]); ! if(int_type != core.NetworkInterface.Console && int_type != core.NetworkInterface.Wireless){ JMenuItem mnuI = new JMenuItem((String) ints[i]); --- 317,321 ---- for (int i = 0; i < ints.length; i++) { int int_type = Simulation.Sim.getNode(this.strNodeName).getIntType((String)ints[i]); ! if(int_type != core.NetworkInterface.Console && int_type != core.NetworkInterface.Wireless){ JMenuItem mnuI = new JMenuItem((String) ints[i]); *************** *** 350,353 **** --- 355,388 ---- } + public void updateConnectedLinkMenu(){ + try { + mnuBreakLink.removeAll(); + Object ints[] = controller.getInterfaces(lblNodeName.getText()); + for (int i = 0; i < ints.length; i++) { + int int_type = Simulation.Sim.getNode(this.strNodeName).getIntType((String)ints[i]); + boolean lineIsConnected = (Simulation.Sim.getNode(this.strNodeName).getNetworkInterface((String)ints[i]).getConnectedLink()!=null); + + if(int_type != core.NetworkInterface.Wireless && lineIsConnected){ + + JMenuItem mnuDI = new JMenuItem((String) ints[i]); + mnuDI.addActionListener(new ActionListener() { + + public void actionPerformed(ActionEvent e) { + + controller.breakLink(lblNodeName.getText(), + ((JMenuItem) e.getSource()).getText()); + + } + + }); + mnuBreakLink.add(mnuDI); + } + } + + } catch (Exception e) { + e.printStackTrace(); + } + } + public abstract void addInterfaces(MainScreen parent, Node node); *************** *** 656,659 **** --- 691,695 ---- .setEnabled(ena); } + updateConnectedLinkMenu(); GuiNodePopMenu.show(e.getComponent(), e.getX(), e.getY()); } Index: GuiMultilayerSwitch.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/guiUI/GuiMultilayerSwitch.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** GuiMultilayerSwitch.java 17 Oct 2008 18:59:14 -0000 1.1 --- GuiMultilayerSwitch.java 22 Oct 2008 21:33:00 -0000 1.2 *************** *** 55,58 **** --- 55,63 ---- package guiUI; + import java.awt.event.ActionEvent; + import java.awt.event.ActionListener; + + import javax.swing.JMenuItem; + import core.Node; *************** *** 87,93 **** --- 92,106 ---- */ + private JMenuItem mnuReset = new JMenuItem("Reset"); + public GuiMultilayerSwitch(String inName, MainScreen inMainScreen) { super(inName, inMainScreen,"images/simulation/mlswitch.png"); + mnuReset.addActionListener(new ActionListener(){ + public void actionPerformed(ActionEvent e){ + controller.Reset(lblNodeName.getText()); + } + }); + GuiNodePopMenu.add(mnuReset); } |