[Javanetsim-cvs] javaNetSim/guiUI LinkDialog.java, 1.2, 1.3 MainScreen.java, 1.55, 1.56 MenuBar.jav
Status: Beta
Brought to you by:
darkkey
From: gift <gi...@us...> - 2007-09-15 11:35:12
|
Update of /cvsroot/javanetsim/javaNetSim/guiUI In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv4186/guiUI Modified Files: LinkDialog.java MainScreen.java MenuBar.java PingDialog.java Log Message: HTML generation pattern added. Console HTML generation done. Some depricated methods replaced. Color usage optimized. Index: MainScreen.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/guiUI/MainScreen.java,v retrieving revision 1.55 retrieving revision 1.56 diff -C2 -d -r1.55 -r1.56 *** MainScreen.java 14 Sep 2007 15:30:08 -0000 1.55 --- MainScreen.java 15 Sep 2007 11:34:58 -0000 1.56 *************** *** 214,218 **** private Hashtable GUInodeTable = new Hashtable(); ! //The File chooser class --- 214,224 ---- private Hashtable GUInodeTable = new Hashtable(); ! //Colors for console output ! private Color NETWORK_LAYER_COLOR = Color.CYAN; ! private Color LINK_LAYER_COLOR = Color.YELLOW; ! private Color TRANSPORT_LAYER_COLOR = Color.LIGHT_GRAY; ! private Color APPLICATION_LAYER_COLOR = Color.GREEN; ! private Color HARDWARE_LAYER_COLOR = Color.ORANGE; ! private Color SYSTEM_LAYER_COLOR = Color.RED ; //The File chooser class *************** *** 554,566 **** mConsole.setColumnIdentifiers(new Object[]{"Time","Node","Packet","Layer","Info"}); ! pnlConsole.getColumnModel().getColumn(0).setMaxWidth(100); ! pnlConsole.getColumnModel().getColumn(0).setMinWidth(100); ! pnlConsole.getColumnModel().getColumn(1).setMaxWidth(100); ! pnlConsole.getColumnModel().getColumn(1).setMinWidth(100); ! pnlConsole.getColumnModel().getColumn(2).setMaxWidth(200); ! pnlConsole.getColumnModel().getColumn(2).setMinWidth(200); ! pnlConsole.getColumnModel().getColumn(3).setMaxWidth(100); ! pnlConsole.getColumnModel().getColumn(3).setMinWidth(100); ! pnlConsole.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS); } --- 560,579 ---- mConsole.setColumnIdentifiers(new Object[]{"Time","Node","Packet","Layer","Info"}); ! // pnlConsole.getColumnModel().getColumn(0).setMaxWidth(100); ! // pnlConsole.getColumnModel().getColumn(0).setMinWidth(100); ! // pnlConsole.getColumnModel().getColumn(1).setMaxWidth(100); ! // pnlConsole.getColumnModel().getColumn(1).setMinWidth(100); ! // pnlConsole.getColumnModel().getColumn(2).setMaxWidth(200); ! // pnlConsole.getColumnModel().getColumn(2).setMinWidth(200); ! // pnlConsole.getColumnModel().getColumn(3).setMaxWidth(100); ! // pnlConsole.getColumnModel().getColumn(3).setMinWidth(100); ! ! // pnlConsole.getColumnModel().getColumn(0).sizeWidthToFit(); ! // pnlConsole.getColumnModel().getColumn(1).sizeWidthToFit(); ! // pnlConsole.getColumnModel().getColumn(2).sizeWidthToFit(); ! // pnlConsole.getColumnModel().getColumn(3).sizeWidthToFit(); ! // pnlConsole.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS); ! ! } *************** *** 1122,1126 **** dlgLink.setTitle("Create Link between " + inNode1 + " and " + inNode2 + "?"); ! dlgLink.show(); --- 1135,1140 ---- dlgLink.setTitle("Create Link between " + inNode1 + " and " + inNode2 + "?"); ! //dlgLink.show(); ! dlgLink.setVisible(true); *************** *** 1278,1282 **** dlgSendPing.setTitle("Send ping from " + inNodeName +" to ..."); ! dlgSendPing.show(); --- 1292,1297 ---- dlgSendPing.setTitle("Send ping from " + inNodeName +" to ..."); ! //dlgSendPing.show(); ! dlgSendPing.setVisible(true); *************** *** 1357,1375 **** return sdf.format(cal.getTime()); } ! public void insertInConsole(String Node, String Packet, String Layer, String Info){ mConsole.insertRow(mConsole.getRowCount(), new Object[]{now(), Node,Packet,Layer,Info}); ! if(Layer.contains("Network")){ ! colorRenderer.setRowColor(mConsole.getRowCount() - 1, Color.CYAN); }else if(Layer.contains("Link")){ ! colorRenderer.setRowColor(mConsole.getRowCount() - 1, Color.YELLOW); }else if(Layer.contains("Transport")){ ! colorRenderer.setRowColor(mConsole.getRowCount() - 1, Color.LIGHT_GRAY); }else if(Layer.contains("Application")){ ! colorRenderer.setRowColor(mConsole.getRowCount() - 1, Color.GREEN); }else if(Layer.contains("Hardware")){ ! colorRenderer.setRowColor(mConsole.getRowCount() - 1, Color.ORANGE); }else if(Layer.contains("*SYSTEM*")){ ! colorRenderer.setRowColor(mConsole.getRowCount() - 1, Color.RED); } --- 1372,1390 ---- return sdf.format(cal.getTime()); } ! public void insertInConsole(String Node, String Packet, String Layer, String Info){ mConsole.insertRow(mConsole.getRowCount(), new Object[]{now(), Node,Packet,Layer,Info}); ! if(Layer.contains("Network")){ ! colorRenderer.setRowColor(mConsole.getRowCount() - 1, this.NETWORK_LAYER_COLOR); }else if(Layer.contains("Link")){ ! colorRenderer.setRowColor(mConsole.getRowCount() - 1, this.LINK_LAYER_COLOR); }else if(Layer.contains("Transport")){ ! colorRenderer.setRowColor(mConsole.getRowCount() - 1, this.TRANSPORT_LAYER_COLOR); }else if(Layer.contains("Application")){ ! colorRenderer.setRowColor(mConsole.getRowCount() - 1, this.APPLICATION_LAYER_COLOR); }else if(Layer.contains("Hardware")){ ! colorRenderer.setRowColor(mConsole.getRowCount() - 1, this.HARDWARE_LAYER_COLOR); }else if(Layer.contains("*SYSTEM*")){ ! colorRenderer.setRowColor(mConsole.getRowCount() - 1, this.SYSTEM_LAYER_COLOR); } *************** *** 1464,1468 **** dlgNodeProperties.setTitle("Properties for " + inNodeName); ! dlgNodeProperties.show(); }catch(Exception ufe){ --- 1479,1484 ---- dlgNodeProperties.setTitle("Properties for " + inNodeName); ! //dlgNodeProperties.show(); ! dlgNodeProperties.setVisible(true); }catch(Exception ufe){ *************** *** 2810,2827 **** /** - * Clears the Console. - * - */ - - - public void clearConsole() - { mConsole.setRowCount(0); } --- 2826,2906 ---- /** * Clears the Console. * */ public void clearConsole() { mConsole.setRowCount(0); } + + /** + * Generates HTML code from text in console. + * + */ + public StringBuffer generate_html_console_out(){ + + int i,j; + int clr = 0xFFFFFF; + int mask = 0xFFFFFF; + StringBuffer out = new StringBuffer(65536); + String cur; + boolean color_selected = false; + + if (mConsole.getColumnCount()>0 && mConsole.getRowCount()>0) + { + out.append("<TABLE align=\"center\" cellSpacing=\"0\" cellPadding=\"0\" width=\"100%\" border=\"0\" style='border:solid windowtext 1.0pt;'>\r\n<TR bgColor=#FFFFFF>"); + //Form table header + for (i=0; i<mConsole.getColumnCount(); i++) + { + out.append("<TD>" + mConsole.getColumnName(i) + "</TD>"); + } + out.append("</TR>\r\n<!-- main console output body -->\r\n\r\n"); + + + //Form table body + for (j=0; j<mConsole.getRowCount(); j++) + { + color_selected = false; + cur = ""; + + //add table row + for (i=0; i<mConsole.getColumnCount(); i++) + { + cur += "<TD vAlign=\"top\">" + (String) mConsole.getValueAt(j,i) + "</TD>"; + //Select TR bgColor. + if (!color_selected) + { + if(cur.contains("Network")){ + clr = NETWORK_LAYER_COLOR.getRGB(); + color_selected = true; + }else if(cur.contains("Link")){ + clr = LINK_LAYER_COLOR.getRGB(); + color_selected = true; + }else if(cur.contains("Transport")){ + clr = TRANSPORT_LAYER_COLOR.getRGB(); + color_selected = true; + }else if(cur.contains("Application")){ + clr = APPLICATION_LAYER_COLOR.getRGB(); + color_selected = true; + }else if(cur.contains("Hardware")){ + clr = HARDWARE_LAYER_COLOR.getRGB(); + color_selected = true; + }else if(cur.contains("*SYSTEM*")){ + clr = SYSTEM_LAYER_COLOR.getRGB(); + color_selected = true; + } + } + } + //Integer.toHexString(clr).toUpperCase() + out.append("<TR bgColor=#" + String.format("%06X", clr & mask) + ">\r\n" + cur + "\r\n</TR>\r\n"); + } + out.append("</TABLE>\r\n<!-- main console output body end -->\r\n\r\n"); + } else + { + out.append("<BR />Nothing to show in simulation transactions.<BR />"); + } + + return out; + } *************** *** 3087,3095 **** help.setLocationRelativeTo(null); ! help.show(); } public void clearSaveAs() --- 3166,3183 ---- help.setLocationRelativeTo(null); ! //help.show(); ! help.setVisible(true); } + /** + * Generates HTML report of the simulation + * + */ + public void generate_html_report() + { + this.addToConsole(generate_html_console_out().toString()); + } public void clearSaveAs() *************** *** 3142,3145 **** --- 3230,3234 ---- { + this.setAllHighlightsOff(); *************** *** 3179,3185 **** return true; ! ! ! } --- 3268,3272 ---- return true; ! } Index: PingDialog.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/guiUI/PingDialog.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** PingDialog.java 13 Sep 2007 13:38:52 -0000 1.2 --- PingDialog.java 15 Sep 2007 11:34:58 -0000 1.3 *************** *** 115,119 **** { wasOkPressed = true; ! this.hide(); } else --- 115,120 ---- { wasOkPressed = true; ! //this.hide(); ! this.setVisible(false); } else Index: MenuBar.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/guiUI/MenuBar.java,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** MenuBar.java 14 Sep 2007 15:30:08 -0000 1.13 --- MenuBar.java 15 Sep 2007 11:34:58 -0000 1.14 *************** *** 47,52 **** private JCheckBoxMenuItem mnuMsgTransport = new JCheckBoxMenuItem("Transport Layer",true); private JCheckBoxMenuItem mnuMsgApplication = new JCheckBoxMenuItem("Application Layer",true); ! ! //Add submenu private JMenu mnuAdd = new JMenu("Add"); //For Adding objects to simulation --- 47,53 ---- private JCheckBoxMenuItem mnuMsgTransport = new JCheckBoxMenuItem("Transport Layer",true); 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 *************** *** 91,95 **** private void buildMenu(){ ! mnuNew.setAccelerator(KeyStroke.getKeyStroke("ctrl N")); mnuOpen.setAccelerator(KeyStroke.getKeyStroke("ctrl O")); mnuSave.setAccelerator(KeyStroke.getKeyStroke("ctrl S")); --- 92,96 ---- private void buildMenu(){ ! mnuNew.setAccelerator(KeyStroke.getKeyStroke("ctrl N")); mnuOpen.setAccelerator(KeyStroke.getKeyStroke("ctrl O")); mnuSave.setAccelerator(KeyStroke.getKeyStroke("ctrl S")); *************** *** 98,101 **** --- 99,103 ---- mnuHub.setAccelerator(KeyStroke.getKeyStroke("ctrl H")); mnuSwitch.setAccelerator(KeyStroke.getKeyStroke("ctrl W")); + mnuGenRep.setAccelerator(KeyStroke.getKeyStroke("ctrl G")); mnuClearConsole.setAccelerator(KeyStroke.getKeyStroke("F3")); *************** *** 121,124 **** --- 123,127 ---- //Add items to simulation menu + mnuSimulation.add(mnuGenRep); mnuSimulation.add(mnuAdd); mnuAdd.add(mnuPC); *************** *** 170,173 **** --- 173,177 ---- mnuRouter.setMnemonic('R'); mnuHub.setMnemonic('H'); + mnuGenRep.setMnemonic('G'); //mnuSwitch.setMnemonic('S'); *************** *** 190,193 **** --- 194,205 ---- + + //Add action listener to generate html report menuitem + mnuGenRep.addActionListener(new ActionListener(){ + public void actionPerformed(ActionEvent e){ + controller.generate_html_report(); + } + }); + //Add action listener to new Pc menuitem mnuPC.addActionListener(new ActionListener(){ Index: LinkDialog.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/guiUI/LinkDialog.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** LinkDialog.java 13 Sep 2007 13:38:52 -0000 1.2 --- LinkDialog.java 15 Sep 2007 11:34:58 -0000 1.3 *************** *** 191,195 **** { wasOkPressed = true; ! this.hide(); } else --- 191,196 ---- { wasOkPressed = true; ! //this.hide(); ! this.setVisible(false); } else |