[Javanetsim-cvs] javaNetSim/guiUI DataLinkLayerDevice.java, 1.2, 1.3 EditRoutesDialog.java, 1.1, 1.
Status: Beta
Brought to you by:
darkkey
Update of /cvsroot/javanetsim/javaNetSim/guiUI In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv28933/guiUI Modified Files: DataLinkLayerDevice.java EditRoutesDialog.java GuiHub.java GuiPC.java GuiRouter.java GuiSwitch.java LinkDialog.java LinkLayerPanel.java MANIFEST MenuBar.java NodePropertiesDialog.java PingDialog.java README.txt SandBox.java SetTCPIPPropertiesDialog.java StandardToolBar.java ToolBar.java breakLinkDialog.java Log Message: Fix dev tree; fixed Java 1.66 bug in Set TCP/IP Properties dialog. Index: LinkLayerPanel.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/guiUI/LinkLayerPanel.java,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** LinkLayerPanel.java 8 Nov 2005 04:04:22 -0000 1.1.1.1 --- LinkLayerPanel.java 13 Sep 2007 13:38:52 -0000 1.2 *************** *** 1,129 **** ! /* ! Java Firewall Simulator (jFirewallSim) ! ! Copyright (c) 2004, jFirewallSim development team All rights reserved. ! ! Redistribution and use in source and binary forms, with or without modification, are ! permitted provided that the following conditions are met: ! ! - Redistributions of source code must retain the above copyright notice, this list ! of conditions and the following disclaimer. ! - Redistributions in binary form must reproduce the above copyright notice, this list ! of conditions and the following disclaimer in the documentation and/or other ! materials provided with the distribution. ! - Neither the name of the Canberra Institute of Technology nor the names of its ! contributors may be used to endorse or promote products derived from this software ! without specific prior written permission. ! ! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY ! EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ! OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ! THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, ! EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF ! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ! HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR ! TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, ! EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ! */ ! package guiUI; ! ! import java.awt.BasicStroke; ! import java.awt.Graphics; ! import java.awt.Graphics2D; ! import java.awt.geom.*; ! import java.awt.Color; ! import java.awt.Point; ! import java.util.Hashtable; ! import java.util.Enumeration; ! ! import javax.swing.JPanel; ! ! /** ! * This object is an extension of the Java Swing JPanel. ! * It has been extended so that we can overide the paint method ! * and use it to draw the various links. It will be inserted into the ! * bottom layer of a layered pane so that it always sits behind the ! * various Nodes being displayed on teh screen. ! * ! * @author bevan_calliess ! * ! */ ! ! public class LinkLayerPanel extends JPanel { ! ! final static String FAKELINE = new String("FakeLine"); ! final static BasicStroke stroke = new BasicStroke(3.0f); ! final static Color linkCol = Color.BLUE; ! private Hashtable LineTable = new Hashtable(); ! ! ! /** ! * This method will take the name of the Link and the starting ! * and ending points that it is drawn between. ! * A 2DLine object is created using these co-ordinates and then ! * it is added to a hashTable using the name as a key ! * so that it can be located and moved and/or removed as required. ! * @param inName Used as the key for the hashTable ! * @param inStart Used for the first set of co-ordinates p1x and p1y ! * @param inEnd Used for the second set of co-ordinates p2x and p2y ! */ ! public void addLine(String inName,Point inStart, Point inEnd){ ! Line2D.Double Line = new Line2D.Double(inStart.x,inStart.y,inEnd.x,inEnd.y); ! LineTable.put(inName,Line); ! repaint(); ! } ! /** ! * This method will remove a line from the hashtable so that ! * it will no longer be drawn. ! * @param inName ! */ ! public void removeLine(String inName){ ! LineTable.remove(inName); ! repaint(); ! } ! ! /** ! * This method is Used to move the co-ordinates of a particular ! * line in the hashTable. ! * ! * @param inName Key to the HashTable.(linkName) ! * @param inWhichEnd Which set of co_ordinates to move p1 or p2 ! * @param inPosition The position to move those cordinates to. ! */ ! public void moveLine(String inName,int inWhichEnd,Point inPosition){ ! if(LineTable.containsKey(inName)) ! { ! Line2D.Double myLine = (Line2D.Double)LineTable.get(inName); ! if(inWhichEnd == 1){ ! Point2D p1 = (Point2D)inPosition; ! Point2D p2 = myLine.getP2(); ! myLine.setLine(p1,p2); ! }else{ ! Point2D p1 = myLine.getP1(); ! Point2D p2 = (Point2D)inPosition; ! myLine.setLine(p1,p2); ! } ! repaint(); ! } ! ! } ! ! /** ! * Overides the standard paint method so that it ! * draws the various lines on the screen. ! */ ! public void paint(Graphics g) ! { ! super.paint(g); ! Graphics2D g2D = (Graphics2D)g; ! g2D.setStroke(stroke); ! g2D.setPaint(linkCol); ! ! Enumeration it = LineTable.elements(); ! ! while(it.hasMoreElements()){ ! Line2D.Double myLine = (Line2D.Double)it.nextElement(); ! g2D.draw(myLine); ! } ! } ! } --- 1,129 ---- ! /* ! Java Firewall Simulator (jFirewallSim) ! ! Copyright (c) 2004, jFirewallSim development team All rights reserved. ! ! Redistribution and use in source and binary forms, with or without modification, are ! permitted provided that the following conditions are met: ! ! - Redistributions of source code must retain the above copyright notice, this list ! of conditions and the following disclaimer. ! - Redistributions in binary form must reproduce the above copyright notice, this list ! of conditions and the following disclaimer in the documentation and/or other ! materials provided with the distribution. ! - Neither the name of the Canberra Institute of Technology nor the names of its ! contributors may be used to endorse or promote products derived from this software ! without specific prior written permission. ! ! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY ! EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ! OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ! THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, ! EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF ! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ! HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR ! TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, ! EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ! */ ! package guiUI; ! ! import java.awt.BasicStroke; ! import java.awt.Graphics; ! import java.awt.Graphics2D; ! import java.awt.geom.*; ! import java.awt.Color; ! import java.awt.Point; ! import java.util.Hashtable; ! import java.util.Enumeration; ! ! import javax.swing.JPanel; ! ! /** ! * This object is an extension of the Java Swing JPanel. ! * It has been extended so that we can overide the paint method ! * and use it to draw the various links. It will be inserted into the ! * bottom layer of a layered pane so that it always sits behind the ! * various Nodes being displayed on teh screen. ! * ! * @author bevan_calliess ! * ! */ ! ! public class LinkLayerPanel extends JPanel { ! ! final static String FAKELINE = new String("FakeLine"); ! final static BasicStroke stroke = new BasicStroke(3.0f); ! final static Color linkCol = Color.BLUE; ! private Hashtable LineTable = new Hashtable(); ! ! ! /** ! * This method will take the name of the Link and the starting ! * and ending points that it is drawn between. ! * A 2DLine object is created using these co-ordinates and then ! * it is added to a hashTable using the name as a key ! * so that it can be located and moved and/or removed as required. ! * @param inName Used as the key for the hashTable ! * @param inStart Used for the first set of co-ordinates p1x and p1y ! * @param inEnd Used for the second set of co-ordinates p2x and p2y ! */ ! public void addLine(String inName,Point inStart, Point inEnd){ ! Line2D.Double Line = new Line2D.Double(inStart.x,inStart.y,inEnd.x,inEnd.y); ! LineTable.put(inName,Line); ! repaint(); ! } ! /** ! * This method will remove a line from the hashtable so that ! * it will no longer be drawn. ! * @param inName ! */ ! public void removeLine(String inName){ ! LineTable.remove(inName); ! repaint(); ! } ! ! /** ! * This method is Used to move the co-ordinates of a particular ! * line in the hashTable. ! * ! * @param inName Key to the HashTable.(linkName) ! * @param inWhichEnd Which set of co_ordinates to move p1 or p2 ! * @param inPosition The position to move those cordinates to. ! */ ! public void moveLine(String inName,int inWhichEnd,Point inPosition){ ! if(LineTable.containsKey(inName)) ! { ! Line2D.Double myLine = (Line2D.Double)LineTable.get(inName); ! if(inWhichEnd == 1){ ! Point2D p1 = (Point2D)inPosition; ! Point2D p2 = myLine.getP2(); ! myLine.setLine(p1,p2); ! }else{ ! Point2D p1 = myLine.getP1(); ! Point2D p2 = (Point2D)inPosition; ! myLine.setLine(p1,p2); ! } ! repaint(); ! } ! ! } ! ! /** ! * Overides the standard paint method so that it ! * draws the various lines on the screen. ! */ ! public void paint(Graphics g) ! { ! super.paint(g); ! Graphics2D g2D = (Graphics2D)g; ! g2D.setStroke(stroke); ! g2D.setPaint(linkCol); ! ! Enumeration it = LineTable.elements(); ! ! while(it.hasMoreElements()){ ! Line2D.Double myLine = (Line2D.Double)it.nextElement(); ! g2D.draw(myLine); ! } ! } ! } Index: GuiPC.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/guiUI/GuiPC.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** GuiPC.java 19 Nov 2005 13:07:37 -0000 1.2 --- GuiPC.java 13 Sep 2007 13:38:52 -0000 1.3 *************** *** 1,48 **** ! /* ! Java Firewall Simulator (jFirewallSim) ! ! Copyright (c) 2004, jFirewallSim development team All rights reserved. ! ! Redistribution and use in source and binary forms, with or without modification, are ! permitted provided that the following conditions are met: ! ! - Redistributions of source code must retain the above copyright notice, this list ! of conditions and the following disclaimer. ! - Redistributions in binary form must reproduce the above copyright notice, this list ! of conditions and the following disclaimer in the documentation and/or other ! materials provided with the distribution. ! - Neither the name of the Canberra Institute of Technology nor the names of its ! contributors may be used to endorse or promote products derived from this software ! without specific prior written permission. ! ! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY ! EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ! OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ! THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, ! EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF ! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ! HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR ! TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, ! EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ! */ ! package guiUI; ! ! /** ! * <P>The GuiPC class is used to instantiate new PC on the GUI</P> ! * ! * @author VC2 Team. ! * @since 15th November 2004 ! * @version v0.20 ! */ ! ! public class GuiPC extends ApplicationLayerDevice { ! ! /** ! * @param inName The name of the PC ! * @param inMainscreen The JFrame that the router will be created on ! */ ! ! public GuiPC(String inName, MainScreen inMainScreen){ ! super(inName, inMainScreen, "images/simulation/PC_large.gif"); ! } ! } --- 1,48 ---- ! /* ! Java Firewall Simulator (jFirewallSim) ! ! Copyright (c) 2004, jFirewallSim development team All rights reserved. ! ! Redistribution and use in source and binary forms, with or without modification, are ! permitted provided that the following conditions are met: ! ! - Redistributions of source code must retain the above copyright notice, this list ! of conditions and the following disclaimer. ! - Redistributions in binary form must reproduce the above copyright notice, this list ! of conditions and the following disclaimer in the documentation and/or other ! materials provided with the distribution. ! - Neither the name of the Canberra Institute of Technology nor the names of its ! contributors may be used to endorse or promote products derived from this software ! without specific prior written permission. ! ! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY ! EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ! OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ! THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, ! EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF ! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ! HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR ! TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, ! EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ! */ ! package guiUI; ! ! /** ! * <P>The GuiPC class is used to instantiate new PC on the GUI</P> ! * ! * @author VC2 Team. ! * @since 15th November 2004 ! * @version v0.20 ! */ ! ! public class GuiPC extends ApplicationLayerDevice { ! ! /** ! * @param inName The name of the PC ! * @param inMainscreen The JFrame that the router will be created on ! */ ! ! public GuiPC(String inName, MainScreen inMainScreen){ ! super(inName, inMainScreen, "images/simulation/PC_large.gif"); ! } ! } Index: EditRoutesDialog.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/guiUI/EditRoutesDialog.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** EditRoutesDialog.java 8 Nov 2005 21:04:54 -0000 1.1 --- EditRoutesDialog.java 13 Sep 2007 13:38:52 -0000 1.2 *************** *** 1,565 **** ! /* ! Java Firewall Simulator (jFirewallSim) ! ! Copyright (c) 2004, jFirewallSim development team All rights reserved. ! ! Redistribution and use in source and binary forms, with or without modification, are ! permitted provided that the following conditions are met: ! ! - Redistributions of source code must retain the above copyright notice, this list ! of conditions and the following disclaimer. [...1101 lines suppressed...] ! * This method will check for a possible default subnet address as the user ! * is typing in an ip address. Once one is found it will add it to the txtSubnetMak ! * text field. ! * @author luke_hamilton ! * ! */ ! private void checkForDefaultSubnet(){ ! String tempip = txtIpAddress.getText(); ! ! if(Simulation.validateDecIP(tempip)){ ! String tempSubnet = Simulation.getDefaultSubnetMask(tempip); ! txtSubnetMask.setText(tempSubnet); ! txtSubnetMask.setEnabled(true); ! btnOk.setEnabled(true); ! }else{ ! txtSubnetMask.setText("Enter Subnet Mask"); ! txtSubnetMask.setEnabled(false); ! } ! } ! } Index: NodePropertiesDialog.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/guiUI/NodePropertiesDialog.java,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** NodePropertiesDialog.java 8 Nov 2005 04:04:35 -0000 1.1.1.1 --- NodePropertiesDialog.java 13 Sep 2007 13:38:52 -0000 1.2 *************** *** 1,128 **** ! /* ! Java Firewall Simulator (jFirewallSim) ! ! Copyright (c) 2004, jFirewallSim development team All rights reserved. ! ! Redistribution and use in source and binary forms, with or without modification, are ! permitted provided that the following conditions are met: ! ! - Redistributions of source code must retain the above copyright notice, this list ! of conditions and the following disclaimer. ! - Redistributions in binary form must reproduce the above copyright notice, this list ! of conditions and the following disclaimer in the documentation and/or other ! materials provided with the distribution. ! - Neither the name of the Canberra Institute of Technology nor the names of its ! contributors may be used to endorse or promote products derived from this software ! without specific prior written permission. ! ! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY ! EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ! OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ! THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, ! EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF ! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ! HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR ! TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, ! EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ! */ ! package guiUI; ! ! import javax.swing.JButton; ! import javax.swing.JDialog; ! import javax.swing.JPanel; ! import javax.swing.*; ! import java.awt.event.*; ! import java.awt.*; ! import java.util.*; ! import javax.swing.table.*; ! ! /** ! * This class is used to display general information about a ! * GUINode. It will display the IP Address information including ! * default gateway and any Interface specific information such as ! * the Current IP address and subnetmask. ! * @author Michael ! */ ! public class NodePropertiesDialog extends JDialog implements ActionListener ! { ! ! private JLabel lblNodeNameLabel = new JLabel("Node Name : "); ! private JLabel lblNodeName = new JLabel(); ! private JLabel lblGatewayLabel = new JLabel("Default Gateway : "); ! private JLabel lblGatewayAddress = new JLabel(); ! private JButton btnOK = new JButton("OK"); ! ! JPanel pnlNodeNameDetails = new JPanel(); ! JPanel pnlGatewayDetails = new JPanel(); ! ! JPanel pnlOKButton = new JPanel(); ! ! public NodePropertiesDialog(JFrame frame, Vector inVectorMasterList){ ! super(frame); ! ArrayList aryColumnNames = new ArrayList(); ! aryColumnNames.add("Name"); ! aryColumnNames.add("Gateway"); ! aryColumnNames.add("Interface Name"); ! aryColumnNames.add("MAC Address"); ! aryColumnNames.add("IP Address"); ! aryColumnNames.add("Subnet Mask"); ! aryColumnNames.add("Link Name"); ! ! Vector col = new Vector(aryColumnNames); ! JTable tblInfo = new JTable(inVectorMasterList, col); ! TableModel model = tblInfo.getModel(); ! ! // Remove the first 2 column names ! lblNodeName.setText(tblInfo.getModel().getValueAt(0, 0).toString()); ! tblInfo.getColumnModel().removeColumn(tblInfo.getColumnModel().getColumn(0)); ! lblGatewayAddress.setText(tblInfo.getModel().getValueAt(0, 1).toString()); ! tblInfo.getColumnModel().removeColumn(tblInfo.getColumnModel().getColumn(0)); ! ! //Makes uneditable ! tblInfo.setEnabled(false); ! tblInfo.getTableHeader().setReorderingAllowed(false); ! JScrollPane scrPane = new JScrollPane(tblInfo); ! ! ! //ArrayList temp = (ArrayList)inArrayMasterList.get(0); ! //lblNodeName.setText((String)temp.get(0)); ! //lblGatewayAddress.setText((String)temp.get(1)); ! ! JPanel pnlPropertiesScreen = (JPanel)this.getContentPane(); ! pnlPropertiesScreen.setLayout(new BoxLayout(pnlPropertiesScreen, BoxLayout.Y_AXIS)); ! pnlNodeNameDetails.setLayout(new FlowLayout()); ! pnlOKButton.setLayout(new FlowLayout()); ! ! pnlNodeNameDetails.setPreferredSize(new Dimension(50,50)); ! pnlNodeNameDetails.add(lblNodeNameLabel); ! pnlNodeNameDetails.add(lblNodeName); ! pnlGatewayDetails.add(lblGatewayLabel); ! pnlGatewayDetails.add(lblGatewayAddress); ! pnlPropertiesScreen.add(pnlNodeNameDetails); ! pnlPropertiesScreen.add(pnlGatewayDetails); ! pnlPropertiesScreen.add(scrPane); ! pnlOKButton.add(btnOK); ! pnlPropertiesScreen.add(pnlOKButton); ! ! this.setSize(700,200); ! this.setLocationRelativeTo(null); ! this.setModal(true); ! this.setResizable(false); ! btnOK.setToolTipText("Close the screen"); ! ! //Set default button to be btnOK ! this.getRootPane().setDefaultButton(btnOK); ! btnOK.addActionListener(this); ! } ! ! ! public void actionPerformed(ActionEvent e) ! { ! if(e.getSource() == btnOK) ! { ! ! this.dispose(); ! } ! } ! ! } --- 1,128 ---- ! /* ! Java Firewall Simulator (jFirewallSim) ! ! Copyright (c) 2004, jFirewallSim development team All rights reserved. ! ! Redistribution and use in source and binary forms, with or without modification, are ! permitted provided that the following conditions are met: ! ! - Redistributions of source code must retain the above copyright notice, this list ! of conditions and the following disclaimer. ! - Redistributions in binary form must reproduce the above copyright notice, this list ! of conditions and the following disclaimer in the documentation and/or other ! materials provided with the distribution. ! - Neither the name of the Canberra Institute of Technology nor the names of its ! contributors may be used to endorse or promote products derived from this software ! without specific prior written permission. ! ! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY ! EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ! OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ! THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, ! EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF ! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ! HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR ! TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, ! EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ! */ ! package guiUI; ! ! import javax.swing.JButton; ! import javax.swing.JDialog; ! import javax.swing.JPanel; ! import javax.swing.*; ! import java.awt.event.*; ! import java.awt.*; ! import java.util.*; ! import javax.swing.table.*; ! ! /** ! * This class is used to display general information about a ! * GUINode. It will display the IP Address information including ! * default gateway and any Interface specific information such as ! * the Current IP address and subnetmask. ! * @author Michael ! */ ! public class NodePropertiesDialog extends JDialog implements ActionListener ! { ! ! private JLabel lblNodeNameLabel = new JLabel("Node Name : "); ! private JLabel lblNodeName = new JLabel(); ! private JLabel lblGatewayLabel = new JLabel("Default Gateway : "); ! private JLabel lblGatewayAddress = new JLabel(); ! private JButton btnOK = new JButton("OK"); ! ! JPanel pnlNodeNameDetails = new JPanel(); ! JPanel pnlGatewayDetails = new JPanel(); ! ! JPanel pnlOKButton = new JPanel(); ! ! public NodePropertiesDialog(JFrame frame, Vector inVectorMasterList){ ! super(frame); ! ArrayList aryColumnNames = new ArrayList(); ! aryColumnNames.add("Name"); ! aryColumnNames.add("Gateway"); ! aryColumnNames.add("Interface Name"); ! aryColumnNames.add("MAC Address"); ! aryColumnNames.add("IP Address"); ! aryColumnNames.add("Subnet Mask"); ! aryColumnNames.add("Link Name"); ! ! Vector col = new Vector(aryColumnNames); ! JTable tblInfo = new JTable(inVectorMasterList, col); ! TableModel model = tblInfo.getModel(); ! ! // Remove the first 2 column names ! lblNodeName.setText(tblInfo.getModel().getValueAt(0, 0).toString()); ! tblInfo.getColumnModel().removeColumn(tblInfo.getColumnModel().getColumn(0)); ! lblGatewayAddress.setText(tblInfo.getModel().getValueAt(0, 1).toString()); ! tblInfo.getColumnModel().removeColumn(tblInfo.getColumnModel().getColumn(0)); ! ! //Makes uneditable ! tblInfo.setEnabled(false); ! tblInfo.getTableHeader().setReorderingAllowed(false); ! JScrollPane scrPane = new JScrollPane(tblInfo); ! ! ! //ArrayList temp = (ArrayList)inArrayMasterList.get(0); ! //lblNodeName.setText((String)temp.get(0)); ! //lblGatewayAddress.setText((String)temp.get(1)); ! ! JPanel pnlPropertiesScreen = (JPanel)this.getContentPane(); ! pnlPropertiesScreen.setLayout(new BoxLayout(pnlPropertiesScreen, BoxLayout.Y_AXIS)); ! pnlNodeNameDetails.setLayout(new FlowLayout()); ! pnlOKButton.setLayout(new FlowLayout()); ! ! pnlNodeNameDetails.setPreferredSize(new Dimension(50,50)); ! pnlNodeNameDetails.add(lblNodeNameLabel); ! pnlNodeNameDetails.add(lblNodeName); ! pnlGatewayDetails.add(lblGatewayLabel); ! pnlGatewayDetails.add(lblGatewayAddress); ! pnlPropertiesScreen.add(pnlNodeNameDetails); ! pnlPropertiesScreen.add(pnlGatewayDetails); ! pnlPropertiesScreen.add(scrPane); ! pnlOKButton.add(btnOK); ! pnlPropertiesScreen.add(pnlOKButton); ! ! this.setSize(700,200); ! this.setLocationRelativeTo(null); ! this.setModal(true); ! this.setResizable(false); ! btnOK.setToolTipText("Close the screen"); ! ! //Set default button to be btnOK ! this.getRootPane().setDefaultButton(btnOK); ! btnOK.addActionListener(this); ! } ! ! ! public void actionPerformed(ActionEvent e) ! { ! if(e.getSource() == btnOK) ! { ! ! this.dispose(); ! } ! } ! ! } Index: GuiSwitch.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/guiUI/GuiSwitch.java,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** GuiSwitch.java 8 Nov 2005 04:04:28 -0000 1.1.1.1 --- GuiSwitch.java 13 Sep 2007 13:38:52 -0000 1.2 *************** *** 1,47 **** ! /* ! Java Firewall Simulator (jFirewallSim) ! ! Copyright (c) 2004, jFirewallSim development team All rights reserved. ! ! Redistribution and use in source and binary forms, with or without modification, are ! permitted provided that the following conditions are met: ! ! - Redistributions of source code must retain the above copyright notice, this list ! of conditions and the following disclaimer. ! - Redistributions in binary form must reproduce the above copyright notice, this list ! of conditions and the following disclaimer in the documentation and/or other ! materials provided with the distribution. ! - Neither the name of the Canberra Institute of Technology nor the names of its ! contributors may be used to endorse or promote products derived from this software ! without specific prior written permission. ! ! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY ! EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ! OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ! THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, ! EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF ! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ! HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR ! TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, ! EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ! */ ! package guiUI; ! ! /** ! * <P>The GuiSwitch class is used to instantiate new Switches on the GUI</P> ! * ! * @author luke_hamilton ! * @since 15th November 2004 ! * @version v0.20 ! */ ! ! public class GuiSwitch extends DataLinkLayerDevice { ! ! /** ! * @param inName The name of the switch ! * @param inMainscreen The JFrame that the Switch will be created on ! */ ! public GuiSwitch(String inName, MainScreen inMainScreen) { ! super(inName, inMainScreen,"images/simulation/switch_large.gif"); ! } ! } --- 1,47 ---- ! /* ! Java Firewall Simulator (jFirewallSim) ! ! Copyright (c) 2004, jFirewallSim development team All rights reserved. ! ! Redistribution and use in source and binary forms, with or without modification, are ! permitted provided that the following conditions are met: ! ! - Redistributions of source code must retain the above copyright notice, this list ! of conditions and the following disclaimer. ! - Redistributions in binary form must reproduce the above copyright notice, this list ! of conditions and the following disclaimer in the documentation and/or other ! materials provided with the distribution. ! - Neither the name of the Canberra Institute of Technology nor the names of its ! contributors may be used to endorse or promote products derived from this software ! without specific prior written permission. ! ! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY ! EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ! OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ! THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, ! EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF ! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ! HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR ! TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, ! EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ! */ ! package guiUI; ! ! /** ! * <P>The GuiSwitch class is used to instantiate new Switches on the GUI</P> ! * ! * @author luke_hamilton ! * @since 15th November 2004 ! * @version v0.20 ! */ ! ! public class GuiSwitch extends DataLinkLayerDevice { ! ! /** ! * @param inName The name of the switch ! * @param inMainscreen The JFrame that the Switch will be created on ! */ ! public GuiSwitch(String inName, MainScreen inMainScreen) { ! super(inName, inMainScreen,"images/simulation/switch_large.gif"); ! } ! } Index: SetTCPIPPropertiesDialog.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/guiUI/SetTCPIPPropertiesDialog.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** SetTCPIPPropertiesDialog.java 10 Nov 2006 19:40:15 -0000 1.6 --- SetTCPIPPropertiesDialog.java 13 Sep 2007 13:38:53 -0000 1.7 *************** *** 131,135 **** btnCancel.setText("Cancel"); this.getRootPane().setDefaultButton(btnOk); ! this.setDefaultCloseOperation(JDialog.EXIT_ON_CLOSE); this.setLocationRelativeTo(null); this.setModal(true); --- 131,135 ---- btnCancel.setText("Cancel"); this.getRootPane().setDefaultButton(btnOk); ! this.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); this.setLocationRelativeTo(null); this.setModal(true); Index: breakLinkDialog.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/guiUI/breakLinkDialog.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** breakLinkDialog.java 19 Nov 2005 16:16:32 -0000 1.2 --- breakLinkDialog.java 13 Sep 2007 13:38:53 -0000 1.3 *************** *** 1,310 **** ! /* ! Java Firewall Simulator (jFirewallSim) ! ! Copyright (c) 2004, jFirewallSim development team All rights reserved. ! ! Redistribution and use in source and binary forms, with or without modification, are ! permitted provided that the following conditions are met: ! ! - Redistributions of source code must retain the above copyright notice, this list ! of conditions and the following disclaimer. ! - Redistributions in binary form must reproduce the above copyright notice, this list ! of conditions and the following disclaimer in the documentation and/or other ! materials provided with the distribution. ! - Neither the name of the Canberra Institute of Technology nor the names of its ! contributors may be used to endorse or promote products derived from this software ! without specific prior written permission. ! ! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY ! EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ! OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ! THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, ! EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF ! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ! HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR ! TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, ! EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ! */ ! ! ! package guiUI; ! ! import javax.swing.JFrame; ! import javax.swing.JPanel; ! import java.awt.GridBagLayout; ! import javax.swing.JDialog; ! import javax.swing.JLabel; ! import javax.swing.JTextField; ! import java.awt.Insets; ! import java.awt.GridBagConstraints; ! import java.awt.BorderLayout; ! import javax.swing.JButton; ! import java.awt.Dimension; ! import java.awt.event.ActionListener; ! import java.awt.event.ActionEvent; ! import javax.swing.JComboBox; ! import core.Simulation; ! import java.awt.event.MouseAdapter; ! import java.awt.event.MouseEvent; ! import java.awt.Color; ! import java.awt.event.KeyAdapter; ! import java.awt.event.KeyEvent; ! import java.awt.event.FocusAdapter; ! import java.awt.event.FocusEvent; ! import java.util.Arrays; ! import java.awt.Component; ! import javax.swing.SwingConstants; ! ! /** ! * ! * @author Key ! * ! * This class is a dialog that enables to remove links from the devices ! * ! */ ! public class breakLinkDialog extends javax.swing.JDialog { ! private JPanel backpanel; ! private JLabel lblInterface; ! private JLabel lblNodeName; ! private JComboBox cmbNodeName; ! private JComboBox cmbInterface; ! private JLabel lblError; ! private JButton btnOk; ! ! private MainScreen controller; ! private Simulation Sim; ! private SandBox SBox; ! ! private String NodeName; ! private String Interface; ! ! private boolean ErrorFlag = true; ! ! public breakLinkDialog(JFrame frame, Object nodeArray[], int selectedIndex, Simulation Sim, SandBox SBox) { ! super(frame); ! setResizable(false); ! controller = (MainScreen)frame; ! this.Sim = Sim; ! this.SBox = SBox; ! setTitle("Break link"); ! initGUI(nodeArray,selectedIndex); ! ! final JPanel panel = new JPanel(); ! getContentPane().add(panel, BorderLayout.SOUTH); ! ! btnOk = new JButton(); ! btnOk.setEnabled(true); ! btnOk.setToolTipText("Disconnect selected link!"); ! btnOk.addActionListener(new ActionListener() { ! public void actionPerformed(ActionEvent e) { ! okButton(); ! } ! }); ! ! btnOk.setName("btnOK"); ! panel.add(btnOk); ! btnOk.setText("OK"); ! ! final JButton btnCancel = new JButton(); ! btnCancel.setToolTipText("Cancel changes"); ! btnCancel.addActionListener(new ActionListener() { ! public void actionPerformed(ActionEvent e) { ! cancelButton(); ! } ! }); ! btnCancel.setName("btnCancel"); ! panel.add(btnCancel); ! btnCancel.setText("Cancel"); ! this.getRootPane().setDefaultButton(btnOk); ! this.setDefaultCloseOperation(JDialog.EXIT_ON_CLOSE); ! this.setLocationRelativeTo(null); ! this.setModal(true); ! this.setVisible(true); ! ! } ! ! private void initGUI(Object nodeArray[], int selectedIndex) { ! try { ! setSize(350, 225); ! { ! backpanel = new JPanel(); ! backpanel.setMinimumSize(new Dimension(200, 10)); ! this.getContentPane().add(backpanel, BorderLayout.CENTER); ! GridBagLayout backpanelLayout = new GridBagLayout(); ! backpanel.setPreferredSize(new java.awt.Dimension(264, 213)); ! backpanelLayout.columnWeights = new double[] {}; ! backpanelLayout.columnWidths = new int[] {}; ! backpanelLayout.rowWeights = new double[] {0.0}; ! backpanelLayout.rowHeights = new int[] {5,5,5,5}; ! backpanel.setLayout(backpanelLayout); ! { ! lblNodeName = new JLabel(); ! backpanel.add(lblNodeName, new GridBagConstraints( ! 0, ! 0, ! 1, ! 1, ! 0.0, ! 1.0, ! GridBagConstraints.LINE_END, ! GridBagConstraints.HORIZONTAL, ! new Insets(0, 0, 0, 0), ! 21, ! 0)); ! lblNodeName.setText("Node Name:"); ! } ! { ! lblInterface = new JLabel(); ! backpanel.add(lblInterface, new GridBagConstraints( ! 0, ! 1, ! 1, ! 1, ! 0.0, ! 1.0, ! GridBagConstraints.LINE_END, ! GridBagConstraints.HORIZONTAL, ! new Insets(0, 0, 0, 27), ! 0, ! 0)); ! lblInterface.setText("Interface:"); ! } ! ! cmbNodeName = new JComboBox(nodeArray); ! cmbNodeName.setMinimumSize(new Dimension(100, 0)); ! cmbNodeName.setSelectedIndex(selectedIndex); ! cmbNodeName.addActionListener(new ActionListener() { ! public void actionPerformed(ActionEvent e) { ! selectNode(); ! } ! }); ! final GridBagConstraints gridBagConstraints = new GridBagConstraints(); ! gridBagConstraints.fill = GridBagConstraints.HORIZONTAL; ! gridBagConstraints.anchor = GridBagConstraints.LINE_START; ! gridBagConstraints.gridy = 0; ! gridBagConstraints.gridx = 1; ! backpanel.add(cmbNodeName, gridBagConstraints); ! ! cmbInterface = new JComboBox(); ! cmbInterface.addActionListener(new ActionListener() { ! public void actionPerformed(ActionEvent e) { ! selectInterface(); ! } ! }); ! cmbInterface.setEnabled(false); ! ! final GridBagConstraints gridBagConstraints_1 = new GridBagConstraints(); ! gridBagConstraints_1.fill = GridBagConstraints.HORIZONTAL; ! gridBagConstraints_1.anchor = GridBagConstraints.LINE_START; ! gridBagConstraints_1.gridy = 1; ! gridBagConstraints_1.gridx = 1; ! backpanel.add(cmbInterface, gridBagConstraints_1); ! ! lblError = new JLabel(); ! lblError.setHorizontalTextPosition(SwingConstants.CENTER); ! lblError.setHorizontalAlignment(SwingConstants.CENTER); ! lblError.setAlignmentX(Component.CENTER_ALIGNMENT); ! lblError.setMinimumSize(new Dimension(100, 20)); ! lblError.setMaximumSize(new Dimension(100, 20)); ! lblError.setPreferredSize(new Dimension(100, 20)); ! lblError.setVisible(false); ! final GridBagConstraints gridBagConstraints_5 = new GridBagConstraints(); ! gridBagConstraints_5.anchor = GridBagConstraints.WEST; ! gridBagConstraints_5.insets = new Insets(0, 1, 0, 0); ! gridBagConstraints_5.fill = GridBagConstraints.BOTH; ! gridBagConstraints_5.gridwidth = 2; ! gridBagConstraints_5.gridy = 5; ! gridBagConstraints_5.gridx = 0; ! backpanel.add(lblError, gridBagConstraints_5); ! lblError.setText("Error Message!!!! Error"); ! ! ! if(selectedIndex == 0){ ! selectNode(); ! } ! ! } ! } catch (Exception e) { ! e.printStackTrace(); ! } ! } ! ! /** ! * This method is executed when the user hit's the enter button. ! * It will delete the link on selected interface. ! * ! * @author Key ! * ! */ ! private void okButton(){ ! try { ! ! if(NodeName != null && Interface != null){ ! String str = Sim.disconnectLink(NodeName, Interface); ! SBox.removeLine(str); ! controller.addToConsole(NodeName +"'s link on interface "+Interface+" has been disconnected!\n"); ! ! } ! ! ! this.dispose(); ! } catch (Exception e) { ! e.printStackTrace(); ! } ! } ! ! /** ! * This method is executed when the user hits the cancel button ! * @author luke_hamilton ! * @author Key ! * ! */ ! private void cancelButton(){ ! this.dispose(); ! } ! ! /** ! * This method will generate the data within the Interface combobox based ! * on the node that is selected. It will also get the default gateway if there is one set ! * for the node and add the text to the text field ! * ! * @author luke_hamilton ! * @author Key ! * ! */ ! private void selectNode(){ ! ! //Remove all items before regenerating the combobox. ! //This is because if a users selects the node twice, it would add the interfaces twice. ! cmbInterface.removeAllItems(); ! ! NodeName = (String)cmbNodeName.getSelectedItem(); ! ! try { ! Object nics[] = Sim.getAllInterfaces(NodeName); //Get object array of interface names ! ! //Sort the array ! Arrays.sort(nics); ! ! for (int i = 0; i < nics.length; i++) { //Add them to the combobox ! cmbInterface.addItem(nics[i]); ! } ! cmbInterface.setEnabled(true); ! ! } catch (Exception e) { //This should never happen ! e.printStackTrace(); ! } ! } ! ! /** ! * This method enabled's the IP Address text field once the interface has been selected. ! * This will also check the selected interface to see if the ip address has already been set ! * if so entering that ip address into the text field and then getting the set subnet mask for that ! * ip address. ! * @author Key ! */ ! private void selectInterface(){ ! Interface = (String)cmbInterface.getSelectedItem(); ! } ! ! } --- 1,310 ---- ! /* ! Java Firewall Simulator (jFirewallSim) ! ! Copyright (c) 2004, jFirewallSim development team All rights reserved. ! ! Redistribution and use in source and binary forms, with or without modification, are ! permitted provided that the following conditions are met: ! ! - Redistributions of source code must retain the above copyright notice, this list ! of conditions and the following disclaimer. ! - Redistributions in binary form must reproduce the above copyright notice, this list ! of conditions and the following disclaimer in the documentation and/or other ! materials provided with the distribution. ! - Neither the name of the Canberra Institute of Technology nor the names of its ! contributors may be used to endorse or promote products derived from this software ! without specific prior written permission. ! ! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY ! EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ! OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ! THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, ! EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF ! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ! HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR ! TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, ! EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ! */ ! ! ! package guiUI; ! ! import javax.swing.JFrame; ! import javax.swing.JPanel; ! import java.awt.GridBagLayout; ! import javax.swing.JDialog; ! import javax.swing.JLabel; ! import javax.swing.JTextField; ! import java.awt.Insets; ! import java.awt.GridBagConstraints; ! import java.awt.BorderLayout; ! import javax.swing.JButton; ! import java.awt.Dimension; ! import java.awt.event.ActionListener; ! import java.awt.event.ActionEvent; ! import javax.swing.JComboBox; ! import core.Simulation; ! import java.awt.event.MouseAdapter; ! import java.awt.event.MouseEvent; ! import java.awt.Color; ! import java.awt.event.KeyAdapter; ! import java.awt.event.KeyEvent; ! import java.awt.event.FocusAdapter; ! import java.awt.event.FocusEvent; ! import java.util.Arrays; ! import java.awt.Component; ! import javax.swing.SwingConstants; ! ! /** ! * ! * @author Key ! * ! * This class is a dialog that enables to remove links from the devices ! * ! */ ! public class breakLinkDialog extends javax.swing.JDialog { ! private JPanel backpanel; ! private JLabel lblInterface; ! private JLabel lblNodeName; ! private JComboBox cmbNodeName; ! private JComboBox cmbInterface; ! private JLabel lblError; ! private JButton btnOk; ! ! private MainScreen controller; ! private Simulation Sim; ! private SandBox SBox; ! ! private String NodeName; ! private String Interface; ! ! private boolean ErrorFlag = true; ! ! public breakLinkDialog(JFrame frame, Object nodeArray[], int selectedIndex, Simulation Sim, SandBox SBox) { ! super(frame); ! setResizable(false); ! controller = (MainScreen)frame; ! this.Sim = Sim; ! this.SBox = SBox; ! setTitle("Break link"); ! initGUI(nodeArray,selectedIndex); ! ! final JPanel panel = new JPanel(); ! getContentPane().add(panel, BorderLayout.SOUTH); ! ! btnOk = new JButton(); ! btnOk.setEnabled(true); ! btnOk.setToolTipText("Disconnect selected link!"); ! btnOk.addActionListener(new ActionListener() { ! public void actionPerformed(ActionEvent e) { ! okButton(); ! } ! }); ! ! btnOk.setName("btnOK"); ! panel.add(btnOk); ! btnOk.setText("OK"); ! ! final JButton btnCancel = new JButton(); ! btnCancel.setToolTipText("Cancel changes"); ! btnCancel.addActionListener(new ActionListener() { ! public void actionPerformed(ActionEvent e) { ! cancelButton(); ! } ! }); ! btnCancel.setName("btnCancel"); ! panel.add(btnCancel); ! btnCancel.setText("Cancel"); ! this.getRootPane().setDefaultButton(btnOk); ! this.setDefaultCloseOperation(JDialog.EXIT_ON_CLOSE); ! this.setLocationRelativeTo(null); ! this.setModal(true); ! this.setVisible(true); ! ! } ! ! private void initGUI(Object nodeArray[], int selectedIndex) { ! try { ! setSize(350, 225); ! { ! backpanel = new JPanel(); ! backpanel.setMinimumSize(new Dimension(200, 10)); ! this.getContentPane().add(backpanel, BorderLayout.CENTER); ! GridBagLayout backpanelLayout = new GridBagLayout(); ! backpanel.setPreferredSize(new java.awt.Dimension(264, 213)); ! backpanelLayout.columnWeights = new double[] {}; ! backpanelLayout.columnWidths = new int[] {}; ! backpanelLayout.rowWeights = new double[] {0.0}; ! backpanelLayout.rowHeights = new int[] {5,5,5,5}; ! backpanel.setLayout(backpanelLayout); ! { ! lblNodeName = new JLabel(); ! backpanel.add(lblNodeName, new GridBagConstraints( ! 0, ! 0, ! 1, ! 1, ! 0.0, ! 1.0, ! GridBagConstraints.LINE_END, ! GridBagConstraints.HORIZONTAL, ! new Insets(0, 0, 0, 0), ! 21, ! 0)); ! lblNodeName.setText("Node Name:"); ! } ! { ! lblInterface = new JLabel(); ! backpanel.add(lblInterface, new GridBagConstraints( ! 0, ! 1, ! 1, ! 1, ! 0.0, ! 1.0, ! GridBagConstraints.LINE_END, ! GridBagConstraints.HORIZONTAL, ! new Insets(0, 0, 0, 27), ! 0, ! 0)); ! lblInterface.setText("Interface:"); ! } ! ! cmbNodeName = new JComboBox(nodeArray); ! cmbNodeName.setMinimumSize(new Dimension(100, 0)); ! cmbNodeName.setSelectedIndex(selectedIndex); ! cmbNodeName.addActionListener(new ActionListener() { ! public void actionPerformed(ActionEvent e) { ! selectNode(); ! } ! }); ! final GridBagConstraints gridBagConstraints = new GridBagConstraints(); ! gridBagConstraints.fill = GridBagConstraints.HORIZONTAL; ! gridBagConstraints.anchor = GridBagConstraints.LINE_START; ! gridBagConstraints.gridy = 0; ! gridBagConstraints.gridx = 1; ! backpanel.add(cmbNodeName, gridBagConstraints); ! ! cmbInterface = new JComboBox(); ! cmbInterface.addActionListener(new ActionListener() { ! public void actionPerformed(ActionEvent e) { ! selectInterface(); ! } ! }); ! cmbInterface.setEnabled(false); ! ! final GridBagConstraints gridBagConstraints_1 = new GridBagConstraints(); ! gridBagConstraints_1.fill = GridBagConstraints.HORIZONTAL; ! gridBagConstraints_1.anchor = GridBagConstraints.LINE_START; ! gridBagConstraints_1.gridy = 1; ! gridBagConstraints_1.gridx = 1; ! backpanel.add(cmbInterface, gridBagConstraints_1); ! ! lblError = new JLabel(); ! lblError.setHorizontalTextPosition(SwingConstants.CENTER); ! lblError.setHorizontalAlignment(SwingConstants.CENTER); ! lblError.setAlignmentX(Component.CENTER_ALIGNMENT); ! lblError.setMinimumSize(new Dimension(100, 20)); ! lblError.setMaximumSize(new Dimension(100, 20)); ! lblError.setPreferredSize(new Dimension(100, 20)); ! lblError.setVisible(false); ! final GridBagConstraints gridBagConstraints_5 = new GridBagConstraints(); ! gridBagConstraints_5.anchor = GridBagConstraints.WEST; ! gridBagConstraints_5.insets = new Insets(0, 1, 0, 0); ! gridBagConstraints_5.fill = GridBagConstraints.BOTH; ! gridBagConstraints_5.gridwidth = 2; ! gridBagConstraints_5.gridy = 5; ! gridBagConstraints_5.gridx = 0; ! backpanel.add(lblError, gridBagConstraints_5); ! lblError.setText("Error Message!!!! Error"); ! ! ! if(selectedIndex == 0){ ! selectNode(); ! } ! ! } ! } catch (Exception e) { ! e.printStackTrace(); ! } ! } ! ! /** ! * This method is executed when the user hit's the enter button. ! * It will delete the link on selected interface. ! * ! * @author Key ! * ! */ ! private void okButton(){ ! try { ! ! if(NodeName != null && Interface != null){ ! String str = Sim.disconnectLink(NodeName, Interface); ! SBox.removeLine(str); ! controller.addToConsole(NodeName +"'s link on interface "+Interface+" has been disconnected!\n"); ! ! } ! ! ! this.dispose(); ! } catch (Exception e) { ! e.printStackTrace(); ! } ! } ! ! /** ! * This method is executed when the user hits the cancel button ! * @author luke_hamilton ! * @author Key ! * ! */ ! private void cancelButton(){ ! this.dispose(); ! } ! ! /** ! * This method will generate the data within the Interface combobox based ! * on the node that is selected. It will also get the default gateway if there is one set ! * for the node and add the text to the text field ! * ! * @author luke_hamilton ! * @author Key ! * ! */ ! private void selectNode(){ ! ! //Remove all items before regenerating the combobox. ! //This is because if a users selects the node twice, it would add the interfaces twice. ! cmbInterface.removeAllItems(); ! ! NodeName = (String)cmbNodeName.getSelectedItem(); ! ! try { ! Object nics[] = Sim.getAllInterfaces(NodeName); //Get object array of interface names ! ! //Sort the array ! Arrays.sort(nics); ! ! for (int i = 0; i < nics.length; i++) { //Add them to the combobox ! cmbInterface.addItem(nics[i]); ! } ! cmbInterface.setEnabled(true); ! ! } catch (Exception e) { //This should never happen ! e.printStackTrace(); ! } ! } ! ! /** ! * This method enabled's the IP Address text field once the interface has been selected. ! * This will also check the selected interface to see if the ip address has already been set ! * if so entering that ip address into the text field and then getting the set subnet mask for that ! * ip address. ! * @author Key ! */ ! private void selectInterface(){ ! Interface = (String)cmbInterface.getSelectedItem(); ! } ! ! } Index: DataLinkLayerDevice.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/guiUI/DataLinkLayerDevice.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** DataLinkLayerDevice.java 23 Feb 2006 11:56:00 -0000 1.2 --- DataLinkLayerDevice.java 13 Sep 2007 13:38:52 -0000 1.3 *************** *** 1,99 **** ! /* ! Java Firewall Simulator (jFirewallSim) ! ! Copyright (c) 2004, jFirewallSim development team All rights reserved. ! ! Redistribution and use in source and binary forms, with or without modification, are ! permitted provided that the following conditions are met: ! ! - Redistributions of source code must retain the above copyright notice, this list ! of conditions and the following disclaimer. ! - Redistributions in binary form must reproduce the above copyright notice, this list ! of conditions and the following disclaimer in the documentation and/or other ! materials provided with the distribution. ! - Neither the name of the Canberra Institute of Technology nor the names of its ! contributors may be used to endorse or promote products derived from this software ! without specific prior written permission. ! ! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY ! EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ! OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ! THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, ! EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF ! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ! HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR ! TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, ! EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ! */ ! package guiUI; ! ! import java.awt.event.ActionEvent; ! ! import java.awt.event.ActionListener; ! ! import javax.swing.JMenuItem; ! ! /** ! * <P>The DataLinkLayerDevice class is an abstract class used for further classification of Data </P> ! * <P>link layer devices such as Hub's and Switches. ! * ! * @author VC2 Team. ! * @since 15th November 2004 ! * @version v0.20 ! */ ! ! public abstract class DataLinkLayerDevice extends GuiNode { ! ! private JMenuItem mnuProperties = new JMenuItem("Properties ..."); ! private JMenuItem mnuShowState = new JMenuItem("Show state"); ! private JMenuItem mnuReset = new JMenuItem("Reset"); ! private JMenuItem mnuLink = new JMenuItem("Links properties"); ! private JMenuItem mnuBreakLink = new JMenuItem("Break link"); ! ! ! /** ! * @param inName The name of the Data Link Layer Device ! * @param inMainscreen The JFrame that the router will be created on ! * @param imageLocation Location of the Image used on the GUI ! */ ! ! public DataLinkLayerDevice(String inName, MainScreen inMainScreen, String imageLocation) { ! super(inName, inMainScreen, imageLocation); ! ! mnuProperties.addActionListener(new ActionListener(){ ! public void actionPerformed(ActionEvent e){ ! controller.showPropertiesDialog(lblNodeName.getText()); ! } ! }); ! mnuBreakLink.addActionListener(new ActionListener(){ ! public void actionPerformed(ActionEvent e){ ! controller.showBreakLinkDialog(lblNodeName.getText()); ! } ! }); ! ! mnuReset.addActionListener(new ActionListener(){ ! public void actionPerformed(ActionEvent e){ ! controller.ResetHub(lblNodeName.getText()); ! } ! }); ! ! mnuShowState.addActionListener(new ActionListener(){ ! public void actionPerformed(ActionEvent e){ ! controller.ShowHubState(lblNodeName.getText()); ! } ! }); ! ! mnuLink.addActionListener(new ActionListener(){ ! public void actionPerformed(ActionEvent e){ ! controller.showLinkDialog(lblNodeName.getText()); ! } ! }); ! ! ! GuiNodePopMenu.add(mnuProperties); ! GuiNodePopMenu.add(mnuShowState); ! GuiNodePopMenu.add(mnuReset); ! GuiNodePopMenu.add(mnuLink); ! GuiNodePopMenu.add(mnuBreakLink); ! } ! } --- 1,99 ---- ! /* ! Java Firewall Simulator (jFirewallSim) ! ! Copyright (c) 2004, jFirewallSim development team All rights reserved. ! ! Redistribution and use in source and binary forms, with or without modification, are ! permitted provided that the following conditions are met: ! ! - Redistributions of source code must retain the above copyright notice, this list ! of conditions and the following disclaimer. ! - Redistributions in binary form must reproduce the above copyright notice, this list ! of conditions and the following disclaimer in the documentation and/or other ! materials provided with the distribution. ! - Neither the name of the Canberra Institute of Technology nor the names of its ! contributors may be used to endorse or promote products derived from this software ! without specific prior written permission. ! ! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY ! EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ! OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ! THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, ! EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF ! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ! HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR ! TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, ! EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ! */ ! package guiUI; ! ! import java.awt.event.ActionEvent; ! ! import java.awt.event.ActionListener; ! ! import javax.swing.JMenuItem; ! ! /** ! * <P>The DataLinkLayerDevice class is an abstract class used for further classification of Data </P> ! * <P>link layer devices such as Hub's and Switches. ! * ! * @author VC2 Team. ! * @since 15th November 2004 ! * @version v0.20 ! */ ! ! public abstract class DataLinkLayerDevice extends GuiNode { ! ! private JMenuItem mnuProperties = new JMenuItem("Properties ..."); ! private JMenuItem mnuShowState = new JMenuItem("Show state"); ! private JMenuItem mnuReset = new JMenuItem("Reset"); ! private JMenuItem mnuLink = new... [truncated message content] |