Thread: [Javanetsim-cvs] javaNetSim/guiUI Terminal.java,1.1,1.2
Status: Beta
Brought to you by:
darkkey
From: QweR <qw...@us...> - 2007-10-14 00:22:19
|
Update of /cvsroot/javanetsim/javaNetSim/guiUI In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv25590/guiUI Modified Files: Terminal.java Log Message: Some small bugs fixed Index: Terminal.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/guiUI/Terminal.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Terminal.java 12 Oct 2007 21:06:39 -0000 1.1 --- Terminal.java 14 Oct 2007 00:22:14 -0000 1.2 *************** *** 32,41 **** import core.CommandInterface; import core.Version; - import java.awt.event.ActionEvent; - import java.awt.event.KeyAdapter; import java.awt.event.KeyEvent; import javax.swing.JComponent; import core.Pair; import core.CommandProcessor; /** --- 32,43 ---- import core.CommandInterface; import core.Version; import java.awt.event.KeyEvent; import javax.swing.JComponent; import core.Pair; import core.CommandProcessor; + import java.awt.Toolkit; + import java.awt.event.FocusEvent; + import java.awt.event.FocusListener; + import javax.swing.SwingUtilities; /** *************** *** 58,62 **** private int current_mode; private int device_type; - private int current_config; private CommandProcessor cmdproc; --- 60,63 ---- *************** *** 78,83 **** current_mode = CommandsTree.STD_MODE; ! device_type = CommandsTree.APPLICATION_LAYER; ! current_config = DeviceConfig.RUNNING_CONFIG; cmdproc.add("clear terminal", clear_terminal_Command, cmdproc.STD_CONF_MODE | cmdproc.NETWORK_LAYER, "<cr>", "Clear screen"); --- 79,88 ---- current_mode = CommandsTree.STD_MODE; ! if(device.getClass().equals(ApplicationLayerDevice.class)){ ! device_type = CommandsTree.APPLICATION_LAYER; ! } ! else{ ! device_type = CommandsTree.NETWORK_LAYER; ! } cmdproc.add("clear terminal", clear_terminal_Command, cmdproc.STD_CONF_MODE | cmdproc.NETWORK_LAYER, "<cr>", "Clear screen"); *************** *** 100,126 **** panel.add(scrollpane, BorderLayout.CENTER); panel.setPreferredSize(new java.awt.Dimension(600,500)); ! scrollpane.setViewportView(terminal); terminal.setEnabled(true); terminal.setEditable(false); ! terminal.setFocusable(false); terminal.setBackground(Color.BLACK); terminal.setForeground(Color.WHITE); terminal.setFont(new Font("Courier New", Font.PLAIN, 12)); addToTerminal("javaNetSim console "+Version.CORE_VERSION+", "+Version.YEARS); - - cmdline.setVisible(true); - cmdline.setEnabled(true); - cmdline.setFocusable(true); - cmdline.setFocusCycleRoot(true); - cmdline.setFocusTraversalKeysEnabled(false); - cmdline.setInputVerifier(cmdverifier); ! cmdline.addKeyListener(cmdverifier); ! this.addWindowListener( new java.awt.event.WindowAdapter() { public void windowClosing(WindowEvent winEvt) { printInfo(); } }); } --- 105,137 ---- panel.add(scrollpane, BorderLayout.CENTER); panel.setPreferredSize(new java.awt.Dimension(600,500)); ! ! cmdline.setVisible(true); ! cmdline.setEnabled(true); ! cmdline.setFocusable(true); ! cmdline.setFocusCycleRoot(true); ! cmdline.setFocusTraversalKeysEnabled(false); ! cmdline.setInputVerifier(cmdverifier); ! cmdline.requestFocus(); ! cmdline.addKeyListener(cmdverifier); ! scrollpane.setViewportView(terminal); terminal.setEnabled(true); terminal.setEditable(false); ! //terminal.setFocusable(false); terminal.setBackground(Color.BLACK); terminal.setForeground(Color.WHITE); terminal.setFont(new Font("Courier New", Font.PLAIN, 12)); addToTerminal("javaNetSim console "+Version.CORE_VERSION+", "+Version.YEARS); ! this.pack(); ! cmdline.requestFocusInWindow(); ! this.addWindowListener( new java.awt.event.WindowAdapter() { public void windowClosing(WindowEvent winEvt) { printInfo(); } + public void windowGainedFocus(WindowEvent e) { + cmdline.requestFocusInWindow(); + } }); } *************** *** 344,348 **** String compl_str = cmdproc.complete(cmdline.getText().substring(0,caretPos), current_mode | device_type); //String last_str = cmdline.getText().substring(caretPos); ! if(compl_str!=null){ cmdline.setText(compl_str+" "); //cmdline.setText(compl_str+last_str); --- 355,359 ---- String compl_str = cmdproc.complete(cmdline.getText().substring(0,caretPos), current_mode | device_type); //String last_str = cmdline.getText().substring(caretPos); ! if(compl_str!=null && !compl_str.endsWith(" ")){ cmdline.setText(compl_str+" "); //cmdline.setText(compl_str+last_str); *************** *** 450,454 **** class configure_terminal_CommandClass implements CommandInterface{ public String call(Vector<String> params){ ! current_config = DeviceConfig.RUNNING_CONFIG; current_mode = cmdproc.CONF_MODE; return ""; --- 461,465 ---- class configure_terminal_CommandClass implements CommandInterface{ public String call(Vector<String> params){ ! device.getConfig().working_config = DeviceConfig.RUNNING_CONFIG; current_mode = cmdproc.CONF_MODE; return ""; *************** *** 457,461 **** class configure_replace_CommandClass implements CommandInterface{ public String call(Vector<String> params){ ! current_config = DeviceConfig.RUNNING_CONFIG; current_mode = cmdproc.CONF_MODE; return "Running-config was erased"; --- 468,472 ---- class configure_replace_CommandClass implements CommandInterface{ public String call(Vector<String> params){ ! device.getConfig().working_config = DeviceConfig.RUNNING_CONFIG; current_mode = cmdproc.CONF_MODE; return "Running-config was erased"; *************** *** 464,468 **** class configure_memory_CommandClass implements CommandInterface{ public String call(Vector<String> params){ ! current_config = DeviceConfig.STARTUP_CONFIG; current_mode = cmdproc.CONF_MODE; return "Starting-config editing"; --- 475,479 ---- class configure_memory_CommandClass implements CommandInterface{ public String call(Vector<String> params){ ! device.getConfig().working_config = DeviceConfig.STARTUP_CONFIG; current_mode = cmdproc.CONF_MODE; return "Starting-config editing"; *************** *** 473,476 **** --- 484,488 ---- if(current_mode == cmdproc.CONF_MODE){ current_mode = cmdproc.STD_MODE; + device.getConfig().working_config = DeviceConfig.RUNNING_CONFIG; } else if(current_mode == cmdproc.STD_MODE){ *************** *** 518,523 **** public String call(Vector<String> params){ String out = ""; ! for(int i=0; i<params.size(); i++){ ! out += params.get(i) + "\n"; } return out; --- 530,535 ---- public String call(Vector<String> params){ String out = ""; ! for(int i=0; i<history.size(); i++){ ! out += history.get(i) + "\n"; } return out; |